Skip to content

Commit

Permalink
Modded dim names in waypoint manager and edit screen
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticdrew committed Mar 14, 2024
1 parent 03fcbc5 commit 3063c3d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
1 change: 1 addition & 0 deletions doc/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ <h1>JourneyMap ${version} for Minecraft ${mcversion}</h1>
<ul>
<li>Fixed: bop plants showing up as wrong color.</li>
<li>Fixed: Fairplay not loading and invalid zip errors at startup</li>
<li>Fixed: Modded dim names in waypoint manager and edit screen.</li>
</ul>
2 changes: 2 additions & 0 deletions src/main/java/journeymap/client/JourneymapClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import journeymap.client.cartography.ColorManager;
import journeymap.client.data.DataCache;
import journeymap.client.data.WaypointsData;
import journeymap.client.data.WorldData;
import journeymap.client.feature.FeatureManager;
import journeymap.client.forge.event.EventHandlerManager;
import journeymap.client.forge.helper.ForgeHelper;
Expand Down Expand Up @@ -494,6 +495,7 @@ private void reset()
WorldInfoHandler.requestWorldID();
}

WorldData.dimNames.clear();
loadConfigProperties();
DataCache.instance().purge();
chunkRenderController = new ChunkRenderController();
Expand Down
35 changes: 30 additions & 5 deletions src/main/java/journeymap/client/data/WorldData.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.google.common.base.Strings;
import com.google.common.cache.CacheLoader;
import cpw.mods.fml.client.FMLClientHandler;
import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import journeymap.client.Constants;
import journeymap.client.JourneymapClient;
import journeymap.client.feature.Feature;
Expand All @@ -19,6 +21,7 @@
import journeymap.common.Journeymap;
import journeymap.common.version.VersionCheck;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.IReloadableResourceManager;
import net.minecraft.network.NetworkManager;
import net.minecraft.server.integrated.IntegratedServer;
import net.minecraft.world.WorldProvider;
Expand All @@ -31,7 +34,14 @@
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.net.URLEncoder;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;

// 1.8
//import net.minecraftforge.fml.client.FMLClientHandler;
Expand All @@ -58,13 +68,23 @@ public class WorldData extends CacheLoader<Class, WorldData>
String[] iconSetNames;
int browser_poll;

public static TIntObjectMap<String> dimNames;

/**
* Constructor.
*/
public WorldData()
{
}

static
{
dimNames = new TIntObjectHashMap<>();
((IReloadableResourceManager) Minecraft.getMinecraft()
.getResourceManager())
.registerReloadListener(iResourceManager -> dimNames.clear());
}

public static boolean isHardcoreAndMultiplayer()
{
WorldData world = DataCache.instance().getWorld(false);
Expand Down Expand Up @@ -285,11 +305,16 @@ public static String getSafeDimensionName(WorldProvider worldProvider)

try
{
String langKey = String.format("jm.common.dimension.%1$d.name", worldProvider.dimensionId);
String dimName = Constants.getString(langKey);
if (langKey.equals(dimName))
String dimName = dimNames.get(worldProvider.dimensionId);
if (dimName == null)
{
dimName = worldProvider.getDimensionName();
String langKey = String.format("jm.common.dimension.%1$d.name", worldProvider.dimensionId);
dimName = Constants.getString(langKey);
if (langKey.equals(dimName))
{
dimName = worldProvider.getDimensionName();
}
dimNames.put(worldProvider.dimensionId, dimName);
}

return dimName;
Expand Down

0 comments on commit 3063c3d

Please sign in to comment.