From 0b93af88a350fcb83f9c9c31e3ad5fb58b430cf0 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Tue, 3 Oct 2023 19:49:44 +1000 Subject: [PATCH] Re-send client information when re-entering play state Fixes #3442 --- .../Protocol1_20_2To1_20.java | 20 +++++++- .../rewriter/EntityPacketRewriter1_20_2.java | 1 + .../storage/ConfigurationState.java | 51 +++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/Protocol1_20_2To1_20.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/Protocol1_20_2To1_20.java index 647c8248a..30c32c18d 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/Protocol1_20_2To1_20.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/Protocol1_20_2To1_20.java @@ -138,10 +138,28 @@ public final class Protocol1_20_2To1_20 extends AbstractProtocol { + final ConfigurationState.ClientInformation clientInformation = new ConfigurationState.ClientInformation( + wrapper.read(Type.STRING), // Language + wrapper.read(Type.BYTE), // View distance + wrapper.read(Type.VAR_INT), // Chat visibility + wrapper.read(Type.BOOLEAN), // Chat colors + wrapper.read(Type.UNSIGNED_BYTE), // Model customization + wrapper.read(Type.VAR_INT), // Main hand + wrapper.read(Type.BOOLEAN), // Text filtering enabled + wrapper.read(Type.BOOLEAN) // Allow listing in server list preview + ); + + // Store it to re-send it when another ClientboundLoginPacket is sent, since the client will only send it + // once per connection right after the handshake + final ConfigurationState configurationState = wrapper.user().get(ConfigurationState.class); + configurationState.setClientInformation(clientInformation); + wrapper.cancel(); + }); registerServerbound(State.CONFIGURATION, ServerboundConfigurationPackets1_20_2.CUSTOM_PAYLOAD.getId(), -1, queueServerboundPacket(ServerboundPackets1_20_2.PLUGIN_MESSAGE)); registerServerbound(State.CONFIGURATION, ServerboundConfigurationPackets1_20_2.KEEP_ALIVE.getId(), -1, queueServerboundPacket(ServerboundPackets1_20_2.KEEP_ALIVE)); registerServerbound(State.CONFIGURATION, ServerboundConfigurationPackets1_20_2.PONG.getId(), -1, queueServerboundPacket(ServerboundPackets1_20_2.PONG)); + // Cancel this, as it will always just be the response to a re-sent pack from us registerServerbound(State.CONFIGURATION, ServerboundConfigurationPackets1_20_2.RESOURCE_PACK.getId(), -1, PacketWrapper::cancel); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/rewriter/EntityPacketRewriter1_20_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/rewriter/EntityPacketRewriter1_20_2.java index 517949089..74761c67c 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/rewriter/EntityPacketRewriter1_20_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/rewriter/EntityPacketRewriter1_20_2.java @@ -101,6 +101,7 @@ public final class EntityPacketRewriter1_20_2 extends EntityRewriter