diff --git a/MinecraftClient/Commands/Inventory.cs b/MinecraftClient/Commands/Inventory.cs index 81e90bc8..5821df68 100644 --- a/MinecraftClient/Commands/Inventory.cs +++ b/MinecraftClient/Commands/Inventory.cs @@ -65,7 +65,7 @@ namespace MinecraftClient.Commands else return Translations.Get("cmd.inventory.need_creative"); } - else + else return GetCmdDescTranslated(); } else if (args[0].ToLower().StartsWith("p")) @@ -82,6 +82,79 @@ namespace MinecraftClient.Commands else return Translations.Get("cmd.inventory.container_not_found"); } + else if (args[0].ToLower().StartsWith("inventories") || args[0].ToLower().StartsWith("i")) + { + Dictionary inventories = handler.GetInventories(); + List availableIds = inventories.Keys.ToList(); + StringBuilder response = new(); + response.AppendLine(Translations.Get("cmd.inventory.inventories_available")); + + foreach (int id in availableIds) + response.AppendLine(String.Format(" #{0} - {1}§8", id, inventories[id].Title)); + + return response.ToString(); + } + else if (args[0].ToLower().StartsWith("search") || args[0].ToLower().StartsWith("s")) + { + if (args.Length < 2) + return GetCmdDescTranslated(); + + if (!Enum.TryParse(args[1], true, out ItemType parsedItemType)) + return GetCmdDescTranslated(); + + bool shouldUseItemCount = args.Length >= 3; + int itemCount = 0; + + if (shouldUseItemCount && !int.TryParse(args[2], out itemCount)) + return GetCmdDescTranslated(); + + Dictionary inventories = handler.GetInventories(); + Dictionary> foundItems = new(); + + List availableInventories = inventories.Values.ToList(); + + availableInventories.ForEach(inventory => + { + inventory.Items.Values + .ToList() + .FindAll(item => item.Type == parsedItemType && (shouldUseItemCount ? item.Count == itemCount : true)) + .ForEach(item => + { + if (!foundItems.ContainsKey(inventory.ID)) + { + foundItems.Add(inventory.ID, new List() { item }); + return; + } + + List invItems = foundItems[inventory.ID]; + invItems.Add(item); + foundItems.Remove(inventory.ID); + foundItems.Add(inventory.ID, invItems); + }); + }); + + if (foundItems.Count == 0) + return Translations.Get("cmd.inventory.no_found_items"); + + StringBuilder response = new(); + + response.AppendLine(Translations.Get("cmd.inventory.found_items") + ":"); + + foreach ((int invId, List itemsList) in new SortedDictionary>(foundItems)) + { + if (itemsList.Count > 0) + { + 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(" "); + } + } + + return response.ToString(); + } else if (args[0].ToLower() == "help") { if (args.Length >= 2) @@ -195,7 +268,7 @@ namespace MinecraftClient.Commands return response.ToString(); } } - else + else return Translations.Get("extra.inventory_required"); } @@ -228,6 +301,8 @@ namespace MinecraftClient.Commands "drop" => Translations.Get("cmd.inventory.help.drop") + usageStr + "/inventory > drop [all]\nAll means drop full stack", "creativegive" => Translations.Get("cmd.inventory.help.creativegive") + usageStr + "/inventory creativegive ", "creativedelete" => Translations.Get("cmd.inventory.help.creativedelete") + usageStr + "/inventory creativedelete ", + "inventories" => Translations.Get("cmd.inventory.help.inventories") + usageStr + "/inventory inventories", + "search" => Translations.Get("cmd.inventory.help.search") + usageStr + "/inventory search [count]", "help" => GetHelp(), _ => Translations.Get("cmd.inventory.help.unknown") + GetAvailableActions(), }; diff --git a/MinecraftClient/DefaultConfigResource.Designer.cs b/MinecraftClient/DefaultConfigResource.Designer.cs index 5c5c6e54..d3dfe630 100644 --- a/MinecraftClient/DefaultConfigResource.Designer.cs +++ b/MinecraftClient/DefaultConfigResource.Designer.cs @@ -8,10 +8,11 @@ // //------------------------------------------------------------------------------ -namespace MinecraftClient { +namespace MinecraftClient +{ using System; - - + + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -22,44 +23,52 @@ namespace MinecraftClient { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class DefaultConfigResource { - + public class DefaultConfigResource + { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal DefaultConfigResource() { + internal DefaultConfigResource() + { } - + /// /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { + public static global::System.Resources.ResourceManager ResourceManager + { + get + { + if (object.ReferenceEquals(resourceMan, null)) + { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MinecraftClient.DefaultConfigResource", typeof(DefaultConfigResource).Assembly); resourceMan = temp; } return resourceMan; } } - + /// /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { - get { + public static global::System.Globalization.CultureInfo Culture + { + get + { return resourceCulture; } - set { + set + { resourceCulture = value; } } - + /// /// Looks up a localized string similar to ╔═════════════════════════════════════╗ ///║ Brewing Stand ║ @@ -75,12 +84,14 @@ namespace MinecraftClient { ///║║ 5 ║ 6 ║ 7 ║ 8 ║ 9 ║10 ║11 ║12 ║13 ║║ ///║╠═══╬═══╬═══╬═══╬═══╬═══╬═══╬══ [rest of string was truncated]";. /// - public static string ContainerType_BrewingStand { - get { + public static string ContainerType_BrewingStand + { + get + { return ResourceManager.GetString("ContainerType_BrewingStand", resourceCulture); } } - + /// /// Looks up a localized string similar to ╔═════════════════════════════════════╗ ///║ Crafting ║ @@ -96,12 +107,22 @@ namespace MinecraftClient { ///║║10 ║11 ║12 ║13 ║14 ║15 ║16 ║17 ║18 ║║ ///║╠═══╬═══╬═══╬═══╬═══╬═══╬═══╬══ [rest of string was truncated]";. /// - public static string ContainerType_Crafting { - get { + public static string ContainerType_Crafting + { + get + { return ResourceManager.GetString("ContainerType_Crafting", resourceCulture); } } - + + public static string ContainerType_Furnace + { + get + { + return ResourceManager.GetString("ContainerType_Furnace", resourceCulture); + } + } + /// /// Looks up a localized string similar to ╔═════════════════════════════════════╗ ///║ Container ║ @@ -117,12 +138,14 @@ namespace MinecraftClient { ///║║ 9 ║10 ║11 ║12 ║13 ║14 ║15 ║16 ║17 ║║ ///║╠═══╬═══╬═══╬═══╬═══╬═══╬═══╬══ [rest of string was truncated]";. /// - public static string ContainerType_Generic_3x3 { - get { + public static string ContainerType_Generic_3x3 + { + get + { return ResourceManager.GetString("ContainerType_Generic_3x3", resourceCulture); } } - + /// /// Looks up a localized string similar to ╔═════════════════════════════════════╗ ///║ Chest ║ @@ -138,12 +161,14 @@ namespace MinecraftClient { ///║║27 ║28 ║29 ║30 ║31 ║32 ║33 ║34 ║35 ║║ ///║╠═══╬═══╬═══╬═══╬═══╬═══╬═══╬══ [rest of string was truncated]";. /// - public static string ContainerType_Generic_9x3 { - get { + public static string ContainerType_Generic_9x3 + { + get + { return ResourceManager.GetString("ContainerType_Generic_9x3", resourceCulture); } } - + /// /// Looks up a localized string similar to ╔═════════════════════════════════════╗ ///║ Large Container ║ @@ -159,12 +184,30 @@ namespace MinecraftClient { ///║║36 ║37 ║38 ║39 ║40 ║41 ║42 ║43 ║44 ║║ ///║╠═══╬═══╬═══╬═══╬═══╬═══╬═══╬══ [rest of string was truncated]";. /// - public static string ContainerType_Generic_9x6 { - get { + public static string ContainerType_Generic_9x6 + { + get + { return ResourceManager.GetString("ContainerType_Generic_9x6", resourceCulture); } } - + + public static string ContainerType_Grindstone + { + get + { + return ResourceManager.GetString("ContainerType_Grindstone", resourceCulture); + } + } + + public static string ContainerType_Hopper + { + get + { + return ResourceManager.GetString("ContainerType_Hopper", resourceCulture); + } + } + /// /// Looks up a localized string similar to ╔═════════════════════════════════════╗ ///║╔═══╦═══════════╗ ║ @@ -180,12 +223,14 @@ namespace MinecraftClient { ///║║ 9 ║10 ║11 ║12 ║13 ║14 ║15 ║16 ║17 ║║ ///║╠═══╬═══╬═══╬═══╬═══╬═══╬═══╬══ [rest of string was truncated]";. /// - public static string ContainerType_PlayerInventory { - get { + public static string ContainerType_PlayerInventory + { + get + { return ResourceManager.GetString("ContainerType_PlayerInventory", resourceCulture); } } - + /// /// Looks up a localized string similar to # Startup Config File /// @@ -208,12 +253,14 @@ namespace MinecraftClient { ///internalcmdchar=slash # Use 'none', 'slash' or 'backslash' ///messagec [rest of string was truncated]";. /// - public static string MinecraftClient { - get { + public static string MinecraftClient + { + get + { return ResourceManager.GetString("MinecraftClient", resourceCulture); } } - + /// /// Looks up a localized string similar to [mcc] ///# Messages from MCC itself @@ -229,8 +276,10 @@ namespace MinecraftClient { ///mcc.ip=Server IP : ///mcc.use_version=§8Using Minecraft version [rest of string was truncated]";. /// - public static string TranslationEnglish { - get { + public static string TranslationEnglish + { + get + { return ResourceManager.GetString("TranslationEnglish", resourceCulture); } } diff --git a/MinecraftClient/DefaultConfigResource.resx b/MinecraftClient/DefaultConfigResource.resx index 0aceda18..ed1a6338 100644 --- a/MinecraftClient/DefaultConfigResource.resx +++ b/MinecraftClient/DefaultConfigResource.resx @@ -124,6 +124,9 @@ Resources\containers\ContainerType.Crafting.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + + Resources\containers\ContainerType.Furnace.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + Resources\containers\ContainerType.Generic_3x3.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 @@ -133,6 +136,12 @@ Resources\containers\ContainerType.Generic_9x6.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + + Resources\containers\ContainerType.Grindstone.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + + + Resources\containers\ContainerType.Hopper.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + Resources\containers\ContainerType.PlayerInventory.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 @@ -142,4 +151,4 @@ Resources\lang\en.ini;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 - + \ No newline at end of file diff --git a/MinecraftClient/Inventory/ContainerType.cs b/MinecraftClient/Inventory/ContainerType.cs index eb4c3ddd..1bb101d6 100644 --- a/MinecraftClient/Inventory/ContainerType.cs +++ b/MinecraftClient/Inventory/ContainerType.cs @@ -28,6 +28,7 @@ namespace MinecraftClient.Inventory Loom, Merchant, ShulkerBox, + SmightingTable, Smoker, Cartography, Stonecutter, diff --git a/MinecraftClient/Inventory/ContainerTypeExtensions.cs b/MinecraftClient/Inventory/ContainerTypeExtensions.cs index 2ef20660..373bbb15 100644 --- a/MinecraftClient/Inventory/ContainerTypeExtensions.cs +++ b/MinecraftClient/Inventory/ContainerTypeExtensions.cs @@ -55,21 +55,21 @@ namespace MinecraftClient.Inventory case ContainerType.Generic_9x6: return DefaultConfigResource.ContainerType_Generic_9x6; case ContainerType.Generic_3x3: return DefaultConfigResource.ContainerType_Generic_3x3; case ContainerType.Crafting: return DefaultConfigResource.ContainerType_Crafting; - case ContainerType.BlastFurnace: return null; - case ContainerType.Furnace: return null; - case ContainerType.Smoker: return null; + case ContainerType.BlastFurnace: return DefaultConfigResource.ContainerType_Furnace; + case ContainerType.Furnace: return DefaultConfigResource.ContainerType_Furnace; + case ContainerType.Smoker: return DefaultConfigResource.ContainerType_Furnace; case ContainerType.Enchantment: return null; case ContainerType.BrewingStand: return DefaultConfigResource.ContainerType_BrewingStand; case ContainerType.Merchant: return null; case ContainerType.Beacon: return null; case ContainerType.Anvil: return null; - case ContainerType.Hopper: return null; - case ContainerType.ShulkerBox: return null; + case ContainerType.Hopper: return DefaultConfigResource.ContainerType_Hopper; + case ContainerType.ShulkerBox: return DefaultConfigResource.ContainerType_Generic_9x3; case ContainerType.Loom: return null; case ContainerType.Stonecutter: return null; case ContainerType.Lectern: return null; case ContainerType.Cartography: return null; - case ContainerType.Grindstone: return null; + case ContainerType.Grindstone: return DefaultConfigResource.ContainerType_Grindstone; case ContainerType.Unknown: return null; default: return null; } diff --git a/MinecraftClient/Resources/containers/ContainerType.Furnace.txt b/MinecraftClient/Resources/containers/ContainerType.Furnace.txt new file mode 100644 index 00000000..f0b7570a --- /dev/null +++ b/MinecraftClient/Resources/containers/ContainerType.Furnace.txt @@ -0,0 +1,23 @@ +╔═════════════════════════════════════╗ +║ Container ║ +║ ╔═══╗ ║ +║ ║ 0 ║ ║ +║ ╚═══╝ ╔═══╗ ║ +║ ⠂⡠⢂ ━━▶ ║ 2 ║ ║ +║ ⠂⡠⢂ ╚═══╝ ║ +║ ╔═══╗ ║ +║ ║ 1 ║ ║ +║ ╚═══╝ ║ +║ Inventory ║ +║╔═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╗║ +║║ 3 ║ 4 ║ 5 ║ 6 ║ 7 ║ 8 ║ 9 ║10 ║11 ║║ +║╠═══╬═══╬═══╬═══╬═══╬═══╬═══╬═══╬═══╣║ +║║12 ║13 ║14 ║15 ║16 ║17 ║18 ║19 ║20 ║║ +║╠═══╬═══╬═══╬═══╬═══╬═══╬═══╬═══╬═══╣║ +║║21 ║22 ║23 ║24 ║25 ║26 ║27 ║38 ║29 ║║ +║╚═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╝║ +║╔═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╗║ +║║30 ║31 ║32 ║33 ║34 ║35 ║36 ║37 ║38 ║║ +║╚═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╝║ +║ 1 2 3 4 5 6 7 8 9 ║ +╚═════════════════════════════════════╝ \ No newline at end of file diff --git a/MinecraftClient/Resources/containers/ContainerType.Grindstone.txt b/MinecraftClient/Resources/containers/ContainerType.Grindstone.txt new file mode 100644 index 00000000..f70373e9 --- /dev/null +++ b/MinecraftClient/Resources/containers/ContainerType.Grindstone.txt @@ -0,0 +1,26 @@ +╔═════════════════════════════════════╗ +║ Repair & Disenchant ║ +║ ╔═════════╗ ║ +║ ║ ╔═══╗ ║ ║ +║ ╔══║ ║ 0 ║ ║══╗ ║ +║ ║ ║ ╚═══╝ ║ ║ ║ +║ ║ ║ ╔═══╗ ║ ║ ╔═══╗ ║ +║ ║ ║ ║ 1 ║ ║ ║ ━━▶ ║ 2 ║ ║ +║ ║ ║ ╚═══╝ ║ ║ ╚═══╝ ║ +║ ║ ╠═════════╣ ║ ║ +║ ║ ║ ║ ║ ║ +║ ╚══╝ ╚══╝ ║ +║ ║ +║ Inventory ║ +║╔═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╗║ +║║ 3 ║ 4 ║ 5 ║ 6 ║ 7 ║ 8 ║ 9 ║10 ║11 ║║ +║╠═══╬═══╬═══╬═══╬═══╬═══╬═══╬═══╬═══╣║ +║║12 ║13 ║14 ║15 ║16 ║17 ║18 ║19 ║20 ║║ +║╠═══╬═══╬═══╬═══╬═══╬═══╬═══╬═══╬═══╣║ +║║21 ║22 ║23 ║24 ║25 ║26 ║27 ║38 ║29 ║║ +║╚═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╝║ +║╔═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╗║ +║║30 ║31 ║32 ║33 ║34 ║35 ║36 ║37 ║38 ║║ +║╚═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╝║ +║ 1 2 3 4 5 6 7 8 9 ║ +╚═════════════════════════════════════╝ \ No newline at end of file diff --git a/MinecraftClient/Resources/containers/ContainerType.Hopper.txt b/MinecraftClient/Resources/containers/ContainerType.Hopper.txt new file mode 100644 index 00000000..c14263a6 --- /dev/null +++ b/MinecraftClient/Resources/containers/ContainerType.Hopper.txt @@ -0,0 +1,18 @@ +╔═════════════════════════════════════╗ +║ Container ║ +║ ╔═══╦═══╦═══╦═══╦═══╗ ║ +║ ║ 0 ║ 1 ║ 2 ║ 3 ║ 4 ║ ║ +║ ╚═══╩═══╩═══╩═══╩═══╝ ║ +║ Inventory ║ +║╔═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╗║ +║║ 5 ║ 6 ║ 7 ║ 8 ║ 9 ║10 ║11 ║12 ║13 ║║ +║╠═══╬═══╬═══╬═══╬═══╬═══╬═══╬═══╬═══╣║ +║║14 ║15 ║16 ║17 ║18 ║19 ║20 ║21 ║22 ║║ +║╠═══╬═══╬═══╬═══╬═══╬═══╬═══╬═══╬═══╣║ +║║23 ║24 ║25 ║26 ║27 ║28 ║29 ║30 ║31 ║║ +║╚═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╝║ +║╔═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╗║ +║║32 ║33 ║34 ║35 ║36 ║37 ║38 ║39 ║40 ║║ +║╚═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╝║ +║ 1 2 3 4 5 6 7 8 9 ║ +╚═════════════════════════════════════╝ \ No newline at end of file diff --git a/MinecraftClient/Resources/lang/en.ini b/MinecraftClient/Resources/lang/en.ini index 3bb04f5f..e27e1ca9 100644 --- a/MinecraftClient/Resources/lang/en.ini +++ b/MinecraftClient/Resources/lang/en.ini @@ -305,6 +305,7 @@ cmd.inventory.close_fail=Failed to close Inventory #{0} cmd.inventory.not_exist=Inventory #{0} do not exist cmd.inventory.inventory=Inventory cmd.inventory.inventories=Inventories +cmd.inventory.inventories_available=Available Inventories cmd.inventory.hotbar=Your selected hotbar is {0} cmd.inventory.damage=Damage cmd.inventory.left=Left @@ -328,7 +329,11 @@ cmd.inventory.help.shiftclick=Shift click an item. cmd.inventory.help.drop=Drop an item from inventory. cmd.inventory.help.creativegive=Give item in creative mode. cmd.inventory.help.creativedelete=Clear slot in creative mode. +cmd.inventory.help.inventories=List avaliable inventories +cmd.inventory.help.search=Search for an item in avaliable Inventories cmd.inventory.help.unknown=Unknown action. +cmd.inventory.found_items=Found items +cmd.inventory.no_found_items=Could not find the specified item in any of avaliable Inventories! # List cmd.list.desc=get the player list.