Fix SystemChatPacket: Support reading packet properly in newer MC versions (#1461)

This commit is contained in:
Andrey
2024-11-19 20:49:17 +03:00
committed by GitHub
parent cefa3b272e
commit 9cfcfcf2ed

View File

@@ -47,9 +47,12 @@ public class SystemChatPacket implements MinecraftPacket {
@Override @Override
public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
component = ComponentHolder.read(buf, version); component = ComponentHolder.read(buf, version);
// System chat is never decoded so this doesn't matter for now if (version.noLessThan(ProtocolVersion.MINECRAFT_1_19_1)){
type = buf.readBoolean() ? ChatType.GAME_INFO : ChatType.SYSTEM;
} else {
type = ChatType.values()[ProtocolUtils.readVarInt(buf)]; type = ChatType.values()[ProtocolUtils.readVarInt(buf)];
} }
}
@Override @Override
public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {