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;
}
}
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;
}
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);
}
}
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);
}
}
}
}
}
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);
}
}
Aggregations