SOLVED So I was trying to generate chests with items filled, and it generated chests but there's no item in it, please help me!! thanks. here's my code: PHP: $level->setBlock($pos, new Chest(), true); $nbt = new CompoundTag("", [ new ListTag("Items", []), new StringTag("id", Tile::CHEST), new IntTag("x", $x), new IntTag("y", $y), new IntTag("z", $z) ]); if($level->getChunk($x, $z) == null) { $level->loadChunk($x, $z); } $chunk = $level->getChunk($x, $z); $tile = new \pocketmine\tile\Chest($chunk, $nbt); if($tile instanceof \pocketmine\tile\Chest) { foreach ($item_drop as $index => $value) { $item = explode(':', $value); $tile->getInventory()->setItem($index, Item::get($item[0], $item[1], $item[2])); } }
CONSIDER CHANGING THE NAME OF THIS TOPIC SO SOMETHING RELATABLE! *************************************Basically, it helps keep the forum neat and tidy. It also helps people who might have the same issue as you. For example "How to generate chests with items"
PHP: $level->setBlock($pos, new Chest(), true); $nbt = new CompoundTag("", [ new ListTag("Items", []), new StringTag("id", Tile::CHEST), new IntTag("x", $x), new IntTag("y", $y), new IntTag("z", $z) ]); if($level->getChunk($x >> 4, $z >> 4) == null) { $level->loadChunk($x >> 4, $z >> 4); } $chunk = $level->getChunk($x >> 4, $z >> 4); $tile = new \pocketmine\tile\Chest($chunk, $nbt); if($tile instanceof \pocketmine\tile\Chest) { foreach ($item_drop as $index => $value) { $item = explode(':', $value); $tile->getInventory()->setItem($index, Item::get($item[0], $item[1], $item[2])); } } I think you need to shift the bits of $x and $z to the right 4 times. Why? "Because chunks are 16*16 groups of X/Z-coordinates." (PeMapModder, online).