Tool: cleanup durability handling, closes #379

long overdue... this isn't quite as extensible as the original api3/blocks system was, but this is primarily intended to replace Item->useOn(). If plugins want to use it it can be extended later on.
This commit is contained in:
Dylan K. Taylor
2018-05-10 19:48:51 +01:00
parent b8523cb304
commit b21572774a
13 changed files with 103 additions and 56 deletions

View File

@ -23,7 +23,9 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockToolType;
use pocketmine\entity\Entity;
class Pickaxe extends TieredTool{
@ -42,4 +44,15 @@ class Pickaxe extends TieredTool{
public function getAttackPoints() : int{
return self::getBaseDamageFromTier($this->tier) - 2;
}
public function onDestroyBlock(Block $block) : bool{
if($block->getHardness() > 0){
return $this->applyDamage(1);
}
return false;
}
public function onAttackEntity(Entity $victim) : bool{
return $this->applyDamage(2);
}
}