mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Living: avoid updates of non-armor slots and armor slots which took no damage
this was also updating empty slots ...
This commit is contained in:
parent
0051b34797
commit
c053742f5d
@ -484,14 +484,16 @@ abstract class Living extends Entity{
|
||||
public function damageArmor(float $damage) : void{
|
||||
$durabilityRemoved = (int) max(floor($damage / 4), 1);
|
||||
|
||||
$armor = $this->armorInventory->getContents(true);
|
||||
foreach($armor as $item){
|
||||
$armor = $this->armorInventory->getContents();
|
||||
foreach($armor as $slotId => $item){
|
||||
if($item instanceof Armor){
|
||||
$oldItem = clone $item;
|
||||
$this->damageItem($item, $durabilityRemoved);
|
||||
if(!$item->equalsExact($oldItem)){
|
||||
$this->armorInventory->setItem($slotId, $item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->armorInventory->setContents($armor);
|
||||
}
|
||||
|
||||
private function damageItem(Durable $item, int $durabilityRemoved) : void{
|
||||
|
Loading…
x
Reference in New Issue
Block a user