From fbacc550e28b0fac49c7222587cf83d42825d35c Mon Sep 17 00:00:00 2001 From: adsicmes <1483492332@qq.com> Date: Thu, 9 Apr 2026 17:15:55 +0800 Subject: [PATCH] fix: correct scoreboard packet parsing for UpdateScore and ScoreboardObjective UpdateScore Display Name was read with ReadNextString instead of ReadNextChat. In 1.20.4+ Text Components are NBT-encoded, causing ReadNextString to misinterpret the tag type byte as a string length prefix, corrupting the read offset and exhausting the packet queue. Also fix incomplete Number Format consumption in both UpdateScore and ScoreboardObjective: the styled (Compound Tag) and fixed (Text Component) payloads after the VarInt enum were not being read, leaving stale bytes in the packet queue. --- .../Protocol/Handlers/Protocol18.cs | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 9edf18ab..c8dda0dc 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -3034,7 +3034,18 @@ namespace MinecraftClient.Protocol.Handlers if (protocolVersion >= MC_1_20_4_Version) { if (dataTypes.ReadNextBool(packetData)) // Has Number Format + { numberFormat = dataTypes.ReadNextVarInt(packetData); // Number Format + switch (numberFormat) + { + case 1: // styled + dataTypes.ReadNextNbt(packetData); // Styling compound tag + break; + case 2: // fixed + dataTypes.ReadNextChat(packetData); // Content text component + break; + } + } } } @@ -3055,11 +3066,21 @@ namespace MinecraftClient.Protocol.Handlers objectiveValue2 = dataTypes.ReadNextVarInt(packetData); // Value if (dataTypes.ReadNextBool(packetData)) // Has Display Name - objectiveDisplayName3 = - ChatParser.ParseText(dataTypes.ReadNextString(packetData)); // Has Display Name + objectiveDisplayName3 = dataTypes.ReadNextChat(packetData); if (dataTypes.ReadNextBool(packetData)) // Has Number Format + { numberFormat2 = dataTypes.ReadNextVarInt(packetData); // Number Format + switch (numberFormat2) + { + case 1: // styled + dataTypes.ReadNextNbt(packetData); // Styling compound tag + break; + case 2: // fixed + dataTypes.ReadNextChat(packetData); // Content text component + break; + } + } } else {