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

    const parts = [
        {name: 'ingot', amount: 144, time: 60, table: true},
        {name: 'gem', amount: 144, time: 60, table: true},
        {name: 'nugget', amount: 16, time: 15, table: true},
        {name: 'rod', amount: 72, time: 40, table: true},
        {name: 'wire', amount: 72, time: 40, table: true},
        {name: 'plate', amount: 144, time: 60, table: true},
        {name: 'dust', amount: 144, time: 60, table: false},
        //{name: 'gear', amount: 576, time: 120, table: false},
        {name: 'sheetmetal', amount: 576, time: 120, table: false},
        {name: 'block', amount: 1296, time: 240, table: false},
    ];

    const temps = [
        500, 425, 790, 330, 950,
        830, 975, 225, 420, 950,
        700, 605, 920, 760, 950,
        900, 1125, 1050, 1350, 1090,
        800, 700, 1000, 400, 670,
        1150, 1400, 1500, 700, 550,
        811, 900, 1150, 1400, 1200,
        1200, 750, 1175, 1250, 1000,
        1500, 1500, 1668, 1907, 1910,
        1530, 690, 1490, 1090, 1550,
        960, 1300, 1300, 650, 1100,
        1300, 850, 790, 1280, 1160,
        1440, // metals
        1450, -1, -1, 140, 445,
        584, 280, 115, 1418, 334,
        637, 637, 637, 1450, 934,
        2047, 2040, 537, 1320, 637,
        -1, 1414, -1, -1, -1
    ];

    for(let i = 0; i < metals.length + gems.length; i++) {

        var material = i<metals.length? metals[i] : gems[i-metals.length];
        var molten = fluidOf(material);

        if(molten != null) {

            var modid = molten.split(':')[0];
            var isMetal = i<metals.length? 'metal/' : '';
            var id_prefix_casting = `${modid}:smeltery/casting/${isMetal}${material}`;
            var id_prefix_melting = `${modid}:smeltery/melting/${isMetal}${material}/`;

            parts.forEach((part) => {

                var item;
                if(part.name != 'block') { 
                    item = itemOf(`#forge:${part.name}s/${material}`); 
                }else{
                    item = itemOf(`#forge:storage_blocks/${material}`);
                    if(quartz.includes(material)) {
                        part = {name: 'block', amount: 576, time: 120, table: false};
                    }
                }

                if(item != null) {

                    let fluid = { tag: `forge:molten_${material}`, amount: part.amount };
                    if(part.table){
                        event.custom({
                            type: 'tconstruct:casting_table',
                            cast: Item.of(`tconstruct:${part.name}_cast`).toResultJson(),
                            cast_consumed: false,
                            fluid: fluid,
                            result: Item.of(item).toResultJson(),
                            cooling_time: part.time
                        }).id(`${id_prefix_casting}/${part.name}_gold_cast`);

                        event.custom({
                            type: 'tconstruct:casting_table',
                            cast: { tag: `tconstruct:casts/single_use/${part.name}`},
                            cast_consumed: true,
                            fluid: fluid,
                            result: Item.of(item).toResultJson(),
                            cooling_time: part.time
                        }).id(`${id_prefix_casting}/${part.name}_sand_cast`)
                    }

                    if(part.name == 'block'){
                        event.custom({
                            type: 'tconstruct:casting_basin',
                            fluid: fluid,
                            result: Item.of(item).toResultJson(),
                            cooling_time: part.time
                        }).id(`${id_prefix_casting}/block`);
                    }

                    let extra = part.name == 'plate'? 's' : '';
                    if(temps[i] != -1) {
                        event.custom({
                            type: 'tconstruct:melting',
                            result: {
                                fluid: molten,
                                amount: part.amount
                            },
                            ingredient: Item.of(item).toResultJson(),
                            temperature: temps[i],
                            time: part.time
                        }).id(`${id_prefix_melting}${part.name}${extra}`);
                    }

                }

            });

            var ore = `#forge:ores/${material}`;
            if(!ore_results.has(material) && itemOf(ore) != null && temps[i] != -1) {
                event.custom({
                    type: 'tconstruct:ore_melting',
                    result: {
                        fluid: molten,
                        amount: i<metals.length? 144 : 288
                    },
                    ingredient: Ingredient.of(ore).toJson(),
                    temperature: temps[i],
                    time: 68
                }).id(`${id_prefix_melting}ore`);
            }
        
        }

    }

    ore_results.forEach((results, material, map) => {
        if(results.fluid != null) {
            event.custom({
                type: 'tconstruct:ore_melting',
                result: results.fluid.result,
                ingredient: Ingredient.of(`#forge:ores/${material}`).toJson(),
                temperature: results.fluid.temp,
                time: 68
            }).id(`tconstruct:smeltery/melting/${material}/ore`);
        }
    })

})