diff --git a/MinecraftClient/Inventory/Item.cs b/MinecraftClient/Inventory/Item.cs index d0c523b3..70b736dd 100644 --- a/MinecraftClient/Inventory/Item.cs +++ b/MinecraftClient/Inventory/Item.cs @@ -46,10 +46,7 @@ namespace MinecraftClient.Inventory /// TRUE if the item is empty public bool IsEmpty { - get - { - return Type == ItemType.Air || Count == 0; - } + get { return Type == ItemType.Air || Count == 0; } } /// @@ -61,13 +58,15 @@ namespace MinecraftClient.Inventory { if (NBT != null && NBT.ContainsKey("display")) { - if (NBT["display"] is Dictionary displayProperties && displayProperties.ContainsKey("Name")) + if (NBT["display"] is Dictionary displayProperties && + displayProperties.ContainsKey("Name")) { string? displayName = displayProperties["Name"] as string; if (!String.IsNullOrEmpty(displayName)) return ChatParser.ParseText(displayProperties["Name"].ToString() ?? string.Empty); } } + return null; } } @@ -82,15 +81,17 @@ namespace MinecraftClient.Inventory List lores = new(); if (NBT != null && NBT.ContainsKey("display")) { - if (NBT["display"] is Dictionary displayProperties && displayProperties.ContainsKey("Lore")) + if (NBT["display"] is Dictionary displayProperties && + displayProperties.ContainsKey("Lore")) { object[] displayName = (object[])displayProperties["Lore"]; lores.AddRange(from string st in displayName - let str = ChatParser.ParseText(st.ToString()) - select str); + let str = ChatParser.ParseText(st.ToString()) + select str); return lores.ToArray(); } } + return null; } } @@ -107,9 +108,11 @@ namespace MinecraftClient.Inventory object damage = NBT["Damage"]; if (damage != null) { - return int.Parse(damage.ToString() ?? string.Empty, NumberStyles.Any, CultureInfo.CurrentCulture); + return int.Parse(damage.ToString() ?? string.Empty, NumberStyles.Any, + CultureInfo.CurrentCulture); } } + return 0; } } @@ -139,19 +142,28 @@ namespace MinecraftClient.Inventory try { - if (NBT != null && (NBT.TryGetValue("Enchantments", out object? enchantments) || NBT.TryGetValue("StoredEnchantments", out enchantments))) + if (NBT != null && (NBT.TryGetValue("Enchantments", out object? enchantments) || + NBT.TryGetValue("StoredEnchantments", out enchantments))) { foreach (Dictionary enchantment in (object[])enchantments) { 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()); + ChatParser.TranslateString("enchantment." + id) ?? id, + ChatParser.TranslateString("enchantment.level." + level) ?? level.ToString()); } } + + if (Lores != null && Lores.Length > 0) + { + foreach (var lore in Lores) + sb.AppendFormat(" | {0}", lore); + } + } + catch (Exception) + { } - catch (Exception) { } return sb.ToString(); } @@ -173,4 +185,4 @@ namespace MinecraftClient.Inventory return sb.ToString(); } } -} +} \ No newline at end of file