From 1db0792d7bd74269d9655bf2b318b6d5d9991c09 Mon Sep 17 00:00:00 2001 From: Anon Date: Mon, 26 Feb 2024 23:39:20 +0100 Subject: [PATCH] Temporary Debug info --- .../Protocol/Message/ChatParser.cs | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/MinecraftClient/Protocol/Message/ChatParser.cs b/MinecraftClient/Protocol/Message/ChatParser.cs index 3e47d72600..3bdaf4be56 100644 --- a/MinecraftClient/Protocol/Message/ChatParser.cs +++ b/MinecraftClient/Protocol/Message/ChatParser.cs @@ -452,11 +452,20 @@ private static string NbtToString(Dictionary nbt) object[] extras = (object[])value; for (int i = 0; i < extras.Length; i++) { - var extraDict = extras[i] is string - ? new Dictionary() { { "text", (string)extras[i] } } - : (Dictionary)extras[i]; - - extraBuilder.Append(NbtToString(extraDict) + "§r"); + try + { + var extraDict = extras[i] is string + ? new Dictionary() { { "text", (string)extras[i] } } + : (Dictionary)extras[i]; + + extraBuilder.Append(NbtToString(extraDict) + "§r"); + } + catch + { + ConsoleIO.WriteLine("[DEBUG] Full object:" + JsonSerializer.Serialize(extras)); + ConsoleIO.WriteLine("[DEBUG] Value in question:" + JsonSerializer.Serialize(extras[i])); + throw; + } } } break; @@ -471,11 +480,21 @@ private static string NbtToString(Dictionary nbt) var withs = (object[])withComponent; for (int i = 0; i < withs.Length; i++) { - var withDict = withs[i] is string - ? new Dictionary() { { "text", (string)withs[i] } } - : (Dictionary)withs[i]; + try + { + var withDict = withs[i] is string + ? new Dictionary() { { "text", (string)withs[i] } } + : (Dictionary)withs[i]; - translateString.Add(NbtToString(withDict)); + translateString.Add(NbtToString(withDict)); + } + catch + { + ConsoleIO.WriteLine("[DEBUG] Full object:" + JsonSerializer.Serialize(withs)); + ConsoleIO.WriteLine("[DEBUG] Value in question:" + JsonSerializer.Serialize(withs[i])); + + throw; + } } } message = TranslateString(translateKey, translateString);