Ejemplo n.º 1
0
        /// <summary>
        /// Sends a player a Chunk
        /// </summary>
        /// <param name='c'>
        /// The chunk to send
        /// </param>
        public void SendChunk(Chunk c)
        {
            if (c == null) return;

                byte[] CompressedData = c.GetCompressedData();
                if (CompressedData == null) { SendPreChunk(c, 0); return; }

                SendPreChunk(c, 1);

                //Send Chunk Data
                byte[] bytes = new byte[17 + CompressedData.Length];
                util.EndianBitConverter.Big.GetBytes((int)(c.x * 16)).CopyTo(bytes, 0);
                util.EndianBitConverter.Big.GetBytes((int)0).CopyTo(bytes, 4);
                util.EndianBitConverter.Big.GetBytes((int)(c.z * 16)).CopyTo(bytes, 6);
                bytes[10] = 15;
                bytes[11] = 127;
                bytes[12] = 15;
                util.EndianBitConverter.Big.GetBytes(CompressedData.Length).CopyTo(bytes, 13);
                CompressedData.CopyTo(bytes, 17);
                SendRaw(0x33, bytes);

                c.Update(level, this);

                lock (VisibleChunks)
                    if (!VisibleChunks.Contains(c.point)) VisibleChunks.Add(c.point);
        }