diff --git a/src/entity/Living.php b/src/entity/Living.php index e695ba425..e7d669fda 100644 --- a/src/entity/Living.php +++ b/src/entity/Living.php @@ -149,24 +149,6 @@ abstract class Living extends Entity{ $this->getViewers(), fn(EntityEventBroadcaster $broadcaster, array $recipients) => $broadcaster->onMobArmorChange($recipients, $this) ))); - $playArmorSound = function(Item $newItem, Item $oldItem) : void{ - if(!$newItem->isNull() && $newItem instanceof Armor && !$newItem->equalsExact($oldItem)){ - $equipSound = $newItem->getMaterial()->getEquipSound(); - if($equipSound !== null){ - $this->broadcastSound($equipSound); - } - } - }; - $this->armorInventory->getListeners()->add(new CallbackInventoryListener( - function(Inventory $inventory, int $slot, Item $oldItem) use ($playArmorSound) : void{ - $playArmorSound($inventory->getItem($slot), $oldItem); - }, - function(Inventory $inventory, array $oldContents) use ($playArmorSound) : void{ - foreach($oldContents as $slot => $oldItem){ - $playArmorSound($inventory->getItem($slot), $oldItem); - } - } - )); $health = $this->getMaxHealth(); diff --git a/src/item/Armor.php b/src/item/Armor.php index e9667a8a8..417c57f75 100644 --- a/src/item/Armor.php +++ b/src/item/Armor.php @@ -146,6 +146,10 @@ class Armor extends Durable{ $new = $thisCopy->pop(); $player->getArmorInventory()->setItem($this->getArmorSlot(), $new); $player->getInventory()->setItemInHand($existing); + $sound = $new->getMaterial()->getEquipSound(); + if($sound !== null){ + $player->broadcastSound($sound); + } if(!$thisCopy->isNull()){ //if the stack size was bigger than 1 (usually won't happen, but might be caused by plugins) $returnedItems[] = $thisCopy;