// priority: 0

onEvent('recipes', event => {
	//removals
	removeRecipeByID(event, [
		//algal andesite
        CR("crafting/materials/andesite_alloy"),
        CR("crafting/materials/andesite_alloy_from_zinc"),
		CR('mixing/andesite_alloy'),
		CR('mixing/andesite_alloy_from_zinc'),
		TC('compat/create/andesite_alloy_zinc'),
		TC('compat/create/andesite_alloy_iron'),

		//blaze burner
		CR("crafting/kinetics/empty_blaze_burner"),

		//wrench
		CR("crafting/kinetics/wrench"),

		//electron tube
		CR('compat/ae2/milling/sky_stone_block'),
		CR('compat/ae2/milling/nether_quartz'),
		CR('compat/ae2/milling/certus_quartz'),
		CR('crafting/materials/electron_tube'),
		CR('crafting/materials/rose_quartz'),
		TC('smeltery/casting/obsidian/block'),
		AE2('misc/seeds_certus'),
		AE2('misc/seeds_fluix'),
		AE2('misc/seeds_nether'),
		TC('smeltery/alloys/molten_obsidian'),
		/tconstruct:smeltery\/melting\/obsidian\/.*/,
		TC('smeltery/melting/diamond/enchanting_table'),

		//andesite age
		MC('diorite'),
		MC('granite'),
		MC('andesite'),

		//copper age
		// TC("smeltery/casting/seared/smeltery_controller"),
		// TC("smeltery/melting/copper/smeltery_controller"),
		AE2('misc/meteors_sky_compass'),

		//brass age
		CR("sequenced_assembly/precision_mechanism"),
		CR("sandpaper_polishing/rose_quartz"),
		CR("sandpaper_polishing/rose_quartz_using_deployer"),

		//zinc age
		TC('smeltery/casting/scorched/foundry_controller'),
		CR("mechanical_crafting/crushing_wheel"),
		TC("smeltery/entity_melting/ender"),
		/tconstruct:smeltery\/melting\/ender\/.*/,
		/tconstruct:smeltery\/casting\/ender\/.*/,
		/tconstruct:smeltery\/entity_melting\/heads\/ender.*/,
		/appliedenergistics2:tools\/paintballs.*/,
    ])

	removeRecipeByOutput(event, [
		//zinc age
		AE2("singularity"),
		AE2("matter_ball"),
		AE2('inscriber'),
		AE2('vibration_chamber'),
		CR('chromatic_compound'),

		//fluix age
		AE2("controller"),

		//digital age
		IF('machine_frame_pity'),

		//misc
		CR("shadow_steel_casing")
	])
	
	event.remove({ type: AE2('inscriber') })



	//algal andesite
	event.smelting(KJ('algal_brick'), KJ('algal_blend')).xp(0).cookingTime(120)

	event.shaped(Item.of(KJ('algal_blend'), 2), [
		'SS',
		'AA'
	], {
		A: MC('clay_ball'),
		S: MC('kelp')
	})
	event.shaped(Item.of(KJ('algal_blend'), 2), [
		'AA',
		'SS'
	], {
		A: MC('clay_ball'),
		S: MC('kelp')
	})
	event.shaped(Item.of(CR('andesite_alloy'), 2), [
		'AAA',
		'PPP',
		'SSS'
	], {
		A: MC('andesite'),
		P: F('#nuggets/zinc'),
		S: KJ('algal_brick')
	})

	event.recipes.createMixing(Item.of(KJ('algal_blend'), 2), [MC('clay_ball'), MC('kelp')])
	event.recipes.createMixing(Item.of(CR('andesite_alloy'), 2), [MC('andesite'), F('#nuggets/zinc'), KJ('algal_brick')])



	//brown toolbox
    event.replaceInput({ output: CR(`brown_toolbox`) }, CR("cogwheel"), F("#cogwheels"))



	//blaze burner
    event.shaped(CR("empty_blaze_burner"), [
        ' A ',
        'ABA',
        ' A '
    ], {
        A: F('#rods/iron'),
        B: MC('netherrack'),
    })



	//iron to zinc in first machines
    event.replaceInput({ id: CR("crafting/kinetics/chute") }, F("#plates/iron"), F("#plates/zinc"))
    event.replaceInput({ id: CR("crafting/kinetics/propeller") }, F("#plates/iron"), F("#plates/zinc"))



	//wrench
	event.smithing(CR("wrench"), Item.of(MAT('wrench')).ignoreNBT(), F('#cogwheels'))



	//casings
	let tweak_casing = (id, mats) => {
		event.remove({ output: id })
		event.shapeless(id, mats)
		event.recipes.createDeploying(id, mats)
	}

	tweak_casing(CR('andesite_casing'), [MC('#logs/stripped'), CR('andesite_alloy')])
	tweak_casing(CR('copper_casing'), [MC('#logs/stripped'), F('#plates/copper')])
	tweak_casing(CR('brass_casing'), [MC('#logs/stripped'), F('#plates/brass')])
	tweak_casing(RTB(`machine_frame`), [MC('#logs/stripped'), F('#plates/zinc')])
	tweak_casing(KJ(`fluix_casing`), [MC('#logs/stripped'), F('#gems/fluix')])
	tweak_casing(CR(`refined_radiance_casing`), [MC('#logs/stripped'), KJ('radiant_sheet')])



	//electron tube
	event.recipes.createFilling(CR("electron_tube"), [CR('polished_rose_quartz'), Fluid.of(TC('molten_iron'), 16)])

	let redstone = MC('redstone')
	event.shapeless(CR('rose_quartz'), [[MC('quartz'), AE2('certus_quartz_crystal'), AE2('charged_certus_quartz_crystal')], redstone, redstone, redstone, redstone])

	event.recipes.createMilling([AE2('certus_quartz_dust')], AE2('#crystals/certus')).processingTime(processingTimesDefault.milling)
	event.recipes.createMilling([EE('quartz_dust')], AE2('#crystals/nether')).processingTime(processingTimesDefault.milling)

	event.stonecutting(Item.of(AE2('certus_crystal_seed'), 2), AE2('#crystals/certus'))
	event.stonecutting(Item.of(AE2('nether_quartz_seed'), 2), AE2('#crystals/nether'))
	event.stonecutting(Item.of(AE2('fluix_crystal_seed'), 2), AE2('#crystals/fluix'))

	let grow = (from, via, to) => {
		event.recipes.createSequencedAssembly([to], from, [
			event.recipes.createFilling(via, [via, Fluid.of(MC("water"), 500)]),
		]).transitionalItem(via)
			.loops(4)
			.id(KJ('grow_') + to.split(':')[1])
	}

	grow(AE2("certus_crystal_seed"), KJ('growing_certus_seed'), KJ('tiny_certus_crystal'))
	grow(AE2("fluix_crystal_seed"), KJ('growing_fluix_seed'), KJ('tiny_fluix_crystal'))
	grow(AE2("nether_quartz_seed"), KJ('growing_nether_seed'), KJ('tiny_nether_crystal'))

	grow(KJ("tiny_certus_crystal"), KJ('growing_tiny_certus_crystal'), KJ('small_certus_crystal'))
	grow(KJ("tiny_fluix_crystal"), KJ('growing_tiny_fluix_crystal'), KJ('small_fluix_crystal'))
	grow(KJ("tiny_nether_crystal"), KJ('growing_tiny_nether_crystal'), KJ('small_nether_crystal'))

	grow(KJ("small_certus_crystal"), KJ('growing_small_certus_crystal'), AE2('certus_quartz_crystal'))
	grow(KJ("small_fluix_crystal"), KJ('growing_small_fluix_crystal'), AE2('fluix_crystal'))
	grow(KJ("small_nether_crystal"), KJ('growing_small_nether_crystal'), MC('quartz'))

	event.recipes.createMixing(Fluid.of(TC("molten_obsidian"), 500), [AE2('sky_dust'), AE2('sky_dust'), AE2('sky_dust'), AE2('sky_dust'), Fluid.of(MC('water'), 500)])
	event.recipes.createMixing([AE2('certus_quartz_crystal'), Fluid.of(EE("molten_redstone"), 250)], [AE2('charged_certus_quartz_crystal'), Fluid.of(TC("molten_obsidian"), 250)])
	event.recipes.createMixing([CR('polished_rose_quartz')], [[MC('quartz'), AE2('certus_quartz_crystal')], Fluid.of(EE("molten_redstone"), 250)])



	//andesite age
	wood_types.forEach(wood => {
		event.recipes.createCutting('2x ' + wood + '_slab', wood + '_planks').processingTime(150)
	})

	let tKinetic = KJ('incomplete_kinetic_mechanism')
	event.recipes.createSequencedAssembly([
		KJ('kinetic_mechanism'),
	], MC('#wooden_slabs'), [
		event.recipes.createDeploying(tKinetic, [tKinetic, CR('andesite_alloy')]),
		event.recipes.createDeploying(tKinetic, [tKinetic, CR('andesite_alloy')]),
		event.recipes.createDeploying(tKinetic, [tKinetic, Item.of(PR_C('screwdriver')).ignoreNBT()])
	]).transitionalItem(tKinetic)
		.loops(1)
		.id(KJ('kinetic_mechanism'))

	event.shapeless(KJ('kinetic_mechanism'), [F('#saws'), F('#cogwheels'), CR('andesite_alloy'), MC('#logs')]).id(KJ("kinetic_mechanism_manual_only"))

	event.shaped(KJ('andesite_machine'), [
		'SSS',
		'SCS',
		'SSS'
	], {
		C: CR('andesite_casing'),
		S: KJ('kinetic_mechanism')
	})

	let andesite_machine = (id, amount, other_ingredient) => {
		event.remove({ output: id })
		if (other_ingredient) {
			event.smithing(Item.of(id, amount), KJ('andesite_machine'), other_ingredient)
			event.recipes.createMechanicalCrafting(Item.of(id, amount), "AB", { A: KJ('andesite_machine'), B: other_ingredient })
		}
		else
			event.stonecutting(Item.of(id, amount), KJ('andesite_machine'))
	}

	andesite_machine(CR('portable_storage_interface'), 2)
	andesite_machine(CR('encased_fan'), 1, CR('propeller'))
	andesite_machine(CR('millstone'), 1, WH('wooden_hopper'))
	andesite_machine(CR('mechanical_press'), 1, F("#storage_blocks/zinc"))
	andesite_machine(CR('mechanical_mixer'), 1, CR('whisk'))
	andesite_machine(CR('mechanical_drill'), 1, CRA('drill_head'))
	andesite_machine(CR('mechanical_saw'), 1, KJ('saw_blade'))
	andesite_machine(CR('deployer'), 1, CR('brass_hand'))
	andesite_machine(CR('mechanical_harvester'), 2)
	andesite_machine(CR('mechanical_plough'), 2)
	andesite_machine(CR('andesite_funnel'), 4)
	andesite_machine(CR('andesite_tunnel'), 4)
	andesite_machine(CR('speedometer'), 1, MC("compass"))
	andesite_machine(CR('mechanical_bearing'), 1, CR("turntable"))
	andesite_machine(CR('mechanical_piston'), 1, MC("piston"))
	andesite_machine(CR('rope_pulley'), 1, CF("rope_and_nail"))
	andesite_machine(IF('water_condensator'), 1, MC("water_bucket"))



	//copper age
	let tSealed = KJ('incomplete_sealed_mechanism')
	event.recipes.createSequencedAssembly([
		KJ('sealed_mechanism'),
	], KJ('kinetic_mechanism'), [
		event.recipes.createDeploying(tSealed, [tSealed, F('#gems/coke')]),
		event.recipes.createDeploying(tSealed, [tSealed, F('#nuggets/copper')]),
		event.recipes.createDeploying(tSealed, [tSealed, Item.of(PR_C('screwdriver')).ignoreNBT()])
	]).transitionalItem(tSealed)
		.loops(1)
		.id(KJ('sealed_mechanism'))

	event.shaped(KJ('copper_machine'), [
		'SSS',
		'SCS',
		'SSS'
	], {
		C: CR('copper_casing'),
		S: KJ('sealed_mechanism')
	})

	// donutCraft(event, TC('smeltery_controller'), TC('seared_bricks'), KJ('sealed_mechanism'))
	donutCraft(event, TC('foundry_controller'), TC('scorched_bricks'), KJ('sealed_mechanism'))

	let copper_machine = (id, amount, other_ingredient) => {
		event.remove({ output: id })
		if (other_ingredient) {
			event.smithing(Item.of(id, amount), KJ('copper_machine'), other_ingredient)
			event.recipes.createMechanicalCrafting(Item.of(id, amount), "AB", { A: KJ('copper_machine'), B: other_ingredient })
		}
		else
			event.stonecutting(Item.of(id, amount), KJ('copper_machine'))
	}

	copper_machine(CR('copper_backtank'), 1, F("#storage_blocks/copper"))
	copper_machine(CR('portable_fluid_interface'), 2)
	copper_machine(CR('spout'), 1, MC('hopper'))
	copper_machine(CR('hose_pulley'), 1)
	copper_machine(CR('item_drain'), 1, MC("iron_bars"))
	copper_machine(CR('smart_fluid_pipe'), 2)
	copper_machine(AE2('charger'), 1, AE2('certus_quartz_crystal'))
	copper_machine(IF('pitiful_generator'), 1, IFC('emerald_furnace'))



	//brass age
	event.recipes.createMilling([
		AE2('sky_dust'),
		AE2('sky_stone_block'),
		Item.of(ENS_AE2("crushed_skystone")).withChance(0.1)
	], AE2('sky_stone_block')).processingTime(processingTimesDefault.milling)

	let tPrecision = CR('incomplete_precision_mechanism')
	event.recipes.createSequencedAssembly([
		CR('precision_mechanism'),
	], KJ('sealed_mechanism'), [
		event.recipes.createDeploying(tPrecision, [tPrecision, CR('electron_tube')]),
		event.recipes.createDeploying(tPrecision, [tPrecision, CR('electron_tube')]),
		event.recipes.createDeploying(tPrecision, [tPrecision, Item.of(PR_C('screwdriver')).ignoreNBT()])
	]).transitionalItem(tPrecision)
		.loops(1)
		.id(KJ('precision_mechanism'))

	event.shaped(KJ('brass_machine'), [
		'SSS',
		'SCS',
		'SSS'
	], {
		C: CR('brass_casing'),
		S: CR('precision_mechanism')
	})

	let brass_machine = (id, amount, other_ingredient) => {
		event.remove({ output: id })
		if (other_ingredient) {
			event.smithing(Item.of(id, amount), KJ('brass_machine'), other_ingredient)
			event.recipes.createMechanicalCrafting(Item.of(id, amount), "AB", { A: KJ('brass_machine'), B: other_ingredient })
		}
		else
			event.stonecutting(Item.of(id, amount), KJ('brass_machine'))
	}

	brass_machine(CR('mechanical_crafter'), 3, MC('crafting_table'))
	brass_machine(CR('sequenced_gearshift'), 2)
	brass_machine(CR('furnace_engine'), 1, IFC('emerald_furnace'))
	brass_machine(CR('rotation_speed_controller'), 1)
	brass_machine(CR('mechanical_arm'), 1)
	brass_machine(CR('stockpile_switch'), 2)
	brass_machine(CR('content_observer'), 2)
	brass_machine(CR('brass_funnel'), 4)
	brass_machine(CR('brass_tunnel'), 4)
	brass_machine(CR('adjustable_crate'), 1, Q("crate"))
	brass_machine(CR('clockwork_bearing'), 1, CR("turntable"))
	brass_machine(TM('feral_flare_lantern'), 1, MC('glowstone_dust'))
	brass_machine(TM('megatorch'), 1, MC('torch'))
	brass_machine(SD('controller'), 1, MC('diamond'))
	brass_machine(SD('controller_slave'), 1, F('#ingots/gold'))
	brass_machine(CRA('ore_extractor'), 1, CRA('drill_head'))



	//zinc age
	event.recipes.createCrushing([AE2("singularity")], CR('crushing_wheel')).processingTime(processingTimesDefault.crushing)

	let dyes = [MC('orange_dye'), MC('magenta_dye'), MC('light_blue_dye'), MC('yellow_dye'), MC('lime_dye'), MC('pink_dye'), MC('cyan_dye'), MC('purple_dye'), MC('blue_dye'), MC('brown_dye'), MC('green_dye'), MC('red_dye')]
	event.recipes.createCompacting('1x ' + KJ("dye_entangled_singularity"), [dyes, Item.of(AE2('quantum_entangled_singularity'), 1)])
	event.recipes.createCrushing([
		Item.of(AE2("red_paint_ball"), 1).withChance(.90),
		Item.of(AE2("yellow_paint_ball"), 1).withChance(.80),
		Item.of(AE2("green_paint_ball"), 1).withChance(.70),
		Item.of(AE2("blue_paint_ball"), 1).withChance(.60),
		Item.of(AE2("magenta_paint_ball"), 1).withChance(.50)],
		KJ('dye_entangled_singularity')).processingTime(processingTimesDefault.crushing)

	let colors = ["red", "yellow", "green", "blue", "magenta", "black"]
	for (let index = 0; index < colors.length; index++) {
		var element = colors[index];
		if (index == colors.length - 1)
			continue;
		event.recipes.createEmptying([AE2(colors[index + 1] + '_paint_ball'), Fluid.of(TC('molten_ender'), 250)], AE2(element + '_paint_ball'))
	}

	event.recipes.createMechanicalCrafting(CR('chromatic_compound'), [
		'AA',
		'AA'
	], {
		A: AE2('magenta_paint_ball')
	})

	event.recipes.createPressing(KJ("radiant_sheet"), CR("refined_radiance"))
	event.recipes.createMechanicalCrafting(KJ('radiant_coil'), ['A'], { A: KJ('radiant_sheet') })

	let tInductive = KJ('incomplete_inductive_mechanism')
	event.recipes.createSequencedAssembly([
		KJ('inductive_mechanism'),
	], CR('precision_mechanism'), [
		event.recipes.createDeploying(tInductive, [tInductive, KJ('radiant_coil')]),
		event.recipes.createDeploying(tInductive, [tInductive, KJ('radiant_coil')]),
		event.recipes.createDeploying(tInductive, [tInductive, Item.of(KJ('chromatic_resonator')).ignoreNBT()])
	]).transitionalItem(tInductive)
		.loops(1)
		.id(KJ('inductive_mechanism'))

	event.shaped(KJ('chromatic_resonator'), [
		' R ',
		'L S',
		'LL '
	], {
		R: F('#ingots/red_alloy'),
		L: F('#ingots/invar'),
		S: EC('crystaltine_ingot')
	})

	event.shaped(KJ('zinc_machine'), [
		'SSS',
		'SCS',
		'SSS'
	], {
		C: RTB('machine_frame'),
		S: KJ('inductive_mechanism')
	})

	let zinc_machine = (id, amount, other_ingredient) => {
		event.remove({ output: id })
		if (other_ingredient) {
			event.smithing(Item.of(id, amount), KJ('zinc_machine'), other_ingredient)
			event.recipes.createMechanicalCrafting(Item.of(id, amount), "AB", { A: KJ('zinc_machine'), B: other_ingredient })
		}
		else
			event.stonecutting(Item.of(id, amount), KJ('zinc_machine'))
	}

	zinc_machine(ES('ender_chest'), 1, IC('obsidian_chest'))
	zinc_machine(ES('ender_tank'), 1, CR('fluid_tank'))
	zinc_machine(MU('mechanical_miner'), 1, CR('mechanical_drill'))
	zinc_machine(MU('mechanical_placer'), 1, CR('deployer'))
	zinc_machine(DU('ender_hopper'), 1, SH('speedyhopper_mk3'))
	zinc_machine(IF('item_transporter_type'), 2)
	zinc_machine(IF('fluid_transporter_type'), 2)
	zinc_machine(IF('world_transporter_type'), 2)



	//fluix age
	event.stonecutting(AE2("silicon_press"), KJ("circuit_scrap"))
	event.stonecutting(AE2("engineering_processor_press"), KJ("circuit_scrap"))
	event.stonecutting(AE2("calculation_processor_press"), KJ("circuit_scrap"))
	event.stonecutting(AE2("logic_processor_press"), KJ("circuit_scrap"))

	event.custom(ifiniDeploying(AE2("printed_silicon"), AE2("silicon"), AE2("silicon_press")))

	let procTypes = ["calculation", "logic", "engineering"]
	procTypes.forEach(e => {
		let t = KJ('incomplete_' + e + '_processor')
		event.recipes.createSequencedAssembly([
			AE2(e + '_processor'),
		], AE2('printed_silicon'), [
			event.recipes.createDeploying(t, [t, AE2('printed_' + e + "_processor")]),
			event.recipes.createFilling(t, [t, Fluid.of(EE("molten_redstone"), 250)]),
			event.recipes.createPressing(t, t)
		]).transitionalItem(t)
			.loops(1)
			.id('kubejs:' + e + "_processor")
	})

	let tCalculation = KJ('incomplete_calculation_mechanism')
	event.recipes.createSequencedAssembly([
		KJ('calculation_mechanism'),
	], KJ('inductive_mechanism'), [
		event.recipes.createDeploying(tCalculation, [tCalculation, AE2('calculation_processor')]),
		event.recipes.createDeploying(tCalculation, [tCalculation, AE2('logic_processor')]),
		event.recipes.createDeploying(tCalculation, [tCalculation, AE2('engineering_processor')]),
		event.recipes.createDeploying(tCalculation, [tCalculation, Item.of(KJ('chromatic_resonator')).ignoreNBT()])
	]).transitionalItem(tCalculation)
		.loops(1)
		.id(KJ('calculation_mechanism'))

	event.shaped(AE2('controller'), [
		'SSS',
		'SCS',
		'SSS'
	], {
		C: KJ('fluix_casing'),
		S: KJ('calculation_mechanism')
	})

	let fluix_machine = (id, amount, other_ingredient) => {
		event.remove({ output: id })
		if (other_ingredient) {
			event.smithing(Item.of(id, amount), AE2('controller'), other_ingredient)
			event.recipes.createMechanicalCrafting(Item.of(id, amount), "AB", { A: AE2('controller'), B: other_ingredient })
		}
		else
			event.stonecutting(Item.of(id, amount), AE2('controller'))
	}

	fluix_machine(AE2('drive'), 1, AE2("empty_storage_cell"))
	fluix_machine(AE2('formation_core'), 4, AE2("fluix_pearl"))
	fluix_machine(AE2('annihilation_core'), 4, MC("ender_pearl"))
	fluix_machine(AE2('chest'), 1, ES('ender_chest'))
	fluix_machine(AE2('molecular_assembler'), 1, CR('mechanical_crafter'))

	event.replaceInput({ id: AE2("network/cells/storage_components_cell_1k_part") }, MC("redstone"), KJ('calculation_mechanism'))
	event.replaceInput({ id: AE2("network/cells/storage_components_cell_1k_part") }, AE2("logic_processor"), F('#dusts/redstone'))
	event.replaceInput({ id: AE2("network/cells/fluid_storage_components_cell_1k_part") }, MC("green_dye"), KJ('calculation_mechanism'))
	event.replaceInput({ id: AE2("network/cells/fluid_storage_components_cell_1k_part") }, AE2("logic_processor"), F('#dyes/green'))
	event.replaceInput({ id: AE2("network/cells/spatial_components") }, MC("glowstone_dust"), KJ('calculation_mechanism'))
	event.replaceInput({ id: AE2("network/cells/spatial_components") }, AE2("engineering_processor"), F('#dusts/glowstone'))
	event.replaceInput({ id: AE2("network/crafting/patterns_blank") }, MC("glowstone_dust"), KJ('calculation_mechanism'))



	//DIGITAL AGE
	let tAbstruse = KJ('incomplete_abstruse_mechanism')
	event.recipes.createSequencedAssembly([
		KJ('abstruse_mechanism'),
	], KJ('calculation_mechanism'), [
		event.recipes.createDeploying(tAbstruse, [tAbstruse, KJ('computation_matrix')]),
		event.recipes.createDeploying(tAbstruse, [tAbstruse, KJ('computation_matrix')]),
		event.recipes.createDeploying(tAbstruse, [tAbstruse, Item.of(KJ('chromatic_resonator')).ignoreNBT()])
	]).transitionalItem(tAbstruse)
		.loops(1)
		.id(KJ('abstruse_mechanism'))

	let numbers = ["three", "eight", "plus", "minus", "multiply", "divide"]
	numbers.forEach(e => {
		event.stonecutting(KJ(e + '_cast'), F('#plates/gold'))
		event.custom({
			"type": TC("casting_table"),
			"cast": {
				"item": KJ(e + '_cast')
			},
			"fluid": {
				"name": KJ("raw_logic"),
				"amount": 1
			},
			"result": Item.of(KJ(e)).toResultJson(),
			"cooling_time": 10
		})
	})

	let meltNumber = (id, out, outAmount) => {
		event.custom({
			"type": TC("melting"),
			"ingredient": { "item": id },
			"result": {
				"fluid": out,
				"amount": outAmount
			},
			"temperature": 2048,
			"time": 20
		})
	}

	let alloyAmount = 10
	let outAmount = 50
	event.custom({
		"type": "tconstruct:alloy",
		"inputs": [
			{ "name": KJ("number_0"), "amount": alloyAmount },
			{ "name": KJ("number_1"), "amount": alloyAmount },
			{ "name": KJ("number_2"), "amount": alloyAmount },
			{ "name": KJ("number_3"), "amount": alloyAmount },
			{ "name": KJ("number_4"), "amount": alloyAmount },
			{ "name": KJ("number_5"), "amount": alloyAmount },
			{ "name": KJ("number_6"), "amount": alloyAmount },
			{ "name": KJ("number_7"), "amount": alloyAmount },
			{ "name": KJ("number_8"), "amount": alloyAmount },
			{ "name": KJ("number_9"), "amount": alloyAmount }
		],
		"result": {
			"fluid": KJ("matrix"),
			"amount": outAmount
		},
		"temperature": 2048
	})

	meltNumber(KJ("calculation_mechanism"), KJ("raw_logic"), 30)
	meltNumber(KJ("zero"), KJ("number_0"), 1)
	meltNumber(KJ("one"), KJ("number_1"), 1)
	meltNumber(KJ("two"), KJ("number_2"), 1)
	meltNumber(KJ("three"), KJ("number_3"), 1)
	meltNumber(KJ("four"), KJ("number_4"), 1)
	meltNumber(KJ("five"), KJ("number_5"), 1)
	meltNumber(KJ("six"), KJ("number_6"), 1)
	meltNumber(KJ("seven"), KJ("number_7"), 1)
	meltNumber(KJ("eight"), KJ("number_8"), 1)
	meltNumber(KJ("nine"), KJ("number_9"), 1)

	event.custom({
		"type": TC("casting_basin"),
		"fluid": {
			"name": KJ("matrix"),
			"amount": 1000
		},
		"result": Item.of(KJ("computation_matrix")).toResultJson(),
		"cooling_time": 20
	})

	let nums = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
	let ops = [(a, b) => a + b, (a, b) => a - b, (a, b) => a * b, (a, b) => b == 0 ? 'error' : a / b]
	let opNames = ['plus', 'minus', 'multiply', 'divide']

	for (var a = 0; a < 10; a++) {
		for (var b = 0; b < 10; b++) {
			for (var op = 0; op < ops.length; op++) {

				let result = ops[op](a, b)
				var output;

				if (result == 'error')
					output = KJ('missingno')
				else if (result < 0)
					continue
				else if (result > 9)
					continue
				else if (result % 1 != 0)
					continue
				else
					output = KJ(nums[result])

				event.custom({
					"type": CR("mechanical_crafting"),
					"pattern": [
						"AOB"
					],
					"key": {
						"A": {
							"item": KJ(nums[a])
						},
						"O": {
							"item": KJ(opNames[op])
						},
						"B": {
							"item": KJ(nums[b])
						}
					},
					"result": {
						"item": output
					},
					"acceptMirrored": false
				})

			}
		}
	}



	//PITY INDUSTRIAL AGE
	event.shaped(IF('machine_frame_pity'), [
		'SSS',
		'SCS',
		'SSS'
	], {
		C: CR('refined_radiance_casing'),
		S: KJ('abstruse_mechanism')
	})

	let pity_machine = (id, amount, other_ingredient) => {
		event.remove({ output: id })
		if (other_ingredient) {
			event.smithing(Item.of(id, amount), IF('machine_frame_pity'), other_ingredient)
			event.recipes.createMechanicalCrafting(Item.of(id, amount), "AB", { A: IF('machine_frame_pity'), B: other_ingredient })
		}
		else
			event.stonecutting(Item.of(id, amount), IF('machine_frame_pity'))
	}

	pity_machine(VH('workstation'), 1, TC('tinker_station'))
	pity_machine(VH('jack'), 1, CR('mechanical_piston'))
	pity_machine(VH('key'), 1, SD('drawer_key'))
	pity_machine(VH('jerry_can'), 1, MC("bucket"))
	pity_machine(VH('industrial_jerry_can'), 1, VH('jerry_can'))
	pity_machine(VH('fuel_drum'), 1, M("basic_fluid_tank"))
	pity_machine(VH('industrial_fuel_drum'), 1, VH('fuel_drum'))
	pity_machine(VH('wrench'), 1, Item.of(MAT('wrench')).ignoreNBT())
	pity_machine(VH('hammer'), 1, 'framedblocks:framed_hammer')



	//SIMPLE INDUSTRIAL AGE
	let simple_machine = (id, amount, other_ingredient) => {
		event.remove({ output: id })
		if (other_ingredient) {
			event.smithing(Item.of(id, amount), IF('machine_frame_simple'), other_ingredient)
			event.recipes.createMechanicalCrafting(Item.of(id, amount), "AB", { A: IF('machine_frame_simple'), B: other_ingredient })
		}
		else
			event.stonecutting(Item.of(id, amount), IF('machine_frame_simple'))
	}

	simple_machine(X('controller'), 1, PREXP('blue_fuel_block'))
	simple_machine(X('antenna'), 2)
	simple_machine(X('antenna_base'), 2)
	simple_machine(X('antenna_dish'), 2)
	simple_machine(X('router'), 1, PR_INT('comparator_gate'))
	simple_machine(X('wireless_router'), 1, CR('redstone_link'))
	simple_machine(X('redstone_proxy'), 1, F('#ingots/red_alloy'))
	simple_machine(X('redstone_proxy_upd'), 1, PR_T('red_alloy_wire'))
})