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

    const id_prefix = 'masterfulmachinery:kubejs/mana_crystalliser';
    const recipes = [
        {
            outputs: ['astralsorcery:perk_gem_sky'],
            inputs: [
                '#forge:gems/rock_crystal',
                'astralsorcery:illumination_powder',
                { data: Item.of('botania:rune_water').toResultJson(), chance: 0.0 }
            ],
            mana: 10000,
            energy: 2000,
            ticks: 600,
            id: 'perk_gem_sky'
        },
        {
            outputs: ['astralsorcery:perk_gem_day'],
            inputs: [
                '#forge:gems/rock_crystal',
                'astralsorcery:illumination_powder',
                { data: Item.of('botania:rune_fire').toResultJson(), chance: 0.0 }
            ],
            mana: 10000,
            energy: 2000,
            ticks: 600,
            id: 'perk_gem_day'
        },
        {
            outputs: ['astralsorcery:perk_gem_night'],
            inputs: [
                '#forge:gems/rock_crystal',
                'astralsorcery:illumination_powder',
                { data: Item.of('botania:rune_air').toResultJson(), chance: 0.0 }
            ],
            mana: 10000,
            energy: 2000,
            ticks: 600,
            id: 'perk_gem_night'
        },
        {
            outputs: ['astralsorcery:celestial_crystal'],
            inputs: [
                '#forge:gems/rock_crystal',
                'astralsorcery:stardust',
            ],
            mana: 15000,
            energy: 2000,
            ticks: 1200,
            id: 'celestial_crystal'
        },
        {
            outputs: ['appliedenergistics2:purified_nether_quartz_crystal'],
            inputs: [
                'appliedenergistics2:nether_quartz_seed'
            ],
            fluid: { fluid: 'industrialforegoing:ether_gas', amount: 100 },
            mana: 1000,
            energy: 2000,
            ticks: 40,
            id: 'purified_nether_quartz'
        },
        {
            outputs: ['appliedenergistics2:purified_certus_quartz_crystal'],
            inputs: [
                'appliedenergistics2:certus_crystal_seed'
            ],
            fluid: { fluid: 'industrialforegoing:ether_gas', amount: 500 },
            mana: 1000,
            energy: 2000,
            ticks: 80,
            id: 'purified_certus_quartz'
        },
        {
            outputs: ['appliedenergistics2:purified_fluix_crystal'],
            inputs: [
                'appliedenergistics2:fluix_crystal_seed'
            ],
            fluid: { fluid: 'industrialforegoing:ether_gas', amount: 1000 },
            mana: 1000,
            energy: 2000,
            ticks: 160,
            id: 'purified_fluix_quartz'
        },
        {
            outputs: ['2x emendatusenigmatica:fluix_gem'],
            inputs: [
                '2x emendatusenigmatica:charged_certus_quartz_gem',
                'materialis:pink_slime_crystal',
                'botania:quartz_red'
            ],
            fluid: { fluid: 'kubejs:witch_water', amount: 400 },
            mana: 8000,
            energy: 2000,
            ticks: 100,
            id: 'fluix'
        },
        {
            outputs: ['2x occultism:spirit_attuned_crystal'],
            inputs: [
                '6x occultism:spirit_attuned_gem',
                'atum:nepthys_godshard',
                'astralsorcery:nocturnal_powder'
            ],
            fluid: { fluid: 'kubejs:witch_water', amount: 200 },
            mana: 4000,
            energy: 2000,
            ticks: 80,
            id: 'spirit_attuned_crystal'
        },
        {
            outputs: ['botania:gaia_pylon'],
            inputs: [
                '4x #forge:plates/elementium',
                '2x botania:pixie_dust',
                '5x botania:dragonstone'
            ],
            fluid: { fluid: 'kubejs:pristine_ether_gas', amount: 4000 },
            mana: 500000,
            energy: 2000,
            ticks: 1200,
            id: 'gaia_pylon'
        },
    ];

    recipes.forEach((recipe) => {
        
        var buildRecipe = {
            type: 'masterfulmachinery:machine_process',
            structureId: 'mana_crystalliser_structure',
            controllerId: 'mana_crystalliser_crucible'
        };
        buildRecipe.outputs = [];
        recipe.outputs.forEach((output) => {
            jsonOutput = mmItem(false, drop(output, ' '), parseIntD(output, 1));
            buildRecipe.outputs.push(jsonOutput);
        });
        buildRecipe.inputs = [];
        recipe.inputs.forEach((input) => {
            if(typeof input == 'string'){
                let id = drop(input, ' ');
                if(id[0] == '#'){
                    jsonInput = mmItem(true, id.substring(1), parseIntD(input, 1));
                }else{
                    jsonInput = mmItem(false, id, parseIntD(input, 1));
                }
            }else{
                input.type = 'masterfulmachinery:items';
                jsonInput = input;
            }
            buildRecipe.inputs.push(jsonInput);
        });
        if(recipe.fluid) {
            buildRecipe.inputs.push({ type: 'masterfulmachinery:fluids', data: recipe.fluid });
        }
        buildRecipe.inputs.push({ type: 'masterfulmachinery:botania_mana', data: { amount: recipe.mana } });
        buildRecipe.inputs.push({ type: 'masterfulmachinery:energy', perTick: true, data: { amount: recipe.energy } });
        buildRecipe.ticks = recipe.ticks;
        event.custom(buildRecipe).id(`${id_prefix}/${recipe.id}`);

    });
});