ServerEvents.recipes(event => {
    // Creating dough from flour from plants is a major progression item for Agricultural grist, so we set it all up in here.

    // First, we set up the flour processing lines
    let flourItem = AlmostUnified.getPreferredItemForTag('forge:flour');
    let doughItem = AlmostUnified.getPreferredItemForTag('forge:dough');
    event.remove({output: flourItem});
    event.remove({output: doughItem});
    // Vanilla crafting with a hammer gives 0.5x flour per wheat
    event.shapeless(flourItem.withCount(1), ['2x #croptopia:flourable', '#alltheores:ore_hammers']);
    // Basic tier of grist gives 2x flour per wheat
    event.recipes.create.crushing(flourItem.withCount(2), '#croptopia:flourable');
    event.recipes.create.milling(flourItem.withCount(2), '#croptopia:flourable');
    // Late basic gives 4x per wheat
    event.recipes.thermal.pulverizer('#croptopia:flourable', [flourItem.withCount(4)]);

    // Dough production scales through the grist tiers. Yeast can always be used to further scale output
    // Vanilla production takes 2x flour to make 1x dough on the crafting table
    //event.shapeless('1x create:dough', [flourItem.withCount(2), '#forge:water_bottles']);
    //event.shapeless('8x create:dough', ['2x #forge:flour', '#forge:water_bottles', 'bakery:yeast']);

    // Cooking pot is 2x efficient
    event.custom({
        type: 'farmersdelight:cooking',
        cookingtime: 15,
        experience: 1.0,
        ingredients: [
            {tag: 'forge:flour'},
            {tag: 'forge:water_bottles'},
        ],
        result: doughItem.withCount(2)
    }).id('kubejs:farmersdelight_cooking_dough_from_flour_with_yeast_manual_only');
    event.custom({
        type: 'farmersdelight:cooking',
        cookingtime: 20,
        experience: 1.0,
        ingredients: [
            {tag: 'forge:flour'},
            {tag: 'forge:water_bottles'},
            {item: 'bakery:yeast'},
        ],
        result: doughItem.withCount(8).toJson()
    }).id('kubejs:farmersdelight_cooking_dough_from_flour_manual_only');

    // A create mixer is 4x efficient
    event.custom({
        type: 'create:mixing',
        ingredients: ['#forge:flour', {fluid: 'minecraft:water', amount: 50}],
        results: [doughItem.withCount(4).toJson()]
    });
    event.custom({
        type: 'create:mixing',
        ingredients: ['#forge:flour', 'bakery:yeast', {fluid: 'minecraft:water', amount: 50}],
        results: [doughItem.withCount(8).toJson()]
    });

    // The thermal bottler (basic build grist) is 4x efficient
    event.recipes.thermal.bottler(doughItem.withCount(8), [Fluid.of("minecraft:water", 50), '#forge:flour']);

    /*
    Agricultural grist
    none -> basic: plant some wheat, make dough, cook with veggies and meat -> unlock early mob farming, botany pots, kitchen parts
        basic grist comes from flour + primordeal grist + veggies cooked in a pot with a block of basic primordeal
        after you get basic grist, you can smelt basic grist with dough..?
        basic grist comes from basic grist + block of primordeal + dough + sugar
        your first basic grist comes from chutney + primordeal + meat + dough + sugar
        chutney comes from primordeal grist + sugar + fruit + caupona vinegar + chives
    */
    event.custom({
        type: 'farmersdelight:cooking',
        cookingtime: 400,
        experience: 5.0,
        ingredients: [
            {item: 'kubejs:grist_primordeal_basic_block'},
            {item: 'minecraft:sugar'},
            {item: 'caupona:vinegar_spice_jar'},
            {tag: 'forge:fruits'},
            {tag: 'forge:fruits'},
            {item: 'caupona:chives_spice_jar'},
        ],
        result: {item: 'kubejs:grist_chutney', count: 2}
    });
    event.custom({
        type: 'farmersdelight:cooking',
        cookingtime: 600,
        experience: 1.0,
        ingredients: [
            {item: 'kubejs:grist_primordeal_basic_block'},
            {item: 'kubejs:grist_chutney'},
            {tag: 'forge:foods/meat/cooked'},
            {tag: 'forge:dough'},
            {item: 'minecraft:gunpowder'}
        ],
        result: {item: 'kubejs:grist_agricultural_basic_block', count: 1}
    });
    event.custom({
        type: 'farmersdelight:cooking',
        cookingtime: 200,
        experience: 2.0,
        ingredients: [
            {item: 'kubejs:grist_primordeal_basic_block'},
            {tag: 'kubejs:grist/agricultural/basic'},
            {tag: 'forge:dough'},
            {item: 'minecraft:gunpowder'}
        ],
        result: {item: 'kubejs:grist_agricultural_basic_block', count: 1}
    });

    /*
    improved grist comes from cooking improved grist with primordeal and dough
    your first improved grist comes from cooking grist treat with grist chutney and improved primordeal block
    grist treats come from coating collectorsreap gummies in grist spice
    grist spice blend comes from grist morsels + asafoeteda + basic grist resting in a dolum
    grist morsels come from dissolving complicated dishes in the dissolution chamber
    */
    event.custom({
        type: 'farmersdelight:cooking',
        cookingtime: 500,
        experience: 1.0,
        ingredients: [
            {item: 'kubejs:grist_primordeal_improved_block'},
            {tag: 'kubejs:grist/agricultural/improved'},
            {item: 'kubejs:grist_primordeal_improved_block'},
            {tag: 'kubejs:grist/agricultural/improved'},
        ],
        result: {item: 'kubejs:grist_agricultural_improved', count: 4}
    });
    event.custom({
        type: 'farmersdelight:cooking',
        cookingtime: 500,
        experience: 1.0,
        ingredients: [
            {item: 'kubejs:grist_primordeal_basic_block'},
            {item: 'kubejs:grist_treats'},
            {item: 'kubejs:grist_treats'},
            {item: 'kubejs:grist_treats'},
            {item: 'kubejs:grist_chutney'},
            {item: 'kubejs:grist_chutney'},
        ],
        result: {item: 'kubejs:grist_agricultural_improved'}
    });
    event.shaped('kubejs:grist_treats', [
        'AAA',
        'ABA',
        'AAA'
    ], {
        'A': 'kubejs:spiced_grist_blend',
        'B': 'croptopia:lemon_coconut_bar'
    });
    event.custom({
        type: 'caupona:dolium',
        amount: 1000,
        density: 0.0,
        items: [
            {item: {item: 'kubejs:grist_morsels'}, count:2},
            {item: {item: 'kubejs:grist_agricultural_basic_block'}, count:3},
            {item: {item: 'caupona:asafoetida'}, count:1}
        ],
        fluid: "kubejs:grist_primordeal_improved_fluid",
        keepInfo: false,
        output: {
            type: 'forge:nbt',
            count: 1,
            item: 'kubejs:spiced_grist_blend'
        }
    });
    event.custom({
        type: "industrialforegoing:dissolution_chamber",
        input: [
            {tag: 'forge:blts'},
            {item: 'kubejs:grist_primordeal_improved'},
            {tag: 'forge:apple_pies'},
            {tag: 'forge:fruit_smoothies'},
            {tag: 'forge:cheeseburgers'},
            {item: 'caupona:okroshka'},
            {item: 'candlelight:pasta_bolognese'},
            {item: 'collectorsreap:prawn_po_boy'},
        ],
        inputFluid: "{Amount:5000,FluidName:\"kubejs:grist_agricultural_improved_fluid\"}",
        output: {
            count: 1,
            item: 'kubejs:grist_morsels'
        },
        processingTime: 3000
    });

    /*
    radiant grist should require:
            more advanced rituals with harder to grab mobs
            cooking some pink slime ingots
            processing liquid meat
            processing some of the vinery fluids
            all of the vinery wines in the dissolution chamber
            fish?
            890101 HNN predictions
            emeralds, because villagers?
    */
});