From 0168cf8aa174aea06c6644cef4d6f1fae5299948 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Mar 2026 19:46:19 +0000 Subject: [PATCH 1/2] Initial plan From 8ab9f8505fa3ca29f95f37820708ac3cbf678596 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Mar 2026 19:58:58 +0000 Subject: [PATCH 2/2] Fix crash when scoreboard is updated on MC 1.20.4+ ChatParser.NbtToString crashed with InvalidCastException when a scoreboard update was received. The switch expressions for extra/with NBT arrays only handled int and string; everything else fell through to a hard cast to Dictionary, which fails for long/short/byte/float/double. Replace with a pattern that explicitly matches string and Dictionary, and converts all other values (any numeric NBT type) to a text component via ToString(). This matches the behavior that ReadNbtField can return for TAG_Byte, TAG_Short, TAG_Int, TAG_Long, TAG_Float, and TAG_Double. Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com> Agent-Logs-Url: https://github.com/MCCTeam/Minecraft-Console-Client/sessions/44b66082-14ee-4966-9c23-4074134e0187 --- MinecraftClient/Protocol/Message/ChatParser.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/MinecraftClient/Protocol/Message/ChatParser.cs b/MinecraftClient/Protocol/Message/ChatParser.cs index 28311400..802ed0c7 100644 --- a/MinecraftClient/Protocol/Message/ChatParser.cs +++ b/MinecraftClient/Protocol/Message/ChatParser.cs @@ -531,12 +531,9 @@ namespace MinecraftClient.Protocol.Message { var extraDict = extras[i] switch { - int => new Dictionary { { "text", $"{extras[i]}" } }, - string => new Dictionary - { - { "text", (string)extras[i] } - }, - _ => (Dictionary)extras[i] + string s => new Dictionary { { "text", s } }, + Dictionary d => d, + _ => new Dictionary { { "text", extras[i]?.ToString() ?? string.Empty } } }; extraBuilder.Append(NbtToString(extraDict) + "§r"); @@ -556,12 +553,9 @@ namespace MinecraftClient.Protocol.Message { var withDict = withs[i] switch { - int => new Dictionary { { "text", $"{withs[i]}" } }, - string => new Dictionary - { - { "text", (string)withs[i] } - }, - _ => (Dictionary)withs[i] + string s => new Dictionary { { "text", s } }, + Dictionary d => d, + _ => new Dictionary { { "text", withs[i]?.ToString() ?? string.Empty } } }; translateString.Add(NbtToString(withDict));