diff --git a/MinecraftClient/ChatBots/AutoCarft.cs b/MinecraftClient/ChatBots/AutoCarft.cs index a8015d4b..d9c56400 100644 --- a/MinecraftClient/ChatBots/AutoCarft.cs +++ b/MinecraftClient/ChatBots/AutoCarft.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using MinecraftClient.Inventory; +using MinecraftClient.Mapping; namespace MinecraftClient.ChatBots { @@ -11,9 +12,45 @@ namespace MinecraftClient.ChatBots private bool waitingForResult = false; private int inventoryInUse; + private enum ActionType + { + MoveTo, + WaitForUpdate, + Repeat + } + + private class ActionStep + { + public ActionType Action; + public int Slot; + public int InventoryID; + } + public override void Initialize() { RegisterChatBotCommand("craft", "craft", CraftCommand); + RegisterChatBotCommand("open", "open", Open); + RegisterChatBotCommand("place", "place", Place); + } + + public string Open(string command, string[] args) + { + double x = -258; + double y = 64; + double z = -187; + Location l = new Location(x, y, z); + SendPlaceBlock(l, Direction.Up); + SendAnimation(); + return "Try to open"; + } + + public string Place(string command, string[] args) + { + double x = Convert.ToDouble(args[0]); + double y = Convert.ToDouble(args[1]); + double z = Convert.ToDouble(args[2]); + SendPlaceBlock(new Location(x, y, z), Direction.Down); + return "Try place"; } public string CraftCommand(string command, string[] args) @@ -29,6 +66,7 @@ namespace MinecraftClient.ChatBots foreach (KeyValuePair slot in recipe) { slotToPut = slot.Key + 1; + slotToTake = -2; // Find material in our inventory foreach (KeyValuePair item in inventory.Items) { diff --git a/MinecraftClient/Inventory/WindowActionType.cs b/MinecraftClient/Inventory/WindowActionType.cs index 53ab536a..e826a691 100644 --- a/MinecraftClient/Inventory/WindowActionType.cs +++ b/MinecraftClient/Inventory/WindowActionType.cs @@ -10,6 +10,7 @@ namespace MinecraftClient.Inventory LeftClick, RightClick, MiddleClick, + ShiftClick, DropItem, DropItemStack } diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index 6e49d6a1..b9f65ece 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -1112,6 +1112,41 @@ namespace MinecraftClient } } break; + case WindowActionType.ShiftClick: + if (inventory.Items.ContainsKey(slotId)) + { + /* Target slot have item */ + + // Cursor have item or not doesn't matter + switch (inventory.Type) + { + case ContainerType.PlayerInventory: // Shift click within player inventory + // If hotbar already have same item, will put on it first until every stack are full + // If no more same item , will put on the first empty slot (smaller slot id) + // If inventory full, item will not move + if (slotId < 36) + { + // Clicked slot is on upper side inventory, put it to hotbar + foreach(KeyValuePair _item in playerInventory.Items) + { + if (_item.Key < 35) continue; + + if (_item.Value.Type == inventory.Items[slotId].Type && _item.Value.Count < 64) + { + // + } + } + } + else + { + // Clicked slot is on hotbar, put it to upper inventory + + + } + break; + } + } + break; case WindowActionType.DropItem: if (inventory.Items.ContainsKey(slotId)) inventory.Items[slotId].Count--;