diff --git a/src/pocketmine/item/Axe.php b/src/pocketmine/item/Axe.php index 83b632bd1..67efffb2e 100644 --- a/src/pocketmine/item/Axe.php +++ b/src/pocketmine/item/Axe.php @@ -23,12 +23,18 @@ declare(strict_types=1); namespace pocketmine\item; +use pocketmine\block\BlockToolType; + class Axe extends TieredTool{ public function isAxe(){ return $this->tier; } + public function getBlockToolType() : int{ + return BlockToolType::TYPE_AXE; + } + public function getAttackPoints() : int{ return self::getBaseDamageFromTier($this->tier) - 1; } diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index 88b82f070..93e5c2a90 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -28,6 +28,7 @@ namespace pocketmine\item; use pocketmine\block\Block; use pocketmine\block\BlockFactory; +use pocketmine\block\BlockToolType; use pocketmine\entity\Entity; use pocketmine\item\enchantment\Enchantment; use pocketmine\level\Level; @@ -741,6 +742,16 @@ class Item implements ItemIds, \JsonSerializable{ return false; } + /** + * Returns what type of block-breaking tool this is. Blocks requiring the same tool type as the item will break + * faster (except for blocks requiring no tool, which break at the same speed regardless of the tool used) + * + * @return int + */ + public function getBlockToolType() : int{ + return BlockToolType::TYPE_NONE; + } + /** * Returns the maximum amount of damage this item can take before it breaks. * diff --git a/src/pocketmine/item/Pickaxe.php b/src/pocketmine/item/Pickaxe.php index 4e59d81af..f78732d13 100644 --- a/src/pocketmine/item/Pickaxe.php +++ b/src/pocketmine/item/Pickaxe.php @@ -23,12 +23,18 @@ declare(strict_types=1); namespace pocketmine\item; +use pocketmine\block\BlockToolType; + class Pickaxe extends TieredTool{ public function isPickaxe(){ return $this->tier; } + public function getBlockToolType() : int{ + return BlockToolType::TYPE_PICKAXE; + } + public function getAttackPoints() : int{ return self::getBaseDamageFromTier($this->tier) - 2; } diff --git a/src/pocketmine/item/Shears.php b/src/pocketmine/item/Shears.php index 36d377185..fbfa3a575 100644 --- a/src/pocketmine/item/Shears.php +++ b/src/pocketmine/item/Shears.php @@ -24,6 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; +use pocketmine\block\BlockToolType; + class Shears extends Tool{ public function __construct(int $meta = 0){ parent::__construct(self::SHEARS, $meta, "Shears"); @@ -36,4 +38,8 @@ class Shears extends Tool{ public function isShears(){ return true; } + + public function getBlockToolType() : int{ + return BlockToolType::TYPE_SHEARS; + } } \ No newline at end of file diff --git a/src/pocketmine/item/Shovel.php b/src/pocketmine/item/Shovel.php index 781f742ad..86ffd541d 100644 --- a/src/pocketmine/item/Shovel.php +++ b/src/pocketmine/item/Shovel.php @@ -23,12 +23,18 @@ declare(strict_types=1); namespace pocketmine\item; +use pocketmine\block\BlockToolType; + class Shovel extends TieredTool{ public function isShovel(){ return $this->tier; } + public function getBlockToolType() : int{ + return BlockToolType::TYPE_SHOVEL; + } + public function getAttackPoints() : int{ return self::getBaseDamageFromTier($this->tier) - 3; } diff --git a/src/pocketmine/item/Sword.php b/src/pocketmine/item/Sword.php index 6eb17fb81..734fba274 100644 --- a/src/pocketmine/item/Sword.php +++ b/src/pocketmine/item/Sword.php @@ -23,12 +23,18 @@ declare(strict_types=1); namespace pocketmine\item; +use pocketmine\block\BlockToolType; + class Sword extends TieredTool{ public function isSword(){ return $this->tier; } + public function getBlockToolType() : int{ + return BlockToolType::TYPE_SWORD; + } + public function getAttackPoints() : int{ return self::getBaseDamageFromTier($this->tier); }