// ==========================================
// IRON'S SPELLS: TOTAL BOOK PURGE
// ==========================================

ServerEvents.recipes(event => {
    // 1. Remove all recipes for Spell Books
    event.remove({ output: '#irons_spellbooks:spell_books' })

    // 2. Fix the Scroll Forge Recipe
    // Since the original needs a book, we replace it with a Dragon Bone
    event.remove({ output: 'irons_spellbooks:scroll_forge' })
    event.shaped('irons_spellbooks:scroll_forge', [
        ' S ',
        'IBI',
        'GGG'
    ], {
        S: 'irons_spellbooks:scroll_paper',
        I: 'minecraft:iron_ingot',
        B: 'iceandfire:dragonbone', // Fits your RLCraft theme
        G: 'minecraft:gold_ingot'
    })
})

// 3. THE SLEDGEHAMMER: Aggressive Inventory Scanning
// This checks every player's inventory once per second
PlayerEvents.tick(event => {
    const { player, level } = event
    
    // Only run every 20 ticks (1 second) to maintain performance
    if (level.time % 20 != 0) return

    // Loop through every single slot in the player's inventory
    player.inventory.allItems.forEach(stack => {
        // Check for the global tag you asked about
        if (stack.hasTag('irons_spellbooks:spell_books')) {
            stack.setCount(0) // Vaporize the item instantly
            
            // Send a clear message to the player
            player.displayClientMessage("§4Spell Books are unstable in this world. Use Scrolls!", true)
            
            // Play a "fizzle" sound so they know what happened
            player.playSound('minecraft:block.fire.extinguish', 0.5, 1.2)
        }
    })
})