Added new Tool type selection constants

This commit is contained in:
Shoghi Cervantes 2014-10-07 10:16:05 +02:00
parent 8769d2bcd1
commit dda9c598f1
26 changed files with 90 additions and 71 deletions

View File

@ -27,4 +27,8 @@ class DiamondAxe extends Tool{
parent::__construct(self::DIAMOND_AXE, $meta, $count, "Diamond Axe");
}
public function isAxe(){
return Tool::TIER_DIAMOND;
}
}

View File

@ -27,4 +27,7 @@ class DiamondHoe extends Tool{
parent::__construct(self::DIAMOND_HOE, $meta, $count, "Diamond Hoe");
}
public function isHoe(){
return Tool::TIER_DIAMOND;
}
}

View File

@ -27,4 +27,7 @@ class DiamondPickaxe extends Tool{
parent::__construct(self::DIAMOND_PICKAXE, $meta, $count, "Diamond Pickaxe");
}
public function isPickaxe(){
return Tool::TIER_DIAMOND;
}
}

View File

@ -27,4 +27,7 @@ class DiamondShovel extends Tool{
parent::__construct(self::DIAMOND_SHOVEL, $meta, $count, "Diamond Shovel");
}
public function isShovel(){
return Tool::TIER_DIAMOND;
}
}

View File

@ -27,4 +27,7 @@ class DiamondSword extends Tool{
parent::__construct(self::DIAMOND_SWORD, $meta, $count, "Diamond Sword");
}
public function isSword(){
return Tool::TIER_DIAMOND;
}
}

View File

@ -27,4 +27,7 @@ class GoldAxe extends Tool{
parent::__construct(self::GOLD_AXE, $meta, $count, "Gold Axe");
}
public function isAxe(){
return Tool::TIER_GOLD;
}
}

View File

@ -27,4 +27,7 @@ class GoldHoe extends Tool{
parent::__construct(self::GOLD_HOE, $meta, $count, "Gold Hoe");
}
public function isHoe(){
return Tool::TIER_GOLD;
}
}

View File

@ -27,4 +27,7 @@ class GoldPickaxe extends Tool{
parent::__construct(self::GOLD_PICKAXE, $meta, $count, "Gold Pickaxe");
}
public function isPickaxe(){
return Tool::TIER_GOLD;
}
}

View File

@ -27,4 +27,7 @@ class GoldShovel extends Tool{
parent::__construct(self::GOLD_SHOVEL, $meta, $count, "Gold Shovel");
}
public function isShovel(){
return Tool::TIER_GOLD;
}
}

View File

@ -27,4 +27,7 @@ class GoldSword extends Tool{
parent::__construct(self::GOLD_SWORD, $meta, $count, "Gold Sword");
}
public function isSword(){
return Tool::TIER_GOLD;
}
}

View File

@ -27,4 +27,7 @@ class IronAxe extends Tool{
parent::__construct(self::IRON_AXE, $meta, $count, "Iron Axe");
}
public function isAxe(){
return Tool::TIER_IRON;
}
}

View File

@ -27,4 +27,7 @@ class IronHoe extends Tool{
parent::__construct(self::IRON_HOE, $meta, $count, "Iron Hoe");
}
public function isHoe(){
return Tool::TIER_IRON;
}
}

View File

@ -27,4 +27,7 @@ class IronPickaxe extends Tool{
parent::__construct(self::IRON_PICKAXE, $meta, $count, "Iron Pickaxe");
}
public function isPickaxe(){
return Tool::TIER_IRON;
}
}

View File

@ -27,4 +27,7 @@ class IronShovel extends Tool{
parent::__construct(self::IRON_SHOVEL, $meta, $count, "Iron Shovel");
}
public function isShovel(){
return Tool::TIER_IRON;
}
}

View File

@ -27,4 +27,7 @@ class IronSword extends Tool{
parent::__construct(self::IRON_SWORD, $meta, $count, "Iron Sword");
}
public function isSword(){
return Tool::TIER_IRON;
}
}

View File

@ -27,4 +27,8 @@ class StoneAxe extends Tool{
parent::__construct(self::STONE_AXE, $meta, $count, "Stone Axe");
}
public function isAxe(){
return Tool::TIER_STONE;
}
}

View File

@ -27,4 +27,7 @@ class StoneHoe extends Tool{
parent::__construct(self::STONE_HOE, $meta, $count, "Stone Hoe");
}
public function isHoe(){
return Tool::TIER_STONE;
}
}

View File

@ -27,4 +27,7 @@ class StonePickaxe extends Tool{
parent::__construct(self::STONE_PICKAXE, $meta, $count, "Stone Pickaxe");
}
public function isPickaxe(){
return Tool::TIER_IRON;
}
}

View File

@ -27,4 +27,7 @@ class StoneShovel extends Tool{
parent::__construct(self::STONE_SHOVEL, $meta, $count, "Stone Shovel");
}
public function isShovel(){
return Tool::TIER_STONE;
}
}

View File

@ -27,4 +27,7 @@ class StoneSword extends Tool{
parent::__construct(self::STONE_SWORD, $meta, $count, "Stone Sword");
}
public function isSword(){
return Tool::TIER_STONE;
}
}

View File

@ -26,6 +26,11 @@ use pocketmine\block\Block;
use pocketmine\entity\Entity;
abstract class Tool extends Item{
const TIER_WOODEN = 1;
const TIER_GOLD = 2;
const TIER_STONE = 3;
const TIER_IRON = 4;
const TIER_DIAMOND = 5;
public function __construct($id, $meta = 0, $count = 1, $name = "Unknown"){
parent::__construct($id, $meta, $count, $name);
@ -87,84 +92,23 @@ abstract class Tool extends Item{
}
public function isPickaxe(){
switch($this->id){
case self::WOODEN_PICKAXE:
return 1;
case self::STONE_PICKAXE:
return 3;
case self::IRON_PICKAXE:
return 4;
case self::DIAMOND_PICKAXE:
return 5;
case self::GOLD_PICKAXE:
return 2;
default:
return false;
}
return false;
}
final public function isAxe(){
switch($this->id){
case self::IRON_AXE:
return 4;
case self::WOODEN_AXE:
return 1;
case self::STONE_AXE:
return 3;
case self::DIAMOND_AXE:
return 5;
case self::GOLD_AXE:
return 2;
default:
return false;
}
public function isAxe(){
return false;
}
final public function isSword(){
switch($this->id){
case self::IRON_SWORD:
return 4;
case self::WOODEN_SWORD:
return 1;
case self::STONE_SWORD:
return 3;
case self::DIAMOND_SWORD:
return 5;
case self::GOLD_SWORD:
return 2;
default:
return false;
}
public function isSword(){
return false;
}
final public function isShovel(){
switch($this->id){
case self::IRON_SHOVEL:
return 4;
case self::WOODEN_SHOVEL:
return 1;
case self::STONE_SHOVEL:
return 3;
case self::DIAMOND_SHOVEL:
return 5;
case self::GOLD_SHOVEL:
return 2;
default:
return false;
}
public function isShovel(){
return false;
}
public function isHoe(){
switch($this->id){
case self::IRON_HOE:
case self::WOODEN_HOE:
case self::STONE_HOE:
case self::DIAMOND_HOE:
case self::GOLD_HOE:
return true;
default:
return false;
}
return false;
}
public function isShears(){
@ -172,8 +116,6 @@ abstract class Tool extends Item{
}
public function isTool(){
return false;
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);
}
}

View File

@ -27,4 +27,7 @@ class WoodenAxe extends Tool{
parent::__construct(self::WOODEN_AXE, $meta, $count, "Wooden Axe");
}
public function isAxe(){
return Tool::TIER_WOODEN;
}
}

View File

@ -27,4 +27,7 @@ class WoodenHoe extends Tool{
parent::__construct(self::WOODEN_HOE, $meta, $count, "Wooden Hoe");
}
public function isHoe(){
return Tool::TIER_WOODEN;
}
}

View File

@ -27,4 +27,7 @@ class WoodenPickaxe extends Tool{
parent::__construct(self::WOODEN_PICKAXE, $meta, $count, "Wooden Pickaxe");
}
public function isPickaxe(){
return Tool::TIER_WOODEN;
}
}

View File

@ -27,4 +27,7 @@ class WoodenShovel extends Tool{
parent::__construct(self::WOODEN_SHOVEL, $meta, $count, "Wooden Shovel");
}
public function isShovel(){
return Tool::TIER_WOODEN;
}
}

View File

@ -27,4 +27,7 @@ class WoodenSword extends Tool{
parent::__construct(self::WOODEN_SWORD, $meta, $count, "Wooden Sword");
}
public function isSword(){
return Tool::TIER_WOODEN;
}
}