Skip to content

Commit

Permalink
Allow null NBT tag (#883, #752)
Browse files Browse the repository at this point in the history
ReadNextNBT() now returns an empty dictionary if the NBT tag is 0x00
As per https://wiki.vg/Slot_Data 0x00 being a placeholder for "no NBT"
  • Loading branch information
ORelio committed Mar 8, 2020
1 parent 981bae1 commit c198027
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions MinecraftClient/Protocol/Handlers/DataTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,16 +324,18 @@ public byte ReadNextByte(List<byte> cache)
/// </summary>
private Dictionary<string, object> ReadNextNbt(List<byte> cache, bool root)
{
Dictionary<string, object> NbtData = new Dictionary<string, object>();

if (root)
{
if (cache[0] == 0) // TAG_End
return NbtData;
if (cache[0] != 10) // TAG_Compound
throw new System.IO.InvalidDataException("Failed to decode NBT: Does not start with TAG_Compound");
ReadNextByte(cache); // Tag type (TAG_Compound)
ReadData(ReadNextUShort(cache), cache); // NBT root name
}

Dictionary<string, object> NbtData = new Dictionary<string, object>();

while (true)
{
int fieldType = ReadNextByte(cache);
Expand Down

0 comments on commit c198027

Please sign in to comment.