Exemplo n.º 1
0
        void dropStack(string[] args)
        {
            functions lookup = new functions();

            Classes.Item thisitem = null;

            if (!lookup.isNumeric(args[2]))
            {
                return;
            }

            foreach (Classes.Item b in Mainform.inventory)
            {
                if (b.slot == (short.Parse(args[2])))
                {
                    thisitem = b;
                    break;
                }
            }

            if (thisitem == null)
            {
                return;
            }

            Packets.ClickWindow click  = new Packets.ClickWindow(Socket, Mainform, short.Parse(args[2]), 0, 0, thisitem);
            Packets.ClickWindow click2 = new Packets.ClickWindow(Socket, Mainform, -999, 0, 0, thisitem); //Slot -999 is outside window click, which drops it.
        }
Exemplo n.º 2
0
        void placeBlock(string[] args)
        {
            functions lookup = new functions();

            if (!lookup.isNumeric(args[2]))
            {
                return;
            }
            if (!lookup.isNumeric(args[3]))
            {
                return;
            }
            if (!lookup.isNumeric(args[4]))
            {
                return;
            }

            int blockX = int.Parse(args[2]);
            int blockY = int.Parse(args[3]);
            int blockZ = int.Parse(args[4]) - 1; // - 1 corrects some error in sending this packet that results in the Z coord being off.

            int heldSlot = Mainform.selectedSlot + 36;

            Classes.Item heldItem = null;

            foreach (Classes.Item b in Mainform.inventory)
            {
                if (b.slot == heldSlot)
                {
                    heldItem = b;
                    break;
                }
            }

            if (heldItem != null)
            {
                Packets.placeBlock myblock = new Packets.placeBlock(blockX, (byte)blockY, blockZ, 3, heldItem, Socket);
            }
            else
            {
                Packets.chatMessage chat = new Packets.chatMessage(Socket, Mainform, "Not holding anything.", true);
            }
        }
Exemplo n.º 3
0
        public void readSlot(Wrapped.Wrapped socket, bool inventory = false, Form1 Mainform = null, short slot = 500)
        {
            // Read's slot data off the socket, and if the options are provided, will also add to the bot's inventory.

            bool delete = false;

            Classes.Item existing = null;

            // Just in case.
            if (inventory == true & Mainform == null)
            {
                throw new Exception("If inventory is true, you must include a main form.");
            }
            if ((inventory == true) & slot == 500)
            {
                throw new Exception("If inventory is true, you must include which slot to add to.");
            }

            // Delete the existing inventory data if it already exists.
            if (inventory == true)
            {
                foreach (Classes.Item b in Mainform.inventory)
                {
                    if (b.slot == slot)
                    {
                        delete   = true;
                        existing = b;
                        break;
                    }
                }

                if (delete == true)
                {
                    Mainform.inventory.Remove(existing);
                }
            }

            int blockID = socket.readShort();

            if (blockID == -1)
            {
                return;
            }

            byte  itemCount = socket.readByte();
            short damage    = socket.readShort();
            int   NBTLength = socket.readShort();

            if (NBTLength == -1)
            {
                if (inventory == true)
                {
                    Mainform.inventory.Add(new Classes.Item(blockID, itemCount, damage, slot));
                }
                return;
            }

            socket.readByteArray(NBTLength);


            if (inventory == true)
            {
                Mainform.inventory.Add(new Classes.Item(blockID, itemCount, damage, slot));
            }
        }