diff --git a/fml/client/cpw/mods/fml/client/FMLClientHandler.java b/fml/client/cpw/mods/fml/client/FMLClientHandler.java index 49c1c0f8dc..6515facd12 100644 --- a/fml/client/cpw/mods/fml/client/FMLClientHandler.java +++ b/fml/client/cpw/mods/fml/client/FMLClientHandler.java @@ -312,18 +312,7 @@ public class FMLClientHandler implements IFMLSidedHandler */ public void onChunkPopulate(IChunkProvider chunkProvider, int chunkX, int chunkZ, World world, IChunkProvider generator) { - Random fmlRandom = new Random(world.func_22138_q()); - long xSeed = fmlRandom.nextLong() >> 2 + 1L; - long zSeed = fmlRandom.nextLong() >> 2 + 1L; - fmlRandom.setSeed((xSeed * chunkX + zSeed * chunkZ) ^ world.func_22138_q()); - - for (ModContainer mod : Loader.getModList()) - { - if (mod.generatesWorld()) - { - mod.getWorldGenerator().generate(fmlRandom, chunkX, chunkZ, world, generator, chunkProvider); - } - } + FMLCommonHandler.instance().handleWorldGeneration(chunkX, chunkZ, world.func_22138_q(), world, generator, chunkProvider); } /** diff --git a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java index d22cfcd6cb..f0def1d3bf 100644 --- a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java +++ b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java @@ -27,6 +27,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.Random; import java.util.Set; import java.util.logging.Logger; import java.util.regex.Matcher; @@ -81,7 +82,9 @@ public class FMLCommonHandler private Map modLanguageData=new HashMap(); - private SettickHandlers = new HashSet(); + private Set tickHandlers = new HashSet(); + + private Set worldGenerators = new HashSet(); /** * We register our delegate here * @param handler @@ -531,8 +534,26 @@ public class FMLCommonHandler } } + public void handleWorldGeneration(int chunkX, int chunkZ, long worldSeed, Object... data) + { + Random fmlRandom = new Random(worldSeed); + long xSeed = fmlRandom.nextLong() >> 2 + 1L; + long zSeed = fmlRandom.nextLong() >> 2 + 1L; + fmlRandom.setSeed((xSeed * chunkX + zSeed * chunkZ) ^ worldSeed); + + for (IWorldGenerator generator : worldGenerators) + { + generator.generate(fmlRandom, chunkX, chunkZ, data); + } + } + public void registerTickHandler(ITickHandler handler) { tickHandlers.add(handler); } + + public void registerWorldGenerator(IWorldGenerator generator) + { + worldGenerators.add(generator); + } } diff --git a/fml/common/cpw/mods/fml/common/FMLModContainer.java b/fml/common/cpw/mods/fml/common/FMLModContainer.java index 2562800e1a..5d501f6d74 100644 --- a/fml/common/cpw/mods/fml/common/FMLModContainer.java +++ b/fml/common/cpw/mods/fml/common/FMLModContainer.java @@ -132,21 +132,7 @@ public class FMLModContainer implements ModContainer // TODO Auto-generated method stub return null; } - - @Override - public boolean generatesWorld() - { - // TODO Auto-generated method stub - return false; - } - - @Override - public IWorldGenerator getWorldGenerator() - { - // TODO Auto-generated method stub - return null; - } - + @Override public int lookupFuelValue(int itemId, int itemDamage) { diff --git a/fml/common/cpw/mods/fml/common/ModContainer.java b/fml/common/cpw/mods/fml/common/ModContainer.java index 1b423008ba..2139c051cd 100644 --- a/fml/common/cpw/mods/fml/common/ModContainer.java +++ b/fml/common/cpw/mods/fml/common/ModContainer.java @@ -103,16 +103,6 @@ public interface ModContainer * @return */ Object getMod(); - /** - * Does this mod want to generate world data. - * @return - */ - boolean generatesWorld(); - /** - * The world generator for this mod. - * @return - */ - IWorldGenerator getWorldGenerator(); /** * Lookup the fuel value for the supplied item/damage with this mod. * @param itemId diff --git a/fml/common/cpw/mods/fml/common/modloader/ModLoaderModContainer.java b/fml/common/cpw/mods/fml/common/modloader/ModLoaderModContainer.java index 83c16d339f..b138dad473 100644 --- a/fml/common/cpw/mods/fml/common/modloader/ModLoaderModContainer.java +++ b/fml/common/cpw/mods/fml/common/modloader/ModLoaderModContainer.java @@ -106,6 +106,7 @@ public class ModLoaderModContainer implements ModContainer mod = modClazz.newInstance(); this.tickHandler.setMod(mod); FMLCommonHandler.instance().registerTickHandler(this.tickHandler); + FMLCommonHandler.instance().registerWorldGenerator(this.mod); } catch (Exception e) { @@ -394,18 +395,6 @@ public class ModLoaderModContainer implements ModContainer return mod; } - @Override - public boolean generatesWorld() - { - return true; - } - - @Override - public IWorldGenerator getWorldGenerator() - { - return mod; - } - @Override public int lookupFuelValue(int itemId, int itemDamage) { diff --git a/fml/server/cpw/mods/fml/server/FMLServerHandler.java b/fml/server/cpw/mods/fml/server/FMLServerHandler.java index 7e894cd35b..d5fe7c363b 100644 --- a/fml/server/cpw/mods/fml/server/FMLServerHandler.java +++ b/fml/server/cpw/mods/fml/server/FMLServerHandler.java @@ -208,18 +208,7 @@ public class FMLServerHandler implements IFMLSidedHandler */ public void onChunkPopulate(IChunkProvider chunkProvider, int chunkX, int chunkZ, World world, IChunkProvider generator) { - Random fmlRandom = new Random(world.func_22079_j()); - long xSeed = fmlRandom.nextLong() >> 2 + 1L; - long zSeed = fmlRandom.nextLong() >> 2 + 1L; - fmlRandom.setSeed((xSeed * chunkX + zSeed * chunkZ) ^ world.func_22079_j()); - - for (ModContainer mod : Loader.getModList()) - { - if (mod.generatesWorld()) - { - mod.getWorldGenerator().generate(fmlRandom, chunkX, chunkZ, world, generator, chunkProvider); - } - } + FMLCommonHandler.instance().handleWorldGeneration(chunkX, chunkZ, world.func_22079_j(), world, generator, chunkProvider); } /**