Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
 private void MoveTo(McTcpClient handler, Location goal)
 {
     if (!handler.GetWorld().GetBlock(goal + new Location(0, -1, 0)).Type.IsSolid())
     {
         handler.PlaceBlock(1, goal + new Location(0, -1, 0));
         Thread.Sleep(100);
     }
     if (handler.GetWorld().GetBlock(goal + new Location(0, 1, 0)).Type.IsSolid())
     {
         BreakBlock(handler, goal + new Location(0, 1, 0));
         Thread.Sleep(100);
     }
     goal += new Location(0.5, 0, 0.5);
     handler.UpdateLocation(goal, goal + new Location(0, 1, 0));
     handler.handler.SendLocationUpdate(goal, true, handler.yaw, handler.pitch);
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        public override string Run(McTcpClient handler, string command)
        {
            if (Settings.TerrainAndMovements)
            {
                string[] args = getArgs(command);
                if (args.Length == 1)
                {
                    string    dirStr = getArg(command).Trim().ToLower();
                    Direction direction;
                    switch (dirStr)
                    {
                    case "up": direction = Direction.Up; break;

                    case "down": direction = Direction.Down; break;

                    case "east": direction = Direction.East; break;

                    case "west": direction = Direction.West; break;

                    case "north": direction = Direction.North; break;

                    case "south": direction = Direction.South; break;

                    default: return("Unknown direction '" + dirStr + "'.");
                    }

                    handler.UpdateLocation(handler.GetCurrentLocation(), direction);
                    return("Looking " + dirStr);
                }
                else if (args.Length == 2)
                {
                    try
                    {
                        float yaw   = Single.Parse(args[0]);
                        float pitch = Single.Parse(args[1]);

                        handler.UpdateLocation(handler.GetCurrentLocation(), yaw, pitch);
                        return(String.Format("Looking at YAW: {0} PITCH: {1}", yaw.ToString("0.00"), pitch.ToString("0.00")));
                    }
                    catch (FormatException) { return(CMDDesc); }
                }
                else if (args.Length == 3)
                {
                    try
                    {
                        int x = int.Parse(args[0]);
                        int y = int.Parse(args[1]);
                        int z = int.Parse(args[2]);

                        Location block = new Location(x, y, z);
                        handler.UpdateLocation(handler.GetCurrentLocation(), block);

                        return("Looking at " + block);
                    }
                    catch (FormatException) { return(CMDDesc); }
                }
                else
                {
                    return(CMDDesc);
                }
            }
            else
            {
                return("Please enable terrainandmovements in config to use this command.");
            }
        }