From f6b248e6cb60c15a5189c1354f7751db7e53801d Mon Sep 17 00:00:00 2001 From: Smyler Date: Sat, 22 Jun 2024 23:49:58 +0200 Subject: [PATCH] Use SmyLib's server info instead of vanilla's --- .../thesmyler/terramap/TerramapClientContext.java | 5 ++--- .../terramap/saving/client/ClientSaveManager.java | 13 ++++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/forge/src/main/java/fr/thesmyler/terramap/TerramapClientContext.java b/forge/src/main/java/fr/thesmyler/terramap/TerramapClientContext.java index bede0ec1..f2edf566 100644 --- a/forge/src/main/java/fr/thesmyler/terramap/TerramapClientContext.java +++ b/forge/src/main/java/fr/thesmyler/terramap/TerramapClientContext.java @@ -38,7 +38,6 @@ import net.buildtheearth.terraplusplus.projection.mercator.WebMercatorProjection; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.multiplayer.ServerData; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -271,7 +270,7 @@ public void reloadState() { } public void saveState() { - ServerData servData = Minecraft.getMinecraft().getCurrentServerData(); + MinecraftServerInfo servData = getGameClient().currentServerInfo(); if(this.proxyForceGlobalSettings && this.proxyUUID != null) { this.saveManager.saveProxyState(this.proxyUUID, this.state); Terramap.instance().logger().debug("Saved proxy state for UUID {} (forced by proxy)", this.proxyUUID); @@ -283,7 +282,7 @@ public void saveState() { Terramap.instance().logger().debug("Saved proxy state for UUID {} (world unknown)", this.proxyUUID); } else if (servData != null) { this.saveManager.saveServerState(servData, this.state); - Terramap.instance().logger().debug("Saved server state for server {} ({})",servData.serverName, servData.serverIP); + Terramap.instance().logger().debug("Saved server state for server {} ({})",servData.name, servData.host); } else { Terramap.instance().logger().debug("Did not save state for unreliable context"); } diff --git a/forge/src/main/java/fr/thesmyler/terramap/saving/client/ClientSaveManager.java b/forge/src/main/java/fr/thesmyler/terramap/saving/client/ClientSaveManager.java index c136f1e4..bd5f4450 100644 --- a/forge/src/main/java/fr/thesmyler/terramap/saving/client/ClientSaveManager.java +++ b/forge/src/main/java/fr/thesmyler/terramap/saving/client/ClientSaveManager.java @@ -2,7 +2,6 @@ import com.google.gson.Gson; import net.smyler.smylib.game.MinecraftServerInfo; -import net.minecraft.client.multiplayer.ServerData; import net.smyler.terramap.Terramap; import java.io.*; @@ -53,8 +52,8 @@ public SavedClientState loadWorldState(UUID worldUUID) { } /** - * Loads a {@link SavedClientState} associated with a specific server, given the server's {@link ServerData}. - * This method will usually be used when a remote world cannot be uniquely identified and we can only identify the server. + * Loads a {@link SavedClientState} associated with a specific server, given the server's {@link MinecraftServerInfo}. + * This method will usually be used when a remote world cannot be uniquely identified, and we can only identify the server. * * @param serverInfo the information of the server to retrieve the save for * @@ -108,14 +107,14 @@ public void saveWorldState(UUID worldUUID, SavedClientState state) { } /** - * Saves a {@link SavedClientState} associated with a specific server, given the server's {@link ServerData}. - * This method will usually be used when a remote world cannot be uniquely identified and we can only identify the server. + * Saves a {@link SavedClientState} associated with a specific server, given the server's {@link MinecraftServerInfo}. + * This method will usually be used when a remote world cannot be uniquely identified, and we can only identify the server. * * @param serverData the information of the server to retrieve the save for * @param state the state to save */ - public void saveServerState(ServerData serverData, SavedClientState state) { - this.saveStateToPath(this.serverDirectory.resolve(serverData.serverIP + EXTENSION), state); + public void saveServerState(MinecraftServerInfo serverData, SavedClientState state) { + this.saveStateToPath(this.serverDirectory.resolve(serverData.host + EXTENSION), state); } /**