3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 16:40:10 +01:00

Properly throw the client information packet into the queue instead

Dieser Commit ist enthalten in:
Nassim Jahnke 2023-10-03 20:54:51 +10:00
Ursprung cabb95a3a4
Commit fdb7f47749
2 geänderte Dateien mit 13 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -101,7 +101,10 @@ public final class EntityPacketRewriter1_20_2 extends EntityRewriter<Clientbound
final ConfigurationState configurationBridge = wrapper.user().get(ConfigurationState.class); final ConfigurationState configurationBridge = wrapper.user().get(ConfigurationState.class);
if (!configurationBridge.setLastDimensionRegistry(dimensionRegistry)) { if (!configurationBridge.setLastDimensionRegistry(dimensionRegistry)) {
// No change, so no need to re-enter the configuration state - just let this one through // No change, so no need to re-enter the configuration state - just let this one through
configurationBridge.sendClientInformation(wrapper.user()); final PacketWrapper clientInformationPacket = configurationBridge.clientInformationPacket(wrapper.user());
if (clientInformationPacket != null) {
clientInformationPacket.sendToServer(Protocol1_20_2To1_20.class);
}
return; return;
} }

Datei anzeigen

@ -106,12 +106,16 @@ public class ConfigurationState implements StorableObject {
} }
public void sendQueuedPackets(final UserConnection connection) throws Exception { public void sendQueuedPackets(final UserConnection connection) throws Exception {
if (joinGamePacket != null) { final boolean hasJoinGamePacket = joinGamePacket != null;
if (hasJoinGamePacket) {
packetQueue.add(0, joinGamePacket); packetQueue.add(0, joinGamePacket);
joinGamePacket = null; joinGamePacket = null;
} }
sendClientInformation(connection); final PacketWrapper clientInformationPacket = clientInformationPacket(connection);
if (clientInformationPacket != null) {
packetQueue.add(hasJoinGamePacket ? 1 : 0, toQueuedPacket(clientInformationPacket, false, true));
}
final ConfigurationState.QueuedPacket[] queuedPackets = packetQueue.toArray(new ConfigurationState.QueuedPacket[0]); final ConfigurationState.QueuedPacket[] queuedPackets = packetQueue.toArray(new ConfigurationState.QueuedPacket[0]);
packetQueue.clear(); packetQueue.clear();
@ -151,10 +155,10 @@ public class ConfigurationState implements StorableObject {
NONE, PROFILE_SENT, CONFIGURATION, REENTERING_CONFIGURATION NONE, PROFILE_SENT, CONFIGURATION, REENTERING_CONFIGURATION
} }
public void sendClientInformation(final UserConnection connection) throws Exception { public @Nullable PacketWrapper clientInformationPacket(final UserConnection connection) {
if (clientInformation == null) { if (clientInformation == null) {
// Should never be null, but we also shouldn't error // Should never be null, but we also shouldn't error
return; return null;
} }
final PacketWrapper settingsPacket = PacketWrapper.create(ServerboundPackets1_19_4.CLIENT_SETTINGS, connection); final PacketWrapper settingsPacket = PacketWrapper.create(ServerboundPackets1_19_4.CLIENT_SETTINGS, connection);
@ -166,7 +170,7 @@ public class ConfigurationState implements StorableObject {
settingsPacket.write(Type.VAR_INT, clientInformation.mainHand); settingsPacket.write(Type.VAR_INT, clientInformation.mainHand);
settingsPacket.write(Type.BOOLEAN, clientInformation.textFiltering); settingsPacket.write(Type.BOOLEAN, clientInformation.textFiltering);
settingsPacket.write(Type.BOOLEAN, clientInformation.allowListing); settingsPacket.write(Type.BOOLEAN, clientInformation.allowListing);
settingsPacket.scheduleSendToServer(Protocol1_20_2To1_20.class); return settingsPacket;
} }
public static final class QueuedPacket { public static final class QueuedPacket {