本文整理汇总了Java中net.minecraftforge.fml.common.IWorldGenerator类的典型用法代码示例。如果您正苦于以下问题:Java IWorldGenerator类的具体用法?Java IWorldGenerator怎么用?Java IWorldGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IWorldGenerator类属于net.minecraftforge.fml.common包,在下文中一共展示了IWorldGenerator类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateWorld
import net.minecraftforge.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 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);
}
}
示例2: doRetrogen
import net.minecraftforge.fml.common.IWorldGenerator; //导入依赖的package包/类
void doRetrogen(boolean test, Chunk chunk, String genType, IWorldGenerator gen) {
if (!test) return;
final int chunkX = chunk.xPosition, chunkZ = chunk.zPosition;
final World world = chunk.getWorld();
//log("Retrogenning %s in dimension %s at chunk coordinates (%s, %s)", genType, world.provider.getDimensionId(), chunkX, chunkZ);
//Thanks, FML!
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);
final IChunkProvider chunkProvider = world.getChunkProvider();
gen.generate(fmlRandom, chunkX, chunkZ, world, chunkProvider, chunkProvider);
}
示例3: process
import net.minecraftforge.fml.common.IWorldGenerator; //导入依赖的package包/类
@Override
public void process(ITypesetter out, String arg) throws TruthError {
try {
GameRegistry.generateWorld(0, 0, null, null, null);
} catch (NullPointerException e) {
// lazy way of making the sortedGeneratorList not be null. Swallow the exception whole.
}
List<IWorldGenerator> sortedGeneratorList = ReflectionHelper.getPrivateValue(GameRegistry.class, null, "sortedGeneratorList");
out.write("\\title{Sorted World Generators}\n\n");
if (sortedGeneratorList == null) {
out.write("Failed to load generator list!");
return;
}
for (IWorldGenerator gen : sortedGeneratorList) {
out.write(gen.toString() + "\n\n");
}
}
示例4: serverStopped
import net.minecraftforge.fml.common.IWorldGenerator; //导入依赖的package包/类
@EventHandler
public void serverStopped(FMLServerStoppedEvent evt)
{
Set<IWorldGenerator> worldGens = ObfuscationReflectionHelper.getPrivateValue(GameRegistry.class, null, "worldGenerators");
Map<IWorldGenerator,Integer> worldGenIdx = ObfuscationReflectionHelper.getPrivateValue(GameRegistry.class, null, "worldGeneratorIndex");
for (TargetWorldWrapper tww : delegates.values())
{
worldGens.remove(tww);
Integer idx = worldGenIdx.remove(tww);
worldGens.add(tww.delegate);
worldGenIdx.put(tww.delegate,idx);
}
delegates.clear();
}
示例5: registerWorldGenerator
import net.minecraftforge.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;
}
}
示例6: computeSortedGeneratorList
import net.minecraftforge.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);
}
示例7: preinit
import net.minecraftforge.fml.common.IWorldGenerator; //导入依赖的package包/类
@Mod.EventHandler
public void preinit(FMLPreInitializationEvent init)
{
final Logger modLog = init.getModLog();
IWorldGenerator gen = new IWorldGenerator() {
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
{
modLog.log(Level.INFO, "Calling!");
}
};
GameRegistry.registerWorldGenerator(gen, 10);
}
示例8: registerWorldGenerator
import net.minecraftforge.fml.common.IWorldGenerator; //导入依赖的package包/类
public static void registerWorldGenerator(IWorldGenerator generator, int modGenerationWeight) {
GameRegistry.registerWorldGenerator(generator, modGenerationWeight);
}
示例9: register
import net.minecraftforge.fml.common.IWorldGenerator; //导入依赖的package包/类
private static void register(IWorldGenerator generator)
{
register(generator, 0);
}
示例10: serverAboutToStart
import net.minecraftforge.fml.common.IWorldGenerator; //导入依赖的package包/类
@EventHandler
public void serverAboutToStart(FMLServerAboutToStartEvent evt)
{
this.pendingWork = new MapMaker().weakKeys().makeMap();
this.completedWork = new MapMaker().weakKeys().makeMap();
this.completedWorkLocks = new MapMaker().weakKeys().makeMap();
Set<IWorldGenerator> worldGens = ObfuscationReflectionHelper.getPrivateValue(GameRegistry.class, null, "worldGenerators");
Map<IWorldGenerator,Integer> worldGenIdx = ObfuscationReflectionHelper.getPrivateValue(GameRegistry.class, null, "worldGeneratorIndex");
for (String retro : ImmutableSet.copyOf(retros.keySet()))
{
if (!delegates.containsKey(retro))
{
FMLLog.info("Substituting worldgenerator %s with delegate", retro);
for (Iterator<IWorldGenerator> iterator = worldGens.iterator(); iterator.hasNext();)
{
IWorldGenerator wg = iterator.next();
if (wg.getClass().getName().equals(retro))
{
iterator.remove();
TargetWorldWrapper tww = new TargetWorldWrapper();
tww.delegate = wg;
tww.tag = retro;
worldGens.add(tww);
Integer idx = worldGenIdx.remove(wg);
worldGenIdx.put(tww, idx);
FMLLog.info("Successfully substituted %s with delegate", retro);
delegates.put(retro, tww);
break;
}
}
if (!delegates.containsKey(retro))
{
FMLLog.warning("WorldRetrogen was not able to locate world generator class %s, it will be skipped, found %s", retro, worldGens);
retros.remove(retro);
}
}
}
}
示例11: addWorldGenerator
import net.minecraftforge.fml.common.IWorldGenerator; //导入依赖的package包/类
public static void addWorldGenerator(IWorldGenerator generator, int modGenerationWeight) {
GameRegistry.registerWorldGenerator(generator, modGenerationWeight);
}
示例12: registerWorldGen
import net.minecraftforge.fml.common.IWorldGenerator; //导入依赖的package包/类
public static void registerWorldGen(IWorldGenerator worldGenClass, int weightedProbability){
GameRegistry.registerWorldGenerator(worldGenClass, weightedProbability);
}
示例13: registerWorldGenerator
import net.minecraftforge.fml.common.IWorldGenerator; //导入依赖的package包/类
/**
* Register an {@link IWorldGenerator}
*
* @param generator
* Instance of implemention of IWorldgenerator
* @param modGenerationWeight
* Worldgeneration order
*/
public static void registerWorldGenerator(IWorldGenerator generator, int modGenerationWeight) {
GameRegistry.registerWorldGenerator(generator, modGenerationWeight);
}
示例14: registerWorldGen
import net.minecraftforge.fml.common.IWorldGenerator; //导入依赖的package包/类
public static void registerWorldGen(IWorldGenerator generator, int modGenerationWeight) {
GameRegistry.registerWorldGenerator(generator, modGenerationWeight);
}