mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2025-02-27 03:33:24 +01:00
Try to improve mod compatibility with port replacement
This commit is contained in:
parent
78722e7257
commit
f99845314a
@ -171,13 +171,13 @@ public class ClientsideFixes {
|
||||
* @param version The protocol version
|
||||
* @return The server address with the replaced default port
|
||||
*/
|
||||
public static ServerAddress replaceDefaultPort(final String address, final ProtocolVersion version) {
|
||||
public static String replaceDefaultPort(final String address, 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() && Objects.equals(version, BedrockProtocolVersion.bedrockLatest) && !address.contains(":")) {
|
||||
return ServerAddress.parse(address + ":" + ProtocolConstants.BEDROCK_DEFAULT_PORT);
|
||||
return address + ":" + ProtocolConstants.BEDROCK_DEFAULT_PORT;
|
||||
} else {
|
||||
return ServerAddress.parse(address);
|
||||
return address;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,6 @@ public class EntityRidingOffsetsPre1_20_2 {
|
||||
if (passenger instanceof AnimalEntity) xOffset += 0.2F;
|
||||
}
|
||||
|
||||
|
||||
return new Vec3d(xOffset, yOffset, 0F).rotateY(-(float) (Math.PI / 2));
|
||||
}
|
||||
} else if (entity instanceof CamelEntity camelEntity) {
|
||||
|
@ -19,7 +19,10 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.fixes.ClientsideFixes;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
@ -34,7 +37,6 @@ import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(MultiplayerScreen.class)
|
||||
@ -56,15 +58,17 @@ public abstract class MixinMultiplayerScreen extends Screen {
|
||||
this.addDrawableChild(GeneralSettings.withOrientation(builder, buttonPosition, width, height).build());
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (((IServerInfo) entry).viaFabricPlus$passedDirectConnectScreen()) {
|
||||
// If the user has already passed the direct connect screen, we use the target version
|
||||
return ClientsideFixes.replaceDefaultPort(address, ProtocolTranslator.getTargetVersion());
|
||||
@WrapOperation(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, Operation<ServerAddress> original, @Local(argsOnly = true) ServerInfo entry) {
|
||||
final IServerInfo mixinServerInfo = (IServerInfo) entry;
|
||||
|
||||
ProtocolVersion version;
|
||||
if (mixinServerInfo.viaFabricPlus$passedDirectConnectScreen()) {
|
||||
version = ProtocolTranslator.getTargetVersion();
|
||||
} else {
|
||||
// Otherwise the forced version is used
|
||||
return ClientsideFixes.replaceDefaultPort(address, ((IServerInfo) entry).viaFabricPlus$forcedVersion());
|
||||
version = mixinServerInfo.viaFabricPlus$forcedVersion();
|
||||
}
|
||||
return original.call(ClientsideFixes.replaceDefaultPort(address, version));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,17 +32,16 @@ import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.util.profiler.MultiValueDebugSampleLogImpl;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
@Mixin(MultiplayerServerListPinger.class)
|
||||
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) {
|
||||
@WrapOperation(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, Operation<ServerAddress> original, @Local(argsOnly = true) ServerInfo entry) {
|
||||
// Replace port when pinging the server and the forced version is set
|
||||
return ClientsideFixes.replaceDefaultPort(address, ((IServerInfo) entry).viaFabricPlus$forcedVersion());
|
||||
return original.call(ClientsideFixes.replaceDefaultPort(address, ((IServerInfo) entry).viaFabricPlus$forcedVersion()));
|
||||
}
|
||||
|
||||
@WrapOperation(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/util/profiler/MultiValueDebugSampleLogImpl;)Lnet/minecraft/network/ClientConnection;"))
|
||||
|
Loading…
Reference in New Issue
Block a user