ServerEvents.recipes((event) => {
  event.shaped(Item.of('refinedstorage:machine_casing', 1), ['ISI', 'SAS', 'ISI'], {
    I: 'create:iron_sheet',
    S: 'create:sturdy_sheet',
    A: 'create:andesite_alloy_block',
  });
  event.remove({
    output: [
      'refinedstorage:controller',
      'refinedstorage:raw_basic_processor',
      'refinedstorage:raw_improved_processor',
      'refinedstorage:raw_advanced_processor',
      'refinedstorage:basic_processor',
      'refinedstorage:improved_processor',
      'refinedstorage:advanced_processor',
      'refinedstorage:machine_casing',
      'create_connected:control_chip',
      'refinedstorage:quartz_enriched_copper',
      'refinedstorage:quartz_enriched_iron',
    ],
  });
});

ServerEvents.recipes((event) => {
  // Required for Create recipes
  addCreateRecipeHandler(event);

  // === REFINED STORAGE CONTROLLER ====
  event.recipes
    .createMechanicalCrafting('refinedstorage:controller', [' DDD ', 'DSLSD', 'DOCED', 'DSLSD', ' DDD '], {
      D: 'create:sturdy_sheet',
      S: 'eternal_starlight:golem_steel_ingot',
      C: 'refinedstorage:machine_casing',
      L: 'create:electron_tube',
      O: 'refinedstorage:construction_core',
      E: 'refinedstorage:destruction_core',
    })
    .id('mechanical_controller');

  // === CORES ===
  event.shapeless(Item.of('refinedstorage:construction_core', 1), ['create:electron_tube', 'forbidden_arcanus:arcane_crystal_dust']);
  event.shapeless(Item.of('refinedstorage:destruction_core', 1), ['create:electron_tube', 'renether:tourmaline_dust']);

  // === BASIC PROCESSOR ===
  event.recipes
    .createSequencedAssembly('refinedstorage:basic_processor', 'create:precision_mechanism', [
      event.recipes.create.deploying('refinedstorage:raw_basic_processor', ['refinedstorage:raw_basic_processor', 'create:iron_sheet']),
      event.recipes.create.deploying('refinedstorage:raw_basic_processor', ['refinedstorage:raw_basic_processor', 'refinedstorage:silicon']),
      event.recipes.create.deploying('refinedstorage:raw_basic_processor', ['refinedstorage:raw_basic_processor', 'create:sturdy_sheet']),
      event.recipes.create.pressing('refinedstorage:raw_basic_processor', 'refinedstorage:raw_basic_processor'),
    ])
    .transitionalItem('refinedstorage:raw_basic_processor')
    .loops(1)
    .id('seq_basic_processor');

  // === IMPROVED PROCESSOR ===
  event.recipes
    .createSequencedAssembly('refinedstorage:improved_processor', 'create:precision_mechanism', [
      event.recipes.create.deploying('refinedstorage:raw_improved_processor', ['refinedstorage:raw_improved_processor', 'create:golden_sheet']),
      event.recipes.create.deploying('refinedstorage:raw_improved_processor', ['refinedstorage:raw_improved_processor', 'refinedstorage:silicon']),
      event.recipes.create.deploying('refinedstorage:raw_improved_processor', ['refinedstorage:raw_improved_processor', 'create:sturdy_sheet']),
      event.recipes.create.pressing('refinedstorage:raw_improved_processor', 'refinedstorage:raw_improved_processor'),
    ])
    .transitionalItem('refinedstorage:raw_improved_processor')
    .loops(1)
    .id('seq_improved_processor');

  // === ADVANCED PROCESSOR ===
  event.recipes
    .createSequencedAssembly('refinedstorage:advanced_processor', 'create:precision_mechanism', [
      event.recipes.create.deploying('refinedstorage:raw_advanced_processor', ['refinedstorage:raw_advanced_processor', 'minecraft:diamond']),
      event.recipes.create.deploying('refinedstorage:raw_advanced_processor', ['refinedstorage:raw_advanced_processor', 'refinedstorage:silicon']),
      event.recipes.create.deploying('refinedstorage:raw_advanced_processor', ['refinedstorage:raw_advanced_processor', 'create:sturdy_sheet']),
      event.recipes.create.pressing('refinedstorage:raw_advanced_processor', 'refinedstorage:raw_advanced_processor'),
    ])
    .transitionalItem('refinedstorage:raw_advanced_processor')
    .loops(1)
    .id('seq_advanced_processor');

  // === QUARTZ ENRICHED IRON ===
  event.recipes.createMixing('refinedstorage:quartz_enriched_iron', ['minecraft:iron_ingot', 'minecraft:quartz']).heated().id('mix_quartz_enriched_iron');

  // === QUARTZ ENRICHED COPPER ===
  event.recipes.createMixing('refinedstorage:quartz_enriched_copper', ['minecraft:copper_ingot', 'minecraft:quartz']).heated().id('mix_quartz_enriched_copper');

  event.recipes.create.finalize();
});
