mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Added Durable class, fixed some tools not breaking correctly, removed some boilerplate code
This commit is contained in:
@ -26,7 +26,7 @@ namespace pocketmine\item;
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
abstract class Tool extends Item{
|
||||
abstract class Tool extends Durable{
|
||||
const TIER_WOODEN = 1;
|
||||
const TIER_GOLD = 2;
|
||||
const TIER_STONE = 3;
|
||||
@ -64,18 +64,18 @@ abstract class Tool extends Item{
|
||||
$object->getToolType() === Tool::TYPE_SWORD and $this->isSword() or
|
||||
$object->getToolType() === Tool::TYPE_SHEARS and $this->isShears()
|
||||
){
|
||||
$this->meta++;
|
||||
$this->applyDamage(1);
|
||||
}elseif(!$this->isShears() and $object->getBreakTime($this) > 0){
|
||||
$this->meta += 2;
|
||||
$this->applyDamage(2);
|
||||
}
|
||||
}elseif($this->isHoe()){
|
||||
if(($object instanceof Block) and ($object->getId() === self::GRASS or $object->getId() === self::DIRT)){
|
||||
$this->meta++;
|
||||
$this->applyDamage(1);
|
||||
}
|
||||
}elseif(($object instanceof Entity) and !$this->isSword()){
|
||||
$this->meta += 2;
|
||||
$this->applyDamage(2);
|
||||
}else{
|
||||
$this->meta++;
|
||||
$this->applyDamage(1);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -111,11 +111,6 @@ abstract class Tool extends Item{
|
||||
return $levels[$type];
|
||||
}
|
||||
|
||||
public function isUnbreakable(){
|
||||
$tag = $this->getNamedTagEntry("Unbreakable");
|
||||
return $tag !== null and $tag->getValue() > 0;
|
||||
}
|
||||
|
||||
public function isTool(){
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user