From 071d54feaf77b83ba642baa289f51798c2713ff7 Mon Sep 17 00:00:00 2001 From: Christian Weeks Date: Thu, 3 May 2012 14:05:13 -0400 Subject: [PATCH] Implement addBiome, hopefully. Pushes biome list to the WorldType field. Sorry Bioxx. --- .../server/MinecraftServer.java.patch | 30 ++++++------ .../minecraft/src/GenLayerBiome.java.patch | 17 +++++++ .../net/minecraft/src/WorldType.java.patch | 47 +++++++++++++++++++ .../cpw/mods/fml/server/FMLServerHandler.java | 9 ++++ fml/server/net/minecraft/src/ModLoader.java | 5 +- 5 files changed, 90 insertions(+), 18 deletions(-) create mode 100644 fml/patches/minecraft_server/net/minecraft/src/GenLayerBiome.java.patch create mode 100644 fml/patches/minecraft_server/net/minecraft/src/WorldType.java.patch diff --git a/fml/patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch b/fml/patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch index 1b8785930..b398c901b 100644 --- a/fml/patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch +++ b/fml/patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch @@ -25,21 +25,19 @@ this.field_6033_f = new ServerConfigurationManager(this); this.field_6028_k[0] = new EntityTracker(this, 0); this.field_6028_k[1] = new EntityTracker(this, -1); -@@ -444,6 +448,8 @@ +@@ -370,6 +374,7 @@ + var7 = 0L; + } - private void func_6018_h() - { -+ FMLServerHandler.instance().onPreTick(); -+ - long var1 = System.nanoTime(); - ArrayList var3 = new ArrayList(); - Iterator var4 = field_6037_b.keySet().iterator(); -@@ -533,6 +539,8 @@ - this.field_48076_G = Packet.field_48101_l; - this.field_48082_x[this.field_9014_h % 100] = Packet.field_48102_m - this.field_48077_H; - this.field_48077_H = Packet.field_48102_m; -+ -+ FMLServerHandler.instance().onPostTick(); - } ++ FMLServerHandler.instance().onPreTick(); + var3 += var7; + var1 = var5; - public void func_6010_a(String p_6010_1_, ICommandListener p_6010_2_) +@@ -386,6 +391,7 @@ + this.func_6018_h(); + } + } ++ FMLServerHandler.instance().onPostTick(); + } + } + else diff --git a/fml/patches/minecraft_server/net/minecraft/src/GenLayerBiome.java.patch b/fml/patches/minecraft_server/net/minecraft/src/GenLayerBiome.java.patch new file mode 100644 index 000000000..fa3446958 --- /dev/null +++ b/fml/patches/minecraft_server/net/minecraft/src/GenLayerBiome.java.patch @@ -0,0 +1,17 @@ +--- ../src-base/minecraft_server/net/minecraft/src/GenLayerBiome.java 0000-00-00 00:00:00.000000000 -0000 ++++ ../src-work/minecraft_server/net/minecraft/src/GenLayerBiome.java 0000-00-00 00:00:00.000000000 -0000 +@@ -7,13 +7,8 @@ + public GenLayerBiome(long p_i1078_1_, GenLayer p_i1078_3_, WorldType p_i1078_4_) + { + super(p_i1078_1_); +- this.field_35029_b = new BiomeGenBase[] {BiomeGenBase.field_4293_h, BiomeGenBase.field_4297_d, BiomeGenBase.field_35518_e, BiomeGenBase.field_4299_b, BiomeGenBase.field_35520_c, BiomeGenBase.field_4294_g, BiomeGenBase.field_48443_w}; ++ this.field_35029_b = p_i1078_4_.getBiomesForWorldType(); + this.field_35023_a = p_i1078_3_; +- +- if (p_i1078_4_ == WorldType.field_48456_d) +- { +- this.field_35029_b = new BiomeGenBase[] {BiomeGenBase.field_4293_h, BiomeGenBase.field_4297_d, BiomeGenBase.field_35518_e, BiomeGenBase.field_4299_b, BiomeGenBase.field_35520_c, BiomeGenBase.field_4294_g}; +- } + } + + public int[] func_35018_a(int p_35018_1_, int p_35018_2_, int p_35018_3_, int p_35018_4_) diff --git a/fml/patches/minecraft_server/net/minecraft/src/WorldType.java.patch b/fml/patches/minecraft_server/net/minecraft/src/WorldType.java.patch new file mode 100644 index 000000000..a7ead3624 --- /dev/null +++ b/fml/patches/minecraft_server/net/minecraft/src/WorldType.java.patch @@ -0,0 +1,47 @@ +--- ../src-base/minecraft_server/net/minecraft/src/WorldType.java 0000-00-00 00:00:00.000000000 -0000 ++++ ../src-work/minecraft_server/net/minecraft/src/WorldType.java 0000-00-00 00:00:00.000000000 -0000 +@@ -1,5 +1,8 @@ + package net.minecraft.src; + ++import java.util.Arrays; ++import java.util.List; ++ + public class WorldType + { + public static final WorldType[] field_48459_a = new WorldType[16]; +@@ -11,9 +14,20 @@ + private boolean field_48455_g; + private boolean field_48460_h; + ++ private BiomeGenBase[] biomesForWorldType; ++ + private WorldType(int p_i1025_1_, String p_i1025_2_) + { + this(p_i1025_1_, p_i1025_2_, 0); ++ switch (p_i1025_1_) { ++ case 8: ++ biomesForWorldType = new BiomeGenBase[] { BiomeGenBase.field_4293_h, BiomeGenBase.field_4297_d, BiomeGenBase.field_35518_e, ++ BiomeGenBase.field_4299_b, BiomeGenBase.field_35520_c, BiomeGenBase.field_4294_g }; ++ break; ++ default: ++ biomesForWorldType = new BiomeGenBase[] { BiomeGenBase.field_4293_h, BiomeGenBase.field_4297_d, BiomeGenBase.field_35518_e, ++ BiomeGenBase.field_4299_b, BiomeGenBase.field_35520_c, BiomeGenBase.field_4294_g, BiomeGenBase.field_48443_w }; ++ } + } + + private WorldType(int p_i1026_1_, String p_i1026_2_, int p_i1026_3_) +@@ -68,4 +82,14 @@ + + return null; + } ++ ++ public BiomeGenBase[] getBiomesForWorldType() { ++ return biomesForWorldType; ++ } ++ ++ public void addNewBiome(BiomeGenBase biome) { ++ List biomes=Arrays.asList(biomesForWorldType); ++ biomes.add(biome); ++ biomesForWorldType=biomes.toArray(new BiomeGenBase[0]); ++ } + } diff --git a/fml/server/cpw/mods/fml/server/FMLServerHandler.java b/fml/server/cpw/mods/fml/server/FMLServerHandler.java index b74693265..76b32d0f2 100644 --- a/fml/server/cpw/mods/fml/server/FMLServerHandler.java +++ b/fml/server/cpw/mods/fml/server/FMLServerHandler.java @@ -36,6 +36,7 @@ import net.minecraft.src.Packet250CustomPayload; import net.minecraft.src.Packet3Chat; import net.minecraft.src.ServerRegistry; import net.minecraft.src.World; +import net.minecraft.src.WorldType; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.IFMLSidedHandler; import cpw.mods.fml.common.Loader; @@ -537,4 +538,12 @@ public class FMLServerHandler implements IFMLSidedHandler } } } + + /** + * @param biome + */ + public void addBiomeToDefaultWorldGenerator(BiomeGenBase biome) + { + WorldType.field_48457_b.addNewBiome(biome); + } } diff --git a/fml/server/net/minecraft/src/ModLoader.java b/fml/server/net/minecraft/src/ModLoader.java index bed7aa8e0..aaf494b25 100644 --- a/fml/server/net/minecraft/src/ModLoader.java +++ b/fml/server/net/minecraft/src/ModLoader.java @@ -33,6 +33,7 @@ public class ModLoader */ public static void addAchievementDesc(Achievement achievement, String name, String description) { + } /** @@ -62,13 +63,13 @@ public class ModLoader } /** - * This method does not work. Creation of a BiomeGenBase is sufficient to populate this array. Using this method will likely corrupt worlds. + * This method adds the supplied biome to the set of candidate biomes for the default world generator type. * * @param biome */ - @Deprecated public static void addBiome(BiomeGenBase biome) { + FMLServerHandler.instance().addBiomeToDefaultWorldGenerator(biome); } /**