ServerEvents.recipes(event => {

	event.recipes.create.sequenced_assembly([
        'immersiveengineering:component_electronic'
     ], 'immersiveengineering:slab_treated_wood_horizontal', [
        event.recipes.createDeploying('kubejs:incomplete_component_electronic', ['kubejs:incomplete_component_electronic', 'tfmg:copper_wire']),
        event.recipes.createDeploying('kubejs:incomplete_component_electronic', ['kubejs:incomplete_component_electronic', 'minecraft:quartz'])
     ]).transitionalItem('kubejs:incomplete_component_electronic').loops(1)


    event.remove({id: 'immersiveengineering:blueprint/component_electronic'})
	event.remove({id: 'immersiveengineering:crafting/light_engineering'})
	event.recipes.createSequencedAssembly([
		'immersiveengineering:light_engineering'
	   ], 'kubejs:light_engineering_empty', [
		event.recipes.createDeploying('kubejs:light_engineering_empty', ['kubejs:light_engineering_empty', 'immersiveengineering:component_electronic']),
		event.recipes.createDeploying('kubejs:light_engineering_empty', ['kubejs:light_engineering_empty', 'tfmg:heavy_plate']),
		event.recipes.createDeploying('kubejs:light_engineering_empty', ['kubejs:light_engineering_empty', 'kubejs:fluorescent_tube']),
	]).transitionalItem('kubejs:light_engineering_empty').loops(1)


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

	event.remove({id: 'immersiveengineering:blueprint/component_electronic_adv'})
	event.remove({id: 'immersiveengineering:crafting/heavy_engineering'})
	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.recipes.createSequencedAssembly([
		'immersiveengineering:heavy_engineering'
	],  'kubejs:heavy_engineering_empty', [
		event.recipes.createDeploying('kubejs:light_engineering_empty', ['kubejs:light_engineering_empty', 'kubejs:soul_fuse']),
		event.recipes.createDeploying('kubejs:light_engineering_empty', ['kubejs:light_engineering_empty', 'tfmg:steel_mechanism']),
		event.recipes.createDeploying('kubejs:light_engineering_empty', ['kubejs:light_engineering_empty', 'tfmg:magnet']),
	]).transitionalItem('kubejs:heavy_engineering_empty').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')
    }
})