27
27
import com .viaversion .viaversion .api .minecraft .entities .Entity1_19_4Types ;
28
28
import com .viaversion .viaversion .api .protocol .packet .Direction ;
29
29
import com .viaversion .viaversion .api .protocol .packet .PacketWrapper ;
30
+ import com .viaversion .viaversion .api .protocol .packet .ServerboundPacketType ;
30
31
import com .viaversion .viaversion .api .protocol .packet .State ;
31
32
import com .viaversion .viaversion .api .rewriter .EntityRewriter ;
32
33
import com .viaversion .viaversion .api .rewriter .ItemRewriter ;
44
45
import com .viaversion .viaversion .protocols .protocol1_20_2to1_20 .packet .ServerboundConfigurationPackets1_20_2 ;
45
46
import com .viaversion .viaversion .protocols .protocol1_20_2to1_20 .packet .ServerboundPackets1_20_2 ;
46
47
import java .util .UUID ;
48
+ import org .checkerframework .checker .nullness .qual .Nullable ;
47
49
48
50
public final class Protocol1_20To1_20_2 extends BackwardsProtocol <ClientboundPackets1_20_2 , ClientboundPackets1_19_4 , ServerboundPackets1_20_2 , ServerboundPackets1_19_4 > {
49
51
@@ -70,17 +72,18 @@ protected void registerPackets() {
70
72
});
71
73
72
74
registerClientbound (State .LOGIN , ClientboundLoginPackets .GAME_PROFILE .getId (), ClientboundLoginPackets .GAME_PROFILE .getId (), wrapper -> {
73
- final ServerboundLoginPackets ackPacket = ServerboundLoginPackets .LOGIN_ACKNOWLEDGED ;
74
- wrapper .create (ackPacket ).sendToServer (Protocol1_20To1_20_2 .class );
75
-
76
75
// We can't set the internal state to configuration here as protocols down the line will expect the state to be play
76
+ // Add this *before* sending the ack since the server might immediately answer
77
77
wrapper .user ().put (new ConfigurationPacketStorage ());
78
+ wrapper .create (ServerboundLoginPackets .LOGIN_ACKNOWLEDGED ).sendToServer (Protocol1_20To1_20_2 .class );
79
+ // TODO Client needs to be set to CONFIGURATION state
78
80
});
79
81
80
82
registerClientbound (State .CONFIGURATION , ClientboundConfigurationPackets1_20_2 .FINISH_CONFIGURATION .getId (), ClientboundConfigurationPackets1_20_2 .FINISH_CONFIGURATION .getId (), wrapper -> {
81
83
wrapper .cancel ();
82
- wrapper .create (ServerboundConfigurationPackets1_20_2 .FINISH_CONFIGURATION ).sendToServer (Protocol1_20To1_20_2 .class );
83
84
wrapper .user ().get (ConfigurationPacketStorage .class ).setFinished (true );
85
+ wrapper .create (ServerboundConfigurationPackets1_20_2 .FINISH_CONFIGURATION ).sendToServer (Protocol1_20To1_20_2 .class );
86
+ // TODO Client needs to be set to PLAY phase
84
87
});
85
88
86
89
registerServerbound (State .LOGIN , ServerboundLoginPackets .HELLO .getId (), ServerboundLoginPackets .HELLO .getId (), wrapper -> {
@@ -96,6 +99,7 @@ protected void registerPackets() {
96
99
// 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
97
100
final PacketWrapper configAcknowledgedPacket = wrapper .create (ServerboundPackets1_20_2 .CONFIGURATION_ACKNOWLEDGED );
98
101
configAcknowledgedPacket .sendToServer (Protocol1_20To1_20_2 .class );
102
+ // TODO Client needs to be set to CONFIGURATION state
99
103
100
104
wrapper .user ().put (new ConfigurationPacketStorage ());
101
105
});
@@ -159,6 +163,16 @@ public void transform(final Direction direction, final State state, final Packet
159
163
}
160
164
}
161
165
166
+ @ Override
167
+ protected @ Nullable ServerboundPackets1_19_4 configurationAcknowledgedPacket () {
168
+ return null ;
169
+ }
170
+
171
+ @ Override
172
+ protected @ Nullable ServerboundPacketType finishConfigurationPacket () {
173
+ return null ;
174
+ }
175
+
162
176
@ Override
163
177
public void init (final UserConnection connection ) {
164
178
addEntityTracker (connection , new EntityTrackerBase (connection , Entity1_19_4Types .PLAYER ));
0 commit comments