Exemplo n.º 1
0
        static void Save(Stream stream, byte[] blocks, int width, int length)
        {
            using (GZipStream wrapper = new GZipStream(stream, CompressionMode.Compress)) {
                BinaryWriter writer = new BinaryWriter(wrapper);
                NbtFile      nbt    = new NbtFile(writer);

                nbt.Write(NbtTagType.Compound); nbt.Write("ClassicWorld");
                nbt.Write(NbtTagType.Int8);
                nbt.Write("FormatVersion"); nbt.WriteUInt8(1);

                nbt.Write(NbtTagType.Int8Array);
                nbt.Write("UUID"); nbt.WriteInt32(16); nbt.WriteBytes(new byte[16]);
                nbt.Write(NbtTagType.Int16); nbt.Write("X"); nbt.WriteInt16((short)width);
                nbt.Write(NbtTagType.Int16); nbt.Write("Y"); nbt.WriteInt16((short)128);
                nbt.Write(NbtTagType.Int16); nbt.Write("Z"); nbt.WriteInt16((short)length);

                nbt.Write(NbtTagType.Compound); nbt.Write("Spawn");
                nbt.Write(NbtTagType.Int16); nbt.Write("X"); nbt.WriteInt16(0);
                nbt.Write(NbtTagType.Int16); nbt.Write("Y"); nbt.WriteInt16(0);
                nbt.Write(NbtTagType.Int16); nbt.Write("Z"); nbt.WriteInt16(0);
                nbt.Write(NbtTagType.Int8);  nbt.Write("H"); nbt.WriteUInt8(0);
                nbt.Write(NbtTagType.Int8);  nbt.Write("P"); nbt.WriteUInt8(0);
                nbt.Write(NbtTagType.End);

                nbt.Write(NbtTagType.Int8Array);
                nbt.Write("BlockArray"); nbt.WriteInt32(blocks.Length); nbt.WriteBytes(blocks);
                nbt.Write(NbtTagType.End);
            }
        }