Esempio n. 1
0
        static byte[] DecodeChunk(string path)
        {
            using (Stream stream = File.OpenRead(path)) {
                using (Stream gs = new GZipStream(stream, CompressionMode.Decompress)) {
                    BinaryReader reader = new BinaryReader(gs);
                    if (reader.ReadByte() != (byte)NbtTagType.Compound)
                    {
                        throw new InvalidDataException("Nbt file must start with Tag_Compound");
                    }

                    NbtFile     file     = new NbtFile(reader);
                    NbtTag      root     = file.ReadTag((byte)NbtTagType.Compound, true);
                    NbtCompound children = (NbtCompound)root.Value;

                    NbtCompound level = (NbtCompound)children["Level"].Value;
                    return((byte[])level["Blocks"].Value);
                }
            }
        }