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.
        }
Exemple #2
0
        private void asdToolStripMenuItem_Click(object sender, EventArgs e)
        {
            functions thisLookup = new functions();
            string    build      = "";

            for (int i = 0; i < 44; i++)
            {
                build += i.ToString() + ": " + thisLookup.getitembyslot(i, this) + "(" + thisLookup.getItemCount(i, this) + ")" + Environment.NewLine;
            }
            MessageBox.Show(build);
        }
        void findBlock(string[] args)
        {
            // Attempt on an alternitive block lookup method, for speed's sake..
            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]);

            decimal ChunkX = decimal.Divide(blockX, 16);
            decimal ChunkZ = decimal.Divide(blockZ, 16);

            ChunkX = Math.Floor(ChunkX);
            ChunkZ = Math.Floor(ChunkZ);

            Classes.Chunk    thisChunk = null;
            Classes.MapBlock thisblock = null;

            foreach (Classes.Chunk b in Mainform.Chunks)
            {
                if (b.x == ChunkX & b.z == ChunkZ)
                {
                    thisChunk = b;
                    break;
                }
            }

            thisblock = thisChunk.getBlock(blockX, blockY, blockZ);

            if (thisblock != null)
            {
                Packets.chatMessage cm = new Packets.chatMessage(Socket, Mainform, "FOUND IT. " + thisblock.Name, true);
            }
            else
            {
                Packets.chatMessage cm = new Packets.chatMessage(Socket, Mainform, "Fail :(", true);
            }
        }
        void cselect(string[] args)
        {
            functions lookup = new functions();
            int       blockId;

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

            blockId = int.Parse(args[2]);

            Packets.creativeInventory ci = new Packets.creativeInventory(Socket, Mainform, 40, new Classes.Item(blockId, 1, 2, 0));
        }
        void holdChange(string[] args)
        {
            functions test = new functions();

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

            if (short.Parse(args[2]) < 0 || short.Parse(args[2]) > 9)
            {
                return;
            }

            Mainform.selectedSlot = short.Parse(args[2]);
            Packets.HeldItemChange hic = new Packets.HeldItemChange(Socket, Mainform, true);
        }
        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);
            }
        }
        public commandHandler(Wrapped.Wrapped socket, Form1 mainform, string username, string message)
        {
            functions func = new functions();

            Socket   = socket;
            Mainform = mainform;

            string[] args = message.Split(' ');


            if (Mainform.admins.Contains(username))
            {
                if (args[1].StartsWith(mainform.prefix))
                {
                    switch (args[1].Replace(mainform.prefix, "").ToLower())
                    {
                    case "say":
                        Say(message);
                        break;

                    case "irc":
                        Irc(message);
                        break;

                    case "hold":
                        holdChange(args);
                        break;

                    case "mute":
                        Mute();
                        break;

                    case "yaw":
                        yaw(message);
                        break;

                    case "pitch":
                        pitch(message);
                        break;

                    case "move":
                        move(message);
                        break;

                    case "drop":
                        dropStack(args);
                        break;

                    case "block":
                        findBlock(args);
                        break;

                    case "pos":
                        pos();
                        break;

                    case "warning":
                        findEnt(mainform);
                        break;

                    case "follow":
                        follow(args);
                        break;

                    case "place":
                        placeBlock(args);
                        break;

                    case "cselect":
                        cselect(args);
                        break;

                    case "import":
                        import(args);
                        break;
                    }
                }
            }
        }