Merge pull request #91 from cpw/multiversefix

Fix world provider behaviour: WorldProvider.byDimension should always return a new instance- otherwise you can end up with worlds overwriting one another
This commit is contained in:
LexManos 2012-06-27 14:37:01 -07:00
commit 0e6e8b87aa
3 changed files with 31 additions and 16 deletions

View file

@ -1,6 +1,9 @@
package net.minecraft.src.forge; package net.minecraft.src.forge;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.logging.Level;
import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.src.*; import net.minecraft.src.*;
@ -67,4 +70,16 @@ public class DimensionManager
{ {
init(); init();
} }
public static WorldProvider createProviderFor(int i) {
try {
if (providers.containsKey(i))
return getProvider(i).getClass().newInstance();
else
return null;
} catch (Exception e) {
FMLCommonHandler.instance().getFMLLogger().log(Level.SEVERE,String.format("An error occured trying to create an instance of WorldProvider %d (%s)",i,getProvider(i).getClass().getSimpleName()),e);
throw new RuntimeException(e);
}
}
} }

View file

@ -13,7 +13,7 @@
public static WorldProvider getProviderForDimension(int par0) public static WorldProvider getProviderForDimension(int par0)
{ {
- return (WorldProvider)(par0 == -1 ? new WorldProviderHell() : (par0 == 0 ? new WorldProviderSurface() : (par0 == 1 ? new WorldProviderEnd() : null))); - return (WorldProvider)(par0 == -1 ? new WorldProviderHell() : (par0 == 0 ? new WorldProviderSurface() : (par0 == 1 ? new WorldProviderEnd() : null)));
+ return DimensionManager.getProvider(par0); + return DimensionManager.createProviderFor(par0);
} }
/** /**

View file

@ -13,7 +13,7 @@
public static WorldProvider getProviderForDimension(int par0) public static WorldProvider getProviderForDimension(int par0)
{ {
- return (WorldProvider)(par0 == -1 ? new WorldProviderHell() : (par0 == 0 ? new WorldProviderSurface() : (par0 == 1 ? new WorldProviderEnd() : null))); - return (WorldProvider)(par0 == -1 ? new WorldProviderHell() : (par0 == 0 ? new WorldProviderSurface() : (par0 == 1 ? new WorldProviderEnd() : null)));
+ return DimensionManager.getProvider(par0); + return DimensionManager.createProviderFor(par0);
} }
/** /**