item)){ $nbt->item = new ShortTag("item", 0); } if(!isset($nbt->mData)){ $nbt->mData = new IntTag("mData", 0); } parent::__construct($chunk, $nbt); } public function canAddItem(Item $item): bool{ if(!$this->isEmpty()){ return false; } switch($item->getId()){ case Item::TALL_GRASS: if($item->getDamage() === 1){ return false; } case Item::SAPLING: case Item::DEAD_BUSH: case Item::DANDELION: case Item::RED_FLOWER: case Item::BROWN_MUSHROOM: case Item::RED_MUSHROOM: case Item::CACTUS: return true; default: return false; } } public function getItem(): Item{ return Item::get((int) ($this->namedtag["item"] ?? 0), (int) ($this->namedtag["mData"] ?? 0), 1); } public function setItem(Item $item){ $this->namedtag["item"] = $item->getId(); $this->namedtag["mData"] = $item->getDamage(); $this->onChanged(); } public function removeItem(){ $this->setItem(Item::get(Item::AIR)); } public function isEmpty(): bool{ return $this->getItem()->getId() === Item::AIR; } public function getSpawnCompound(): CompoundTag{ return new CompoundTag("", [ new StringTag("id", Tile::FLOWER_POT), new IntTag("x", (int) $this->x), new IntTag("y", (int) $this->y), new IntTag("z", (int) $this->z), $this->namedtag->item, $this->namedtag->mData ]); } }