mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2025-01-02 18:39:16 +01:00
Fixed code behaviour
This commit is contained in:
parent
ca828d2bc2
commit
973a3df00c
@ -27,7 +27,7 @@ public interface IServerInfo {
|
||||
void viaFabricPlus$forceVersion(final ProtocolVersion version);
|
||||
|
||||
boolean viaFabricPlus$passedDirectConnectScreen();
|
||||
void viaFabricPlus$passDirectConnectScreen();
|
||||
void viaFabricPlus$passDirectConnectScreen(final boolean state);
|
||||
|
||||
ProtocolVersion viaFabricPlus$translatingVersion();
|
||||
void viaFabricPlus$setTranslatingVersion(final ProtocolVersion version);
|
||||
|
@ -64,6 +64,7 @@ public abstract class MixinConnectScreen_1 {
|
||||
ProtocolVersion targetVersion = ProtocolTranslator.getTargetVersion();
|
||||
if (mixinServerInfo.viaFabricPlus$forcedVersion() != null && !mixinServerInfo.viaFabricPlus$passedDirectConnectScreen()) {
|
||||
targetVersion = mixinServerInfo.viaFabricPlus$forcedVersion();
|
||||
mixinServerInfo.viaFabricPlus$passDirectConnectScreen(false); // reset state
|
||||
}
|
||||
if (targetVersion == ProtocolTranslator.AUTO_DETECT_PROTOCOL) {
|
||||
this.field_2416.setStatus(Text.translatable("base.viafabricplus.detecting_server_version"));
|
||||
|
@ -35,7 +35,7 @@ public abstract class MixinMultiplayerScreen {
|
||||
|
||||
@WrapOperation(method = "directConnect", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;connect(Lnet/minecraft/client/network/ServerInfo;)V"))
|
||||
private void storeDirectConnectionPhase(MultiplayerScreen instance, ServerInfo entry, Operation<Void> original) {
|
||||
((IServerInfo) entry).viaFabricPlus$passDirectConnectScreen();
|
||||
((IServerInfo) entry).viaFabricPlus$passDirectConnectScreen(true);
|
||||
original.call(instance, entry);
|
||||
}
|
||||
|
||||
|
@ -46,9 +46,9 @@ public abstract class MixinMultiplayerServerListPinger {
|
||||
|
||||
@Redirect(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/util/profiler/PerformanceLog;)Lnet/minecraft/network/ClientConnection;"))
|
||||
private ClientConnection setForcedVersion(InetSocketAddress address, boolean useEpoll, PerformanceLog packetSizeLog, @Local(argsOnly = true) ServerInfo serverInfo) {
|
||||
final ProtocolVersion forcedVersion = ((IServerInfo) serverInfo).viaFabricPlus$forcedVersion();
|
||||
final IServerInfo mixinServerInfo = (IServerInfo) serverInfo;
|
||||
|
||||
if (forcedVersion != null && !((IServerInfo) serverInfo).viaFabricPlus$passedDirectConnectScreen()) {
|
||||
if (mixinServerInfo.viaFabricPlus$forcedVersion() != null && !mixinServerInfo.viaFabricPlus$passedDirectConnectScreen()) {
|
||||
// We use the PerformanceLog field to store the forced version since it's always null when pinging a server
|
||||
// So we can create a dummy instance, store the forced version in it and later destroy the instance again
|
||||
// To avoid any side effects, we also support cases where a mod is also creating a PerformanceLog instance
|
||||
@ -57,7 +57,8 @@ public abstract class MixinMultiplayerServerListPinger {
|
||||
}
|
||||
|
||||
// Attach the forced version to the PerformanceLog instance
|
||||
((IPerformanceLog) packetSizeLog).viaFabricPlus$setForcedVersion(forcedVersion);
|
||||
((IPerformanceLog) packetSizeLog).viaFabricPlus$setForcedVersion(mixinServerInfo.viaFabricPlus$forcedVersion());
|
||||
mixinServerInfo.viaFabricPlus$passDirectConnectScreen(false);
|
||||
}
|
||||
|
||||
return ClientConnection.connect(address, useEpoll, packetSizeLog);
|
||||
|
@ -81,15 +81,12 @@ public abstract class MixinServerInfo implements IServerInfo {
|
||||
|
||||
@Override
|
||||
public boolean viaFabricPlus$passedDirectConnectScreen() {
|
||||
final boolean previous = viaFabricPlus$passedDirectConnectScreen;
|
||||
viaFabricPlus$passedDirectConnectScreen = false;
|
||||
|
||||
return previous;
|
||||
return viaFabricPlus$passedDirectConnectScreen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaFabricPlus$passDirectConnectScreen() {
|
||||
viaFabricPlus$passedDirectConnectScreen = true;
|
||||
public void viaFabricPlus$passDirectConnectScreen(boolean state) {
|
||||
viaFabricPlus$passedDirectConnectScreen = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user