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);
}