onEvent('recipes', event => {

    const id_prefix = 'bloodmagic:kubejs/arc';

    const recipes = [
        {
            input: '#forge:slimeball/earth',
            tool: '#bloodmagic:arc/resonator',
            result: 'tconstruct:earth_slime_crystal',
            extra: [Item.of('tconstruct:earth_slime_crystal').chance(0.5)],
            id: 'earth_slime_crystal'
        },
        {
            input: '#forge:slimeball/sky',
            tool: '#bloodmagic:arc/resonator',
            result: 'tconstruct:sky_slime_crystal',
            extra: [Item.of('tconstruct:sky_slime_crystal').chance(0.5)],
            id: 'sky_slime_crystal'
        },
        {
            input: '#forge:slimeball/ender',
            tool: '#bloodmagic:arc/resonator',
            result: 'tconstruct:ender_slime_crystal',
            extra: [Item.of('tconstruct:ender_slime_crystal').chance(0.5)],
            id: 'ender_slime_crystal'
        },
        {
            input: 'industrialforegoing:pink_slime',
            tool: '#bloodmagic:arc/resonator',
            result: 'materialis:pink_slime_crystal',
            extra: [Item.of('materialis:pink_slime_crystal').chance(0.5)],
            id: 'pink_slime_crystal'
        }
    ];

    recipes.forEach(recipe => {
        if(!recipe.extra) recipe.extra = [];
        event.recipes.bloodmagic
                .arc(recipe.result, recipe.input, recipe.tool, recipe.extra)
                .id(`${id_prefix}/${recipe.id}`);
    });

    ores.forEach((ore) => {

        var oreId = `#forge:ores/${ore}`;
        var fragment = itemOf(`#bloodmagic:fragments/${ore}`);
        var gravel =  itemOf(`#bloodmagic:gravels/${ore}`);
        var gem = itemOf(`#forge:gems/${ore}`);
        var dust = itemOf(`#forge:dusts/${ore}`);

        if(Item.exists(fragment) && Item.exists(gravel)){
            event.recipes.bloodmagic
                .arc(Item.of(fragment,3), oreId, '#bloodmagic:arc/explosive')
                .id(`bloodmagic:arc/fragments${ore}`);
            event.recipes.bloodmagic
                .arc(gravel, fragment, '#bloodmagic:arc/resonator', [Item.of('bloodmagic:corrupted_tinydust').chance(0.05), Item.of('bloodmagic:corrupted_tinydust').chance(0.005)])
                .id(`bloodmagic:arc/gravels${ore}`);
            
        };

        var output = null, count = 1;
        if(ore_results.has(ore)) {
            let stack = ore_results.get(ore).item;
            output = stack.item;
            count = stack.count;
        }else if(gem != null){
            output = gem;
            count = 2;
        }else if(dust != null){
            output = dust;
        }

        if(gravel != null && output != null) {
            event.recipes.bloodmagic
                .arc(Item.of(output,count), gravel, '#bloodmagic:arc/cuttingfluid')
                .id(`${id_prefix}/${ore}_from_gravel`);
            event.recipes.bloodmagic
                .arc(Item.of(output,count*2), oreId, '#bloodmagic:arc/cuttingfluid')
                .id(`${id_prefix}/${ore}`);
        }

        var crystal = itemOf(`#mekanism:crystals/${ore}`);
        if(Item.exists(crystal)){
            event.recipes.bloodmagic
                .arc(Item.of(crystal,2), oreId, '#bloodmagic:arc/resonator', [Item.of('bloodmagic:corrupted_tinydust').chance(0.2)])
                .id(`${id_prefix}/${ore}_crystal`);
        }
        
    });

})