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

    const id_prefix = 'masterfulmachinery:kubejs/industrial_crucible';
    const recipes = [
        {
            output: 'minecraft:rotten_flesh',
            inputs: [
                'minecraft:porkchop',
                'minecraft:brown_mushroom'
            ],
            energy: 1000,
            ticks: 20,
            id: 'rotten_flesh_from_porkchop'
        },
        {
            output: 'minecraft:rotten_flesh',
            inputs: [
                'minecraft:mutton',
                'minecraft:brown_mushroom'
            ],
            energy: 1000,
            ticks: 20,
            id: 'rotten_flesh_from_mutton'
        },
        {
            output: 'minecraft:rotten_flesh',
            inputs: [
                'minecraft:beef',
                'minecraft:brown_mushroom'
            ],
            energy: 1000,
            ticks: 20,
            id: 'rotten_flesh_from_beef'
        },
        {
            output: 'minecraft:rotten_flesh',
            inputs: [
                'minecraft:rabbit',
                'minecraft:brown_mushroom'
            ],
            energy: 1000,
            ticks: 20,
            id: 'rotten_flesh_from_rabbit'
        },
        {
            output: 'minecraft:rotten_flesh',
            inputs: [
                'minecraft:chicken',
                'minecraft:brown_mushroom'
            ],
            energy: 1000,
            ticks: 20,
            id: 'rotten_flesh_from_chicken'
        },
        {
            output: 'eidolon:ender_calx',
            count: 2,
            inputs: [
                'minecraft:ender_pearl',
                'eidolon:enchanted_ash'
            ],
            energy: 1000,
            ticks: 20,
            id: 'ender_calx'
        },
        {
            output: 'eidolon:death_essence',
            count: 4,
            inputs: [
                'eidolon:zombie_heart',
                'minecraft:rotten_flesh',
                'minecraft:bone_meal',
                'minecraft:charcoal'
            ],
            energy: 2000,
            ticks: 60,
            id: 'death_essence'
        },
        {
            output: 'minecraft:golden_carrot',
            inputs: [
                '2-minecraft:gold_nugget',
                'eidolon:enchanted_ash',
                'minecraft:carrot'
            ],
            energy: 2000,
            ticks: 60,
            id: 'golden_carrot'
        },
        {
            output: 'eidolon:crimson_essence',
            count: 2,
            inputs: [
                'minecraft:weeping_vines',
                'minecraft:nether_wart',
                'emendatusenigmatica:sulfur_dust'
            ],
            energy: 1500,
            ticks: 40,
            id: 'crimson_essence_from_vines'
        },
        {
            output: 'eidolon:crimson_essence',
            count: 2,
            inputs: [
                'minecraft:crimson_roots',
                'minecraft:nether_wart',
                'emendatusenigmatica:sulfur_dust'
            ],
            energy: 1500,
            ticks: 40,
            id: 'crimson_essence_from_roots'
        },
        {
            output: 'eidolon:crimson_essence',
            count: 4,
            inputs: [
                'minecraft:crimson_fungus',
                'minecraft:nether_wart',
                'emendatusenigmatica:sulfur_dust'
            ],
            energy: 1500,
            ticks: 40,
            id: 'crimson_essence_from_fungus'
        },
        {
            output: 'kubejs:holy_ingot',
            count: 4,
            inputs: [
                '4-emendatusenigmatica:silver_ingot',
                'kubejs:holy_symbol'
            ],
            energy: 1500,
            ticks: 40,
            id: 'holy_ingot'
        },
        {
            output: 'eidolon:shadow_gem',
            inputs: [
                'minecraft:coal',
                'minecraft:ghast_tear',
                '2-eidolon:death_essence',
                'eidolon:soul_shard',
                'minecraft:diamond'
            ],
            energy: 2000,
            ticks: 80,
            id: 'shadow_gem'
        },
        {
            output: 'eidolon:lesser_soul_gem',
            inputs: [
                '2-minecraft:redstone',
                '2-minecraft:lapis_lazuli',
                'eidolon:soul_shard',
                'minecraft:quartz'
            ],
            energy: 2000,
            ticks: 60,
            id: 'lesser_soul_gem'
        },
        {
            output: 'minecraft:leather',
            inputs: [
                'eidolon:enchanted_ash',
                'minecraft:rotten_flesh'
            ],
            energy: 2000,
            ticks: 40,
            id: 'leather'
        },
        {
            output: 'eidolon:warped_sprouts',
            count: 2,
            inputs: [
                'minecraft:warped_fungus',
                'eidolon:ender_calx',
                'minecraft:nether_wart'
            ],
            energy: 2000,
            ticks: 60,
            id: 'warped_sprouts'
        },
        {
            output: 'eidolon:arcane_gold_ingot',
            count: 2,
            inputs: [
                '2-minecraft:redstone',
                'eidolon:soul_shard',
                '2-minecraft:gold_ingot'
            ],
            energy: 1000,
            ticks: 40,
            id: 'arcane_gold_ingot'
        },
        {
            output: 'eidolon:fungus_sprouts',
            count: 2,
            inputs: [
                'minecraft:brown_mushroom',
                'minecraft:bone_meal',
                'minecraft:wheat_seeds'
            ],
            energy: 2000,
            ticks: 60,
            id: 'fungus_sprouts'
        },
        {
            output: 'minecraft:gunpowder',
            count: 4,
            inputs: [
                'emendatusenigmatica:sulfur_dust',
                'minecraft:bone_meal',
                'minecraft:charcoal'
            ],
            energy: 1500,
            ticks: 40,
            id: 'gunpowder'
        },
        {
            output: 'minecraft:glistering_melon_slice',
            inputs: [
                '2-minecraft:gold_nugget',
                'eidolon:enchanted_ash',
                'minecraft:melon_slice'
            ],
            energy: 2000,
            ticks: 60,
            id: 'glistering_melon_slice'
        },
        {
            output: 'minecraft:golden_apple',
            inputs: [
                '2-minecraft:gold_ingot',
                'eidolon:enchanted_ash',
                'minecraft:apple'
            ],
            energy: 2000,
            ticks: 60,
            id: 'golden_apple'
        },
        {
            output: 'eidolon:polished_planks',
            count: 32,
            inputs: [
                '32-#minecraft:planks',
                'eidolon:soul_shard',
                'eidolon:enchanted_ash'
            ],
            energy: 1500,
            ticks: 40,
            id: 'polished_planks'
        }
    ];

    ores.forEach((ore) => {
        var oreId = `#forge:chunks/${ore}`;
        var crystal = itemOf(`#mekanism:crystals/${ore}`);
        if(Item.exists(crystal)){
            recipes.push({
                output: crystal,
                count: 2,
                inputs: [ oreId, 'eidolon:enchanted_ash' ],
                energy: 2000,
                ticks: 40,
                id: `${ore}_crystal`
            })
        }
    })

    recipes.forEach((recipe) => {
        
        var buildRecipe = {
            type: 'masterfulmachinery:machine_process',
            structureId: 'industrial_crucible_structure',
            controllerId: 'industrial_crucible'
        };
        if(!recipe.count){
            recipe.count = 1;
        }
        buildRecipe.outputs = [{ type: 'masterfulmachinery:items', data: Item.of(recipe.output, recipe.count).toResultJson() }];
        buildRecipe.inputs = [{ type: 'masterfulmachinery:fluids', data: { fluid: 'minecraft:water', amount: 1000 } }];
        recipe.inputs.forEach((input) => {
            cnt = 1;
            if(input.includes('-')){
                cnt = parseInt(input.substring(0,input.indexOf('-')));
                input = input.substring(input.indexOf('-')+1);
            }
            jsonInput = { type: 'masterfulmachinery:items', data: Item.of(input, cnt).toResultJson() }
            buildRecipe.inputs.push(jsonInput);
        });
        buildRecipe.inputs.push({ type: 'masterfulmachinery:energy', perTick: true, data: { amount: recipe.energy } });
        buildRecipe.ticks = recipe.ticks;
        event.custom(buildRecipe).id(`${id_prefix}/${recipe.id}`);

        buildRecipe.outputs = [{ type: 'masterfulmachinery:items', data: Item.of(recipe.output, recipe.count*2).toResultJson() }];
        buildRecipe.inputs[0] = { type: 'masterfulmachinery:fluids', data: { fluid: 'kubejs:witch_water', amount: 100 } };
        buildRecipe.inputs[buildRecipe.inputs.length-1] = { type: 'masterfulmachinery:energy', perTick: true, data: { amount: recipe.energy*2 } };
        event.custom(buildRecipe).id(`${id_prefix}/${recipe.id}_double`);

    });
});
