diff --git a/src/main/java/com/replaymod/recording/handler/ConnectionEventHandler.java b/src/main/java/com/replaymod/recording/handler/ConnectionEventHandler.java index 876430fc..1137485f 100644 --- a/src/main/java/com/replaymod/recording/handler/ConnectionEventHandler.java +++ b/src/main/java/com/replaymod/recording/handler/ConnectionEventHandler.java @@ -19,6 +19,10 @@ import net.minecraft.client.resource.language.I18n; import net.minecraft.network.ClientConnection; import org.apache.logging.log4j.Logger; +//#if MC>=11900 +//$$ import com.replaymod.recording.mixin.ClientLoginNetworkHandlerAccessor; +//#endif + //#if MC>=11600 import net.minecraft.world.World; //#else @@ -88,6 +92,15 @@ public class ConnectionEventHandler { } } + ServerInfo serverInfo; + //#if MC>=11903 + //$$ serverInfo = networkManager.getPacketListener() instanceof ClientLoginNetworkHandlerAccessor loginNetworkHandler + //$$ ? loginNetworkHandler.getServerInfo() + //$$ : null; + //#else + serverInfo = mc.getCurrentServerEntry(); + //#endif + String worldName; String serverName = null; boolean autoStart = core.getSettingsRegistry().get(Setting.AUTO_START_RECORDING); @@ -98,8 +111,12 @@ public class ConnectionEventHandler { //$$ worldName = mc.getServer().getLevelName(); //#endif serverName = worldName; - } else if (mc.getCurrentServerEntry() != null) { - ServerInfo serverInfo = mc.getCurrentServerEntry(); + //#if MC>=11100 + } else if (mc.isConnectedToRealms()) { + // we can't access the server name without tapping too deep in the Realms Library + worldName = "A Realms Server"; + //#endif + } else if (serverInfo != null) { worldName = serverInfo.address; if (!I18n.translate("selectServer.defaultName").equals(serverInfo.name)) { serverName = serverInfo.name; @@ -109,11 +126,6 @@ public class ConnectionEventHandler { if (autoStartServer != null) { autoStart = autoStartServer; } - //#if MC>=11100 - } else if (mc.isConnectedToRealms()) { - // we can't access the server name without tapping too deep in the Realms Library - worldName = "A Realms Server"; - //#endif } else { logger.info("Recording not started as the world is neither local nor remote (probably a replay)."); return; diff --git a/src/main/java/com/replaymod/recording/mixin/ClientLoginNetworkHandlerAccessor.java b/src/main/java/com/replaymod/recording/mixin/ClientLoginNetworkHandlerAccessor.java new file mode 100644 index 00000000..37990587 --- /dev/null +++ b/src/main/java/com/replaymod/recording/mixin/ClientLoginNetworkHandlerAccessor.java @@ -0,0 +1,17 @@ +package com.replaymod.recording.mixin; + +import net.minecraft.client.network.ClientLoginNetworkHandler; +import org.spongepowered.asm.mixin.Mixin; + +//#if MC>=11903 +//$$ import net.minecraft.client.network.ServerInfo; +//$$ import org.spongepowered.asm.mixin.gen.Accessor; +//#endif + +@Mixin(ClientLoginNetworkHandler.class) +public interface ClientLoginNetworkHandlerAccessor { + //#if MC>=11903 + //$$ @Accessor + //$$ ServerInfo getServerInfo(); + //#endif +} diff --git a/src/main/resources/mixins.recording.replaymod.json b/src/main/resources/mixins.recording.replaymod.json index 5dec2e07..df7f09ea 100644 --- a/src/main/resources/mixins.recording.replaymod.json +++ b/src/main/resources/mixins.recording.replaymod.json @@ -5,6 +5,7 @@ "server": [], "client": [ "AddServerScreenAccessor", + "ClientLoginNetworkHandlerAccessor", "EntityLivingBaseAccessor", "IntegratedServerAccessor", "NetworkManagerAccessor", diff --git a/version.txt b/version.txt index d48d3702..a04abec9 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -2.6.9 +2.6.10