本文整理汇总了Java中net.minecraft.world.gen.feature.WorldGenerator.generate方法的典型用法代码示例。如果您正苦于以下问题:Java WorldGenerator.generate方法的具体用法?Java WorldGenerator.generate怎么用?Java WorldGenerator.generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.world.gen.feature.WorldGenerator
的用法示例。
在下文中一共展示了WorldGenerator.generate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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));
}
示例2: 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);
}
}
示例3: 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);
}
}
示例4: 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);
}
}
示例5: 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);
// }
}
}
示例6: 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);
}
}
}
示例7: 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);
}
}
}
示例8: 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);
// }
}
}
示例9: 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();
}
}
}
示例10: 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);
}
示例11: generateTrees
import net.minecraft.world.gen.feature.WorldGenerator; //导入方法依赖的package包/类
private void generateTrees(Random random, int chunkX, int chunkZ, World world)
{
int xCoord = chunkX;
int yCoord = Global.SEALEVEL + 1;
int zCoord = chunkZ;
WorldGenerator worldGen = new WorldGenShortTrees(false, 0);
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.getTopSolidOrLiquidBlock(xCoord, zCoord);
temperature = TFC_Climate.getBioTemperatureHeight(world, xCoord, yCoord, zCoord);
if (shouldtreeSpawn(random, 0.25f, 2, 250f, 1200f, 5, 25, 100))
worldGen.generate(world, random, xCoord, yCoord, zCoord);
}
}
示例12: tryGrow
import net.minecraft.world.gen.feature.WorldGenerator; //导入方法依赖的package包/类
public boolean tryGrow(boolean bonemealed) {
if (this.getTree() == null)
return false;
if(!bonemealed && timesTicked < getTree().getRequiredMaturity())
return false;
WorldGenerator generator = this.getTree().getTreeGenerator(worldObj, xCoord, yCoord, zCoord, bonemealed);
if (generator.generate(worldObj, worldObj.rand, xCoord, yCoord, zCoord)) {
if(worldObj.getBlockId(xCoord, yCoord - 1, zCoord) == ForestryBlock.soil.blockID)
worldObj.setBlockAndMetadataWithNotify(xCoord, yCoord - 1, zCoord, Block.sand.blockID, 0);
return true;
}
return false;
}
示例13: generate
import net.minecraft.world.gen.feature.WorldGenerator; //导入方法依赖的package包/类
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator,
IChunkProvider chunkProvider)
{
final Settings settings = Settings.INSTANCE;
if (settings.isOverworldTreeGenEnabled())
{
final int x = (chunkX << 4) + 8 + random.nextInt(16);
final int z = (chunkZ << 4) + 8 + random.nextInt(16);
final BiomeGenBase biome = world.getBiomeGenForCoords(x, z);
final List<Type> biomeTypes = ImmutableList.copyOf(BiomeDictionary.getTypesForBiome(biome));
if (!(biomeTypes.contains(Type.NETHER) || biomeTypes.contains(Type.END)))
if (random.nextInt(settings.overworldTreeGenRarity()) == 0)
{
final OverworldTreeSpecies species =
OverworldTreeSpecies.values()[random.nextInt(OverworldTreeSpecies.values().length)];
final WorldGenerator tree = species.worldTreeGenerator();
final int maxY = world.getHeightValue(x, z) * 2;
final int y = maxY > 0 ? random.nextInt(maxY) : 0;
tree.generate(world, random, x, y, z);
}
}
}
示例14: applyBonemeal
import net.minecraft.world.gen.feature.WorldGenerator; //导入方法依赖的package包/类
@Override
public boolean applyBonemeal (World world, int x, int y, int z, BlockGarden hostBlock, int slot) {
Block plantBlock = hostBlock.getPlantBlockFromSlot(world, x, y, z, slot);
if (plantBlock == null)
return false;
Item sapling = Item.getItemFromBlock(plantBlock);
int saplingMeta = hostBlock.getPlantMetaFromSlot(world, x, y, z, slot);
WorldGenerator generator = (WorldGenerator) SaplingRegistry.instance().getExtendedData(sapling, saplingMeta, "sm_generator");
if (generator == null)
return false;
NBTTagCompound storedTE = hostBlock.saveAndClearPlantedContents(world, x, y, z);
if (!generator.generate(world, world.rand, x, y + 1, z))
hostBlock.restorePlantedContents(world, x, y, z, storedTE);
return true;
}
示例15: onUseBonemeal
import net.minecraft.world.gen.feature.WorldGenerator; //导入方法依赖的package包/类
/**
* Handles bonemeal usage for fir saplings type.
*/
// / FIXME: This is gone.
// @Override
public boolean onUseBonemeal(World world, int bid, int i, int j, int k) {
if (bid != ForestryBlock.firsapling.blockID)
return false;
int type = world.getBlockMetadata(i, j, k) & 0x03;
WorldGenerator generator;
if (type != 2) {
generator = createTreeGenerator(world, type);
} else {
generator = new WorldGenBigMushroom();
}
world.setBlockAndMetadata(i, j, k, 0, 0);
if (!generator.generate(world, world.rand, i, j, k)) {
world.setBlockAndMetadata(i, j, k, ForestryBlock.firsapling.blockID, type);
return false;
}
return true;
}