// priority: 0

ServerEvents.recipes((event) => {
	removeRecipeByID(event, [
		EC('crystaltine_ingot'),
		EC("ender_ingot"),
		EC("enhanced_redstone_ingot"),
		EC("flux_star"),
	])
	removeRecipeByOutput(event, [
		EC('advanced_table'),
		EC('advanced_auto_table'),
		EC('elite_table'),
		EC('elite_auto_table'),
		EC('ultimate_table'),
		EC('ultimate_auto_table'),
		EC('epic_table'),
		EC('epic_auto_table'),
		EC('auto_ender_crafter'),
		EC("flux_crafter"),
		EC("flux_alternator"),
		EC('auto_flux_crafter'),
		
		// w/o replace
		EC("black_iron_ingot"),
		EC("luminessence"),
		EC("crystaltine_component"),
		EC("the_ultimate_component"),
		EC("redstone_nugget"),
		EC("redstone_ingot"),
		EC("redstone_ingot_block"),
		EC('enhanced_redstone_component'),
	])
	
	//advanced crafting tables
	event.shaped(EC('advanced_table'), [
		'ABA',
		'BCB',
		'ABA',
	], {
		A: CP('gold_1'),
		B: AV("compressed_crafting_table"),
		C: AE2("controller"),
	})
	event.recipes.extendedcrafting.shaped_table(EC('advanced_auto_table'), [
		'AAAAA',
		'ABBBA',
		'ABCBA',
		'ABBBA',
		'AAAAA',
	], {
		A: CP('gold_1'),
		B: AV("double_compressed_crafting_table"),
		C: EC("advanced_table"),
	})

	//elite crafting tables
	event.recipes.extendedcrafting.shaped_table(EC('elite_table'), [
		'AAAAA',
		'ABBBA',
		'ABCBA',
		'ABBBA',
		'AAAAA',
	], {
		A: CP('diamond_1'),
		B: AV("compressed_crafting_table"),
		C: EC("advanced_table"),
	})
	event.recipes.extendedcrafting.shaped_table(EC('elite_auto_table'), [
		'AAAAAAA',
		'ABBBBBA',
		'ABAAABA',
		'ABACABA',
		'ABAAABA',
		'ABBBBBA',
		'AAAAAAA',
	], {
		A: CP('diamond_1'),
		B: AV("double_compressed_crafting_table"),
		C: EC("elite_table"),
	})
	
	//ultimate crafting tables
	event.recipes.extendedcrafting.shaped_table(EC('ultimate_table'), [
		'AAAAAAA',
		'ABBBBBA',
		'ABAAABA',
		'ABACABA',
		'ABAAABA',
		'ABBBBBA',
		'AAAAAAA',
	], {
		A: CP('emerald_1'),
		B: AV("compressed_crafting_table"),
		C: EC("elite_table"),
	})
	event.recipes.extendedcrafting.shaped_table(EC('ultimate_auto_table'), [
		'AAAAAAAAA',
		'ABBBBBBBA',
		'ABAAAAABA',
		'ABABBBABA',
		'ABABCBABA',
		'ABABBBABA',
		'ABAAAAABA',
		'ABBBBBBBA',
		'AAAAAAAAA',
	], {
		A: CP('emerald_1'),
		B: AV("double_compressed_crafting_table"),
		C: EC("ultimate_table"),
	})
	
	//ultimate crafting tables
	event.recipes.extendedcrafting.shaped_table(EC('epic_table'), [
		'AAAAAAAAA',
		'ABBBBBBBA',
		'ABAAAAABA',
		'ABABBBABA',
		'ABABCBABA',
		'ABABBBABA',
		'ABAAAAABA',
		'ABBBBBBBA',
		'AAAAAAAAA',
	], {
		A: PRE('dark_matter_block'),
		B: AV("compressed_crafting_table"),
		C: EC("ultimate_table"),
	})
	event.recipes.extendedcrafting.shaped_table(EC('epic_auto_table'), [
		'AAAAAAAAAAA',
		'ABBBBBBBBBA',
		'ABAAAAAAABA',
		'ABABBBBBABA',
		'ABABAAABABA',
		'ABABACABABA',
		'ABABAAABABA',
		'ABABBBBBABA',
		'ABAAAAAAABA',
		'ABBBBBBBBBA',
		'AAAAAAAAAAA',
	], {
		A: PRE('red_matter_block'),
		B: AV("double_compressed_crafting_table"),
		C: EC("epic_table"),
	})
	event.recipes.extendedcrafting.shaped_table(EC('auto_ender_crafter'), [
		'AAAAAAAAAAA',
		'ABBBBBBBBBA',
		'ABAAAAAAABA',
		'ABABBBBBABA',
		'ABABAAABABA',
		'ABABACABABA',
		'ABABAAABABA',
		'ABABBBBBABA',
		'ABAAAAAAABA',
		'ABBBBBBBBBA',
		'AAAAAAAAAAA',
	], {
		A: F('#storage_blocks/ender_ingot'),
		B: AV("double_compressed_crafting_table"),
		C: EC("ender_crafter"),
	})
	event.recipes.extendedcrafting.shaped_table(EC('auto_flux_crafter'), [
		'AAAAAAAAAAA',
		'ABBBBBBBBBA',
		'ABAAAAAAABA',
		'ABABBBBBABA',
		'ABABAAABABA',
		'ABABACABABA',
		'ABABAAABABA',
		'ABABBBBBABA',
		'ABAAAAAAABA',
		'ABBBBBBBBBA',
		'AAAAAAAAAAA',
	], {
		A: F('#storage_blocks/red_alloy'),
		B: AV("double_compressed_crafting_table"),
		C: EC("flux_crafter"),
	})
	
	//flux crafter
	event.recipes.powah.energizing([EC("ender_crafter")], EC("flux_crafter"), 30000)
	event.recipes.powah.energizing([EC("ender_alternator")], EC("flux_alternator"), 30000)
	
	//enhanced redstone ingot
	event.recipes.extendedcrafting.shaped_flux_crafter(Item.of(EC("enhanced_redstone_ingot"), 4), [
		' A ',
		'ABA',
		' A '
	], {
		A: F("#ingots/red_alloy"),
		B: EC("flux_star"),
	}, 800000).powerRate(400)
	
	//flux star
	event.recipes.extendedcrafting.shapeless_flux_crafter(EC("flux_star"), [EC("ender_star")], 400000).powerRate(400)
	
	//crystaltine ingot
	event.recipes.extendedcrafting.shaped_table(EC('crystaltine_ingot'), [
		'ABBBBBA',
		'ACDEDCA',
		'ACDEDCA',
		'ABBBBBA',
	], {
		A: MC('diamond'),
		B: MC("lapis_lazuli"),
		C: MC("gold_ingot"),
		D: MC("iron_ingot"),
		E: AE2("singularity"),
	})
	event.recipes.create.mechanical_crafting(EC('crystaltine_ingot'), [
		'ABBBBBA',
		'ACDEDCA',
		'ACDEDCA',
		'ABBBBBA',
	], {
		A: MC('diamond'),
		B: MC("lapis_lazuli"),
		C: MC("gold_ingot"),
		D: MC("iron_ingot"),
		E: AE2("singularity"),
	})
	
	event.replaceInput({ id: EC("guide_book") }, EC("black_iron_ingot"), EC("crystaltine_ingot"))
	
	//redstone ingot with red alloy compat
	event.shapeless(Item.of(PR_C("red_ingot"), 9), [F("#storage_blocks/red_alloy")])
	event.shapeless(EC("redstone_ingot_block"), [Item.of(PR_C("red_ingot"), 9)])
	event.shapeless(Item.of(EC("redstone_nugget"), 9), [F("#ingots/red_alloy")])
	event.shapeless(PR_C("red_ingot"), [Item.of(EC("redstone_nugget"), 9)])
		
	//singularities
    singularities.forEach(singularity => {
        const { id, core } = singularity

        event.recipes.extendedcrafting.shaped_table(singularityId(id), [
            'B    B    B',
            ' B   B   B ',
            '  B  B  B  ',
            '   B B B   ',
            '    BBB    ',
            'BBBBBABBBBB',
            '    BBB    ',
            '   B B B   ',
            '  B  B  B  ',
            ' B   B   B ',
            'B    B    B',
        ], {
			B: core,
			A: AE2("singularity"),
        })
    })
})