From 26e8a2f2e6e57bb0aca3bab2c3fc965f45da1c25 Mon Sep 17 00:00:00 2001 From: BruceChen Date: Sat, 21 Mar 2026 01:08:08 +0800 Subject: [PATCH] fix: adapt chat packet format for MC 1.21.5 (protocol 770) 1.21.5 changed LastSeenMessages.Update to include a trailing checksum byte (0 = skip verification). This affects serverbound chat and signed chat command packets. Additionally, the clientbound PlayerChat packet now has a globalIndex VarInt prepended before the sender UUID. Without these fixes: - Sending plain chat messages causes DecoderException on the server - Receiving player chat messages causes Queue empty crash in MCC Made-with: Cursor --- MinecraftClient/Protocol/Handlers/Protocol18.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 743fd3e9..9beae52e 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -1069,6 +1069,11 @@ namespace MinecraftClient.Protocol.Handlers // 1.19.3+ // Header section // net.minecraft.network.packet.s2c.play.ChatMessageS2CPacket#write + + // 1.21.5+: globalIndex prepended before sender UUID + if (protocolVersion >= MC_1_21_5_Version) + dataTypes.ReadNextVarInt(packetData); + var senderUuid = dataTypes.ReadNextUUID(packetData); var index = dataTypes.ReadNextVarInt(packetData); // Signature is fixed size of 256 bytes @@ -3732,6 +3737,10 @@ namespace MinecraftClient.Protocol.Handlers case >= MC_1_19_3_Version: fields.AddRange(DataTypes.GetVarInt(messageCount1193)); fields.AddRange(bitset1193); + + // Checksum: Byte (1.21.5+, 0 = skip verification) + if (protocolVersion >= MC_1_21_5_Version) + fields.Add(0); break; } @@ -3835,6 +3844,10 @@ namespace MinecraftClient.Protocol.Handlers // Acknowledged: BitSet fields.AddRange(bitset1193); + + // Checksum: Byte (1.21.5+, 0 = skip verification) + if (protocolVersion >= MC_1_21_5_Version) + fields.Add(0); break; case MC_1_19_2_Version: // Message Acknowledgment