//------------------------------------------------------------------------------------------------------------------------------------------------
// PA2 Extras - Langs
//------------------------------------------------------------------------------------------------------------------------------------------------
// Author: RicTheCoder
//
// This is a script to basically fix some missing localization keys that were not being translated into their actual values. As for some of
// cyclic descriptions added the "Not Official Description" to it because they are not based on any official info and were added more as a funny
// things.
//------------------------------------------------------------------------------------------------------------------------------------------------

// Language entries to fix
// - Add the language localized string as the key, and the actual translation as the value
// - This is English Only, mainly just a quick fix for some annoyances
const langs = {
	// Entities
	"entity.minecraft.villager.ae2:fluix_researcher": "Fluix Researcher",
	"entity.minecraft.villager.advancedperipherals:computer_scientist": "Computer Scientist",
	"entity.minecraft.villager.spelunkers_charm:spelunker": "Spelunker",
	
	// Biomes
	"biome.deeperdarker.echoing_forest": "Echoing Forest",
	"biome.deeperdarker.overcast_columns": "Overcast Columns",
	"biome.deeperdarker.deeplands": "Deeplands",
	
	// Fluids
	"fuild_type.biggerreactors.liquid_uranium": "Liquid Uranium",
	"fluid_type.biggerreactors.liquid_obsidian": "Liquid Obsidian",
	"fluid_type.biggerreactors.steam": "Steam",
	
	// Blocks
	"block.rftoolsstorage.crafting_manager": "Crafting Manager",
	"block.starbunclemania.source_fluid_block": "Liquefied Source", // Used 'Liquefied' because all other items related to it have the typo.
	"block.thermal.crude_oil_fluid": "Crude Oil",
	"block.thermal.ender_fluid": "Ender Fluid",
	"block.thermal.glowstone_mushroom": "Glowstone Mushroom",
	"block.thermal.gunpowder_mushroom": "Gunpowder Mushroom",
	"block.thermal.redstone_fluid": "Redstone Fluid",
	"block.thermal.redstone_mushroom": "Redstone Mushroom",
	"block.thermal.slime_mushroom": "Slime Mushroom",
	
	// Items
	"item.rftoolsutility.teleport_probe": "Teleport Probe",
	
	// Enchantments
	"enchantment.draconicevolution.reaper_enchantment.desc": "Mobs have a chance to drop the corresponding Mob Soul.",
	
	// Game Rules
	"gamerule.brandonscore:allowSignEditing": "Should signs be editable?",
	"gamerule.decorative_blocks:disableThatch": "Should Thatch be disabled?",
	
	// Effects
	"effect.reliquary.pacification": "Pacification"
};

// Same as above but allows multiple entries to map to the same description
// - Values in the array are objects where:
//   - 'baseEntry' is optional, and it will be used as the base for the entries, replacing '%entry' with the actual entry from the provided list
//   - 'entries' is required, and it will work as above the 'baseEntry' is provided, or it will work as a full localized string for translation
//   - 'description' is required, the translated value to add
//   - 'namespace' is optional, used when the default 'pa2' is not wanted, or another namespace might be required
// - Again mainly fixes for annoyances and only applied for English.
const multiLang = [
	{
		baseEntry: "item.cyclic.crystal_%entry.guide", 
		entries: ["boots", "helmet", "chestplate", "leggings"], 
		description: "A relatively strong armor!\n\n§8Not an official description" 
	},{ 
		baseEntry: "item.cyclic.crystal_%entry.guide", 
		entries: ["pickaxe", "axe", "hoe", "shovel", "sword"], 
		description: "An exceptional strong tool!\n\n§8Not an official description" 
	},{ 
		baseEntry: "item.cyclic.emerald_%entry.guide", 
		entries: ["boots", "helmet", "chestplate", "leggings", "pickaxe", "axe", "hoe", "shovel", "sword"], 
		description: "Good use for spare emeralds!\n\n§8Not an official description" 
	},{ 
		baseEntry: "item.cyclic.copper_%entry.guide", 
		entries: ["pickaxe", "axe", "hoe", "shovel", "sword"], 
		description: "Better than stone I guess?!\n\n§8Not an official description" 
	},{ 
		baseEntry: "item.cyclic.amethyst_%entry.guide", 
		entries: ["pickaxe", "axe", "hoe", "shovel", "sword"], 
		description: "We gotta use amethyst for something right?\n\n§8Not an official description"
	},{
		baseEntry: "item.cyclic.sandstone_%entry.guide",
		entries: ["pickaxe", "axe", "hoe", "shovel", "sword"],
		description: "I guess that in the desert this is more common...\n\n§8Not an official description"
	},{ 
		baseEntry: "item.cyclic.netherbrick_%entry.guide", 
		entries: ["pickaxe", "axe", "hoe", "shovel", "sword"], 
		description: "It is not netherite, that is for sure!\n\n§8Not an official description"
	}
]

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

// The language event to apply the fixes in
ClientEvents.lang("en_us", event => {
	Object.keys(langs).forEach(key => {
		event.add("pa2", key, langs[key]);
	});
	
	multiLang.forEach(fix => {
		fix.entries.forEach(entry => {
			let ns = fix.namespace ? fix.namespace : "pa2";
			
			if (fix.baseEntry)
				event.add(ns, fix.baseEntry.replace("%entry", entry), fix.description);
			else
				event.add(ns, entry, fix.description);
		});
	});
});