mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 17:36:12 +00:00
Merge branch 'stable' into minor-next
This commit is contained in:
@ -487,14 +487,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{
|
||||
@ -640,9 +642,12 @@ abstract class Living extends Entity{
|
||||
}
|
||||
|
||||
foreach($this->armorInventory->getContents() as $index => $item){
|
||||
$oldItem = clone $item;
|
||||
if($item->onTickWorn($this)){
|
||||
$hasUpdate = true;
|
||||
$this->armorInventory->setItem($index, $item);
|
||||
if(!$item->equalsExact($oldItem)){
|
||||
$this->armorInventory->setItem($index, $item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user