mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-06 01:51:51 +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{
|
public function damageArmor(float $damage) : void{
|
||||||
$durabilityRemoved = (int) max(floor($damage / 4), 1);
|
$durabilityRemoved = (int) max(floor($damage / 4), 1);
|
||||||
|
|
||||||
$armor = $this->armorInventory->getContents(true);
|
$armor = $this->armorInventory->getContents();
|
||||||
foreach($armor as $item){
|
foreach($armor as $slotId => $item){
|
||||||
if($item instanceof Armor){
|
if($item instanceof Armor){
|
||||||
|
$oldItem = clone $item;
|
||||||
$this->damageItem($item, $durabilityRemoved);
|
$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{
|
private function damageItem(Durable $item, int $durabilityRemoved) : void{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user