From c6711919b1f663367ef0bfaac56bf14479cd180b Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Mon, 25 Sep 2023 18:34:03 +1000 Subject: [PATCH] Add separate client and server state handling --- .../api/ViaBackwardsPlatform.java | 2 +- .../Protocol1_20To1_20_2.java | 26 +++++++++---------- gradle/libs.versions.toml | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java b/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java index a65c7d1e..cf0734c8 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java @@ -66,7 +66,7 @@ import java.util.logging.Logger; public interface ViaBackwardsPlatform { - String MINIMUM_VV_VERSION = "4.8.0"; + String MINIMUM_VV_VERSION = "4.8.1"; /** * Initialize ViaBackwards. 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 bd2f04fc..10d6374f 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,7 +27,6 @@ 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; @@ -45,7 +44,6 @@ 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 { @@ -75,15 +73,21 @@ public final class Protocol1_20To1_20_2 extends BackwardsProtocol { wrapper.cancel(); + wrapper.user().getProtocolInfo().setServerState(State.PLAY); 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 + wrapper.user().getProtocolInfo().setClientState(State.PLAY); }); registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), wrapper -> { @@ -96,11 +100,12 @@ public final class Protocol1_20To1_20_2 extends BackwardsProtocol { wrapper.cancel(); + wrapper.user().getProtocolInfo().setServerState(State.CONFIGURATION); + // TODO: Check whether all the necessary data for the join game packet is always expected by the client or if we need to cache it from the initial login final PacketWrapper configAcknowledgedPacket = wrapper.create(ServerboundPackets1_20_2.CONFIGURATION_ACKNOWLEDGED); configAcknowledgedPacket.sendToServer(Protocol1_20To1_20_2.class); - // TODO Client needs to be set to CONFIGURATION state - + wrapper.user().getProtocolInfo().setClientState(State.CONFIGURATION); wrapper.user().put(new ConfigurationPacketStorage()); }); cancelClientbound(ClientboundPackets1_20_2.PONG_RESPONSE); @@ -164,13 +169,8 @@ public final class Protocol1_20To1_20_2 extends BackwardsProtocol