mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Add /inventory player and /inventory container
Allow interacting with an inventory without specifying an ID Useful for automated interactions when container has in incremental ID Eg. /inventory container click 1 See #981
This commit is contained in:
parent
2f1b99c064
commit
c2dc483d36
1 changed files with 16 additions and 2 deletions
|
|
@ -9,7 +9,7 @@ namespace MinecraftClient.Commands
|
||||||
class Inventory : Command
|
class Inventory : Command
|
||||||
{
|
{
|
||||||
public override string CMDName { get { return "inventory"; } }
|
public override string CMDName { get { return "inventory"; } }
|
||||||
public override string CMDDesc { get { return "inventory <id> <list|close|click <slot>>: Interact with inventories"; } }
|
public override string CMDDesc { get { return "inventory <<id>|player|container> <list|close|click <slot>>: Interact with inventories"; } }
|
||||||
|
|
||||||
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars)
|
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars)
|
||||||
{
|
{
|
||||||
|
|
@ -20,7 +20,21 @@ namespace MinecraftClient.Commands
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int inventoryId = int.Parse(args[0]);
|
int inventoryId;
|
||||||
|
if (args[0].ToLower() == "player")
|
||||||
|
{
|
||||||
|
// player inventory is always ID 0
|
||||||
|
inventoryId = 0;
|
||||||
|
}
|
||||||
|
else if (args[0].ToLower() == "container")
|
||||||
|
{
|
||||||
|
List<int> availableIds = handler.GetInventories().Keys.ToList();
|
||||||
|
availableIds.Remove(0); // remove player inventory ID from list
|
||||||
|
if (availableIds.Count == 1)
|
||||||
|
inventoryId = availableIds[0]; // one container, use it
|
||||||
|
else return "Cannot find container, please retry with explicit ID";
|
||||||
|
}
|
||||||
|
else inventoryId = int.Parse(args[0]);
|
||||||
string action = args.Length > 1
|
string action = args.Length > 1
|
||||||
? args[1].ToLower()
|
? args[1].ToLower()
|
||||||
: "list";
|
: "list";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue