Client side of the new Dimension support.

This commit is contained in:
LexManos 2012-02-28 18:52:52 -08:00
parent cfc68427ef
commit fcaddfd0fa
6 changed files with 272 additions and 0 deletions

View File

@ -0,0 +1,97 @@
--- ../src_base/minecraft/net/minecraft/client/Minecraft.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src_work/minecraft/net/minecraft/client/Minecraft.java 0000-00-00 00:00:00.000000000 -0000
@@ -1615,70 +1615,47 @@
public void usePortal(int i)
{
+ usePortal(i, new Teleporter());
+ }
+ public void usePortal(int i, Teleporter teleporter)
+ {
int j = thePlayer.dimension;
thePlayer.dimension = i;
theWorld.setEntityDead(thePlayer);
thePlayer.isDead = false;
+ WorldProvider pNew = WorldProvider.getProviderForDimension(i);
+ WorldProvider pOld = WorldProvider.getProviderForDimension(j);
double d = thePlayer.posX;
double d1 = thePlayer.posZ;
- double d2 = 1.0D;
- if (j > -1 && thePlayer.dimension == -1)
- {
- d2 = 0.125D;
- }
- else if (j == -1 && thePlayer.dimension > -1)
- {
- d2 = 8D;
- }
+ double d2 = pOld.getMovementFactor() / pNew.getMovementFactor();
d *= d2;
d1 *= d2;
- if (thePlayer.dimension == -1)
+
+ World world = new World(theWorld, pNew);
+ if (thePlayer.isEntityAlive())
{
- thePlayer.setLocationAndAngles(d, thePlayer.posY, d1, thePlayer.rotationYaw, thePlayer.rotationPitch);
- if (thePlayer.isEntityAlive())
- {
- theWorld.updateEntityWithOptionalForce(thePlayer, false);
- }
- World world = null;
- world = new World(theWorld, WorldProvider.getProviderForDimension(thePlayer.dimension));
- changeWorld(world, "Entering the Nether", thePlayer);
- }
- else if (thePlayer.dimension == 0)
- {
- if (thePlayer.isEntityAlive())
- {
- thePlayer.setLocationAndAngles(d, thePlayer.posY, d1, thePlayer.rotationYaw, thePlayer.rotationPitch);
- theWorld.updateEntityWithOptionalForce(thePlayer, false);
- }
- World world1 = null;
- world1 = new World(theWorld, WorldProvider.getProviderForDimension(thePlayer.dimension));
- if (j == -1)
- {
- changeWorld(world1, "Leaving the Nether", thePlayer);
- }
- else
- {
- changeWorld(world1, "Leaving the End", thePlayer);
- }
+ theWorld.updateEntityWithOptionalForce(thePlayer, false);
}
- else
+
+ if (thePlayer.dimension == 1)
{
- World world2 = null;
- world2 = new World(theWorld, WorldProvider.getProviderForDimension(thePlayer.dimension));
- ChunkCoordinates chunkcoordinates = world2.getEntrancePortalLocation();
+ ChunkCoordinates chunkcoordinates = world.getEntrancePortalLocation();
d = chunkcoordinates.posX;
thePlayer.posY = chunkcoordinates.posY;
d1 = chunkcoordinates.posZ;
- thePlayer.setLocationAndAngles(d, thePlayer.posY, d1, 90F, 0.0F);
- if (thePlayer.isEntityAlive())
- {
- world2.updateEntityWithOptionalForce(thePlayer, false);
- }
- changeWorld(world2, "Entering the End", thePlayer);
+ }
+
+ if (thePlayer.dimension == 0)
+ {
+ changeWorld(world, pOld.getDepartMessage(), thePlayer);
+ }
+ else
+ {
+ changeWorld(world, pNew.getWelcomeMessage(), thePlayer);
}
thePlayer.worldObj = theWorld;
System.out.println((new StringBuilder()).append("Teleported to ").append(theWorld.worldProvider.worldType).toString());
- if (thePlayer.isEntityAlive() && j < 1)
+ if (thePlayer.isEntityAlive())
{
thePlayer.setLocationAndAngles(d, thePlayer.posY, d1, thePlayer.rotationYaw, thePlayer.rotationPitch);
theWorld.updateEntityWithOptionalForce(thePlayer, false);

View File

@ -0,0 +1,23 @@
--- ../src_base/minecraft/net/minecraft/src/SaveOldDir.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src_work/minecraft/net/minecraft/src/SaveOldDir.java 0000-00-00 00:00:00.000000000 -0000
@@ -13,18 +13,12 @@
public IChunkLoader getChunkLoader(WorldProvider worldprovider)
{
File file = getSaveDirectory();
- if (worldprovider instanceof WorldProviderHell)
+ if (worldprovider.getSaveFolder() != null)
{
- File file1 = new File(file, "DIM-1");
+ File file1 = new File(file, worldprovider.getSaveFolder());
file1.mkdirs();
return new ThreadedChunkLoader(file1);
}
- if (worldprovider instanceof WorldProviderEnd)
- {
- File file2 = new File(file, "DIM1");
- file2.mkdirs();
- return new ThreadedChunkLoader(file2);
- }
else
{
return new ThreadedChunkLoader(file);

View File

@ -0,0 +1,71 @@
--- ../src_base/minecraft/net/minecraft/src/WorldProvider.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src_work/minecraft/net/minecraft/src/WorldProvider.java 0000-00-00 00:00:00.000000000 -0000
@@ -1,5 +1,7 @@
package net.minecraft.src;
+import net.minecraft.src.forge.DimensionManager;
+
public abstract class WorldProvider
{
public World worldObj;
@@ -142,22 +144,7 @@
public static WorldProvider getProviderForDimension(int i)
{
- if (i == -1)
- {
- return new WorldProviderHell();
- }
- if (i == 0)
- {
- return new WorldProviderSurface();
- }
- if (i == 1)
- {
- return new WorldProviderEnd();
- }
- else
- {
- return null;
- }
+ return DimensionManager.getProvider(i);
}
public float getCloudHeight()
@@ -196,4 +183,36 @@
{
return terrainType != EnumWorldType.FLAT ? 0.03125D : 1.0D;
}
+
+ /**
+ * 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.
+ * It is applied to the players position when they transfer dimensions.
+ * Exa: Nether movement is 8.0
+ * @return The movement factor
+ */
+ public double getMovementFactor()
+ {
+ return 1.0;
+ }
}

View File

@ -0,0 +1,25 @@
--- ../src_base/minecraft/net/minecraft/src/WorldProviderEnd.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src_work/minecraft/net/minecraft/src/WorldProviderEnd.java 0000-00-00 00:00:00.000000000 -0000
@@ -87,4 +87,22 @@
{
return 50;
}
+
+ @Override
+ public String getSaveFolder()
+ {
+ return "DIM1";
+ }
+
+ @Override
+ public String getWelcomeMessage()
+ {
+ return "Entering the End";
+ }
+
+ @Override
+ public String getDepartMessage()
+ {
+ return "Leaving the End";
+ }
}

View File

@ -0,0 +1,31 @@
--- ../src_base/minecraft/net/minecraft/src/WorldProviderHell.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src_work/minecraft/net/minecraft/src/WorldProviderHell.java 0000-00-00 00:00:00.000000000 -0000
@@ -49,4 +49,28 @@
{
return false;
}
+
+ @Override
+ public String getSaveFolder()
+ {
+ return "DIM-1";
+ }
+
+ @Override
+ public String getWelcomeMessage()
+ {
+ return "Entering the Nether";
+ }
+
+ @Override
+ public String getDepartMessage()
+ {
+ return "Leaving the Nether";
+ }
+
+ @Override
+ public double getMovementFactor()
+ {
+ return 8.0;
+ }
}

View File

@ -0,0 +1,25 @@
--- ../src_base/minecraft/net/minecraft/src/WorldProviderSurface.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src_work/minecraft/net/minecraft/src/WorldProviderSurface.java 0000-00-00 00:00:00.000000000 -0000
@@ -5,4 +5,22 @@
public WorldProviderSurface()
{
}
+
+ @Override
+ public String getSaveFolder()
+ {
+ return null;
+ }
+
+ @Override
+ public String getWelcomeMessage()
+ {
+ return null;
+ }
+
+ @Override
+ public String getDepartMessage()
+ {
+ return null;
+ }
}