//priority: 5

//This script replaces various recipes to make them more consistent with TFC. Does not work with fluid based recipes.
ServerEvents.recipes(event => {

    //Handcrafted replacements.
    event.replaceInput(
        {mod: 'handcrafted'},
        'minecraft:iron_ingot',
        'tfc:metal/ingot/wrought_iron'
    )
    event.replaceInput(
        {mod: 'handcrafted'},
        'minecraft:iron_bars',
        'tfc:metal/bars/wrought_iron'
    )
    event.replaceInput(
        {mod: 'handcrafted'},
        'minecraft:gold_ingot',
        'tfc:metal/ingot/gold'
    )
    event.replaceInput(
        {mod: 'handcrafted'},
        'minecraft:sweet_berries',
        '#forge:fruits/berries'
    )
    event.replaceInput(
        {mod: 'handcrafted'},
        'minecraft:glass_bottle',
        'tfc:empty_jar'
    )
    event.replaceInput(
        {mod: 'handcrafted'},
        'minecraft:cod',
        'tfc:food/cod'
    )
    event.replaceInput(
        {mod: 'handcrafted'},
        'minecraft:salmon',
        'tfc:food/salmon'
    )
    event.replaceInput(
        {mod: 'handcrafted'},
        'minecraft:tropical_fish',
        'tfc:food/tropical_fish'
    )

    //IronChests. Helper functions go BRRRR.
    
    function ironchestsinputswap(currentinput, inputswap) {
   
       event.replaceInput(
        {mod: "ironchests"},
        currentinput,
        inputswap
    )}

    ironchestsinputswap('minecraft:chest', '#balm:wooden_chests')
    ironchestsinputswap('minecraft:barrel', '#tfcbarrels:barrels')
    ironchestsinputswap('minecraft:copper_ingot', '#forge:ingots/copper')
    ironchestsinputswap('minecraft:iron_ingot', '#forge:ingots/wrought_iron')
    ironchestsinputswap('minecraft:gold_ingot', 'tfc:metal/ingot/gold')
    ironchestsinputswap('minecraft:diamond', '#forge:gems/diamond')
    ironchestsinputswap('minecraft:amethyst_shard', '#forge:gems/amethyst')

    //Musket
    event.replaceInput(
        {id: 'musketmod:cartridge'},
        'minecraft:iron_nugget',
        '#forge:nuggets'
    )
    event.replaceInput(
        {mod: 'musketmod'},
        'minecraft:stick',
        '#tfc:lumber'
    )
    event.replaceInput(
        {mod: 'musketmod'},
        '#minecraft:planks',
        '#tfc:lumber'
    )
    event.replaceInput(
        {mod: 'musketmod'},
        'minecraft:iron_ingot',
        'tfc:metal/ingot/wrought_iron'
    )
    event.replaceInput(
        {mod: 'musketmod'},
        'minecraft:copper_ingot',
        'tfc:metal/ingot/copper'
    )
    event.replaceInput(
        {id: 'musketmod:musket_with_bayonet_smithing'},
        'minecraft:iron_sword',
        'immersiveengineering:toolupgrade_revolver_bayonet'
    )
    //simpleradio
     event.replaceInput(
        {mod: 'simpleradio'},
        'minecraft:iron_ingot',
        'tfc:metal/ingot/wrought_iron'
    )
    event.replaceInput(
        {mod: 'simpleradio'},
        'minecraft:copper_ingot',
        'tfc:metal/ingot/copper'
    )
    event.replaceInput(
        {mod: 'simpleradio'},
        'minecraft:polished_deepslate',
        '#forge:smooth_stone'
    )
    event.replaceInput(
        {mod: 'simpleradio'},
        'minecraft:lapis_lazuli',
        '#forge:gems/lapis'
    )
    event.replaceInput(
        {mod: 'simpleradio'},
        'minecraft:iron_bars',
        'tfc:metal/bars/wrought_iron'
    )
    event.replaceInput(
        {mod: 'simpleradio'},
        'minecraft:potato',
        '#forge:vegetables/potato'
    )
    event.replaceInput(
        {id: 'simpleradio:transmitting_module'},
        'minecraft:ender_pearl',
        '#forge:ingots/silver'
    ) 
    event.replaceInput(
        {id: 'simpleradio:insulator'},
        '#forge:ingots/wrought_iron',
        '#forge:rods'
    )
    event.replaceInput(
        {id: 'simpleradio:spuddie_talkie'},
        '#forge:ingots/wrought_iron',
        '#forge:rods/copper'
    )
    event.replaceInput(
        {mod: 'simpleradio'},
        'minecraft:quartz',
        '#forge:gems/quartz'
    )
    event.replaceInput(
        {mod: 'simpleradio'},
        'minecraft:iron_block',
        'tfc:metal/double_ingot/wrought_iron'
    )
    //TWT Tweaks
    event.replaceInput(
        {id: "minecraft:grindstone"},
        'minecraft:stone_slab',
        'tfc:handstone'
    )    
    event.replaceInput(
        {input: 'minecraft:amethyst_shard'},
        'minecraft:amethyst_shard',
        '#forge:gems/amethyst'
    )
    event.replaceInput(
        {id: 'waystones:warp_stone'},
        'minecraft:emerald',
        '#forge:gems/emerald'
    )
    event.replaceInput(
        {id: 'toolbelt:belt'},
        'minecraft:iron_ingot',
        'tfc:metal/ingot/wrought_iron'
    )
    event.replaceInput(
        {id: 'toolbelt:pouch'},
        'minecraft:gold_ingot',
        'tfc:metal/ingot/gold'
    )
    event.replaceInput(
        {id: 'parcool:zipline_rope'},       
        'minecraft:string', 
        'tfc:jute_fiber'
    )
    event.replaceInput(
        {id: 'parcool:zipline_rope'}, 
        'minecraft:chain', 
        '#forge:metal/chain'
    )
    event.replaceOutput(
        {mod: 'dfc'},
        Fluid.of('dfc:metal/dfc_aluminum'),
        Fluid.of('tfc_ie_addon:metal/aluminum')
    )
    event.replaceOutput(
        {mod: 'dfc'},
        Fluid.of('dfc:metal/dfc_alumina'),
        Fluid.of('tfc_ie_addon:metal/aluminum')    
    )
    event.replaceOutput(
        {mod: 'dfc'},
        Fluid.of('dfc:metal/dfc_lead'),
        Fluid.of('tfc_ie_addon:metal/lead')
    )
    event.replaceInput(
        {id: 'minecraft:stonecutter'},
        'minecraft:stone',
        '#forge:stone'
    )
    event.replaceInput(
        {id: 'minecraft:stonecutter'},
        'minecraft:iron_ingot',
        '#forge:ingots/wrought_iron',
    )
    event.replaceInput(
        {id: 'tfc:crafting/fire_clay'},
         'tfc:powder/graphite',
         '#forge:dusts/coal_coke'
    )
    event.replaceInput(
        {id: 'dfc:crafting/alt_fire_clay'},
         'tfc:powder/graphite',
         '#forge:dusts/coal_coke'
    )
    event.replaceInput(
        {mod: 'waystones'},
         'minecraft:stone_bricks',
         '#forge:stone_bricks'
    )
    event.replaceInput(
        {id: 'immersiveengineering:crafting/voltmeter'},
         'minecraft:compass',
         '#minecraft:compasses'
    )
    
})