Search in sources :

Example 1 with TropicraftSaplings

use of net.tropicraft.core.common.enums.TropicraftSaplings in project Tropicraft by Tropicraft.

the class BlockTropicsSapling method grow.

@Override
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) {
    // Change flag (and back) to make it show up when generated
    TCGenBase.blockGenNotifyFlag = 3;
    WorldGenerator gen;
    TropicraftSaplings variant;
    switch(variant = state.getValue(VARIANT)) {
        case PALM:
            int b = rand.nextInt(3);
            if (b == 0) {
                gen = new WorldGenLargePalmTrees(worldIn, rand);
            } else if (b == 1) {
                gen = new WorldGenCurvedPalms(worldIn, rand);
            } else if (b == 2) {
                gen = new WorldGenNormalPalms(worldIn, rand);
            } else {
                gen = null;
            }
            break;
        case MAHOGANY:
            gen = randomRainforestTreeGen(worldIn);
            break;
        default:
            gen = new WorldGenFruitTrees(worldIn, rand, variant.getMeta() - 2);
            break;
    }
    if (gen != null) {
        worldIn.setBlockToAir(pos);
        if (!gen.generate(worldIn, rand, pos)) {
            worldIn.setBlockState(pos, state.withProperty(BlockTropicsSapling.VARIANT, variant), 3);
        }
    }
    TCGenBase.blockGenNotifyFlag = TCGenBase.BLOCK_GEN_NOTIFY_FLAG_DEFAULT;
}
Also used : WorldGenLargePalmTrees(net.tropicraft.core.common.worldgen.WorldGenLargePalmTrees) WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator) WorldGenCurvedPalms(net.tropicraft.core.common.worldgen.WorldGenCurvedPalms) TropicraftSaplings(net.tropicraft.core.common.enums.TropicraftSaplings) WorldGenFruitTrees(net.tropicraft.core.common.worldgen.WorldGenFruitTrees) WorldGenNormalPalms(net.tropicraft.core.common.worldgen.WorldGenNormalPalms)

Aggregations

WorldGenerator (net.minecraft.world.gen.feature.WorldGenerator)1 TropicraftSaplings (net.tropicraft.core.common.enums.TropicraftSaplings)1 WorldGenCurvedPalms (net.tropicraft.core.common.worldgen.WorldGenCurvedPalms)1 WorldGenFruitTrees (net.tropicraft.core.common.worldgen.WorldGenFruitTrees)1 WorldGenLargePalmTrees (net.tropicraft.core.common.worldgen.WorldGenLargePalmTrees)1 WorldGenNormalPalms (net.tropicraft.core.common.worldgen.WorldGenNormalPalms)1