Hi, I apologize in advance for my English. I'm trying to make inventory menu, here's code: PHP: public function createChest(Player $player, array $items, int $id, string $title, $double = false) { $this->clearData($player); $this->inv[$player->getName()] = $player->getInventory()->getContents(); $v3 = $this->getVector($player); $this->chest[$player->getName()] = [$id, $v3]; $this->updateBlock($player, 54, $v3); $nbt = new NBT(NBT::LITTLE_ENDIAN); if ($double) { $this->chest[$player->getName()][2] = true; $this->updateBlock($player, 54, new Vector3($v3->x + 1, $v3->y, $v3->z)); $nbt->setData(new CompoundTag( "", [ new StringTag("CustomName", $title), new IntTag("pairx", $v3->x + 1), new IntTag("pairz", $v3->z) ] )); } else { $nbt->setData(new CompoundTag( "", [ new StringTag("CustomName", $title) ] )); } $pk = new BlockEntityDataPacket(); $pk->x = $v3->x; $pk->y = $v3->y; $pk->z = $v3->z; $pk->namedtag = $nbt->write(true); $pk1 = new ContainerOpenPacket(); $pk1->windowid = 10; $pk1->type = 0; $pk1->x = $v3->x; $pk1->y = $v3->y; $pk1->z = $v3->z; $pk2 = new ContainerSetContentPacket(); $pk2->windowid = 10; $pk2->slots = $items; $player->dataPacket($pk); $player->dataPacket($pk1); $player->dataPacket($pk2); } But when I create a double chest can sometimes be a problem: first opening 27-slot chest and immediately closes, then if I repeat this code again works. If you do a little sleep() after sending BlockEntityDataPacket, then everything will work. How to make immediately opened a double chest without sleep()? Thank you.
Yeah you will need to delay sending ContainerOpenPacket by 0.25s (5 ticks). Aside from that, are you aware about the consequences of using pure packets to handle inventory transactions? You will end up having many bugs if you don't handle the transactions properly.