From f2750c71506e056ca0d7f552cd208056b197a3c6 Mon Sep 17 00:00:00 2001 From: aericio <16523741+Aericio@users.noreply.github.com> Date: Thu, 28 Sep 2023 17:27:54 -1000 Subject: [PATCH] Fix effects not being reset after inventory change --- src/DaPigGuy/PiggyCustomEnchants/EventListener.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DaPigGuy/PiggyCustomEnchants/EventListener.php b/src/DaPigGuy/PiggyCustomEnchants/EventListener.php index 232df95..24c577b 100644 --- a/src/DaPigGuy/PiggyCustomEnchants/EventListener.php +++ b/src/DaPigGuy/PiggyCustomEnchants/EventListener.php @@ -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); } } }