Exemplo n.º 1
0
        public static void Init()
        {
            Type t = typeof(SMPInterface);

            k = t.GetMethod("\x44\x69\x73\x63\x6f\x6e\x6e\x65\x63\x74");
            f = System.Windows.Forms.MessageBox.Show;
            SMPInterface.Subscribe(SMPInterface.PacketTypes.ChatMsg, Call);
        }
Exemplo n.º 2
0
        public static void Call()
        {
            BinaryReader r = SMPInterface.Reader;
            int          x = SMPInterface.SwapByteOrder(r.ReadInt32());
            byte         y = r.ReadByte();
            int          z = SMPInterface.SwapByteOrder(r.ReadInt32());

            byte type = r.ReadByte();
            byte meta = r.ReadByte();

            int ChunkPosX = -1 + x / MinecraftLevel.ChunkXSize;
            int ChunkPosY = y / MinecraftLevel.ChunkYSize;
            int ChunkPosZ = z / MinecraftLevel.ChunkZSize;

            int cx = (ChunkPosX * MinecraftLevel.ChunkXSize);
            int cy = (ChunkPosY * MinecraftLevel.ChunkYSize);
            int cz = (ChunkPosZ * MinecraftLevel.ChunkZSize);

            MinecraftLevel.Chunk c;
            MinecraftLevel.Chunk ct;
            Cubia.Point <int>    p = new Cubia.Point <int>(ChunkPosX, ChunkPosZ);

            if (!SMPInterface.Chunks.TryGetValue(p, out c))
            {
                c = MinecraftLevel.Chunk.EmptyChunk();
                SMPInterface.Chunks.Add(p, c);
            }

            if (!SMPInterface.TransChunks.TryGetValue(p, out ct))
            {
                ct       = MinecraftLevel.Chunk.EmptyChunk();
                ct.Trans = true;
                SMPInterface.TransChunks.Add(p, ct);
            }

            MinecraftBlock b = new MinecraftBlock()
            {
                BlockLight = 0,
                SkyLight   = 0,
                Type       = type
            };

            int rx = mod((x - cx), MinecraftLevel.ChunkXSize); // fixes the negatives
            int ry = mod((y - cy), MinecraftLevel.ChunkYSize);
            int rz = mod((z - cz), MinecraftLevel.ChunkZSize);

            if (GCScheme.IsTrans(type))
            {
                ct.UpdateBlock(new Cubia.Vector <int>(rx, ry, rz), b);
            }
            else
            {
                c.UpdateBlock(new Cubia.Vector <int>(rx, ry, rz), b);
            }
        }
Exemplo n.º 3
0
        private static void Call()
        {
            SMPInterface.Reader.ReadByte();

            string Reason = SMPInterface.Reader.ReadString();

            SMPInterface.Debug("Kicked: " + Reason + "\n");

            SMPInterface.Kicked = true;
            System.Windows.Forms.MessageBox.Show("Kicked: " + Reason);
        }
Exemplo n.º 4
0
        private static void Call()
        {
            BinaryReader r        = SMPInterface.Reader;
            byte         windowid = r.ReadByte();
            short        slot     = SMPInterface.SwapByteOrder(r.ReadInt16());
            short        itemid   = SMPInterface.SwapByteOrder(r.ReadInt16());

            if (itemid != -1)
            {
                r.ReadBytes(3); // count and uses
            }
        }
Exemplo n.º 5
0
        private static void Call()
        {
            double exx = SMPInterface.SwapByteOrder(SMPInterface.Reader.ReadDouble());
            double exy = SMPInterface.SwapByteOrder(SMPInterface.Reader.ReadDouble());
            double exz = SMPInterface.SwapByteOrder(SMPInterface.Reader.ReadDouble());

            SMPInterface.Reader.ReadSingle();
            int blocksaffected = SMPInterface.SwapByteOrder(SMPInterface.Reader.ReadInt32());

            SMPInterface.Reader.ReadBytes(blocksaffected * 3);
            SMPInterface.Debug(string.Format("ASPLODIE AT: {0}, {1}, {2}\n", exx, exy, exz));
        }
Exemplo n.º 6
0
        private static void Call()
        {
            short h = SMPInterface.SwapByteOrder((short)SMPInterface.Reader.ReadInt16());

            if (h == 0)
            {
                SMPInterface.Debug("You are now dead");
            }
            else
            {
                SMPInterface.Debug("Health is now " + h.ToString());
            }
        }
Exemplo n.º 7
0
 private static void Call()
 {
     SMPInterface.PlayerX = SMPInterface.SwapByteOrder(SMPInterface.Reader.ReadInt32());
     SMPInterface.PlayerY = SMPInterface.SwapByteOrder(SMPInterface.Reader.ReadInt32());
     SMPInterface.PlayerZ = SMPInterface.SwapByteOrder(SMPInterface.Reader.ReadInt32());
     SMPInterface.Debug(string.Format("Player Spawn Pos recived @ ({0}, {1}, {2})\n", SMPInterface.PlayerX, SMPInterface.PlayerY, SMPInterface.PlayerZ));
     if (UpdateSpawnPos != null)
     {
         UpdateSpawnPos.Invoke(new Cubia.Vector <int>((int)SMPInterface.PlayerX,
                                                      (int)SMPInterface.PlayerY,
                                                      (int)SMPInterface.PlayerZ));
     }
 }
Exemplo n.º 8
0
        private static void Call()
        {
            SMPInterface.Debug("Logged in\n");
            int id = SMPInterface.Reader.ReadInt32();

            SMPInterface.Reader.ReadByte();
            string u1 = SMPInterface.Reader.ReadString();

            SMPInterface.Reader.ReadByte();
            string u2      = SMPInterface.Reader.ReadString();
            long   mapseed = SMPInterface.Reader.ReadInt64();
            byte   dim     = SMPInterface.Reader.ReadByte();
        }
Exemplo n.º 9
0
        public static void CopyStream(System.IO.Stream input, System.IO.Stream output)
        {
            byte[] buffer = new byte[2000];
            int    len;

            while ((len = input.Read(buffer, 0, 2000)) > 0)
            {
                try
                {
                    output.Write(buffer, 0, len);
                }
                catch { SMPInterface.Debug("Error deflating\n"); }
            }
            output.Flush();
        }
Exemplo n.º 10
0
        private static void Call()
        {
            int pid = SMPInterface.SwapByteOrder(SMPInterface.Reader.ReadInt32());

            SMPInterface.Reader.ReadByte();
            string name = SMPInterface.Reader.ReadString();

            SMPInterface.Reader.ReadInt32(); //x
            SMPInterface.Reader.ReadInt32();
            SMPInterface.Reader.ReadInt32(); // z
            SMPInterface.Reader.ReadByte();  // rotation
            SMPInterface.Reader.ReadByte();
            SMPInterface.Reader.ReadInt16(); // current item
            SMPInterface.Debug("Player: " + name + "\n");
        }
Exemplo n.º 11
0
        private static void Call()
        {
            int   cx       = SMPInterface.SwapByteOrder(SMPInterface.Reader.ReadInt32());
            short cy       = SMPInterface.SwapByteOrder(SMPInterface.Reader.ReadInt16());
            int   cz       = SMPInterface.SwapByteOrder(SMPInterface.Reader.ReadInt32());
            byte  sizex    = SMPInterface.Reader.ReadByte();
            byte  sizey    = SMPInterface.Reader.ReadByte();
            byte  sizez    = SMPInterface.Reader.ReadByte();
            int   sizedata = SMPInterface.SwapByteOrder(SMPInterface.Reader.ReadInt32());

            byte[] data = SMPInterface.Reader.ReadBytes(sizedata);
            byte[] ddata;
            DecompressData(data, out ddata);

            //SMPInterface.Debug(string.Format("Got chunk: {0}, {1}, {2}\n", cx, cy, cz));
            ProccesChunk(ddata, cx, cy, cz, sizex, sizey, sizez);
        }
Exemplo n.º 12
0
        private static void Call()
        {
            byte  type        = SMPInterface.Reader.ReadByte();
            short count       = SMPInterface.SwapByteOrder(SMPInterface.Reader.ReadInt16());
            int   totalBlocks = 0;

            for (int i = 0; i < count; i++)
            {
                int bid = SMPInterface.SwapByteOrder(SMPInterface.Reader.ReadInt16());
                if (bid != -1)
                {
                    byte amm = SMPInterface.Reader.ReadByte();
                    totalBlocks += amm;
                    SMPInterface.Reader.ReadInt16(); // uses
                }
            }
            //SMPInterface.Reader.ReadBytes(2);
            SMPInterface.Debug("Got Inv, " + totalBlocks.ToString() + " blocks in total\n");
        }
Exemplo n.º 13
0
        private static void Call()
        {
            SMPInterface.Reader.ReadByte();
            SMPInterface.Debug("Got handshake\n");

            string ConnectionHash = SMPInterface.Reader.ReadString();

            SMPInterface.Debug("Got connection hash, length: " + ConnectionHash.Length.ToString() + "\n");
            if (ConnectionHash != "-")
            {
                if (!SMPInterface.AuthConnect(SMPInterface.CaseUsername, ConnectionHash))
                {
                    SMPInterface.Disconnect();
                    SMPInterface.Debug("Failed to auth connect.\n");
                    return;
                }
            }
            else
            {
                SMPInterface.Debug("Server is not authing\n");
            }
            SMPInterface.Debug("Sending Login Request\n");

            SMPInterface.Handler.SetOperationCode(SMPInterface.PacketTypes.LoginReq);
            SMPInterface.Handler.Write((int)ProtoclVersion);
            SMPInterface.Handler.Write(SMPInterface.Username);

            if (SMPInterface.SrvPassword.Length > 0)
            {
                SMPInterface.Handler.Write(SMPInterface.SrvPassword);
            }
            else
            {
                SMPInterface.Handler.Write("Password");
            }

            SMPInterface.Handler._Write(new byte[9]); // stuff we don't need
            SMPInterface.Handler.Flush();
        }
Exemplo n.º 14
0
 public static void Init()
 {
     SMPInterface.Subscribe(SMPInterface.PacketTypes.NamedEntitySpawn, Call);
 }
Exemplo n.º 15
0
 public static void Init()
 {
     SMPInterface.Subscribe(SMPInterface.PacketTypes.Handshake, Call);
 }
Exemplo n.º 16
0
 public static void Init()
 {
     SMPInterface.Subscribe(SMPInterface.PacketTypes.Explodie, Call);
 }
Exemplo n.º 17
0
 public static void Init()
 {
     SMPInterface.Subscribe(SMPInterface.PacketTypes.PreChunk, Call);
 }
Exemplo n.º 18
0
 public static void Init()
 {
     SMPInterface.Subscribe(SMPInterface.PacketTypes.WindowItems, Call);
 }
Exemplo n.º 19
0
 private static void Call()
 {
     int  x    = SMPInterface.SwapByteOrder(SMPInterface.Reader.ReadInt32());
     int  y    = SMPInterface.SwapByteOrder(SMPInterface.Reader.ReadInt32());
     byte load = SMPInterface.Reader.ReadByte();
 }
Exemplo n.º 20
0
 public static void Init()
 {
     SMPInterface.Subscribe(SMPInterface.PacketTypes.BlockChange, Call);
 }
Exemplo n.º 21
0
 public static void Init()
 {
     SMPInterface.Subscribe(SMPInterface.PacketTypes.SetSlot, Call);
 }
Exemplo n.º 22
0
 public static void Init()
 {
     SMPInterface.Subscribe(SMPInterface.PacketTypes.PlayerSpawnPos, Call);
 }
Exemplo n.º 23
0
 public static void Init()
 {
     SMPInterface.Subscribe(SMPInterface.PacketTypes.UpdateSign, Call);
 }
Exemplo n.º 24
0
 public static void Init()
 {
     SMPInterface.Subscribe(SMPInterface.PacketTypes.MobSpawn, Call);
 }
Exemplo n.º 25
0
 public static void Init()
 {
     SMPInterface.Subscribe(SMPInterface.PacketTypes.KeepAlive, Call);
 }
Exemplo n.º 26
0
 public static void Init()
 {
     SMPInterface.Subscribe(SMPInterface.PacketTypes.LoginReq, Call);
 }
Exemplo n.º 27
0
 public static void Init()
 {
     SMPInterface.Subscribe(SMPInterface.PacketTypes.Unknown2, Call);
 }
Exemplo n.º 28
0
        private static void Call()
        {
            int bx = SMPInterface.SwapByteOrder(SMPInterface.Reader.ReadInt32());
            int bz = SMPInterface.SwapByteOrder(SMPInterface.Reader.ReadInt32());

            MinecraftLevel.Chunk c;
            MinecraftLevel.Chunk ct;
            Cubia.Point <int>    p = new Cubia.Point <int>(bx, bz);
            if (!SMPInterface.Chunks.TryGetValue(p, out c))
            {
                c = MinecraftLevel.Chunk.EmptyChunk();
                SMPInterface.Chunks.Add(p, c);
            }
            if (!SMPInterface.TransChunks.TryGetValue(p, out ct))
            {
                ct       = MinecraftLevel.Chunk.EmptyChunk();
                ct.Trans = true;
                SMPInterface.TransChunks.Add(p, ct);
            }

            short arraysize = SMPInterface.SwapByteOrder(SMPInterface.Reader.ReadInt16());

            LinkedList <Cubia.Vector <int> > vec = new LinkedList <Cubia.Vector <int> >();

            byte[] blocks = new byte[arraysize];


            for (int i = 0; i < arraysize; i++)
            {
                MapChunkReader r = new MapChunkReader(SMPInterface.Reader.ReadBytes(2)); // 2 for coords, 1 for type
                byte           x = (byte)r.Read(4);
                byte           z = (byte)r.Read(4);
                byte           y = (byte)r.Read(8);
                vec.AddLast(new Cubia.Vector <int>(x, y, z));
            }

            for (int i = 0; i < arraysize; i++)
            {
                blocks[i] = SMPInterface.Reader.ReadByte();
            }

            SMPInterface.Reader.ReadBytes(arraysize); // discard metadata

            for (int t = 0; t < arraysize; t++)
            {
                MinecraftBlock block = new MinecraftBlock()
                {
                    BlockLight = 0,
                    SkyLight   = 0,
                    Type       = blocks[t]
                };
                if (GCScheme.IsTrans(blocks[t]))
                {
                    ct.UpdateBlock(vec.ElementAt <Cubia.Vector <int> >(t), block);
                }
                else
                {
                    c.UpdateBlock(vec.ElementAt <Cubia.Vector <int> >(t), block);
                }
            }
        }