Added Item->getBlockToolType()

This commit is contained in:
Dylan K. Taylor 2017-11-24 11:26:03 +00:00
parent 55d0684565
commit db31d13f96
6 changed files with 41 additions and 0 deletions

View File

@ -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;
}

View File

@ -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.
*

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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);
}