Example #1
0
        public static void Main(string[] argv)
        {
            var stream = new FileStream(@"D:\projects\Survivalist\data.dat", FileMode.Open);
            var net = new NetworkReader(stream);

            while (true) {
                var packet = Packet.Get(net);
                Console.WriteLine(packet.GetType());
                if (packet is PlayerMoveLookPacket) {
                    var mypacket = packet as PlayerMoveLookPacket;
                    Console.WriteLine("PlayerMoveLook: {0:0.00}, {1:0.00}, {2:0.00}, {3:0.00}", mypacket.X, mypacket.Y, mypacket.Stance, mypacket.Z);
                    Console.WriteLine("Rot: {0:0.00}; {1:0.00}", mypacket.RotationX, mypacket.RotationY);
                }
                if (packet is SetSpawnPacket) {
                    var mypacket = packet as SetSpawnPacket;
                    Console.WriteLine("Pos: {0}, {1}, {2}", mypacket.X, mypacket.Y, mypacket.Z);
                }
                if (packet is UpdateTimePacket) {
                    var mypacket = packet as UpdateTimePacket;
                    Console.WriteLine("Time: " + mypacket.Time);
                }
                if (packet is UpdateBlockPacket) {
                    var mypacket = packet as UpdateBlockPacket;
                    Console.WriteLine("Update block: {0}, {1}, {2}, {3}, {4}", mypacket.ChunkX, mypacket.ChunkY, mypacket.ChunkZ, mypacket.Type, mypacket.MetaData);
                }
                if (packet is PlayerDigPacket) {
                    var mypacket = packet as PlayerDigPacket;
                    Console.WriteLine("Dig: {0}, {1}, {2}", mypacket.DigX, mypacket.DigY, mypacket.DigZ);
                }
                if (packet is LoginPacket) {
                    var mypacket = packet as LoginPacket;
                    Console.WriteLine("Login: {0}, {1}", mypacket.Time, mypacket.DimensionType);
                }
            }
        }
Example #2
0
        public PacketPipe(TcpClient client, PacketHandler handler)
        {
            this.client = client;
            this.handler = handler;

            var stream = client.GetStream();
            reader = new NetworkReader(stream);
            writer = new NetworkWriter(stream);

            readThread = new Thread(new ThreadStart(ReadLoop));
            writeThread = new Thread(new ThreadStart(WriteLoop));
            readThread.Start();
            writeThread.Start();
        }
Example #3
0
 public override void Read(NetworkReader reader)
 {
     EntityId = reader.ReadInt32();
     TypeId = reader.ReadInt16();
     Count = reader.ReadByte();
     X = reader.ReadInt32();
     Y = reader.ReadInt32();
     Z = reader.ReadInt32();
     MoveX = reader.ReadByte();
     MoveY = reader.ReadByte();
     MoveZ = reader.ReadByte();
 }
Example #4
0
 public override void Read(NetworkReader reader)
 {
     Message = reader.ReadUTF8();
 }
Example #5
0
 public override void Read(NetworkReader reader)
 {
     Type = (InventoryType)reader.ReadInt32();
     int count = reader.ReadInt16();
     Items = new InventoryItem[count];
     for (int i = 0; i < count; i++) {
         int id = reader.ReadInt16();
         if (id == -1) {
             Items[i] = null;
         } else {
             int itemCount = reader.ReadByte();
             int damage = reader.ReadInt16();
             Items[i] = new InventoryItem(id, itemCount, damage);
         }
     }
 }
Example #6
0
 public override void Read(NetworkReader reader)
 {
     X = reader.ReadDouble();
     Y = reader.ReadDouble();
     Stance = reader.ReadDouble();
     Z = reader.ReadDouble();
     base.Read(reader);
 }
Example #7
0
 public override void Read(NetworkReader reader)
 {
     State = reader.ReadByte();
     DigX = reader.ReadInt32();
     DigY = reader.ReadByte();
     DigZ = reader.ReadInt32();
     Face = reader.ReadByte();
 }
Example #8
0
 public override void Read(NetworkReader reader)
 {
     Unknown = reader.ReadInt32();
     Slot = reader.ReadInt16();
 }
Example #9
0
 public override void Read(NetworkReader reader)
 {
     EntityId = reader.ReadInt32();
     TypeId = reader.ReadByte();
     X = reader.ReadInt32();
     Y = reader.ReadInt32();
     Z = reader.ReadInt32();
     RotationX = reader.ReadByte();
     RotationY = reader.ReadByte();
 }
Example #10
0
 public override void Read(NetworkReader reader)
 {
     base.Read(reader);
     XDiff = reader.ReadByte();
     YDiff = reader.ReadByte();
     ZDiff = reader.ReadByte();
 }
Example #11
0
 public override void Read(NetworkReader reader)
 {
     base.Read(reader);
     RotationX = reader.ReadByte();
     RotationY = reader.ReadByte();
 }
Example #12
0
 public override void Read(NetworkReader reader)
 {
     Contents = reader.ReadUTF8();
 }
Example #13
0
 public override void Read(NetworkReader reader)
 {
     Time = reader.ReadInt64();
 }
Example #14
0
        public override void Read(NetworkReader reader)
        {
            ChunkX = reader.ReadInt32();
            ChunkY = reader.ReadInt16();
            ChunkZ = reader.ReadInt32();
            Width = reader.ReadByte() + 1;
            Height = reader.ReadByte() + 1;
            Depth = reader.ReadByte() + 1;

            byte[] data = new byte[reader.ReadInt32()];
            reader.Read(data, 0, data.Length);
            var uncompressed = new MemoryStream(data.Length); // TODO: use better guess here
            var zlib = new ZOutputStream(uncompressed);
            zlib.Write(data, 0, data.Length);
            zlib.Flush();
            zlib.finish();
            Data = new byte[zlib.TotalOut];
            uncompressed.Read(Data, 0, Data.Length);
            zlib.Close();
            uncompressed.Close();
        }
Example #15
0
 public abstract void Read(NetworkReader reader);
Example #16
0
 public override void Read(NetworkReader reader)
 {
     TypeId = reader.ReadInt16();
     Count = reader.ReadByte();
     Durability = reader.ReadInt16();
 }
Example #17
0
 public override void Read(NetworkReader reader)
 {
     ChunkX = reader.ReadInt32();
     ChunkY = reader.ReadInt32();
     Add = reader.ReadBoolean();
 }
Example #18
0
 public override void Read(NetworkReader reader)
 {
     throw new NotImplementedException();
 }
Example #19
0
 public override void Read(NetworkReader reader)
 {
     CollectEntityId = reader.ReadInt32();
     CollectingEntityId = reader.ReadInt32();
 }
Example #20
0
 public override void Read(NetworkReader reader)
 {
     Reason = reader.ReadUTF8();
 }
Example #21
0
 public override void Read(NetworkReader reader)
 {
     RotationX = reader.ReadSingle();
     RotationY = reader.ReadSingle();
     base.Read(reader);
 }
Example #22
0
 public override void Read(NetworkReader reader)
 {
     EntityId = reader.ReadInt32();
 }
Example #23
0
 public override void Read(NetworkReader reader)
 {
     Type = reader.ReadInt16();
     X = reader.ReadInt32();
     Y = reader.ReadByte();
     Z = reader.ReadInt32();
     Face = reader.ReadByte();
 }
Example #24
0
 public override void Read(NetworkReader reader)
 {
     base.Read(reader);
     ForwardAnimation = reader.ReadBoolean();
 }
Example #25
0
 //public SendTileEntityAttributesPacket(TileEntity e) { // TODO: encode tile entity attributes as NBT }
 public override void Read(NetworkReader reader)
 {
     X = reader.ReadInt32();
     Y = reader.ReadInt16();
     Z = reader.ReadInt32();
     var dataLength = reader.ReadInt16();
     Data = new byte[dataLength];
     reader.Read(Data, 0, dataLength);
 }
Example #26
0
 public override void Read(NetworkReader reader)
 {
     Flying = reader.ReadBoolean();
 }
Example #27
0
 public override void Read(NetworkReader reader)
 {
     X = reader.ReadInt32();
     Y = reader.ReadInt32();
     Z = reader.ReadInt32();
 }
Example #28
0
 public override void Read(NetworkReader reader)
 {
     Version = reader.ReadInt32();
     AccountName = reader.ReadUTF8();
     Password = reader.ReadUTF8();
     Time = reader.ReadInt64();
     DimensionType = reader.ReadByte();
 }
Example #29
0
 public override void Read(NetworkReader reader)
 {
     ChunkX = reader.ReadInt32();
     ChunkY = reader.ReadByte();
     ChunkZ = reader.ReadInt32();
     Type = reader.ReadByte();
     MetaData = reader.ReadByte();
 }
Example #30
0
 public override void Read(NetworkReader reader)
 {
 }