diff --git a/common/net/minecraftforge/common/DimensionManager.java b/common/net/minecraftforge/common/DimensionManager.java index fb6e8bfe8c..63b417e9fb 100644 --- a/common/net/minecraftforge/common/DimensionManager.java +++ b/common/net/minecraftforge/common/DimensionManager.java @@ -1,5 +1,6 @@ package net.minecraftforge.common; +import java.util.ArrayList; import java.util.Hashtable; import java.util.Map.Entry; import java.util.logging.Level; @@ -78,13 +79,11 @@ public class DimensionManager { worlds.put(id, world); - WorldServer[] tmp = new WorldServer[worlds.size() > 3 ? worlds.size() : 3]; - for (int x = -1; x <= 1; x++) - { - tmp[(x == 0 ? 0 : x == -1 ? 1 : 2)] = worlds.get(x); - } + ArrayList tmp = new ArrayList(); + tmp.add(worlds.get( 0)); + tmp.add(worlds.get(-1)); + tmp.add(worlds.get( 1)); - int x = 3; for (Entry entry : worlds.entrySet()) { int dim = entry.getKey(); @@ -92,10 +91,10 @@ public class DimensionManager { continue; } - tmp[x++] = entry.getValue(); + tmp.add(entry.getValue()); } - MinecraftServer.getServer().theWorldServer = tmp; + MinecraftServer.getServer().theWorldServer = tmp.toArray(new WorldServer[0]); MinecraftServer.getServer().worldTickTimes.put(id, new long[100]); } @@ -126,7 +125,9 @@ public class DimensionManager { if (dimensions.containsKey(dim)) { - return providers.get(getProviderType(dim)).newInstance(); + WorldProvider provider = providers.get(getProviderType(dim)).newInstance(); + provider.setDimension(dim); + return provider; } else { diff --git a/patches/common/net/minecraft/src/WorldProvider.java.patch b/patches/common/net/minecraft/src/WorldProvider.java.patch index b18bdc8e41..c3664d0f42 100644 --- a/patches/common/net/minecraft/src/WorldProvider.java.patch +++ b/patches/common/net/minecraft/src/WorldProvider.java.patch @@ -16,10 +16,25 @@ } @SideOnly(Side.CLIENT) -@@ -249,4 +250,73 @@ - { - return false; +@@ -251,4 +252,79 @@ } + + public abstract String func_80004_l(); +-} ++ ++ /*======================================= Forge Start =========================================*/ ++ private int dimensionID = 0; ++ ++ /** ++ * Sets the providers current dimension ID, used in default getSaveFolder() ++ * Added to allow default providers to be registered for multiple dimensions. ++ * ++ * @param dim Dimension ID ++ */ ++ public void setDimension(int dim) ++ { ++ this.dimensionID = dim; ++ } + + /** + * Returns the sub-folder of the world folder that this WorldProvider saves to. @@ -28,15 +43,7 @@ + */ + public String getSaveFolder() + { -+ if (this instanceof WorldProviderEnd) -+ { -+ return "DIM1"; -+ } -+ else if (this instanceof WorldProviderHell) -+ { -+ return "DIM-1"; -+ } -+ return null; ++ return (dimensionID == 0 ? null : "DIM" + dimensionID); + } + + /** @@ -89,4 +96,4 @@ + } + return 1.0; + } - } ++} \ No newline at end of file