ServerEvents.recipes((event) => {
  // =========================================
  // Components
  // =========================================

  // Silicon
  event.recipes.remove({ output: "refinedstorage:silicon" });
  event.recipes.thermal
    .smelter("refinedstorage:silicon", [
      "#forge:sand",
      "alexscaves:marine_snow",
    ])
    .energy(800)
    .id("refinedstorage:silicon");

  // Processor Binding
  event
    .shaped("16x refinedstorage:processor_binding", ["ABA"], {
      A: "spawn:mucus",
      B: "naturalist:lizard_tail",
    })
    .id("refinedstorage:processor_binding");

  // Raw Processors
  let makeRawProcessor = (Type, Input) => {
    event
      .shaped(`refinedstorage:raw_${Type}_processor`, ["AB", "CD"], {
        A: "refinedstorage:processor_binding",
        B: Input,
        C: "refinedstorage:silicon",
        D: "alexscaves:sea_glass_shards",
      })
      .id(`refinedstorage:raw_${Type}_processor`);
  };

  makeRawProcessor("basic", "#forge:ingots/invar");
  makeRawProcessor("improved", "#forge:ingots/electrum");
  makeRawProcessor("advanced", "#forge:ingots/enderium");

  // Processors
  let makeProcessor = (Type) => {
    event.remove({ output: `refinedstorage:${Type}_processor` });
    event.recipes.create
      .filling(`refinedstorage:${Type}_processor`, [
        Fluid.of("alexscaves:acid", 250),
        `refinedstorage:raw_${Type}_processor`,
      ])
      .id(`refinedstorage:${Type}_processor`);
  };

  makeProcessor("basic");
  makeProcessor("improved");
  makeProcessor("advanced");

  event.remove({ output: "extrastorage:neural_processor" });
  event.recipes.create
    .filling("extrastorage:neural_processor", [
      Fluid.of("alexscaves:acid", 250),
      "extrastorage:raw_neural_processor",
    ])
    .id("extrastorage:neural_processor");

  // Machine Casing
  event.recipes.create
    .mechanical_crafting(
      "refinedstorage:machine_casing",
      ["AABAA", "ACDCA", "BEFEB", "ACECA", "AABAA"],
      {
        A: "create_new_age:overcharged_iron",
        B: "alexscaves:depth_glass",
        C: "createaddition:copper_spool",
        D: "createaddition:large_connector",
        E: "createaddition:connector",
        F: "alexscaves:heart_of_iron",
      }
    )
    .id("refinedstorage:machine_casing");

  // Construction and Destruction Cores

  let seqCores = (Output, Deploy1) => {
    const TransItem = "refinedstorage:incomplete_processor";

    event.recipes.create
      .sequenced_assembly(Output, "refinedstorage:basic_processor", [
        event.recipes.create.deploying(TransItem, [TransItem, Deploy1]),
        event.recipes.create.deploying(TransItem, [
          TransItem,
          "create_new_age:overcharged_iron_wire",
        ]),
        event.recipes.create.filling(TransItem, [
          TransItem,
          Fluid.of("alexscaves:acid", 250),
        ]),
        event.recipes.create.pressing(TransItem, TransItem),
      ])
      .transitionalItem(TransItem)
      .loops(1)
      .id(Output);
  };

  seqCores("refinedstorage:construction_core", "thermal:sapphire");
  seqCores("refinedstorage:destruction_core", "thermal:ruby");

  // Swap Quartz Enriched Iron for Overcharged Iron

  event.replaceInput(
    [{ mod: "refinedstorage" },{ mod: "refinedstorageaddons" },{ mod: "extrastorage" }],
    "refinedstorage:quartz_enriched_iron",
    "create_new_age:overcharged_iron"
  );

  // Swap Glass for Depth Glass

  event.replaceInput(
    [{ mod: "refinedstorage" },{ mod: "refinedstorageaddons" },{ mod: "extrastorage" }],
    "#forge:glass",
    "alexscaves:depth_glass"
  );

  // Wireless Crafting Grid
  event.shaped('refinedstorageaddons:wireless_crafting_grid',
[
  'ABA',
  'ACA',
  'ADA'
],
{
  A: 'create_new_age:overcharged_iron',
  B: 'toms_storage:ts.adv_wireless_terminal',
  C: '#refinedstorage:crafting_grid',
  D: 'refinedstorage:advanced_processor'
})
.id('refinedstorageaddons:wireless_crafting_grid')

  // Network Transmitter and Receiver
  event.replaceInput(
    { mod: 'refinedstorage' },
    '#forge:ingots/netherite',
    'alexscaves:beholder'
  );

// Infinity Range Booster
event.shaped('rsinfinitybooster:infinity_card',
[
  'ABA',
  'BCB',
  'DDD'
],
{
  A: 'minecraft:ender_eye',
  B: 'refinedstorage:range_upgrade',
  C: 'alexscaves:pure_darkness',
  D: 'createutilities:void_steel_ingot'
})
.id('rsinfinitybooster:infinity_card')

// Dimension Card
event.shaped('rsinfinitybooster:dimension_card',
[
  'ABA',
  'CDE',
  'ABA'
],
{
  A: 'rsinfinitybooster:infinity_card',
  B: 'createutilities:graviton_tube',
  C: 'refinedstorage:network_receiver',
  D: 'refinedstorage:network_card',
  E: 'refinedstorage:network_transmitter'
})
.id('rsinfinitybooster:dimension_card')


  // CableTiers mod changes
  event.replaceInput(
    { mod: 'cabletiers' },
    '#forge:storage_blocks/iron',
    '#forge:storage_blocks/desh'
  );

  event.replaceInput(
    { mod: 'cabletiers' },
    '#forge:storage_blocks/diamond',
    '#forge:storage_blocks/ostrum'
  );

  event.replaceInput(
    { mod: 'cabletiers' },
    '#forge:storage_blocks/netherite',
    '#forge:storage_blocks/calorite'
  );

  event.replaceInput(
    { mod: 'cabletiers' },
    'minecraft:dragon_head',
    'rats:marbled_cheese_rat_head'
  );

// Extra Storage Changes

// Iron Crafter

event.shaped('extrastorage:iron_crafter',
[
  'ABA',
  ' C ',
  'ADA'
],
{
  A: '#forge:ingots/silver',
  B: 'create_sa:vault_component',
  C: '#refinedstorage:crafter',
  D: 'create_dd:integrated_circuit'
})
.id('extrastorage:iron_crafter')

// Gold Crafter

event.shaped('extrastorage:gold_crafter',
[
  'ABA',
  'CDC',
  'AEA'
],
{
  A: '#forge:storage_blocks/dawnstone',
  B: 'create_sa:vault_component',
  C: 'extrastorage:neural_processor',
  D: 'extrastorage:iron_crafter',
  E: 'create_dd:integrated_circuit'
})
.id('extrastorage:gold_crafter')

// Diamond Crafter

event.shaped('extrastorage:diamond_crafter',
[
  'ABA',
  'CDC',
  'AEA'
],
{
  A: '#forge:storage_blocks/enderium',
  B: 'create_sa:vault_component',
  C: 'extrastorage:neural_processor',
  D: 'extrastorage:gold_crafter',
  E: 'create_dd:integrated_circuit'
})
.id('extrastorage:diamond_crafter')

// Netherite Crafter

event.shaped('extrastorage:netherite_crafter',
[
  'ABA',
  'CDC',
  'AEA'
],
{
  A: '#forge:storage_blocks/ostrum',
  B: 'create_sa:vault_component',
  C: 'extrastorage:neural_processor',
  D: 'extrastorage:diamond_crafter',
  E: 'create_dd:integrated_circuit'
})
.id('extrastorage:netherite_crafter')



});
