getNamedTagEntry("Unbreakable"); return $tag !== null and $tag->getValue() !== 0; } /** * Sets whether the item will take damage when used. * @param bool $value */ public function setUnbreakable(bool $value = true){ $this->setNamedTagEntry(new ByteTag("Unbreakable", $value ? 1 : 0)); } /** * Applies damage to the item. * @param int $amount * * @return bool if any damage was applied to the item */ public function applyDamage(int $amount) : bool{ if($this->isUnbreakable() or $this->isBroken()){ return false; } //TODO: Unbreaking enchantment $this->meta += $amount; if($this->isBroken()){ $this->pop(); } return true; } /** * Returns whether the item is broken. * @return bool */ public function isBroken() : bool{ return $this->meta >= $this->getMaxDurability(); } }