getCompoundTag(self::TAG_ITEM)) !== null){ $this->item = Item::nbtDeserialize($itemTag); }else{ $this->item = ItemFactory::get(Item::AIR, 0, 0); } $this->itemRotation = $nbt->getByte(self::TAG_ITEM_ROTATION, 0, true); $this->itemDropChance = $nbt->getFloat(self::TAG_ITEM_DROP_CHANCE, 1.0, true); } 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($this->item->nbtSerialize(-1, self::TAG_ITEM)); } public function hasItem() : bool{ return !$this->item->isNull(); } public function getItem() : Item{ return clone $this->item; } public function setItem(Item $item = null){ if($item !== null and !$item->isNull()){ $this->item = clone $item; }else{ $this->item = ItemFactory::get(Item::AIR, 0, 0); } $this->onChanged(); } public function getItemRotation() : int{ return $this->itemRotation; } public function setItemRotation(int $rotation){ $this->itemRotation = $rotation; $this->onChanged(); } public function getItemDropChance() : float{ return $this->itemDropChance; } public function setItemDropChance(float $chance){ $this->itemDropChance = $chance; $this->onChanged(); } 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($this->item->nbtSerialize(-1, self::TAG_ITEM)); } }