// Kubejs scripts for extended crafting recipes

ServerEvents.recipes(event => {

// Helper Function for EnderIO alloy smelting
function eioAlloySmelt(output, in1, quant1, in2, quant2, in3, quant3, energy, exp) {
	event.custom({
	"type": "enderio:alloy_smelting",
	"energy": energy,
	"experience": exp,
	"inputs": [
		{
		"count": quant1,
		"ingredient": {
        "item": in1
		}
	  },
	  {
		"count": quant2,
		"ingredient": {
			"item": in2
		}
	  },
	  {
		"count": quant3,
		"ingredient": {
			"item": in3
		}
	  }
	],
	"result": {
		"item": output
	}
  })
}	

//Implement prismatter
event.recipes.extendedcrafting.combination("kubejs:prismatter", '#kubejs:red_matter',
['thermal:enderium_gear', 'ae2:cell_component_16k','pneumaticcraft:security_upgrade','enderio:octadic_capacitor','immersiveengineering:heavy_engineering','create:sturdy_sheet','create_new_age:copper_circuit','mekanism:hdpe_sheet','extendedcrafting:advanced_component','ars_nouveau:thread_magic_capacity','bloodmagic:sacrificerune','botania:rune_winter','malum:spirit_fabric','embers:dawnstone_aspectus'], 
 20000000).powerRate(50000);
 
 // Remove standard crafting for ext alloys
event.remove({ output: 'extendedcrafting:black_iron_ingot'})
event.remove({ output: 'extendedcrafting:redstone_ingot'})
event.remove({ output: 'extendedcrafting:ender_ingot'})

event.remove({ output: 'extendedcrafting:luminessence'})
event.remove({ output: 'extendedcrafting:black_iron_slate'})

// No Default part recipes
event.remove({ output: 'extendedcrafting:basic_component'})
event.remove({ output: 'extendedcrafting:advanced_component'})
event.remove({ output: 'extendedcrafting:elite_component'})
event.remove({ output: 'extendedcrafting:ultimate_component'})
event.remove({ output: 'extendedcrafting:redstone_component'})
event.remove({ output: 'extendedcrafting:enhanced_redstone_component'})
event.remove({ output: 'extendedcrafting:ender_component'})
event.remove({ output: 'extendedcrafting:enhanced_ender_component'})
event.remove({ output: 'extendedcrafting:crystaltine_component'})
event.remove({ output: 'extendedcrafting:the_ultimate_component'})

event.remove({ output: 'extendedcrafting:basic_catalyst'})
event.remove({ output: 'extendedcrafting:advanced_catalyst'})
event.remove({ output: 'extendedcrafting:elite_catalyst'})
event.remove({ output: 'extendedcrafting:ultimate_catalyst'})
event.remove({ output: 'extendedcrafting:redstone_catalyst'})
event.remove({ output: 'extendedcrafting:enhanced_redstone_catalyst'})
event.remove({ output: 'extendedcrafting:ender_catalyst'})
event.remove({ output: 'extendedcrafting:enhanced_ender_catalyst'})
event.remove({ output: 'extendedcrafting:crystaltine_catalyst'})
event.remove({ output: 'extendedcrafting:the_ultimate_catalyst'})

// No Tables
event.remove({ output: 'extendedcrafting:basic_table'})
event.remove({ output: 'extendedcrafting:advanced_table'})
event.remove({ output: 'extendedcrafting:elite_table'})
event.remove({ output: 'extendedcrafting:ultimate_table'})
event.remove({ output: 'extendedcrafting:crafting_core'})
event.remove({ output: 'extendedcrafting:pedestal'})
event.remove({ output: 'extendedcrafting:compressor'})

event.remove({ output: 'extendedcrafting:frame'})

// PackagedEX
event.remove({ output: 'packagedexcrafting:basic_crafter'})
event.remove({ output: 'packagedexcrafting:advanced_crafter'})
event.remove({ output: 'packagedexcrafting:elite_crafter'})
event.remove({ output: 'packagedexcrafting:ultimate_crafter'})
event.remove({ output: 'packagedexcrafting:combination_crafter'})
event.remove({ output: 'packagedexcrafting:ender_crafter'})
event.remove({ output: 'packagedexcrafting:flux_crafter'})

// Luminessence 
event.recipes.ars_nouveau.imbuement(
        '#forge:gems/source', // input item
        'extendedcrafting:luminessence', // output
        4000, // source cost
        ['botania:pixie_dust', 'bloodmagic:defaultcrystal', 'embers:glimmer_crystal', 'malum:iridescent_ether']
)

// Dark Matter Alloy
event.custom({
  "type": "enderio:alloy_smelting",
  "energy": 10000,
  "experience": 0.77,
  "inputs": [
    {
      "count": 1,
      "ingredient": {
        "tag": "kubejs:dark_matter"
      }
    },
    {
      "count": 1,
      "ingredient": {
        "tag": "forge:ingots/dark_steel"
      }
    },
    {
      "count": 1,
      "ingredient": {
        "item": "mekanism:ingot_refined_obsidian"
      }
    }
  ],
  "result": {
    "item": "extendedcrafting:black_iron_ingot"
  }
})

// Block decompressing
event.shapeless(
  Item.of('9x extendedcrafting:black_iron_ingot'),
  [
    'extendedcrafting:black_iron_block'
  ]
)

// Luminessence
event.shapeless(
  Item.of('2x kubejs:pint_luminessence'),
  [
    'extendedcrafting:luminessence'
  ]
)

event.shapeless(
  Item.of('extendedcrafting:luminessence'),
  [
    'kubejs:pint_luminessence',
	'kubejs:pint_luminessence'
  ]
)

// Dark Alloy Plate
event.recipes.thermal.press('extendedcrafting:black_iron_slate', ['extendedcrafting:black_iron_ingot']).energy(24000)

// Basic and Advanced components
eioAlloySmelt('extendedcrafting:basic_component', 'extendedcrafting:black_iron_slate', 1, 'kubejs:pint_luminessence', 1, 'projecte:dark_matter', 1, 20000, 0.3)
eioAlloySmelt('extendedcrafting:basic_component', 'extendedcrafting:black_iron_slate', 1, 'kubejs:pint_luminessence', 1, 'kubejs:emc_dark_matter', 1, 20000, 0.3)
eioAlloySmelt('extendedcrafting:advanced_component', 'extendedcrafting:black_iron_slate', 1, 'extendedcrafting:luminessence', 1, 'projecte:red_matter', 1, 20000, 0.3)
eioAlloySmelt('extendedcrafting:advanced_component', 'extendedcrafting:black_iron_slate', 1, 'extendedcrafting:luminessence', 1, 'kubejs:emc_red_matter', 1, 20000, 0.3)

// Extended Crafter
event.shaped(
  Item.of('mbd2:extended_crafter'),
  [
    'ABA',
    'BCB',
    'ABA'
  ],
  {
    A: 'minecraft:crafting_table',
    B: 'extendedcrafting:basic_component',
	C: 'extendedcrafting:black_iron_block'
  }
)

// Elite Comps
event.custom({
  "type": "enderio:alloy_smelting",
  "energy": 40000,
  "experience": 1.2,
  "inputs": [
    {
      "count": 1,
      "ingredient": {
        "item": "extendedcrafting:black_iron_slate"
      }
    },
    {
      "count": 1,
      "ingredient": {
        "item": "extendedcrafting:luminessence_block"
      }
    },
    {
      "count": 1,
      "ingredient": {
        "tag": "kubejs:prismatter"
      }
    }
  ],
  "result": {
    "item": "extendedcrafting:elite_component"
  }
})

// No crystaltine
event.remove({output: 'extendedcrafting:crystaltine_ingot'})

// Black iron compressing
event.shapeless(
  Item.of('extendedcrafting:black_iron_ingot'),
  [
    'extendedcrafting:black_iron_nugget',
    'extendedcrafting:black_iron_nugget',
    'extendedcrafting:black_iron_nugget',
	'extendedcrafting:black_iron_nugget',
	'extendedcrafting:black_iron_nugget',
	'extendedcrafting:black_iron_nugget',
	'extendedcrafting:black_iron_nugget',
	'extendedcrafting:black_iron_nugget',
	'extendedcrafting:black_iron_nugget'
  ]
)

// Return relevant items
event.shapeless(
  Item.of('mbd2:extended_crafter'),
  [
    'extendedcrafting:basic_table'
  ]
)

event.shapeless(
  Item.of('kubejs:advanced_core'),
  [
    'extendedcrafting:advanced_table'
  ]
)

event.shapeless(
  Item.of('kubejs:prismatic_core'),
  [
    'extendedcrafting:elite_table'
  ]
)

})