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:
parent
f174cb3948
commit
43e4ed7872
3 changed files with 31 additions and 16 deletions
|
@ -1,6 +1,9 @@
|
|||
package net.minecraft.src.forge;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
import net.minecraft.src.*;
|
||||
|
||||
|
@ -67,4 +70,16 @@ public class DimensionManager
|
|||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
public static WorldProvider getProviderForDimension(int par0)
|
||||
{
|
||||
- return (WorldProvider)(par0 == -1 ? new WorldProviderHell() : (par0 == 0 ? new WorldProviderSurface() : (par0 == 1 ? new WorldProviderEnd() : null)));
|
||||
+ return DimensionManager.getProvider(par0);
|
||||
+ return DimensionManager.createProviderFor(par0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,30 +21,30 @@
|
|||
{
|
||||
return false;
|
||||
}
|
||||
+
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the sub-folder of the world folder that this WorldProvider saves to.
|
||||
+ * EXA: DIM1, DIM-1
|
||||
+ * @return The sub-folder name to save this world's chunks to.
|
||||
+ */
|
||||
+ public abstract String getSaveFolder();
|
||||
+
|
||||
+
|
||||
+ /**
|
||||
+ * A message to display to the user when they transfer to this dimension.
|
||||
+ *
|
||||
+ *
|
||||
+ * @return The message to be displayed
|
||||
+ */
|
||||
+ public abstract String getWelcomeMessage();
|
||||
+
|
||||
+
|
||||
+ /**
|
||||
+ * A Message to display to the user when they transfer out of this dismension.
|
||||
+ *
|
||||
+ *
|
||||
+ * @return The message to be displayed
|
||||
+ */
|
||||
+ public abstract String getDepartMessage();
|
||||
+
|
||||
+
|
||||
+ /**
|
||||
+ * The dimensions movement factor. Relative to normal overworld.
|
||||
+ * The dimensions movement factor. Relative to normal overworld.
|
||||
+ * It is applied to the players position when they transfer dimensions.
|
||||
+ * Exa: Nether movement is 8.0
|
||||
+ * @return The movement factor
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
public static WorldProvider getProviderForDimension(int par0)
|
||||
{
|
||||
- return (WorldProvider)(par0 == -1 ? new WorldProviderHell() : (par0 == 0 ? new WorldProviderSurface() : (par0 == 1 ? new WorldProviderEnd() : null)));
|
||||
+ return DimensionManager.getProvider(par0);
|
||||
+ return DimensionManager.createProviderFor(par0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,30 +21,30 @@
|
|||
{
|
||||
return this.terrainType.getMinimumSpawnHeight(worldObj);
|
||||
}
|
||||
+
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the sub-folder of the world folder that this WorldProvider saves to.
|
||||
+ * EXA: DIM1, DIM-1
|
||||
+ * @return The sub-folder name to save this world's chunks to.
|
||||
+ */
|
||||
+ public abstract String getSaveFolder();
|
||||
+
|
||||
+
|
||||
+ /**
|
||||
+ * A message to display to the user when they transfer to this dimension.
|
||||
+ *
|
||||
+ *
|
||||
+ * @return The message to be displayed
|
||||
+ */
|
||||
+ public abstract String getWelcomeMessage();
|
||||
+
|
||||
+
|
||||
+ /**
|
||||
+ * A Message to display to the user when they transfer out of this dismension.
|
||||
+ *
|
||||
+ *
|
||||
+ * @return The message to be displayed
|
||||
+ */
|
||||
+ public abstract String getDepartMessage();
|
||||
+
|
||||
+
|
||||
+ /**
|
||||
+ * The dimensions movement factor. Relative to normal overworld.
|
||||
+ * The dimensions movement factor. Relative to normal overworld.
|
||||
+ * It is applied to the players position when they transfer dimensions.
|
||||
+ * Exa: Nether movement is 8.0
|
||||
+ * @return The movement factor
|
||||
|
|
Loading…
Reference in a new issue