Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/stable' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
dries-c committed Apr 8, 2024
2 parents 5bac0e0 + 50e2c46 commit 3ad6272
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 31 deletions.
26 changes: 13 additions & 13 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 0 additions & 18 deletions src/entity/Living.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,24 +149,6 @@ protected function initEntity(CompoundTag $nbt) : void{
$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();

Expand Down
4 changes: 4 additions & 0 deletions src/item/Armor.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ public function onClickAir(Player $player, Vector3 $directionVector, array &$ret
$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;
Expand Down

0 comments on commit 3ad6272

Please sign in to comment.