This function do not work PHP: public function loadVault(Player $player, $number) { $itemblock = Item::fromString("chest"); $block = $itemblock->getBlock(); $player->getLevel()->setBlock(new Vector3($player->getX(), 128, $player->getZ()), $block); $nbt = new CompoundTag("", [ new ListTag("Items", []), new StringTag("id", Tile::CHEST), new IntTag("x", $player->getX()), new IntTag("y", $player->getY()), new IntTag("z", $player->getZ()) ]); $nbt->Items->setTagType(NBT::TAG_Compound); $tile = Tile::createTile("Chest", $player->getLevel()->getChunk($player->getX() >> 4, $player->getZ() >> 4), $nbt); if($player instanceof Player) { $player = $player->getName(); } $player = strtolower($player); $cfg = new Config($this->getDataFolder() . "players/" . $player . ".yml", Config::YAML); $tile->getInventory()->clearAll(); for ($i = 0; $i < 26; $i++) { $ite = $cfg->getNested("$number.items." . $i); $item = Item::get($ite[0]); $item->setDamage($ite[1]); $item->setCount($ite[2]); foreach ($ite[3] as $key => $en) { $enchantment = Enchantment::getEnchantment($en[0]); $enchantment->setLevel($en[1]); $item->addEnchantment($enchantment); } $tile->getInventory()->setItem($i, $item); } return $tile->getInventory(); }Line error:$tile = Tile::createTile("Chest", $player->getLevel()->getChunk($player->getX() >> 4, $player->getZ() >> 4), $nbt);
Of course but the chest keep visible after close PHP: public function loadVault(Player $player, $number) { $itemblock = Item::fromString("chest"); $block = $itemblock->getBlock(); $player->getLevel()->setBlock(new Vector3($player->getX(), 128, $player->getZ()), $block); $nbt = new CompoundTag("", [ new ListTag("Items", []), new StringTag("id", Tile::CHEST), new IntTag("x", $player->getX()), new IntTag("y", $player->getY()), new IntTag("z", $player->getZ()) ]); $nbt->Items->setTagType(NBT::TAG_Compound); $tile = Tile::createTile ( "Chest", $player->getLevel (), $nbt ); $block = Block::get ( Block::CHEST ); $block->x = ( int ) $tile->x; $block->y = ( int ) $tile->y; $block->z = ( int ) $tile->z; $block->level = $tile->getLevel (); $block->level->sendBlocks ( [ $player ], [ $block ] ); if($player instanceof Player) { $player = $player->getName(); } $player = strtolower($player); $cfg = new Config($this->getDataFolder() . "players/" . $player . ".yml", Config::YAML); $tile->getInventory()->clearAll(); for ($i = 0; $i < 26; $i++) { $ite = $cfg->getNested("$number.items." . $i); $item = Item::get($ite[0]); $item->setDamage($ite[1]); $item->setCount($ite[2]); foreach ($ite[3] as $key => $en) { $enchantment = Enchantment::getEnchantment($en[0]); $enchantment->setLevel($en[1]); $item->addEnchantment($enchantment); } $tile->getInventory()->setItem($i, $item); } return $tile->getInventory(); }
Your source: https://github.com/BukkitPlaysMC/Pr...rusDarkSeeker/PrivateVaults/PrivateVaults.php It's a very old code you've dug in to, you should check this class: https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/block/Chest.php It has become way easier.