// Kubejs scripts for ProjectE items/interactions

ServerEvents.recipes(event => {

// Replace watch of time in gem leggings
event.replaceInput(
  { output: 'projecte:gem_leggings' },
  'projecte:watch_of_flowing_time',
  'minecraft:clock'
)

// Removal of philosopher stone crafting transmutations
event.remove({ output: 'minecraft:ender_pearl', input: 'projecte:philosophers_stone' })
event.remove({ output: 'minecraft:coal', input: 'projecte:philosophers_stone' })
event.remove({ output: 'minecraft:charcoal', input: 'projecte:philosophers_stone' })
event.remove({ output: 'minecraft:emerald', input: 'projecte:philosophers_stone' })
event.remove({ output: 'minecraft:iron_ingot', input: 'projecte:philosophers_stone' })
event.remove({ output: 'minecraft:gold_ingot', input: 'projecte:philosophers_stone' })
event.remove({ output: 'minecraft:diamond', input: 'projecte:philosophers_stone' })

// Remove default recipes for projexpanded collectors, relays and flowers
event.remove({ output: 'projecte:collector_mk1'})
event.remove({ output: 'projecte:collector_mk2'})
event.remove({ output: 'projecte:collector_mk3'})
event.remove({ output: 'projecte:relay_mk1'})
event.remove({ output: 'projecte:relay_mk2'})
event.remove({ output: 'projecte:relay_mk3'})

event.remove({ output: '#projectexpansion:collector'})
event.remove({ output: '#projectexpansion:relay'})
event.remove({ output: '#projectexpansion:power_flower'})
event.remove({ output: '#projectexpansion:emc_link'})

event.remove({ output: 'projecte:watch_of_flowing_time'})

// Adjust covalence dust outputs
event.remove({ output: 'projecte:low_covalence_dust'})
event.remove({ output: 'projecte:medium_covalence_dust'})
event.remove({ output: 'projecte:high_covalence_dust'})

// Disable default matter recipes
event.remove({ output: 'projecte:dark_matter'})
event.remove({ output: 'projecte:red_matter'})
event.remove({ output: '#projectexpansion:matter'})
event.remove({ output: '#projectexpansion:fuel'})

event.shapeless(
  Item.of('projecte:low_covalence_dust'),
  [
    'minecraft:charcoal',
    'minecraft:cobblestone',
	'minecraft:cobblestone',
	'minecraft:cobblestone',
	'minecraft:cobblestone',
	'minecraft:cobblestone',
	'minecraft:cobblestone',
	'minecraft:cobblestone',
	'minecraft:cobblestone'
  ]
)

event.shapeless(
  Item.of('projecte:medium_covalence_dust'),
  [
    'minecraft:iron_ingot',
    'minecraft:redstone'
  ]
)

event.shapeless(
  Item.of('projecte:high_covalence_dust'),
  [
    'minecraft:diamond',
    'minecraft:coal'
  ]
)

// Dark matter
event.shaped(
  Item.of('projecte:dark_matter'),
  [
    'ABA',
    'ACA',
    'ADA'
  ],
  {
    A: 'projecte:aeternalis_fuel',
    B: 'ae2:singularity',
    C: 'minecraft:diamond_block',
	D: 'projecte:philosophers_stone'
  }
).keepIngredient('projecte:philosophers_stone')

// Imp recipes for projexpanded collectors
event.shaped(
  Item.of('projectexpansion:basic_power_flower'),
  [
    'ABA',
    'CDC',
    'ABA'
  ],
  {
    A: 'minecraft:stone',
    B: 'projecte:low_covalence_dust',
    C: 'minecraft:iron_ingot',
	D: 'minecraft:furnace'
  }
)

event.shapeless(Item.of('projectexpansion:basic_power_flower'), ['projectexpansion:basic_emc_link'])
event.shapeless(Item.of('projectexpansion:basic_emc_link'), ['projectexpansion:basic_power_flower'])

// Tier 2 flower and link
event.shaped(
  Item.of('projectexpansion:dark_power_flower'),
  [
    'ABA',
    'CDC',
    'ABA'
  ],
  {
    A: 'embers:caminite_bricks',
    B: 'projecte:medium_covalence_dust',
    C: 'minecraft:gold_ingot',
	D: 'projectexpansion:basic_power_flower'
  }
)

event.shapeless(Item.of('projectexpansion:dark_power_flower'), ['projectexpansion:dark_emc_link'])
event.shapeless(Item.of('projectexpansion:dark_emc_link'), ['projectexpansion:dark_power_flower'])

// Tier 3 flower and link

event.shaped(
  Item.of('projectexpansion:red_power_flower'),
  [
    'ABA',
    'CDC',
    'ABA'
  ],
  {
    A: 'ae2:sky_stone_brick',
    B: 'projecte:high_covalence_dust',
    C: 'minecraft:diamond',
	D: 'projectexpansion:dark_power_flower'
  }
)

event.shapeless(Item.of('projectexpansion:red_power_flower'), ['projectexpansion:red_emc_link'])
event.shapeless(Item.of('projectexpansion:red_emc_link'), ['projectexpansion:red_power_flower'])

// Tier 4 flower and link
event.shaped(
  Item.of('projectexpansion:magenta_power_flower'),
  [
    'ABA',
    'CDC',
    'ABA'
  ],
  {
    A: 'projecte:aeternalis_fuel_block',
    B: '#kubejs:engineering_processor',
    C: '#kubejs:dark_matter',
	D: 'projectexpansion:red_power_flower'
  }
)

event.shapeless(Item.of('projectexpansion:magenta_power_flower'), ['projectexpansion:magenta_emc_link'])
event.shapeless(Item.of('projectexpansion:magenta_emc_link'), ['projectexpansion:magenta_power_flower'])

// T5 flower and link
event.shaped(
  Item.of('projectexpansion:pink_power_flower'),
  [
    'ABA',
    'CDC',
    'ABA'
  ],
  {
    A: 'minecraft:purpur_block',
    B: 'extendedcrafting:luminessence',
    C: '#kubejs:red_matter',
	D: 'projectexpansion:magenta_power_flower'
  }
)

event.shapeless(Item.of('projectexpansion:pink_power_flower'), ['projectexpansion:pink_emc_link'])
event.shapeless(Item.of('projectexpansion:pink_emc_link'), ['projectexpansion:pink_power_flower'])

// T6 Power Flower
event.shaped(
  Item.of('projectexpansion:purple_power_flower'),
  [
    'ABA',
    'CDC',
    'ABA'
  ],
  {
    A: 'fluxnetworks:flux_block',
    B: 'minecraft:netherite_scrap',
    C: '#kubejs:prismatter',
	D: 'projectexpansion:pink_power_flower'
  }
)

event.shapeless(Item.of('projectexpansion:purple_power_flower'), ['projectexpansion:purple_emc_link'])
event.shapeless(Item.of('projectexpansion:purple_emc_link'), ['projectexpansion:purple_power_flower'])

// T7 Power Flower
event.shaped(
  Item.of('projectexpansion:violet_power_flower'),
  [
    'ABA',
    'CDC',
    'ABA'
  ],
  {
    A: 'draconicevolution:draconium_block',
    B: 'kubejs:prisma_dust',
    C: 'kubejs:transcendent',
	D: 'projectexpansion:purple_power_flower'
  }
)

event.shapeless(Item.of('projectexpansion:violet_power_flower'), ['projectexpansion:violet_emc_link'])
event.shapeless(Item.of('projectexpansion:violet_emc_link'), ['projectexpansion:violet_power_flower'])

// Dark matter skip
event.recipes.extendedcrafting.shaped_table("projecte:dark_matter", 
	['aaa', 
	 'aba', 
	 'aaa'
	 ], 
	{
		a: 'projecte:aeternalis_fuel',
		b: 'minecraft:diamond_block'
	}
).tier(1);

// Red Matter Tool changes
event.remove({output: 'projecte:rm_sword'})
event.remove({output: 'projecte:rm_pick'})
event.remove({output: 'projecte:rm_axe'})
event.remove({output: 'projecte:rm_shovel'})
event.remove({output: 'projecte:rm_hoe'})
event.remove({output: 'projecte:rm_shears'})
event.remove({output: 'projecte:rm_hammer'})

event.shaped(
  Item.of('projecte:rm_sword'),
  [
    ' a ',
    ' a ',
    'bcb'
  ],
  {
    a: '#kubejs:prismatter',
    b: '#kubejs:red_matter',
    c: 'projecte:dm_sword'
  }
)

event.shaped(
  Item.of('projecte:rm_pick'),
  [
    'aaa',
    ' c ',
    ' b '
  ],
  {
    a: '#kubejs:prismatter',
    b: '#kubejs:red_matter',
    c: 'projecte:dm_pick'
  }
)

event.shaped(
  Item.of('projecte:rm_axe'),
  [
    'aa ',
    'ac ',
    ' b '
  ],
  {
    a: '#kubejs:prismatter',
    b: '#kubejs:red_matter',
    c: 'projecte:dm_axe'
  }
)

event.shaped(
  Item.of('projecte:rm_shovel'),
  [
    ' a ',
    ' c ',
    ' b '
  ],
  {
    a: '#kubejs:prismatter',
    b: '#kubejs:red_matter',
    c: 'projecte:dm_shovel'
  }
)

event.shaped(
  Item.of('projecte:rm_hoe'),
  [
    'aa ',
    ' c ',
    ' b '
  ],
  {
    a: '#kubejs:prismatter',
    b: '#kubejs:red_matter',
    c: 'projecte:dm_hoe'
  }
)

event.shaped(
  Item.of('projecte:rm_shears'),
  [
    '  a',
    ' c ',
    'b  '
  ],
  {
    a: '#kubejs:prismatter',
    b: '#kubejs:red_matter',
    c: 'projecte:dm_shears'
  }
)

event.shaped(
  Item.of('projecte:rm_hammer'),
  [
    'aba',
    'aca',
    ' b '
  ],
  {
    a: '#kubejs:prismatter',
    b: '#kubejs:red_matter',
    c: 'projecte:dm_hammer'
  }
)

})

ServerEvents.tags('item', event => {
	
// Remove collector fuel upcycling
event.removeAll('projecte:collector_fuel')

})