Ejemplo n.º 1
0
        public static byte[] GetMapChunk(Chunk c)
        {
            using (MinecraftPacketStream stream = new MinecraftPacketStream())
            {
                stream.WriteByte((byte)MinecraftOpcode.MapChunk);
                stream.WriteInt(c.Position.X);
                stream.WriteShort(c.Position.Y);
                stream.WriteInt(c.Position.Z);
                stream.WriteByte(15);
                stream.WriteByte(127);
                stream.WriteByte(15);

                using (MemoryStream mStream = new MemoryStream())
                {
                    using (ZOutputStream zStream = new ZOutputStream(mStream, zlibConst.Z_BEST_COMPRESSION))
                    {
                        zStream.Write(c.Data, 0, c.Data.Length);
                        stream.WriteInt((int)mStream.Length);
                        mStream.Position = 0;
                        mStream.CopyTo(stream);
                    }
                }
                return stream.ToArray();
            }
        }
Ejemplo n.º 2
0
 public static byte[] GetSpawnPosition(PointInt position)
 {
     using (MinecraftPacketStream stream = new MinecraftPacketStream())
     {
         stream.WriteByte((byte)MinecraftOpcode.SpawnPosition);
         stream.WriteInt(position.X);
         stream.WriteInt(position.Y);
         stream.WriteInt(position.Z);
         return stream.ToArray();
     }
 }
Ejemplo n.º 3
0
 public static byte[] GetPreChunk(Chunk c)
 {
     using (MinecraftPacketStream stream = new MinecraftPacketStream())
     {
         stream.WriteByte((byte)MinecraftOpcode.PreChunk);
         stream.WriteInt(c.Position.X);
         stream.WriteInt(c.Position.Z);
         stream.WriteBool(true);
         return stream.ToArray();
     }
 }