Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-10-08 11:10:06 +02:00
Don't re-enter config state if the dimension registry did not change
Dieser Commit ist enthalten in:
Ursprung
fe5646a68c
Commit
16f89f2638
@ -133,7 +133,7 @@ public final class Protocol1_20_2To1_20 extends AbstractProtocol<ClientboundPack
|
|||||||
wrapper.cancel();
|
wrapper.cancel();
|
||||||
|
|
||||||
final ConfigurationState configurationState = wrapper.user().get(ConfigurationState.class);
|
final ConfigurationState configurationState = wrapper.user().get(ConfigurationState.class);
|
||||||
if (configurationState.getReenterInfo() == null) {
|
if (configurationState.bridgePhase() != BridgePhase.REENTERING_CONFIGURATION) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,8 +141,7 @@ public final class Protocol1_20_2To1_20 extends AbstractProtocol<ClientboundPack
|
|||||||
configurationState.setBridgePhase(BridgePhase.CONFIGURATION);
|
configurationState.setBridgePhase(BridgePhase.CONFIGURATION);
|
||||||
|
|
||||||
final LastResourcePack lastResourcePack = wrapper.user().get(LastResourcePack.class);
|
final LastResourcePack lastResourcePack = wrapper.user().get(LastResourcePack.class);
|
||||||
sendConfigurationPackets(wrapper.user(), configurationState.getReenterInfo().dimensionRegistry(), lastResourcePack);
|
sendConfigurationPackets(wrapper.user(), configurationState.lastDimensionRegistry(), lastResourcePack);
|
||||||
configurationState.setReenterInfo(null);
|
|
||||||
});
|
});
|
||||||
cancelServerbound(ServerboundPackets1_20_2.CHUNK_BATCH_RECEIVED);
|
cancelServerbound(ServerboundPackets1_20_2.CHUNK_BATCH_RECEIVED);
|
||||||
|
|
||||||
@ -203,7 +202,6 @@ public final class Protocol1_20_2To1_20 extends AbstractProtocol<ClientboundPack
|
|||||||
if (!packetWrapper.user().isClientSide() && !Via.getPlatform().isProxy() && unmappedId == ClientboundPackets1_19_4.SYSTEM_CHAT.getId()) {
|
if (!packetWrapper.user().isClientSide() && !Via.getPlatform().isProxy() && unmappedId == ClientboundPackets1_19_4.SYSTEM_CHAT.getId()) {
|
||||||
// Cancelling this on the Vanilla server will cause it to exceptionally resend a message
|
// Cancelling this on the Vanilla server will cause it to exceptionally resend a message
|
||||||
// Assume that we have already sent the login packet and just let it through
|
// Assume that we have already sent the login packet and just let it through
|
||||||
// TODO Maybe just don't wait for the finish config response?
|
|
||||||
super.transform(direction, State.PLAY, packetWrapper);
|
super.transform(direction, State.PLAY, packetWrapper);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ import com.viaversion.viaversion.api.type.types.version.Types1_20;
|
|||||||
import com.viaversion.viaversion.api.type.types.version.Types1_20_2;
|
import com.viaversion.viaversion.api.type.types.version.Types1_20_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4;
|
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.Protocol1_20_2To1_20;
|
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.Protocol1_20_2To1_20;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundConfigurationPackets1_20_2;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2;
|
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.storage.ConfigurationState;
|
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.storage.ConfigurationState;
|
||||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||||
@ -99,17 +98,19 @@ public final class EntityPacketRewriter1_20_2 extends EntityRewriter<Clientbound
|
|||||||
|
|
||||||
// Debug, flat, last death pos, and portal cooldown at the end unchanged
|
// Debug, flat, last death pos, and portal cooldown at the end unchanged
|
||||||
|
|
||||||
// Send configuration packets first before going into the play protocol state
|
final ConfigurationState configurationBridge = wrapper.user().get(ConfigurationState.class);
|
||||||
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
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (configurationBridge.bridgePhase() == ConfigurationState.BridgePhase.NONE) {
|
if (configurationBridge.bridgePhase() == ConfigurationState.BridgePhase.NONE) {
|
||||||
// Reenter the configuration state
|
// Reenter the configuration state
|
||||||
final PacketWrapper configurationPacket = wrapper.create(ClientboundPackets1_20_2.START_CONFIGURATION);
|
final PacketWrapper configurationPacket = wrapper.create(ClientboundPackets1_20_2.START_CONFIGURATION);
|
||||||
configurationPacket.send(Protocol1_20_2To1_20.class);
|
configurationPacket.send(Protocol1_20_2To1_20.class);
|
||||||
|
|
||||||
// TODO The client clears the resource pack when reentering (?)
|
|
||||||
configurationBridge.setBridgePhase(ConfigurationState.BridgePhase.REENTERING_CONFIGURATION);
|
configurationBridge.setBridgePhase(ConfigurationState.BridgePhase.REENTERING_CONFIGURATION);
|
||||||
configurationBridge.setJoinGamePacket(wrapper);
|
configurationBridge.setJoinGamePacket(wrapper);
|
||||||
configurationBridge.setReenterInfo(new ConfigurationState.ReenterInfo(dimensionRegistry));
|
|
||||||
wrapper.cancel();
|
wrapper.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class ConfigurationState implements StorableObject {
|
public class ConfigurationState implements StorableObject {
|
||||||
@ -35,7 +36,7 @@ public class ConfigurationState implements StorableObject {
|
|||||||
private BridgePhase bridgePhase = BridgePhase.NONE;
|
private BridgePhase bridgePhase = BridgePhase.NONE;
|
||||||
private QueuedPacket joinGamePacket;
|
private QueuedPacket joinGamePacket;
|
||||||
private boolean queuedJoinGame;
|
private boolean queuedJoinGame;
|
||||||
private ReenterInfo reenterInfo;
|
private CompoundTag lastDimensionRegistry;
|
||||||
|
|
||||||
public BridgePhase bridgePhase() {
|
public BridgePhase bridgePhase() {
|
||||||
return bridgePhase;
|
return bridgePhase;
|
||||||
@ -45,12 +46,20 @@ public class ConfigurationState implements StorableObject {
|
|||||||
this.bridgePhase = bridgePhase;
|
this.bridgePhase = bridgePhase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable ReenterInfo getReenterInfo() {
|
public @Nullable CompoundTag lastDimensionRegistry() {
|
||||||
return reenterInfo;
|
return lastDimensionRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReenterInfo(@Nullable final ReenterInfo reenterInfo) {
|
/**
|
||||||
this.reenterInfo = reenterInfo;
|
* Sets the last dimension registry and returns whether it differs from the previously stored one.
|
||||||
|
*
|
||||||
|
* @param dimensionRegistry dimension registry to set
|
||||||
|
* @return whether the dimension registry differs from the previously stored one
|
||||||
|
*/
|
||||||
|
public boolean setLastDimensionRegistry(final CompoundTag dimensionRegistry) {
|
||||||
|
final boolean equals = Objects.equals(this.lastDimensionRegistry, dimensionRegistry);
|
||||||
|
this.lastDimensionRegistry = dimensionRegistry;
|
||||||
|
return !equals;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPacketToQueue(final PacketWrapper wrapper, final boolean clientbound) throws Exception {
|
public void addPacketToQueue(final PacketWrapper wrapper, final boolean clientbound) throws Exception {
|
||||||
@ -123,7 +132,6 @@ public class ConfigurationState implements StorableObject {
|
|||||||
packetQueue.clear();
|
packetQueue.clear();
|
||||||
bridgePhase = BridgePhase.NONE;
|
bridgePhase = BridgePhase.NONE;
|
||||||
queuedJoinGame = false;
|
queuedJoinGame = false;
|
||||||
reenterInfo = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean queuedOrSentJoinGame() {
|
public boolean queuedOrSentJoinGame() {
|
||||||
@ -181,16 +189,4 @@ public class ConfigurationState implements StorableObject {
|
|||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class ReenterInfo {
|
|
||||||
private final CompoundTag dimensionRegistry;
|
|
||||||
|
|
||||||
public ReenterInfo(final CompoundTag dimensionRegistry) {
|
|
||||||
this.dimensionRegistry = dimensionRegistry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompoundTag dimensionRegistry() {
|
|
||||||
return dimensionRegistry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren