mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2025-02-25 03:12:53 +01:00
Always replace the port in direct connection screen, otherwise only when bedrock is forced
This commit is contained in:
parent
7bda76f004
commit
945a77a713
@ -148,15 +148,14 @@ public class ClientsideFixes {
|
||||
/**
|
||||
* Replaces the default port when parsing a server address if the default port should be replaced
|
||||
*
|
||||
* @param info The server info
|
||||
* @param info The server info
|
||||
* @param version The protocol version
|
||||
* @return The server address with the replaced default port
|
||||
*/
|
||||
public static ServerAddress replaceDefaultPort(final ServerInfo info) {
|
||||
final boolean isBedrock = Objects.equals(((IServerInfo) info).viaFabricPlus$forcedVersion(), BedrockProtocolVersion.bedrockLatest);
|
||||
|
||||
public static ServerAddress replaceDefaultPort(final ServerInfo info, final ProtocolVersion version) {
|
||||
// If the default port for this entry should be replaced, check if the address already contains a port
|
||||
// We can't just replace vanilla's default port because a bedrock server might be running on the same port
|
||||
if (BedrockSettings.global().replaceDefaultPort.getValue() && isBedrock && !info.address.contains(":")) {
|
||||
if (BedrockSettings.global().replaceDefaultPort.getValue() && Objects.equals(version, BedrockProtocolVersion.bedrockLatest) && !info.address.contains(":")) {
|
||||
return ServerAddress.parse(info.address + ":" + 19132);
|
||||
} else {
|
||||
return ServerAddress.parse(info.address);
|
||||
|
@ -21,6 +21,8 @@ package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import de.florianmichael.viafabricplus.fixes.ClientsideFixes;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import de.florianmichael.viafabricplus.screen.base.ProtocolSelectionScreen;
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
@ -56,7 +58,13 @@ public abstract class MixinMultiplayerScreen extends Screen {
|
||||
|
||||
@Redirect(method = "connect(Lnet/minecraft/client/network/ServerInfo;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ServerAddress;parse(Ljava/lang/String;)Lnet/minecraft/client/network/ServerAddress;"))
|
||||
private ServerAddress replaceDefaultPort(String address, @Local(argsOnly = true) ServerInfo entry) {
|
||||
return ClientsideFixes.replaceDefaultPort(entry);
|
||||
if (((IServerInfo) entry).viaFabricPlus$passedDirectConnectScreen()) {
|
||||
// If the user has already passed the direct connect screen, we use the target version
|
||||
return ClientsideFixes.replaceDefaultPort(entry, ProtocolTranslator.getTargetVersion());
|
||||
} else {
|
||||
// Otherwise the forced version is used
|
||||
return ClientsideFixes.replaceDefaultPort(entry, ((IServerInfo) entry).viaFabricPlus$forcedVersion());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,8 @@ public abstract class MixinMultiplayerServerListPinger {
|
||||
|
||||
@Redirect(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ServerAddress;parse(Ljava/lang/String;)Lnet/minecraft/client/network/ServerAddress;"))
|
||||
private ServerAddress replaceDefaultPort(String address, @Local(argsOnly = true) ServerInfo entry) {
|
||||
return ClientsideFixes.replaceDefaultPort(entry);
|
||||
// Replace port when pinging the server and the forced version is set
|
||||
return ClientsideFixes.replaceDefaultPort(entry, ((IServerInfo) entry).viaFabricPlus$forcedVersion());
|
||||
}
|
||||
|
||||
@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;"))
|
||||
|
Loading…
Reference in New Issue
Block a user