Skip to content

Commit

Permalink
Fix effects not being reset after inventory change
Browse files Browse the repository at this point in the history
  • Loading branch information
Aericio committed Sep 29, 2023
1 parent bd18618 commit f2750c7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/DaPigGuy/PiggyCustomEnchants/EventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ public function onJoin(PlayerJoinEvent $event): void
$holder = $inventory->getHolder();
if ($holder instanceof Player) {
if (!$oldItem->equals(($newItem = $inventory->getItem($slot)), !$inventory instanceof ArmorInventory)) {
if ($newItem->getTypeId() === BlockTypeIds::AIR || $inventory instanceof ArmorInventory) foreach ($oldItem->getEnchantments() as $oldEnchantment) ToggleableEnchantment::attemptToggle($holder, $oldItem, $oldEnchantment, $inventory, $slot, false);
if ($oldItem->getTypeId() === BlockTypeIds::AIR || $inventory instanceof ArmorInventory) foreach ($newItem->getEnchantments() as $newEnchantment) ToggleableEnchantment::attemptToggle($holder, $newItem, $newEnchantment, $inventory, $slot);
if ($newItem->equals(VanillaItems::AIR()) || $inventory instanceof ArmorInventory) foreach ($oldItem->getEnchantments() as $oldEnchantment) ToggleableEnchantment::attemptToggle($holder, $oldItem, $oldEnchantment, $inventory, $slot, false);
if ($oldItem->equals(VanillaItems::AIR()) || $inventory instanceof ArmorInventory) foreach ($newItem->getEnchantments() as $newEnchantment) ToggleableEnchantment::attemptToggle($holder, $newItem, $newEnchantment, $inventory, $slot);
}
}
}
Expand Down

0 comments on commit f2750c7

Please sign in to comment.