--- ../src_base/common/net/minecraft/src/WorldProvider.java +++ ../src_work/common/net/minecraft/src/WorldProvider.java @@ -1,5 +1,7 @@ package net.minecraft.src; +import net.minecraftforge.client.SkyProvider; +import net.minecraftforge.common.DimensionManager; import cpw.mods.fml.common.Side; import cpw.mods.fml.common.asm.SideOnly; @@ -30,6 +32,8 @@ /** Array for sunrise/sunset colors (RGBA) */ private float[] colorsSunriseSunset = new float[4]; + + private SkyProvider skyProvider = null; /** * associate an existing world with a World provider, and setup its lightbrightness table @@ -185,7 +189,7 @@ public static WorldProvider getProviderForDimension(int par0) { - return (WorldProvider)(par0 == -1 ? new WorldProviderHell() : (par0 == 0 ? new WorldProviderSurface() : (par0 == 1 ? new WorldProviderEnd() : null))); + return DimensionManager.createProviderFor(par0); } @SideOnly(Side.CLIENT) @@ -251,4 +255,109 @@ } public abstract String func_80007_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. + * EXA: DIM1, DIM-1 + * @return The sub-folder name to save this world's chunks to. + */ + public String getSaveFolder() + { + return (dimensionID == 0 ? null : "DIM" + dimensionID); + } + + /** + * A message to display to the user when they transfer to this dimension. + * + * @return The message to be displayed + */ + public String getWelcomeMessage() + { + if (this instanceof WorldProviderEnd) + { + return "Entering the End"; + } + else if (this instanceof WorldProviderHell) + { + return "Entering the Nether"; + } + return null; + } + + /** + * A Message to display to the user when they transfer out of this dismension. + * + * @return The message to be displayed + */ + public String getDepartMessage() + { + if (this instanceof WorldProviderEnd) + { + return "Leaving the End"; + } + else if (this instanceof WorldProviderHell) + { + return "Leaving the Nether"; + } + return null; + } + + /** + * 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() + { + if (this instanceof WorldProviderHell) + { + return 8.0; + } + return 1.0; + } + + @SideOnly(Side.CLIENT) + public SkyProvider getSkyProvider() + { + return this.skyProvider; + } + + @SideOnly(Side.CLIENT) + public void setSkyProvider(SkyProvider skyProvider) + { + this.skyProvider = skyProvider; + } + + public ChunkCoordinates getRandomizedSpawnPoint() + { + ChunkCoordinates var5 = new ChunkCoordinates(this.worldObj.getSpawnPoint()); + + boolean isAdventure = worldObj.getWorldInfo().getGameType() != EnumGameType.ADVENTURE; + int spawnFuzz = terrainType.getSpawnFuzz(); + int spawnFuzzHalf = spawnFuzz / 2; + + if (!this.hasNoSky && !isAdventure) + { + var5.posX += this.worldObj.rand.nextInt(spawnFuzz) - spawnFuzzHalf; + var5.posZ += this.worldObj.rand.nextInt(spawnFuzz) - spawnFuzzHalf; + var5.posY = this.worldObj.getTopSolidOrLiquidBlock(var5.posX, var5.posZ); + } + + return var5; + } }