// priority: 9
//Run this at a lower priority than cyclic_whitelist.js

ServerEvents.recipes((event) => {

  event.remove([
    { output: "cyclic:glowing_helmet" },
    { output: "cyclic:anvil" },
    { output: "cyclic:apple_honey" },
    { output: "cyclic:eye_teleport" },
    { output: "cyclic:altar_destruction" },
    { output: "cyclic:battery" },
    { output: "cyclic:battery_clay" },
    { output: "cyclic:generator_solar" },
    { output: "cyclic:fire_killer" },
    { output: "cyclic:workbench" },
    { output: "cyclic:beacon" },
    { output: "cyclic:crafter" },
    { output: "cyclic:crate_mini" },
    { output: "cyclic:dark_glass" },
    { output: "cyclic:melter" },
    { output: "cyclic:solidifier" },
    { output: "cyclic:charm_stealthpotion" },
    { output: "cyclic:shield_flint" },
    { output: "cyclic:spikes_curse" },
    { output: "cyclic:spikes_fire" },
    { output: "quark:gunpowder_sack" },
    { output: "cyclic:detector_moon" },
  ]);

  //Remove cyclic solidifier recipes
  let solidifier_whitelist = [
    "cyclic:solidifier/solidifier_obs_legacy",
    "cyclic:solidifier/solidifier_obs",
    "cyclic:solidifier/solidifier_amberalt",
    "cyclic:solidifier/solidifier_amber",
    "cyclic:solidifier/solidifier_obsflower",
    "cyclic:solidifier/solidifier_ice0",
    "cyclic:solidifier/solidifier_ice",
    "cyclic:solidifier/solidifier_glass",
    "cyclic:solidifier/solidifier_glass0",
    "cyclic:melter/melter_obslava1",
    "cyclic:solidifier/fireball_dark",
    "cyclic:solidifier/candle",
    //For converting liquid back into solid form
    "cyclic:solidifier/solidifier_slimeblock",
    "cyclic:solidifier/solidifier_honey_block0",
  ];

  // let solidifier_blacklist = [
  //   "cyclic:solidifier/solidifier_obsidian",
  //   "cyclic:solidifier/solidifier_magmabricksl",
  //   "cyclic:solidifier/solidifier_magmaava",
  //   "cyclic:solidifier/solidifier_magmabrickred",
  //   "cyclic:solidifier/solidifier_magmabrick",
  //   "cyclic:solidifier/solidifier_magmaliq",
  // ];

  event.forEachRecipe({ mod: "cyclic" }, (recipe) => {
    let id = recipe.getId();
    let include = solidifier_whitelist.includes(id);
    if (id.includes("solidifier") && !include) {
      event.remove({ id: id });
    }
  });

  //Spikes
  event.shaped(
    Item.of('cyclic:spikes_fire', 1), [
    ' R ',
    ' C ',
    '   '
  ],
    {
      C: 'cyclic:spikes_iron',
      R: 'minecraft:fire_charge',
    });


  event.shaped(
    Item.of('cyclic:spikes_curse', 1), [
    'RRR',
    'RCR',
    'RRR'
  ],
    {
      C: 'cyclic:spikes_iron',
      R: 'minecraft:spider_eye',
    });


  event.shaped(
    Item.of('cyclic:melter', 1), [
    'RCR',
    'GQG',
    'OTO'
  ],
    {
      C: 'minecraft:blast_furnace',
      R: 'thermal:invar_gear',
      Q: 'thermal:machine_frame',
      G: 'minecraft:glass',
      O: 'minecraft:obsidian',
      T: 'thermal:rf_coil',
    });

  event.shaped(
    Item.of('cyclic:shield_flint', 1), [
    ' S ',
    ' F ',
    '   '
  ],
    {
      S: 'minecraft:shield',
      F: flintBlockID,
    });



  event.shaped(
    Item.of('cyclic:dark_glass', 5), [
    'TAT',
    'ATA',
    'TAT'
  ],
    {
      T: 'thermal:obsidian_glass',
      // A: 'minecraft:amethyst_shard',
      A: 'northstar:polished_amethyst',
    });

  //This should only be a LITTLE bit harder to craft than waystones warp plate
  event.recipes.create.mechanical_crafting('cyclic:eye_teleport', [
    'FFSFF',
    'OPPPO',
    'SPWPS',
    'OPPPO',
    'FFSFF'
  ], {
    P: 'minecraft:ender_pearl',
    W: 'quark:ender_watcher',
    S: 'waystones:warp_dust',
    O: 'create:powdered_obsidian',
    F: flintBlockID,
  });

  /**
   * The apple is worth 20 HP, but given that it requires 8 gold apples of 5HP each, the recipe makes this item totally fair.
   */
  event.shaped(
    Item.of('cyclic:apple_honey', 1), [
    'GGG',
    'GAG',
    'GGG'
  ],
    {
      A: 'create:honeyed_apple',
      G: 'minecraft:golden_apple',
    });


  event.shaped(
    Item.of('cyclic:charm_stealthpotion', 1), [
    'GGG',
    'CDC',
    'GGG'
  ],
    {
      C: 'minecraft:redstone',
      G: 'minecraft:gold_nugget',
      D: flintBlockID,
    });

  event.shaped(
    Item.of('cyclic:glowing_helmet', 1), [
    ' G ',
    'DDD',
    'D D'
  ], {
    D: 'minecraft:glowstone',
    //O: 'cyclic:gem_amber',
    G: 'minecraft:gold_block',
    // J: 'mowziesmobs:glowing_jelly',
  });


  event.recipes.create.mechanical_crafting('cyclic:anvil', [
    'OOOOO',
    'DTRTD',
    ' TAT ',
    'GVVVG',
    'GGGGG'
  ], {
    R: 'thermal:rf_coil',
    D: 'minecraft:diamond_block',
    O: 'cyclic:gem_obsidian',
    // o: 'cyclic:gem_amber',
    A: 'minecraft:anvil',
    G: 'minecraft:quartz_block',
    T: 'thermal:upgrade_augment_3',
    V: 'cataclysm:witherite_ingot',
  });


  event.shaped(
    Item.of('cyclic:altar_destruction', 1), [
    'GGG',
    'ONO',
    'OOO'
  ], {
    // C: 'minecraft:creeper_head',
    O: 'thermal:gunpowder_block',
    N: 'minecraft:nether_star',
    G: 'thermal:obsidian_glass',
    // G: 'minecraft:glass'
  });

  event.shaped(
    Item.of('cyclic:detector_moon', 1), [
    'GGG',
    'O O',
    'DDD'
  ], {
    O: 'minecraft:observer',
    G: 'minecraft:glass',
    D: 'minecraft:daylight_detector',
  });

  //Thermal dynamos produce about 40RF/tick 1 solar panel produces 0.16 RF/tick
  //Thermal dynamos require: 1 redstone dust, 1 rf coil, 1 iron gear, 2 iron ingots, and 2 blocks of any type
  event.shaped(
    Item.of('cyclic:generator_solar', 10), [
    ' B ',
    'ICI',
    'LRL'
  ], {
    R: 'thermal:rf_coil',
    B: 'minecraft:redstone',
    I: 'minecraft:iron_ingot',
    L: 'minecraft:bone_block',
    // C: 'cyclic:compressed_cobblestone',
    C: 'thermal:iron_gear',
  });

  event.shaped(
    Item.of('cyclic:fire_killer', 1), [
    ' T ',
    'IRI',
    'IGI'
  ], {
    R: 'minecraft:flint',
    G: 'minecraft:red_dye',
    T: 'minecraft:tripwire_hook',
    I: 'minecraft:iron_ingot',
  });

  event.shaped(
    Item.of('cyclic:workbench', 1), [
    'CCC',
    'CWC',
    'CCC'
  ], {
    C: 'cyclic:compressed_cobblestone',
    W: 'minecraft:crafting_table',
  });

});
