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

    const id_prefix = 'tconstruct:smeltery/casting/eemetal';

    const parts = [
        {name: 'ingot', amount: 144, time: 60},
        {name: 'nugget', amount: 16, time: 15},
        {name: 'rod', amount: 72, time: 40},
        {name: 'plate', amount: 144, time: 60}
    ];

    metals.forEach((metal) => {

        parts.forEach((part) => {

            if(Item.exists(`emendatusenigmatica:${metal}_${part.name}`)) {
                if(Fluid.exists(`tconstruct:molten_${metal}`) || Fluid.exists(`emendatusenigmatica:molten_${metal}`)) {

                    event.custom({
                        type: 'tconstruct:casting_table',
                        cast: Item.of(`tconstruct:${part.name}_cast`).toResultJson(),
                        cast_consumed: false,
                        fluid: {
                            tag: `forge:molten_${metal}`,
                            amount: part.amount
                        },
                        result: Item.of(`emendatusenigmatica:${metal}_${part.name}`).toResultJson(),
                        cooling_time: part.time
                    })
                    .id(`${id_prefix}/${metal}/${part.name}_gold_cast`);

                    event.custom({
                        type: 'tconstruct:casting_table',
                        cast: { tag: `tconstruct:casts/single_use/${part.name}`},
                        cast_consumed: true,
                        fluid: {
                            tag: `forge:molten_${metal}`, 
                            amount: part.amount
                        },
                        result: Item.of(`emendatusenigmatica:${metal}_${part.name}`).toResultJson(),
                        cooling_time: part.time
                    })
                    .id(`${id_prefix}/${metal}/${part.name}_sand_cast`)

                }
            }

        })


        if(Item.exists(`emendatusenigmatica:${metal}_block`)){
            event.custom({
                type: 'tconstruct:casting_basin',
                fluid: {
                    tag: `forge:molten_${metal}`,
                    amount: 1296
                },
                result: Item.of(`emendatusenigmatica:${metal}_block`).toResultJson(),
                cooling_time: 160
            })
            .id(`${id_prefix}/${metal}/block`);
        }


    });

})