// priority: 0

const charcoalTemp = 247

onEvent('recipes', event => {
    removeRecipeByOutput(event, [
        ENS("chunk_zinc"),
        ENS("chunk_copper"),
    ])

    //zinc & copper ore chunks
    event.shapeless(EE("copper_chunk"), Item.of(ENS("piece_copper"), 4))
    event.shapeless(EE("zinc_chunk"), Item.of(ENS("piece_zinc"), 4))

    //charcoal melting
    let recipes = [
        { type: 'block', amount: 1296, tag: `storage_blocks`, time: 171 },
        { type: 'gem', amount: 144, tag: `gems`, time: 57 },
        { type: 'dust', amount: 144, tag: `dusts`, time: 43 }
    ]
    recipes.forEach((recipe) => {
        event
            .custom({
                type: 'tconstruct:melting',
                ingredient: { tag: F(`${recipe.tag}/charcoal`) },
                result: { fluid: EE("molten_coal"), amount: recipe.amount },
                temperature: charcoalTemp,
                time: 43
            })
            .id(`tconstruct:smeltery/melting/metal/charcoal/${recipe.type}`);
    });

    //molten charcoal casting
    let casts = ['gold', 'sand'];
    casts.forEach((cast) => {
        event
            .custom({
                type: 'tconstruct:casting_table',
                cast: {
                    tag: `tconstruct:casts/${cast == 'sand' ? 'single_use' : 'multi_use'}/gem`
                },
                cast_consumed: cast == 'sand',
                fluid: { name: EE(`molten_coal`), amount: 144 },
                result: MC("charcoal"),
                cooling_time: 64
            })
            .id(`tconstruct:smeltery/casting/charcoal/gem_${cast}_cast`);
    });
    event
        .custom({
            type: 'tconstruct:casting_basin',
            fluid: { name: EE(`molten_coal`), amount: 1296 },
            result: M("block_charcoal"),
            cooling_time: 193
        })
        .id(`tconstruct:smeltery/casting/charcoal/block`);

    //coal coke
    event.recipes.createMixing(EE("coke_dust"), [MC("flint"), Fluid.of(EE("molten_coal"), 100), Fluid.of(MC("water"), 100)])
    event.smoking(EE("coke_gem"), EE("coke_dust")).xp(0).cookingTime(120)
})