本文整理匯總了Java中cpw.mods.fml.common.IWorldGenerator類的典型用法代碼示例。如果您正苦於以下問題:Java IWorldGenerator類的具體用法?Java IWorldGenerator怎麽用?Java IWorldGenerator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IWorldGenerator類屬於cpw.mods.fml.common包,在下文中一共展示了IWorldGenerator類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: generateWorld
import cpw.mods.fml.common.IWorldGenerator; //導入依賴的package包/類
/**
* Callback hook for world gen - if your mod wishes to add extra mod related generation to the world
* call this
*
* @param chunkX
* @param chunkZ
* @param world
* @param chunkGenerator
* @param chunkProvider
*/
public static void generateWorld(int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
{
if (sortedGeneratorList == null)
{
computeSortedGeneratorList();
}
long worldSeed = world.func_72905_C();
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);
}
}
示例2: generateWorld
import cpw.mods.fml.common.IWorldGenerator; //導入依賴的package包/類
/**
* Callback hook for world gen - if your mod wishes to add extra mod related generation to the world
* call this
*
* @param chunkX
* @param chunkZ
* @param world
* @param chunkGenerator
* @param chunkProvider
*/
public static void generateWorld(int chunkX, int chunkZ, World world, IChunkProvider 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);
}
}
示例3: registerWorldGenerator
import cpw.mods.fml.common.IWorldGenerator; //導入依賴的package包/類
/**
* Register a world generator - something that inserts new block types into the world
*
* @param generator the generator
* @param modGenerationWeight a weight to assign to this generator. Heavy weights tend to sink to the bottom of
* list of world generators (i.e. they run later)
*/
public static void registerWorldGenerator(IWorldGenerator generator, int modGenerationWeight)
{
// Cauldron start - mod id's are not available during generateWorld so we must capture them here
String modId = Loader.instance().activeModContainer().getModId();
modId = modId.replaceAll("[^A-Za-z0-9]", ""); // remove all non-digits/alphanumeric
modId.replace(" ", "_");
worldGenerators.add(generator);
worldGeneratorIndex.put(generator, modGenerationWeight);
if (sortedGeneratorList != null)
{
sortedGeneratorList = null;
}
worldGenMap.put(generator.getClass().getName(), modId);
// Cauldron end
}
示例4: isEnabled
import cpw.mods.fml.common.IWorldGenerator; //導入依賴的package包/類
public static boolean isEnabled(IWorldGenerator generator)
{
if(isEnabled(generator))
{
long worldSeed = 0;
Random fmlRandom = new Random(worldSeed);
long xSeed = fmlRandom.nextLong() >> 2 + 1L;
long zSeed = fmlRandom.nextLong() >> 2 + 1L;
int chunkX = 0;
int chunkZ = 0;
long chunkSeed = (xSeed * chunkX + zSeed * chunkZ ) ^ worldSeed;
fmlRandom.setSeed(chunkSeed);
World world = null;
IChunkProvider chunkGenerator = null;
IChunkProvider chunkProvider = null;
generator.generate(fmlRandom, chunkX, chunkZ, world, chunkGenerator, chunkProvider);
}
return false;
}
示例5: getName
import cpw.mods.fml.common.IWorldGenerator; //導入依賴的package包/類
public static String getName(IWorldGenerator generator)
{
try
{
String name = (String) generator.getClass().getMethod("getName").invoke(generator);
if(!name.equals(""))
return name;
}catch(Exception e){
}
if(!getPrefix().equals("minecraft"))
{
return getPrefix();
}
return generator.getClass().getName();
}
示例6: onAdd
import cpw.mods.fml.common.IWorldGenerator; //導入依賴的package包/類
public static void onAdd(IWorldGenerator generator)
{
try
{
String name = getName(generator);
while (containsName(name)) {
name += "I";
}
WorldGenerator worldGenerator = new WorldGenerator(name, generator, getPrefix());
worldGenerators.add(worldGenerator);
configuration.load();
worldGenerator.state = configuration.get("regeneration", worldGenerator.name, 1).getInt();
configuration.save();
}catch(Exception e){
System.out.println("Error registering World Generator");
e.printStackTrace();
}
}
示例7: registerWorldGenerator
import cpw.mods.fml.common.IWorldGenerator; //導入依賴的package包/類
/**
* Register a world generator - something that inserts new block types into the world
*
* @param generator the generator
* @param modGenerationWeight a weight to assign to this generator. Heavy weights tend to sink to the bottom of
* list of world generators (i.e. they run later)
*/
public static void registerWorldGenerator(IWorldGenerator generator, int modGenerationWeight)
{
worldGenerators.add(generator);
worldGeneratorIndex.put(generator, modGenerationWeight);
if (sortedGeneratorList != null)
{
sortedGeneratorList = null;
}
}
示例8: computeSortedGeneratorList
import cpw.mods.fml.common.IWorldGenerator; //導入依賴的package包/類
private static void computeSortedGeneratorList()
{
ArrayList<IWorldGenerator> list = Lists.newArrayList(worldGenerators);
Collections.sort(list, new Comparator<IWorldGenerator>() {
@Override
public int compare(IWorldGenerator o1, IWorldGenerator o2)
{
return Ints.compare(worldGeneratorIndex.get(o1), worldGeneratorIndex.get(o2));
}
});
sortedGeneratorList = ImmutableList.copyOf(list);
}
示例9: generateWorld
import cpw.mods.fml.common.IWorldGenerator; //導入依賴的package包/類
/**
* Callback hook for world gen - if your mod wishes to add extra mod related generation to the world
* call this
*
* @param chunkX
* @param chunkZ
* @param world
* @param chunkGenerator
* @param chunkProvider
*/
public static void generateWorld(int chunkX, int chunkZ, World world, IChunkProvider 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;
boolean before = ((net.minecraft.world.WorldServer)world).theChunkProviderServer.loadChunkOnProvideRequest; // Cauldron store value
((net.minecraft.world.WorldServer)world).theChunkProviderServer.loadChunkOnProvideRequest = true; // Cauldron load chunks on provide requests
for (IWorldGenerator generator : worldGenerators)
{
// Cauldron start
if (!configWorldGenCache.containsKey(generator.getClass().getName()))
{
String modId = worldGenMap.get(generator.getClass().getName());
String generatorName = "";
generatorName = modId + "-" + generator.getClass().getSimpleName();
boolean generatorEnabled = world.cauldronConfig.getBoolean("worldgen-" + generatorName, true);
configWorldGenCache.put(generator.getClass().getName(), generatorEnabled);
}
if (configWorldGenCache.get(generator.getClass().getName()))
{
fmlRandom.setSeed(chunkSeed);
generator.generate(fmlRandom, chunkX, chunkZ, world, chunkGenerator, chunkProvider);
}
}
((net.minecraft.world.WorldServer)world).theChunkProviderServer.loadChunkOnProvideRequest = before; // reset
// Cauldron end
}
示例10: generateWorld
import cpw.mods.fml.common.IWorldGenerator; //導入依賴的package包/類
/**
* Callback hook for world gen - if your mod wishes to add extra mod related generation to the world
* call this
*
* @param chunkX
* @param chunkZ
* @param world
* @param chunkGenerator
* @param chunkProvider
*/
public static void generateWorld(int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
{
long worldSeed = world.func_72905_C();
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 : worldGenerators)
{
fmlRandom.setSeed(chunkSeed);
generator.generate(fmlRandom, chunkX, chunkZ, world, chunkGenerator, chunkProvider);
}
}
示例11: generateWorld
import cpw.mods.fml.common.IWorldGenerator; //導入依賴的package包/類
/**
* Callback hook for world gen - if your mod wishes to add extra mod related generation to the world
* call this
*
* @param chunkX
* @param chunkZ
* @param world
* @param chunkGenerator
* @param chunkProvider
*/
public static void generateWorld(int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
{
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 : worldGenerators)
{
fmlRandom.setSeed(chunkSeed);
generator.generate(fmlRandom, chunkX, chunkZ, world, chunkGenerator, chunkProvider);
}
}
示例12: register
import cpw.mods.fml.common.IWorldGenerator; //導入依賴的package包/類
@Override
protected void register(IWorldGenerator value, RegWorldGen anno, String field)
throws Exception {
GameRegistry.registerWorldGenerator(value, anno.value());
}
示例13: registerWorldGen
import cpw.mods.fml.common.IWorldGenerator; //導入依賴的package包/類
public static void registerWorldGen(IWorldGenerator worldGenClass, int weightedProbability){
GameRegistry.registerWorldGenerator(worldGenClass, weightedProbability);
}
示例14: getWorldGenerators
import cpw.mods.fml.common.IWorldGenerator; //導入依賴的package包/類
public List<Class<? extends IWorldGenerator>> getWorldGenerators() {
return worldGens;
}
示例15: registerWorldGen
import cpw.mods.fml.common.IWorldGenerator; //導入依賴的package包/類
public static void registerWorldGen(IWorldGenerator worldGenClass, int weightedProbablility)
{
GameRegistry.registerWorldGenerator(worldGenClass, weightedProbablility);
}