From 67f7a66ca55f5ef25786298cb4848497fdb65bc5 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Mon, 25 Sep 2023 10:54:52 +1000 Subject: [PATCH] Fix 1.20.2->1.20 if run on the backend --- .../Protocol1_20To1_20_2.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20to1_20_2/Protocol1_20To1_20_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20to1_20_2/Protocol1_20To1_20_2.java index f7fa71cb..bd2f04fc 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20to1_20_2/Protocol1_20To1_20_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20to1_20_2/Protocol1_20To1_20_2.java @@ -27,6 +27,7 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types; import com.viaversion.viaversion.api.protocol.packet.Direction; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; +import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType; import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.rewriter.EntityRewriter; import com.viaversion.viaversion.api.rewriter.ItemRewriter; @@ -44,6 +45,7 @@ import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.Clientbou import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundConfigurationPackets1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2; import java.util.UUID; +import org.checkerframework.checker.nullness.qual.Nullable; public final class Protocol1_20To1_20_2 extends BackwardsProtocol { @@ -70,17 +72,18 @@ public final class Protocol1_20To1_20_2 extends BackwardsProtocol { - final ServerboundLoginPackets ackPacket = ServerboundLoginPackets.LOGIN_ACKNOWLEDGED; - wrapper.create(ackPacket).sendToServer(Protocol1_20To1_20_2.class); - // We can't set the internal state to configuration here as protocols down the line will expect the state to be play + // Add this *before* sending the ack since the server might immediately answer wrapper.user().put(new ConfigurationPacketStorage()); + wrapper.create(ServerboundLoginPackets.LOGIN_ACKNOWLEDGED).sendToServer(Protocol1_20To1_20_2.class); + // TODO Client needs to be set to CONFIGURATION state }); registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_2.FINISH_CONFIGURATION.getId(), ClientboundConfigurationPackets1_20_2.FINISH_CONFIGURATION.getId(), wrapper -> { wrapper.cancel(); - wrapper.create(ServerboundConfigurationPackets1_20_2.FINISH_CONFIGURATION).sendToServer(Protocol1_20To1_20_2.class); wrapper.user().get(ConfigurationPacketStorage.class).setFinished(true); + wrapper.create(ServerboundConfigurationPackets1_20_2.FINISH_CONFIGURATION).sendToServer(Protocol1_20To1_20_2.class); + // TODO Client needs to be set to PLAY phase }); registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), wrapper -> { @@ -96,6 +99,7 @@ public final class Protocol1_20To1_20_2 extends BackwardsProtocol