ItemRotation)){ $nbt->ItemRotation = new ByteTag("ItemRotation", 0); } if(!isset($nbt->ItemDropChance)){ $nbt->ItemDropChance = new FloatTag("ItemDropChance", 1.0); } parent::__construct($level, $nbt); } public function hasItem() : bool{ return $this->getItem()->getId() !== Item::AIR; } public function getItem() : Item{ if(isset($this->namedtag->Item)){ return Item::nbtDeserialize($this->namedtag->Item); }else{ return ItemFactory::get(Item::AIR); } } public function setItem(Item $item = null){ if($item !== null and $item->getId() !== Item::AIR){ $this->namedtag->Item = $item->nbtSerialize(-1, "Item"); }else{ unset($this->namedtag->Item); } $this->onChanged(); } public function getItemRotation() : int{ return $this->namedtag->ItemRotation->getValue(); } public function setItemRotation(int $rotation){ $this->namedtag->ItemRotation->setValue($rotation); $this->onChanged(); } public function getItemDropChance() : float{ return $this->namedtag->ItemDropChance->getValue(); } public function setItemDropChance(float $chance){ $this->namedtag->ItemDropChance->setValue($chance); $this->onChanged(); } public function addAdditionalSpawnData(CompoundTag $nbt){ $nbt->ItemDropChance = $this->namedtag->ItemDropChance; $nbt->ItemRotation = $this->namedtag->ItemRotation; if($this->hasItem()){ $nbt->Item = $this->namedtag->Item; } } }