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); }