I tried using PHP: $player->addWindow($chest->getInventory); $chest is a chest tile; i also tried PHP: $player->addWindows($player->getInventory()
PHP: $pos = [ $player->getX(), $player->getY(), $player->getZ() ]; $level = $player->getLevel(); $items = new ListTag("Items", []); $items->setTagType(NBT::TAG_Compound); $nbt = new CompoundTag("", [ $items, new StringTag("id", Tile::CHEST), new StringTag("CustomName", "Insert Custom Name Here"), new IntTag("x", $pos[0]), new IntTag("y", $pos[1]), new IntTag("z", $pos[2]) ]); $chest = Tile::createTile(Tile::CHEST, $level, $nbt); if($chest instanceof Chest) { $chest->getInventory()->addItem($rpgItem['item']); $player->addWindow($chest->getInventory()); }
You need to setblock at that position as chest, also need to spawn the chest tile to the player before you addWindow
you can use this very useful library made by @Muqsit https://github.com/Muqsit/InvMenu read the README.md for instructions
you get your wanted level's instance, then use the function called setBlock to set the block. The first parameter requires a Vector3 instance of your wanted location, and the second parameter requires a Block instance of your wanted block which you can get by using Block::get()