Java Code Examples for net.minecraft.world.gen.feature.WorldGenerator#generate()

The following examples show how to use net.minecraft.world.gen.feature.WorldGenerator#generate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BiomeTofuForest.java    From TofuCraftReload with MIT License 6 votes vote down vote up
@Override
public void decorate(World worldIn, Random rand, BlockPos pos) {
    super.decorate(worldIn, rand, pos);
    int j, k, l, i1;

    if (rand.nextInt(30) == 0) {
        BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos();

        for (j = 0; j < 5; j++) {
            k = pos.getX() + rand.nextInt(16) + 8;
            l = rand.nextInt(128);
            i1 = pos.getZ() + rand.nextInt(16) + 8;
            mutable.setPos(k, l, i1);

            WorldGenerator var6 = new WorldGenBush(BlockLoader.TOFUFLOWER);
            var6.generate(worldIn, rand, mutable);
        }
    }
}
 
Example 2
Source File: BlockMapleSaplingGreen.java    From Sakura_mod with MIT License 6 votes vote down vote up
@Override
public void grow(World world, Random rand, BlockPos pos, IBlockState state) {
	WorldGenerator treeGenerator = rand.nextInt(8) == 0
			? new WorldGenMapleTreeGreen(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
					BlockLoader.MAPLE_LEAVE_GREEN.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false)
							.withProperty(BlockLeaves.DECAYABLE, true),
					BlockLoader.FALLEN_LEAVES_MAPLE_GREEN.getDefaultState(), true)
			: new WorldGenMapleTreeGreen(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
					BlockLoader.MAPLE_LEAVE_GREEN.getDefaultState()
							.withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
					BlockLoader.FALLEN_LEAVES_MAPLE_GREEN.getDefaultState(), false);

	world.setBlockState(pos, Blocks.AIR.getDefaultState(), 4);

	if (!treeGenerator.generate(world, rand, pos)) {

		world.setBlockState(pos, state, 4);

	}
}
 
Example 3
Source File: GardenCoreIntegration.java    From GardenCollection with MIT License 6 votes vote down vote up
@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;
}
 
Example 4
Source File: ForgeEventHandler.java    From GardenCollection with MIT License 6 votes vote down vote up
@SubscribeEvent
public void applyEnrichedSoil (EnrichedSoilEvent event) {
    if (!GardenTrees.config.compostGrowsOrnamentalTrees)
        return;

    Item sapling = Item.getItemFromBlock(event.block);
    int saplingMeta = event.world.getBlockMetadata(event.x, event.y, event.z);
    if (sapling == null)
        return;

    WorldGenerator generator = (WorldGenerator) SaplingRegistry.instance().getExtendedData(sapling, saplingMeta, "sm_generator");
    if (generator == null)
        return;

    event.world.setBlockToAir(event.x, event.y, event.z);

    if (generator.generate(event.world, event.world.rand, event.x, event.y, event.z)) {
        event.setResult(Event.Result.ALLOW);
        return;
    }

    event.world.setBlock(event.x, event.y, event.z, event.block, saplingMeta, 0);
}
 
Example 5
Source File: BlockTofuSapling.java    From TofuCraftReload with MIT License 5 votes vote down vote up
@Override
public void grow(World world, Random rand, BlockPos pos, IBlockState state) {
    WorldGenerator treeGenerator = new WorldGenTofuTrees(true);
    world.setBlockState(pos, Blocks.AIR.getDefaultState(), 4);
    if (!treeGenerator.generate(world, rand, pos)) {
        world.setBlockState(pos, state, 4);
    }
}
 
Example 6
Source File: BlockSakuraSapling.java    From Sakura_mod with MIT License 5 votes vote down vote up
@Override
public void grow(World world, Random rand, BlockPos pos, IBlockState state) {
	WorldGenerator treeGenerator = rand.nextInt(8) == 0 ? new WorldGenSakuraTree(true, 5)
			: new WorldGenBigSakura(true);

	world.setBlockState(pos, Blocks.AIR.getDefaultState(), 4);
	if (!treeGenerator.generate(world, rand, pos))
		world.setBlockState(pos, state, 4);
}
 
Example 7
Source File: BiomeRockyPlains.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void genStandardOre2(World worldIn, Random random, int blockCount, WorldGenerator generator, int centerHeight, int spread) {
	for (int i = 0; i < blockCount; ++i)
	{
		BlockPos blockpos = this.chunkPos.add(random.nextInt(16), random.nextInt(spread) + random.nextInt(spread) + centerHeight - spread, random.nextInt(16));
		generator.generate(worldIn, random, blockpos);
	}
}
 
Example 8
Source File: BiomeRockyPlains.java    From Traverse-Legacy-1-12-2 with MIT License 5 votes vote down vote up
@Override
protected void genStandardOre2(World worldIn, Random random, int blockCount, WorldGenerator generator, int centerHeight, int spread) {
	for (int i = 0; i < blockCount; ++i)
	{
		BlockPos blockpos = this.chunkPos.add(random.nextInt(16), random.nextInt(spread) + random.nextInt(spread) + centerHeight - spread, random.nextInt(16));
		generator.generate(worldIn, random, blockpos);
	}
}
 
Example 9
Source File: ValkyrienSkiesWorldGen.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
private void runValkyriumGenerator(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 + 1;
    for (int i = 0; i < chancesToSpawn; i++) {
        int x = chunk_X * 16 + rand.nextInt(16);
        int y = minHeight + rand.nextInt(heightDiff);
        int z = chunk_Z * 16 + rand.nextInt(16);
        generator.generate(world, rand, new BlockPos(x, y, z));
    }
}
 
Example 10
Source File: BlockGTSapling.java    From GardenCollection with MIT License 5 votes vote down vote up
@Override
public void func_149878_d (World world, int x, int y, int z, Random random) {
    if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(world, random, x, y, z))
        return;

    int id = world.getBlockMetadata(x, y, z) & 7;
    WorldGenerator generator = null;

    switch (id) {
        case 0:
            generator = new WorldGenTaiga1() {
                @Override
                protected void setBlockAndNotifyAdequately (World world, int x, int y, int z, Block block, int meta) {
                    world.setBlock(x, y, z, block, meta, 3);
                }
            };
            break;
        case 1:
            generator = new WorldGenSwamp() {
                @Override
                protected void setBlockAndNotifyAdequately (World world, int x, int y, int z, Block block, int meta) {
                    world.setBlock(x, y, z, block, meta, 3);
                }
            };
            break;
        case 2:
            generator = new WorldGenForest(true, true);
            break;
        default:
            return;
    }

    world.setBlock(x, y, z, Blocks.air, 0, 4);

    if (!(generator.generate(world, random, x, y, z)))
        world.setBlock(x, y, z, this, id, 4);
}
 
Example 11
Source File: WorldGenTofuBuilding.java    From TofuCraftReload with MIT License 4 votes vote down vote up
protected void plantLeeks(BlockPos pos, int r, World world, Random random)
{
    WorldGenerator var6 = new WorldGenBush(BlockLoader.LEEK);
    var6.generate(world, random, pos);
}
 
Example 12
Source File: BlockMapleSaplingYellow.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public void grow(World world, Random rand, BlockPos pos, IBlockState state) {
	WorldGenerator treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
			BlockLoader.MAPLE_LEAVE_YELLOW.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
			BlockLoader.FALLEN_LEAVES_MAPLE_YELLOW.getDefaultState(), false);
	switch (rand.nextInt(16)) {
	case 0:
		treeGenerator = new WorldGenBigMaple(true, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_SAPLING_YELLOW.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_YELLOW.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_YELLOW.getDefaultState(), true);
		break;
	case 1:
		treeGenerator = new WorldGenBigMaple(true, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_SAPLING_YELLOW.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_YELLOW.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_YELLOW.getDefaultState(), false);
		break;
	case 2:
		treeGenerator = new WorldGenBigMaple(true, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_SAPLING_YELLOW.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_YELLOW.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_YELLOW.getDefaultState(), false);
		break;
	case 3:
		treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_YELLOW.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_YELLOW.getDefaultState(), true);
		break;
	case 4:
		treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_YELLOW.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_YELLOW.getDefaultState(), true);
		break;
	case 5:
		treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_YELLOW.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_YELLOW.getDefaultState(), true);
		break;
	default:
		break;
	}
	world.setBlockState(pos, Blocks.AIR.getDefaultState(), 4);
	if (!treeGenerator.generate(world, rand, pos)) {
		world.setBlockState(pos, state, 4);
	}
}
 
Example 13
Source File: BlockMapleSaplingRed.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public void grow(World world, Random rand, BlockPos pos, IBlockState state) {
	WorldGenerator treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
			BlockLoader.MAPLE_LEAVE_RED.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true), BlockLoader.FALLEN_LEAVES_MAPLE_RED.getDefaultState(),
			false);
	switch (rand.nextInt(16)) {
	case 0:
		treeGenerator = new WorldGenBigMaple(true, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_SAPLING_RED.getDefaultState(), BlockLoader.MAPLE_LEAVE_RED.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_RED.getDefaultState(), true);
		break;
	case 1:
		treeGenerator = new WorldGenBigMaple(true, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_SAPLING_RED.getDefaultState(), BlockLoader.MAPLE_LEAVE_RED.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_RED.getDefaultState(), false);
		break;
	case 2:
		treeGenerator = new WorldGenBigMaple(true, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_SAPLING_RED.getDefaultState(), BlockLoader.MAPLE_LEAVE_RED.getDefaultState(),
				BlockLoader.FALLEN_LEAVES_MAPLE_RED.getDefaultState(), false);
		break;
	case 3:
		treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_RED.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_RED.getDefaultState(), true);
		break;
	case 4:
		treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_RED.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_RED.getDefaultState(), true);
		break;
	case 5:
		treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_RED.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_RED.getDefaultState(), true);
		break;
	default:
		break;
	}
	world.setBlockState(pos, Blocks.AIR.getDefaultState(), 4);
	if (!treeGenerator.generate(world, rand, pos)) {
		world.setBlockState(pos, state, 4);
	}
}
 
Example 14
Source File: BlockMapleSaplingOrange.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public void grow(World world, Random rand, BlockPos pos, IBlockState state) {
	WorldGenerator treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
			BlockLoader.MAPLE_LEAVE_ORANGE.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
			BlockLoader.FALLEN_LEAVES_MAPLE_ORANGE.getDefaultState(), false);
	switch (rand.nextInt(16)) {
	case 0:
		treeGenerator = new WorldGenBigMaple(true, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_SAPLING_ORANGE.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_ORANGE.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_ORANGE.getDefaultState(), true);
		break;
	case 1:
		treeGenerator = new WorldGenBigMaple(true, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_SAPLING_ORANGE.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_ORANGE.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_ORANGE.getDefaultState(), false);
		break;
	case 2:
		treeGenerator = new WorldGenBigMaple(true, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_SAPLING_ORANGE.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_ORANGE.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_ORANGE.getDefaultState(), false);
		break;
	case 3:
		treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_ORANGE.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_ORANGE.getDefaultState(), true);
		break;
	case 4:
		treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_ORANGE.getDefaultState(),
				BlockLoader.FALLEN_LEAVES_MAPLE_ORANGE.getDefaultState(), true);
		break;
	case 5:
		treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_ORANGE.getDefaultState(),
				BlockLoader.FALLEN_LEAVES_MAPLE_ORANGE.getDefaultState(), true);
		break;
	default:
		break;
	}
	world.setBlockState(pos, Blocks.AIR.getDefaultState(), 4);
	if (!treeGenerator.generate(world, rand, pos)) {
		world.setBlockState(pos, state, 4);
	}
}
 
Example 15
Source File: BlockApricotSapling.java    From TofuCraftReload with MIT License 3 votes vote down vote up
@Override
public void grow(World world, Random rand, BlockPos pos, IBlockState state) {
    WorldGenerator treeGenerator = new WorldGenApricotTrees(true);

    world.setBlockState(pos, Blocks.AIR.getDefaultState(), 4);

    if (!treeGenerator.generate(world, rand, pos)) {

        world.setBlockState(pos, state, 4);

    }
}