3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-11-17 13:30:14 +01:00

Add separate client and server state handling

Dieser Commit ist enthalten in:
Nassim Jahnke 2023-09-25 18:34:03 +10:00
Ursprung 67f7a66ca5
Commit c6711919b1
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
3 geänderte Dateien mit 15 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -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.

Datei anzeigen

@ -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<ClientboundPackets1_20_2, ClientboundPackets1_19_4, ServerboundPackets1_20_2, ServerboundPackets1_19_4> {
@ -75,15 +73,21 @@ public final class Protocol1_20To1_20_2 extends BackwardsProtocol<ClientboundPac
// 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());
// Overwrite what is set by the base protocol
wrapper.user().getProtocolInfo().setClientState(State.LOGIN);
// States set to configuration in the base protocol
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.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<ClientboundPac
registerClientbound(ClientboundPackets1_20_2.START_CONFIGURATION, null, wrapper -> {
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<ClientboundPac
}
@Override
protected @Nullable ServerboundPackets1_19_4 configurationAcknowledgedPacket() {
return null;
}
@Override
protected @Nullable ServerboundPacketType finishConfigurationPacket() {
return null;
protected void registerConfigurationChangeHandlers() {
// Don't register them in the transitioning protocol
}
@Override

Datei anzeigen

@ -3,7 +3,7 @@ metadata.format.version = "1.1"
[versions]
# ViaVersion
viaver = "4.8.0-1.20.2-pre1-SNAPSHOT"
viaver = "4.8.1-SNAPSHOT"
# Common provided
netty = "4.0.20.Final"