// priority: 9
/** 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * Waystones
 */
ServerEvents.recipes((event) => {
  //Replace recipes
  event.remove([
    { output: "waystones:warp_plate" },
    { output: "waystones:warp_stone" },
    { output: "waystones:warp_dust" },
    { output: "waystones:return_scroll" },
    { output: "waystones:bound_scroll" },
    { output: "waystones:warp_scroll" },
  ]);

  //1 netherite scrap makes 8 nethersteel ingots
  //Thats enough for 2 warp plates or 2 warp stones
  event.shaped(Item.of("kubejs:warp_core", 1), [
    " D ",
    "DGD",
    " D ",
  ],
    {
      // G: "minecraft:emerald",
      G: 'kubejs:ancient_pearl',
      D: "kubejs:void_ingot",
      //A: 'kubejs:black_netherite_ingot',
      // A: 'kubejs:abyssal_ingot',
      //A:'kubejs:cursium_pearl',
      // L: 'minecraft:lodestone',
      //A: "northstar:polished_lunar_sapphire",
      //A: "northstar:martian_steel_sheet",
    });

  //We could use pyrotide or abyssal ingot instead of lunar amethyst
  event.recipes.create.mechanical_crafting("waystones:warp_stone", [
    " AAA ",
    "AEEEA",
    "AEWEA",
    "AEEEA",
    " AAA ",
  ],
    {
      W: 'kubejs:warp_core',
      A: "northstar:polished_lunar_sapphire",
      E: "minecraft:ender_pearl",
    });

  //We could make warp dust harder, since eye_teleport and warp plate are the only 2 that use it (warp plate and block both use 4 warp dust)
  event.shapeless(Item.of("waystones:warp_dust", 4), [
    "thermal:ender_pearl_dust",
    "northstar:polished_lunar_sapphire",
    "northstar:polished_lunar_sapphire",
    "northstar:polished_lunar_sapphire",
  ]);

  event.shaped(Item.of("waystones:return_scroll", 1), [
    "PPP",
    "GDG",
    "PEP"
  ],
    {
      P: "minecraft:paper",
      D: "waystones:warp_dust",
      E: "kubejs:cursium_pearl",
      G: "create_enchantment_industry:hyper_experience_bottle",
    }
  );

  event.shaped(Item.of("waystones:bound_scroll", 1), [
    "PBP",
    "BXB",
    "PBP"
  ],
    {
      X: "waystones:return_scroll",
      B: "minecraft:blaze_rod",
      P: "minecraft:paper",
    }
  );

  event.shaped(Item.of("waystones:warp_scroll", 1), [
    "PBP",
    "BXB",
    "PBP"
  ],
    {
      X: "waystones:bound_scroll",
      B: "minecraft:compass",
      P: "minecraft:paper",
    }
  );

  //Warp plate comes with 4 free warp dust and 1 flint (that is why it is in the original recipe)
  //This should be hard to engourage other means of travel for short distances
  //If we really wanted to make this hard, we should add a nether star
  //THIS could reqyire pyrotide
  event.recipes.create.mechanical_crafting('waystones:warp_plate', [
    'OOOOO',
    'DDKDD',
    'OOROO',
    'FFWFF',
  ],
    {
      D: 'waystones:warp_dust',
      K: "minecraft:flint",
      R: 'kubejs:cursium_pearl',
      O: 'minecraft:lodestone',
      W: 'waystones:warp_stone',
      F: 'minecraft:obsidian',
    });
});



/**
 * 
 * 
 * 
 * Aether recipes
 */
ServerEvents.recipes((event) => {
  event.remove([
    { output: "aether:altar" },
  ]);

  //The Altar allows items to be recharged using ambrosium shards
  //https://aether.fandom.com/wiki/Zanite_Gemstone
  //Zanite is the second most common ore in The Aether. 
  //https://aether.fandom.com/wiki/Ambrosium_Shard
  //Holystone Tools when being used have a chance to cause whatever they are being used on to drop an Ambrosium Shard.
  //The altar smelts gravitite into enchanted gravitite (block)
  event.shaped(Item.of('aether:altar', 1), [
    'ZZZ',
    'ZAZ',
    'HAH',
  ], {
    Z: 'aether:zanite_block',
    A: 'kubejs:pyrotide_shard',
    H: 'aether:holystone',
  });
});


/**
 * 
 * 
 * 
 * Create addons
 */
ServerEvents.recipes((event) => {
  event.remove([
    { output: "create_power_loader:empty_andesite_chunk_loader" },
    { output: "create_power_loader:empty_brass_chunk_loader" },
  ]);

  //The andesite chunkloader only loads the current chunk
  //it requires 1 netherite gear and way more precision mechanisms
  event.recipes.create.mechanical_crafting('create_power_loader:empty_andesite_chunk_loader', [
    'GGGGG',
    'GV VG',
    'GPXPG',
    'AVSVA',
    'AASAA'
  ], {
    G: '#forge:glass',
    S: 'create:shaft',
    A: 'create:andesite_casing',
    X: 'minecraft:respawn_anchor',
    V: 'kubejs:hydronite_shard',
    P: 'kubejs:precision_component',
  });

  // //The brass chunkloader works in a  1x1, 3x3 or 5x5 pattern
  // //It reqires 3x as much netherite gear
  // event.recipes.create.mechanical_crafting('create_power_loader:empty_brass_chunk_loader', [
  //   'GGGGG',
  //   'GPPPG',
  //   'GVXVG',
  //   'AVSVA',
  //   'AASAA'
  // ], {
  //   G: 'thermal:enderium_glass',
  //   S: 'create:shaft',
  //   A: 'create:brass_casing',
  //   V: 'kubejs:hydronite_shard',
  //   X: 'minecraft:respawn_anchor',
  //   P: 'kubejs:precision_machine',
  // });


  event.remove([
    { output: "create_enchantment_industry:printer" },
    { output: "createpropulsion:thruster" },
    { output: "createpropulsion:physics_assembler" },
    { output: "createpropulsion:assembly_gauge" }
  ]);

  //We can reprint enchantments with this
  event.shaped(Item.of("create_enchantment_industry:printer", 1), [
    " C ",
    "BGB",
    "III"
  ],
    {
      C: "create:copper_casing",
      B: "minecraft:dried_kelp",
      I: "#forge:plates/iron",
      G: "aether:enchanted_gravitite"
    });

  //All we added was the combustion chamber
  //Mechanical recipes can be automated but if too tedious, we can make this a 3x3 pattern

  event.shaped(Item.of('createpropulsion:physics_assembler', 1), [
    ' W ',
    'GAG',
    'III',
  ], {
    W: 'vs_clockwork:wanderlite_matrix',
    A: 'create:precision_mechanism',
    I: 'create:sturdy_sheet',
    G: '#forge:plates/gold',
  });

  event.shaped(Item.of('createpropulsion:assembly_gauge', 1), [
    ' W ',
    ' G ',
    ' I ',
  ], {
    W: 'vs_clockwork:wanderlite_matrix',
    // A: 'minecraft:amethyst_shard',
    I: '#forge:plates/iron',
    G: '#forge:plates/gold',
  });

  event.shaped(Item.of('createpropulsion:thruster', 1), [ //Did requrie a precision mechanism before I changed the recipe
    'ItI',
    'ICI',
    ' p ',
  ], {
    I: '#forge:plates/iron',
    C: 'tjetpacks:combustion_chamber',
    t: 'create:fluid_pipe',
    p: 'create:propeller',
  });
});

/**
 * 
 * 
 * 
 * 
 *
 * 
 * 
 * 
 * 
 * Clockwork / vs_eureka
 * 
 */
ServerEvents.recipes((event) => {

  event.remove([
    { output: "vs_eureka:engine" },
    { output: "vs_eureka:oak_ship_helm" },
    { output: "vs_eureka:birch_ship_helm" },
    { output: "vs_eureka:spruce_ship_helm" },
    { output: "vs_eureka:acacia_ship_helm" },
    { output: "vs_eureka:dark_oak_ship_helm" },
    { output: "vs_eureka:jungle_ship_helm" },
    { output: "vs_eureka:crimson_ship_helm" },
    { output: "vs_eureka:warped_ship_helm" },
  ]);

  event.shaped(Item.of("vs_eureka:engine", 1), [
    "SSS",
    "IBp",
    "PGP"
  ],
    {
      G: "create:brass_block",
      I: "minecraft:iron_ingot",//thermal:iron_gear
      S: "minecraft:smooth_stone",
      p: "minecraft:glass_pane",
      B: "minecraft:blast_furnace",
      P: "kubejs:brass_piston",
    }
  );


  //Ship helms
  //Ships trump any other means of transportation
  let helm_layout = [
    'FBF',
    'BWB',
    'FOF',
    'ZSZ',
  ];

  function helm_key(woodType) {
    return {
      B: 'create:brass_ingot',
      W: ['kubejs:wanderlite_ingot',
        'kubejs:wanderlite_jewel'
      ],
      S: 'kubejs:steering_mechanism',
      F: 'minecraft:' + woodType + '_fence',
      Z: "create:brass_casing",

      O: 'minecraft:' + woodType + '_planks',
    }
  }

  event.recipes.create.mechanical_crafting('vs_eureka:oak_ship_helm', helm_layout, helm_key("oak"));
  event.recipes.create.mechanical_crafting('vs_eureka:birch_ship_helm', helm_layout, helm_key("birch"));
  event.recipes.create.mechanical_crafting('vs_eureka:spruce_ship_helm', helm_layout, helm_key("spruce"));
  event.recipes.create.mechanical_crafting('vs_eureka:acacia_ship_helm', helm_layout, helm_key("acacia"));
  event.recipes.create.mechanical_crafting('vs_eureka:dark_oak_ship_helm', helm_layout, helm_key("dark_oak"));
  event.recipes.create.mechanical_crafting('vs_eureka:jungle_ship_helm', helm_layout, helm_key("jungle"));
  event.recipes.create.mechanical_crafting('vs_eureka:crimson_ship_helm', helm_layout, helm_key("crimson"));
  event.recipes.create.mechanical_crafting('vs_eureka:warped_ship_helm', helm_layout, helm_key("warped"));

  // event.shaped(Item.of('vs_eureka:oak_ship_helm', 1), helm_layout, helm_key("oak"));
  // event.shaped(Item.of('vs_eureka:birch_ship_helm', 1), helm_layout, helm_key("birch"));
  // event.shaped(Item.of('vs_eureka:spruce_ship_helm', 1), helm_layout, helm_key("spruce"));
  // event.shaped(Item.of('vs_eureka:acacia_ship_helm', 1), helm_layout, helm_key("acacia"));
  // event.shaped(Item.of('vs_eureka:dark_oak_ship_helm', 1), helm_layout, helm_key("dark_oak"));
  // event.shaped(Item.of('vs_eureka:jungle_ship_helm', 1), helm_layout, helm_key("jungle"));
  // event.shaped(Item.of('vs_eureka:crimson_ship_helm', 1), helm_layout, helm_key("crimson"));
  // event.shaped(Item.of('vs_eureka:warped_ship_helm', 1), helm_layout, helm_key("warped"));

});






/**
 * 
 * 
 * 
 * 
 *
 * 
 * 
 * 
 * 
 * Redstone Pen
 * 
 */
ServerEvents.recipes((event) => {

  event.remove([
    { output: "redstonepen:pen" },
    { output: "redstonepen:quill" },
    { output: "redstonepen:control_box" },
    // { output: "redstonepen:relay" },
    { output: "redstonepen:basic_pulse_button" },
  ]);

  event.shaped(Item.of('redstonepen:control_box', 1), [
    // event.shaped(Item.of("redstonepen:control_box", 1), [
    "QRQ",
    "RsR",
    "QRQ",
  ],
    {
      //sides
      "R": "minecraft:redstone",
      // "L": "minecraft:lapis_lazuli",
      // "G": "minecraft:gold_ingot",
      // "E": "minecraft:emerald",
      //material
      // "P": "create:precision_mechanism",
      // "Q": "create:brass_ingot",
      "Q": "create:brass_casing",
      // "s": "northstar:circuit",
      "s": "northstar:advanced_circuit",
    }
  );

  event.shapeless(Item.of("redstonepen:basic_pulse_button", 1), [
    "#minecraft:wooden_buttons",
    "create:brass_ingot",
  ]);

  // event.shaped(Item.of("redstonepen:relay", 1), [
  //   "TCT",
  //   "CDC",
  //   "III"
  // ],
  //   {
  //     "C": "minecraft:smooth_stone",
  //     "T": "minecraft:redstone_torch",
  //     "D": "minecraft:redstone",
  //     "I": "minecraft:iron_block",
  //   }
  // );

});
