//------------------------------------------------------------------------------------------------------------------------------------------------
// 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 = [
]

// 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"
]

// 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)
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 },
	{ output: "minecraft:charcoal", manual: true },
    { output: "minecraft:clay", manual: true },
    { output: "minecraft:flint", manual: true },
    { output: "thermal:steel_ingot", manual: true },
    { output: "minecraft:nether_star", manual: true },
    { output: "minecraft:iron_ingot", manual: true },
    { output: "minecraft:diamond", manual: true },
    { output: "minecraft:copper_ingot", manual: true },
    { output: "minecraft:emerald", manual: true },
    { output: "minecraft:netherrack", manual: true },
    { output: "minecraft:gold_ingot", manual: true },
    { output: "minecraft:lapis_lazuli", manual: true },
    { output: "minecraft:sandstone", manual: true },
    { output: "thermal:silver_ingot", manual: true },
    { output: "minecraft:end_stone", manual: true },
    { output: "minecraft:dirt", manual: true },
    { output: "minecraft:gravel", manual: true },
    { output: "minecraft:gunpowder", manual: true },
    { output: "minecraft:sand", manual: true },
    { output: "minecraft:obsidian", manual: true },
    { output: "thermal:tin_ingot", manual: true },
    { output: "minecraft:soul_sand", manual: true }
]

// reliquary:reliquary.fragment_to_spawn_egg.item.minecraft.chicken_spawn_egg

//---[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;
		
		if (manual)
		{
			delete(condition.manual);
			let recipes = event.findRecipes(condition);
			recipes.forEach(recipe => {
				recipe.id(recipe.getId() + "_manual_only");
			});
		}
		else		
			event.remove(condition);
	});
})