mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Added item lore/description to be displayed in the list of items in the inventory
This commit is contained in:
parent
3570ef605e
commit
df6eeb9b4a
1 changed files with 26 additions and 14 deletions
|
|
@ -46,10 +46,7 @@ namespace MinecraftClient.Inventory
|
||||||
/// <returns>TRUE if the item is empty</returns>
|
/// <returns>TRUE if the item is empty</returns>
|
||||||
public bool IsEmpty
|
public bool IsEmpty
|
||||||
{
|
{
|
||||||
get
|
get { return Type == ItemType.Air || Count == 0; }
|
||||||
{
|
|
||||||
return Type == ItemType.Air || Count == 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -61,13 +58,15 @@ namespace MinecraftClient.Inventory
|
||||||
{
|
{
|
||||||
if (NBT != null && NBT.ContainsKey("display"))
|
if (NBT != null && NBT.ContainsKey("display"))
|
||||||
{
|
{
|
||||||
if (NBT["display"] is Dictionary<string, object> displayProperties && displayProperties.ContainsKey("Name"))
|
if (NBT["display"] is Dictionary<string, object> displayProperties &&
|
||||||
|
displayProperties.ContainsKey("Name"))
|
||||||
{
|
{
|
||||||
string? displayName = displayProperties["Name"] as string;
|
string? displayName = displayProperties["Name"] as string;
|
||||||
if (!String.IsNullOrEmpty(displayName))
|
if (!String.IsNullOrEmpty(displayName))
|
||||||
return ChatParser.ParseText(displayProperties["Name"].ToString() ?? string.Empty);
|
return ChatParser.ParseText(displayProperties["Name"].ToString() ?? string.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -82,7 +81,8 @@ namespace MinecraftClient.Inventory
|
||||||
List<string> lores = new();
|
List<string> lores = new();
|
||||||
if (NBT != null && NBT.ContainsKey("display"))
|
if (NBT != null && NBT.ContainsKey("display"))
|
||||||
{
|
{
|
||||||
if (NBT["display"] is Dictionary<string, object> displayProperties && displayProperties.ContainsKey("Lore"))
|
if (NBT["display"] is Dictionary<string, object> displayProperties &&
|
||||||
|
displayProperties.ContainsKey("Lore"))
|
||||||
{
|
{
|
||||||
object[] displayName = (object[])displayProperties["Lore"];
|
object[] displayName = (object[])displayProperties["Lore"];
|
||||||
lores.AddRange(from string st in displayName
|
lores.AddRange(from string st in displayName
|
||||||
|
|
@ -91,6 +91,7 @@ namespace MinecraftClient.Inventory
|
||||||
return lores.ToArray();
|
return lores.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -107,9 +108,11 @@ namespace MinecraftClient.Inventory
|
||||||
object damage = NBT["Damage"];
|
object damage = NBT["Damage"];
|
||||||
if (damage != null)
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -139,7 +142,8 @@ namespace MinecraftClient.Inventory
|
||||||
|
|
||||||
try
|
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<string, object> enchantment in (object[])enchantments)
|
foreach (Dictionary<string, object> enchantment in (object[])enchantments)
|
||||||
{
|
{
|
||||||
|
|
@ -150,8 +154,16 @@ namespace MinecraftClient.Inventory
|
||||||
ChatParser.TranslateString("enchantment.level." + level) ?? level.ToString());
|
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();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue