Skip to content

Commit

Permalink
Fix non-compound files being loadable like normal
Browse files Browse the repository at this point in the history
  • Loading branch information
tryashtar committed Dec 31, 2020
1 parent 8eb0580 commit 0b58ebc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NbtStudio/NbtObjects/NbtFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ private static bool LooksSuspicious(NbtTag tag)
{
if (LooksSuspicious(tag.Name))
return true;
if (tag is NbtString str && LooksSuspicious(str.Value))
return true;
if (tag is NbtContainerTag container && container.Any(x => LooksSuspicious(x.Name)))
return true;
return false;
Expand Down Expand Up @@ -157,6 +159,8 @@ public static NbtFile CreateFromNbt(string path, NbtCompression compression, boo
}
if (file.RootTag == null)
throw new FormatException("File had no root tag");
if (!(file.RootTag is NbtCompound))
throw new FormatException("File did not contain an NBT compound");

return new NbtFile(path, file.RootTag, ExportSettings.AsNbt(file.FileCompression, big_endian, bedrock_header));
}
Expand Down

0 comments on commit 0b58ebc

Please sign in to comment.