// priority: 1000

onEvent('recipes', e => {


    function unifyTheIngots(name, nugget, ingot, block, dust, raw_ore, raw_ore_block){

        e.replaceOutput(`#forge:ingots/${name}`, ingot)
        e.replaceOutput(`#forge:dusts/${name}`, dust)
        e.replaceOutput(`#forge:nuggets/${name}`, nugget)
        e.replaceOutput(`#forge:storage_blocks/${name}`, block)

        if (!Ingredient.of(raw_ore).empty) {

            e.replaceOutput(`#forge:raw_materials/${name}`, raw_ore)
            e.replaceOutput(`#forge:storage_blocks/raw_${name}`, raw_ore_block)

        }
    
        /* ENABLE LATER GIVES A CHANCE TO CONVERT OLD MATREIALS INTO NEW

        e.replaceInput(`#forge:nuggets/${name}`, nugget)
        e.replaceInput(`#forge:dusts/${name}`, dust)
        e.replaceInput(`#forge:ingots/${name}`, ingot)        
        e.replaceInput(`#forge:storage_blocks/${name}`, block)
        e.replaceInput(`#forge:raw_materials/${name}`, raw_ore)
        e.replaceInput(`#forge:storage_blocks/raw_${name}`, raw_ore_block)

        */


    }
    
    unifyTheIngots('tin', 'thermal:tin_nugget', 'thermal:tin_ingot', 'thermal:tin_block', 'thermal:tin_dust', 'thermal:raw_tin', 'thermal:raw_tin_block')
    unifyTheIngots('lead', 'thermal:lead_nugget', 'thermal:lead_ingot', 'thermal:lead_block', 'thermal:lead_dust', 'thermal:raw_lead', 'thermal:raw_lead_block')
    unifyTheIngots('copper', 'thermal:copper_nugget', 'minecraft:copper_ingot', 'minecraft:copper_block', 'thermal:copper_dust', 'minecraft:raw_copper', 'minecraft:raw_copper_block')

    unifyTheIngots('bronze', 'thermal:bronze_nugget', 'thermal:bronze_ingot', 'thermal:bronze_block', 'thermal:bronze_dust', '', '')
    unifyTheIngots('steel', 'thermal:steel_nugget', 'thermal:steel_ingot', 'thermal:steel_block', 'thermal:steel_dust', '', '')






})

onEvent('recipes', e => {


    function unifyTheGems(name, gem, block, dust){

        e.replaceOutput(`#forge:dusts/${name}`, dust)
        e.replaceOutput(`#forge:gems/${name}`, gem)
        e.replaceOutput(`#forge:storage_blocks/${name}`, block)

        /*
        e.replaceInput(`#forge:dusts/${name}`, dust)
        e.replaceInput(`#forge:gems/${name}`, gem)
        e.replaceInput(`#forge:storage_blocks/${name}`, block)
        */

    }


    unifyTheGems('diamond', 'minecraft:diamond', 'minecraft:diamond_block', 'thermal:diamond_dust')
    unifyTheGems('emerald', 'minecraft:emerald', 'minecraft:emerald_block', 'thermal:emerald_dust')
    unifyTheGems('quartz', 'minecraft:quartz', 'minecraft:quartz_block', 'thermal:quartz_dust')

})

onEvent('recipes', e => {

    //Miscellaneous

    e.replaceOutput('mekanism:sawdust', 'thermal:sawdust')
    e.replaceInput('mekanism:sawdust', 'thermal:sawdust')



})