diff --git a/MinecraftClient/Commands/Inventory.cs b/MinecraftClient/Commands/Inventory.cs index d1e0797a..4f2907ac 100644 --- a/MinecraftClient/Commands/Inventory.cs +++ b/MinecraftClient/Commands/Inventory.cs @@ -83,6 +83,13 @@ namespace MinecraftClient.Commands return keyName + " clicking slot " + slot + " in window #" + inventoryId; } else return CMDDesc; + case "drop": + if (args.Length >= 3) + { + int slot = int.Parse(args[2]); + handler.DoWindowAction(inventoryId, slot, WindowActionType.DropItem); + } + return "Dropped"; default: return CMDDesc; } diff --git a/MinecraftClient/Inventory/WindowActionType.cs b/MinecraftClient/Inventory/WindowActionType.cs index c4688baa..e4e9c23f 100644 --- a/MinecraftClient/Inventory/WindowActionType.cs +++ b/MinecraftClient/Inventory/WindowActionType.cs @@ -9,6 +9,7 @@ namespace MinecraftClient.Inventory { LeftClick, RightClick, - MiddleClick + MiddleClick, + DropItem } } diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 61940cf0..bad43541 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -1362,6 +1362,13 @@ namespace MinecraftClient.Protocol.Handlers case WindowActionType.LeftClick: button = 0; break; case WindowActionType.RightClick: button = 1; break; case WindowActionType.MiddleClick: button = 2; mode = 3; break; + case WindowActionType.DropItem: + button = 0; + mode = 4; + item = new Item(-1, 0, null); + Container inventory = handler.GetInventory(0); + inventory.Items[slotId].Count--; // server won't update us after dropped + break; } List packet = new List(); diff --git a/MinecraftClient/Protocol/IMinecraftComHandler.cs b/MinecraftClient/Protocol/IMinecraftComHandler.cs index e4790913..c870e5cd 100644 --- a/MinecraftClient/Protocol/IMinecraftComHandler.cs +++ b/MinecraftClient/Protocol/IMinecraftComHandler.cs @@ -33,6 +33,7 @@ namespace MinecraftClient.Protocol bool SetInventoryEnabled(bool enabled); bool GetEntityHandlingEnabled(); bool SetEntityHandlingEnabled(bool enabled); + Container GetInventory(int inventoryID); /// /// Called when a server was successfully joined