Search in sources :

Example 1 with WorldGenFroliaTree

use of stevekung.mods.moreplanets.planets.fronos.world.gen.feature.WorldGenFroliaTree 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)

Aggregations

IBlockState (net.minecraft.block.state.IBlockState)1 WorldGenerator (net.minecraft.world.gen.feature.WorldGenerator)1 WorldGenCheeseSporeTree (stevekung.mods.moreplanets.planets.chalos.world.gen.feature.WorldGenCheeseSporeTree)1 WorldGenFroliaTree (stevekung.mods.moreplanets.planets.fronos.world.gen.feature.WorldGenFroliaTree)1 WorldGenOscaleaTrees (stevekung.mods.moreplanets.planets.fronos.world.gen.feature.WorldGenOscaleaTrees)1