Ejemplo n.º 1
0
        protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
        {
            buffer.WriteVarint(ID);
            buffer.WriteInt(client.TheWorld.FlatWorld[Ndx].X);
            buffer.WriteInt(client.TheWorld.FlatWorld[Ndx].Z);
            buffer.WriteBoolean(GroundUpContinuous);
            buffer.WriteLEUShort(PrimaryBitmap);
            buffer.WriteShort((short)SecondaryBitmap);

            byte[] chunkData    = client.TheWorld.FlatWorld[Ndx].ChunkData;
            byte[] compressData = new byte[chunkData.Length];

            ConcurrentStack <Deflater> DeflaterPool = new ConcurrentStack <Deflater>();
            Deflater deflater;

            DeflaterPool.TryPop(out deflater);
            if (deflater == null)
            {
                deflater = new Deflater(5);
            }
            deflater.SetInput(chunkData, 0, chunkData.Length);
            deflater.Finish();
            int length = deflater.Deflate(compressData);

            deflater.Reset();
            DeflaterPool.Push(deflater);

            buffer.WriteInt(length);
            buffer.Write(compressData, 0, length);
        }
Ejemplo n.º 2
0
 protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
 {
     buffer.WriteVarint(ID);
     buffer.WriteInt((int)client.PlayerPosition.X);
     buffer.WriteInt((int)client.PlayerPosition.FeetY);
     buffer.WriteInt((int)client.PlayerPosition.Z);
 }
Ejemplo n.º 3
0
 protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
 {
     buffer.WriteVarint(ID);
     buffer.WriteFloat(Health);
     buffer.WriteShort(Food);
     buffer.WriteFloat(FoodSaturation);
 }
Ejemplo n.º 4
0
 protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
 {
     buffer.WriteVarint(ID);
     buffer.WriteInt(Id);
     buffer.WriteByteAngle(Yaw);
     buffer.WriteByteAngle(Pitch);
 }
Ejemplo n.º 5
0
 protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
 {
     buffer.WriteVarint(ID);
     buffer.WriteFloat(0.0f);
     buffer.WriteShort(0);
     buffer.WriteShort(0);
 }
Ejemplo n.º 6
0
 protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
 {
     buffer.WriteVarint(ID);
     buffer.WriteInt(Dimension);
     buffer.WriteByte(Difficulty);
     buffer.WriteByte(Gamemode);
     buffer.WriteString(LevelType);
 }
Ejemplo n.º 7
0
        protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
        {
            Random r = new Random();

            KeepAlive = r.Next(int.MinValue, int.MaxValue);

            buffer.WriteVarint(ID);
            buffer.WriteInt(KeepAlive);
        }
Ejemplo n.º 8
0
        protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
        {
            byte flag = 0x01 | 0x08 | 0x02 | 0x04;

            buffer.WriteVarint(ID);
            buffer.WriteByte(flag);
            buffer.WriteFloat(0.1f);
            buffer.WriteFloat(1.0f);
        }
 protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
 {
     buffer.WriteVarint(ID);
     buffer.WriteByte((byte)Entities.Count);
     foreach (int i in Entities)
     {
         buffer.WriteInt(i);
     }
 }
Ejemplo n.º 10
0
 protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
 {
     buffer.WriteVarint(ID);
     buffer.WriteDouble(10.0d);
     buffer.WriteDouble(128.0d);
     buffer.WriteDouble(10.0d);
     buffer.WriteFloat(0.0f);
     buffer.WriteFloat(0.0f);
     buffer.WriteBoolean(true);
 }
Ejemplo n.º 11
0
 protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
 {
     MinecraftServer.Core.Network.Server.ViewModel.Warning("Block Change : Block(" + X + ", " + Y + ", " + Z + "), NewID = " + BlockID);
     buffer.WriteVarint(ID);
     buffer.WriteInt(X);
     buffer.WriteByte(Y);
     buffer.WriteInt(Z);
     buffer.WriteVarint(BlockID);
     buffer.WriteByte(BlockMeta);
 }
        protected override void OnWrite(System.Net.Sockets.NetworkStream stream, Server.Core.Stream.ByteBuffer buffer)
        {
            ByteBuffer tmp = new ByteBuffer();

            tmp.WriteVarint((int)buffer.Length);
            tmp.Write(buffer.GetBuffer(), 0, (int)buffer.Length);
            stream.Write(tmp.GetBuffer(), 0, (int)tmp.Length);

            Data   = tmp.GetBuffer();
            Length = (int)tmp.Length;
        }
Ejemplo n.º 13
0
        protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
        {
            client.PlayerMetadata.GameMode = 1;

            buffer.WriteVarint(ID);
            buffer.WriteInt(4);
            buffer.WriteByte(1);
            buffer.WriteByte(0);
            buffer.WriteByte(1);
            buffer.WriteByte(32);
            buffer.WriteString("default");
        }
Ejemplo n.º 14
0
 protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
 {
     buffer.WriteVarint(ID);
     buffer.WriteInt(Id);
     //buffer.WriteByte(Convert.ToByte(DX));
     //buffer.WriteByte(Convert.ToByte(DY));
     //buffer.WriteByte(Convert.ToByte(DZ));
     //buffer.WriteByte(0);
     //buffer.WriteByte(0);
     buffer.WriteFixedPointByte(DX);
     buffer.WriteFixedPointByte(DY);
     buffer.WriteFixedPointByte(DZ);
 }
Ejemplo n.º 15
0
 protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
 {
     buffer.WriteVarint(ID);
     buffer.WriteVarint(PlayerEntityId);
     buffer.WriteString(PlayerUUID);
     buffer.WriteString(PlayerName);
     buffer.WriteFixedPoint(PlayerX);
     buffer.WriteFixedPoint(PlayerY);
     buffer.WriteFixedPoint(PlayerZ);
     buffer.WriteByte(PlayerYaw);
     buffer.WriteByte(PlayerPitch);
     buffer.WriteShort(CurrentItem);
     buffer.WriteByte((3 << 5) | 6);
     buffer.WriteFloat(Health);
     buffer.WriteByte(0x7F);
 }
Ejemplo n.º 16
0
        protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
        {
            X        = client.PlayerPosition.X;
            Y        = client.PlayerPosition.FeetY;
            Z        = client.PlayerPosition.Z;
            Yaw      = client.PlayerPosition.Yaw;
            Pitch    = client.PlayerPosition.Pitch;
            OnGround = client.PlayerPosition.OnGround;

            buffer.WriteVarint(ID);
            buffer.WriteDouble(X);
            buffer.WriteDouble(Y);
            buffer.WriteDouble(Z);
            buffer.WriteFloat((float)Yaw);
            buffer.WriteFloat((float)Pitch);
            buffer.WriteBoolean(OnGround);
        }
Ejemplo n.º 17
0
        protected override void OnAfterWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
        {
            SpawnPlayerPacket spawnPacket = StateManager.FindState("play").GetSendPacket(0x0C) as SpawnPlayerPacket;

            spawnPacket.PlayerEntityId = client.ID;
            spawnPacket.PlayerUUID     = client.UUID;
            spawnPacket.PlayerName     = client.Name;
            spawnPacket.PlayerX        = client.PlayerPosition.X;
            spawnPacket.PlayerY        = client.PlayerPosition.FeetY;
            spawnPacket.PlayerZ        = client.PlayerPosition.Z;
            spawnPacket.PlayerYaw      = 0;
            spawnPacket.PlayerPitch    = 0;
            spawnPacket.CurrentItem    = client.PlayerMetadata.CurrentItem;
            spawnPacket.Health         = client.PlayerMetadata.Health;
            //packet.Metadata = metadata; To add

            client.AddBroadCast(spawnPacket, client);
        }
Ejemplo n.º 18
0
 protected override void OnRead(Server.Core.Stream.ByteBuffer stream)
 {
     Time = stream.ReadLong();
 }
 protected override void OnRead(Server.Core.Stream.ByteBuffer stream)
 {
 }
Ejemplo n.º 20
0
 protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
 {
 }
Ejemplo n.º 21
0
 protected override void OnWrite(NetworkStream stream, Server.Core.Stream.ByteBuffer buffer)
 {
 }
Ejemplo n.º 22
0
 protected override void OnAfterWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
 {
     client.LastKeepAlive = KeepAlive;
 }
Ejemplo n.º 23
0
 protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
 {
     buffer.WriteVarint(ID);
     buffer.WriteString("{\"version\":{\"name\":\"1.7.2\",\"protocol\":4},\"players\":{\"max\":" + client.Server._config.maxPlayers + ",\"online\":" + client.Server.GetPlayerCount() + ",\"sample\":[]},\"description\":{\"text\":\"" + client.Server._config.name + "\"},\"favicon\":\"data:image/png;base64,\"}");
 }
 protected override void OnAfterWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
 {
     Entities.Clear();
 }
Ejemplo n.º 25
0
 protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
 {
     buffer.WriteVarint(ID);
     buffer.WriteLong(Time);
 }