PHP: public function createChest(Player $player, array $items, int $id) { $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); $pk = new ContainerOpenPacket; $pk->windowid = 10; $pk->type = 0; $block->x = ( int ) $v3->x; $block->y = ( int ) $v3->y; $block->z = ( int ) $v3->z; $player->dataPacket($pk); $pk1 = new ContainerSetContentPacket; $pk1->windowid = 10; $pk1->slots = $items; $pk1->targetEid = $id; $player->dataPacket($pk1); } public function updateBlock(Player $player, int $id, Vector3 $v3){ $block->x = ( int ) $v3->x; $block->y = ( int ) $v3->y; $block->z = ( int ) $v3->z; $pk = new UpdateBlockPacket(); $pk->blockId = $id; $pk->blockData = (int) 0xb << 4 | (0 & 0xf); $player->dataPacket($pk); } public function getVector(Player $player): Vector3 { return new Vector3($player->x, $player->y - 3, $player->z); } public function clearData(Player $player) { if (isset($this->chest[$player->getName()])) unset($this->chest[$player->getName()]); if (isset($this->inv[$player->getName()])) unset($this->inv[$player->getName()]); }
$block is not defined, it is not used either, why is it there? To easily create inventory menus i suggest using https://github.com/Muqsit/InvMenu