// priority: 100
ServerEvents.recipes(event => {
  
  // Replacing items with other items (or with tags if the original mod forgot to do so)
  let replaceItemInRecipes = (original, replacement) => {
    event.replaceInput({input: original }, original, replacement)  
  }
  
  // replaceItemInRecipes('#aether:skyroot_stick', '#forge:rods/wooden')
  // replaceItemInRecipes('#forge:mushrooms/portobello', '#forge:mushrooms/portabella')
  // replaceItemInRecipes('#forge:dough', 'minecraft:wheat')
  replaceItemInRecipes('aether:skyroot_stick', '#forge:rods/wooden')
  replaceItemInRecipes('galosphere:silver_block', '#forge:storage_blocks/silver')
  replaceItemInRecipes('galosphere:silver_ingot', '#forge:ingots/silver')
  replaceItemInRecipes('gravitation:bronzite_ingot', 'unify:bronze_ingot')
  replaceItemInRecipes('minecraft:bread', '#forge:bread')
  replaceItemInRecipes('netherexp:soul_candle', 'buzzier_bees:soul_candle')
  replaceItemInRecipes('oreganized:electrum_ingot', '#forge:ingots/electrum')
  replaceItemInRecipes('oreganized:lead_block', '#forge:storage_blocks/lead')
  replaceItemInRecipes('quark:polished_calcite', 'caverns_and_caverns:polished_calcite')
  
  // Map redo
  event.remove({ id: 'minecraft:map' })
  
  // Jade stuff
  let jadeSmithing = (outputItem, inputItem) => {
    event.smithing( outputItem, 'sullysmod:jade_upgrade_smithing_template', // Smithing Template
      inputItem,  'sullysmod:jade', // Upgrade material
    )
    event.remove({output: outputItem})
  }
  
  jadeSmithing('deep_aether:skyjade_helmet', 'minecraft:diamond_helmet')
  jadeSmithing('deep_aether:skyjade_chestplate', 'minecraft:diamond_chestplate')
  jadeSmithing('deep_aether:skyjade_leggings', 'minecraft:diamond_leggings')
  jadeSmithing('deep_aether:skyjade_boots', 'minecraft:diamond_boots')
  jadeSmithing('deep_aether:skyjade_moa_armor', 'aether_protect_your_moa:diamond_moa_armor')
  
  jadeSmithing('deep_aether:skyjade_axe', 'minecraft:diamond_axe')
  jadeSmithing('deep_aether:skyjade_hoe', 'minecraft:diamond_hoe')
  jadeSmithing('deep_aether:skyjade_pickaxe', 'minecraft:diamond_pickaxe')
  jadeSmithing('deep_aether:skyjade_sword', 'minecraft:diamond_sword')
  jadeSmithing('deep_aether:skyjade_shovel', 'minecraft:diamond_shovel')
  jadeSmithing('delightful:skyjade_knife', 'farmersdelight:diamond_knife')
  
  jadeSmithing('sullysmod:jade_shield', 'shieldexp:diamond_shield')

  event.remove({ id: 'sullysmod:smithing/jade_shield' })
  
  // Necromium stuff
  let necromiumSmithing = (outputItem, inputItem) => {
    event.smithing( outputItem, 'kubejs:necromium_upgrade_smithing_template', // Smithing Template
      inputItem,  '#forge:ingots/necromium', // Upgrade material
    )
    event.remove({output: outputItem})
  }
  
  necromiumSmithing('caverns_and_chasms:necromium_helmet', 'gravitation:bronzite_helmet')
  necromiumSmithing('caverns_and_chasms:necromium_chestplate', 'gravitation:bronzite_chestplate')
  necromiumSmithing('caverns_and_chasms:necromium_leggings', 'gravitation:bronzite_leggings')
  necromiumSmithing('caverns_and_chasms:necromium_boots', 'gravitation:bronzite_boots')
  
  necromiumSmithing('caverns_and_chasms:necromium_horse_armor', 'kubejs:bronze_horse_armor')
  
  necromiumSmithing('caverns_and_chasms:necromium_axe', 'gravitation:bronzite_axe')
  necromiumSmithing('caverns_and_chasms:necromium_hoe', 'gravitation:bronzite_hoe')
  necromiumSmithing('caverns_and_chasms:necromium_pickaxe', 'gravitation:bronzite_pickaxe')
  necromiumSmithing('caverns_and_chasms:necromium_sword', 'gravitation:bronzite_sword')
  necromiumSmithing('caverns_and_chasms:necromium_shovel', 'gravitation:bronzite_shovel')
  
  necromiumSmithing('abnormals_delight:necromium_knife', 'delightful:bronze_knife')
  
  // Electrum stuff

  let electrumSmithing = (outputItem, inputItem) => {
    event.smithing( outputItem, 'oreganized:electrum_upgrade_smithing_template', // Smithing Template
      inputItem,  '#forge:ingots/electrum', // Upgrade material
    )
    event.remove({output: outputItem})
  }
  
  electrumSmithing('oreganized:electrum_helmet', 'gravitation:bronzite_helmet')
  electrumSmithing('oreganized:electrum_chestplate', 'gravitation:bronzite_chestplate')
  electrumSmithing('oreganized:electrum_leggings', 'gravitation:bronzite_leggings')
  electrumSmithing('oreganized:electrum_boots', 'gravitation:bronzite_boots')
  
  electrumSmithing('oreganized:electrum_shield', 'gravitation:bronzite_shield')
  
  electrumSmithing('oreganized:electrum_axe', 'gravitation:bronzite_axe')
  electrumSmithing('oreganized:electrum_hoe', 'gravitation:bronzite_hoe')
  electrumSmithing('oreganized:electrum_pickaxe', 'gravitation:bronzite_pickaxe')
  electrumSmithing('oreganized:electrum_sword', 'gravitation:bronzite_sword')
  electrumSmithing('oreganized:electrum_shovel', 'gravitation:bronzite_shovel')
  
  electrumSmithing('oreganized:electrum_knife', 'delightful:bronze_knife')

  
  
  event.smithing( 'wan_ancient_beasts:reinforced_shield', 'wan_ancient_beasts:ancient_upgrade_smithing_template', // Smithing Template
    'shieldexp:diamond_shield',  'wan_ancient_beasts:crusher_spike', // Upgrade material
  )
  event.remove({id: 'wan_ancient_beasts:reinforced_shield_smithing'})
  
  
  // New Spyglass recipe
  event.remove({id: 'minecraft:spyglass'})
  event.shaped('minecraft:spyglass', [
    ' A ',
    ' B ',
    ' C '
  ],{
    A:'minecraft:amethyst_shard',
    B:'#forge:ingots/copper',
    C:'#forge:rods/wooden',
  })
  
  // New Magnetic Compass and recipe
  event.shaped('spelunkery:magnetic_compass', [
    ' I ',
    'IRI',
    ' I '
  ],{
    I:'#forge:ingots/magnetic',
    S:'#forge:dusts/redstone',
  })
  
  // Fixing recipe conflict with furnace using #forge:cobblestone 
  event.remove({id: 'quark:building/crafting/furnaces/cobblestone_furnace'})
  event.shaped('minecraft:furnace', [
    'CCC',
    'C C',
    'CCC'
  ],{
    C:'minecraft:cobblestone',
  })

  // New Coaster recipe
  event.remove({id: 'brewinandchewin:item_coaster'})
  
  event.shaped('4x brewinandchewin:coaster', [
    '   ',
    'SCS',
    '   '
  ],{
    C:'farmersdelight:canvas',
    S:'#forge:rods/wooden',
  })
  
  // Removing smelting food -> charcoal recipe because I don't like it
  event.remove({id: 'spelunkery:charcoal_lump_from_smelting_food'})
  event.remove({id: 'spelunkery:charcoal_lump_from_blasting_food'})

  // Fixing recipe conflict with bamboo
  event.remove({id: 'minecraft:scaffolding'})
  event.remove({id: 'farmersdelight:scaffolding_from_canvas'})
  event.remove({id: 'mynethersdelight:crafting/scaffolding_alt'})
  event.remove({id: 'minecraft:stick_from_bamboo_item'})
  
  event.shaped('6x minecraft:scaffolding', [
    'BNB',
    'B B',
    'B B'
  ],{
    B:'#caramel:bamboo',
    N:'#caramel:scaffolding_net',
  })
  
  event.remove({id: 'farmersdelight:basket'})
  
  event.replaceInput(
    {id: 'supplementaries:lunch_basket' }, // Condense these with a helper function at some point
    'minecraft:bamboo', 
    '#caramel:bamboo'
  )
  
  event.replaceInput(
    {id: 'quark:building/crafting/paper_lantern' },
    'minecraft:bamboo', 
    '#caramel:bamboo'
  )
  
  event.replaceInput(
    {id: 'quark:building/crafting/panes/paper_wall' },
    'minecraft:bamboo', 
    '#caramel:bamboo'
  )
  
  event.replaceInput(
    {id: 'supplementaries:bamboo_spikes' },
    'minecraft:bamboo', 
    '#caramel:bamboo'
  )
  
  event.replaceInput(
    {id: 'supplementaries:flute' },
    'minecraft:bamboo', 
    '#caramel:bamboo'
  )
  
  event.replaceInput(
    {id: 'naturalist:bug_net' },
    'minecraft:bamboo', 
    '#caramel:bamboo'
  )
  
  // New Cupric Torch recipe
  event.replaceInput(
    {id: 'caverns_and_chasms:cupric_torch' },
    '#caverns_and_chasms:cupric_fire_base_blocks', 
    '#forge:ingots/copper'
  )
  
  // Removing overlapping charcoal -> X recipe
  event.remove({id: 'quark:tweaks/crafting/utility/misc/charcoal_to_black_dye'})
  
  // Removing overlapping double coloured wool + dye -> coloured wool
  event.remove({id: 'minecraft:dye_black_wool'})
  event.remove({id: 'minecraft:dye_blue_wool'})
  event.remove({id: 'minecraft:dye_brown_wool'})
  event.remove({id: 'minecraft:dye_cyan_wool'})
  event.remove({id: 'minecraft:dye_gray_wool'})
  event.remove({id: 'minecraft:dye_green_wool'})
  event.remove({id: 'minecraft:dye_light_blue_wool'})
  event.remove({id: 'minecraft:dye_light_gray_wool'})
  event.remove({id: 'minecraft:dye_lime_wool'})
  event.remove({id: 'minecraft:dye_magenta_wool'})
  event.remove({id: 'minecraft:dye_orange_wool'})
  event.remove({id: 'minecraft:dye_pink_wool'})
  event.remove({id: 'minecraft:dye_purple_wool'})
  event.remove({id: 'minecraft:dye_red_wool'})
  event.remove({id: 'minecraft:dye_white_wool'})
  event.remove({id: 'minecraft:dye_yellow_wool'})
  
  // Removing overlapping cake recipes
  event.remove({id: 'caverns_and_chasms:cake'})
  
  // Removing a weird overlapping (Infused) Veridum Knife recipe
  event.remove({id: 'delightful:knives/infused_veridium_knife'})
  
  // Hopper stuff
  event.remove({id: 'quark:tweaks/crafting/utility/misc/easy_hopper'})
  event.remove({id: 'minecraft:hopper'})
  event.shaped('4x minecraft:hopper', [
    'I I',
    'ICI',
    ' I '
  ],{
    C:'#forge:chests/wooden',
    I:'#forge:ingots/iron',
  })
  
  // Quick Shrapnel Bomb Minecart recipe for consistency with Quark
  event.shaped('oreganized:shrapnel_bomb_minecart', [
    'ISI',
    'III',
    '   '
  ],{
    I:'#forge:ingots/iron',
    S:'oreganized:shrapnel_bomb',
  })


  // Trophy recipe
  event.shapeless('kubejs:trophy', [
    '#caramel:nukelist',
  ])
  
  // Fixing duplicate Crafting Table recipes (Aether, why do you have to have your own special planks)
  event.remove({id: 'aether:skyroot_crafting_table'})
  event.remove({id: 'deep_aether:skyroot_crafting_table'})
  
  
  // Removing one Jade Flinger Totem recipe for consistency
  event.remove({id: 'sullysmod:jade_flinger_totem'})
  
  
  // New Dirty Glass recipe
  event.remove({id: 'quark:tweaks/crafting/dirty_glass'})
  event.shaped('quark:dirty_glass', [
    'SS ',
    'SS ',
    '   '
  ],{
    S:'quark:dirty_shard',
  })
  
  event.shaped('8x quark:dirty_glass', [
    'GGG',
    'GDG',
    'GGG'
  ],{
    G:'minecraft:glass',
    D:'#minecraft:dirt',
  })
  
  event.shaped('8x quark:dirty_glass_pane', [
    'GGG',
    'GDG',
    'GGG'
  ],{
    G:'minecraft:glass_pane',
    D:'#minecraft:dirt',
  })

  event.remove({id: 'quark:oddities/crafting/backpack'})
  event.shaped('quark:backpack', [
    'HRH',
    'BSB',
    'BLB'
  ],{
    B:'minecraft:bundle',
    H:'minecraft:rabbit_hide',
    L:'#forge:leather',
    R:'#forge:ropes',
    S:'supplementaries:sack'
  })

  event.remove({id: 'deep_aether:crystal_brewing_stand'})
  event.remove({id: 'quark:building/crafting/furnaces/mixed_furnace'})
  event.remove({id: 'lost_aether_content:gale_stone_mosaic'})

  event.remove({id: 'spelunkery:coal_ore_smelting'})
  event.remove({id: 'spelunkery:copper_ore_smelting'})
  event.remove({id: 'spelunkery:diamond_ore_smelting'})
  event.remove({id: 'spelunkery:emerald_ore_smelting'})
  event.remove({id: 'spelunkery:gold_ore_smelting'})
  event.remove({id: 'spelunkery:iron_ore_smelting'})
  event.remove({id: 'spelunkery:lapis_ore_smelting'})
  event.remove({id: 'spelunkery:redstone_ore_smelting'})

  event.remove({id: 'spelunkery:coal_ore_blasting'})
  event.remove({id: 'spelunkery:copper_ore_blasting'})
  event.remove({id: 'spelunkery:diamond_ore_blasting'})
  event.remove({id: 'spelunkery:emerald_ore_blasting'})
  event.remove({id: 'spelunkery:gold_ore_blasting'})
  event.remove({id: 'spelunkery:iron_ore_blasting'})
  event.remove({id: 'spelunkery:lapis_ore_blasting'})
  event.remove({id: 'spelunkery:redstone_ore_blasting'})
  
  // Making more stuff into storage blocks
  let storageBlocking = (item, storageBlock) => {
    event.remove({output: storageBlock})
    event.shaped(storageBlock, [
      'III',
      'III',
      'III'
    ],{
      I:item,
    })
    
    event.shapeless(`9x ${item}`, [
      storageBlock,
    ])
  }
  
  storageBlocking('minecraft:quartz', 'minecraft:quartz_block')
  storageBlocking('aether:blue_berry', 'ascended_quark:blue_berry_crate')
  storageBlocking('deep_aether:goldenleaf_berries', 'ascended_quark:goldenleaf_berries_crate')
  
  event.remove({id: 'netherexp:nether_quartz_from_quartz_block'})

  
})