Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-08 17:20:24 +01:00
Ursprung
11cb113619
Commit
0b93af88a3
@ -138,10 +138,28 @@ public final class Protocol1_20_2To1_20 extends AbstractProtocol<ClientboundPack
|
||||
configurationState.sendQueuedPackets(wrapper.user());
|
||||
configurationState.clear();
|
||||
});
|
||||
registerServerbound(State.CONFIGURATION, ServerboundConfigurationPackets1_20_2.CLIENT_INFORMATION.getId(), -1, queueServerboundPacket(ServerboundPackets1_20_2.CLIENT_SETTINGS));
|
||||
registerServerbound(State.CONFIGURATION, ServerboundConfigurationPackets1_20_2.CLIENT_INFORMATION.getId(), -1, wrapper -> {
|
||||
final ConfigurationState.ClientInformation clientInformation = new ConfigurationState.ClientInformation(
|
||||
wrapper.read(Type.STRING), // Language
|
||||
wrapper.read(Type.BYTE), // View distance
|
||||
wrapper.read(Type.VAR_INT), // Chat visibility
|
||||
wrapper.read(Type.BOOLEAN), // Chat colors
|
||||
wrapper.read(Type.UNSIGNED_BYTE), // Model customization
|
||||
wrapper.read(Type.VAR_INT), // Main hand
|
||||
wrapper.read(Type.BOOLEAN), // Text filtering enabled
|
||||
wrapper.read(Type.BOOLEAN) // Allow listing in server list preview
|
||||
);
|
||||
|
||||
// Store it to re-send it when another ClientboundLoginPacket is sent, since the client will only send it
|
||||
// once per connection right after the handshake
|
||||
final ConfigurationState configurationState = wrapper.user().get(ConfigurationState.class);
|
||||
configurationState.setClientInformation(clientInformation);
|
||||
wrapper.cancel();
|
||||
});
|
||||
registerServerbound(State.CONFIGURATION, ServerboundConfigurationPackets1_20_2.CUSTOM_PAYLOAD.getId(), -1, queueServerboundPacket(ServerboundPackets1_20_2.PLUGIN_MESSAGE));
|
||||
registerServerbound(State.CONFIGURATION, ServerboundConfigurationPackets1_20_2.KEEP_ALIVE.getId(), -1, queueServerboundPacket(ServerboundPackets1_20_2.KEEP_ALIVE));
|
||||
registerServerbound(State.CONFIGURATION, ServerboundConfigurationPackets1_20_2.PONG.getId(), -1, queueServerboundPacket(ServerboundPackets1_20_2.PONG));
|
||||
|
||||
// Cancel this, as it will always just be the response to a re-sent pack from us
|
||||
registerServerbound(State.CONFIGURATION, ServerboundConfigurationPackets1_20_2.RESOURCE_PACK.getId(), -1, PacketWrapper::cancel);
|
||||
|
||||
|
@ -101,6 +101,7 @@ public final class EntityPacketRewriter1_20_2 extends EntityRewriter<Clientbound
|
||||
final ConfigurationState configurationBridge = wrapper.user().get(ConfigurationState.class);
|
||||
if (!configurationBridge.setLastDimensionRegistry(dimensionRegistry)) {
|
||||
// No change, so no need to re-enter the configuration state - just let this one through
|
||||
configurationBridge.sendClientInformation(wrapper.user());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,8 @@ import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ServerboundPackets1_19_4;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.Protocol1_20_2To1_20;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
@ -37,6 +39,7 @@ public class ConfigurationState implements StorableObject {
|
||||
private QueuedPacket joinGamePacket;
|
||||
private boolean queuedJoinGame;
|
||||
private CompoundTag lastDimensionRegistry;
|
||||
private ClientInformation clientInformation;
|
||||
|
||||
public BridgePhase bridgePhase() {
|
||||
return bridgePhase;
|
||||
@ -62,6 +65,10 @@ public class ConfigurationState implements StorableObject {
|
||||
return !equals;
|
||||
}
|
||||
|
||||
public void setClientInformation(final ClientInformation clientInformation) {
|
||||
this.clientInformation = clientInformation;
|
||||
}
|
||||
|
||||
public void addPacketToQueue(final PacketWrapper wrapper, final boolean clientbound) throws Exception {
|
||||
packetQueue.add(toQueuedPacket(wrapper, clientbound, false));
|
||||
}
|
||||
@ -104,6 +111,8 @@ public class ConfigurationState implements StorableObject {
|
||||
joinGamePacket = null;
|
||||
}
|
||||
|
||||
sendClientInformation(connection);
|
||||
|
||||
final ConfigurationState.QueuedPacket[] queuedPackets = packetQueue.toArray(new ConfigurationState.QueuedPacket[0]);
|
||||
packetQueue.clear();
|
||||
|
||||
@ -142,6 +151,24 @@ public class ConfigurationState implements StorableObject {
|
||||
NONE, PROFILE_SENT, CONFIGURATION, REENTERING_CONFIGURATION
|
||||
}
|
||||
|
||||
public void sendClientInformation(final UserConnection connection) throws Exception {
|
||||
if (clientInformation == null) {
|
||||
// Should never be null, but we also shouldn't error
|
||||
return;
|
||||
}
|
||||
|
||||
final PacketWrapper settingsPacket = PacketWrapper.create(ServerboundPackets1_19_4.CLIENT_SETTINGS, connection);
|
||||
settingsPacket.write(Type.STRING, clientInformation.language);
|
||||
settingsPacket.write(Type.BYTE, clientInformation.viewDistance);
|
||||
settingsPacket.write(Type.VAR_INT, clientInformation.chatVisibility);
|
||||
settingsPacket.write(Type.BOOLEAN, clientInformation.showChatColors);
|
||||
settingsPacket.write(Type.UNSIGNED_BYTE, clientInformation.modelCustomization);
|
||||
settingsPacket.write(Type.VAR_INT, clientInformation.mainHand);
|
||||
settingsPacket.write(Type.BOOLEAN, clientInformation.textFiltering);
|
||||
settingsPacket.write(Type.BOOLEAN, clientInformation.allowListing);
|
||||
settingsPacket.sendToServer(Protocol1_20_2To1_20.class);
|
||||
}
|
||||
|
||||
public static final class QueuedPacket {
|
||||
private final ByteBuf buf;
|
||||
private final boolean clientbound;
|
||||
@ -189,4 +216,28 @@ public class ConfigurationState implements StorableObject {
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
public static final class ClientInformation {
|
||||
private final String language;
|
||||
private final byte viewDistance;
|
||||
private final int chatVisibility;
|
||||
private final boolean showChatColors;
|
||||
private final short modelCustomization;
|
||||
private final int mainHand;
|
||||
private final boolean textFiltering;
|
||||
private final boolean allowListing;
|
||||
|
||||
public ClientInformation(final String language, final byte viewDistance, final int chatVisibility,
|
||||
final boolean showChatColors, final short modelCustomization, final int mainHand,
|
||||
final boolean textFiltering, final boolean allowListing) {
|
||||
this.language = language;
|
||||
this.viewDistance = viewDistance;
|
||||
this.chatVisibility = chatVisibility;
|
||||
this.showChatColors = showChatColors;
|
||||
this.modelCustomization = modelCustomization;
|
||||
this.mainHand = mainHand;
|
||||
this.textFiltering = textFiltering;
|
||||
this.allowListing = allowListing;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren