Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-11-20 06:50:10 +01:00
Add separate client and server state handling
Dieser Commit ist enthalten in:
Ursprung
67f7a66ca5
Commit
c6711919b1
@ -66,7 +66,7 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
public interface ViaBackwardsPlatform {
|
public interface ViaBackwardsPlatform {
|
||||||
|
|
||||||
String MINIMUM_VV_VERSION = "4.8.0";
|
String MINIMUM_VV_VERSION = "4.8.1";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize ViaBackwards.
|
* Initialize ViaBackwards.
|
||||||
|
@ -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.minecraft.entities.Entity1_19_4Types;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.Direction;
|
import com.viaversion.viaversion.api.protocol.packet.Direction;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
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.protocol.packet.State;
|
||||||
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
|
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
|
||||||
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
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.ServerboundConfigurationPackets1_20_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
|
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
|
||||||
import java.util.UUID;
|
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> {
|
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
|
// 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
|
// Add this *before* sending the ack since the server might immediately answer
|
||||||
wrapper.user().put(new ConfigurationPacketStorage());
|
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);
|
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 -> {
|
registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_2.FINISH_CONFIGURATION.getId(), ClientboundConfigurationPackets1_20_2.FINISH_CONFIGURATION.getId(), wrapper -> {
|
||||||
wrapper.cancel();
|
wrapper.cancel();
|
||||||
|
wrapper.user().getProtocolInfo().setServerState(State.PLAY);
|
||||||
wrapper.user().get(ConfigurationPacketStorage.class).setFinished(true);
|
wrapper.user().get(ConfigurationPacketStorage.class).setFinished(true);
|
||||||
|
|
||||||
wrapper.create(ServerboundConfigurationPackets1_20_2.FINISH_CONFIGURATION).sendToServer(Protocol1_20To1_20_2.class);
|
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 -> {
|
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 -> {
|
registerClientbound(ClientboundPackets1_20_2.START_CONFIGURATION, null, wrapper -> {
|
||||||
wrapper.cancel();
|
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
|
// 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);
|
final PacketWrapper configAcknowledgedPacket = wrapper.create(ServerboundPackets1_20_2.CONFIGURATION_ACKNOWLEDGED);
|
||||||
configAcknowledgedPacket.sendToServer(Protocol1_20To1_20_2.class);
|
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());
|
wrapper.user().put(new ConfigurationPacketStorage());
|
||||||
});
|
});
|
||||||
cancelClientbound(ClientboundPackets1_20_2.PONG_RESPONSE);
|
cancelClientbound(ClientboundPackets1_20_2.PONG_RESPONSE);
|
||||||
@ -164,13 +169,8 @@ public final class Protocol1_20To1_20_2 extends BackwardsProtocol<ClientboundPac
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected @Nullable ServerboundPackets1_19_4 configurationAcknowledgedPacket() {
|
protected void registerConfigurationChangeHandlers() {
|
||||||
return null;
|
// Don't register them in the transitioning protocol
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected @Nullable ServerboundPacketType finishConfigurationPacket() {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,7 +3,7 @@ metadata.format.version = "1.1"
|
|||||||
[versions]
|
[versions]
|
||||||
|
|
||||||
# ViaVersion
|
# ViaVersion
|
||||||
viaver = "4.8.0-1.20.2-pre1-SNAPSHOT"
|
viaver = "4.8.1-SNAPSHOT"
|
||||||
|
|
||||||
# Common provided
|
# Common provided
|
||||||
netty = "4.0.20.Final"
|
netty = "4.0.20.Final"
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren