// priority: 9


/**
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * Thermal Recipe Changes
 */
ServerEvents.recipes((event) => {
  event.remove([
    { output: "thermal:flux_drill" },
    { output: "thermal:flux_saw" },
    { output: "thermal:machine_pulverizer" },
    { output: "thermal:area_radius_augment" },
    { output: "thermal:drill_head" },
    { output: "thermal:flux_capacitor" },
    { output: "thermal:hazmat_fabric" },
    { output: "thermal:diving_fabric" },

    { output: "thermal:diving_helmet" },

    { output: "thermal:hazmat_helmet" },
    { output: "thermal:hazmat_chestplate" },
    { output: "thermal:hazmat_leggings" },
    { output: "thermal:hazmat_boots" },
  ]);

  /**
   * New recipes
   */
  event.recipes.create.deploying('kubejs:steel_string', ['minecraft:string', 'createbigcannons:cast_iron_nugget']);

  event.shaped(Item.of('kubejs:aqua_machine', 1), [
    'GRG',
    'NMN',
    'GRG',
  ], {
    R: 'thermal:redstone_servo',
    G: 'minecraft:iron_ingot',
    // C: "create:netherite_backtank",
    M: "minecraft:heart_of_the_sea",
    N: "minecraft:nautilus_shell",
    //N: "create:golden_sheet",
  });

  event.shaped(Item.of('kubejs:light_aqua_machine', 2), [
    ' R ',
    'MAM',
    ' M ',
  ], {
    A: 'kubejs:aqua_machine',
    // G: 'minecraft:iron_ingot',
    M: "minecraft:prismarine_crystals",
    R: 'thermal:redstone_servo',
  });

  //Gives us the ability to make light aqua machines out of light aqua machines
  event.shaped(Item.of('kubejs:light_aqua_machine', 2), [
    'NRN',
    'NAN',
    'MMM',
  ], {
    A: 'kubejs:light_aqua_machine',
    M: "minecraft:prismarine_crystals",
    N: "minecraft:nautilus_shell",
    R: 'thermal:redstone_servo',
  });

  //Hazmat suit grants fire and lava protection but has less durability
  event.shaped(Item.of('thermal:hazmat_fabric', 1), [
    'SMS',
    'SRS',
    'SMS',
  ], {
    R: 'thermal:cured_rubber',
    S: "kubejs:steel_string",
    M: "minecraft:magma_cream",
  });

  event.shaped(Item.of('thermal:diving_fabric', 1), [
    'S S',
    'SRS',
    'S S',
  ], {
    R: 'minecraft:prismarine_crystals',
    S: "minecraft:string",
  });

  /**
   * To prevent the hazmat suit from eclipsing the phoenix armor, the hazmat suit requires tungsten
   * The hazmat suit has very low durability, so that is going to be a factor that would help with the balance
   * The hazmat suit also protects against harmful potions, increases air supply and reduces fall damage
   * If because of the low durability, I decide to make this easier to obtain, do so by reducing/removing magma cream
   */
  event.shaped(Item.of('thermal:hazmat_helmet', 1), [
    'FIF',
    'IGI',
    'FAF'
  ], {
    F: 'thermal:hazmat_fabric',
    I: "northstar:tungsten_ingot",
    G: "#forge:glass",
    A: "kubejs:light_aqua_machine"
  });

  event.shaped(Item.of('thermal:hazmat_chestplate', 1), [
    'F F',
    'IFI',
    'FFF',
  ], {
    F: 'thermal:hazmat_fabric',
    I: "northstar:tungsten_ingot",
  });

  event.shaped(Item.of('thermal:hazmat_leggings', 1), [
    'FFF',
    'I I',
    'F F',
  ], {
    F: 'thermal:hazmat_fabric',
    I: "northstar:tungsten_ingot",
  });

  event.shaped(Item.of('thermal:hazmat_boots', 1), [
    'F F',
    'LIL',
  ], {
    F: 'thermal:hazmat_fabric',
    I: "northstar:tungsten_ingot",
    // R: "thermal:cured_rubber",
    L: "minecraft:leather",
  });

  /**
   * The diving helmet doesnt run out of durability nor does the player die as long as they are wearing it
   * Lets prevent this from eclipsing create helmet and backtank
   * The aether iron bubble provides infinite water breathing, and doesnt run out of durability, it can be obtained in a gold dungeon
   */
  event.shaped(Item.of('thermal:diving_helmet', 1), [
    'FGF',
    'GIG',
    'TBT'
  ], {
    F: 'thermal:diving_fabric',
    G: 'minecraft:gold_ingot',
    // I: "minecraft:conduit",
    I: "#forge:glass",
    B: "aether:iron_bubble",
    T: "minecraft:iron_ingot",
  });
  //The diving helmet does a damage hit but you cant die because it regenerates, so I think it might also be fare to add an alternative tungsten recipe
  event.shaped(Item.of('thermal:diving_helmet', 1), [
    'FGF',
    'GIG',
    'TBT'
  ], {
    F: 'thermal:diving_fabric',
    G: 'minecraft:gold_ingot',
    // I: "minecraft:conduit",
    B: "kubejs:aqua_machine",
    I: "#forge:glass",
    T: "northstar:tungsten_ingot",
  });

  //Dont make this too hard, but radial enhanncment is pretty good for any item
  //Allows increased radius
  event.shaped(Item.of('thermal:area_radius_augment', 1), [
    'GrG',
    'PtP',
    'GrG',
  ], {
    // t: 'thermal:tin_ingot',
    t: 'thermal:silver_gear',
    r: 'thermal:redstone_servo',
    G: 'thermal:gold_gear',
    P: 'kubejs:precision_component',
  });


  //The pulverizer allows a chance to get additional stuff (sometimes ore doubling), if using a catalyst
  //Pulverizer affectively increases diamond yield to about 1.5x (50% chance of additional diamond)
  event.shaped(Item.of('thermal:machine_pulverizer', 1), [
    ' b ',
    'sfs',
    'iri',
  ], {
    b: 'minecraft:blast_furnace',
    r: 'thermal:rf_coil',
    f: 'thermal:machine_frame',
    s: flintBlockID,
    // i: 'thermal:copper_gear',
    //Changed copper to signalum
    i: 'thermal:signalum_gear',
  });

  //This is only used for the drill, so it makes sense to add diamond
  event.recipes.create.mechanical_crafting('thermal:drill_head', [
    ' D ',
    'DDD',
    'iii',
    'ici'
  ], {
    c: 'minecraft:copper_ingot',
    i: 'minecraft:iron_ingot',
    D: '#forge:dusts/diamond',
  });


  // This is a tool with infinite durability and can be upgraded with radial enhancment to mine 3x3, 5x5 or 7x7 blocks
  // The only balancing factor is that the drill requires a lot of power to run, but again can be upgraded
  event.recipes.create.mechanical_crafting('thermal:flux_drill', [
    ' d ',
    'gBg',
    'trt',
    'WWW',
    'EPE',
    'RER',
  ], {
    d: 'thermal:drill_head',
    r: 'thermal:rf_coil',
    B: 'kubejs:black_netherite_ingot',
    // g: 'create:sturdy_sheet',
    W: 'northstar:tungsten_sheet',
    g: 'thermal:netherite_plate',
    t: 'thermal:invar_gear',
    E: 'thermal:enderium_gear',
    P: 'kubejs:precision_machine',
    R: 'thermal:cured_rubber',
  });

  event.recipes.create.mechanical_crafting('thermal:flux_saw', [
    ' d ',
    'ggg',
    'trt',
    'RPR',
    'ERE',
  ], {
    d: 'thermal:saw_blade',
    r: 'thermal:rf_coil',
    // G: 'thermal:netherite_plate',
    t: 'thermal:invar_gear',
    // g: 'create:sturdy_sheet',
    g: 'northstar:tungsten_sheet',
    E: 'thermal:enderium_plate',
    P: 'create:precision_mechanism',
    R: 'thermal:cured_rubber',
  });

  //Thermal battery has 4 lead ingots, 1 electrum gear and 4 cured rubber
  //The original capacitor had 3 lead ingots, 3 redstone, 1 rf coil
  //Can recharge all items in inventory
  event.recipes.create.mechanical_crafting('thermal:flux_capacitor', [
    'aEa',
    'RrR',
    'lal',
    'lal'
  ], {
    r: 'thermal:rf_coil',
    l: 'thermal:lead_ingot',
    a: 'minecraft:redstone',
    //added
    R: 'thermal:cured_rubber',
    E: 'thermal:electrum_ingot',
  });


  /**
   * 
   * 
   * Create factory recipes
   * It should be different than the traditional way to make elements so we arent making multipurpose factories
   * nickel factory (Difficulty==iron) (If you live in the overworld, its harder to make, if you live on mars, its the same)
   * Silver factory (Difficulty==gold) (If you live in the overworld, its harder to make, if you live on mars, its the same)
   */
  // event.recipes.create.crushing([Item.of("thermal:nickel_nugget").withChance(0.20)], "minecraft:copper_ingot").processingTime(500);
  // event.recipes.create.crushing([Item.of("thermal:nickel_nugget").withChance(0.05)], "minecraft:raw_copper").processingTime(500);

  event.recipes.create.splashing([Item.of("thermal:silver_nugget", 3).withChance(0.18)], 'northstar:mars_sand'); //Sand -> 12% 3x gold nugget
  event.recipes.create.splashing([Item.of("thermal:nickel_nugget").withChance(0.18), Item.of("thermal:raw_nickel").withChance(0.05)], 'northstar:mars_gravel');//Gravel -> 12% iron nugget
  // event.recipes.create.splashing([Item.of("thermal:nickel_nugget").withChance(0.05)], 'northstar:mars_soil');
  event.recipes.create.splashing([Item.of("thermal:silver_nugget").withChance(0.02)], 'minecraft:soul_soil');//Gold has this too

  event.recipes.create.crushing([
    // Item.of("minecraft:flint").withChance(0.25),
    // Item.of("minecraft:gold_nugget").withChance(0.1),
    // Item.of("create:copper_nugget").withChance(0.1),
    // Item.of("create:zinc_nugget").withChance(0.1),
    // Item.of("minecraft:iron_nugget").withChance(0.1),
    // Item.of("createaddition:electrum_nugget").withChance(0.1),
    Item.of("thermal:silver_nugget").withChance(0.1),
    Item.of("thermal:nickel_nugget").withChance(0.1)
  ], 'minecraft:tuff');

  /**
   * 
   * 
   * 
   * 
   * 
   * 
   * Thermal Jetpacks
   */
  event.remove([
    //A jetpack requires a elytra
    //Higher tier jetpacks are unlocked by bossfight drops
    //A jetpack should not replace vehicles or the elytra
    //The top tier jetpack provides 12 armor points and so should be as hard as ignitium chestplate

    { output: "tjetpacks:jetpack_te1" },
    { output: "tjetpacks:jetpack_te2" },
    { output: "tjetpacks:jetpack_te3" },
    { output: "tjetpacks:jetpack_te4" },
    // { output: "tjetpacks:jetpack_te5_enderium" },
    { output: "tjetpacks:cryogenic_crystal" },
    { output: "tjetpacks:thruster_te1" },
    { output: "tjetpacks:thruster_te2" },
    { output: "tjetpacks:thruster_te3" },
    { output: "tjetpacks:thruster_te4" },
    { output: "tjetpacks:flux_chestplate" },
    { output: "tjetpacks:combustion_chamber_hard" },
  ]);

  event.shaped(Item.of('tjetpacks:flux_chestplate', 1), [
    'i i',
    'fcf',
    'iii',
  ], {
    // c: 'tjetpacks:ignitium_elytra_chestplate',
    // c: 'tjetpacks:ignitium_chestplate',
    c: 'kubejs:ignitium_pearl',
    i: 'kubejs:ignitium_ingot',
    f: 'thermal:rf_coil',
  });

  event.shaped(Item.of("tjetpacks:combustion_chamber_hard", 1), [
    "ITI",
    "IRI",
    "IPI"
  ], {
    "I": "#forge:plates/nickel",
    "T": "tjetpacks:combustion_chamber",
    "R": "thermal:redstone_servo",
    "P": "create:precision_mechanism",
  });

  // event.shaped(Item.of("tjetpacks:combustion_chamber", 1), [
  //   "IRI",
  //   "ITI",
  //   "IRI"
  // ], {
  //   "I": "#forge:plates/nickel",
  //   "T": "thermal:fluid_cell_frame",
  //   "R": "thermal:redstone_servo",
  // })


  event.shaped(Item.of('tjetpacks:cryogenic_crystal', 1), [
    'bbb',
    'brb',
    'bbb',
  ], {
    b: 'thermal:blitz_powder',
    r: 'deeperdarker:soul_crystal'
  });

  event.recipes.create.mechanical_crafting('tjetpacks:thruster_te1', [
    'PrP',
    'pCp',
    'pLp',
    'pEp'
  ], {
    r: 'thermal:rf_coil',
    p: '#forge:plates/lead',
    P: '#forge:ingots/lead',
    C: 'tjetpacks:combustion_chamber',
    L: 'thermal:lightning_charge',
    E: 'create:propeller',
  });

  event.recipes.create.mechanical_crafting('tjetpacks:thruster_te2', [
    'PrP',
    'UCU',
    'pLp',
    'UEU'
  ], {
    r: 'thermal:rf_coil',
    p: '#forge:plates/invar',
    P: '#forge:ingots/invar',
    C: 'tjetpacks:combustion_chamber_hard',
    L: 'thermal:lightning_charge',
    U: 'thermal:upgrade_augment_1',
    E: 'create:propeller',
  });

  event.recipes.create.mechanical_crafting('tjetpacks:thruster_te3', [
    'PrP',
    'UCU',
    'pLp',
    'UEU'
  ], {
    r: 'thermal:rf_coil',
    p: '#forge:plates/electrum',
    P: '#forge:ingots/electrum',
    C: 'tjetpacks:combustion_chamber_hard',
    L: 'thermal:lightning_charge',
    U: 'thermal:upgrade_augment_2',
    E: 'create:propeller',
  });

  event.recipes.create.mechanical_crafting('tjetpacks:thruster_te4', [
    'PrP',
    'UCU',
    'pLp',
    'UEU'
  ], {
    r: 'thermal:rf_coil',
    p: '#forge:plates/enderium',
    P: '#forge:ingots/enderium',
    C: 'tjetpacks:combustion_chamber_hard',
    L: 'thermal:lightning_charge',
    U: 'thermal:upgrade_augment_3',
    E: 'create:propeller',
  });


  event.recipes.create.mechanical_crafting('tjetpacks:jetpack_te1', [
    'prp',
    'sEs',
    'prp',
    'T T'
  ], {
    r: 'thermal:rf_coil',
    p: '#forge:plates/lead',
    T: 'tjetpacks:thruster_te1',
    s: 'tjetpacks:leather_strap',
    E: 'minecraft:elytra',
  });

  event.recipes.create.mechanical_crafting('tjetpacks:jetpack_te2', [
    'prp',
    'sEs',
    'prp',
    'T T'
  ], {
    r: 'thermal:rf_coil',
    p: '#forge:plates/invar',
    T: 'tjetpacks:thruster_te2',
    s: 'tjetpacks:leather_strap',
    E: 'tjetpacks:jetpack_te1',
  });

  event.recipes.create.mechanical_crafting('tjetpacks:jetpack_te3', [
    'prp',
    'sEs',
    'prp',
    'T T'
  ], {
    r: 'thermal:rf_coil',
    p: '#forge:plates/electrum',
    T: 'tjetpacks:thruster_te3',
    s: 'tjetpacks:leather_strap',
    E: 'tjetpacks:jetpack_te2',
  });

  event.recipes.create.mechanical_crafting('tjetpacks:jetpack_te4', [
    'prp',
    'sEs',
    'pCp',
    'prp',
    'T T'
  ], {
    r: 'thermal:rf_coil',
    p: '#forge:plates/enderium',
    T: 'tjetpacks:thruster_te4',
    s: 'tjetpacks:leather_strap',
    E: 'tjetpacks:jetpack_te3',
    C: 'tjetpacks:cryogenic_crystal',
  });

});