diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 9fa7297f..43a6183c 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -1566,7 +1566,7 @@ class Entity extends Position if($v2 < 1) $v2 = 1; foreach($this->player->armor as $slot => $part){ - $part->hurtAndBreak($v2, $this->player); + $part->hurtAndBreak($v2, $this->player, helditem: false); } $this->player->sendArmor(); } diff --git a/src/material/Item.php b/src/material/Item.php index fa194dde..f67a52be 100755 --- a/src/material/Item.php +++ b/src/material/Item.php @@ -223,14 +223,19 @@ class Item{ /** * @param int $dmg - damage dealt to item * @param Player $player - player who used the item + * @param boolean $helditem - modify player's helditem state or not - should be false if using by non-held item(armor damaging for example) */ - public function hurtAndBreak($dmg, Player $player){ + public function hurtAndBreak($dmg, Player $player, $helditem = true){ if(($player->gamemode & 1) !== 0) return; //dont break items in creative if($this->getMaxDurability() !== false){ $this->meta += $dmg; - if($this->meta > $this->getMaxDurability()){ - $player->consumeSingleItem(); + + if($helditem){ + $player->setSlot($player->slot, $this, send: false); + if($this->meta > $this->getMaxDurability()){ + $player->consumeSingleItem(); + } } } }