isUnbreakable()){ return true; } if($object instanceof Block){ if( $object->getToolType() === Tool::TYPE_PICKAXE and $this->isPickaxe() or $object->getToolType() === Tool::TYPE_SHOVEL and $this->isShovel() or $object->getToolType() === Tool::TYPE_AXE and $this->isAxe() or $object->getToolType() === Tool::TYPE_SWORD and $this->isSword() or $object->getToolType() === Tool::TYPE_SHEARS and $this->isShears() ){ $this->meta++; }elseif(!$this->isShears() and $object->getBreakTime($this) > 0){ $this->meta += 2; } }elseif($this->isHoe()){ if(($object instanceof Block) and ($object->getId() === self::GRASS or $object->getId() === self::DIRT)){ $this->meta++; } }elseif(($object instanceof Entity) and !$this->isSword()){ $this->meta += 2; }else{ $this->meta++; } return true; } /** * TODO: Move this to each item * * @return int|bool */ public function getMaxDurability(){ $levels = [ Tool::TIER_GOLD => 33, Tool::TIER_WOODEN => 60, Tool::TIER_STONE => 132, Tool::TIER_IRON => 251, Tool::TIER_DIAMOND => 1562, self::FLINT_STEEL => 65, self::SHEARS => 239, self::BOW => 385, ]; if(($type = $this->isPickaxe()) === false){ if(($type = $this->isAxe()) === false){ if(($type = $this->isSword()) === false){ if(($type = $this->isShovel()) === false){ if(($type = $this->isHoe()) === false){ $type = $this->id; } } } } } return $levels[$type]; } public function isUnbreakable(){ $tag = $this->getNamedTagEntry("Unbreakable"); return $tag !== null and $tag->getValue() > 0; } public function isPickaxe(){ return false; } public function isAxe(){ return false; } public function isSword(){ return false; } public function isShovel(){ return false; } public function isHoe(){ return false; } public function isShears(){ return ($this->id === self::SHEARS); } public function isTool(){ return ($this->id === self::FLINT_STEEL or $this->id === self::SHEARS or $this->id === self::BOW or $this->isPickaxe() !== false or $this->isAxe() !== false or $this->isShovel() !== false or $this->isSword() !== false); } }