item = ItemFactory::air(); parent::__construct($world, $pos); } public function readSaveData(CompoundTag $nbt) : void{ if(($itemTag = $nbt->getCompoundTag(self::TAG_ITEM)) !== null){ $this->item = Item::nbtDeserialize($itemTag); } $this->itemRotation = $nbt->getByte(self::TAG_ITEM_ROTATION, $this->itemRotation); $this->itemDropChance = $nbt->getFloat(self::TAG_ITEM_DROP_CHANCE, $this->itemDropChance); } protected function writeSaveData(CompoundTag $nbt) : void{ $nbt->setFloat(self::TAG_ITEM_DROP_CHANCE, $this->itemDropChance); $nbt->setByte(self::TAG_ITEM_ROTATION, $this->itemRotation); $nbt->setTag(self::TAG_ITEM, $this->item->nbtSerialize()); } public function hasItem() : bool{ return !$this->item->isNull(); } public function getItem() : Item{ return clone $this->item; } public function setItem(?Item $item) : void{ if($item !== null and !$item->isNull()){ $this->item = clone $item; }else{ $this->item = ItemFactory::air(); } } public function getItemRotation() : int{ return $this->itemRotation; } public function setItemRotation(int $rotation) : void{ $this->itemRotation = $rotation; } public function getItemDropChance() : float{ return $this->itemDropChance; } public function setItemDropChance(float $chance) : void{ $this->itemDropChance = $chance; } protected function addAdditionalSpawnData(CompoundTag $nbt) : void{ $nbt->setFloat(self::TAG_ITEM_DROP_CHANCE, $this->itemDropChance); $nbt->setByte(self::TAG_ITEM_ROTATION, $this->itemRotation); $nbt->setTag(self::TAG_ITEM, $this->item->nbtSerialize()); } }