getTag(self::TAG_ITEM)) instanceof ShortTag and ($itemMetaTag = $nbt->getTag(self::TAG_ITEM_DATA)) instanceof IntTag){ try{ $this->setPlant(BlockFactory::getInstance()->get($itemIdTag->getValue(), $itemMetaTag->getValue())); }catch(\InvalidArgumentException $e){ //noop } }else{ //TODO: new PlantBlock tag } } protected function writeSaveData(CompoundTag $nbt) : void{ if($this->plant !== null){ $nbt->setShort(self::TAG_ITEM, $this->plant->getId()); $nbt->setInt(self::TAG_ITEM_DATA, $this->plant->getMeta()); } } public function getPlant() : ?Block{ return $this->plant !== null ? clone $this->plant : null; } public function setPlant(?Block $plant) : void{ if($plant === null or $plant instanceof Air){ $this->plant = null; }else{ $this->plant = clone $plant; } } protected function addAdditionalSpawnData(CompoundTag $nbt) : void{ if($this->plant !== null){ $nbt->setShort(self::TAG_ITEM, $this->plant->getId()); $nbt->setInt(self::TAG_ITEM_DATA, $this->plant->getMeta()); } } }