本文整理匯總了Java中net.minecraft.world.gen.feature.WorldGenerator類的典型用法代碼示例。如果您正苦於以下問題:Java WorldGenerator類的具體用法?Java WorldGenerator怎麽用?Java WorldGenerator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WorldGenerator類屬於net.minecraft.world.gen.feature包,在下文中一共展示了WorldGenerator類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: generateTree
import net.minecraft.world.gen.feature.WorldGenerator; //導入依賴的package包/類
public void generateTree(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(worldIn, rand, pos)) return;
WorldGenerator worldgenerator;
switch (wood.getName()) {
case "banana":
default:
worldgenerator = new WorldGenApple(true);
}
worldIn.setBlockToAir(pos);
worldIn.setBlockToAir(pos.up());
if (!worldgenerator.generate(worldIn, rand, pos)) {
worldIn.setBlockState(pos, state, 4);
}
}
示例2: decorate
import net.minecraft.world.gen.feature.WorldGenerator; //導入依賴的package包/類
public void decorate(World worldIn, Random rand, BlockPos pos)
{
super.decorate(worldIn, rand, pos);
net.minecraftforge.common.MinecraftForge.ORE_GEN_BUS.post(new net.minecraftforge.event.terraingen.OreGenEvent.Pre(worldIn, rand, pos));
WorldGenerator emeralds = new EmeraldGenerator();
if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(worldIn, rand, emeralds, pos, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.EMERALD))
emeralds.generate(worldIn, rand, pos);
for (int i = 0; i < 7; ++i)
{
int j1 = rand.nextInt(16);
int k1 = rand.nextInt(64);
int l1 = rand.nextInt(16);
if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(worldIn, rand, theWorldGenerator, pos.add(j1, k1, l1), net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.SILVERFISH))
this.theWorldGenerator.generate(worldIn, rand, pos.add(j1, k1, l1));
}
net.minecraftforge.common.MinecraftForge.ORE_GEN_BUS.post(new net.minecraftforge.event.terraingen.OreGenEvent.Post(worldIn, rand, pos));
}
示例3: cropsPassGenerate
import net.minecraft.world.gen.feature.WorldGenerator; //導入依賴的package包/類
public void cropsPassGenerate(World worldIn, Random rand, Biome biome, BlockPos pos)
{
if (!(biome instanceof ExPBiome))
{
return;
}
int x = rand.nextInt(16) + 8;
int z = rand.nextInt(16) + 8;
BlockPos at = worldIn.getHeight(pos.add(x, 0, z));
WorldGenerator cropsGen = new CropGenerator((ExPBiome) biome);
EventGenVegetation event = new EventGenVegetation(worldIn, at, rand, cropsGen, Type.WILD_CROP);
if (MinecraftForge.TERRAIN_GEN_BUS.post(event))
{
return;
}
event.generator.generate(worldIn, rand, at);
}
示例4: beyyBushesPassGenerate
import net.minecraft.world.gen.feature.WorldGenerator; //導入依賴的package包/類
public void beyyBushesPassGenerate(World worldIn, Random rand, Biome biome, BlockPos pos)
{
if (!(biome instanceof ExPBiome))
{
return;
}
int x = rand.nextInt(16) + 8;
int z = rand.nextInt(16) + 8;
BlockPos at = worldIn.getHeight(pos.add(x, 0, z));
EnumSeason currentSeason = IExPWorld.of(worldIn).getCurrentSeason();
EnumShrubState stateToGenerate = currentSeason == EnumSeason.WINTER ? EnumShrubState.DEAD : currentSeason == EnumSeason.AUTUMN ? EnumShrubState.AUTUMN : rand.nextFloat() < 0.3 ? EnumShrubState.BLOOMING : EnumShrubState.NORMAL;
WorldGenerator gen = new BerryBushGenerator(stateToGenerate);
EventGenVegetation event = new EventGenVegetation(worldIn, at, rand, gen, Type.BERRY_BUSH);
if (MinecraftForge.TERRAIN_GEN_BUS.post(event))
{
return;
}
event.generator.generate(worldIn, rand, at);
}
示例5: generateTree
import net.minecraft.world.gen.feature.WorldGenerator; //導入依賴的package包/類
@Override
public void generateTree(@Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull Random rand) {
if(!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(worldIn, rand, pos)) {
return;
}
SaplingType type = state.getValue(VARIANT);
WorldGenerator gen = null;
if(type == SaplingType.BAMBOO){
gen = new WorldGenBambooTree(false);
}
if(gen == null)return;
// replace sapling with air
worldIn.setBlockToAir(pos);
if (!gen.generate(worldIn, rand, pos))
{
worldIn.setBlockState(pos, state, 4);
}
}
示例6: runGenerator
import net.minecraft.world.gen.feature.WorldGenerator; //導入依賴的package包/類
private void runGenerator(WorldGenerator generator, World world, Random rand,
int chunk_x, int chunk_z, int veinsPerChunk, int minHeight, int maxHeight) {
if(minHeight<0||maxHeight>256||minHeight>maxHeight) {
throw new IllegalArgumentException("Illegal Height Arguments");
}
int heightDiff = (maxHeight - minHeight + 1);
for (int i=0; i<veinsPerChunk; i++) {
int x = chunk_x * 16 + rand.nextInt(16);
int y = minHeight + rand.nextInt(heightDiff);
int z = chunk_z * 16 + rand.nextInt(16);
BlockPos tempPos = new BlockPos(x, y, z);
generator.generate(world, rand, tempPos);
}
}
示例7: generateTree
import net.minecraft.world.gen.feature.WorldGenerator; //導入依賴的package包/類
private void generateTree(Random random, int chunkX, int chunkZ, World world) {
WorldGenerator gen = new WorldGenHeveaTree();
int xCoord = chunkX;
int yCoord = Global.SEALEVEL + 1;
int zCoord = chunkZ;
int numTrees = 1;
if (random.nextInt(20) == 0)
numTrees += random.nextInt(3);
for (int var2 = 0; var2 < numTrees; ++var2) {
xCoord = chunkX + random.nextInt(16);
zCoord = chunkZ + random.nextInt(16);
yCoord = world.getHeightValue(xCoord, zCoord);
temperature = TFC_Climate.getBioTemperatureHeight(world, xCoord, world.getHeightValue(xCoord, zCoord), zCoord);
int spawnChance = this.treeSpawnChance();
if (random.nextInt(100) < spawnChance) {
gen.generate(world, random, xCoord, yCoord, zCoord);
}
}
}
示例8: OreGeneratorEntry
import net.minecraft.world.gen.feature.WorldGenerator; //導入依賴的package包/類
/**
* 鉱石生成システムのエントリー<br>
* 生成高度配列の指定方法は
* PROPERTY_OVERWORLD,10,25 -- 通常ワールドに10~25の間に生成
* PROPERTY_HELL,150,200 -- ネザーに150~200の間に生成
* これを1列にしたもの
*
* @param genMinable ジェネレーターアルゴリズムクラス
* @param loop 1チャンク內にジェネレートを実行する回數
* @param isGeneratOverworld 通常世界に生成するか
* @param isGeneratHell ネザーに生成するか
* @param isGeneratEnd エンドに生成するか
* @param limiter 生成高度配列
*/
private OreGeneratorEntry(WorldGenerator genMinable, int loop, boolean isGeneratOverworld, boolean isGeneratHell, boolean isGeneratEnd, int... limiter) {
this.loop = loop;
this.isGeneratOverworld = isGeneratOverworld;
this.isGeneratHell = isGeneratHell;
this.isGeneratEnd = isGeneratEnd;
this.genMinable = genMinable;
for (int i = 0; i < limiter.length; ) {
switch (limiter[i++]) {
case 0:
this.minYOverworld = limiter[i++];
this.maxYOverworld = limiter[i++];
break;
case 1:
this.minYHell = limiter[i++];
this.maxYHell = limiter[i++];
break;
case 2:
this.minYEnd = limiter[i++];
this.maxYEnd = limiter[i++];
break;
}
}
}
示例9: run
import net.minecraft.world.gen.feature.WorldGenerator; //導入依賴的package包/類
private void run(WorldGenerator generator, World world, Random rand, int chunk_X, int chunk_Z, int chancesToSpawn, int minHeight, int maxHeight) {
if (minHeight < 0 || maxHeight > 256 || minHeight > maxHeight)
throw new IllegalArgumentException("Illegal Height Arguments for WorldGenerator");
int heightDiff = maxHeight - minHeight;
BlockPos pos;
// BiomeGenBase biome;
for (int i = 0; i < chancesToSpawn; i++) {
int x = chunk_X + rand.nextInt(Const.CHUNK_SIZE);
int y = minHeight + rand.nextInt(heightDiff);
int z = chunk_Z + rand.nextInt(Const.CHUNK_SIZE);
pos = new BlockPos(x, y, z);
// biome = world.getBiomeGenForCoords(pos);
// if(biome == Biomes.sky){
generator.generate(world, rand, pos);
// }
}
}
示例10: run
import net.minecraft.world.gen.feature.WorldGenerator; //導入依賴的package包/類
private void run(WorldGenerator generator, World world, Random rand, int chunk_X, int chunk_Z, int chancesToSpawn, int minHeight, int maxHeight) {
if (minHeight < 0 || maxHeight > Const.WORLDHEIGHT || minHeight > maxHeight)
throw new IllegalArgumentException("Illegal Height Arguments for WorldGenerator");
int heightDiff = maxHeight - minHeight;
BlockPos pos;
Biome biome;
for (int i = 0; i < chancesToSpawn; i++) {
int x = chunk_X + rand.nextInt(Const.CHUNK_SIZE);
int y = minHeight + rand.nextInt(heightDiff);
int z = chunk_Z + rand.nextInt(Const.CHUNK_SIZE);
pos = new BlockPos(x, y, z);
biome = world.getBiome(pos);
if (biome == Biomes.RIVER || biome == Biomes.FROZEN_RIVER) {
generator.generate(world, rand, pos);
}
}
}
示例11: run
import net.minecraft.world.gen.feature.WorldGenerator; //導入依賴的package包/類
private void run(WorldGenerator generator, World world, Random rand, int chunk_X, int chunk_Z, int chancesToSpawn, int minHeight, int maxHeight) {
if (minHeight < 0 || maxHeight > Const.WORLDHEIGHT || minHeight > maxHeight)
throw new IllegalArgumentException("Illegal Height Arguments for WorldGenerator");
int heightDiff = maxHeight - minHeight;
BlockPos pos;
Biome biome;
for (int i = 0; i < chancesToSpawn; i++) {
int x = chunk_X + rand.nextInt(Const.CHUNK_SIZE);
int y = minHeight + rand.nextInt(heightDiff);
int z = chunk_Z + rand.nextInt(Const.CHUNK_SIZE);
pos = new BlockPos(x, y, z);
biome = world.getBiome(pos);
if (biome == Biomes.EXTREME_HILLS || biome == Biomes.EXTREME_HILLS_EDGE || biome == Biomes.EXTREME_HILLS_WITH_TREES) {
generator.generate(world, rand, pos);
}
}
}
示例12: run
import net.minecraft.world.gen.feature.WorldGenerator; //導入依賴的package包/類
private void run(WorldGenerator generator, World world, Random rand, int chunk_X, int chunk_Z, int chancesToSpawn, int minHeight, int maxHeight) {
if (minHeight < 0 || maxHeight > 256 || minHeight > maxHeight)
throw new IllegalArgumentException("Illegal Height Arguments for WorldGenerator");
int heightDiff = maxHeight - minHeight;
BlockPos pos;
// BiomeGenBase biome;
for (int i = 0; i < chancesToSpawn; i++) {
int x = chunk_X + rand.nextInt(Const.CHUNK_SIZE);
int y = minHeight + rand.nextInt(heightDiff);
int z = chunk_Z + rand.nextInt(Const.CHUNK_SIZE);
pos = new BlockPos(x, y, z);
// biome = world.getBiomeGenForCoords(pos);
// if(biome == Biomes.hell){// no longer do this, in case some mod adds biomes to nether
generator.generate(world, rand, pos);
// }
}
}
示例13: getGenerator
import net.minecraft.world.gen.feature.WorldGenerator; //導入依賴的package包/類
private static WorldGenerator getGenerator(Algorithm algorithm) {
switch (algorithm) {
case TallOak:
return new KWorldGenTallTree(false);
case BlockOak:
return new WorldGenBlockOak(false);
case GreatOak:
return new WorldGenGreatOak(false);
case SwampOak:
return new WorldGenSwampOak(false);
case BigPine:
return new WorldGenBigPine(false);
case BigBirch:
return new WorldGenBigBirch(false);
case Dead:
return new WorldGenDesertTree(false);
case Cyprus:
return new KWorldGenCyprusTree(false);
case Hat:
return new KWorldGenHatTree(false);
}
throw new IllegalArgumentException("Unknown algorithm: " + algorithm.toString());
}
示例14: growTree
import net.minecraft.world.gen.feature.WorldGenerator; //導入依賴的package包/類
@Override
public void growTree(World world, int i, int j, int k, Random rand, long timestamp)
{
int meta = world.getBlockMetadata(i, j, k);
world.setBlockToAir(i, j, k);
WorldGenerator worldGen = new WorldGenShortTrees(false, meta);
if (worldGen != null && !worldGen.generate(world, rand, i, j, k))
{
world.setBlock(i, j, k, this, meta, 3);
if (world.getTileEntity(i, j, k) instanceof TESapling)
{
TESapling te = (TESapling) world.getTileEntity(i, j, k);
te.growTime = timestamp;
te.enoughSpace = false;
te.markDirty();
}
}
}
示例15: generateFruitTrees
import net.minecraft.world.gen.feature.WorldGenerator; //導入依賴的package包/類
private void generateFruitTrees(Random random, int chunkX, int chunkZ, World world)
{
int xCoord = chunkX + random.nextInt(16);
int zCoord = chunkZ + random.nextInt(16);
int yCoord = world.getTopSolidOrLiquidBlock(xCoord, zCoord);
int meta = random.nextInt(Constants.NUTTREETYPES.length);
temperature = TFC_Climate.getBioTemperatureHeight(world, xCoord, yCoord, zCoord);
WorldGenerator worldGen = new WorldGenFruitTrees(false, meta);
if(meta == 1 || meta == 2)
{
if(shouldtreeSpawn(random, 0.25f, 2, 500f, 1200f, 25, 45, 175))
worldGen.generate(world, random, xCoord, yCoord, zCoord);
}
else if(shouldtreeSpawn(random, 0.25f, 2, 500f, 1200f, 5, 25, 175))
worldGen.generate(world, random, xCoord, yCoord, zCoord);
}