1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Double Chest

Discussion in 'Development' started by Teamblocket, Jan 22, 2018.

  1. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    Hey, How can i create a double chest, here is my previous attempt
    PHP:
                                                $tile Tile::createTile(Tile::CHEST$player->getLevel(), new CompoundTag("", [
                                                    new 
    StringTag("id"Tile::CHEST),
                                                    new 
    StringTag("CustomName"'test name ' ucfirst($data['name']) . ' !'),
                                                    new 
    IntTag("x", (int)$player->x),
                                                    new 
    IntTag("y", (int)$player->2),
                                                    new 
    IntTag("z", (int)$player->z),
                                                    new 
    IntTag('one'1)
                                                ]));
                                                
    $tile2 Tile::createTile(Tile::CHEST$player->getLevel(), new CompoundTag("", [
                                                    new 
    StringTag("id"Tile::CHEST),
                                                    new 
    StringTag("CustomName"'test name ' ucfirst($data['name']) . ' !'),
                                                    new 
    IntTag("x", (int)$player->x),
                                                    new 
    IntTag("y", (int)$player->2),
                                                    new 
    IntTag("z", (int)$player->z),
                                                    new 
    IntTag('one'1)
                                                ]));
                                                
    $tile->pairWith($tile2);
                                                
    $tile2->pairWith($tile);
                                                
    $block Block::get(Block::CHEST0$tile);
                                                
    $block2 Block::get(Block::CHEST0$tile2);
                                                
    $block->level->sendBlocks([$player], [$block$block2]);

                                                
    $player->addWindow($tile->getInventory());
    i get an error to
    Code:
    22.01 23:20:11 [Server] Server thread/CRITICAL Error: "Call to a member function hasTag() on null" (EXCEPTION) in "src/pocketmine/tile/Chest" at line 131
     
  2. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    I've fixed the error, i added + 1 to the x on one of the tiles, but now the inv only popups for like a second and its a normal chest inv.
     
  3. Derpific

    Derpific Spider Jockey

    Messages:
    44
    GitHub:
    Derpific
    Use a task to keep the tile, seemed to fix for me
     
    xXNiceAssassinlo YT and Muqsit like this.
  4. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    You need to cause a bit of delay after sending the tiles and blocks to the client. You need to send the inventory after around 0.2 seconds. There should be an instantaneous method because in vanilla, this is 100% instantaneous. The more the player's ping, the lesser can be the delay.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.