Use correct minimum ClientSettings packet length for older protocol versions

For correctness's sake: in practice this bug never got triggered because `locale` is almost always a string of length 5+ ("en_us").
This commit is contained in:
Wouter Gritter
2026-09-01 13:19:46 +02:00
parent ddea763c8b
commit 940f395e3e
@@ -213,7 +213,34 @@ public class ClientSettingsPacket implements MinecraftPacket {
@Override @Override
public int decodeExpectedMinLength(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { public int decodeExpectedMinLength(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
return 1 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1; int minLength = 1 // locale
+ 1 // viewDistance
+ 1 // chatVisibility
+ 1; // chatColors
if (version.noGreaterThan(ProtocolVersion.MINECRAFT_1_7_6)) {
minLength += 1; // difficulty
}
minLength += 1; // skinParts
if (version.noLessThan(ProtocolVersion.MINECRAFT_1_9)) {
minLength += 1; // mainHand
if (version.noLessThan(ProtocolVersion.MINECRAFT_1_17)) {
minLength += 1; // textFilteringEnabled
if (version.noLessThan(ProtocolVersion.MINECRAFT_1_18)) {
minLength += 1; // clientListingAllowed
if (version.noLessThan(ProtocolVersion.MINECRAFT_1_21_2)) {
minLength += 1; // particleStatus
}
}
}
}
return minLength;
} }
@Override @Override