ServerEvents.recipes(event => {

	event.recipes.create.sequenced_assembly([
		'kubejs:quartz_timer_circuit'
	], 'tfmg:hardened_planks_slab', [
		event.recipes.createDeploying('kubejs:incomplete_quartz_timer_circuit', ['kubejs:incomplete_quartz_timer_circuit', 'powergrid:wire']),
		event.recipes.createDeploying('kubejs:incomplete_quartz_timer_circuit', ['kubejs:incomplete_quartz_timer_circuit', 'minecraft:quartz'])
	]).transitionalItem('kubejs:incomplete_quartz_timer_circuit').loops(1)


	event.recipes.createSequencedAssembly([
		'kubejs:basic_machine_block'
	], 'kubejs:incomplete_basic_machine_block', [
		event.recipes.createDeploying('kubejs:incomplete_basic_machine_block', ['kubejs:incomplete_basic_machine_block', 'kubejs:quartz_timer_circuit']),
		event.recipes.createDeploying('kubejs:incomplete_basic_machine_block', ['kubejs:incomplete_basic_machine_block', 'tfmg:heavy_plate']),
		event.recipes.createDeploying('kubejs:incomplete_basic_machine_block', ['kubejs:incomplete_basic_machine_block', 'kubejs:fluorescent_tube']),
	]).transitionalItem('kubejs:incomplete_basic_machine_block').loops(1)


	event.recipes.create.haunting('kubejs:soul_fuse', 'kubejs:empty_fuse')

	event.remove({ output: 'tfmg:steel_mechanism' })
	event.recipes.createSequencedAssembly([
		Item.of('tfmg:steel_mechanism').withChance(130.0), // this is the item that will appear in JEI as the result
		Item.of('tfmg:heavy_sheet').withChance(8.0), // the rest of these items will be part of the scrap
		Item.of('tfmg:steel_cogwheel').withChance(8.0),
	], 'tfmg:heavy_plate', [
		event.recipes.createDeploying('tfmg:unfinished_steel_mechanism', ['tfmg:unfinished_steel_mechanism', 'tfmg:steel_cogwheel']),
		event.recipes.createDeploying('tfmg:unfinished_steel_mechanism', ['tfmg:unfinished_steel_mechanism', 'tfmg:rubber_sheet']),
		event.recipes.createDeploying('tfmg:unfinished_steel_mechanism', ['tfmg:unfinished_steel_mechanism', 'tfmg:steel_ingot']),
		event.recipes.createDeploying('tfmg:unfinished_steel_mechanism', ['tfmg:unfinished_steel_mechanism', 'kubejs:fluorescent_tube']),
		event.recipes.createDeploying('tfmg:unfinished_steel_mechanism', ['tfmg:unfinished_steel_mechanism', 'tfmg:screw']),
		event.recipes.createDeploying('tfmg:unfinished_steel_mechanism', ['tfmg:unfinished_steel_mechanism', 'tfmg:screwdriver'])
	]).transitionalItem('tfmg:unfinished_steel_mechanism').loops(2)

	event.remove({id: 'powergrid:sequenced_assembly/battery'})
	event.recipes.createSequencedAssembly([
		Item.of('powergrid:battery').withChance(130.0), // this is the item that will appear in JEI as the result
		Item.of('create:copper_sheet').withChance(8.0), // the rest of these items will be part of the scrap
		Item.of('powergrid:zinc_sheet').withChance(8.0),
		Item.of('powergrid:conductive_casing').withChance(8.0)
	], 'powergrid:conductive_casing', [
		event.recipes.createDeploying('powergrid:incomplete_battery', ['powergrid:incomplete_battery', 'tfmg:lithium_ingot']),
		event.recipes.createDeploying('powergrid:incomplete_battery', ['powergrid:incomplete_battery', 'create:copper_sheet']),
		event.recipes.createFilling('powergrid:incomplete_battery', ['powergrid:incomplete_battery', Fluid.of('tfmg:sulfuric_acid', 250)])
	]).transitionalItem('powergrid:incomplete_battery').loops(3)

	event.recipes.createSequencedAssembly([
		'kubejs:industrial_machine_block'
	],
		'kubejs:incomplete_industrial_machine_block',
		[
			event.recipes.createDeploying('kubejs:incomplete_industrial_machine_block', ['kubejs:incomplete_industrial_machine_block', 'kubejs:soul_fuse']),
			event.recipes.createDeploying('kubejs:incomplete_industrial_machine_block', ['kubejs:incomplete_industrial_machine_block', 'tfmg:steel_mechanism']),
			event.recipes.createDeploying('kubejs:incomplete_industrial_machine_block', ['kubejs:incomplete_industrial_machine_block', 'powergrid:magnet']),
		]).transitionalItem('kubejs:incomplete_industrial_machine_block').loops(1)


	event.recipes.create.sequenced_assembly([
		'endrem:evil_eye'
	], 'ae2:quantum_entangled_singularity', [
		event.recipes.createFilling('ae2:quantum_entangled_singularity', ['ae2:quantum_entangled_singularity', Fluid.of('supplementaries:lumisene', 1000)])
	]).transitionalItem('ae2:quantum_entangled_singularity',).loops(100)



	event.recipes.create.sequenced_assembly([
		'endrem:cursed_eye'
	], 'ae2:quantum_entangled_singularity', [
		event.recipes.createFilling('ae2:quantum_entangled_singularity', ['ae2:quantum_entangled_singularity', Fluid.of('create_central_kitchen:dragon_breath', 1000)])
	]).transitionalItem('ae2:quantum_entangled_singularity',).loops(100)


	event.recipes.create.sequenced_assembly([
		'endrem:nether_eye'
	], 'supplementaries:cannonball', [
		event.recipes.createDeploying('supplementaries:cannonball', ['supplementaries:cannonball', 'kubejs:hot_steel']),
		event.recipes.createFilling('supplementaries:cannonball', ['supplementaries:cannonball', Fluid.of('brewinandchewin:beer', 1000)]),
		event.recipes.createPressing('supplementaries:cannonball', 'supplementaries:cannonball')
	]).transitionalItem('supplementaries:cannonball',).loops(100)

	event.recipes.create.sequenced_assembly([
		'endrem:cold_eye'
	], 'minecraft:snowball', [
		event.recipes.createDeploying('minecraft:snowball', ['minecraft:snowball', 'thermal:blizz_rod'])
	]).transitionalItem('minecraft:snowball',).loops(250)

	event.recipes.create.sequenced_assembly([
		'kubejs:cobblestone_bucket'
	], 'minecraft:bucket', [
		event.recipes.createDeploying('minecraft:bucket', ['minecraft:bucket', 'minecraft:cobblestone']),
	]).transitionalItem('minecraft:bucket',).loops(10)
	event.smelting('minecraft:lava_bucket', 'kubejs:cobblestone_bucket')

})

ItemEvents.firstRightClicked(event => {
	const { player, hand } = event

	if (hand !== 'MAIN_HAND') return
	const mainItem = player.mainHandItem
	const offItem = player.offHandItem

	if (!mainItem.nbt || !offItem.nbt || !mainItem.nbt.Amount || !offItem.nbt.Amount || !/tfmg.*spool/.test(mainItem.id) || !/tfmg.*spool/.test(offItem.id) || mainItem.nbt.Amount > 1000) return

	const mainAmount = mainItem.nbt.Amount
	const offAmount = offItem.nbt.Amount

	const totalAmount = mainAmount + offAmount

	if (totalAmount > 1000) {
		offItem.nbt.Amount = totalAmount - 1000
		mainItem.nbt.Amount = 1000
	} else {
		mainItem.nbt.Amount = totalAmount
		player.offHandItem = Item.of('tfmg:empty_spool')
	}
})	