Search in sources :

Example 36 with WorldGenerator

use of net.minecraft.world.gen.feature.WorldGenerator in project ForestryMC by ForestryMC.

the class TileSapling method canAcceptBoneMeal.

public boolean canAcceptBoneMeal(Random rand) {
    ITree tree = getTree();
    if (tree == null) {
        return false;
    }
    int maturity = getRequiredMaturity(world, tree);
    if (timesTicked < maturity) {
        return true;
    }
    WorldGenerator generator = tree.getTreeGenerator(world, getPos(), true);
    if (generator instanceof WorldGenArboriculture) {
        WorldGenArboriculture arboricultureGenerator = (WorldGenArboriculture) generator;
        arboricultureGenerator.preGenerate(world, rand, getPos());
        return arboricultureGenerator.getValidGrowthPos(world, getPos()) != null;
    } else {
        return true;
    }
}
Also used : WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator) WorldGenArboriculture(forestry.arboriculture.worldgen.WorldGenArboriculture) ITree(forestry.api.arboriculture.ITree)

Example 37 with WorldGenerator

use of net.minecraft.world.gen.feature.WorldGenerator in project ForestryMC by ForestryMC.

the class TreeGenHelper method generateTree.

public static boolean generateTree(ITree tree, World world, BlockPos pos) {
    WorldGenerator gen = tree.getTreeGenerator(world, pos, true);
    IBlockState blockState = world.getBlockState(pos);
    if (BlockUtil.canPlaceTree(blockState, world, pos)) {
        if (gen instanceof WorldGenBase) {
            return ((WorldGenBase) gen).generate(world, world.rand, pos, true);
        } else {
            return gen.generate(world, world.rand, pos);
        }
    }
    return false;
}
Also used : WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator) IBlockState(net.minecraft.block.state.IBlockState) WorldGenBase(forestry.core.worldgen.WorldGenBase)

Example 38 with WorldGenerator

use of net.minecraft.world.gen.feature.WorldGenerator in project GregTech by GregTechCE.

the class BlockGregSapling method generateTree.

public void generateTree(World worldIn, BlockPos pos, IBlockState state, Random rand) {
    if (!TerrainGen.saplingGrowTree(worldIn, rand, pos))
        return;
    WorldGenerator worldgenerator;
    IBlockState logState = MetaBlocks.LOG.getDefaultState().withProperty(BlockGregLog.VARIANT, LogVariant.RUBBER_WOOD).withProperty(BlockGregLog.NATURAL, true);
    IBlockState leavesState = MetaBlocks.LEAVES.getDefaultState().withProperty(BlockGregLeaves.VARIANT, LogVariant.RUBBER_WOOD);
    if (rand.nextInt(10) == 0) {
        worldgenerator = new WorldGenBigTreeCustom(true, logState, leavesState.withProperty(BlockGregLeaves.CHECK_DECAY, false), BlockGregLog.LOG_AXIS);
    } else {
        worldgenerator = new WorldGenTrees(true, 6, logState, leavesState, false);
    }
    worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 4);
    if (!worldgenerator.generate(worldIn, rand, pos)) {
        worldIn.setBlockState(pos, state, 4);
    }
}
Also used : WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator) IBlockState(net.minecraft.block.state.IBlockState) WorldGenTrees(net.minecraft.world.gen.feature.WorldGenTrees)

Example 39 with WorldGenerator

use of net.minecraft.world.gen.feature.WorldGenerator in project MorePlanets by SteveKunG.

the class BlockSaplingMP method grow.

@Override
public void grow(World world, Random rand, BlockPos pos, IBlockState state) {
    if (state.getValue(STAGE) == 0) {
        world.setBlockState(pos, state.cycleProperty(STAGE), 4);
    } else {
        WorldGenerator worldGen = null;
        int i = 0;
        int j = 0;
        boolean flag = false;
        switch(this.type) {
            case INFECTED_OAK_SAPLING:
                worldGen = rand.nextInt(10) == 0 ? new WorldGenInfectedBigTree(true, MPBlocks.INFECTED_OAK_LOG.getDefaultState(), MPBlocks.INFECTED_OAK_LEAVES.getDefaultState()) : new WorldGenInfectedTrees(true, MPBlocks.INFECTED_OAK_LOG.getDefaultState(), MPBlocks.INFECTED_OAK_LEAVES.getDefaultState());
                break;
            case INFECTED_SPRUCE_SAPLING:
                label68: for (i = 0; i >= -1; --i) {
                    for (j = 0; j >= -1; --j) {
                        if (this.isTwoByTwoOfType(world, pos, i, j, BlockType.INFECTED_SPRUCE_SAPLING)) {
                            worldGen = new WorldGenInfectedMegaPineTree(true, rand.nextBoolean());
                            flag = true;
                            break label68;
                        }
                    }
                }
                if (!flag) {
                    i = 0;
                    j = 0;
                    worldGen = new WorldGenInfectedDeadSpruce(true);
                }
                break;
            case INFECTED_JUNGLE_SAPLING:
                label269: for (i = 0; i >= -1; --i) {
                    for (j = 0; j >= -1; --j) {
                        if (this.isTwoByTwoOfType(world, pos, i, j, BlockType.INFECTED_JUNGLE_SAPLING)) {
                            worldGen = new WorldGenInfectedMegaJungleTree();
                            flag = true;
                            break label269;
                        }
                    }
                }
                if (!flag) {
                    j = 0;
                    i = 0;
                    worldGen = new WorldGenInfectedJungleTrees(true, 4 + rand.nextInt(7), false);
                }
                break;
            case ALIEN_BERRY_OAK_SAPLING:
                worldGen = rand.nextInt(10) == 0 ? new WorldGenAlienBerryBigTree() : new WorldGenAlienBerryTree();
                break;
            case OSCALEA_SAPLING:
                worldGen = new WorldGenOscaleaTrees();
                break;
            case FROLIA_SAPLING:
                worldGen = new WorldGenFroliaTree();
                break;
            case CHEESE_SPORE_FLOWER:
                if (!state.getValue(NATURAL_GEN)) {
                    worldGen = new WorldGenCheeseSporeTree(6 + rand.nextInt(4), true);
                }
                break;
        }
        if (worldGen != null) {
            IBlockState iblockstate2 = Blocks.AIR.getDefaultState();
            if (flag) {
                world.setBlockState(pos.add(i, 0, j), iblockstate2, 4);
                world.setBlockState(pos.add(i + 1, 0, j), iblockstate2, 4);
                world.setBlockState(pos.add(i, 0, j + 1), iblockstate2, 4);
                world.setBlockState(pos.add(i + 1, 0, j + 1), iblockstate2, 4);
            } else {
                world.setBlockState(pos, iblockstate2, 4);
            }
            if (!worldGen.generate(world, rand, pos.add(i, 0, j))) {
                if (flag) {
                    world.setBlockState(pos.add(i, 0, j), state, 4);
                    world.setBlockState(pos.add(i + 1, 0, j), state, 4);
                    world.setBlockState(pos.add(i, 0, j + 1), state, 4);
                    world.setBlockState(pos.add(i + 1, 0, j + 1), state, 4);
                } else {
                    world.setBlockState(pos, state, 4);
                }
            }
        }
    }
}
Also used : WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator) IBlockState(net.minecraft.block.state.IBlockState) WorldGenFroliaTree(stevekung.mods.moreplanets.planets.fronos.world.gen.feature.WorldGenFroliaTree) WorldGenCheeseSporeTree(stevekung.mods.moreplanets.planets.chalos.world.gen.feature.WorldGenCheeseSporeTree) WorldGenOscaleaTrees(stevekung.mods.moreplanets.planets.fronos.world.gen.feature.WorldGenOscaleaTrees)

Example 40 with WorldGenerator

use of net.minecraft.world.gen.feature.WorldGenerator in project BetterWithAddons by DaedalusGame.

the class BlockModSapling method generateTree.

public void generateTree(World worldIn, BlockPos pos, IBlockState state, Random rand) {
    if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(worldIn, rand, pos))
        return;
    WorldGenerator worldgenerator = isBig ? new WorldGenBigTrees(true, log, leaves, this) : new WorldGenTrees(true, 3, log, leaves, false);
    int i = 0;
    int j = 0;
    IBlockState iblockstate2 = Blocks.AIR.getDefaultState();
    worldIn.setBlockState(pos, iblockstate2, 4);
    if (!worldgenerator.generate(worldIn, rand, pos.add(i, 0, j))) {
        worldIn.setBlockState(pos, state, 4);
    }
}
Also used : WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator) IBlockState(net.minecraft.block.state.IBlockState) WorldGenBigTrees(betterwithaddons.world.WorldGenBigTrees) WorldGenTrees(net.minecraft.world.gen.feature.WorldGenTrees)

Aggregations

WorldGenerator (net.minecraft.world.gen.feature.WorldGenerator)44 BlockPos (net.minecraft.util.math.BlockPos)25 IBlockState (net.minecraft.block.state.IBlockState)8 WorldUtil (rtg.api.util.WorldUtil)7 World (net.minecraft.world.World)3 WorldGenMinable (net.minecraft.world.gen.feature.WorldGenMinable)3 WorldGenGrass (rtg.api.world.gen.feature.WorldGenGrass)3 MapMaker (com.google.common.collect.MapMaker)2 ITree (forestry.api.arboriculture.ITree)2 WorldGenBase (forestry.core.worldgen.WorldGenBase)2 Predicate (java.util.function.Predicate)2 RailcraftConfig (mods.railcraft.common.core.RailcraftConfig)2 NoiseGenSimplex (mods.railcraft.common.worldgen.NoiseGen.NoiseGenSimplex)2 Vec3 (net.minecraft.util.Vec3)2 Biome (net.minecraft.world.biome.Biome)2 WorldGenTrees (net.minecraft.world.gen.feature.WorldGenTrees)2 EventType (net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType)2 TerrainGen (net.minecraftforge.event.terraingen.TerrainGen)2 DecorateBiomeEventRTG (rtg.api.event.DecorateBiomeEventRTG)2 WorldGenBigTrees (betterwithaddons.world.WorldGenBigTrees)1