mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Inventory: Show item Damage (#1213)
* /inventory add show item Damage * Removing unnecessary using * Upgrade * Fix * Update Inventory.cs * add Damage * Done * Done, Fix * Remove extra space, Fix documentation
This commit is contained in:
parent
08db87e5f6
commit
33781c5de5
2 changed files with 35 additions and 4 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using MinecraftClient.Inventory;
|
using MinecraftClient.Inventory;
|
||||||
|
|
||||||
namespace MinecraftClient.Commands
|
namespace MinecraftClient.Commands
|
||||||
|
|
@ -86,8 +85,19 @@ namespace MinecraftClient.Commands
|
||||||
{
|
{
|
||||||
string displayName = item.Value.DisplayName;
|
string displayName = item.Value.DisplayName;
|
||||||
if (String.IsNullOrEmpty(displayName))
|
if (String.IsNullOrEmpty(displayName))
|
||||||
response.Add(String.Format(" #{0}: {1} x{2}", item.Key, item.Value.Type, item.Value.Count));
|
{
|
||||||
else response.Add(String.Format(" #{0}: {1} x{2} - {3}§8", item.Key, item.Value.Type, item.Value.Count, displayName));
|
if (item.Value.Damage != 0)
|
||||||
|
response.Add(String.Format(" #{0}: {1} x{2} | Damage: {3}", item.Key, item.Value.Type, item.Value.Count, item.Value.Damage));
|
||||||
|
else
|
||||||
|
response.Add(String.Format(" #{0}: {1} x{2}", item.Key, item.Value.Type, item.Value.Count));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (item.Value.Damage != 0)
|
||||||
|
response.Add(String.Format(" #{0}: {1} x{2} - {3}§8 | Damage: {4}", item.Key, item.Value.Type, item.Value.Count, displayName, item.Value.Damage));
|
||||||
|
else
|
||||||
|
response.Add(String.Format(" #{0}: {1} x{2} - {3}§8", item.Key, item.Value.Type, item.Value.Count, displayName));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (inventoryId == 0) response.Add("Your selected hotbar is " + (handler.GetCurrentSlot() + 1));
|
if (inventoryId == 0) response.Add("Your selected hotbar is " + (handler.GetCurrentSlot() + 1));
|
||||||
return String.Join("\n", response.ToArray());
|
return String.Join("\n", response.ToArray());
|
||||||
|
|
@ -153,8 +163,10 @@ namespace MinecraftClient.Commands
|
||||||
Dictionary<int, Container> inventories = handler.GetInventories();
|
Dictionary<int, Container> inventories = handler.GetInventories();
|
||||||
List<string> response = new List<string>();
|
List<string> response = new List<string>();
|
||||||
response.Add("Inventories:");
|
response.Add("Inventories:");
|
||||||
foreach (var inventory in inventories)
|
foreach (KeyValuePair<int, Container> inventory in inventories)
|
||||||
|
{
|
||||||
response.Add(String.Format(" #{0}: {1}", inventory.Key, inventory.Value.Title + "§8"));
|
response.Add(String.Format(" #{0}: {1}", inventory.Key, inventory.Value.Title + "§8"));
|
||||||
|
}
|
||||||
response.Add(CMDDesc);
|
response.Add(CMDDesc);
|
||||||
return String.Join("\n", response);
|
return String.Join("\n", response);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,5 +70,24 @@ namespace MinecraftClient.Inventory
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve item damage from NBT properties. Returns 0 if no damage is defined.
|
||||||
|
/// </summary>
|
||||||
|
public int Damage
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (NBT != null && NBT.ContainsKey("Damage"))
|
||||||
|
{
|
||||||
|
object damage = NBT["Damage"];
|
||||||
|
if (damage != null)
|
||||||
|
{
|
||||||
|
return int.Parse(damage.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue