Merge pull request #29 from ScottKillen/master

Fixed WorldType to allow custom WorldTypes
This commit is contained in:
LexManos 2012-06-19 19:22:06 -07:00
commit c0dffcbcec
6 changed files with 108 additions and 12 deletions

View File

@ -0,0 +1,10 @@
--- ../src-base/minecraft/net/minecraft/src/GuiCreateWorld.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src-work/minecraft/net/minecraft/src/GuiCreateWorld.java 0000-00-00 00:00:00.000000000 -0000
@@ -164,6 +164,7 @@
this.field_945_b.field_6327_b = new PlayerControllerSP(this.field_945_b);
}
+ WorldType.field_48637_a[this.field_46030_z].onGUICreateWorldPress();
this.field_945_b.func_6247_b(this.field_22132_k, this.field_22134_h.func_22071_a(), new WorldSettings(var2, var9, this.field_35365_g, this.field_40232_h, WorldType.field_48637_a[this.field_46030_z]));
this.field_945_b.func_6272_a((GuiScreen)null);
}

View File

@ -0,0 +1,10 @@
--- ../src-base/minecraft/net/minecraft/src/World.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src-work/minecraft/net/minecraft/src/World.java 0000-00-00 00:00:00.000000000 -0000
@@ -3880,6 +3880,6 @@
public double func_46068_G()
{
- return this.field_22145_q.func_46133_t() == WorldType.field_48636_c ? 0.0D : 63.0D;
+ return this.field_22145_q.func_46133_t().getHorizon(this);
}
}

View File

@ -27,7 +27,7 @@
public int func_46066_g()
{
- return this.field_46067_b == WorldType.field_48636_c ? 4 : 64;
+ return this.field_46067_b.getSeaLevel(field_4216_a);
+ return this.field_46067_b.getMinimumSpawnHeight(field_4216_a);
}
public boolean func_46064_i()

View File

@ -10,16 +10,22 @@
public class WorldType
{
public static final WorldType[] field_48637_a = new WorldType[16];
@@ -11,6 +15,8 @@
@@ -11,17 +15,26 @@
private boolean field_48633_g;
private boolean field_48638_h;
+ private BiomeGenBase[] biomesForWorldType;
- private WorldType(int p_i1080_1_, String p_i1080_2_)
+ protected BiomeGenBase[] biomesForWorldType;
+
private WorldType(int p_i1080_1_, String p_i1080_2_)
+ protected WorldType(int p_i1080_1_, String p_i1080_2_)
{
this(p_i1080_1_, p_i1080_2_, 0);
@@ -22,6 +28,13 @@
}
- private WorldType(int p_i1081_1_, String p_i1081_2_, int p_i1081_3_)
+ protected WorldType(int p_i1081_1_, String p_i1081_2_, int p_i1081_3_)
{
this.field_46139_c = p_i1081_2_;
this.field_48632_f = p_i1081_3_;
this.field_48633_g = true;
field_48637_a[p_i1081_1_] = this;
@ -33,7 +39,7 @@
}
public String func_48628_a()
@@ -78,4 +91,52 @@
@@ -78,4 +91,69 @@
return null;
}
@ -48,11 +54,24 @@
+ return this == field_48636_c ? new ChunkProviderFlat(var1, var1.func_22138_q(), var1.func_22144_v().func_35917_r()) : new ChunkProviderGenerate(var1, var1.func_22138_q(), var1.func_22144_v().func_35917_r());
+ }
+
+ /**
+ * @deprecated Use {@link #getMinimumSpawnHeight(World)} instead
+ */
+ public int getSeaLevel(World var1)
+ {
+ return getMinimumSpawnHeight(var1);
+ }
+
+ public int getMinimumSpawnHeight(World world)
+ {
+ return this == field_48636_c ? 4 : 64;
+ }
+
+ public double getHorizon(World world)
+ {
+ return this == field_48636_c ? 0.0D : 63.0D;
+ }
+
+ public boolean hasVoidParticles(boolean var1)
+ {
+ return this != field_48636_c && !var1;
@ -84,5 +103,9 @@
+ biomesForWorldType = newBiomesForWorld.toArray(new BiomeGenBase[0]);
+ }
+
+ /**
+ * Called when 'Create New World' button is pressed before starting game
+ */
+ public void onGUICreateWorldPress() { }
+
}

View File

@ -0,0 +1,32 @@
--- ../src-base/minecraft_server/net/minecraft/src/WorldProvider.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src-work/minecraft_server/net/minecraft/src/WorldProvider.java 0000-00-00 00:00:00.000000000 -0000
@@ -32,19 +32,12 @@
protected void func_4090_a()
{
- if (this.field_4302_a.func_22081_n().func_46069_q() == WorldType.field_48458_c)
- {
- this.field_4301_b = new WorldChunkManagerHell(BiomeGenBase.field_35520_c, 0.5F, 0.5F);
- }
- else
- {
- this.field_4301_b = new WorldChunkManager(this.field_4302_a);
- }
+ this.field_4301_b = this.field_4302_a.func_22081_n().func_46069_q().getChunkManager(field_4302_a);
}
public IChunkProvider func_4087_c()
{
- return (IChunkProvider)(this.field_46120_b == WorldType.field_48458_c ? new ChunkProviderFlat(this.field_4302_a, this.field_4302_a.func_22079_j(), this.field_4302_a.func_22081_n().func_35499_o()) : new ChunkProviderGenerate(this.field_4302_a, this.field_4302_a.func_22079_j(), this.field_4302_a.func_22081_n().func_35499_o()));
+ return this.field_46120_b.getChunkGenerator(this.field_4302_a);
}
public boolean func_4092_a(int p_4092_1_, int p_4092_2_)
@@ -96,6 +89,6 @@
public int func_46119_e()
{
- return this.field_46120_b == WorldType.field_48458_c ? 4 : 64;
+ return this.field_46120_b.getMinimumSpawnHeight(field_4302_a);
}
}

View File

@ -10,16 +10,22 @@
public class WorldType
{
public static final WorldType[] field_48459_a = new WorldType[16];
@@ -11,6 +15,8 @@
@@ -11,17 +15,28 @@
private boolean field_48455_g;
private boolean field_48460_h;
+ private BiomeGenBase[] biomesForWorldType;
- private WorldType(int p_i1025_1_, String p_i1025_2_)
+ protected BiomeGenBase[] biomesForWorldType;
+
private WorldType(int p_i1025_1_, String p_i1025_2_)
+ protected WorldType(int p_i1025_1_, String p_i1025_2_)
{
this(p_i1025_1_, p_i1025_2_, 0);
@@ -22,6 +28,15 @@
}
- private WorldType(int p_i1026_1_, String p_i1026_2_, int p_i1026_3_)
+ protected WorldType(int p_i1026_1_, String p_i1026_2_, int p_i1026_3_)
{
this.field_46052_c = p_i1026_2_;
this.field_48454_f = p_i1026_3_;
this.field_48455_g = true;
field_48459_a[p_i1026_1_] = this;
@ -35,11 +41,26 @@
}
public String func_48449_a()
@@ -68,4 +83,26 @@
@@ -68,4 +83,41 @@
return null;
}
+
+
+ public WorldChunkManager getChunkManager(World world)
+ {
+ return this == field_48458_c ? new WorldChunkManagerHell(BiomeGenBase.field_35520_c, 0.5F, 0.5F) : new WorldChunkManager(world);
+ }
+
+ public IChunkProvider getChunkGenerator(World var1)
+ {
+ return this == field_48458_c ? new ChunkProviderFlat(var1, var1.func_22079_j(), var1.func_22081_n().func_35499_o()) : new ChunkProviderGenerate(var1, var1.func_22079_j(), var1.func_22081_n().func_35499_o());
+ }
+
+ public int getMinimumSpawnHeight(World world)
+ {
+ return this == field_48458_c ? 4 : 64;
+ }
+
+ public BiomeGenBase[] getBiomesForWorldType() {
+ return biomesForWorldType;
+ }