fNbt.NbtFile.LoadFromStream C# (CSharp) 메소드

LoadFromStream() 공개 메소드

Loads NBT data from a stream. Existing RootTag will be replaced
is null. If an unrecognized/unsupported value was given for . If is set to AutoDetect, but the stream is not seekable. If file ended earlier than expected. If file compression could not be detected, decompressing failed, or given stream does not support reading. If an error occurred while parsing data in NBT format.
public LoadFromStream ( [ stream, NbtCompression compression ) : long
stream [ Stream from which data will be loaded. If compression is set to AutoDetect, this stream must support seeking.
compression NbtCompression Compression method to use for loading/saving this file.
리턴 long
        public long LoadFromStream([NotNull] Stream stream, NbtCompression compression)
        {
            return LoadFromStream(stream, compression, null);
        }

Same methods

NbtFile::LoadFromStream ( [ stream, NbtCompression compression, [ selector ) : long

Usage Example

예제 #1
0
        public void Load()
        {
            if (IsCorrupt || IsExternal)
            {
                return;
            }
            var stream = Region.GetStream();

            stream.Seek(Offset + 4, SeekOrigin.Begin);
            int compression = stream.ReadByte();

            if (compression == -1)
            {
                IsCorrupt = true;
                Remove();
            }
            else
            {
                if ((compression & (1 << 7)) != 0)
                {
                    IsExternal          = true;
                    ExternalCompression = (byte)compression;
                }
                else
                {
                    var file = new fNbt.NbtFile();
                    try
                    {
                        file.LoadFromStream(stream, NbtCompression.AutoDetect);
                        Compression = file.FileCompression;
                        SetData(file.GetRootTag <NbtCompound>());
                    }
                    catch
                    {
                        IsCorrupt = true;
                        Remove();
                    }
                }
            }
            stream.Dispose();
            OnLoaded?.Invoke(this, EventArgs.Empty);
        }
All Usage Examples Of fNbt.NbtFile::LoadFromStream