Introduce Item use results - can be success, fail or none

closes #2693, closes #2705, closes #2734
This commit is contained in:
Dylan K. Taylor
2019-02-14 19:21:29 +00:00
parent d9bbe99b83
commit dce08b4e88
11 changed files with 143 additions and 64 deletions

View File

@@ -35,7 +35,7 @@ class FlintSteel extends Tool{
parent::__construct(self::FLINT_STEEL, 0, "Flint and Steel");
}
public function onActivate(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : bool{
public function onActivate(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : ItemUseResult{
if($blockReplace->getId() === self::AIR){
$level = $player->getLevel();
assert($level !== null);
@@ -44,10 +44,10 @@ class FlintSteel extends Tool{
$this->applyDamage(1);
return true;
return ItemUseResult::success();
}
return false;
return ItemUseResult::none();
}
public function getMaxDurability() : int{