Exemplo n.º 1
0
 public virtual Packet Read(byte[] data)
 {
     var re = new Packet();
     MinecraftStream ms = new MinecraftStream(data);
     re.ID = ms.ReadVarInt();
     return re;
 }
Exemplo n.º 2
0
 public override void Flush(NetworkStream ns)
 {
     MinecraftStream read = new MinecraftStream();
     read.WriteString(Json);
     var buf = read.Flush(ID);
     ns.Write(buf, 0, buf.Length);
 }
Exemplo n.º 3
0
 public override void Flush(NetworkStream ns)
 {
     MinecraftStream read = new MinecraftStream();
     read.WriteVarInt(KeepAliveID);
     var buf = read.Flush(ID);
     ns.Write(buf, 0, buf.Length);
 }
Exemplo n.º 4
0
 public override void Flush(NetworkStream ns)
 {
     MinecraftStream Write = new MinecraftStream();
     Write.WriteLong(Payload);
     var buf = Write.Flush(ID);
     ns.Write(buf, 0, buf.Length);
 }
Exemplo n.º 5
0
 public override Packet Read(byte[] data)
 {
     var re = new Ping();
     MinecraftStream ms = new MinecraftStream(data);
     re.ID = ms.ReadVarInt();
     re.Payload = ms.ReadLong();
     return re;
 }
Exemplo n.º 6
0
 public override Packet Read(byte[] data)
 {
     var ms = new MinecraftStream(data);
     var re = new LoginStart() { ID = ms.ReadVarInt() };
     var l = ms.ReadVarInt();
     re.Name = ms.ReadString(l);
     return  re;
 }
Exemplo n.º 7
0
        public override void Flush(NetworkStream ns)
        {
            MinecraftStream read = new MinecraftStream();
            read.WriteDouble(X);
            read.WriteDouble(Y);
            read.WriteDouble(X);
            read.WriteFloat(Yaw);
            read.WriteFloat(Pitch);
            read.WriteByte(Flags);
            read.WriteVarInt(TeleportID);

            var buf = read.Flush(ID);
            ns.Write(buf, 0, buf.Length);
        }
Exemplo n.º 8
0
        public static Packet GetPacket(byte[] raw, int state)
        {
            var ms = new MinecraftStream(raw);
            var id = ms.ReadVarInt();

            foreach (var i in _packets)
            {
                if (i.IDs[state] == id)
                {
                    return i.Read(raw);
                }
            }
            return null;
        }
Exemplo n.º 9
0
        public override void Flush(NetworkStream ns)
        {
            MinecraftStream read = new MinecraftStream();

            read.WriteInt(EntityID);
            read.WriteByte(Gamemode);
            read.WriteInt(Dimension);
            read.WriteByte(Difficulty);
            read.WriteByte(MaxPlayers);
            read.WriteString(LevelType);
            read.WriteSByte(ReducedDebugInfo);

            var buf = read.Flush(ID);
            ns.Write(buf, 0, buf.Length);
        }
Exemplo n.º 10
0
        public override Packet Read(byte[] data)
        {
            var re = new PlayerPositionAndLook();
            MinecraftStream ms = new MinecraftStream(data);
            re.ID = ms.ReadVarInt();

            re.X = ms.ReadDouble();
            re.Y = ms.ReadDouble();
            re.Z = ms.ReadDouble();

            //re.Yaw = ms.ReadFloat(data);
            //  re.Pitch = ms.ReadFloat(data);

            // re.OnGround = ms.ReadByte(data);
            return re;
        }
Exemplo n.º 11
0
        public override Packet Read(byte[] data)
        {
            var re = new HandShake();

            MinecraftStream ms = new MinecraftStream(data);
            re.ID = ms.ReadVarInt();

            re.ProtocolVersion = ms.ReadVarInt();

            var l = ms.ReadVarInt();
            re.ServerAddress = ms.ReadString(l);

            re.ServerPort = ms.ReadUShort();

            re.NextState = ms.ReadVarInt();

            return re;
        }
Exemplo n.º 12
0
        public byte[] Write()
        {
            var stream = new MinecraftStream();
            stream.WriteByte((byte)BitsPerEntry);
            stream.WriteVarInt(States.Count);
            foreach (var state in States)
            {
                stream.WriteVarInt(state);
            }

            long[] data = Storage.GetData();
            stream.WriteVarInt(data.Length);

            foreach (var i in data)
            {
                stream.WriteLong(i);
            }

            for (int i = 0; i < (16 * 16 * 16) / 2; i++)
            {
                stream.WriteByte(255);
            }

            for (int i = 0; i < (16 * 16 * 16) / 2; i++)
            {
                stream.WriteByte(255);
            }

            return stream._buffer.ToArray();
        }