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

@ -26,6 +26,7 @@ namespace pocketmine\block;
use pocketmine\inventory\AnvilInventory;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
@ -107,7 +108,7 @@ class Anvil extends Fallable{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return [
ItemFactory::get($this->getItemId(), $this->getDamage() & 0x0c, 1)
];

View File

@ -29,6 +29,7 @@ namespace pocketmine\block;
use pocketmine\entity\Entity;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
use pocketmine\level\Level;
use pocketmine\level\MovingObjectPosition;
@ -230,19 +231,19 @@ class Block extends Position implements BlockIds, Metadatable{
($this->getToolType() === Tool::TYPE_SHOVEL and ($tier = $item->isShovel()) !== false)
){
switch($tier){
case Tool::TIER_WOODEN:
case TieredTool::TIER_WOODEN:
$base /= 2;
break;
case Tool::TIER_STONE:
case TieredTool::TIER_STONE:
$base /= 4;
break;
case Tool::TIER_IRON:
case TieredTool::TIER_IRON:
$base /= 6;
break;
case Tool::TIER_DIAMOND:
case TieredTool::TIER_DIAMOND:
$base /= 8;
break;
case Tool::TIER_GOLD:
case TieredTool::TIER_GOLD:
$base /= 12;
break;
}

View File

@ -25,6 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\PillarRotationHelper;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
use pocketmine\math\Vector3;
use pocketmine\Player;
@ -59,7 +60,7 @@ class BoneBlock extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class Bricks extends Solid{
@ -51,7 +52,7 @@ class Bricks extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\StringTag;
@ -92,7 +93,7 @@ class BurningFurnace extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class Coal extends Solid{
@ -47,7 +48,7 @@ class Coal extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -25,6 +25,7 @@ namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class CoalOre extends Solid{
@ -48,7 +49,7 @@ class CoalOre extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return [
ItemFactory::get(Item::COAL, 0, 1)
];

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class Cobblestone extends Solid{
@ -47,7 +48,7 @@ class Cobblestone extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -25,6 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\ColorBlockMetaHelper;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class Concrete extends Solid{
@ -48,7 +49,7 @@ class Concrete extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class Diamond extends Solid{
@ -47,7 +48,7 @@ class Diamond extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_IRON){
if($item->isPickaxe() >= TieredTool::TIER_IRON){
return parent::getDrops($item);
}

View File

@ -25,6 +25,7 @@ namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class DiamondOre extends Solid{
@ -48,7 +49,7 @@ class DiamondOre extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_IRON){
if($item->isPickaxe() >= TieredTool::TIER_IRON){
return [
ItemFactory::get(Item::DIAMOND, 0, 1)
];

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class DoubleStoneSlab extends DoubleSlab{
@ -43,7 +44,7 @@ class DoubleStoneSlab extends DoubleSlab{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class Emerald extends Solid{
@ -47,7 +48,7 @@ class Emerald extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_IRON){
if($item->isPickaxe() >= TieredTool::TIER_IRON){
return parent::getDrops($item);
}

View File

@ -25,6 +25,7 @@ namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class EmeraldOre extends Solid{
@ -48,7 +49,7 @@ class EmeraldOre extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_IRON){
if($item->isPickaxe() >= TieredTool::TIER_IRON){
return [
ItemFactory::get(Item::EMERALD, 0, 1)
];

View File

@ -25,6 +25,7 @@ namespace pocketmine\block;
use pocketmine\inventory\EnchantInventory;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
use pocketmine\math\Vector3;
use pocketmine\Player;
@ -74,7 +75,7 @@ class EnchantingTable extends Transparent{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class EndStoneBricks extends Solid{
@ -47,7 +48,7 @@ class EndStoneBricks extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -25,6 +25,7 @@ namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
use pocketmine\math\Vector3;
use pocketmine\Player;
@ -98,7 +99,7 @@ class EnderChest extends Chest{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return [ItemFactory::get(Item::OBSIDIAN, 0, 8)];
}

View File

@ -25,6 +25,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
use pocketmine\math\Vector3;
use pocketmine\Player;
@ -58,7 +59,7 @@ class GlazedTerracotta extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class Gold extends Solid{
@ -47,7 +48,7 @@ class Gold extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_IRON){
if($item->isPickaxe() >= TieredTool::TIER_IRON){
return parent::getDrops($item);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class GoldOre extends Solid{
@ -47,7 +48,7 @@ class GoldOre extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_IRON){
if($item->isPickaxe() >= TieredTool::TIER_IRON){
return parent::getDrops($item);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class Iron extends Solid{
@ -47,7 +48,7 @@ class Iron extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_STONE){
if($item->isPickaxe() >= TieredTool::TIER_STONE){
return parent::getDrops($item);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class IronBars extends Thin{
@ -51,7 +52,7 @@ class IronBars extends Thin{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class IronDoor extends Door{
@ -49,7 +50,7 @@ class IronDoor extends Door{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class IronOre extends Solid{
@ -47,7 +48,7 @@ class IronOre extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_STONE){
if($item->isPickaxe() >= TieredTool::TIER_STONE){
return parent::getDrops($item);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class Lapis extends Solid{
@ -47,7 +48,7 @@ class Lapis extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_STONE){
if($item->isPickaxe() >= TieredTool::TIER_STONE){
return parent::getDrops($item);
}

View File

@ -25,6 +25,7 @@ namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class LapisOre extends Solid{
@ -48,7 +49,7 @@ class LapisOre extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_STONE){
if($item->isPickaxe() >= TieredTool::TIER_STONE){
return [
ItemFactory::get(Item::DYE, 4, mt_rand(4, 8))
];

View File

@ -27,6 +27,7 @@ use pocketmine\entity\Entity;
use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class Magma extends Solid{
@ -65,7 +66,7 @@ class Magma extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class NetherBrick extends Solid{
@ -37,7 +38,7 @@ class NetherBrick extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class NetherBrickFence extends Fence{
@ -43,7 +44,7 @@ class NetherBrickFence extends Fence{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -25,6 +25,7 @@ namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class NetherQuartzOre extends Solid{
@ -48,7 +49,7 @@ class NetherQuartzOre extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return [
ItemFactory::get(Item::QUARTZ, 0, 1)
];

View File

@ -25,6 +25,7 @@ namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class NetherReactor extends Solid{
@ -52,7 +53,7 @@ class NetherReactor extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return [
ItemFactory::get(Item::IRON_INGOT, 0, 6),
ItemFactory::get(Item::DIAMOND, 0, 3)

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class Netherrack extends Solid{
@ -47,7 +48,7 @@ class Netherrack extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class Obsidian extends Solid{
@ -51,7 +52,7 @@ class Obsidian extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_DIAMOND){
if($item->isPickaxe() >= TieredTool::TIER_DIAMOND){
return parent::getDrops($item);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class Prismarine extends Solid{
@ -60,7 +61,7 @@ class Prismarine extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -25,6 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\PillarRotationHelper;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
use pocketmine\math\Vector3;
use pocketmine\Player;
@ -70,7 +71,7 @@ class Quartz extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class Redstone extends Solid{
@ -47,7 +48,7 @@ class Redstone extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -25,6 +25,7 @@ namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
use pocketmine\level\Level;
use pocketmine\math\Vector3;
@ -65,7 +66,7 @@ class RedstoneOre extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_IRON){
if($item->isPickaxe() >= TieredTool::TIER_IRON){
return [
ItemFactory::get(Item::REDSTONE_DUST, 0, mt_rand(4, 5))
];

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class Sandstone extends Solid{
@ -60,7 +61,7 @@ class Sandstone extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
@ -104,7 +105,7 @@ abstract class Stair extends Transparent{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -25,6 +25,7 @@ namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class Stone extends Solid{
@ -64,7 +65,7 @@ class Stone extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
if($this->getDamage() === self::NORMAL){
return [
ItemFactory::get(Item::COBBLESTONE, $this->getDamage(), 1)

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class StoneBricks extends Solid{
@ -57,7 +58,7 @@ class StoneBricks extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class StoneSlab extends Slab{
@ -65,7 +66,7 @@ class StoneSlab extends Slab{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\TieredTool;
use pocketmine\item\Tool;
class Stonecutter extends Solid{
@ -43,7 +44,7 @@ class Stonecutter extends Solid{
}
public function getDrops(Item $item) : array{
if($item->isPickaxe() >= Tool::TIER_WOODEN){
if($item->isPickaxe() >= TieredTool::TIER_WOODEN){
return parent::getDrops($item);
}

View File

@ -23,17 +23,13 @@ declare(strict_types=1);
namespace pocketmine\item;
class IronAxe extends Tool{
public function __construct(int $meta = 0){
parent::__construct(self::IRON_AXE, $meta, "Iron Axe");
}
class Axe extends TieredTool{
public function isAxe(){
return Tool::TIER_IRON;
return $this->tier;
}
public function getAttackPoints() : int{
return 6;
return self::getBaseDamageFromTier($this->tier) - 1;
}
}

View File

@ -1,39 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\item;
class DiamondAxe extends Tool{
public function __construct(int $meta = 0){
parent::__construct(self::DIAMOND_AXE, $meta, "Diamond Axe");
}
public function isAxe(){
return Tool::TIER_DIAMOND;
}
public function getAttackPoints() : int{
return 7;
}
}

View File

@ -1,35 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\item;
class DiamondHoe extends Tool{
public function __construct(int $meta = 0){
parent::__construct(self::DIAMOND_HOE, $meta, "Diamond Hoe");
}
public function isHoe(){
return Tool::TIER_DIAMOND;
}
}

View File

@ -1,39 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\item;
class DiamondPickaxe extends Tool{
public function __construct(int $meta = 0){
parent::__construct(self::DIAMOND_PICKAXE, $meta, "Diamond Pickaxe");
}
public function isPickaxe(){
return Tool::TIER_DIAMOND;
}
public function getAttackPoints() : int{
return 6;
}
}

View File

@ -1,39 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\item;
class DiamondShovel extends Tool{
public function __construct(int $meta = 0){
parent::__construct(self::DIAMOND_SHOVEL, $meta, "Diamond Shovel");
}
public function isShovel(){
return Tool::TIER_DIAMOND;
}
public function getAttackPoints() : int{
return 5;
}
}

View File

@ -1,39 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\item;
class DiamondSword extends Tool{
public function __construct(int $meta = 0){
parent::__construct(self::DIAMOND_SWORD, $meta, "Diamond Sword");
}
public function isSword(){
return Tool::TIER_DIAMOND;
}
public function getAttackPoints() : int{
return 8;
}
}

View File

@ -1,39 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\item;
class GoldAxe extends Tool{
public function __construct(int $meta = 0){
parent::__construct(self::GOLD_AXE, $meta, "Gold Axe");
}
public function isAxe(){
return Tool::TIER_GOLD;
}
public function getAttackPoints() : int{
return 4;
}
}

View File

@ -1,35 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\item;
class GoldHoe extends Tool{
public function __construct(int $meta = 0){
parent::__construct(self::GOLD_HOE, $meta, "Gold Hoe");
}
public function isHoe(){
return Tool::TIER_GOLD;
}
}

View File

@ -1,39 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\item;
class GoldPickaxe extends Tool{
public function __construct(int $meta = 0){
parent::__construct(self::GOLD_PICKAXE, $meta, "Gold Pickaxe");
}
public function isPickaxe(){
return Tool::TIER_GOLD;
}
public function getAttackPoints() : int{
return 3;
}
}

View File

@ -1,39 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\item;
class GoldShovel extends Tool{
public function __construct(int $meta = 0){
parent::__construct(self::GOLD_SHOVEL, $meta, "Gold Shovel");
}
public function isShovel(){
return Tool::TIER_GOLD;
}
public function getAttackPoints() : int{
return 2;
}
}

View File

@ -1,39 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\item;
class GoldSword extends Tool{
public function __construct(int $meta = 0){
parent::__construct(self::GOLD_SWORD, $meta, "Gold Sword");
}
public function isSword(){
return Tool::TIER_GOLD;
}
public function getAttackPoints() : int{
return 5;
}
}

View File

@ -23,13 +23,10 @@ declare(strict_types=1);
namespace pocketmine\item;
class IronHoe extends Tool{
public function __construct(int $meta = 0){
parent::__construct(self::IRON_HOE, $meta, "Iron Hoe");
}
class Hoe extends TieredTool{
public function isHoe(){
return Tool::TIER_IRON;
return $this->tier;
}
}

View File

@ -39,9 +39,9 @@ class ItemFactory{
if(self::$list === null){
self::$list = new \SplFixedArray(65536);
self::registerItem(new IronShovel());
self::registerItem(new IronPickaxe());
self::registerItem(new IronAxe());
self::registerItem(new Shovel(Item::IRON_SHOVEL, 0, "Iron Shovel", TieredTool::TIER_IRON));
self::registerItem(new Pickaxe(Item::IRON_PICKAXE, 0, "Iron Pickaxe", TieredTool::TIER_IRON));
self::registerItem(new Axe(Item::IRON_AXE, 0, "Iron Axe", TieredTool::TIER_IRON));
self::registerItem(new FlintSteel());
self::registerItem(new Apple());
self::registerItem(new Bow());
@ -50,34 +50,34 @@ class ItemFactory{
self::registerItem(new Item(Item::DIAMOND, 0, "Diamond"));
self::registerItem(new Item(Item::IRON_INGOT, 0, "Iron Ingot"));
self::registerItem(new Item(Item::GOLD_INGOT, 0, "Gold Ingot"));
self::registerItem(new IronSword());
self::registerItem(new Sword(Item::IRON_SWORD, 0, "Iron Sword", TieredTool::TIER_IRON));
self::registerItem(new WoodenSword());
self::registerItem(new WoodenShovel());
self::registerItem(new WoodenPickaxe());
self::registerItem(new WoodenAxe());
self::registerItem(new StoneSword());
self::registerItem(new StoneShovel());
self::registerItem(new StonePickaxe());
self::registerItem(new StoneAxe());
self::registerItem(new DiamondSword());
self::registerItem(new DiamondShovel());
self::registerItem(new DiamondPickaxe());
self::registerItem(new DiamondAxe());
self::registerItem(new Sword(Item::STONE_SWORD, 0, "Stone Sword", TieredTool::TIER_STONE));
self::registerItem(new Shovel(Item::STONE_SHOVEL, 0, "Stone Shovel", TieredTool::TIER_STONE));
self::registerItem(new Pickaxe(Item::STONE_PICKAXE, 0, "Stone Pickaxe", TieredTool::TIER_STONE));
self::registerItem(new Axe(Item::STONE_AXE, 0, "Stone Axe", TieredTool::TIER_STONE));
self::registerItem(new Sword(Item::DIAMOND_SWORD, 0, "Diamond Sword", TieredTool::TIER_DIAMOND));
self::registerItem(new Shovel(Item::DIAMOND_SHOVEL, 0, "Diamond Shovel", TieredTool::TIER_DIAMOND));
self::registerItem(new Pickaxe(Item::DIAMOND_PICKAXE, 0, "Diamond Pickaxe", TieredTool::TIER_DIAMOND));
self::registerItem(new Axe(Item::DIAMOND_AXE, 0, "Diamond Axe", TieredTool::TIER_DIAMOND));
self::registerItem(new Stick());
self::registerItem(new Bowl());
self::registerItem(new MushroomStew());
self::registerItem(new GoldSword());
self::registerItem(new GoldShovel());
self::registerItem(new GoldPickaxe());
self::registerItem(new GoldAxe());
self::registerItem(new Sword(Item::GOLDEN_SWORD, 0, "Gold Sword", TieredTool::TIER_GOLD));
self::registerItem(new Shovel(Item::GOLDEN_SHOVEL, 0, "Gold Shovel", TieredTool::TIER_GOLD));
self::registerItem(new Pickaxe(Item::GOLDEN_PICKAXE, 0, "Gold Pickaxe", TieredTool::TIER_GOLD));
self::registerItem(new Axe(Item::GOLDEN_AXE, 0, "Gold Axe", TieredTool::TIER_GOLD));
self::registerItem(new StringItem());
self::registerItem(new Item(Item::FEATHER, 0, "Feather"));
self::registerItem(new Item(Item::GUNPOWDER, 0, "Gunpowder"));
self::registerItem(new WoodenHoe());
self::registerItem(new StoneHoe());
self::registerItem(new IronHoe());
self::registerItem(new DiamondHoe());
self::registerItem(new GoldHoe());
self::registerItem(new Hoe(Item::WOODEN_HOE, 0, "Wooden Hoe", TieredTool::TIER_WOODEN));
self::registerItem(new Hoe(Item::STONE_HOE, 0, "Stone Hoe", TieredTool::TIER_STONE));
self::registerItem(new Hoe(Item::IRON_HOE, 0, "Iron Hoe", TieredTool::TIER_IRON));
self::registerItem(new Hoe(Item::DIAMOND_HOE, 0, "Diamond Hoe", TieredTool::TIER_DIAMOND));
self::registerItem(new Hoe(Item::GOLDEN_HOE, 0, "Golden Hoe", TieredTool::TIER_GOLD));
self::registerItem(new WheatSeeds());
self::registerItem(new Item(Item::WHEAT, 0, "Wheat"));
self::registerItem(new Bread());

View File

@ -23,17 +23,13 @@ declare(strict_types=1);
namespace pocketmine\item;
class IronPickaxe extends Tool{
public function __construct(int $meta = 0){
parent::__construct(self::IRON_PICKAXE, $meta, "Iron Pickaxe");
}
class Pickaxe extends TieredTool{
public function isPickaxe(){
return Tool::TIER_IRON;
return $this->tier;
}
public function getAttackPoints() : int{
return 5;
return self::getBaseDamageFromTier($this->tier) - 2;
}
}

View File

@ -23,17 +23,13 @@ declare(strict_types=1);
namespace pocketmine\item;
class IronShovel extends Tool{
public function __construct(int $meta = 0){
parent::__construct(self::IRON_SHOVEL, $meta, "Iron Shovel");
}
class Shovel extends TieredTool{
public function isShovel(){
return Tool::TIER_IRON;
return $this->tier;
}
public function getAttackPoints() : int{
return 4;
return self::getBaseDamageFromTier($this->tier) - 3;
}
}

View File

@ -1,40 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\item;
class StoneAxe extends Tool{
public function __construct(int $meta = 0){
parent::__construct(self::STONE_AXE, $meta, "Stone Axe");
}
public function isAxe(){
return Tool::TIER_STONE;
}
public function getAttackPoints() : int{
return 5;
}
}

View File

@ -1,35 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\item;
class StoneHoe extends Tool{
public function __construct(int $meta = 0){
parent::__construct(self::STONE_HOE, $meta, "Stone Hoe");
}
public function isHoe(){
return Tool::TIER_STONE;
}
}

View File

@ -1,39 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\item;
class StonePickaxe extends Tool{
public function __construct(int $meta = 0){
parent::__construct(self::STONE_PICKAXE, $meta, "Stone Pickaxe");
}
public function isPickaxe(){
return Tool::TIER_STONE;
}
public function getAttackPoints() : int{
return 4;
}
}

View File

@ -1,39 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\item;
class StoneShovel extends Tool{
public function __construct(int $meta = 0){
parent::__construct(self::STONE_SHOVEL, $meta, "Stone Shovel");
}
public function isShovel(){
return Tool::TIER_STONE;
}
public function getAttackPoints() : int{
return 3;
}
}

View File

@ -1,39 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\item;
class StoneSword extends Tool{
public function __construct(int $meta = 0){
parent::__construct(self::STONE_SWORD, $meta, "Stone Sword");
}
public function isSword(){
return Tool::TIER_STONE;
}
public function getAttackPoints() : int{
return 6;
}
}

View File

@ -23,17 +23,14 @@ declare(strict_types=1);
namespace pocketmine\item;
class IronSword extends Tool{
public function __construct(int $meta = 0){
parent::__construct(self::IRON_SWORD, $meta, "Iron Sword");
}
class Sword extends TieredTool{
public function isSword(){
return Tool::TIER_IRON;
return $this->tier;
}
public function getAttackPoints() : int{
return 7;
return self::getBaseDamageFromTier($this->tier);
}
}

View File

@ -0,0 +1,76 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\item;
abstract class TieredTool extends Tool{
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;
/** @var int */
protected $tier;
public function __construct(int $id, int $meta, string $name, int $tier){
parent::__construct($id, $meta, $name);
$this->tier = $tier;
}
public function getMaxDurability(){
return self::getDurabilityFromTier($this->tier);
}
public static function getDurabilityFromTier(int $tier) : int{
static $levels = [
self::TIER_GOLD => 33,
self::TIER_WOODEN => 60,
self::TIER_STONE => 132,
self::TIER_IRON => 251,
self::TIER_DIAMOND => 1562
];
if(!isset($levels[$tier])){
throw new \InvalidArgumentException("Unknown tier '$tier'");
}
return $levels[$tier];
}
protected static function getBaseDamageFromTier(int $tier) : int{
static $levels = [
self::TIER_WOODEN => 5,
self::TIER_GOLD => 5,
self::TIER_STONE => 6,
self::TIER_IRON => 7,
self::TIER_DIAMOND => 8
];
if(!isset($levels[$tier])){
throw new \InvalidArgumentException("Unknown tier '$tier'");
}
return $levels[$tier];
}
}

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

View File

@ -24,20 +24,16 @@ declare(strict_types=1);
namespace pocketmine\item;
class WoodenAxe extends Tool{
class WoodenAxe extends Axe{
public function __construct(int $meta = 0){
parent::__construct(self::WOODEN_AXE, $meta, "Wooden Axe");
parent::__construct(self::WOODEN_AXE, $meta, "Wooden Axe", self::TIER_WOODEN);
}
public function isAxe(){
return Tool::TIER_WOODEN;
return self::TIER_WOODEN;
}
public function getFuelTime() : int{
return 200;
}
public function getAttackPoints() : int{
return 4;
}
}

View File

@ -24,13 +24,13 @@ declare(strict_types=1);
namespace pocketmine\item;
class WoodenHoe extends Tool{
class WoodenHoe extends Hoe{
public function __construct(int $meta = 0){
parent::__construct(self::WOODEN_HOE, $meta, "Wooden Hoe");
parent::__construct(self::WOODEN_HOE, $meta, "Wooden Hoe", self::TIER_WOODEN);
}
public function isHoe(){
return Tool::TIER_WOODEN;
return self::TIER_WOODEN;
}
public function getFuelTime() : int{

View File

@ -24,20 +24,16 @@ declare(strict_types=1);
namespace pocketmine\item;
class WoodenPickaxe extends Tool{
class WoodenPickaxe extends Pickaxe{
public function __construct(int $meta = 0){
parent::__construct(self::WOODEN_PICKAXE, $meta, "Wooden Pickaxe");
parent::__construct(self::WOODEN_PICKAXE, $meta, "Wooden Pickaxe", self::TIER_WOODEN);
}
public function isPickaxe(){
return Tool::TIER_WOODEN;
return self::TIER_WOODEN;
}
public function getFuelTime() : int{
return 200;
}
public function getAttackPoints() : int{
return 3;
}
}

View File

@ -24,20 +24,16 @@ declare(strict_types=1);
namespace pocketmine\item;
class WoodenShovel extends Tool{
class WoodenShovel extends Shovel{
public function __construct(int $meta = 0){
parent::__construct(self::WOODEN_SHOVEL, $meta, "Wooden Shovel");
parent::__construct(self::WOODEN_SHOVEL, $meta, "Wooden Shovel", self::TIER_WOODEN);
}
public function isShovel(){
return Tool::TIER_WOODEN;
return self::TIER_WOODEN;
}
public function getFuelTime() : int{
return 200;
}
public function getAttackPoints() : int{
return 2;
}
}

View File

@ -24,20 +24,16 @@ declare(strict_types=1);
namespace pocketmine\item;
class WoodenSword extends Tool{
class WoodenSword extends Sword{
public function __construct(int $meta = 0){
parent::__construct(self::WOODEN_SWORD, $meta, "Wooden Sword");
parent::__construct(self::WOODEN_SWORD, $meta, "Wooden Sword", self::TIER_WOODEN);
}
public function isSword(){
return Tool::TIER_WOODEN;
return self::TIER_WOODEN;
}
public function getFuelTime() : int{
return 200;
}
public function getAttackPoints() : int{
return 5;
}
}