events.listen('recipes', event => {
    event.shaped(item.of('mekanism:qio_drive_array', 1), [
        'PAP',
        'UCU',
        'PTP'
    ], {
        P: 'mekanism:pellet_polonium',
        U: 'mekanism:ultimate_control_circuit',
        T: 'mekanism:teleportation_core',
        C: 'mekanism:personal_chest',
        A: 'appliedenergistics2:controller'
    })
    
    event.shaped(item.of('mekanism:teleportation_core', 1), [
        'ABA',
        'CDC',
        'ABA'
    ], {
        A: '#forge:ingots/enderium',
        B: '#forge:alloys/ultimate',
        C: '#forge:ingots/gold',
        D: '#forge:gems/diamond'
    })
    
    event.shaped(item.of('mekanism:advanced_control_circuit', 1), [
        ' A ',
        'BCB',
        ' A '
    ], {
        A: '#forge:ingots/invar',
        B: '#forge:alloys/advanced',
        C: 'mekanism:basic_control_circuit'
    })
    
    event.shaped(item.of('mekanism:elite_control_circuit', 1), [
        ' A ',
        'BCB',
        ' A '
    ], {
        A: '#forge:ingots/electrum',
        B: '#forge:alloys/elite',
        C: 'mekanism:advanced_control_circuit'
    })
    
    event.shaped(item.of('mekanism:ultimate_control_circuit', 1), [
        ' A ',
        'BCB',
        ' A '
    ], {
        A: '#forge:ingots/enderium',
        B: '#forge:alloys/ultimate',
        C: 'mekanism:elite_control_circuit'
    })
    
    event.shaped(item.of('mekanism:atomic_disassembler', 1), [
        'ABA',
        'ACA',
        ' D '
    ], {
        A: '#forge:alloys/advanced',
        B: 'mekanism:energy_tablet',
        C: 'kubejs:disassembly_core',
        D: '#forge:ingots/refined_obsidian'
    })
    
    event.shaped(item.of('mekanism:digital_miner', 1), [
        'ABA',
        'CDC',
        'EFE'
    ], {
        A: '#forge:alloys/ultimate',
        B: 'kubejs:miner_control_circuit',
        C: 'mekanism:logistical_sorter',
        D: 'mekanism:robit',
        E: 'mekanism:teleportation_core',
        F: 'mekanism:atomic_disassembler'
    })

    event.shaped(item.of('mekanism:upgrade_speed', 1), [
        ' A ',
        'BCB',
        ' A '
    ], {
        A: '#forge:ingots/electrum',
        B: '#forge:alloys/advanced',
        C: '#forge:dusts/osmium'
    })

    event.shaped(item.of('mekanism:upgrade_energy', 1), [
        ' A ',
        'BCB',
        ' A '
    ], {
        A: '#forge:ingots/electrum',
        B: '#forge:alloys/advanced',
        C: '#forge:dusts/gold'
    })

    event.shaped(item.of('mekanism:upgrade_muffling', 2), [
        ' A ',
        'BCB',
        ' A '
    ], {
        A: '#forge:glass',
        B: '#forge:alloys/advanced',
        C: '#mana-and-artifice:all_concrete'
    })

    event.shaped(item.of('mekanismgenerators:gas_burning_generator', 1), [
        'ADA',
        'CBC',
        'ADA'
    ], {
        A: '#forge:ingots/osmium',
        B: '#forge:circuits/elite',
        C: 'mekanism:steel_casing',
        D: 'kubejs:reinforced_electrolytic_core'
    })

    event.shaped(item.of('mekanism:electrolytic_separator', 1), [
        'ABA',
        'CDC',
        'ABA'
    ], {
        A: '#forge:ingots/iron',
        B: '#forge:dusts/redstone',
        C: '#forge:alloys/elite',
        D: 'kubejs:reinforced_electrolytic_core'
    })

    event.shaped(item.of('mekanism:structural_glass', 2), [
        ' A ',
        'ABA',
        ' A '
    ], {
        A: '#forge:ingots/steel',
        B: '#forge:glass'
    })

    event.shaped(item.of('mekanismgenerators:turbine_casing', 2), [
        ' A ',
        'ABA',
        ' A '
    ], {
        A: '#forge:ingots/osmium',
        B: 'kubejs:infused_casing'
    })

    event.shaped(item.of('mekanismgenerators:electromagnetic_coil', 1), [
        'ABA',
        'CDC',
        'ABA'
    ], {
        A: '#forge:ingots/steel',
        B: 'immersiveengineering:coil_mv',
        C: '#forge:ingots/electrum',
        D: 'mekanism:energy_tablet'
    })

    event.shaped(item.of('mekanismgenerators:rotational_complex', 1), [
        'ABA',
        'CBC',
        'ABA'
    ], {
        A: '#forge:ingots/steel',
        B: '#forge:alloys/elite',
        C: '#forge:circuits/elite'
    })

    event.shaped(item.of('mekanismgenerators:turbine_valve', 2), [
        'EAE',
        'ABA',
        'PAP'
    ], {
        A: 'mekanismgenerators:turbine_casing',
        B: '#forge:circuits/elite',
        E: 'mekanism:ultimate_universal_cable',
        P: 'mekanism:ultimate_pressurized_tube'
    })

    event.shaped(item.of('mekanismgenerators:turbine_vent', 2), [
        'ABA',
        'BCB',
        'ABA'
    ], {
        A: '#forge:ingots/enderium',
        B: 'mekanismgenerators:turbine_casing',
        C: 'minecraft:iron_bars'
    })

    event.shaped(item.of('mekanismgenerators:turbine_rotor', 1), [
        'ABA',
        'ABA',
        'ABA'
    ], {
        A: '#forge:ingots/steel',
        B: '#forge:alloys/elite'
    })

    event.shaped(item.of('mekanismgenerators:saturating_condenser', 1), [
        'ABA',
        'BCB',
        'ABA'
    ], {
        A: '#forge:ingots/steel',
        B: '#forge:ingots/silver',
        C: 'minecraft:blue_ice'
    })

    event.shaped(item.of('mekanismgenerators:reactor_glass', 2), [
        'ABA',
        'BCB',
        'ABA'
    ], {
        A: 'mekanism:enriched_iron',
        B: '#forge:ingots/lead',
        C: '#thermal:glass/hardened'
    })

    event.shaped(item.of('mekanismgenerators:fission_reactor_casing', 2), [
        ' A ',
        'ABA',
        ' A '
    ], {
        A: '#forge:ingots/lead',
        B: 'mekanism:steel_casing'
    })

    event.shaped(item.of('mekanismgenerators:fission_reactor_port', 2), [
        'PA ',
        'ABA',
        ' AP'
    ], {
        A: 'mekanismgenerators:fission_reactor_casing',
        B: '#forge:circuits/ultimate',
        P: 'mekanism:ultimate_pressurized_tube'
    })

    event.shaped(item.of('mekanismgenerators:fission_reactor_port', 2), [
        ' AP',
        'ABA',
        'PA '
    ], {
        A: 'mekanismgenerators:fission_reactor_casing',
        B: '#forge:circuits/ultimate',
        P: 'mekanism:ultimate_pressurized_tube'
    })

    event.shaped(item.of('mekanismgenerators:control_rod_assembly', 1), [
        'ABA',
        'CAC',
        'CAC'
    ], {
        A: '#forge:ingots/lead',
        B: '#forge:circuits/ultimate',
        C: '#forge:ingots/steel'
    })

    event.shaped(item.of('mekanismgenerators:fission_fuel_assembly', 2), [
        'ABA',
        'ACA',
        'ABA'
    ], {
        A: '#forge:ingots/lead',
        B: '#forge:ingots/steel',
        C: 'mekanism:elite_chemical_tank'
    })

    event.shaped(item.of('mekanismgenerators:fusion_reactor_frame', 2), [
        'ABA',
        'BCB',
        'ABA'
    ], {
        A: '#forge:alloys/ultimate',
        B: 'mekanism:pellet_polonium',
        C: 'kubejs:reinforced_casing'
    })

    event.shaped(item.of('mekanismgenerators:fusion_reactor_port', 2), [
        'EAE',
        'ABA',
        'PAP'
    ], {
        A: 'mekanismgenerators:fusion_reactor_frame',
        B: '#forge:circuits/ultimate',
        E: 'mekanism:ultimate_universal_cable',
        P: 'mekanism:ultimate_pressurized_tube'
    })

    event.shaped(item.of('mekanismgenerators:fusion_reactor_controller', 1), [
        'ABA',
        'CDC',
        'CCC'
    ], {
        A: '#forge:circuits/ultimate',
        B: '#forge:glass_panes',
        C: 'mekanismgenerators:fusion_reactor_frame',
        D: 'mekanism:ultimate_chemical_tank'
    })

    event.shaped(('1x mekanismgenerators:turbine_blade'), [
        ' S ',
        'SAS',
        ' S '
    ], {
        S: '#forge:ingots/steel',
        A: 'mekanism:alloy_reinforced'
    })

    var basicPipesCenter = [
        'minecraft:redstone_block',
        'minecraft:bucket',
        '#forge:glass',
        'mekanism:basic_control_circuit',
        '#forge:ingots/copper'
    ]

    var pipesCenter = [
        'mekanism:alloy_infused',
        'mekanism:alloy_reinforced',
        'mekanism:alloy_atomic'
    ]

    var tiers = [
        'basic_',
        'advanced_',
        'elite_',
        'ultimate_'
    ]

    var pipeTypes = [
        'universal_cable',
        'mechanical_pipe',
        'pressurized_tube',
        'logistical_transporter',
        'thermodynamic_conductor'
    ]

    for (var i in pipeTypes){
        event.remove({output: 'mekanism:basic_' + pipeTypes[i]})
        if(i==0){
            event.shaped(('4x mekanism:basic_' + pipeTypes[i]), [
                'ABA'
            ], {
                A: '#forge:ingots/steel',
                B: basicPipesCenter[i]
            })
        } else {
            event.shaped(('2x mekanism:basic_' + pipeTypes[i]), [
                'ABA'
            ], {
                A: '#forge:ingots/steel',
                B: basicPipesCenter[i]
            })
        }

        for (var j=1; j < tiers.length; j++){
            event.remove({output: 'mekanism:' + tiers[j] + pipeTypes[i]})
            event.shaped(('2x mekanism:' + tiers[j] + pipeTypes[i]), [
                'ABA'
            ], {
                A: 'mekanism:' + tiers[j-1] + pipeTypes[i],
                B: pipesCenter[j-1]
            })
        }
    }
})