onEvent('recipes', (event) =>{

    const outputReplace = [
        {toReplace: 'create:powdered_obsidian', replaceWith: 'emendatusenigmatica:obsidian_dust'},
        {toReplace: 'mekanism:dust_obsidian', replaceWith: 'emendatusenigmatica:obsidian_dust'},
        {toReplace: 'occultism:obsidian_dust', replaceWith: 'emendatusenigmatica:obsidian_dust'},
        {toReplace: 'thermal:lumium_ingot', replaceWith: 'emendatusenigmatica:lumium_ingot'},
        {toReplace: 'thermal:signalum_ingot', replaceWith: 'emendatusenigmatica:signalum_ingot'},
        {toReplace: 'thermal:enderium_ingot', replaceWith: 'emendatusenigmatica:enderium_ingot'},
        {toReplace: 'createaddition:copper_rod', replaceWith: 'emendatusenigmatica:copper_rod'},
        {toReplace: 'createaddition:iron_rod', replaceWith: 'emendatusenigmatica:iron_rod'},
        {toReplace: 'createaddition:gold_rod', replaceWith: 'emendatusenigmatica:gold_rod'},
        {toReplace: 'createaddition:brass_rod', replaceWith: 'emendatusenigmatica:brass_rod'},
        {toReplace: 'createaddition:copper_wire', replaceWith: 'immersiveengineering:wire_copper'},
        {toReplace: 'immersiveengineering:coal_coke', replaceWith: 'emendatusenigmatica:coke_gem'},
        {toReplace: 'immersiveengineering:coke', replaceWith: 'emendatusenigmatica:coke_block'},
        {toReplace: 'immersiveengineering:dust_coke', replaceWith: 'emendatusenigmatica:coke_dust'},
        {toReplace: 'immersiveengineering:dust_wood', replaceWith: 'emendatusenigmatica:wood_dust'},
        {toReplace: 'immersiveengineering:slag', replaceWith: 'thermal:slag'},
        {toReplace: 'appliedenergistics2:certus_quartz_crystal', replaceWith: 'emendatusenigmatica:certus_quartz_gem'},
        {toReplace: 'appliedenergistics2:charged_certus_quartz_crystal', replaceWith: 'emendatusenigmatica:charged_certus_quartz_gem'},
        {toReplace: 'appliedenergistics2:certus_quartz_dust', replaceWith: 'emendatusenigmatica:certus_quartz_dust'},
        {toReplace: 'appliedenergistics2:fluix_crystal', replaceWith: 'emendatusenigmatica:fluix_gem'},
        {toReplace: 'appliedenergistics2:fluix_dust', replaceWith: 'emendatusenigmatica:fluix_dust'},
        {toReplace: 'appliedenergistics2:quartz_block', replaceWith: 'emendatusenigmatica:certus_quartz_block'},
        {toReplace: 'appliedenergistics2:fluix_block', replaceWith: 'emendatusenigmatica:fluix_block'},
        {toReplace: 'emendatusenigmatica:dimensional_gem', replaceWith: 'rftoolsbase:dimensionalshard'}
    ];

    const inputReplace = [
        {
            filter: {id: 'naturesaura:bottle_two_the_rebottling'},
            toReplace: '#minecraft:planks',
            replaceWith: '#minecraft:wooden_buttons'
        },
        {
            filter: {id: 'archers_paradox:explosive_arrow'},
            toReplace: 'minecraft:tnt',
            replaceWith: 'thermal:explosive_grenade'
        },
        {
            filter: {id: 'archers_paradox:frost_arrow'},
            toReplace: 'minecraft:packed_ice',
            replaceWith: 'thermal:blizz_powder'
        },
        {
            filter: {id: 'archers_paradox:lightning_arrow'},
            toReplace: 'minecraft:nether_star',
            replaceWith: 'thermal:blitz_powder'
        },
        {
            filter: {id: 'naturesaura:tree_ritual/plant_powder'},
            toReplace: 'naturesaura:sky_ingot',
            replaceWith: 'farmingforblockheads:green_fertilizer'
        },
        {
            filter: {id: 'minecraft:lodestone'},
            toReplace: 'minecraft:netherite_ingot',
            replaceWith: 'tconstruct:hepatizon_block'
        },
        {
            filter: {id: 'create:crafting/kinetics/mechanical_pump'},
            toReplace: 'create:cogwheel',
            replaceWith: 'emendatusenigmatica:iron_gear'
        },
        {
            filter: {id: 'create:crafting/kinetics/encased_chain_drive'},
            toReplace: 'minecraft:iron_nugget',
            replaceWith: 'minecraft:chain'
        },
        {
            filter: {id: 'naturesaura:tree_ritual/eye_improved'},
            toReplace: 'naturesaura:end_flower',
            replaceWith: 'create:rose_quartz'
        },
        {
            filter: {id: 'createaddition:crafting/heater'},
            toReplace: '#forge:rods/iron',
            replaceWith: 'kubejs:inductive_mechanism'
        },
        {
            filter: {id: 'bloodmagic:arc/reversion/weak_blood_orb'},
            toReplace: 'minecraft:diamond',
            replaceWith: 'kubejs:scarlet_gem'
        },
        {
            filter: {id: 'bloodmagic:arc/reversion/apprentice_blood_orb'},
            toReplace: 'minecraft:redstone_block',
            replaceWith: 'emendatusenigmatica:enderium_block'
        },
        {
            filter: {id: 'bloodmagic:arc/reversion/magician_blood_orb'},
            toReplace: 'minecraft:gold_block',
            replaceWith: Item.of('jaept:overcharged_alloy', '{Energy:100000}')
        },
        {
            filter: {id: 'bloodmagic:arc/reversion/master_blood_orb'},
            toReplace: 'bloodmagic:weakbloodshard',
            replaceWith: 'atum:idol_of_labor'
        },
        {
            filter: {id: 'occultism:spirit_fire/spirit_attuned_gem'},
            toReplace: 'minecraft:diamond',
            replaceWith: 'create:polished_rose_quartz'
        },
        {
            filter: {id: 'createaddition:filling/treated_wood_planks'},
            toReplace: '#minecraft:planks',
            replaceWith: 'astralsorcery:infused_wood_planks'
        },
        {
            filter: {},
            toReplace: 'xkdeco:steel_ingot',
            replaceWith: 'emendatusenigmatica:cast_iron_ingot'
        },
        {
            filter: {id: 'immersiveengineering:crafting/coil_lv'},
            toReplace: 'minecraft:iron_ingot',
            replaceWith: 'create:shaft'
        },
        {
            filter: {id: 'immersiveengineering:crafting/coil_mv'},
            toReplace: 'minecraft:iron_ingot',
            replaceWith: 'engineersdecor:thin_steel_pole'
        },
        {
            filter: {id: 'immersiveengineering:crafting/coil_hv'},
            toReplace: 'minecraft:iron_ingot',
            replaceWith: 'immersiveengineering:ingot_hop_graphite'
        },
        {
            filter: {id: 'immersiveengineering:crafting/windmill'},
            toReplace: 'minecraft:iron_ingot',
            replaceWith: 'emendatusenigmatica:iron_gear'
        },
        {
            filter: {id: 'minecraft:beacon'},
            toReplace: 'minecraft:nether_star',
            replaceWith: 'kubejs:beacon_core'
        },
        {
            filter: {id: 'occultism:ritual/craft_satchel'},
            toReplace: 'minecraft:leather',
            replaceWith: 'kubejs:linen_leather'
        },
        {
            filter: {id: 'occultism:ritual/craft_satchel'},
            toReplace: '#forge:string',
            replaceWith: 'immersiveengineering:hemp_fabric'
        },
        {
            filter: {id: 'occultism:ritual/craft_satchel'},
            toReplace: '#forge:ingots/silver',
            replaceWith: 'kubejs:holy_gear'
        },
        {
            filter: {id: 'occultism:ritual/craft_stable_wormhole'},
            toReplace: 'minecraft:ender_pearl',
            replaceWith: 'astralsorcery:colored_lens_spectral'
        },
        {
            filter: {id: 'occultism:ritual/craft_stable_wormhole'},
            toReplace: 'minecraft:quartz',
            replaceWith: Item.of('integrateddynamics:part_connector_omni_directional').ignoreNBT()
        },
        {
            filter: {id: 'occultism:ritual/craft_storage_remote'},
            toReplace: 'minecraft:ender_pearl',
            replaceWith: 'occultism:afrit_essence'
        },
        {
            filter: {id: 'occultism:ritual/craft_storage_remote'},
            toReplace: 'minecraft:quartz',
            replaceWith: 'occultism:stable_wormhole'
        },
        {
            filter: {id: 'pedestals:upgrades/dropper'},
            toReplace: 'minecraft:dropper',
            replaceWith: 'engineersdecor:factory_dropper'
        },
        {
            filter: {id: 'pedestals:upgrades/placer'},
            toReplace: 'minecraft:dispenser',
            replaceWith: 'engineersdecor:factory_placer'
        },
        {
            filter: {id: 'pedestals:upgrades/fluidpump'},
            toReplace: 'minecraft:bucket',
            replaceWith: 'immersiveengineering:fluid_pump'
        },
        {
            filter: {id: 'pedestals:upgrades/fan'},
            toReplace: 'minecraft:feather',
            replaceWith: 'mob_grinding_utils:fan'
        },
        {
            filter: {id: 'pedestals:upgrades/fluidrelay'},
            toReplace: 'minecraft:glass_bottle',
            replaceWith: 'immersiveengineering:fluid_sorter'
        },
        {
            filter: {id: 'pedestals:upgrades/enderimport'},
            toReplace: 'minecraft:hopper',
            replaceWith: 'engineersdecor:factory_hopper'
        },
        {
            filter: {id: 'immersiveengineering:squeezer/graphite_dust'},
            toReplace: '#forge:dusts/coal_coke',
            replaceWith: '#forge:dusts/coke'
        },
        {
            filter: {id: 'powah:energizing/ender_core'},
            toReplace: 'powah:dielectric_casing',
            replaceWith: 'kubejs:dielectric_frame'
        },
        {
            filter: {id: 'powah:energizing/ender_core'},
            toReplace: 'powah:capacitor_basic_tiny',
            replaceWith: 'emendatusenigmatica:enderium_gear'
        },
        {
            filter: {id: 'appliedenergistics2:materials/cardcapacity'},
            toReplace: '#appliedenergistics2:crystals/certus',
            replaceWith: 'rftoolsbase:filter_module'
        },
        {
            filter: {id: 'appliedenergistics2:network/crafting/cpu_crafting_accelerator'},
            toReplace: 'appliedenergistics2:engineering_processor',
            replaceWith: 'lazierae2:parallel_processor'
        },
        {
            filter: {id: 'modularrouters:void_module'},
            toReplace: 'minecraft:lava_bucket',
            replaceWith: 'trashcans:item_trash_can'
        },
        {
            filter: {id: 'modularrouters:range_up_augment'},
            toReplace: 'minecraft:quartz',
            replaceWith: 'rftoolsbase:dimensionalshard'
        },
        {
            filter: {id: 'modularrouters:range_down_augment'},
            toReplace: 'minecraft:quartz',
            replaceWith: 'rftoolsbase:dimensionalshard'
        },
        {
            filter: {},
            toReplace: 'createaddition:copper_spool',
            replaceWith: 'immersiveengineering:wirecoil_copper'
        },
        {
            filter: {},
            toReplace: 'emendatusenigmatica:dimensional_gem',
            replaceWith: '#forge:gems/dimensional'
        },
        {
            filter: {},
            toReplace: 'industrialforegoing:machine_frame_pity',
            replaceWith: 'jaept:machine_frame_pity'
        },
        {
            filter: {},
            toReplace: 'industrialforegoing:machine_frame_simple',
            replaceWith: 'jaept:machine_frame_simple'
        },
        {
            filter: {},
            toReplace: 'industrialforegoing:machine_frame_advanced',
            replaceWith: 'jaept:machine_frame_advanced'
        },
        {
            filter: {},
            toReplace: 'industrialforegoing:machine_frame_supreme',
            replaceWith: 'jaept:machine_frame_supreme'
        },
        {
            filter: {},
            toReplace: 'eidolon:tallow',
            replaceWith: '#forge:tallow'
        },
        {
            filter: {},
            toReplace: 'appliedenergistics2:certus_quartz_crystal',
            replaceWith: '#forge:gems/certus_quartz'
        },
        {
            filter: {},
            toReplace: 'appliedenergistics2:charged_certus_quartz_crystal',
            replaceWith: '#forge:gems/charged_certus_quartz'
        },
        {
            filter: {},
            toReplace: 'appliedenergistics2:certus_quartz_dust',
            replaceWith: '#forge:dusts/certus_quartz'
        },
        {
            filter: {},
            toReplace: 'appliedenergistics2:fluix_crystal', 
            replaceWith: '#forge:gems/fluix'
        },
        {
            filter: {},
            toReplace: 'appliedenergistics2:fluix_dust', 
            replaceWith: '#forge:dusts/fluix'
        },
        {
            filter: {},
            toReplace: 'appliedenergistics2:quartz_block', 
            replaceWith: '#forge:storage_blocks/certus_quartz'
        },
        {
            filter: {},
            toReplace: 'appliedenergistics2:fluix_block', 
            replaceWith: '#forge:storage_blocks/fluix'
        },
        {
            filter: {},
            toReplace: 'refinedstorage:silicon', 
            replaceWith: '#forge:silicon'
        }
    ]

    outputReplace.forEach((recipe) => {
        event.replaceOutput({}, recipe.toReplace, recipe.replaceWith);
    });
    
    inputReplace.forEach((recipe) => {
        event.replaceInput(recipe.filter, recipe.toReplace, recipe.replaceWith);
    });

    metals.concat(gems).concat(cgems).forEach(type => {

        var parts = ['ingots', 'gems', 'nuggets', 'storage_blocks', 'dusts', 'plates', 'rods', 'gears'];

        parts.forEach(part => {

            let tag = `#forge:${part}/${type}`;
            var stacks = toStacks(tag);
            var id = itemOf(tag);

            if(id!=null){
                stacks.forEach(stack => {
                    stack = stack.id;
                    if(stack!=id){
                        event.replaceOutput({}, stack, id);
                        event.replaceInput({}, stack, id);
                    }
                })
                event.replaceInput({}, tag, id);
            }
            
            
        })

    })
    

})