Refactored tool hierarchy

This commit is contained in:
Dylan K. Taylor
2017-11-24 10:36:31 +00:00
parent 3beccc47cd
commit 2088a43c56
71 changed files with 218 additions and 742 deletions

View File

@ -27,11 +27,6 @@ use pocketmine\block\Block;
use pocketmine\entity\Entity;
abstract class Tool extends Durable{
public const TIER_WOODEN = 1;
public const TIER_GOLD = 2;
public const TIER_STONE = 3;
public const TIER_IRON = 4;
public const TIER_DIAMOND = 5;
public const TYPE_NONE = 0;
public const TYPE_SWORD = 1;
@ -81,36 +76,6 @@ abstract class Tool extends Durable{
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
];
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){
return false;
}
}
}
}
}
return $levels[$type];
}
public function isTool(){
return true;
}