public override string Run(McTcpClient handler, string command, Dictionary <string, object> localVars)
        {
            Dictionary <int, Item> items = handler.GetPlayerInventory().Items;

            foreach (KeyValuePair <int, Item> a in items)
            {
                ConsoleIO.WriteLine("Slot: " + a.Key + " ItemID: " + a.Value.ID + ", Count: " + a.Value.Count);
            }
            return("");
        }
예제 #2
0
        public bool FindBucketAndUse(McTcpClient handler, int hotbar, Location block)
        {
            Container container   = handler.GetPlayerInventory();
            Container inventory   = new Container(container.ID, container.Type, container.Title, container.Items);
            bool      found       = false;
            byte      CurrentSlot = handler.GetCurrentSlot();

            if (inventory.Items.ContainsKey(CurrentSlot + 36) && inventory.Items[CurrentSlot + 36].Type == ItemType.Bucket)
            {
                found = true;
            }
            else
            {
                for (int i = 36; i <= 44; i++)
                {
                    if (!inventory.Items.ContainsKey(i))
                    {
                        continue;
                    }
                    if (inventory.Items[i].Type == ItemType.Bucket)
                    {
                        int slot = i - 36;
                        handler.ChangeSlot((short)slot);
                        found = true;
                        break;
                    }
                }
                for (int i = 9; i <= 35; i++)
                {
                    if (!inventory.Items.ContainsKey(i))
                    {
                        continue;
                    }
                    if (inventory.Items[i].Type == ItemType.Bucket)
                    {
                        handler.ClickWindowSlot(0, i, hotbar, 2);
                        handler.ChangeSlot((short)hotbar);
                        found = true;
                        break;
                    }
                }
            }
            if (found)
            {
                handler.UpdateLocation(handler.GetCurrentLocation(), block);
                handler.UseItemOnHand();
                Thread.Sleep(100);
                handler.ChangeSlot((short)CurrentSlot);
            }
            return(found);
        }
        private bool FindBucketAndUse(McTcpClient handler, int hotbar, Location block)
        {
            if (!handler.GetWorld().GetBlock(block).Type.IsLiquid())
            {
                return(false);
            }
            ConsoleIO.WriteLine("use bucket at " + block.ToString());
            Container container   = handler.GetPlayerInventory();
            Container inventory   = new Container(container.ID, container.Type, container.Title, container.Items);
            bool      found       = false;
            byte      CurrentSlot = handler.GetCurrentSlot();

            if (inventory.Items.ContainsKey(CurrentSlot + 36) && inventory.Items[CurrentSlot + 36].Type == ItemType.Bucket)
            {
                found = true;
            }
            else
            {
                Thread.Sleep(100);
                for (int i = 36; i <= 44; i++)
                {
                    if (!inventory.Items.ContainsKey(i))
                    {
                        continue;
                    }
                    if (inventory.Items[i].Type == ItemType.Bucket)
                    {
                        int slot = i - 36;
                        handler.ChangeSlot((short)slot);
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    for (int i = 9; i <= 35; i++)
                    {
                        if (!inventory.Items.ContainsKey(i))
                        {
                            continue;
                        }
                        if (inventory.Items[i].Type == ItemType.Bucket)
                        {
                            handler.ClickWindowSlot(0, i, hotbar, 2);
                            handler.ChangeSlot((short)hotbar);
                            found = true;
                            break;
                        }
                    }
                }
            }
            if (found)
            {
                handler.UpdateLocation(handler.GetCurrentLocation(), block);
                Thread.Sleep(200);
                handler.UseItemOnHand();
                Thread.Sleep(500);
                if (handler.GetWorld().GetBlock(block).Type.IsLiquid())
                {
                    for (int i = 36; i <= 44; i++)
                    {
                        if (!inventory.Items.ContainsKey(i))
                        {
                            continue;
                        }
                        if (inventory.Items[i].Type == ItemType.Bucket)
                        {
                            int slot = i - 36;
                            handler.ChangeSlot((short)slot);
                            found = true;
                            break;
                        }
                    }
                    if (found)
                    {
                        Thread.Sleep(200);
                        handler.UseItemOnHand();
                        Thread.Sleep(200);
                    }
                    if (handler.GetWorld().GetBlock(block).Type.IsLiquid())
                    {
                        handler.PlaceBlock(1, block);
                        ConsoleIO.WriteLine("fail to use bucket, place block instead");
                        Thread.Sleep(100);
                    }
                }
                handler.ChangeSlot(CurrentSlot);
            }
            return(found);
        }