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"
This commit is contained in:
ORelio 2020-03-08 14:29:06 +01:00
parent 981bae184a
commit c19802725f

View file

@ -324,16 +324,18 @@ namespace MinecraftClient.Protocol.Handlers
/// </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);