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

    const id_prefix = 'botania:kubejs/mana_infusion';

    const recipes = [
        {
            input: '#forge:ingots/iesnium',
            output: 'botania:manasteel_ingot',
            count: 1,
            mana: 3000,
            id: 'manasteel_from'
        },
        {
            input: '#forge:storage_blocks/iesnium',
            output: 'botania:manasteel_block',
            count: 1,
            mana: 27000,
            id: 'manasteel_block'
        },
        {
            input: '#forge:ingots/starmetal',
            output: 'botania:manasteel_ingot',
            count: 2,
            mana: 4000,
            id: 'manasteel_mul'
        },
        {
            input: '#forge:storage_blocks/starmetal',
            output: 'botania:manasteel_block',
            count: 2,
            mana: 36000,
            id: 'manasteel_block_mul'
        },
        {
            input: 'jaept:scarlet_rope',
            output: 'botania:mana_string',
            count: 1,
            mana: 1000,
            id: 'mana_string'
        },
        {
            input: 'bloodmagic:soulsnare',
            output: 'botania:mana_string',
            count: 2,
            mana: 1500,
            id: 'mana_string_mul'
        },
        {
            input: 'engineersdecor:panzerglass_block',
            output: 'botania:mana_glass',
            count: 1,
            mana: 1000,
            id: 'mana_glass'
        },
        {
            input: Item.of('naturesaura:effect_powder', '{effect:"naturesstarlight:starlight_increase"}'),
            output: 'botania:mana_powder',
            count: 1,
            mana: 2000,
            id: 'mana_powder'
        },
        {
            input: 'botania:quartz_dark',
            output: 'botania:quartz_mana',
            count: 1,
            mana: 2000,
            id: 'mana_quartz'
        },
        {
            input: '#forge:gems/charged_certus_quartz',
            output: 'botania:quartz_mana',
            count: 2,
            mana: 3000,
            id: 'mana_quartz_mul'
        },
        {
            input: 'rftoolsbase:infused_enderpearl',
            output: 'botania:mana_pearl',
            count: 1,
            mana: 6000,
            id: 'mana_pearl'
        },
        {
            input: 'kubejs:vibrant_gem',
            output: 'botania:mana_diamond',
            count: 1,
            mana: 8000,
            id: 'mana_diamond'
        },
        {
            input: 'emendatusenigmatica:quartz_crystal',
            output: 'appliedenergistics2:nether_quartz_seed',
            catalyst: 'botania:vivid_grass',
            count: 1,
            mana: 1500,
            id: 'nether_quartz_seed'
        },
        {
            input: 'emendatusenigmatica:certus_quartz_crystal',
            output: 'appliedenergistics2:certus_crystal_seed',
            catalyst: 'botania:vivid_grass',
            count: 1,
            mana: 1500,
            id: 'certus_crystal_seed'
        },
        {
            input: 'twilightforest:tower_wood',
            output: 'twilightforest:tower_wood_infested',
            catalyst: 'botania:mutated_grass',
            count: 1,
            mana: 2000,
            id: 'tower_wood_infested'
        },
        {
            input: Item.of('powah:energy_cell_basic').ignoreNBT(),
            output: 'masterfulmachinery:mana_crystalliser_energy_port_energy_input',
            catalyst: 'botania:infused_grass',
            count: 1,
            mana: 10000,
            id: 'mana_crystalliser_energy_input_port'
        },
        {
            input: 'rftoolsbase:dimensionalshard',
            output: 'kubejs:temporal_shard',
            catalyst: 'botania:alchemy_catalyst',
            count: 1,
            mana: 4000,
            id: 'temporal_shard'
        },
        {
            input: 'minecraft:blue_ice',
            output: 'powah:dry_ice',
            catalyst: 'botania:alchemy_catalyst',
            count: 1,
            mana: 4000,
            id: 'dry_ice'
        },
        {
            input: 'botania:black_mystical_flower',
            output: 'botania:black_lotus',
            catalyst: 'botania:alchemy_catalyst',
            count: 1,
            mana: 8000,
            id: 'black_lotus'
        },
    ];

    const grassTypes = ['dry', 'golden', 'vivid', 'scorched', 'infused', 'mutated'];

    grassTypes.forEach((type) => {
        let constructed_recipe = {
            type: 'botania:mana_infusion',
            input: Ingredient.of('botania:grass_seeds').toJson(),
            output: Item.of(`botania:${type}_seeds`).toResultJson(),
            catalyst: { type: 'block', block: `botania:${type}_grass` },
            mana: 4000
        };
        event.custom(constructed_recipe).id(`${id_prefix}/${type}_seeds`);
    })

    const itemsConvertions = [
        {
            items: [
                Item.of('naturesaura:aura_bottle', '{stored_type:"naturesaura:overworld"}'),
                Item.of('naturesaura:aura_bottle', '{stored_type:"naturesaura:nether"}'),
                Item.of('naturesaura:aura_bottle', '{stored_type:"naturesaura:end"}'),
                Item.of('naturesaura:aura_bottle', '{stored_type:"naturesaura:other"}')
            ],
            mana: 1500,
            id: 'aura_bottle'
        },
        { 
            tag: '#bloodmagic:crystals/demon',
            mana: 2000,
            id: 'demon_crystal'
        },
        {
            tag: '#atum:godshards',
            mana: 1000,
            id: 'godshard'
        },
        {
            items: [
                Item.of('botania:livingwood_twig'),
                Item.of('twilightforest:liveroot')
            ],
            mana: 2000,
            id: 'liveroot'
        },
        {
            items: [
                Item.of('tconstruct:dragon_scale'),
                Item.of('twilightforest:naga_scale')
            ],
            mana: 4000,
            id: 'scale'
        },
        {
            items: [
                Item.of('minecraft:dragon_head'),
                Item.of('twilightforest:hydra_trophy')
            ],
            mana: 10000,
            id: 'dragon_head'
        }
    ];

    itemsConvertions.forEach((itemsConvertion) => {
        var items = itemsConvertion.tag?
            utils.listOf(Ingredient.of(itemsConvertion.tag).stacks).toArray() :
            itemsConvertion.items;
        var len = items.length;
        for(i=0;i<len;i++){
            var result = items[(i+1)%len];
            let constructed_recipe = {
                type: 'botania:mana_infusion',
                input: items[i].toJson(),
                output: result.toResultJson(),
                catalyst: { type: 'block', block: 'botania:alchemy_catalyst' },
                mana: itemsConvertion.mana
            };
            event.custom(constructed_recipe).id(`${id_prefix}/${itemsConvertion.id}_${i}`);
        }
    })

    recipes.forEach((recipe) => {
        let constructed_recipe = {
            type: 'botania:mana_infusion',
            input: Ingredient.of(recipe.input).toJson(),
            output: { item: recipe.output, count: recipe.count },
            mana: recipe.mana
        };

        if (recipe.catalyst) {
            constructed_recipe.catalyst = {
                type: 'block',
                block: recipe.catalyst
            };
        }

        event.custom(constructed_recipe).id(`${id_prefix}/${recipe.id}`);
    });
});
