// priority: 0

// Visit the wiki for more info - https://kubejs.com/

// onEvent('recipes', event => {
    
ServerEvents.recipes(event => {
    let inscriber = (middle, top, mode, output) => {
        event.custom({
            type: 'ae2:inscriber',
            ingredients: {
                middle: {
                    item: middle
                },
                top: {
                    item: top
                }
            },
            mode: mode,
            result: {
                item: output
            }
        })
    }

    event.remove('ae2:inscriber/silicon_print')
    inscriber('kubejs:refined_silicon', 'ae2:silicon_press', 'inscribe', 'ae2:printed_silicon')

    let transform = (fluidTag, ingredientsList, amount, result) => {
        event.custom({
            type: 'ae2:transform',
            circumstance: {
                type: 'fluid',
                tag: fluidTag
            },
            ingredients: ingredientsList,
            result: {
                count: amount,
                item: result
            }
        })
    }

    event.remove('ae2:transform/fluix_crystal')
    event.remove('ae2:transform/fluix_crystals')
    event.remove('ae2:transform/certus_quartz_crystals')
    event.remove('ae2:transform/chipped_budding_quartz')
    event.remove('ae2:transform/damaged_budding_quartz')
    event.remove('ae2:transform/flawed_budding_quartz')
    transform('bttk:water', [{item: 'ae2:charged_certus_quartz_crystal'}, {item: 'ae2:certus_quartz_dust'}], 2, 'ae2:certus_quartz_crystal')
    transform('bttk:water', [{item: 'ae2:charged_certus_quartz_crystal'}, {item: 'ae2:damaged_budding_quartz'}], 1, 'ae2:chipped_budding_quartz')
    transform('bttk:water', [{item: 'ae2:charged_certus_quartz_crystal'}, {item: 'ae2:quartz_block'}], 1, 'ae2:damaged_budding_quartz')
    transform('bttk:water', [{item: 'ae2:charged_certus_quartz_crystal'}, {item: 'ae2:chipped_budding_quartz'}], 1, 'ae2:flawed_budding_quartz')
    transform('bttk:water', [{item: 'ae2:charged_certus_quartz_crystal'}, {item: 'ae2:fluix_dust'}], 1, 'ae2:fluix_crystal')
    transform('bttk:water', [{item: 'ae2:charged_certus_quartz_crystal'}, {item: 'minecraft:redstone'}, {item: 'minecraft:quartz'}], 2, 'ae2:fluix_crystal')

    let incompleteCertusQuartzCrystal = 'kubejs:incomplete_certus_quartz_crystal'
    event.recipes.create.sequenced_assembly([
        Item.of('ae2:certus_quartz_crystal', 1)
    ], 'ae2:certus_quartz_dust', [
        event.recipes.create.filling(incompleteCertusQuartzCrystal, [incompleteCertusQuartzCrystal, Fluid.of('minecraft:water', 250)])
    ]).transitionalItem(incompleteCertusQuartzCrystal).loops(10).id('bttk:sequenced_assembly/certus_quartz_crystal')

    let crystallizerRecipe = (result, liquidInput, liquidAmount, input) => {
        event.custom({
            type: 'thermal:crystallizer',
            ingredients: [
                {
                    fluid: liquidInput,
                    amount: liquidAmount
                },
                {
                    item: input
                }
            ],
            result: [
                {
                    item: result
                }
            ]
        })
    }

    // crystallizerRecipe('ae2:quartz_cluster', 'minecraft:water', 500, 'ae2:small_quartz_bud')
    // event.shaped('2x ae2:quartz_cluster', [
    //     ' A ',
    //     'ABA',
    //     ' A '
    // ], {
    //     A: 'minecraft:diamond',
    //     B: 'ae2:quartz_cluster'
    // }).id('bttk:quartz_cluster_duplication')

    let siftingRecipe = (mesh, input, timeToProcess, chance, results, count) => {
        event.custom({
            type: "createsifter:sifting",
            ingredients: [
                {
                    item: mesh
                },
                {
                    item: input
                }
            ],
            processingTime: timeToProcess,
            results: results
        })
    }

    event.remove('ae2:misc/deconstruction_certus_quartz_block')
    event.remove('ae2:misc/deconstruction_cut_certus_quartz_block')
    event.remove('ae2:misc/deconstruction_smooth_certus_quartz_block')
    event.remove('ae2:misc/deconstruction_certus_quartz_bricks')
    event.remove('ae2:misc/deconstruction_certus_quartz_pillar')
    event.remove('ae2:misc/deconstruction_chiseled_certus_quartz')
    event.shapeless('4x ae2:certus_quartz_crystal', '#ae2:decorative_quartz').id('ae2:certus_quartz_crystal_from_decorative_blocks')

    // siftingRecipe('createsifter:advanced_brass_mesh', 'ae2:sky_stone_block', 200, 0.0 /* Unused */, [{item: 'ae2:sky_dust', count: 1, chance: 1.0}, {item: 'ae2:certus_quartz_dust', count: 1, chance: 0.15}, {item: 'ae2:certus_quartz_dust', count: 1, chance: 0.10}, {item: 'thermal:quartz_dust', count: 1, chance: 0.05}], 0.0 /* Unused */)
    // event.recipes.create.mixing('ae2:certus_quartz_crystal', ['4x ae2:sky_dust', '4x thermal:quartz_dust', Fluid.of('minecraft:water', 250)]).id('bttk:mixing/certus_quartz_crystal_from_sky_stone_dust')
    
})