/** * TODO: Move this to each item * * @param Entity|Block $object * * @return bool */ public function useOn($object) { if ($this->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; }