Skip to content

Commit

Permalink
Hotfix for 'minecraft:chat_type' not present in the dictionary (#2794)
Browse files Browse the repository at this point in the history
  • Loading branch information
breadbyte authored Sep 6, 2024
1 parent c5dc517 commit 27e6643
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions MinecraftClient/Protocol/Message/ChatParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,25 @@ public enum MessageType
public static void ReadChatType(Dictionary<string, object> registryCodec)
{
Dictionary<int, MessageType> chatTypeDictionary = ChatId2Type ?? new();
var chatTypeListNbt =
(object[])(((Dictionary<string, object>)registryCodec["minecraft:chat_type"])["value"]);

// Check if the chat type registry is in the correct format
if (!registryCodec.ContainsKey("minecraft:chat_type")) {

// If not, then we force the registry to be in the correct format
if (registryCodec.ContainsKey("chat_type")) {

foreach (var key in registryCodec.Keys.ToArray()) {
// Skip entries with a namespace already
if (key.Contains(':', StringComparison.OrdinalIgnoreCase)) continue;

// Assume all other entries are in the minecraft namespace
registryCodec["minecraft:" + key] = registryCodec[key];
registryCodec.Remove(key);
}
}
}

var chatTypeListNbt = (object[])(((Dictionary<string, object>)registryCodec["minecraft:chat_type"])["value"]);
foreach (var (chatName, chatId) in from Dictionary<string, object> chatTypeNbt in chatTypeListNbt
let chatName = (string)chatTypeNbt["name"]
let chatId = (int)chatTypeNbt["id"]
Expand Down

0 comments on commit 27e6643

Please sign in to comment.