//------------------------------------------------------------------------------------------------------------------------------------------------
// PA2 Extras - Remove Recipes
//------------------------------------------------------------------------------------------------------------------------------------------------
// Author: RicTheCoder
//
// Removes recipes based on different factors, it also fixes problems with automatic recipe generation from Create by changing the IDs of some
// recipes and suffixing them with '_manual_only'
//------------------------------------------------------------------------------------------------------------------------------------------------

// Remove by Output
// - Add the item id of the output item of the recipe and all recipes with that output will be removed
const byOutput = [
	"quark:obsidian_pressure_plate",
	"cyclic:compressed_cobblestone",
	"jaopca:storage_blocks.brick",
	"jaopca:storage_blocks.fluix",
	"jaopca:storage_blocks.glowstone",
	"jaopca:storage_blocks.brick",
	"jaopca:storage_blocks.nether_brick",
	"jaopca:storage_blocks.wood",
	/chisel_chipped_integration:metal_aluminum_.*/,
	/chisel_chipped_integration:metal_cobalt_.*/,
	/chisel_chipped_integration:metal_platinum_.*/,
	"architects_palette:charcoal_block"
]

// Remove by ID
// - Add the recipe id for the recipe to remove
const byId = [
	// Compact Suns don't work with the normal collectors of ProjectE, and the ones from ProjectExpansion are disabled,
	// this only follows the logic.
    "projectexpansion:compact_sun_1",
	"projectexpansion:compact_sun_2",
	"reliquary:reliquary.fragment_to_spawn_egg.item.minecraft.chicken_spawn_egg",
	"outer_end:violite/bricks/slab_from_vertical_slab",
	"outer_end:himmel_vertical_to_slab",
	"outer_end:violite/tiles/slab_from_vertical_slab",
	"outer_end:violite/mossy_tiles/slab_from_vertical_slab",
	"outer_end:azure_vertical_to_planks",
	"outer_end:violite/mossy_bricks/slab_from_vertical_slab",
	"outer_end:violite/slab_from_vertical_slab",
	"outer_end:azure_vertical_to_slab",
	"allthecompressed:compress/invar_block_1x",
	"allthecompressed:compress/soularium_block_1x",
	"allthecompressed:compress/ender_pearl_block_1x",
	"allthecompressed:compress/copper_alloy_block_1x",
	"allthecompressed:compress/silver_block_1x",
	"allthecompressed:compress/tin_block_1x",
	"allthecompressed:compress/lumium_block_1x",
	"allthecompressed:compress/blaze_block_1x",
	"allthecompressed:compress/atm_star_block_1x",
	"allthecompressed:compress/redstone_alloy_block_1x",
	"allthecompressed:compress/pulsating_alloy_block_1x",
	"allthecompressed:compress/aluminum_block_1x",
	"allthecompressed:compress/steel_block_1x",
	"allthecompressed:compress/peridot_block_1x",
	"allthecompressed:compress/energetic_alloy_block_1x",
	"allthecompressed:compress/osmium_block_1x",
	"allthecompressed:compress/allthemodium_block_1x",
	"allthecompressed:compress/vibranium_block_1x",
	"allthecompressed:compress/ruby_block_1x",
	"allthecompressed:compress/vibranium_allthemodium_alloy_block_1x",
	"allthecompressed:compress/platinum_block_1x",
	"allthecompressed:compress/unobtainium_block_1x",
	"allthecompressed:compress/end_steel_block_1x",
	"allthecompressed:compress/vibrant_alloy_block_1x",
	"allthecompressed:compress/enderium_block_1x",
	"allthecompressed:compress/ancient_log_0_1x",
	"allthecompressed:compress/wax_block_1x",
	"allthecompressed:compress/lead_block_1x",
	"allthecompressed:compress/zinc_block_1x",
	"allthecompressed:compress/iridium_block_1x",
	"allthecompressed:compress/conductive_alloy_block_1x",
	"allthecompressed:compress/bronze_block_1x",
	"allthecompressed:compress/unobtainium_vibranium_alloy_block_1x",
	"allthecompressed:compress/sapphire_block_1x",
	"allthecompressed:compress/ancient_stone_1x",
	"allthecompressed:compress/signalum_block_1x",
	"allthecompressed:compress/unobtainium_allthemodium_alloy_block_1x",
	"allthecompressed:compress/constantan_block_1x",
	"allthecompressed:compress/nickel_block_1x",
	"allthecompressed:compress/electrum_block_1x",
	"allthecompressed:compress/dark_steel_block_1x",
	"allthecompressed:compress/uranium_block_1x",
	"allthecompressed:compress/nether_star_block_1x",
	"moredelight:farmersdelight/cutting/bread_slice"
]

// Advance Remove
// - Provide multiple options to target the removal
// - Removes the base version and adds it as '_manual_only' in order to fix Create issues (set 'manual' property to true)
// - To use regex when targeting ids (for dynamic recipes), use '$' in the start of the id
const advRemoval = [
	// This is a fix for a crash when opening the 'Automated Shaped Crafting' for the Ender Storage recipes
	{ output: "enderstorage:ender_pouch", manual: true },
	{ output: "enderstorage:ender_chest", manual: true },
	{ output: "enderstorage:ender_tank", manual: true },
	
	// Fixes the Alkahestry Tome with Create
	{ input: "reliquary:alkahestry_tome", manual: true }
]

//---[CODE]---------------------------------------------------------------------------------------------------------------------------------------

// The remove event
ServerEvents.recipes(event => {
	// Run the normal removes
    byOutput.forEach(item => event.remove({ output: item }));
    byId.forEach(item => event.remove({ id: item }));
	
	// Run the advance removes
	advRemoval.forEach(condition => {
		let manual = condition.manual;
		let test = condition.test;
		
		if (manual)
		{
			delete(condition.manual);
			
			let recipes = event.findRecipes(condition);
			recipes.forEach(recipe => {
				if (recipe.getId().endsWith("_manual_only"))
					return;
				
				recipe.id(recipe.getId() + "_manual_only");
			});
		}
		else		
			event.remove(condition);
	});
})