From c19802725f039e61ad1ce015637f3692df05a6a2 Mon Sep 17 00:00:00 2001 From: ORelio Date: Sun, 8 Mar 2020 14:29:06 +0100 Subject: [PATCH] Allow null NBT tag (#883, #752) 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" --- MinecraftClient/Protocol/Handlers/DataTypes.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MinecraftClient/Protocol/Handlers/DataTypes.cs b/MinecraftClient/Protocol/Handlers/DataTypes.cs index 489eb405..3b8c36fa 100644 --- a/MinecraftClient/Protocol/Handlers/DataTypes.cs +++ b/MinecraftClient/Protocol/Handlers/DataTypes.cs @@ -324,16 +324,18 @@ namespace MinecraftClient.Protocol.Handlers /// private Dictionary ReadNextNbt(List cache, bool root) { + Dictionary NbtData = new Dictionary(); + 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 NbtData = new Dictionary(); - while (true) { int fieldType = ReadNextByte(cache);