Fix that a hoe gets damage applied to it, when it's used to break a block (#3967)

closes #3965
This commit is contained in:
Mohamed 2020-12-11 22:14:52 +01:00 committed by GitHub
parent 68887105b2
commit 1c43538238
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 0 deletions

View File

@ -35,5 +35,6 @@ interface BlockToolType{
public const TYPE_PICKAXE = 1 << 2;
public const TYPE_AXE = 1 << 3;
public const TYPE_SHEARS = 1 << 4;
public const TYPE_HOE = 1 << 5;
}

View File

@ -31,6 +31,10 @@ class Sponge extends Solid{
$this->meta = $meta;
}
public function getToolType() : int{
return BlockToolType::TYPE_HOE;
}
public function getHardness() : float{
return 0.6;
}

View File

@ -23,11 +23,24 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockToolType;
use pocketmine\entity\Entity;
class Hoe extends TieredTool{
public function getBlockToolType() : int{
return BlockToolType::TYPE_HOE;
}
public function onAttackEntity(Entity $victim) : bool{
return $this->applyDamage(1);
}
public function onDestroyBlock(Block $block) : bool{
if($block->getHardness() > 0){
return $this->applyDamage(1);
}
return false;
}
}