mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Add drop item for inventory
This commit is contained in:
parent
902527502e
commit
aaf6dca522
3 changed files with 33 additions and 6 deletions
|
|
@ -9,7 +9,7 @@ namespace MinecraftClient.Commands
|
|||
class Inventory : Command
|
||||
{
|
||||
public override string CMDName { get { return "inventory"; } }
|
||||
public override string CMDDesc { get { return "inventory <<id>|player|container> <list|close|click <slot> <left|right|middle>>: Interact with inventories"; } }
|
||||
public override string CMDDesc { get { return "inventory <<id>|player|container> <list|close|drop <slot> <all>|click <slot> <left|right|middle>>: Interact with inventories"; } }
|
||||
|
||||
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars)
|
||||
{
|
||||
|
|
@ -87,9 +87,27 @@ namespace MinecraftClient.Commands
|
|||
if (args.Length >= 3)
|
||||
{
|
||||
int slot = int.Parse(args[2]);
|
||||
handler.DoWindowAction(inventoryId, slot, WindowActionType.DropItem);
|
||||
// check item exist
|
||||
if (!handler.GetInventory(inventoryId).Items.ContainsKey(slot))
|
||||
return "No item in slot #" + slot;
|
||||
WindowActionType actionType = WindowActionType.DropItem;
|
||||
if (args.Length == 4)
|
||||
{
|
||||
if (args[3].ToLower() == "all")
|
||||
{
|
||||
actionType = WindowActionType.DropItemStack;
|
||||
}
|
||||
}
|
||||
if (handler.DoWindowAction(inventoryId, slot, actionType))
|
||||
{
|
||||
return "Dropped item from slot #" + slot;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
return "Dropped";
|
||||
else return CMDDesc;
|
||||
default:
|
||||
return CMDDesc;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue