Merge branch 'master' into 1.20.6

This commit is contained in:
breadbyte 2025-12-02 00:06:16 +08:00 committed by GitHub
commit 494be0930b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 455 additions and 1655 deletions

View file

@ -56,9 +56,26 @@ namespace MinecraftClient.Protocol.Message
public static void ReadChatType(Dictionary<string, object> registryCodec)
{
var chatTypeDictionary = ChatId2Type ?? new Dictionary<int, MessageType>();
var chatTypeListNbt =
(object[])(((Dictionary<string, object>)registryCodec["minecraft:chat_type"])["value"]);
Dictionary<int, MessageType> chatTypeDictionary = ChatId2Type ?? new();
// 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"]