const fire_metal_keys = [
    "metal_feed/fire_metal/ignitium_ingot",
    "metal_feed/fire_metal/moltengold_ingot",
    "metal_feed/fire_metal/serpon_alloy_ingot",
    "metal_feed/fire_metal/forged_steel_ingot",
    "metal_feed/fire_metal/hellstone_ingot"
]
TetraJSEvents.workbenchCraft(event => {
    let { player, level, currentSchematic, currentSlot, targetStack, upgradedStack, materials } = event;

    if (!player || !player.getServer()) return;
    if (level.clientSide || !targetStack || !upgradedStack) return

    let item_module = upgradedStack.getItem().getModuleFromSlot(upgradedStack, currentSlot)
    if (!item_module || !item_module instanceof $ItemModuleMajor) return

    for (const key of fire_metal_keys) {
        if (!dzzl_has_improvement(item_module, upgradedStack, key)) {
            return
        }
    }

    fire_metal_keys.forEach(key => {
        item_module.removeImprovement(upgradedStack, key)
    })

    item_module.addImprovement(upgradedStack, 'all_fire_metal', 0)
    

})

const thunder_metal_keys = [
    "metal_feed/thunder_metal/copper_ingot",
    "metal_feed/thunder_metal/scarlet_neodymium_ingot",
    "metal_feed/thunder_metal/azure_neodymium_ingot",
    "metal_feed/thunder_metal/essence_of_the_storm_metal",
    "metal_feed/thunder_metal/vobrivium_ingot"
]
TetraJSEvents.workbenchCraft(event => {
    let { player, level, currentSchematic, currentSlot, targetStack, upgradedStack, materials } = event;

    if (!player || !player.getServer()) return;
    if (level.clientSide || !targetStack || !upgradedStack) return

    let item_module = upgradedStack.getItem().getModuleFromSlot(upgradedStack, currentSlot)
    if (!item_module || !item_module instanceof $ItemModuleMajor) return

    for (const key of thunder_metal_keys) {
        if (!dzzl_has_improvement(item_module, upgradedStack, key)) {
            return
        }
    }

    thunder_metal_keys.forEach(key => {
        item_module.removeImprovement(upgradedStack, key)
    })

    item_module.addImprovement(upgradedStack, 'all_thunder_metal', 0)
    

})