Merge pull request #33 from vfrz/master

Fixed bug where top-level compound tags without a name would be skipped by the TagWriter.
This commit is contained in:
ForeverZer0 2024-05-17 15:21:44 -04:00 committed by GitHub
commit bd80810e2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 2 deletions

View File

@ -306,7 +306,10 @@ public class TagWriter : TagIO
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private void WriteTypeAndName(Tag tag) private void WriteTypeAndName(Tag tag)
{ {
if (tag.Parent is ListTag || string.IsNullOrEmpty(tag.Name)) if (tag.Parent is ListTag)
return;
if (string.IsNullOrEmpty(tag.Name) && !(tag is CompoundTag && tag.Parent is null))
return; return;
BaseStream.WriteByte((byte) tag.Type); BaseStream.WriteByte((byte) tag.Type);
@ -384,4 +387,4 @@ public class TagWriter : TagIO
else else
BaseStream.Write(GetBytes(count), 0, sizeof(int)); BaseStream.Write(GetBytes(count), 0, sizeof(int));
} }
} }