126 lines
4 KiB
Diff
126 lines
4 KiB
Diff
--- ../src-base/minecraft/net/minecraft/world/WorldType.java
|
|
+++ ../src-work/minecraft/net/minecraft/world/WorldType.java
|
|
@@ -1,7 +1,11 @@
|
|
package net.minecraft.world;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.Random;
|
|
|
|
+import net.minecraft.client.Minecraft;
|
|
+import net.minecraft.client.gui.GuiCreateFlatWorld;
|
|
+import net.minecraft.client.gui.GuiCreateWorld;
|
|
import net.minecraft.world.biome.BiomeGenBase;
|
|
import net.minecraft.world.biome.WorldChunkManager;
|
|
import net.minecraft.world.biome.WorldChunkManagerHell;
|
|
@@ -9,6 +13,10 @@
|
|
import net.minecraft.world.gen.ChunkProviderFlat;
|
|
import net.minecraft.world.gen.ChunkProviderGenerate;
|
|
import net.minecraft.world.gen.FlatGeneratorInfo;
|
|
+import net.minecraft.world.gen.layer.GenLayer;
|
|
+import net.minecraft.world.gen.layer.GenLayerBiome;
|
|
+import net.minecraft.world.gen.layer.GenLayerBiomeEdge;
|
|
+import net.minecraft.world.gen.layer.GenLayerZoom;
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
@@ -45,6 +53,7 @@
|
|
|
|
private WorldType(int par1, String par2Str, int par3)
|
|
{
|
|
+ if (par2Str.length() > 16) throw new IllegalArgumentException("World type names must not be longer then 16: " + par2Str.length());
|
|
this.worldType = par2Str;
|
|
this.generatorVersion = par3;
|
|
this.canBeCreated = true;
|
|
@@ -199,8 +208,92 @@
|
|
return this == FLAT ? random.nextInt(4) != 1 : false;
|
|
}
|
|
|
|
+ /*=================================================== FORGE START ======================================*/
|
|
+ private static int getNextID()
|
|
+ {
|
|
+ for (int x = 0; x < worldTypes.length; x++)
|
|
+ {
|
|
+ if (worldTypes[x] == null)
|
|
+ {
|
|
+ return x;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ int oldLen = worldTypes.length;
|
|
+ worldTypes = Arrays.copyOf(worldTypes, oldLen + 16);
|
|
+ return oldLen;
|
|
+ }
|
|
+
|
|
/**
|
|
+ * Creates a new world type, the ID is hidden and should not be referenced by modders.
|
|
+ * It will automatically expand the underlying workdType array if there are no IDs left.
|
|
+ * @param name
|
|
+ */
|
|
+ public WorldType(String name)
|
|
+ {
|
|
+ this(getNextID(), name);
|
|
+ }
|
|
+
|
|
+ /**
|
|
* Called when 'Create New World' button is pressed before starting game
|
|
*/
|
|
public void onGUICreateWorldPress() { }
|
|
+
|
|
+ /**
|
|
+ * Gets the spawn fuzz for players who join the world.
|
|
+ * Useful for void world types.
|
|
+ * @return Fuzz for entity initial spawn in blocks.
|
|
+ */
|
|
+ public int getSpawnFuzz()
|
|
+ {
|
|
+ return 20;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Called when the 'Customize' button is pressed on world creation GUI
|
|
+ * @param instance The minecraft instance
|
|
+ * @param guiCreateWorld the createworld GUI
|
|
+ */
|
|
+ @SideOnly(Side.CLIENT)
|
|
+ public void onCustomizeButton(Minecraft instance, GuiCreateWorld guiCreateWorld)
|
|
+ {
|
|
+ if (this == FLAT)
|
|
+ {
|
|
+ instance.func_147108_a(new GuiCreateFlatWorld(guiCreateWorld, guiCreateWorld.field_146334_a));
|
|
+ }
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Should world creation GUI show 'Customize' button for this world type?
|
|
+ * @return if this world type has customization parameters
|
|
+ */
|
|
+ public boolean isCustomizable()
|
|
+ {
|
|
+ return this == FLAT;
|
|
+ }
|
|
+
|
|
+
|
|
+ /**
|
|
+ * Get the height to render the clouds for this world type
|
|
+ * @return The height to render clouds at
|
|
+ */
|
|
+ public float getCloudHeight()
|
|
+ {
|
|
+ return 128.0F;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Creates the GenLayerBiome used for generating the world
|
|
+ *
|
|
+ * @param worldSeed The world seed
|
|
+ * @param parentLayer The parent layer to feed into any layer you return
|
|
+ * @return A GenLayer that will return ints representing the Biomes to be generated, see GenLayerBiome
|
|
+ */
|
|
+ public GenLayer getBiomeLayer(int worldSeed, GenLayer parentLayer)
|
|
+ {
|
|
+ GenLayer ret = new GenLayerBiome(200L, parentLayer, this);
|
|
+ ret = GenLayerZoom.magnify(1000L, ret, 2);
|
|
+ ret = new GenLayerBiomeEdge(1000L, ret);
|
|
+ return ret;
|
|
+ }
|
|
}
|