From 117a38b5f9f33680989a07beba642be3d08e1668 Mon Sep 17 00:00:00 2001 From: BruceChen Date: Mon, 17 Oct 2022 20:00:33 +0800 Subject: [PATCH] Better translation --- MinecraftClient/ChatBots/AutoDig.cs | 6 +- MinecraftClient/ChatBots/AutoFishing.cs | 8 +-- MinecraftClient/ChatBots/ScriptScheduler.cs | 1 - MinecraftClient/Commands/BlockInfo.cs | 16 ++--- MinecraftClient/Commands/Dig.cs | 4 +- MinecraftClient/Commands/Entitycmd.cs | 56 +++++++++--------- MinecraftClient/Commands/Inventory.cs | 4 +- MinecraftClient/ExtensionMethods.cs | 12 ++++ .../Inventory/EnchantmentMapping.cs | 52 ++-------------- MinecraftClient/Inventory/Item.cs | 20 +++---- MinecraftClient/Mapping/Block.cs | 7 +++ MinecraftClient/Mapping/Entity.cs | 7 +++ MinecraftClient/Mapping/Location.cs | 4 +- MinecraftClient/Resources/lang/de.ini | Bin 71740 -> 70464 bytes MinecraftClient/Resources/lang/en.ini | 42 +------------ MinecraftClient/Resources/lang/fr.ini | Bin 73698 -> 72428 bytes MinecraftClient/Resources/lang/ru.ini | Bin 70822 -> 69552 bytes MinecraftClient/Resources/lang/vi.ini | Bin 67120 -> 65850 bytes MinecraftClient/Resources/lang/zh-Hans.ini | Bin 75172 -> 73534 bytes MinecraftClient/Resources/lang/zh-Hant.ini | Bin 75252 -> 73614 bytes README.md | 12 ++-- 21 files changed, 95 insertions(+), 156 deletions(-) create mode 100644 MinecraftClient/ExtensionMethods.cs diff --git a/MinecraftClient/ChatBots/AutoDig.cs b/MinecraftClient/ChatBots/AutoDig.cs index 9d0c585c..fafbfdb2 100644 --- a/MinecraftClient/ChatBots/AutoDig.cs +++ b/MinecraftClient/ChatBots/AutoDig.cs @@ -247,7 +247,7 @@ namespace MinecraftClient.ChatBots { currentDig = blockLoc; if (Config.Log_Block_Dig) - LogToConsole(Translations.Get("cmd.dig.dig", blockLoc.X, blockLoc.Y, blockLoc.Z, block.Type)); + LogToConsole(Translations.Get("cmd.dig.dig", blockLoc.X, blockLoc.Y, blockLoc.Z, block.GetTypeString())); return true; } else @@ -308,7 +308,7 @@ namespace MinecraftClient.ChatBots { currentDig = target; if (Config.Log_Block_Dig) - LogToConsole(Translations.Get("cmd.dig.dig", target.X, target.Y, target.Z, targetBlock.Type)); + LogToConsole(Translations.Get("cmd.dig.dig", target.X, target.Y, target.Z, targetBlock.GetTypeString())); return true; } else @@ -342,7 +342,7 @@ namespace MinecraftClient.ChatBots { currentDig = blockLoc; if (Config.Log_Block_Dig) - LogToConsole(Translations.Get("cmd.dig.dig", blockLoc.X, blockLoc.Y, blockLoc.Z, block.Type)); + LogToConsole(Translations.Get("cmd.dig.dig", blockLoc.X, blockLoc.Y, blockLoc.Z, block.GetTypeString())); return true; } else diff --git a/MinecraftClient/ChatBots/AutoFishing.cs b/MinecraftClient/ChatBots/AutoFishing.cs index 0762f1d8..3849f161 100644 --- a/MinecraftClient/ChatBots/AutoFishing.cs +++ b/MinecraftClient/ChatBots/AutoFishing.cs @@ -144,7 +144,7 @@ namespace MinecraftClient.ChatBots private Location LastPos = Location.Zero; private DateTime CaughtTime = DateTime.Now; private int fishItemCounter = 10; - private Entity fish = new(-1, EntityType.Item, Location.Zero); + private Entity fishItem = new(-1, EntityType.Item, Location.Zero); private int counter = 0; private readonly object stateLock = new(); @@ -221,7 +221,7 @@ namespace MinecraftClient.ChatBots if (Config.Auto_Start) { double delay = Config.Fishing_Delay; - LogToConsole(Translations.Get("bot.autoFish.start", delay)); + LogToConsole(Translations.Get("bot.autoFish.start_at", delay)); lock (stateLock) { isFishing = false; @@ -352,7 +352,7 @@ namespace MinecraftClient.ChatBots { if (Config.Log_Fish_Bobber) LogToConsole(string.Format("Item ({0}) spawn at {1}, distance = {2:0.00}", entity.ID, entity.Location, entity.Location.Distance(LastPos))); - fish = entity; + fishItem = entity; } else if (entity.Type == EntityType.FishingBobber && entity.ObjectData == GetPlayerEntityID()) { @@ -431,7 +431,7 @@ namespace MinecraftClient.ChatBots public override void OnEntityMetadata(Entity entity, Dictionary metadata) { - if (fishItemCounter < 10 && entity.ID == fish.ID && metadata.TryGetValue(8, out object? item)) + if (fishItemCounter < 10 && entity.ID == fishItem.ID && metadata.TryGetValue(8, out object? item)) { LogToConsole(Translations.Get("bot.autoFish.got", ((Item)item!).ToFullString())); fishItemCounter = 10; diff --git a/MinecraftClient/ChatBots/ScriptScheduler.cs b/MinecraftClient/ChatBots/ScriptScheduler.cs index 6e977775..1fc14b73 100644 --- a/MinecraftClient/ChatBots/ScriptScheduler.cs +++ b/MinecraftClient/ChatBots/ScriptScheduler.cs @@ -1,5 +1,4 @@ using System; -using System.Xml.Linq; using Tomlet.Attributes; using static MinecraftClient.ChatBots.ScriptScheduler.Configs; diff --git a/MinecraftClient/Commands/BlockInfo.cs b/MinecraftClient/Commands/BlockInfo.cs index 391dbe84..b4458d2b 100644 --- a/MinecraftClient/Commands/BlockInfo.cs +++ b/MinecraftClient/Commands/BlockInfo.cs @@ -10,7 +10,7 @@ namespace MinecraftClient.Commands public override string CmdUsage { get { return "blockinfo [-s]"; } } public override string CmdDesc { get { return "cmd.blockinfo.desc"; } } - public override string Run(McClient handler, string command, Dictionary localVars) + public override string Run(McClient handler, string command, Dictionary? localVars) { string[] args = GetArgs(command); @@ -24,7 +24,7 @@ namespace MinecraftClient.Commands Block block = handler.GetWorld().GetBlock(targetBlockLocation); - handler.Log.Info(Translations.TryGet("cmd.blockinfo.BlockType") + ": " + block.Type); + handler.Log.Info(Translations.TryGet("cmd.blockinfo.BlockType") + ": " + block.GetTypeString()); if (reportSurrounding) { @@ -38,14 +38,14 @@ namespace MinecraftClient.Commands Block blockZPositive = handler.GetWorld().GetBlock(new Location(targetBlockLocation.X, targetBlockLocation.Y, targetBlockLocation.Z + 1)); Block blockZNegative = handler.GetWorld().GetBlock(new Location(targetBlockLocation.X, targetBlockLocation.Y, targetBlockLocation.Z - 1)); - sb.AppendLine("[X " + Translations.TryGet("cmd.blockinfo.Positive") + "] " + Translations.TryGet("cmd.blockinfo.BlockType") + ": " + blockXPositive.Type); - sb.AppendLine("[X " + Translations.TryGet("cmd.blockinfo.Negative") + "] " + Translations.TryGet("cmd.blockinfo.BlockType") + ": " + blockXNegative.Type); + sb.AppendLine("[X " + Translations.TryGet("cmd.blockinfo.Positive") + "] " + Translations.TryGet("cmd.blockinfo.BlockType") + ": " + blockXPositive.GetTypeString()); + sb.AppendLine("[X " + Translations.TryGet("cmd.blockinfo.Negative") + "] " + Translations.TryGet("cmd.blockinfo.BlockType") + ": " + blockXNegative.GetTypeString()); sb.AppendLine(" "); - sb.AppendLine("[Y " + Translations.TryGet("cmd.blockinfo.Positive") + "] " + Translations.TryGet("cmd.blockinfo.BlockType") + ": " + blockYPositive.Type); - sb.AppendLine("[Y " + Translations.TryGet("cmd.blockinfo.Negative") + "] " + Translations.TryGet("cmd.blockinfo.BlockType") + ": " + blockYNegative.Type); + sb.AppendLine("[Y " + Translations.TryGet("cmd.blockinfo.Positive") + "] " + Translations.TryGet("cmd.blockinfo.BlockType") + ": " + blockYPositive.GetTypeString()); + sb.AppendLine("[Y " + Translations.TryGet("cmd.blockinfo.Negative") + "] " + Translations.TryGet("cmd.blockinfo.BlockType") + ": " + blockYNegative.GetTypeString()); sb.AppendLine(" "); - sb.AppendLine("[Z " + Translations.TryGet("cmd.blockinfo.Positive") + "] " + Translations.TryGet("cmd.blockinfo.BlockType") + ": " + blockZPositive.Type); - sb.AppendLine("[Z " + Translations.TryGet("cmd.blockinfo.Negative") + "] " + Translations.TryGet("cmd.blockinfo.BlockType") + ": " + blockZNegative.Type); + sb.AppendLine("[Z " + Translations.TryGet("cmd.blockinfo.Positive") + "] " + Translations.TryGet("cmd.blockinfo.BlockType") + ": " + blockZPositive.GetTypeString()); + sb.AppendLine("[Z " + Translations.TryGet("cmd.blockinfo.Negative") + "] " + Translations.TryGet("cmd.blockinfo.BlockType") + ": " + blockZNegative.GetTypeString()); handler.Log.Info(sb.ToString()); } diff --git a/MinecraftClient/Commands/Dig.cs b/MinecraftClient/Commands/Dig.cs index ce825e98..59b9d79d 100644 --- a/MinecraftClient/Commands/Dig.cs +++ b/MinecraftClient/Commands/Dig.cs @@ -24,7 +24,7 @@ namespace MinecraftClient.Commands else if (block.Type == Material.Air) return Translations.Get("cmd.dig.no_block"); else if (handler.DigBlock(blockLoc, lookAtBlock: false)) - return Translations.Get("cmd.dig.dig", blockLoc.X, blockLoc.Y, blockLoc.Z, block.Type); + return Translations.Get("cmd.dig.dig", blockLoc.X, blockLoc.Y, blockLoc.Z, block.GetTypeString()); else return Translations.Get("cmd.dig.fail"); } @@ -42,7 +42,7 @@ namespace MinecraftClient.Commands else if (handler.DigBlock(blockToBreak)) { blockToBreak = blockToBreak.ToCenter(); - return Translations.Get("cmd.dig.dig", blockToBreak.X, blockToBreak.Y, blockToBreak.Z, block.Type); + return Translations.Get("cmd.dig.dig", blockToBreak.X, blockToBreak.Y, blockToBreak.Z, block.GetTypeString()); } else return Translations.Get("cmd.dig.fail"); diff --git a/MinecraftClient/Commands/Entitycmd.cs b/MinecraftClient/Commands/Entitycmd.cs index bb5783b6..64bfa6c1 100644 --- a/MinecraftClient/Commands/Entitycmd.cs +++ b/MinecraftClient/Commands/Entitycmd.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.Text; using MinecraftClient.Inventory; using MinecraftClient.Mapping; @@ -56,43 +57,44 @@ namespace MinecraftClient.Commands color = "§e"; // Yellow string location = String.Format("X:{0}, Y:{1}, Z:{2}", Math.Round(entity.Location.X, 2), Math.Round(entity.Location.Y, 2), Math.Round(entity.Location.Z, 2)); - string done = Translations.Replace("([cmd.entityCmd.entity]): {0}\n [MCC] Type: {1}", id, type); + StringBuilder done = new(); + done.Append(Translations.Replace("([cmd.entityCmd.entity]): {0}\n [MCC] Type: {1}", id, entity.GetTypeString())); if (!String.IsNullOrEmpty(nickname)) - done += Translations.Replace("\n [MCC] ([cmd.entityCmd.nickname]): {0}", nickname); + done.Append(Translations.Replace("\n [MCC] ([cmd.entityCmd.nickname]): {0}", nickname)); else if (!String.IsNullOrEmpty(customname)) - done += Translations.Replace("\n [MCC] ([cmd.entityCmd.customname]): {0}§8", customname.Replace("&", "§")); + done.Append(Translations.Replace("\n [MCC] ([cmd.entityCmd.customname]): {0}§8", customname.Replace("&", "§"))); if (type == EntityType.Player) - done += Translations.Replace("\n [MCC] ([cmd.entityCmd.latency]): {0}", latency); + done.Append(Translations.Replace("\n [MCC] ([cmd.entityCmd.latency]): {0}", latency)); else if (type == EntityType.Item || type == EntityType.ItemFrame || type == Mapping.EntityType.EyeOfEnder || type == Mapping.EntityType.Egg || type == Mapping.EntityType.EnderPearl || type == Mapping.EntityType.Potion || type == Mapping.EntityType.Fireball || type == Mapping.EntityType.FireworkRocket) { string? displayName = item.DisplayName; if (String.IsNullOrEmpty(displayName)) - done += Translations.Replace("\n [MCC] ([cmd.entityCmd.item]): {0} x{1}", item.Type, item.Count); + done.Append(Translations.Replace("\n [MCC] ([cmd.entityCmd.item]): {0} x{1}", item.GetTypeString(), item.Count)); else - done += Translations.Replace("\n [MCC] ([cmd.entityCmd.item]): {0} x{1} - {2}§8", item.Type, item.Count, displayName); + done.Append(Translations.Replace("\n [MCC] ([cmd.entityCmd.item]): {0} x{1} - {2}§8", item.GetTypeString(), item.Count, displayName)); } if (entity.Equipment.Count >= 1 && entity.Equipment != null) { - done += Translations.Replace("\n [MCC] ([cmd.entityCmd.equipment]):"); + done.Append(Translations.Replace("\n [MCC] ([cmd.entityCmd.equipment]):")); if (entity.Equipment.ContainsKey(0) && entity.Equipment[0] != null) - done += Translations.Replace("\n [MCC] ([cmd.entityCmd.mainhand]): {0} x{1}", entity.Equipment[0].Type, entity.Equipment[0].Count); + done.Append(Translations.Replace("\n [MCC] ([cmd.entityCmd.mainhand]): {0} x{1}", entity.Equipment[0].GetTypeString(), entity.Equipment[0].Count)); if (entity.Equipment.ContainsKey(1) && entity.Equipment[1] != null) - done += Translations.Replace("\n [MCC] ([cmd.entityCmd.offhand]): {0} x{1}", entity.Equipment[1].Type, entity.Equipment[1].Count); + done.Append(Translations.Replace("\n [MCC] ([cmd.entityCmd.offhand]): {0} x{1}", entity.Equipment[1].GetTypeString(), entity.Equipment[1].Count)); if (entity.Equipment.ContainsKey(5) && entity.Equipment[5] != null) - done += Translations.Replace("\n [MCC] ([cmd.entityCmd.helmet]): {0} x{1}", entity.Equipment[5].Type, entity.Equipment[5].Count); + done.Append(Translations.Replace("\n [MCC] ([cmd.entityCmd.helmet]): {0} x{1}", entity.Equipment[5].GetTypeString(), entity.Equipment[5].Count)); if (entity.Equipment.ContainsKey(4) && entity.Equipment[4] != null) - done += Translations.Replace("\n [MCC] ([cmd.entityCmd.chestplate]): {0} x{1}", entity.Equipment[4].Type, entity.Equipment[4].Count); + done.Append(Translations.Replace("\n [MCC] ([cmd.entityCmd.chestplate]): {0} x{1}", entity.Equipment[4].GetTypeString(), entity.Equipment[4].Count)); if (entity.Equipment.ContainsKey(3) && entity.Equipment[3] != null) - done += Translations.Replace("\n [MCC] ([cmd.entityCmd.leggings]): {0} x{1}", entity.Equipment[3].Type, entity.Equipment[3].Count); + done.Append(Translations.Replace("\n [MCC] ([cmd.entityCmd.leggings]): {0} x{1}", entity.Equipment[3].GetTypeString(), entity.Equipment[3].Count)); if (entity.Equipment.ContainsKey(2) && entity.Equipment[2] != null) - done += Translations.Replace("\n [MCC] ([cmd.entityCmd.boots]): {0} x{1}", entity.Equipment[2].Type, entity.Equipment[2].Count); + done.Append(Translations.Replace("\n [MCC] ([cmd.entityCmd.boots]): {0} x{1}", entity.Equipment[2].GetTypeString(), entity.Equipment[2].Count)); } - done += Translations.Replace("\n [MCC] ([cmd.entityCmd.pose]): {0}", pose); - done += Translations.Replace("\n [MCC] ([cmd.entityCmd.health]): {0}", color + health + "§8"); - done += Translations.Replace("\n [MCC] ([cmd.entityCmd.distance]): {0}", distance); - done += Translations.Replace("\n [MCC] ([cmd.entityCmd.location]): {0}", location); - return done; + done.Append(Translations.Replace("\n [MCC] ([cmd.entityCmd.pose]): {0}", pose)); + done.Append(Translations.Replace("\n [MCC] ([cmd.entityCmd.health]): {0}", color + health + "§8")); + done.Append(Translations.Replace("\n [MCC] ([cmd.entityCmd.distance]): {0}", distance)); + done.Append(Translations.Replace("\n [MCC] ([cmd.entityCmd.location]): {0}", location)); + return done.ToString(); } } else return Translations.Get("cmd.entityCmd.not_found"); @@ -132,10 +134,8 @@ namespace MinecraftClient.Commands else { Dictionary entities = handler.GetEntities(); - List response = new() - { - Translations.Get("cmd.entityCmd.entities") - }; + StringBuilder response = new(); + response.AppendLine(Translations.Get("cmd.entityCmd.entities")); foreach (var entity2 in entities) { int id = entity2.Key; @@ -149,16 +149,16 @@ namespace MinecraftClient.Commands string location = String.Format("X:{0}, Y:{1}, Z:{2}", Math.Round(entity2.Value.Location.X, 2), Math.Round(entity2.Value.Location.Y, 2), Math.Round(entity2.Value.Location.Z, 2)); if (type == EntityType.Item || type == EntityType.ItemFrame || type == EntityType.EyeOfEnder || type == EntityType.Egg || type == EntityType.EnderPearl || type == EntityType.Potion || type == EntityType.Fireball || type == EntityType.FireworkRocket) - response.Add(Translations.Replace(" #{0}: ([cmd.entityCmd.type]): {1}, ([cmd.entityCmd.item]): {2}, ([cmd.entityCmd.location]): {3}", id, type, item.Type, location)); + response.AppendLine(Translations.Replace(" #{0}: ([cmd.entityCmd.type]): {1}, ([cmd.entityCmd.item]): {2}, ([cmd.entityCmd.location]): {3}", id, entity2.Value.GetTypeString(), item.GetTypeString(), location)); else if (type == EntityType.Player && !String.IsNullOrEmpty(nickname)) - response.Add(Translations.Replace(" #{0}: ([cmd.entityCmd.type]): {1}, ([cmd.entityCmd.nickname]): §8{2}§8, ([cmd.entityCmd.latency]): {3}, ([cmd.entityCmd.health]): {4}, ([cmd.entityCmd.pose]): {5}, ([cmd.entityCmd.location]): {6}", id, type, nickname, latency, health, pose, location)); + response.AppendLine(Translations.Replace(" #{0}: ([cmd.entityCmd.type]): {1}, ([cmd.entityCmd.nickname]): §8{2}§8, ([cmd.entityCmd.latency]): {3}, ([cmd.entityCmd.health]): {4}, ([cmd.entityCmd.pose]): {5}, ([cmd.entityCmd.location]): {6}", id, entity2.Value.GetTypeString(), nickname, latency, health, pose, location)); else if (type == EntityType.Player && !String.IsNullOrEmpty(customname)) - response.Add(Translations.Replace(" #{0}: ([cmd.entityCmd.type]): {1}, ([cmd.entityCmd.customname]): §8{2}§8, ([cmd.entityCmd.latency]): {3}, ([cmd.entityCmd.health]): {4}, ([cmd.entityCmd.pose]): {5}, ([cmd.entityCmd.location]): {6}", id, type, customname.Replace("&", "§"), latency, health, pose, location)); + response.AppendLine(Translations.Replace(" #{0}: ([cmd.entityCmd.type]): {1}, ([cmd.entityCmd.customname]): §8{2}§8, ([cmd.entityCmd.latency]): {3}, ([cmd.entityCmd.health]): {4}, ([cmd.entityCmd.pose]): {5}, ([cmd.entityCmd.location]): {6}", id, entity2.Value.GetTypeString(), customname.Replace("&", "§"), latency, health, pose, location)); else - response.Add(Translations.Replace(" #{0}: ([cmd.entityCmd.type]): {1}, ([cmd.entityCmd.health]): {2}, ([cmd.entityCmd.location]): {3}", id, type, health, location)); + response.AppendLine(Translations.Replace(" #{0}: ([cmd.entityCmd.type]): {1}, ([cmd.entityCmd.health]): {2}, ([cmd.entityCmd.location]): {3}", id, entity2.Value.GetTypeString(), health, location)); } - response.Add(GetCmdDescTranslated()); - return String.Join("\n", response); + response.Append(GetCmdDescTranslated()); + return response.ToString(); } } else return Translations.Get("extra.entity_required"); diff --git a/MinecraftClient/Commands/Inventory.cs b/MinecraftClient/Commands/Inventory.cs index 11c214bf..f5f1a6c2 100644 --- a/MinecraftClient/Commands/Inventory.cs +++ b/MinecraftClient/Commands/Inventory.cs @@ -148,7 +148,7 @@ namespace MinecraftClient.Commands response.AppendLine(String.Format("{0} (#{1}):", inventories[invId].Title, invId)); foreach (Item item in itemsList) - response.AppendLine(String.Format("\t- {0}", item.ToString())); + response.AppendLine(String.Format("\t- {0}", item.ToFullString())); response.AppendLine(" "); } @@ -195,7 +195,7 @@ namespace MinecraftClient.Commands string hotbarString = isHotbar ? (hotbar + 1).ToString() : " "; if ((hotbar + 1) == selectedHotbar) hotbarString = ">" + hotbarString; - response.AppendLine(String.Format("{0,2} | #{1,-2}: {2}", hotbarString, itemId, item.ToString())); + response.AppendLine(String.Format("{0,2} | #{1,-2}: {2}", hotbarString, itemId, item.ToFullString())); } if (inventoryId == 0) diff --git a/MinecraftClient/ExtensionMethods.cs b/MinecraftClient/ExtensionMethods.cs new file mode 100644 index 00000000..f21b97bd --- /dev/null +++ b/MinecraftClient/ExtensionMethods.cs @@ -0,0 +1,12 @@ +using System.Linq; + +namespace MinecraftClient +{ + public static class ExtensionMethods + { + public static string ToUnderscoreCase(this string str) + { + return string.Concat(str.Select((x, i) => i > 0 && char.IsUpper(x) ? "_" + x.ToString() : x.ToString())).ToLower(); + } + } +} diff --git a/MinecraftClient/Inventory/EnchantmentMapping.cs b/MinecraftClient/Inventory/EnchantmentMapping.cs index d7797cc9..50f20b50 100644 --- a/MinecraftClient/Inventory/EnchantmentMapping.cs +++ b/MinecraftClient/Inventory/EnchantmentMapping.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using MinecraftClient.Protocol; using MinecraftClient.Protocol.Handlers; namespace MinecraftClient.Inventory @@ -136,50 +137,6 @@ namespace MinecraftClient.Inventory { 37, Enchantment.Mending }, { 38, Enchantment.VanishingCurse } }; - - private static Dictionary enchantmentNames = new Dictionary() - { - //type - { Enchantment.Protection, "Enchantment.Protection" }, - { Enchantment.FireProtection, "Enchantment.FireProtection" }, - { Enchantment.FeatherFalling, "Enchantment.FeatherFalling" }, - { Enchantment.BlastProtection, "Enchantment.BlastProtection" }, - { Enchantment.ProjectileProtection, "Enchantment.ProjectileProtection" }, - { Enchantment.Respiration, "Enchantment.Respiration" }, - { Enchantment.AquaAffinity, "Enchantment.AquaAffinity" }, - { Enchantment.Thorns, "Enchantment.Thorns" }, - { Enchantment.DepthStrieder, "Enchantment.DepthStrieder" }, - { Enchantment.FrostWalker, "Enchantment.FrostWalker" }, - { Enchantment.BindingCurse, "Enchantment.BindingCurse" }, - { Enchantment.SoulSpeed, "Enchantment.SoulSpeed" }, - { Enchantment.SwiftSneak, "Enchantment.SwiftSneak" }, - { Enchantment.Sharpness, "Enchantment.Sharpness" }, - { Enchantment.Smite, "Enchantment.Smite" }, - { Enchantment.BaneOfArthropods, "Enchantment.BaneOfArthropods" }, - { Enchantment.Knockback, "Enchantment.Knockback" }, - { Enchantment.FireAspect, "Enchantment.FireAspect" }, - { Enchantment.Looting, "Enchantment.Looting" }, - { Enchantment.Sweeping, "Enchantment.Sweeping" }, - { Enchantment.Efficency, "Enchantment.Efficency" }, - { Enchantment.SilkTouch, "Enchantment.SilkTouch" }, - { Enchantment.Unbreaking, "Enchantment.Unbreaking" }, - { Enchantment.Fortune, "Enchantment.Fortune" }, - { Enchantment.Power, "Enchantment.Power" }, - { Enchantment.Punch, "Enchantment.Punch" }, - { Enchantment.Flame, "Enchantment.Flame" }, - { Enchantment.Infinity, "Enchantment.Infinity" }, - { Enchantment.LuckOfTheSea, "Enchantment.LuckOfTheSea" }, - { Enchantment.Lure, "Enchantment.Lure" }, - { Enchantment.Loyality, "Enchantment.Loyality" }, - { Enchantment.Impaling, "Enchantment.Impaling" }, - { Enchantment.Riptide, "Enchantment.Riptide" }, - { Enchantment.Channeling, "Enchantment.Channeling" }, - { Enchantment.Multishot, "Enchantment.Multishot" }, - { Enchantment.QuickCharge, "Enchantment.QuickCharge" }, - { Enchantment.Piercing, "Enchantment.Piercing" }, - { Enchantment.Mending, "Enchantment.Mending" }, - { Enchantment.VanishingCurse, "Enchantment.VanishingCurse" } - }; #pragma warning restore format // @formatter:on public static Enchantment GetEnchantmentById(int protocolVersion, short id) @@ -202,10 +159,11 @@ namespace MinecraftClient.Inventory public static string GetEnchantmentName(Enchantment enchantment) { - if (!enchantmentNames.ContainsKey(enchantment)) + string? trans = ChatParser.TranslateString("enchantment.minecraft." + enchantment.ToString().ToUnderscoreCase()); + if (string.IsNullOrEmpty(trans)) return "Unknown Enchantment with ID: " + ((short)enchantment) + " (Probably not named in the code yet)"; - - return Translations.TryGet(enchantmentNames[enchantment]); + else + return trans; } public static string ConvertLevelToRomanNumbers(int num) diff --git a/MinecraftClient/Inventory/Item.cs b/MinecraftClient/Inventory/Item.cs index a3bac10a..fff591e5 100644 --- a/MinecraftClient/Inventory/Item.cs +++ b/MinecraftClient/Inventory/Item.cs @@ -3,10 +3,6 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; -using System.Text.RegularExpressions; -using System.Web; -using Microsoft.VisualBasic; -using MinecraftClient.Protocol; namespace MinecraftClient.Inventory { @@ -117,14 +113,14 @@ namespace MinecraftClient.Inventory } } - private string GetTranslatedType(ItemType itemType) + public string GetTypeString() { - string type = itemType.ToString(); - string type_renamed = string.Concat(type.Select((x, i) => i > 0 && char.IsUpper(x) ? "_" + x.ToString() : x.ToString())).ToLower(); - string? res1 = ChatParser.TranslateString("item.minecraft." + type_renamed); + string type = Type.ToString(); + string type_renamed = type.ToUnderscoreCase(); + string? res1 = Protocol.ChatParser.TranslateString("item.minecraft." + type_renamed); if (!string.IsNullOrEmpty(res1)) return res1; - string? res2 = ChatParser.TranslateString("block.minecraft." + type_renamed); + string? res2 = Protocol.ChatParser.TranslateString("block.minecraft." + type_renamed); if (!string.IsNullOrEmpty(res2)) return res2; return type; @@ -144,8 +140,8 @@ namespace MinecraftClient.Inventory short level = (short)enchantment["lvl"]; string id = ((string)enchantment["id"]).Replace(':', '.'); sb.AppendFormat(" | {0} {1}", - ChatParser.TranslateString("enchantment." + id) ?? id, - ChatParser.TranslateString("enchantment.level." + level) ?? level.ToString()); + Protocol.ChatParser.TranslateString("enchantment." + id) ?? id, + Protocol.ChatParser.TranslateString("enchantment.level." + level) ?? level.ToString()); } } } @@ -158,7 +154,7 @@ namespace MinecraftClient.Inventory { StringBuilder sb = new(); - sb.AppendFormat("x{0,-2} {1}", Count, GetTranslatedType(Type)); + sb.AppendFormat("x{0,-2} {1}", Count, GetTypeString()); string? displayName = DisplayName; if (!String.IsNullOrEmpty(displayName)) diff --git a/MinecraftClient/Mapping/Block.cs b/MinecraftClient/Mapping/Block.cs index 595356ab..065699a7 100644 --- a/MinecraftClient/Mapping/Block.cs +++ b/MinecraftClient/Mapping/Block.cs @@ -112,6 +112,13 @@ namespace MinecraftClient.Mapping blockIdAndMeta = typeAndMeta; } + public string GetTypeString() + { + string typeStr = Type.ToString(); + string? trans = Protocol.ChatParser.TranslateString("block.minecraft." + typeStr.ToUnderscoreCase()); + return string.IsNullOrEmpty(trans) ? typeStr : trans; + } + /// /// String representation of the block /// diff --git a/MinecraftClient/Mapping/Entity.cs b/MinecraftClient/Mapping/Entity.cs index bd19247b..fa7646b7 100644 --- a/MinecraftClient/Mapping/Entity.cs +++ b/MinecraftClient/Mapping/Entity.cs @@ -154,5 +154,12 @@ namespace MinecraftClient.Mapping Yaw = yaw * (1 / 256) * 360; // to angle in 360 degree Pitch = pitch * (1 / 256) * 360; } + + public string GetTypeString() + { + string typeStr = Type.ToString(); + string? trans = Protocol.ChatParser.TranslateString("entity.minecraft." + typeStr.ToUnderscoreCase()); + return string.IsNullOrEmpty(trans) ? typeStr : trans; + } } } diff --git a/MinecraftClient/Mapping/Location.cs b/MinecraftClient/Mapping/Location.cs index f535c724..5094648f 100644 --- a/MinecraftClient/Mapping/Location.cs +++ b/MinecraftClient/Mapping/Location.cs @@ -64,7 +64,7 @@ namespace MinecraftClient.Mapping /// /// Parse location from the string. - /// return NULL if the parsing fails. + /// throw FormatException if the parsing fails. /// /// The string representation of the X-axis coordinate. /// The string representation of the Y-axis coordinate. @@ -99,7 +99,7 @@ namespace MinecraftClient.Mapping /// /// Parse location from the string (relative coordinate representation is supported). - /// return NULL if the parsing fails. + /// throw FormatException if the parsing fails. /// /// Relative position base point. /// The string representation of the X-axis coordinate. diff --git a/MinecraftClient/Resources/lang/de.ini b/MinecraftClient/Resources/lang/de.ini index 391d6c490445a7dffa21bd468665a57327c13497..cc7b0f4eb6d1319868fb050fda57579299a99941 100644 GIT binary patch delta 360 zcmdn9f#tw5mJQ!rHrM&=u{LyK$YIE5NM^`pP+-Vp$YV$Y@^~4zfFijJDGYiHNpN|n z>}1C_>3WzRm<~OL0HD5Npa~^FT*i>fV2j@rpvitfRp|_gB%}KK>=4*ow=<7%@{aWaKn~aB3mas>^p_0= zlP~PzncTKRV{*twIgl882GHglhJwkBJ9H<1S|&32z(x_U+J@yKlRs<}+5BghLo5Jk Ceqhc3 delta 940 zcmZ{jv1{945XCPL5==0z3C1a*gwmmNwm=}%wkilosB5|H)FH7ITa_)lQccL1ExZ1Q zEM3wVI<>T&y7f=!*rj{t{_Z3@Az*~0Pj~OT_wL@O?^nxTu9vU>Iq9Fq#(Gm?8OaCn zrNc8|9i=~QvQJaxoTKzqi%${ND}>i=ul;BnmwK|NME|#v1ThSk&!8W zW8H+aOto%xyY}o!1HKrXue-_~dnWYiQQ6me8eR9~4D=~19_%`)Fh}=U$6z&@WV#BT z3_;_8Vz%laH2Z@6HLyBkRW|1CW;@CUAVxSA$_Z%RR(Qt-FGxw|fJfB~Octk~;Al(J@7D}566QX_V?iGj=G+AG_HHt1M)jJ_?y%d^6l*=Z} zmuB)R1=miAHTmiJg} zkyrl%b=^8?P*ta`^S*O>i$_!+7&4*fug;UoOCo_z8vip7dpUcPxc&nj-ZQ2nA`vX} r$mVO~32>&LMQ_j1^sn=CclzsMZ#(_{X=S=Ijh52Oj}LA>KYRNhbY|`H diff --git a/MinecraftClient/Resources/lang/en.ini b/MinecraftClient/Resources/lang/en.ini index bdcbb118..f9143844 100644 --- a/MinecraftClient/Resources/lang/en.ini +++ b/MinecraftClient/Resources/lang/en.ini @@ -159,46 +159,6 @@ Enchantment.middle_slot=Middle slot Enchantment.bottom_slot=Bottom slot Enchantment.levels=Levels -Enchantment.Protection=Protection -Enchantment.FireProtection=Fire Protection -Enchantment.FeatherFalling=Feather Falling -Enchantment.BlastProtection=Blast Protection -Enchantment.ProjectileProtection=Projectile Protection -Enchantment.Respiration=Respiration -Enchantment.AquaAffinity=Aqua Affinity -Enchantment.Thorns=Thorns -Enchantment.DepthStrieder=Depth Strieder -Enchantment.FrostWalker=Frost Walker -Enchantment.BindingCurse=Curse of Binding -Enchantment.SoulSpeed=Soul Speed -Enchantment.SwiftSneak=Swift Sneak -Enchantment.Sharpness=Sharpness -Enchantment.Smite=Smite -Enchantment.BaneOfArthropods=Bane of Arthropods -Enchantment.Knockback=Knockback -Enchantment.FireAspect=Fire Aspect -Enchantment.Looting=Looting -Enchantment.Sweeping=Sweeping -Enchantment.Efficency=Efficency -Enchantment.SilkTouch=Silk Touch -Enchantment.Unbreaking=Unbreaking -Enchantment.Fortune=Fortune -Enchantment.Power=Power -Enchantment.Punch=Punch -Enchantment.Flame=Flame -Enchantment.Infinity=Infinity -Enchantment.LuckOfTheSea=Luck of the Sea -Enchantment.Lure=Lure -Enchantment.Loyality=Loyality -Enchantment.Impaling=Impaling -Enchantment.Riptide=Riptide -Enchantment.Channeling=Channeling -Enchantment.Multishot=Multishot -Enchantment.QuickCharge=Quick Charge -Enchantment.Piercing=Piercing -Enchantment.Mending=Mending -Enchantment.VanishingCurse=Curse of Vanishing - [forge] # Messages from Forge handler forge.version=§8Forge protocol version : {0} @@ -587,7 +547,7 @@ bot.autoDrop.no_inventory=Cannot find inventory {0}! # AutoFish bot.autoFish.no_inv_handle=Inventory handling is not enabled. Cannot check rod durability and switch rods. -bot.autoFish.start=Fishing will start in {0:0.0} second(s). +bot.autoFish.start_at=Fishing will start in {0:0.0} second(s). bot.autoFish.throw=Casting successfully. bot.autoFish.caught=Retract the fishing rod. (Count: {0}) bot.autoFish.caught_at=Retract the fishing rod at ({0:0.0},{1:0.0},{2:0.0})! (Count: {3}) diff --git a/MinecraftClient/Resources/lang/fr.ini b/MinecraftClient/Resources/lang/fr.ini index 07d5617ad98ffce2a09ad1406dcf9ad4691c35a1..3ab0cab983214dd5238fa908a84f24142dbce169 100644 GIT binary patch delta 364 zcmaE~pXJR~mJJ;4nvsP)WQ_;eKbdi_;$)w_msrz*l3?CuxqZ_ZCv)tTnw+#%X7ar~ uT$4qX%S_JNDgtIJ?bVtruuTrkzOq#dOtWp%fT(L0ne4SqWb={zatQ!QYG9H8 delta 950 zcmZ{j!DbnhmqUJ+XwJ5{%~$ut=!nZy}`6kPfS1G;qQ zRw2}Y8{a@%AHanRS1x=3!S9@zq*4gO%-lKWzvutY`S1KbS^W8B@nhj$`rfUsG$odS zybxbnJOkEI`p&JdIo2`J`FURs*wFp&6^b1K}-;?HKxz4>g_ zJ#vW*O_Q?Dbk^$fTt+a}<%mo91MkSZ^-DQ6rtj<`K4Y}Ldj>-cN0~`zG5HxSAKJ~0_v%=Bz%x#pmL8`+u zZ_27pwdy=`zbbe0`L&2gRI~}wT|jT4>{DSxv}@fx0&$2Y>+8Hm$$?V6Bl6Zuu}MU^ zY{GnLCa+R-c0&3YvV5P+1^;T>#u?fq)Jvaf!l@cAX$}RtE^CL!%t6mz?mhMT^q0l* z9!q=V)&D?Uw@$XGs?*ka|95&zJ5=u(GNI>h?ndkk8!faYJo{x zc_s&~kpihHSz`dA!nSBlzOqIR#Qe2J3q*ZbBr@4ytq6$Ov{+u zL)LNj$=O(UStms2=Y82_M*t=fmvxUTlvujD|4x&yT}eUAsqi3=znwAn=Cjqd$)z$h zP0BjcS#QWY8Nt+$eJ$seeOZ+QGBnK|&jh3|9qvT4HJ8Z16u-7^ zqG_hyw7MO8cEy1&0q5(ks>hxYy?RvkwVp;-Jox~69~KXGom5ny1J(&xji$M-k|%x8 zc%Yb#CJ4N5}n9E)TRG;gau^{ipD!qM!bbFaJ!QXQUoQ&DxQ zRp(jwRee&-uT4CrqD_$QLVAm2hYBO2fpzy1#2%Wguge-`7nJH9k+)t-Eh5Tg6Xr`Z zMU|3kC#0VvD^JP%=U;u(I3t^cdg(JwI90<{&7nZo747hVIq3N-yr*8D{_$^owm;VpVM33qI%DeDLq%6`?VKDLY*}J=N@(o_7-vd2im-+Oj|@^SZ0y+ zSH=_KOpr$}&(Y+>Iej!qK7V$qd;H3JjSHc?@Yl9xnqIP$ZWjg+Y%Y2`&$n zovhd?S&tzKR2cx&SqwCz1c=KRQWq1d!bZrYg_?4{Lb(2lHYY?xVd)xoO zew>Bedgxht^ynYc`kUEJltNf`_uZN2o#&Z(-u-nod-HYn=B$=}Uw<**lvw(5E}pb_ z2CSoWrnbE3u#SmN&wFyr4j)V`4(l#gAdz%*|5AgmV@W_vsj!;G&nC>>>1>rfa)}H~ zld?{9R_pRbhA`FTluP*o@|UV%ZXb1h)J2l$_rhDM3{11jGY08Nn>*HQ#Uau+#h#;`B0i}9}}ZbP`zu&gr3)GuPVDl0-ZGeXC8KP_9k)t2U@(xOgls(SSFFh ukH!<=jGsjx&(Y|xcKBv=e{uUd{rlr(dVBpRJ-B{0`u*)_X5|08`}_b+d(<5O diff --git a/MinecraftClient/Resources/lang/zh-Hans.ini b/MinecraftClient/Resources/lang/zh-Hans.ini index 7b7dca5ce4f581b44775970384314dc75f23737d..fbef68787d016992e84f86661f58ff9f80526fe2 100644 GIT binary patch delta 303 zcmZ2-nq}WUmJNq=HhY=qnAAHl6ov1iAW=dHB}6GwieNXh6kI3O0kOr{sk&~GX);bSi8BW28wlbm;uH7) zLKfY1(XBp|-?=kMix7sH`RCsA-*fIg|6E`1{Q9%=`zBca2p;bCEVr3`w%7(d6V}=C zd$7M3vd)Qa&&PJojxm_rLe>+m#4;Oc|Kl!S=T?B&QsJ{tj5pSjy(y!*WOSHHaCGrPc?{+pDiV>-em2bonhfs2_ur!y9iJQYWpNXXRJ( zWi`J6@r;T-LAp!mEwwW$EQpT1yLTY^X!5>pYt%zf(z_t2^Wd8H7ee9g6PeNYCOcPFNxThQnv~H-wOXi^SS9wppDgBkPs>k{%dHJ8nb?@Ye zs+zXuedqMnPpCd|WI@jd!IRcoB8euA|D}hcioHi%|G&6o${jB1M9Th%KRr1k%kcyXdZrX(yCeVjSCU8+D@7(b3LCf^U#jHbR$u zfo?*5fIdLi-S-i?$OH5{XGVpB3^Q}@Isg6tbIyP7eij~n74H8ys~^sjYDW^8$+ZMB z;2W}zSKpn+p~pHQx<4PtB`3yU67g71ctVL~r01Wt*j-8rVh_XfEdF_`JlU^S>yk@l zZZ)auw$8dMUu1!jD_1zpEugC4U^z-lzjsw(<2 z1%0i2jTU*$opag+sq@vU=DfoUUpWIY!>vgAp!pm3#xK|AgqthZX&$ses=HfX%37ON zsiRB!!&|L(NTF25sM>EQ?S dGQ^K@hTGg63D&=z(--TP{ZGg1Z?}KH{sZSP*%AN% diff --git a/README.md b/README.md index df6550b4..7d49547e 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,13 @@ If you'd like to contribute to Minecraft Console Client, great, just fork the re Check out: [How to update or add translations for MCC](https://mccteam.github.io/guide/contibuting.html#translations). MCC now supports the following languages (Alphabetical order) : - * `de.ini` (49.19% translated) : Deutsch - German + * `de.ini` (51.34% translated) : Deutsch - German * `en.ini` : English - English - * `fr.ini` (49.19% translated) : Français (France) - French - * `ru.ini` (48.38% translated) : Русский (Russkiy) - Russian - * `vi.ini` (48.38% translated) : Tiếng Việt (Việt Nam) - Vietnamese - * `zh-Hans.ini` (90.43% translated) : 简体中文 - Chinese Simplified - * `zh-Hant.ini` (90.43% translated) : 繁體中文 - Chinese Traditional + * `fr.ini` (51.34% translated) : Français (France) - French + * `ru.ini` (50.49% translated) : Русский (Russkiy) - Russian + * `vi.ini` (50.49% translated) : Tiếng Việt (Việt Nam) - Vietnamese + * `zh-Hans.ini` (95.50% translated) : 简体中文 - Chinese Simplified + * `zh-Hant.ini` (95.50% translated) : 繁體中文 - Chinese Traditional ## Building from the source 🏗️