onEvent('recipes', event => {

    let multiSmelt = (output, input, includeBlasting, id) => {
        event.smelting(output, input).xp(0.7).id(`emendatusenigmatica:${id.format('smelting')}`);
        
        if (includeBlasting) {
          event.blasting(output, input).xp(0.7).id(`emendatusenigmatica:${id.format('blasting')}`);
        }
    }

    metals.forEach(metal => {
        var dust = itemOf(`#forge:dusts/${metal}`);
        var ingot = itemOf(`#forge:ingots/${metal}`);
        if(dust != null && ingot != null) {
            multiSmelt(ingot, dust, true, 'ingot_from_dust/{0}/'+metal);
        }
    });

    ores.forEach(type => {
        var chunk = itemOf(`#forge:chunks/${type}`);
        if(chunk == null) {
            chunk = itemOf(`#forge:ores/${type}`);
        }
        var crushed = itemOf(`#create:crushed_ores/${type}`);
        var result = null;
        if(ore_results.has(type)) {
            result = ore_results.get(type).item;
        }else if(metals.includes(type)) {
            result = itemOf(`#forge:ingots/${type}`);
        }else if(gems.includes(type)){
            result = Item.of(itemOf(`#forge:gems/${type}`),2);
        }
        if(result!=null){
            multiSmelt(result, chunk, true, 'ingot_from_chunk/{0}/'+type);
            if(crushed!=null && result!=null){
                multiSmelt(result, crushed, true, 'ingot_from_crushed/{0}/'+type);
            }
        }
    });

})