LootJS.modifiers((event) => {
    // Using a Set is significantly faster for performance than an Array for lookups
    const blacklist = new Set([
        "minecraft:binding_curse", "minecraft:loyalty", "minecraft:mending",
        "minecraft:unbreaking", "minecraft:vanishing_curse", "minecraft:smite",
        "minecraft:bane_of_arthropods", "minecraft:aqua_affinity", "minecraft:depth_strider",
        "minecraft:respiration", "minecraft:sweeping", "enchancement:slide",
        "enchancement:perception", "enchancement:buoy", "enchancement:berserk",
        "enchancement:molten", "enchancement:lumberjack", "enchancement:bury",
        "enchancement:scooping", "enchancement:grapple", "enchancement:extracting",
        "enchancement:assimilation", "enchancement:frostbite", "majruszsenchantments:breaking_curse",
        "majruszsenchantments:corrosion_curse", "majruszsenchantments:fatigue_curse",
        "majruszsenchantments:incompatibility_curse", "majruszsenchantments:slippery_curse",
        "majruszsenchantments:gold_fuelled", "majruszsenchantments:fuse_cutter",
        "majruszsenchantments:harvester", "majruszsenchantments:immortality",
        "majruszsenchantments:leech", "majruszsenchantments:misanthropy",
        "majruszsenchantments:smelter", "majruszsenchantments:telekinesis",
        "majruszsenchantments:magic_protection", "grapplemod:doublejumpenchantment",
        "grapplemod:wallrunenchantment", "grapplemod:slidingenchantment",
        "spectrum:indestructible", "spectrum:autosmelt", "minecraft:feather_falling"
    ]);

    event.addLootTypeModifier([LootType.CHEST, LootType.ENTITY])
        .modifyLoot(Ingredient.all, (itemStack) => {
            // Fast exit: if it's not enchanted, don't even look at it
            if (!itemStack.enchanted) return itemStack;

            // Handle Enchanted Books (Delete if they contain blacklist)
            if (itemStack.id === 'minecraft:enchanted_book') {
                let removeBook = false;
                itemStack.enchantments.forEach((id) => {
                    if (blacklist.has(id)) removeBook = true;
                });
                return removeBook ? Item.empty : itemStack;
            }

            // Handle Gear (Strip individual enchants)
            itemStack.enchantments.forEach((id) => {
                if (blacklist.has(id)) {
                    itemStack.removeEnchantment(id);
                }
            });

            return itemStack;
        });
});