ServerEvents.recipes((event) => {
  // =========================================
  // Create New Age
  // =========================================

  // Generator Coil
  event.recipes.create
    .mechanical_crafting("create_new_age:generator_coil", [
      "A B A", 
      " CCC ", 
      "BCDCB", 
      " CCC ", 
      "A B A"
    ],
    {
      A: "alexscaves:scarlet_magnet",
      B: "alexscaves:azure_magnet",
      C: "call_of_yucutan:hematite_block",
      D: "create:encased_chain_drive",
    })
    .id("create_new_age:shaped/generator_coil");

  // Carbon Brushes
  event
    .shaped("create_new_age:carbon_brushes", [
      "ABA", 
      "CDC", 
      "ABA"
    ], 
    {
      A: "call_of_yucutan:hematite_block",
      B: "alexscaves:ferrouslime_ball",
      C: "createdieselgenerators:lubricant_bucket",
      D: "alexscaves:heart_of_iron",
    })
    .id("create_new_age:shaped/carbon_brushes");

  // Basic Energizer
  event
    .shapeless("create_new_age:energiser_t1", [
      "thermal:charge_bench",
      "minecraft:lightning_rod",
    ])
    .id("create_new_age:shapeless/energiser_t1");

  // Basic Motor
  event
    .shaped("create_new_age:basic_motor", [
      "AAA", 
      "BCD", 
      "AAA"
    ], 
    {
      A: "#forge:nuggets/steel",
      B: "create_new_age:electrical_connector",
      C: "create_new_age:magnetite_block",
      D: "create:shaft",
    })
    .id("create_new_age:shaped/basic_motor");

  // Strong (Advanced) Motor
  event
    .shaped("create_new_age:advanced_motor", [
      "AAA", 
      "BCD", 
      "AAA"
    ], 
    {
      A: "#forge:nuggets/steel",
      B: "create_new_age:electrical_connector",
      C: "create_new_age:neodymized_magnet",
      D: "create:shaft",
    })
    .id("create_new_age:shaped/advanced_motor");

  // Reinforced Motor
  event.recipes.create
    .mechanical_crafting("create_new_age:reinforced_motor", [
      "ABCCA", 
      "DBEFF", 
      "ABCCA"
    ],
    {
      A: "alexscaves:scrap_metal_plate",
      B: "create_new_age:overcharged_magnet",
      C: "#forge:plates/steel",
      D: "create_new_age:electrical_connector",
      E: "alexscaves:magnetic_activator",
      F: "create:shaft",
    })
    .id("create_new_age:reinforced_motor");

  // Electrical Connector

  event.remove({ output: `create_new_age:electrical_connector` });
  event
    .shaped("2x create_new_age:electrical_connector", [
      "A", 
      "B", 
      "C"
    ], 
    {
      A: "#forge:nuggets/copper",
      B: "#forge:plates/steel",
      C: "minecraft:terracotta",
    })
    .id("create_new_age:shaped/electrical_connector");

  // Neodymized Magnet
  event
    .shaped("2x create_new_age:neodymized_magnet", [
      "AAA", 
      "ABA", 
      "AAA"
    ], 
    {
      A: "alexscaves:raw_scarlet_neodymium",
      B: "create_new_age:magnetite_block",
    })
    .id("create_new_age:shaped/neodymized_magnet");

  // Overcharged Magnet
  event
    .shaped("2x create_new_age:overcharged_magnet", [
      "ABA", 
      "BCB", 
      "ABA"
    ], 
    {
      A: "create_new_age:overcharged_iron",
      B: "create_new_age:overcharged_gold",
      C: "create_new_age:neodymized_magnet",
    })
    .id("create_new_age:shaped/overcharged_magnet");

  // Sculked Magnet
  event
    .shaped("2x create_new_age:sculked_magnet", [
      "ABA", 
      "BCB", 
      "ABA"
    ], 
    {
      A: "deeperdarker:chiseled_sculk_stone",
      B: "create_new_age:overcharged_diamond",
      C: "create_new_age:overcharged_magnet",
    })
    .id("create_new_age:shaped/sculked_magnet");

  // Lunar Magnet
  event
    .shaped("2x create_new_age:lunar_magnet", [
      "ABA", 
      "BCB", 
      "ABA"
    ], 
    {
      A: "#forge:storage_blocks/sapphire",
      B: "#forge:ingots/desh",
      C: "create_new_age:sculked_magnet",
    })
    .id("create_new_age:shaped/lunar_magnet");

  // Martian Magnet
  event
    .shaped("2x create_new_age:martian_magnet", [
      "ABA", 
      "BCB", 
      "ABA"
    ], 
    {
      A: "#forge:storage_blocks/ruby",
      B: "#forge:ingots/ostrum",
      C: "create_new_age:lunar_magnet",
    })
    .id("create_new_age:shaped/martian_magnet");

    // Blank Circuit
  event.replaceInput(
    { id: "create_new_age:pressing/blank_circuit" },
    "minecraft:iron_ingot", 
    "create_new_age:copper_wire" 
  );

    
    // Embers Stamping - Blank Circuit
    event.custom({
      type: "embers:stamping",
      fluid: {
        amount: 90,
        tag: `forge:molten_copper`,
      },
      input: {
        item: `minecraft:quartz`,
      },
      output: {
        item: `create_new_age:blank_circuit`,
      },
      stamp: {
        item: "embers:plate_stamp",
      },
    });

  // =========================================
  // Create Enchantment Industry
  // =========================================

  // Ink
  event.replaceInput(
    { id: "create_enchantment_industry:mixing/ink" },
    "#create_enchantment_industry:ink_ingredient", 
    "undergarden:seeping_ink" 
  );

  // =========================================
  // Create Sifters
  // =========================================

  // Sifter
  event
    .shaped("createsifter:sifter", [
      "AAA", 
      "BCB", 
      "DED"
    ], 
    {
      A: "#forge:fences/wooden",
      B: "create:cogwheel",
      C: "minecraft:brush",
      D: "minecraft:polished_andesite",
      E: "create:andesite_casing",
    })
    .id("createsifter:sifter");

  // Custom Sea Pig Mesh
  event
    .shaped("createsifter:sea_pig_mesh", [
      "ABA", 
      "BCB", 
      "ABA"
    ], 
    {
      A: "seadwellers:depth_ingot",
      B: "undergarden:mushroom_veil",
      C: "alexscaves:sea_pig_bucket",
    })
    .id("createsifter:sea_pig_mesh");

  // Using Custom Sea Pig Mesh
  event.recipes
    .createsifterSifting(
      [
        Item.of("refinedstorage:silicon").withChance(0.25),
        Item.of("alexscaves:marine_snow").withChance(0.7),
        Item.of("alexscaves:pearl").withChance(0.1),
      ],
      ["#alexscaves:sea_pig_digests", "createsifter:sea_pig_mesh"]
    )
    .waterlogged();

  // Gravel Sifting
  event.recipes.createsifterSifting(
    [
      Item.of("twigs:pebble").withChance(0.5),
      Item.of("minecraft:flint").withChance(0.2),
      Item.of("#minecraft:decorated_pot_sherds").withChance(0.05),
    ],
    ["#forge:gravel", "createsifter:string_mesh"]
  );

  // Dirt Sifting
  event.recipes.createsifterSifting(
    [
      Item.of("naturalist:snail_shell").withChance(0.2),
      Item.of("spawn:snail_shell").withChance(0.2),
      Item.of("betterarcheology:artifact_shards").withChance(0.05),
    ],
    ["#minecraft:dirt", "createsifter:string_mesh"]
  );

  // Sand Sifting
  event.recipes
    .createsifterSifting(
      [
        Item.of("ecologics:seashell").withChance(0.25),
        Item.of("minecraft:nautilus_shell").withChance(0.05),
        Item.of("#twigs:seashells").withChance(0.05),
      ],
      ["#forge:sand", "createsifter:string_mesh"]
    )
    .waterlogged();

  // Guano Sifting
  event.recipes.createsifterSifting(
    [
      Item.of("waterloggedchests:cricket_bait").withChance(0.05),
      Item.of("waterloggedchests:glow_worm_bait").withChance(0.05),
      Item.of("waterloggedchests:worm_bait").withChance(0.05),
      Item.of("rats:garbage_pile").withChance(0.2),
      Item.of("rats:tiny_coin").withChance(0.1),
      Item.of("alexscaves:block_of_chocolate").withChance(0.05),
    ],
    ["alexscaves:guano_block", "createsifter:brass_mesh"]
  );

  // =========================================
  // Ancient Gold and Caramel stuff
  // =========================================


  // A Sheet (Custom Item)
  event.recipes.create.pressing(
    "call_of_yucutan:ancient_gold_sheet",
    "call_of_yucutan:ancient_gold_ingot"
  );
  event.recipes.thermal.press(
    `call_of_yucutan:ancient_gold_sheet`,
    `call_of_yucutan:ancient_gold_ingot`
  );

  // Caramel Sheet (Custom Item)
  event.recipes.create.pressing(
    "alexscaves:caramel_sheet",
    "alexscaves:caramel"
  );
  event.recipes.thermal.press(
    `alexscaves:caramel_sheet`,
    `alexscaves:caramel`
  );


  event.shapeless("9x call_of_yucutan:ancient_gold_nugget", [
      "call_of_yucutan:ancient_gold_ingot",
    ])
    .id("call_of_yucutan:ancient_gold_nugget");
  event.shapeless("call_of_yucutan:ancient_gold_ingot", [
    "9x call_of_yucutan:ancient_gold_nugget",
  ]);

  // =========================================
  // Create Diesel Generators
  // =========================================

  // Diesel Engine
  event
    .shaped("createdieselgenerators:diesel_engine", [
      " A ", 
      "BCB", 
      "DED"
    ], 
    {
      A: "minecraft:flint_and_steel",
      B: "createdieselgenerators:engine_piston",
      C: "create_connected:brass_gearbox",
      D: "#forge:ingots/steel",
      E: "thermal:fluid_cell",
    })
    .id("createdieselgenerators:crafting/diesel_engine");

  // Modular (Large) Diesel Engine
  event
    .shaped("createdieselgenerators:large_diesel_engine", [
      " A ", 
      "BCB", 
      "DED"
    ],
    {
      A: "create:smart_fluid_pipe",
      B: "createdieselgenerators:engine_piston",
      C: "createdieselgenerators:diesel_engine",
      D: "#forge:ingots/steel",
      E: "modularrouters:modular_router",
    })
    .id("createdieselgenerators:crafting/large_diesel_engine");

  // Huge Diesel Engine
  event
    .shaped("createdieselgenerators:huge_diesel_engine", [
      " A ", 
      "BCB", 
      "DED"
    ],
    {
      A: "create:steam_engine",
      B: "createdieselgenerators:engine_piston",
      C: "createdieselgenerators:large_diesel_engine",
      D: "#forge:gears/steel",
      E: "create:blaze_burner",
    })
    .id("createdieselgenerators:crafting/huge_diesel_engine");

  // Pumpjack Head
  event
    .shaped("createdieselgenerators:pumpjack_head", [
      "A A", 
      "BCB", 
      "A A"
    ], 
    {
      A: "create:andesite_alloy_block",
      B: "alexscaves:heavyweight",
      C: "create:encased_chain_drive",
    })
    .id("createdieselgenerators:crafting/pumpjack_head");

  // Pumpjack Bearing
  event
    .shaped("createdieselgenerators:pumpjack_bearing", [
      "ABA", 
      "BCB", 
      "ABA"
    ], 
    {
      A: "create:andesite_alloy_block",
      B: "#forge:gears/steel",
      C: "create:mechanical_bearing",
    })
    .id("createdieselgenerators:crafting/pumpjack_bearing");

  // Distillation Controller
  event
    .shaped("createdieselgenerators:distillation_controller", [
      "ABA", 
      "CDC"
    ], 
    {
      A: "create:fluid_pipe",
      B: "embers:atmospheric_gauge",
      C: "#forge:tar",
      D: "#forge:plates/steel",
    })
    .id("createdieselgenerators:crafting/distillation_controller");

  // Pumpjack Crank
  event.recipes.create
    .mechanical_crafting("createdieselgenerators:pumpjack_crank",[
      "A A", 
      "B B", 
      "C C", 
      "DED", 
      "C C"
    ],
    {
      A: "#forge:plates/steel",
      B: "createdieselgenerators:engine_piston",
      C: "create:andesite_alloy_block",
      D: "#forge:gears/steel",
      E: "create:encased_chain_drive",
    })
    .id("createdieselgenerators:mechanical_crafting/pumpjack_crank");

  // Burner
  event
    .shaped("createdieselgenerators:burner", [
      " A ", 
      "BCD", 
      "EFG"
    ], 
    {
      A: "supplementaries:fire_pit",
      B: "create:fluid_pipe",
      C: "createdieselgenerators:chemical_sprayer_lighter",
      D: "createdieselgenerators:andesite_girder",
      E: "create_sa:small_fueling_tank",
      F: "create:empty_blaze_burner",
      G: "embers:atmospheric_gauge"
    })
    .id("createdieselgenerators:crafting/burner");

  // Bulk Fermenter
  event
    .shaped("createdieselgenerators:bulk_fermenter", [
      "AAA", 
      "BCD", 
      "BEB"
    ], 
    {
      A: "#forge:plates/steel",
      B: "create_dd:industrial_casing",
      C: "create:chute",
      D: "embers:atmospheric_gauge",
      E: "thermal:device_composter"
    })
    .id("createdieselgenerators:crafting/bulk_fermenter");

  // Custom Lubricant Recipe
  event.custom({
    type: "createdieselgenerators:basin_fermenting",
    heatRequirement: "heated",
    ingredients: [
      {
        fluid: "createdieselgenerators:gasoline",
        amount: 500,
      },
    ],
    processingTime: 100,
    results: [
      {
        fluid: "createdieselgenerators:lubricant",
        amount: 1000,
      },
    ],
  });

  event.custom({
    type: "createdieselgenerators:bulk_fermenting",
    heatRequirement: "heated",
    ingredients: [
      {
        fluid: "createdieselgenerators:gasoline",
        amount: 1000,
      },
    ],
    processingTime: 100,
    results: [
      {
        fluid: "createdieselgenerators:lubricant",
        amount: 2000,
      },
    ],
  });

  // =========================================
  // Create Utilities
  // =========================================

  // Void Steel Ingot
  event.recipes.thermal
    .smelter("createutilities:void_steel_ingot", [
      "#forge:ingots/shadow_steel",
      "#forge:ingots/enderium",
    ])
    .energy(800)
    .id("createutilities:void_steel_ingot");
  event.replaceInput(
    { id: "createutilities:mixing/void_steel_ingot" },
    "#forge:ingots/netherite",
    "#forge:ingots/shadow_steel"
  );
  event.replaceInput(
    { id: "createutilities:mixing/void_steel_ingot" },
    "#forge:ender_pearls",
    "#forge:ingots/enderium"
  );
  event.replaceInput(
    { output: "createutilities:void_casing" },
    "#forge:obsidian",
    "thermal:device_collector"
  );

  // Graviton Tube
  event
    .shaped("createutilities:graviton_tube", [
      "A", 
      "B", 
      "C"
    ], 
    {
      A: "createutilities:polished_amethyst",
      B: "createutilities:void_steel_sheet",
      C: "alexscaves:occult_gem",
    })
    .id("createutilities:shaped/graviton_tube");

  // =========================================
  // Create Dreams and Desires
  // =========================================

  // Rubber Compat Recipe for Belts
  event.replaceInput(
    { id: "create_dd:crafting/mechanical_belt_from_rubber" },
    "create_dd:rubber",
    ["create_dd:rubber", "thermal:cured_rubber"]
  );

  // Create DD Steel only for decoration
  event.replaceInput(
    { mod: "create_dd" },
    "#forge:ingots/steel",
    "create_dd:steel_ingot"
  );
  event.replaceInput(
    { mod: "create_dd" },
    "#forge:nuggets/steel",
    "create_dd:steel_nugget"
  );
  event.replaceInput(
    { mod: "create_dd" },
    "#forge:storage_blocks/steel",
    "create_dd:steel_block"
  );
  event
    .custom({
      type: "create:sequenced_assembly",
      ingredient: {
        tag: "forge:plates/lapis_alloy",
      },
      transitionalItem: {
        item: "create_dd:incomplete_integrated_circuit",
      },
      sequence: [
        {
          type: "create:deploying",
          ingredients: [
            {
              item: "create_dd:incomplete_integrated_circuit",
            },
            {
              item: "minecraft:redstone",
            },
          ],
          results: [
            {
              item: "create_dd:incomplete_integrated_circuit",
            },
          ],
        },
        {
          type: "create:deploying",
          ingredients: [
            {
              item: "create_dd:incomplete_integrated_circuit",
            },
            {
              item: "minecraft:quartz",
            },
          ],
          results: [
            {
              item: "create_dd:incomplete_integrated_circuit",
            },
          ],
        },
        {
          type: "create:deploying",
          ingredients: [
            {
              item: "create_dd:incomplete_integrated_circuit",
            },
            {
              item: "call_of_yucutan:ancient_gold_nugget",
            },
          ],
          results: [
            {
              item: "create_dd:incomplete_integrated_circuit",
            },
          ],
        },
      ],
      results: [
        {
          item: "create_dd:integrated_circuit",
          chance: 160.0,
        },
        {
          item: "create_dd:lapis_sheet",
          chance: 5.0,
        },
        {
          item: "minecraft:redstone",
          chance: 2.5,
        },
        {
          item: "minecraft:quartz",
          chance: 2.5,
        },
        {
          item: "call_of_yucutan:ancient_gold_nugget",
          chance: 2.5,
        },
      ],
      loops: 4,
    })
    .id("create_dd:sequenced_assembly/integrated_circuit");

  // Sealed Mechanism also takes Thermal rubber
  event.replaceInput(
    { id: "create_dd:sequenced_assembly/sealed_mechanism" },
    "create_dd:rubber",
    ["create_dd:rubber", "thermal:cured_rubber"]
  );

  // Coal Pieces
  event
    .shapeless("32x create_dd:coal_piece", [
      "minecraft:coal",
      "hostilenetworks:nether_prediction",
    ])
    .id("create_dd:coal_piece");


// Create Chromatic Compound Fix
	event.replaceOutput(
	  { id: "thermal:compat/create/smelter_create_alloy_chromatic_compound" },
	  "create:chromatic_compound",
	  "create_dd:chromatic_compound"
	);  

// Create DD Item Vault
  event.remove({ output: "create:item_vault" });
  event
    .shaped("create:item_vault", [
      "A", 
      "B", 
      "A"
    ], 
    {
      A: "create_dd:andesite_sheet",
      B: "create_dd:overburden_casing",
    })
    .id("create_dd:crafting/vault");
   event.shapeless("create:item_vault", [
	"#create:item_vault_crafting_component"])
	.id("generikb:create_item_vault_from_tagged_item");
  
// Create DD Calculation Mechanism
  event.custom({
    type: "embers:alchemy",
    aspects: [
      {
        tag: "embers:aspectus/copper",
      },
      {
        tag: "embers:aspectus/lead",
      },
      {
        tag: "embers:aspectus/silver",
      },
    ],
    inputs: [
      {
        item: "waxablecoral:waxed_brain_coral_block",
      },
      {
        item: "supplementaries:crystal_display",
      },
      {
        item: "create_new_age:copper_circuit",
      },
      {
        item: "create_sa:heap_of_experience",
      },
    ],
    output: {
      item: "create_dd:calculation_mechanism",
    },
    tablet: {
      item: "create_dd:andesite_sheet",
    },
  });


  // =========================================
  // Create Vibrant Vaults
  // =========================================

  // Package Frogport

  event.replaceInput(
    { id: /.*package_frogport$/ },
    "#forge:slimeballs",
    "#naturalist:froglass",
  );

  event.replaceInput(
    { id: /.*package_frogport$/ },
    "create:andesite_alloy",
    "create_dd:inductive_mechanism"
  );

  // Stock Links
  event
    .shaped("create:stock_link", [
      " A ", 
      "BCD", 
      "EFE"
    ], 
    {
      A: "create:redstone_link",
      B: "etcetera:tinted_light_bulb",
      C: "create_dd:inductive_mechanism",
      D: "infinitybuttons:gold_large_button",
      E: "supplementaries:cog_block",
      F: "create:item_vault"
    })
    .id("create:crafting/logistics/stock_link");
  

  event
    .shaped("create:stock_link", [
      " A ", 
      "BCD", 
      "EFE"
    ], 
    {
      A: "create:redstone_link",
      B: "etcetera:tinted_light_bulb",
      C: "create_dd:inductive_mechanism",
      D: "infinitybuttons:gold_large_button",
      E: "supplementaries:cog_block",
      F: ["create_vibrant_vaults:vertical_item_vault","create_vibrant_vaults:shipping_container","create_vibrant_vaults:basic_shipping_container","create_vibrant_vaults:vertical_shipping_container","create_vibrant_vaults:vertical_basic_shipping_container"]
    })
    .id("create_vibrant_vaults:crafting/stock_link");
  

  global.colors.forEach((color) => {
      event
    .shaped(`create_vibrant_vaults:${color}_stock_link`, [
      " A ", 
      "BCD", 
      "EFE"
    ], 
    {
      A: "create:redstone_link",
      B: "etcetera:tinted_light_bulb",
      C: "create_dd:inductive_mechanism",
      D: "infinitybuttons:gold_large_button",
      E: "supplementaries:cog_block",
      F: [`create_vibrant_vaults:${color}_vertical_item_vault`,`create_vibrant_vaults:${color}_shipping_container`,`create_vibrant_vaults:${color}_basic_shipping_container`,`create_vibrant_vaults:${color}_vertical_shipping_container`,`create_vibrant_vaults:${color}_vertical_basic_shipping_container`]
    })
    .id(`create_vibrant_vaults:crafting/${color}_stock_link`);
    });


  // =========================================
  // Create Jetpacks
  // =========================================

  // Copper Jetpack
  event
  .shaped("create_sa:copper_jetpack_chestplate", [
    "ABA", 
    "ACA", 
    "DED"
  ], 
  {
    A: "alexscaves:caramel",
    B: "create:cogwheel",
    C: "create_sa:hydraulic_engine",
    D: "alexscaves:purple_soda_bottle_rocket",
    E: "create:fluid_tank",
  })
  .id("create_sa:copper_propeler_recipe");
  
  event.replaceInput(
    { id: "create_sa:andesite_jetpack_recipe" },
    "create:belt_connector",
    "create_sa:copper_jetpack_chestplate"
  );

  event.replaceInput(
    { id: "create_sa:andesite_jetpack_recipe" },
    "create:zinc_ingot",
    "alexscaves:purple_soda_bottle_rocket"
  );

  event.replaceInput(
    { id: "create_sa:brass_jetpack_recipe" },
    "create:andesite_alloy",
    "create_sa:andesite_jetpack_chestplate"
  );

  event.replaceInput(
    { id: "create_sa:brass_jetpack_recipe" },
    "create:encased_fan",
    "alexscaves:purple_soda_bottle_rocket"
  );

  event.replaceInput(
    { id: "create_sa:brass_jetpack_recipe" },
    "create:cogwheel",
    "create:encased_fan"
  );

  event
    .custom({
      type: "create_jetpack:copy_nbt_mechanical_crafting",
      pattern: [
        " PSP ", 
        "PYXYP", 
        "PCECP", 
        " C C "
      ],
      key: {
        E: {
          item: "minecraft:elytra",
        },
        C: {
          item: "alexscaves:purple_soda_bottle_rocket",
        },
        X: {
          item: "create:copper_backtank",
        },
        S: {
          item: "create_sa:brass_jetpack_chestplate",
        },
        Y: {
          item: "create:precision_mechanism",
        },
        P: {
          item: "call_of_yucutan:ancient_gold_sheet",
        },
      },
      result: {
        item: "create_jetpack:jetpack",
      },
    })
    .id("create_jetpack:jetpack");

   event
    .custom({
      type: "create_jetpack:copy_nbt_mechanical_crafting",
      pattern: [
        " PSP ", 
        "PYXYP", 
        "PCECP", 
        " C C "
      ],
      key: {
        E: {
          item: "minecraft:elytra",
        },
        C: {
          item: "alexscaves:purple_soda_bottle_rocket",
        },
        X: {
          item: "create:netherite_backtank",
        },
        S: {
          item: "create_sa:brass_jetpack_chestplate",
        },
        Y: {
          item: "create:precision_mechanism",
        },
        P: {
          item: "call_of_yucutan:ancient_gold_sheet",
        },
      },
      result: {
        item: "create_jetpack:netherite_jetpack",
      },
    })
    .id("create_jetpack:netherite_jetpack");

  // =========================================
  // Create Stuff & Additions
  // =========================================    

 // Copper Magnet
  event.replaceInput(
    { id: "create_sa:copper_magnet_recipe" },
    "minecraft:netherite_ingot",
    "call_of_yucutan:hematite"
  );

});
