Code: $tile = Tile::createTile("SanalSandik", $level = $o->getLevel(), new CompoundTag("", [ new StringTag("id", Tile::CHEST), new StringTag("CustomName", $isim), new IntTag("x", (int) $o->x), new IntTag("y", (int) $o->y + 2), new IntTag("z", (int) $o->z) ])); if(!$tile instanceof SanalSandik) return false; $this->replacement(); $inventory = new SanalEnvanter($tile); $o->addWindow($inventory); Specify custom name, even though the inventory is still the name of "Chest".
PHP: // create the chest tile/** @var \pocketmine\nbt\tag\CompoundTag $nbt */$nbt = new \pocketmine\nbt\tag\CompoundTag("", [ new \pocketmine\nbt\tag\ListTag("Items", []), new \pocketmine\nbt\tag\StringTag("id", \pocketmine\tile\Tile::CHEST), new \pocketmine\nbt\tag\StringTag("CustomName", "Insert Custom Name Here"), new \pocketmine\nbt\tag\IntTag("x", $this->x), new \pocketmine\nbt\tag\IntTag("y", $this->y), new \pocketmine\nbt\tag\IntTag("z", $this->z)]);$nbt->Items->setTagType(\pocketmine\nbt\NBT::TAG_Compound);/** @var \pocketmine\tile\Chest $chest */$chest = \pocketmine\tile\Tile::createTile(\pocketmine\tile\Tile::CHEST, $level, $nbt);// send player the inventory/** @var \pocketmine\Player $player */$player->addWindow($chest->getInventory());
I know that already. I pointed out that does not work in virtual inventory. Code: class SanalEnvanter extends ChestInventory class SanalSandik extends \pocketmine\tile\Chest
PHP: class SanalSandik extends Chest { protected $cevir; public function __construct(Level $level, CompoundTag $nbt){ parent::__construct($level, $nbt); $this->inventory = new SanalEnvanter($this); $this->cevir= [$this->getBlock()->getId(), $this->getBlock()->getDamage()]; } public function spawnTo(Player $player){ } public function spawnToAll(){ }} PHP: class SanalEnvanter extends ChestInventory { public function __construct(Chest $tile){ parent::__construct($tile); } public function onClose(Player $who){ $this->holder->sendReplacement($who); $this->holder->close(); }}
PHP: class SanalSandik extends Chest { protected $cevir; public function __construct(Level $level, CompoundTag $nbt){ parent::__construct($level, $nbt); $this->inventory = new SanalEnvanter($this); $this->cevir= [$this->getBlock()->getId(), $this->getBlock()->getDamage()]; } private function getReplacement() : Block { return Block::get(...$this->cevir); } public function sendReplacement(Player $player) { $block = $this->getReplacement(); $block->x = (int) ($this->x); $block->y = (int) ($this->y); $block->z = (int) ($this->z); $block->level = $this->getLevel(); if($block->level !== null) { $block->level->sendBlocks([$player], [$block]); } } public function addAdditionalSpawnData(CompoundTag $nbt) { }} Try this when using Custom Tiles. You didn't have a Replacement inventory, and addAdditionalSpawnData() should add the CustomName NBT.