Skip to content

Commit 27e6643

Browse files
authored
Hotfix for 'minecraft:chat_type' not present in the dictionary (#2794)
1 parent c5dc517 commit 27e6643

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

MinecraftClient/Protocol/Message/ChatParser.cs

+19-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,25 @@ public enum MessageType
3434
public static void ReadChatType(Dictionary<string, object> registryCodec)
3535
{
3636
Dictionary<int, MessageType> chatTypeDictionary = ChatId2Type ?? new();
37-
var chatTypeListNbt =
38-
(object[])(((Dictionary<string, object>)registryCodec["minecraft:chat_type"])["value"]);
37+
38+
// Check if the chat type registry is in the correct format
39+
if (!registryCodec.ContainsKey("minecraft:chat_type")) {
40+
41+
// If not, then we force the registry to be in the correct format
42+
if (registryCodec.ContainsKey("chat_type")) {
43+
44+
foreach (var key in registryCodec.Keys.ToArray()) {
45+
// Skip entries with a namespace already
46+
if (key.Contains(':', StringComparison.OrdinalIgnoreCase)) continue;
47+
48+
// Assume all other entries are in the minecraft namespace
49+
registryCodec["minecraft:" + key] = registryCodec[key];
50+
registryCodec.Remove(key);
51+
}
52+
}
53+
}
54+
55+
var chatTypeListNbt = (object[])(((Dictionary<string, object>)registryCodec["minecraft:chat_type"])["value"]);
3956
foreach (var (chatName, chatId) in from Dictionary<string, object> chatTypeNbt in chatTypeListNbt
4057
let chatName = (string)chatTypeNbt["name"]
4158
let chatId = (int)chatTypeNbt["id"]

0 commit comments

Comments
 (0)