Fixed a NBT crash < 1.20.2 and Fixed a crash with parsing 'extra' section in Chat

This commit is contained in:
Anon 2024-02-18 17:56:02 +01:00
parent 6d016332fb
commit 35cfd4a7db
2 changed files with 5 additions and 8 deletions

View file

@ -565,12 +565,9 @@ namespace MinecraftClient.Protocol.Handlers
var nextId = cache.Dequeue();
if (protocolversion < Protocol18Handler.MC_1_20_2_Version)
{
if (nextId is 10) // TAG_Compound
if (nextId is not 10) // TAG_Compound
throw new System.IO.InvalidDataException("Failed to decode NBT: Does not start with TAG_Compound");
// Read TAG_Compound
ReadNextByte(cache);
// NBT root name
var rootName = Encoding.ASCII.GetString(ReadData(ReadNextUShort(cache), cache));
@ -595,9 +592,6 @@ namespace MinecraftClient.Protocol.Handlers
{ "", result }
};
}
// Read TAG_Compound
//ReadNextByte(cache);
}
}

View file

@ -452,7 +452,10 @@ namespace MinecraftClient.Protocol.Message
object[] extras = (object[])value;
for (int i = 0; i < extras.Length; i++)
{
var extraDict = (Dictionary<string, object>)extras[i];
var extraDict = extras[i] is string
? new Dictionary<string, object>() { { "text", (string)extras[i] } }
: (Dictionary<string, object>)extras[i];
extraBuilder.Append(NbtToString(extraDict) + "§r");
}
}