use of net.minecraftforge.fml.common.IWorldGenerator in project MinecraftForge by MinecraftForge.
the class GameRegistry method generateWorld.
/**
* Callback hook for world gen - if your mod wishes to add extra mod related generation to the world
* call this
*
* @param chunkX Chunk X coordinate
* @param chunkZ Chunk Z coordinate
* @param world World we're generating into
* @param chunkGenerator The chunk generator
* @param chunkProvider The chunk provider
*/
public static void generateWorld(int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
if (sortedGeneratorList == null) {
computeSortedGeneratorList();
}
long worldSeed = world.getSeed();
Random fmlRandom = new Random(worldSeed);
long xSeed = fmlRandom.nextLong() >> 2 + 1L;
long zSeed = fmlRandom.nextLong() >> 2 + 1L;
long chunkSeed = (xSeed * chunkX + zSeed * chunkZ) ^ worldSeed;
for (IWorldGenerator generator : sortedGeneratorList) {
fmlRandom.setSeed(chunkSeed);
generator.generate(fmlRandom, chunkX, chunkZ, world, chunkGenerator, chunkProvider);
}
}
use of net.minecraftforge.fml.common.IWorldGenerator in project Galacticraft by micdoodle8.
the class TransformerHooks method otherModPreventGenerate.
public static boolean otherModPreventGenerate(int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
if (!(world.provider instanceof IGalacticraftWorldProvider)) {
return false;
}
if (world.provider instanceof WorldProviderSpaceStation) {
return true;
}
if (ConfigManagerCore.enableOtherModsFeatures) {
return false;
}
if (!generatorsInitialised) {
generatorsInitialised = true;
if (ConfigManagerCore.whitelistCoFHCoreGen) {
addWorldGenForName("CoFHCore custom oregen", "cofh.core.world.WorldHandler");
}
addWorldGenForName("GalacticGreg oregen", "bloodasp.galacticgreg.GT_Worldgenerator_Space");
addWorldGenForName("Dense Ores oregen", "com.rwtema.denseores.WorldGenOres");
addWorldGenForName("AE2 meteorites worldgen", "appeng.worldgen.MeteoriteWorldGen");
try {
Class genThaumCraft = Class.forName("thaumcraft.common.lib.world.ThaumcraftWorldGenerator");
if (genThaumCraft != null && ConfigManagerCore.enableThaumCraftNodes) {
final Field regField = GameRegistry.class.getDeclaredField("worldGenerators");
regField.setAccessible(true);
Set<IWorldGenerator> registeredGenerators = (Set<IWorldGenerator>) regField.get(null);
for (IWorldGenerator gen : registeredGenerators) {
if (genThaumCraft.isInstance(gen)) {
generatorTCAuraNodes = gen;
break;
}
}
if (generatorTCAuraNodes != null) {
generateTCAuraNodes = genThaumCraft.getDeclaredMethod("generateWildNodes", World.class, Random.class, int.class, int.class, boolean.class, boolean.class);
generateTCAuraNodes.setAccessible(true);
GCLog.info("Whitelisting ThaumCraft aura node generation on planets.");
}
}
} catch (Exception e) {
}
}
if (otherModGeneratorsWhitelist.size() > 0 || generateTCAuraNodes != null) {
try {
long worldSeed = world.getSeed();
Random fmlRandom = new Random(worldSeed);
long xSeed = fmlRandom.nextLong() >> 2 + 1L;
long zSeed = fmlRandom.nextLong() >> 2 + 1L;
long chunkSeed = (xSeed * chunkX + zSeed * chunkZ) ^ worldSeed;
fmlRandom.setSeed(chunkSeed);
for (IWorldGenerator gen : otherModGeneratorsWhitelist) {
gen.generate(fmlRandom, chunkX, chunkZ, world, chunkGenerator, chunkProvider);
}
if (generateTCAuraNodes != null) {
generateTCAuraNodes.invoke(generatorTCAuraNodes, world, fmlRandom, chunkX, chunkZ, false, true);
}
} catch (Exception e) {
GCLog.severe("Error in another mod's worldgen. This is *NOT* a Galacticraft bug, report it to the other mod please.");
e.printStackTrace();
}
}
return true;
}
use of net.minecraftforge.fml.common.IWorldGenerator in project Galacticraft by micdoodle8.
the class TransformerHooks method addWorldGenForName.
private static void addWorldGenForName(String logString, String name) {
try {
Class target = Class.forName(name);
if (target != null) {
final Field regField = GameRegistry.class.getDeclaredField("worldGenerators");
regField.setAccessible(true);
Set<IWorldGenerator> registeredGenerators = (Set<IWorldGenerator>) regField.get(null);
for (IWorldGenerator gen : registeredGenerators) {
if (target.isInstance(gen)) {
otherModGeneratorsWhitelist.add(gen);
GCLog.info("Whitelisting " + logString + " on planets.");
return;
}
}
}
} catch (Exception e) {
}
}
Aggregations