fNbt.NbtFile.LoadFromBuffer C# (CSharp) Method

LoadFromBuffer() public method

Loads NBT data from a byte array. Existing RootTag will be replaced. FileName will be set to null.
is null. If an unrecognized/unsupported value was given for ; /// if or is less than zero; /// if the sum of and is greater than the length of . If NBT stream extends beyond the given . If file compression could not be detected or decompressing failed. If an error occurred while parsing data in NBT format.
public LoadFromBuffer ( [ buffer, int index, int length, NbtCompression compression ) : long
buffer [ Stream from which data will be loaded. If is set to AutoDetect, this stream must support seeking.
index int The index into at which the stream begins. Must not be negative.
length int Maximum number of bytes to read from the given buffer. Must not be negative. /// An is thrown if NBT stream is longer than the given length.
compression NbtCompression Compression method to use for loading/saving this file.
return long
        public long LoadFromBuffer([NotNull] byte[] buffer, int index, int length, NbtCompression compression)
        {
            if (buffer == null) throw new ArgumentNullException("buffer");

            using (var ms = new MemoryStream(buffer, index, length)) {
                LoadFromStream(ms, compression, null);
                FileName = null;
                return ms.Position;
            }
        }

Same methods

NbtFile::LoadFromBuffer ( [ buffer, int index, int length, NbtCompression compression, [ selector ) : long

Usage Example

Ejemplo n.º 1
0
        public NbtWrapper ReadNBT()
        {
            if (!this.ReadBoolean())
            {
                return null;
            }

            byte[] nbt = new byte[this.ReadInt32(15)];
            for (int nbtIndex = 0; nbtIndex < nbt.Length; nbtIndex++)
            {
                nbt[nbtIndex] = (byte)this.ReadInt32(8);
            }

            var nbtFile = new NbtFile();
            nbtFile.LoadFromBuffer(nbt, 0, nbt.Length, NbtCompression.GZip);
            NbtCompound rootTag = nbtFile.RootTag;

            return new NbtWrapper { OriginalData = nbt, RootTag = rootTag };
        }
All Usage Examples Of fNbt.NbtFile::LoadFromBuffer