ServerEvents.recipes(mystic_sky => {

    function cell(output, item, typeA, typeB, component){
        mystic_sky.shaped(output, [
                'GIG',
                'XCY',
                'AVU'
            ], {
                G: 'ae2:quartz_glass',
                I: item,
                X: typeA,
                C: component,
                Y: typeB,
                A: 'allthemodium:unobtainium_allthemodium_alloy_ingot',
                V: 'allthemodium:unobtainium_vibranium_alloy_ingot',
                U: 'allthemodium:vibranium_allthemodium_alloy_ingot'
            }
        )
    }

    cell('kubejs:lava_cell', 'allthecompressed:blazing_crystal_block_3x', 'minecraft:lava_bucket', 'minecraft:lava_bucket', 'megacells:cell_component_256m')
    cell('kubejs:dirt_cell', 'allthecompressed:dirt_6x', 'minecraft:water_bucket', 'minecraft:mud', 'megacells:cell_component_256m')
    cell('kubejs:moss_cell', 'allthecompressed:moss_block_5x', 'minecraft:bone_block', 'minecraft:bone_block', 'megacells:cell_component_256m')
    cell('kubejs:andesite_cell', 'allthecompressed:andesite_5x', 'minecraft:water_bucket', 'minecraft:lava_bucket', 'megacells:cell_component_256m')
    cell('kubejs:diorite_cell', 'allthecompressed:diorite_5x', 'minecraft:water_bucket', 'minecraft:lava_bucket', 'megacells:cell_component_256m')
    cell('kubejs:granite_cell', 'allthecompressed:granite_5x', 'minecraft:water_bucket', 'minecraft:lava_bucket', 'megacells:cell_component_256m')
    cell('kubejs:tuff_cell', 'allthecompressed:tuff_5x', 'minecraft:water_bucket', 'minecraft:lava_bucket', 'megacells:cell_component_256m')
    cell('kubejs:sand_cell', 'allthecompressed:sand_6x', 'mekanism:crusher', 'mekanism:crusher', 'extendedae:infinity_cobblestone_cell')
    cell('kubejs:red_sand_cell', 'allthecompressed:red_sand_5x', 'minecraft:lava_bucket', 'minecraft:lava_bucket', 'kubejs:sand_cell')
    cell('kubejs:end_stone_cell', 'allthecompressed:end_stone_6x', 'minecraft:purpur_block', 'minecraft:purpur_block', 'megacells:cell_component_256m')
    cell('kubejs:netherrack_cell', 'allthecompressed:netherrack_6x', 'minecraft:lava_bucket', 'minecraft:gravel', 'megacells:cell_component_256m')
    cell('kubejs:clay_cell', 'allthecompressed:clay_5x', 'minecraft:mud', 'minecraft:mud', 'megacells:cell_component_256m')
    cell('kubejs:blackstone_cell', 'allthecompressed:blackstone_6x', 'minecraft:lava_bucket', 'minecraft:blue_ice', 'megacells:cell_component_256m')
    cell('kubejs:basalt_cell', 'allthecompressed:basalt_6x', 'minecraft:lava_bucket', 'minecraft:blue_ice', 'megacells:cell_component_256m')
    cell('kubejs:calcite_cell', 'allthecompressed:calcite_5x', 'minecraft:water_bucket', 'minecraft:bone_block', 'megacells:cell_component_256m')
    cell('kubejs:cobbled_deepslate_cell', 'allthecompressed:cobbled_deepslate_6x', 'minecraft:lava_bucket', 'minecraft:packed_ice', 'megacells:cell_component_256m')
    cell('kubejs:soul_sand_cell', 'allthecompressed:soul_sand_6x', 'allthemodium:soul_lava_bucket', 'minecraft:sand', 'megacells:cell_component_256m')
    cell('kubejs:sky_stone_cell', 'allthecompressed:sky_stone_block_5x', 'allthemodium:soul_lava_bucket', 'ae2:sky_dust', 'megacells:cell_component_256m')

    function universalPress(input, output, id) {
        mystic_sky.custom(
            {
                type: 'ae2:inscriber',
                ingredients: {
                    top: {
                        item: 'kubejs:universal_press'
                    },
                    middle: {
                        item: input
                    }
                },
                mode: 'inscribe',
                result: {
                    count: 1,
                    id: output
                }
            }
        ).id(`kubejs:inscriber/universal_press/${id}`)
    }
    function createCrystalAssemblerRecipe(output, inputs, id, fluid) {
        let recipe = {
            "type": "extendedae:crystal_assembler",
            "input_items": [],
            "output": {
                "id": output.item,
                "count": output.count || 1
            }
        };

        if (fluid) {
            recipe.input_fluid = {
                "amount": fluid.amount || 1000,
                "ingredient":{
                    "fluid": fluid.fluid,
                }

            };

        }

        inputs.forEach(input => {
            let ingredient = {
                "amount": input.count || 1,
                "ingredient": {}
            };

            if (input.tag) {
                ingredient.ingredient.tag = input.tag;
            } else {
                ingredient.ingredient.item = input.item;
            }

            recipe.input_items.push(ingredient);
        });

        mystic_sky.custom(recipe).id(`kubejs:crystal_assembler/${id}`);
    }


    universalPress('ae2:silicon', 'ae2:printed_silicon', 'printed_silicon')
    universalPress('ae2:certus_quartz_crystal', 'ae2:printed_calculation_processor', 'printed_calculation_processor')
    universalPress('minecraft:diamond', 'ae2:printed_engineering_processor', 'printed_engineering_processor')
    universalPress('minecraft:gold_ingot', 'ae2:printed_logic_processor', 'printed_logic_processor')
    universalPress('megacells:sky_steel_ingot', 'megacells:printed_accumulation_processor', 'printed_accumulation_processor')
    universalPress('appflux:charged_redstone', 'appflux:printed_energy_processor', 'printed_energy_processor')
    universalPress('extendedae:entro_crystal', 'extendedae:concurrent_processor_print', 'concurrent_processor_print')
    universalPress('minecraft:iron_block', 'kubejs:universal_press', 'universal_press_duplicate')
    universalPress('advanced_ae:quantum_alloy', 'advanced_ae:printed_quantum_processor', 'printed_quantum_processor')

    const colors = [
        'white', 'yellow', 'orange', 'red', 'pink', 'magenta', 'purple', 'light_blue', 'cyan', 'blue', 'lime', 'green', 'brown', 'light_gray', 'gray', 'black'
    ];

    colors.forEach(color => {
        mystic_sky.shapeless(`4x ae2:${color}_covered_cable`, [`ae2:${color}_covered_dense_cable`]).id(`mystic_sky:ae2/${color}_dense_covered_to_normal`);
        mystic_sky.shapeless(`4x ae2:${color}_smart_cable`, [`ae2:${color}_smart_dense_cable`]).id(`mystic_sky:ae2/${color}_smart_covered_to_normal`);
        mystic_sky.shapeless(`ae2:${color}_covered_dense_cable`, [`4x ae2:${color}_covered_cable`]).id(`mystic_sky:ae2/${color}_covered_to_dense`);
        mystic_sky.shapeless(`ae2:${color}_smart_dense_cable`, [`4x ae2:${color}_smart_cable`]).id(`mystic_sky:ae2/${color}_smart_to_dense`);
    });

    mystic_sky.shapeless(` 4x ae2:fluix_covered_cable`,[`ae2:fluix_covered_dense_cable`]).id(`mystic_sky:ae2/dense_to_normal`)
    mystic_sky.shapeless(` 4x ae2:fluix_smart_cable`,[`ae2:fluix_smart_dense_cable`]).id(`mystic_sky:ae2/smart_dense_to_smart_normal`)

    // duplicating universal press with the circuit slicer for when you used up all your presses
    createCrystalAssemblerRecipe(
        { item: 'extendedae:circuit_cutter'},
        [
            {item: 'extendedae:machine_frame'},
            {item: 'ae2:engineering_processor', count: 8 },
            {item: 'kubejs:universal_press'},
            {item: 'minecraft:stonecutter'}
        ],
        'circuit_cutter_from_universal'
    );

    // making more circuit slicers with the universal press as both have the same capabilities
    mystic_sky.custom({
        "type": "extendedae:circuit_cutter",
        "input": {
            "ingredient": {
            "item": "minecraft:iron_block"
            }
        },
        "output": {
            "count": 1,
            "id": "kubejs:universal_press"
        }
    }).id('extendedae:slicing/universal_press')
  
})