示例#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);
        }
示例#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);
 }
示例#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);
 }
示例#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);
 }
 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);
 }
 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);
 }
        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);
        }
示例#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);
     }
 }
示例#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);
 }
示例#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;
        }
示例#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");
        }
示例#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);
 }
 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);
 }
示例#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);
        }
示例#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);
        }
示例#18
0
 protected override void OnRead(Server.Core.Stream.ByteBuffer stream)
 {
     Time = stream.ReadLong();
 }
 protected override void OnRead(Server.Core.Stream.ByteBuffer stream)
 {
 }
示例#20
0
 protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
 {
 }
示例#21
0
 protected override void OnWrite(NetworkStream stream, Server.Core.Stream.ByteBuffer buffer)
 {
 }
 protected override void OnAfterWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
 {
     client.LastKeepAlive = KeepAlive;
 }
示例#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();
 }
示例#25
0
 protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer)
 {
     buffer.WriteVarint(ID);
     buffer.WriteLong(Time);
 }