Added Durable class, fixed some tools not breaking correctly, removed some boilerplate code

This commit is contained in:
Dylan K. Taylor
2017-10-08 15:54:31 +01:00
parent ae5aa31e7b
commit aa91183504
7 changed files with 90 additions and 39 deletions

View File

@ -2512,12 +2512,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
}
if($this->isSurvival()){
if($heldItem->isTool()){
if($heldItem->useOn($target) and $heldItem->getDamage() >= $heldItem->getMaxDurability()){
$this->inventory->setItemInHand(ItemFactory::get(Item::AIR, 0, 0));
}else{
$this->inventory->setItemInHand($heldItem);
}
if($heldItem->useOn($target)){
$this->inventory->setItemInHand($heldItem);
}
$this->exhaust(0.3, PlayerExhaustEvent::CAUSE_ATTACK);