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); } } }