// Kubejs scripts for adding emc substitutes to recipes

// Add tags
ServerEvents.tags('item', event => {
	
// Ember crystals
event.add('kubejs:ember_crystals', 'embers:ember_crystal')
event.add('kubejs:ember_crystals', 'kubejs:emc_ember_crystal')

// Grains of Infinity
event.add('forge:dusts/grains_of_infinity', 'kubejs:emc_grains_of_infinity')

// Andesite Alloy
event.add('kubejs:andesite_alloys', 'create:andesite_alloy')
event.add('kubejs:andesite_alloys', 'kubejs:emc_andesite_alloy')

// Silicon
event.add('forge:silicon', 'kubejs:emc_silicon')

// Alc Calx
event.add('kubejs:alchemical_calx', 'malum:alchemical_calx')
event.add('kubejs:alchemical_calx', 'kubejs:emc_alchemical_calx')

// B. Control Circuit
event.add('forge:circuits/basic', 'kubejs:emc_basic_control_circuit')

// Blank Slate
event.add('kubejs:blank_slate', 'bloodmagic:blankslate')
event.add('kubejs:blank_slate', 'kubejs:emc_blank_slate')

// Brass Ingot
event.add('forge:ingots/brass', 'kubejs:emc_brass_ingot')

// Calculation Processor
event.add('kubejs:calculation_processor', 'ae2:calculation_processor')
event.add('kubejs:calculation_processor', 'kubejs:emc_calculation_processor')

// Compressed Iron
event.add('forge:ingots/compressed_iron', 'kubejs:emc_compressed_iron_ingot')

// Constantan Ingot
event.add('forge:ingots/constantan', 'kubejs:emc_constantan_ingot')

// Copper Wire
event.add('kubejs:copper_wire', 'create_new_age:copper_wire')
event.add('kubejs:copper_wire', 'kubejs:emc_copper_wire')

// Cyanite
event.add('forge:ingots/cyanite', 'kubejs:emc_cyanite_ingot')

// Dark Matter
event.add('kubejs:dark_matter', 'projecte:dark_matter')
event.add('kubejs:dark_matter', 'kubejs:emc_dark_matter')

// Dark Steel
event.add('forge:ingots/dark_steel', 'kubejs:emc_dark_steel_ingot')

// Dawnstone
event.add('forge:ingots/dawnstone', 'kubejs:emc_dawnstone_ingot')

// Electrum
event.add('forge:ingots/electrum', 'kubejs:emc_electrum_ingot')

// Energetic Alloy
event.add('forge:ingots/energetic_alloy', 'kubejs:emc_energetic_alloy_ingot')

// Engineering Processor
event.add('kubejs:engineering_processor', 'ae2:engineering_processor')
event.add('kubejs:engineering_processor', 'kubejs:emc_engineering_processor')

// Hex Ash
event.add('kubejs:hex_ash', 'malum:hex_ash')
event.add('kubejs:hex_ash', 'kubejs:emc_hex_ash')

// Fluix Crystal
event.add('forge:gems/fluix', 'kubejs:emc_fluix_crystal')

// Infused Alloy
event.add('mekanism:alloys/infused', 'kubejs:emc_infused_alloy')

// Invar Ingot
event.add('forge:ingots/invar', 'kubejs:emc_invar_ingot')

// Logic Processor
event.add('kubejs:logic_processor', 'ae2:logic_processor')
event.add('kubejs:logic_processor', 'kubejs:emc_logic_processor')

// Lumium Ingot
event.add('forge:ingots/lumium', 'kubejs:emc_lumium_ingot')

// Mana Items
event.add('botania:mana_diamond_gems', 'kubejs:emc_mana_diamond')
event.add('botania:manasteel_ingots', 'kubejs:emc_manasteel')
event.add('botania:mana_dusts', 'kubejs:emc_mana_powder')

event.add('kubejs:mana_pearl', 'botania:mana_pearl')
event.add('kubejs:mana_pearl', 'kubejs:emc_mana_pearl')

// Source Gems
event.add('forge:gems/source', 'kubejs:emc_mana_gem')

// Iron/Steel mech component
event.add('kubejs:iron_mechanical_component', 'immersiveengineering:component_iron')
event.add('kubejs:iron_mechanical_component', 'kubejs:emc_material_component_iron')

event.add('kubejs:steel_mechanical_component', 'immersiveengineering:component_steel')
event.add('kubejs:steel_mechanical_component', 'kubejs:emc_material_component_steel')

// Polished Rose Quartz
event.add('kubejs:rose_quartz', 'create:polished_rose_quartz')
event.add('kubejs:rose_quartz', 'kubejs:emc_polished_rose_quartz')

// Red Matter
event.add('kubejs:red_matter', 'projecte:red_matter')
event.add('kubejs:red_matter', 'kubejs:emc_red_matter')

// Signalum
event.add('forge:ingots/signalum', 'kubejs:emc_signalum_ingot')

// Steel
event.add('forge:ingots/steel', 'kubejs:emc_steel_ingot')

// Wilden Drops
event.add('kubejs:wilden_horn', 'ars_nouveau:wilden_horn')
event.add('kubejs:wilden_horn', 'kubejs:emc_wilden_horn')

event.add('kubejs:wilden_spike', 'ars_nouveau:wilden_spike')
event.add('kubejs:wilden_spike', 'kubejs:emc_wilden_spike')

event.add('kubejs:wilden_wing', 'ars_nouveau:wilden_wing')
event.add('kubejs:wilden_wing', 'kubejs:emc_wilden_wing')

// Coal Coke, yes this was added last lmao
event.add('forge:coal_coke', 'kubejs:emc_coal_coke')

// Compressed Iron Armor unrecyclable
event.add('immersiveengineering:recycling/ignored_components', 'pneumaticcraft:compressed_iron_leggings')

})

ServerEvents.recipes(event => {

// Quantised ember
event.replaceInput(
  { input: 'embers:ember_crystal' },
  'embers:ember_crystal',
  '#kubejs:ember_crystals'
)

// Quantised Ember crystal recipe
event.custom({
  "type": "embers:alchemy",
  "aspects": [
    {
      "tag": "embers:aspectus/copper"
    },
    {
      "tag": "embers:aspectus/lead"
    },
    {
      "tag": "embers:aspectus/iron"
    },
    {
      "tag": "embers:aspectus/dawnstone"
    }
  ],
  "inputs": [
    {
      "item": "projecte:medium_covalence_dust"
    },
    {
      "item": "projecte:medium_covalence_dust"
    },
    {
      "item": "embers:dawnstone_plate"
    },
    {
      "item": "embers:ember_crystal"
    }
  ],
  "output": {
    "item": "kubejs:emc_ember_crystal"
  },
  "tablet": {
    "item": "embers:ember_crystal_cluster"
  }
})

// Quantised Grains of Infinity
event.replaceInput(
  { input: 'enderio:grains_of_infinity' },
  'enderio:grains_of_infinity',
  '#forge:dusts/grains_of_infinity'
)

// Quantised Andesite Alloy
event.replaceInput(
  { input: 'create:andesite_alloy' },
  'create:andesite_alloy',
  '#kubejs:andesite_alloys'
)

// Quantised Andesite recipe
event.custom({
  "type": "createdieselgenerators:basin_fermenting",
  "ingredients": [
    {
      "item": "create:andesite_alloy"
    },
	{
      "item": "projecte:medium_covalence_dust"
    },
    {
      "fluid": "embers:molten_iron",
      "amount": 1000
    }
  ],
  "heatRequirement": "heated",
  "processingTime": 400,
  "results": [
    {
      "item": "kubejs:emc_andesite_alloy"
    }
  ]
})

// Quantised Silicon recipe
event.custom({
  "type": "ae2:transform",
  "circumstance": {
    "type": "explosion"
  },
  "ingredients": [
    {
      "item": "ae2:cell_component_16k"
    },
    {
      "item": "expatternprovider:silicon_block"
    },
    {
      "item": "projecte:high_covalence_dust"
    }
  ],
  "result": {
    "count": 1,
    "item": "kubejs:emc_silicon"
  }
})

// PRISMA QUANTISED ----------------------------------------------------------------------------
// Alchemical Calx
event.replaceInput(
  { input: 'malum:alchemical_calx' },
  'malum:alchemical_calx',
  '#kubejs:alchemical_calx'
)

// Blank Slate
event.replaceInput(
  { input: 'bloodmagic:blankslate' },
  'bloodmagic:blankslate',
  '#kubejs:blank_slate'
)

// Calc Processor
event.replaceInput(
  { input: 'ae2:calculation_processor' },
  'ae2:calculation_processor',
  '#kubejs:calculation_processor'
)

// Copper Wire
event.replaceInput(
  { input: 'create_new_age:copper_wire' },
  'create_new_age:copper_wire',
  '#kubejs:copper_wire'
)

// Cyanite
event.replaceInput(
  { input: 'bigreactors:cyanite_ingot' },
  'bigreactors:cyanite_ingot',
  '#forge:ingots/cyanite'
)

event.replaceInput(
  { input: 'projecte:dark_matter' },
  'projecte:dark_matter',
  '#kubejs:dark_matter'
)

// Engineering Processor
event.replaceInput(
  { input: 'ae2:engineering_processor' },
  'ae2:engineering_processor',
  '#kubejs:engineering_processor'
)

// Hex Ash
event.replaceInput(
  { input: 'malum:hex_ash' },
  'malum:hex_ash',
  '#kubejs:hex_ash'
)

// Fluix Crystal
event.replaceInput(
  { input: 'ae2:fluix_crystal' },
  'ae2:fluix_crystal',
  '#forge:gems/fluix'
)

// Logic Processor
event.replaceInput(
  { input: 'ae2:logic_processor' },
  'ae2:logic_processor',
  '#kubejs:logic_processor'
)

// Mana Pearls
event.replaceInput({ input: 'botania:mana_pearl' }, 'botania:mana_pearl', '#kubejs:mana_pearl')
event.replaceInput({ input: 'botania:manasteel_ingot' }, 'botania:manasteel_ingot', '#botania:manasteel_ingots')
event.replaceInput({ input: 'botania:mana_powder' }, 'botania:mana_powder', '#botania:mana_dusts')
event.replaceInput({ input: 'botania:mana_diamond' }, 'botania:mana_diamond', '#botania:mana_diamond_gems')

// Sourcegem
event.replaceInput({ input: 'ars_nouveau:mana_gem' }, 'ars_nouveau:mana_gem', '#forge:gems/source')

// Iron/Steel Mech component
event.replaceInput({ input: 'immersiveengineering:component_iron' }, 'immersiveengineering:component_iron', '#kubejs:iron_mechanical_component')
event.replaceInput({ input: 'immersiveengineering:component_steel' }, 'immersiveengineering:component_steel', '#kubejs:steel_mechanical_component')

// Infused Alloy
event.replaceInput(
  { input: 'mekanism:alloy_infused' },
  'mekanism:alloy_infused',
  '#mekanism:alloys/infused'
)

// Polished rose quartz
event.replaceInput({ input: 'create:polished_rose_quartz' }, 'create:polished_rose_quartz', '#kubejs:rose_quartz')

// Red Matter
event.replaceInput({ input: 'projecte:red_matter' }, 'projecte:red_matter', '#kubejs:red_matter')

// Wilden
event.replaceInput({ input: 'ars_nouveau:wilden_horn' }, 'ars_nouveau:wilden_horn', '#kubejs:wilden_horn')
event.replaceInput({ input: 'ars_nouveau:wilden_spike' }, 'ars_nouveau:wilden_spike', '#kubejs:wilden_spike')
event.replaceInput({ input: 'ars_nouveau:wilden_wing' }, 'ars_nouveau:wilden_wing', '#kubejs:wilden_wing')

// Remove unwanted alt recipes for quantised items
event.remove({output: 'kubejs:emc_invar_ingot', type: 'immersiveengineering:alloy'})
event.remove({output: 'kubejs:emc_invar_ingot', type: 'immersiveengineering:arc_furnace'})

})