From efc8d1bb37f6d79853a3dd8b232fd836a669231a Mon Sep 17 00:00:00 2001 From: Scott Killen Date: Sat, 16 Jun 2012 23:31:17 -0400 Subject: [PATCH 1/3] Client ====== - Fixed WorldType to allow custom WorldTypes in world creation GUI. - Deprecated client WorldType.getSeaLevel() and renamed it with the more accurate name of getMinimumSpawnHeight. - Changed related reference WorldProvider. Server ====== - Fixed WorldType to allow custom WorldTypes - Added methods to WorldType giving it the exact abilities of client WorldType - Adjusted WorldProvider so that it relies on WorldType the same way it does on client. --- .../minecraft/src/WorldProvider.java.patch | 2 +- .../net/minecraft/src/WorldType.java.patch | 24 +++++++++++--- .../minecraft/src/WorldProvider.java.patch | 32 ++++++++++++++++++ .../net/minecraft/src/WorldType.java.patch | 33 +++++++++++++++---- 4 files changed, 79 insertions(+), 12 deletions(-) create mode 100644 fml/patches/minecraft_server/net/minecraft/src/WorldProvider.java.patch diff --git a/fml/patches/minecraft/net/minecraft/src/WorldProvider.java.patch b/fml/patches/minecraft/net/minecraft/src/WorldProvider.java.patch index 76021b56d..1d2f080c8 100644 --- a/fml/patches/minecraft/net/minecraft/src/WorldProvider.java.patch +++ b/fml/patches/minecraft/net/minecraft/src/WorldProvider.java.patch @@ -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() diff --git a/fml/patches/minecraft/net/minecraft/src/WorldType.java.patch b/fml/patches/minecraft/net/minecraft/src/WorldType.java.patch index f3e16fb54..6e60f1f37 100644 --- a/fml/patches/minecraft/net/minecraft/src/WorldType.java.patch +++ b/fml/patches/minecraft/net/minecraft/src/WorldType.java.patch @@ -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,60 @@ return null; } @@ -48,8 +54,16 @@ + 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; + } + diff --git a/fml/patches/minecraft_server/net/minecraft/src/WorldProvider.java.patch b/fml/patches/minecraft_server/net/minecraft/src/WorldProvider.java.patch new file mode 100644 index 000000000..15721822c --- /dev/null +++ b/fml/patches/minecraft_server/net/minecraft/src/WorldProvider.java.patch @@ -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); + } + } diff --git a/fml/patches/minecraft_server/net/minecraft/src/WorldType.java.patch b/fml/patches/minecraft_server/net/minecraft/src/WorldType.java.patch index 7bf1e4147..15d91310e 100644 --- a/fml/patches/minecraft_server/net/minecraft/src/WorldType.java.patch +++ b/fml/patches/minecraft_server/net/minecraft/src/WorldType.java.patch @@ -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; + } From f85c7a48ca7050b447a9c50043844e62750b5a99 Mon Sep 17 00:00:00 2001 From: Scott Killen Date: Sun, 17 Jun 2012 00:04:50 -0400 Subject: [PATCH 2/3] **Client** * Delegated World.func_46068_G() (getHorizon), which depends on WorldType, to the WorldType class per LexManos' suggestion --- .../minecraft/net/minecraft/src/World.java.patch | 10 ++++++++++ .../minecraft/net/minecraft/src/WorldType.java.patch | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 fml/patches/minecraft/net/minecraft/src/World.java.patch diff --git a/fml/patches/minecraft/net/minecraft/src/World.java.patch b/fml/patches/minecraft/net/minecraft/src/World.java.patch new file mode 100644 index 000000000..1b20a5c6a --- /dev/null +++ b/fml/patches/minecraft/net/minecraft/src/World.java.patch @@ -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); + } + } diff --git a/fml/patches/minecraft/net/minecraft/src/WorldType.java.patch b/fml/patches/minecraft/net/minecraft/src/WorldType.java.patch index 6e60f1f37..67390325a 100644 --- a/fml/patches/minecraft/net/minecraft/src/WorldType.java.patch +++ b/fml/patches/minecraft/net/minecraft/src/WorldType.java.patch @@ -39,7 +39,7 @@ } public String func_48628_a() -@@ -78,4 +91,60 @@ +@@ -78,4 +91,65 @@ return null; } @@ -67,6 +67,11 @@ + 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; From 83fa5ffa5e68227d15067230f99d2af93e9a9fdd Mon Sep 17 00:00:00 2001 From: Scott Killen Date: Sun, 17 Jun 2012 15:05:16 -0400 Subject: [PATCH 3/3] Client ====== Added hook in GuiCreateWorld to allow WorldType to present GUI on world creation. --- .../net/minecraft/src/GuiCreateWorld.java.patch | 10 ++++++++++ .../minecraft/net/minecraft/src/WorldType.java.patch | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 fml/patches/minecraft/net/minecraft/src/GuiCreateWorld.java.patch diff --git a/fml/patches/minecraft/net/minecraft/src/GuiCreateWorld.java.patch b/fml/patches/minecraft/net/minecraft/src/GuiCreateWorld.java.patch new file mode 100644 index 000000000..4c659a9de --- /dev/null +++ b/fml/patches/minecraft/net/minecraft/src/GuiCreateWorld.java.patch @@ -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); + } diff --git a/fml/patches/minecraft/net/minecraft/src/WorldType.java.patch b/fml/patches/minecraft/net/minecraft/src/WorldType.java.patch index 67390325a..ea5e65259 100644 --- a/fml/patches/minecraft/net/minecraft/src/WorldType.java.patch +++ b/fml/patches/minecraft/net/minecraft/src/WorldType.java.patch @@ -39,7 +39,7 @@ } public String func_48628_a() -@@ -78,4 +91,65 @@ +@@ -78,4 +91,69 @@ return null; } @@ -103,5 +103,9 @@ + biomesForWorldType = newBiomesForWorld.toArray(new BiomeGenBase[0]); + } + ++ /** ++ * Called when 'Create New World' button is pressed before starting game ++ */ ++ public void onGUICreateWorldPress() { } + }