// Strange Aeons: gate advanced Apotheosis infrastructure behind Cataclysm.
// Place in: kubejs/server_scripts/strange_aeons_apotheosis_gates.js
// Reload with: /reload

const HAMMER = 'cataclysm:infernal_forge'

// Apotheosis table IDs. Verify with /kubejs hand if any fail.
const SALVAGING_TABLE = 'apotheosis:salvaging_table'
const REFORGING_TABLE = 'apotheosis:reforging_table'
const GEM_CUTTING_TABLE = 'apotheosis:gem_cutting_table'
const AUGMENTING_TABLE = 'apotheosis:augmenting_table'

ServerEvents.recipes(event => {
  // Remove default recipes.
  event.remove({ output: SALVAGING_TABLE })
  event.remove({ output: REFORGING_TABLE })
  event.remove({ output: GEM_CUTTING_TABLE })
  event.remove({ output: AUGMENTING_TABLE })

  // Salvaging Table: breaks affix gear/gems into rarity materials.
  event.shaped(SALVAGING_TABLE, [
    'CAC',
    'PHP',
    'CGC'
  ], {
    C: 'minecraft:copper_ingot',
    A: 'minecraft:iron_axe',
    P: 'minecraft:iron_pickaxe',
    H: HAMMER,
    G: 'minecraft:smithing_table'
  })
  .keepIngredient(HAMMER)
  .id('strange_aeons:apotheosis/salvaging_table_cataclysm_gated')

  // Reforging Table: the more dangerous progression piece.
  event.shaped(REFORGING_TABLE, [
    'NAN',
    'DHD',
    'OSO'
  ], {
    N: 'minecraft:netherite_scrap',
    A: 'minecraft:anvil',
    D: 'minecraft:diamond',
    H: HAMMER,
    O: 'minecraft:obsidian',
    S: 'minecraft:smithing_table'
  })
  .keepIngredient(HAMMER)
  .id('strange_aeons:apotheosis/reforging_table_cataclysm_gated')

  // Gem Cutting Table: controls gem upgrading/optimization.
  event.shaped(GEM_CUTTING_TABLE, [
    'ADA',
    'GHG',
    'SQS'
  ], {
    A: 'minecraft:amethyst_shard',
    D: 'minecraft:diamond',
    G: 'minecraft:gold_ingot',
    H: HAMMER,
    S: 'minecraft:smooth_stone',
    Q: 'minecraft:quartz'
  })
  .keepIngredient(HAMMER)
  .id('strange_aeons:apotheosis/gem_cutting_table_cataclysm_gated')

  // Augmenting Table: late-game affix perfection.
  event.shaped(AUGMENTING_TABLE, [
    'ESE',
    'DHD',
    'OBO'
  ], {
    E: 'minecraft:ender_eye',
    S: 'minecraft:nether_star',
    D: 'minecraft:diamond',
    H: HAMMER,
    O: 'minecraft:crying_obsidian',
    B: 'minecraft:enchanting_table'
  })
  .keepIngredient(HAMMER)
  .id('strange_aeons:apotheosis/augmenting_table_cataclysm_gated')
})