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: 'bloodmagic:saltpeter', replaceWith: 'emendatusenigmatica:potassium_nitrate_dust'},
        {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: {output: 'minecraft:blast_furnace'},
            toReplace: 'minecraft:iron_ingot',
            replaceWith: 'emendatusenigmatica:cast_iron_ingot'
        },
        {
            filter: {id: 'minecraft:minecart'},
            toReplace: 'minecraft:iron_ingot',
            replaceWith: 'emendatusenigmatica:cast_iron_ingot'
        },
        {
            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: 'emendatusenigmatica:silicon_from_quartz/smelting/nether_quartz'},
            toReplace: 'minecraft:quartz',
            replaceWith: 'emendatusenigmatica:quartz_dust'
        },
        {
            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: 'astralsorcery:shaped/marble/marble_pillar'},
            toReplace: 'astralsorcery:marble_raw',
            replaceWith: 'astralsorcery:marble_chiseled'
        },
        {
            filter: {id: 'astralsorcery:stonecutting/marble_pillar'},
            toReplace: 'astralsorcery:marble_raw',
            replaceWith: 'astralsorcery:marble_chiseled'
        },
        {
            filter: {id: 'astralsorcery:shaped/marble/black_marble_pillar'},
            toReplace: 'astralsorcery:black_marble_raw',
            replaceWith: 'astralsorcery:black_marble_chiseled'
        },
        {
            filter: {id: 'astralsorcery:stonecutting/black_marble_pillar'},
            toReplace: 'astralsorcery:black_marble_raw',
            replaceWith: 'astralsorcery:black_marble_chiseled'
        },
        {
            filter: {id: 'occultism:spirit_fire/otherworld_ashes'},
            toReplace: 'occultism:otherworld_log',
            replaceWith: 'eidolon:enchanted_ash'
        },
        {
            filter: {id: 'occultism:spirit_fire/purified_ink'},
            toReplace: 'minecraft:black_dye',
            replaceWith: Item.of('naturesaura:aura_bottle', '{stored_type:"naturesaura:end"}')
        },
        {
            filter: {id: 'occultism:spirit_fire/spirit_attuned_gem'},
            toReplace: 'minecraft:diamond',
            replaceWith: 'eidolon:lesser_soul_gem'
        },
        {
            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: '#forge:rods/hop_graphite'
        },
        {
            filter: {id: 'immersiveengineering:crafting/windmill'},
            toReplace: 'minecraft:iron_ingot',
            replaceWith: 'emendatusenigmatica:iron_gear'
        },
        {
            filter: {id: 'immersiveengineering:crafting/strip_curtain'},
            toReplace: 'emendatusenigmatica:copper_rod',
            replaceWith: 'engineersdecor:metal_bar'
        },
        {
            filter: {id: 'immersiveengineering:crafting/metal_ladder_none'},
            toReplace: 'emendatusenigmatica:copper_rod',
            replaceWith: 'engineersdecor:metal_bar'
        },
        {
            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: '#forge:gears/holy'
        },
        {
            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).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);
            }
            
            
        })

    })
    

})