ServerEvents.recipes((event) => {
  // =========================================
  // Embers Mod Recipes
  // =========================================

  // Undergarden Catalyst
  event
    .shaped("undergarden:catalyst", [
        "ABA", 
        "CDC", 
        "ABA"
    ], 
    {
      A: "naturalist:glow_goop",
      B: "miners_delight:arthropod",
      C: "miners_delight:moss",
      D: "thermal:diamond_gear",
    })
    .id("undergarden:catalyst");

  // removing Supplementaries Ash as an ingredient option for Ashen Bricks (for portal gating)
  event.replaceInput(
    { input: "#forge:dusts/ash", mod: "embers" }, // Arg 1: the filter
    "#forge:dusts/ash", // Arg 2: the item to replace
    "embers:ash" // Arg 3: the item to replace it with
  );

  // Caminite Blend
  event
    .shapeless("8x embers:caminite_blend", [
      // arg 1: output
      "4x undergarden:sediment",
      "undergarden:goo_ball", //arg 2: the array of inputs
    ])
    .id("embers:caminite_blend");

  // Mechanical Core
  event
    .shaped("embers:mechanical_core", [
        "ABA", 
        " C ", 
        "A A"
    ], 
    {
      A: "undergarden:froststeel_ingot",
      B: "embers:caminite_bricks",
      C: "#forge:ingots/forgotten",
    })
    .id("embers:mechanical_core");

  // Ember Alloy

  event.recipes.create
    .mixing("2x create_dd:ember_alloy", [
      "undergarden:regalium_crystal",
      "#forge:raw_materials/cloggrum",
      "undergarden:glitterkelp",
      "embers:ember_grit",
    ])
    .heated()
    .id("create_dd:crafting/ember_alloy");

  // Ember Bore
  event
    .shaped("embers:ember_bore", [
        "ABA", 
        "ACA", 
        "DDD"
    ], 
    {
      A: "embers:caminite_bricks",
      B: "undergarden:cloggrum_ingot",
      C: "embers:mechanical_core",
      D: "create:mechanical_drill",
    })
    .id("embers:ember_bore");

  // Melter
  event
    .shaped("embers:melter", [
        "ABA", 
        "ACA", 
        "DED"
    ], 
    {
      A: "embers:caminite_bricks",
      B: "embers:caminite_plate",
      C: "undergarden:cloggrum_ingot",
      D: "undergarden:froststeel_ingot",
      E: "create_dd:ember_alloy_block",
    })
    .id("embers:melter");

  // Bin
  event
    .shaped("embers:bin", [
        "A A", 
        "B B", 
        "ACA"
    ], 
    {
      A: "undergarden:cloggrum_ingot",
      B: "embers:item_pipe",
      C: "#forge:plates/cloggrum",
    })
    .id("embers:bin");

  // Fluid Vessel
  event
    .shaped("embers:fluid_vessel", [
        "A A", 
        "B B", 
        "ACA"
    ], 
    {
      A: "embers:caminite_brick",
      B: "embers:fluid_pipe",
      C: "undergarden:froststeel_ingot",
    })
    .id("embers:fluid_vessel");

  // Reservoir
  event
    .shaped("embers:reservoir", [
        "A A", 
        "B B", 
        "ACA"
    ], 
    {
      A: "embers:caminite_bricks",
      B: "undergarden:froststeel_ingot",
      C: "embers:fluid_vessel",
    })
    .id("embers:reservoir");

  // Item Transfer
  event
    .shaped("embers:item_transfer", [
        "ABA", 
        "CBC", 
        "C C"
    ], 
    {
      A: "#forge:plates/cloggrum",
      B: "embers:item_pipe",
      C: "undergarden:cloggrum_ingot",
    })
    .id("embers:item_transfer");

  // Item Transfer
  event
    .shaped("embers:fluid_transfer", [
        "ABA", 
        "CBC", 
        "C C"
    ],
    {
      A: "#forge:plates/froststeel",
      B: "embers:fluid_pipe",
      C: "undergarden:froststeel_ingot",
    })
    .id("embers:fluid_transfer");

  // Caminite Gauge
  event
    .shaped("embers:caminite_gauge", [
        "AAA", 
        "B B", 
        "AAA"
    ], 
    {
      A: "embers:caminite_bricks",
      B: "undergarden:sediment_glass",
    })
    .id("embers:caminite_gauge");

  // Stamper
  event
    .shaped("embers:stamper", [
        "ABA", 
        "ACA", 
        "A A"
    ], 
    {
      A: "embers:caminite_brick",
      B: "undergarden:blisterbomb",
      C: "create:mechanical_press",
    })
    .id("embers:stamper");

  // Stamper Base
  event
    .shaped("embers:stamp_base", [
        "A A", 
        "BCB"
    ], 
    {
      A: "undergarden:froststeel_ingot",
      B: "embers:caminite_brick",
      C: "create:basin",
    })
    .id("embers:stamp_base");

  // Ember Activator
  event
    .shaped("embers:ember_activator", [
        "AAA", 
        "AAA", 
        "BCB"
    ], 
    {
      A: "undergarden:cloggrum_bars",
      B: "#forge:plates/froststeel",
      C: "create_dd:ember_alloy_block",
    })
    .id("embers:ember_activator");

  // Item Pipe
  event
    .shaped("8x embers:item_pipe", [
        "ABA"
    ], 
    {
      A: "undergarden:cloggrum_ingot",
      B: "undergarden:mogmoss",
    })
    .id("embers:item_pipe");

  // Item Extractor
  event
    .shaped("embers:item_extractor", [
        " A ", 
        "BCB", 
        " A "
    ], 
    {
      A: "undergarden:utheric_shard",
      B: "embers:item_pipe",
      C: "embers:caminite_plate",
    })
    .id("embers:item_extractor");

  // Fluid Pipe
  event
    .shaped("8x embers:fluid_pipe", [
        "ABA"
    ], 
    {
      A: "undergarden:froststeel_ingot",
      B: "undergarden:goo_ball",
    })
    .id("embers:fluid_pipe");

  // Fluid Extractor
  event
    .shaped("embers:fluid_extractor", [
        " A ", 
        "BCB", 
        " A "
    ], 
    {
      A: "undergarden:utheric_shard",
      B: "embers:fluid_pipe",
      C: "embers:caminite_plate",
    })
    .id("embers:fluid_extractor");

  // Ember Dial
  event
    .shaped("embers:ember_dial", [
        "A", 
        "B", 
        "C"
    ], 
    {
      A: "undergarden:sediment_glass_pane",
      B: "create_dd:ember_alloy",
      C: "undergarden:shard_torch",
    })
    .id("embers:ember_dial");

  // Item Dial
  event
    .shaped("embers:item_dial", [
        "A", 
        "B", 
        "C"
    ], 
    {
      A: "undergarden:sediment_glass_pane",
      B: "#forge:plates/cloggrum",
      C: "undergarden:shard_torch",
    })
    .id("embers:item_dial");

  // Fluid Dial
  event
    .shaped("embers:fluid_dial", [
        "A", 
        "B", 
        "C"
    ], 
    {
      A: "undergarden:sediment_glass_pane",
      B: "#forge:plates/froststeel",
      C: "undergarden:shard_torch",
    })
    .id("embers:fluid_dial");

  // Atmospheric Gauge
  event
    .shaped("embers:atmospheric_gauge", [
        " A ", 
        "BCB", 
        "DAD"
    ], 
    {
      A: "undergarden:froststeel_ingot",
      B: "undergarden:shard_torch",
      C: "undergarden:sediment_glass_pane",
      D: "undergarden:cloggrum_ingot",
    })
    .id("embers:atmospheric_gauge");

  // Ember Emitter
  event
    .shaped("4x embers:ember_emitter", [
        " A ", 
        " A ", 
        "BCB"
    ], 
    {
      A: "create_dd:ember_alloy",
      B: "undergarden:froststeel_ingot",
      C: "embers:caminite_plate",
    })
    .id("embers:ember_emitter");

  // Ember Receiver
  event
    .shaped("4x embers:ember_receiver", [
        "A A", 
        "BCB"
    ], 
    {
      A: "undergarden:froststeel_ingot",
      B: "create_dd:ember_alloy",
      C: "embers:caminite_plate",
    })
    .id("embers:ember_receiver");

  // Tinker Lens
  event
    .shaped("embers:tinker_lens", [
        "AB ", 
        "CDB", 
        "AB "
    ], 
    {
      A: "undergarden:froststeel_ingot",
      B: "undergarden:cloggrum_nugget",
      C: "#forge:plates/cloggrum",
      D: "undergarden:sediment_glass_pane",
    })
    .id("embers:tinker_lens");

  // Mechanical Pump
  event
    .shaped("embers:mechanical_pump", [
        "ABA", 
        "BCB", 
        "DED"
    ], 
    {
      A: "embers:fluid_pipe",
      B: "#forge:plates/froststeel",
      C: "create:mechanical_pump",
      D: "embers:caminite_brick",
      E: "embers:fluid_extractor",
    })
    .id("embers:mechanical_pump");

  // Mixer Centrifuge
  event
    .shaped("embers:mixer_centrifuge", [
        "AAA", 
        "ABA", 
        "CDC"
    ], 
    {
      A: "#forge:plates/froststeel",
      B: "create:mechanical_mixer",
      C: "create_dd:ember_alloy",
      D: "embers:mechanical_core",
    })
    .id("embers:mixer_centrifuge");

  // Ember Lantern
  event
    .shaped("4x embers:ember_lantern", [
        "A", 
        "B", 
        "C"
    ],
    {
      A: "#forge:plates/froststeel",
      B: "embers:ember_shard",
      C: "undergarden:froststeel_ingot",
    })
    .id("embers:ember_lantern");

  // Pressure Refinery
  event
    .shaped("embers:pressure_refinery", [
        "AAA", 
        "BCB", 
        "BDB"
    ], 
    {
      A: "create_dd:ember_alloy",
      B: "undergarden:froststeel_ingot",
      C: "embers:dawnstone_ingot",
      D: "create_dd:ember_alloy_block",
    })
    .id("embers:pressure_refinery");

  // Geologic Separator
  event
    .shaped("embers:geologic_separator", [
        "ABA", 
        "CDC"
    ], 
    {
      A: "undergarden:froststeel_ingot",
      B: "create:filter",
      C: "embers:caminite_brick",
      D: "embers:fluid_vessel",
    })
    .id("embers:geologic_separator");

  // Mini Boiler
  event
    .shaped("embers:mini_boiler", [
        "AAA", 
        "BCA", 
        "AAA"
    ], 
    {
      A: "#forge:plates/froststeel",
      B: "create_dd:ember_alloy",
      C: "create:fluid_tank",
    })
    .id("embers:mini_boiler");

  // Copper Charger
  event
    .shaped("embers:copper_charger", [
        " A ", 
        "BCB", 
        "DED"
    ], 
    {
      A: "#forge:plates/froststeel",
      B: "embers:dawnstone_ingot",
      C: "thermal:energy_cell",
      D: "undergarden:froststeel_ingot",
      E: "create_dd:ember_alloy",
    })
    .id("embers:copper_charger");

  // Ember Ejector
  event
    .shaped("embers:ember_ejector", [
        "A", 
        "B", 
        "C"
    ], 
    {
      A: "#forge:plates/dawnstone",
      B: "embers:ember_emitter",
      C: "undergarden:froststeel_ingot",
    })
    .id("embers:ember_ejector");

  // Copper Cell
  event
    .shaped("embers:copper_cell", [
        "ABA", 
        "BCB", 
        "ABA"
    ], 
    {
      A: "embers:caminite_bricks",
      B: "create_dd:ember_alloy",
      C: "thermal:rf_potato",
    })
    .id("embers:copper_cell");

  // Ember Relay
  event
    .shaped("4x embers:ember_relay", [
        " A ", 
        "A A", 
        " B "
    ], 
    {
      A: "create_dd:ember_alloy",
      B: "#forge:plates/froststeel",
    })
    .id("embers:ember_relay");

  // Beam Splitter
  event
    .shaped("embers:beam_splitter", [
        " A ", 
        "BCB", 
        " D "
    ], 
    {
      A: "embers:dawnstone_ingot",
      B: "create_dd:ember_alloy",
      C: "#forge:plates/froststeel",
      D: "undergarden:froststeel_ingot",
    })
    .id("embers:beam_splitter");

  // Ember Funnel
  event
    .shaped("embers:ember_funnel", [
        "A A", 
        "BCB", 
        " A "
    ], 
    {
      A: "#forge:plates/dawnstone",
      B: "create_dd:ember_alloy",
      C: "embers:ember_receiver",
    })
    .id("embers:ember_funnel");

  // Hearth Core
  event
    .shaped("embers:hearth_coil", [
        "AAA", 
        "BCB", 
        " D "
    ], 
    {
      A: "create:blaze_burner",
      B: "undergarden:froststeel_ingot",
      C: "create_dd:ember_alloy_block",
      D: "embers:mechanical_core",
    })
    .id("embers:hearth_coil");

  // Crystal Cell
  event
    .shaped("embers:crystal_cell", [
        " A ", 
        "BAB", 
        "CDC"
    ], 
    {
      A: "embers:ember_crystal",
      B: "#forge:plates/dawnstone",
      C: "create_dd:ember_alloy_block",
      D: "embers:dawnstone_block",
    })
    .id("embers:crystal_cell");

  // Alchemy Pedestal
  event
    .shaped("embers:alchemy_pedestal", [
        "A A", 
        "BCB", 
        "DED"
    ], 
    {
      A: "#forge:plates/dawnstone",
      B: "embers:dawnstone_ingot",
      C: "embers:ember_crystal",
      D: "embers:caminite_bricks",
      E: "create_dd:ember_alloy_block",
    })
    .id("embers:alchemy_pedestal");

  // Alchemy Tablet
  event
    .shaped("embers:alchemy_tablet", [
        " A ", 
        "BCB", 
        "BDB"
    ], 
    {
      A: "#forge:plates/dawnstone",
      B: "embers:caminite_bricks",
      C: "create_dd:ember_alloy",
      D: "embers:dawnstone_ingot",
    })
    .id("embers:alchemy_tablet");

  // Ember Siphon
  event
    .shaped("embers:ember_siphon", [
        "ABA", 
        "CBC", 
        "AAA"
    ], 
    {
      A: "embers:caminite_brick",
      B: "create_dd:ember_alloy",
      C: "#forge:plates/froststeel",
    })
    .id("embers:ember_siphon");

  // Beam Cannon
  event
    .shaped("embers:beam_cannon", [
        "ABA", 
        "ABA", 
        "CDC"
    ], 
    {
      A: "create_dd:ember_alloy",
      B: "embers:ember_crystal",
      C: "embers:dawnstone_ingot",
      D: "embers:caminite_bricks",
    })
    .id("embers:beam_cannon");

  // Wildfire Stirling
  event
    .shaped("embers:wildfire_stirling", [
        "ABA", 
        "ABA", 
        "CDC"
    ], 
    {
      A: "#forge:plates/dawnstone",
      B: "create_dd:ember_alloy_block",
      C: "embers:ember_shard",
      D: "embers:wildfire_core",
    })
    .id("embers:wildfire_stirling");

  // Tinker Hammer
  event
    .shaped("embers:tinker_hammer", [
        "ABA", 
        "ACA", 
        " C "
    ], 
    {
      A: "undergarden:froststeel_ingot",
      B: "undergarden:cloggrum_ingot",
      C: "undergarden:twistytwig",
    })
    .id("embers:tinker_hammer");

  // Undergarden Plates (Embers, Create, Thermal)

  global.emberMetal.forEach((metalInput) => {
    event
      .shapeless(`embers:${metalInput}_plate`, [
        // arg 1: output
        `2x undergarden:${metalInput}_ingot`,
        "embers:tinker_hammer", //arg 2: the array of inputs
      ])
      .id(`embers:${metalInput}_plate_hammering`);

    event.recipes.create.pressing(
      `create:${metalInput}_sheet`,
      `undergarden:${metalInput}_ingot`
    );

    event.recipes.thermal.press(
      `thermal:${metalInput}_plate`,
      `undergarden:${metalInput}_ingot`
    );

    // Embers Plate Stamping
    event.custom({
      type: "embers:stamping",
      conditions: [
        {
          type: "forge:not",
          value: {
            type: "forge:tag_empty",
            tag: `forge:plates/${metalInput}`,
          },
        },
      ],
      fluid: {
        amount: 90,
        tag: `forge:molten_${metalInput}`,
      },
      output: {
        tag: `forge:plates/${metalInput}`,
      },
      stamp: {
        item: "embers:plate_stamp",
      },
    });

    // Embers Ingot Stamping
    event.custom({
      type: "embers:stamping",
      conditions: [
        {
          type: "forge:not",
          value: {
            type: "forge:tag_empty",
            tag: `forge:ingots/${metalInput}`,
          },
        },
      ],
      fluid: {
        amount: 90,
        tag: `forge:molten_${metalInput}`,
      },
      output: {
        tag: `forge:ingots/${metalInput}`,
      },
      stamp: {
        item: "embers:ingot_stamp",
      },
    });

    // Embers Nugget Stamping
    event.custom({
      type: "embers:stamping",
      conditions: [
        {
          type: "forge:not",
          value: {
            type: "forge:tag_empty",
            tag: `forge:nuggets/${metalInput}`,
          },
        },
      ],
      fluid: {
        amount: 10,
        tag: `forge:molten_${metalInput}`,
      },
      output: {
        tag: `forge:nuggets/${metalInput}`,
      },
      stamp: {
        item: "embers:nugget_stamp",
      },
    });

    // Embers Ingot Melting
    event.custom({
      type: "embers:melting",
      conditions: [
        {
          type: "forge:not",
          value: {
            type: "forge:tag_empty",
            tag: `forge:ingots/${metalInput}`,
          },
        },
      ],
      input: {
        tag: `forge:ingots/${metalInput}`,
      },
      output: {
        amount: 90,
        fluid: `embers:molten_${metalInput}`,
      },
    });

    // Embers Raw Melting
    event.custom({
      type: "embers:melting",
      conditions: [
        {
          type: "forge:not",
          value: {
            type: "forge:tag_empty",
            tag: `forge:raw_materials/${metalInput}`,
          },
        },
      ],
      input: {
        tag: `forge:raw_materials/${metalInput}`,
      },
      output: {
        amount: 120,
        fluid: `embers:molten_${metalInput}`,
      },
    });

    // Embers nugget Melting
    event.custom({
      type: "embers:melting",
      conditions: [
        {
          type: "forge:not",
          value: {
            type: "forge:tag_empty",
            tag: `forge:nuggets/${metalInput}`,
          },
        },
      ],
      input: {
        tag: `forge:nuggets/${metalInput}`,
      },
      output: {
        amount: 10,
        fluid: `embers:molten_${metalInput}`,
      },
    });

    // Embers plate Melting
    event.custom({
      type: "embers:melting",
      conditions: [
        {
          type: "forge:not",
          value: {
            type: "forge:tag_empty",
            tag: `forge:plates/${metalInput}`,
          },
        },
      ],
      input: {
        tag: `forge:plates/${metalInput}`,
      },
      output: {
        amount: 90,
        fluid: `embers:molten_${metalInput}`,
      },
    });

    // Embers storage blocks Melting
    event.custom({
      type: "embers:melting",
      conditions: [
        {
          type: "forge:not",
          value: {
            type: "forge:tag_empty",
            tag: `forge:storage_blocks/${metalInput}`,
          },
        },
      ],
      input: {
        tag: `forge:storage_blocks/${metalInput}`,
      },
      output: {
        amount: 810,
        fluid: `embers:molten_${metalInput}`,
      },
    });

    // Embers raw storage blocks Melting
    event.custom({
      type: "embers:melting",
      conditions: [
        {
          type: "forge:not",
          value: {
            type: "forge:tag_empty",
            tag: `forge:storage_blocks/raw_${metalInput}`,
          },
        },
      ],
      input: {
        tag: `forge:storage_blocks/raw_${metalInput}`,
      },
      output: {
        amount: 1080,
        fluid: `embers:molten_${metalInput}`,
      },
    });

    // Embers ore blocks Melting
    event.custom({
      type: "embers:melting",
      conditions: [
        {
          type: "forge:not",
          value: {
            type: "forge:tag_empty",
            tag: `forge:ores/${metalInput}`,
          },
        },
      ],
      input: {
        tag: `forge:ores/${metalInput}`,
      },
      output: {
        amount: 240,
        fluid: `embers:molten_${metalInput}`,
      },
    });
  });

  // =========================================
  // Embers Bore "Recipes"
  // =========================================

  event.custom({
    type: "embers:boring",
    dimensions: ["undergarden:undergarden"],
    max_height: 7,
    output: {
      item: "embers:ember_grit",
    },
    required_block: {
      amount: 3,
      block_tag: "embers:world_bottom",
    },
    weight: 20,
  });

  event.custom({
    type: "embers:boring",
    dimensions: ["undergarden:undergarden"],
    max_height: 7,
    output: {
      item: "embers:ember_shard",
    },
    required_block: {
      amount: 3,
      block_tag: "embers:world_bottom",
    },
    weight: 20,
  });

  event.custom({
    type: "embers:boring",
    dimensions: ["undergarden:undergarden"],
    max_height: 7,
    output: {
      item: "embers:ember_crystal",
    },
    required_block: {
      amount: 3,
      block_tag: "embers:world_bottom",
    },
    weight: 20,
  });

  // =========================================
  // Primordial Caves Portal Block Recipe
  // =========================================

  event.custom({
    type: "embers:alchemy",
    aspects: [
      {
        tag: "embers:aspectus/dawnstone",
      },
      {
        tag: "embers:aspectus/lead",
      },
      {
        tag: "embers:aspectus/silver",
      },
    ],
    inputs: [
      {
        item: "farmersdelight:organic_compost",
      },
      {
        tag: "forge:ingots/cloggrum",
      },
      {
        item: "farmersdelight:organic_compost",
      },
      {
        tag: "forge:ingots/cloggrum",
      },
    ],
    output: {
      item: "alexscaves:guanostone_bricks",
    },
    tablet: {
      item: "embers:caminite_brick",
    },
  });

  // =========================================
  // Dawnstone Mixing Recipes
  // =========================================

  event
    .custom({
      type: "embers:mixing",
      inputs: [
        {
          amount: 2,
          tag: "forge:molten_cloggrum",
        },
        {
          amount: 2,
          tag: "forge:molten_gold",
        },
      ],
      output: {
        amount: 4,
        fluid: "embers:molten_dawnstone",
      },
    })
    .id("embers:mixing/molten_dawnstone");

  event
    .custom({
      type: "embers:mixing",
      inputs: [
        {
          amount: 2,
          tag: "forge:molten_copper",
        },
        {
          amount: 2,
          tag: "forge:molten_froststeel",
        },
      ],
      output: {
        amount: 4,
        fluid: "embers:molten_dawnstone",
      },
    })
    .id("embers:mixing/molten_dawnstone_2");
});
