Search in sources :

Example 1 with WorldGenBirchTreePerverted

use of cavern.world.gen.WorldGenBirchTreePerverted in project Cavern2 by kegare.

the class ChunkGeneratorCaveland method populate.

@Override
public void populate(int chunkX, int chunkZ) {
    BlockFalling.fallInstantly = true;
    int worldX = chunkX * 16;
    int worldZ = chunkZ * 16;
    BlockPos blockPos = new BlockPos(worldX, 0, worldZ);
    Biome biome = world.getBiome(blockPos.add(16, 0, 16));
    BiomeDecorator decorator = biome.decorator;
    int worldHeight = world.provider.getActualHeight();
    ForgeEventFactory.onChunkPopulate(true, this, world, rand, chunkX, chunkZ, false);
    int x, y, z;
    if (CavelandConfig.generateLakes) {
        if (TerrainGen.populate(this, world, rand, chunkX, chunkZ, false, EventType.LAKE)) {
            x = rand.nextInt(16) + 8;
            y = rand.nextInt(worldHeight - 16);
            z = rand.nextInt(16) + 8;
            lakeWaterGen.generate(world, rand, blockPos.add(x, y, z));
        }
        if (rand.nextInt(30) == 0 && TerrainGen.populate(this, world, rand, chunkX, chunkZ, false, EventType.LAVA)) {
            x = rand.nextInt(16) + 8;
            y = rand.nextInt(worldHeight / 2);
            z = rand.nextInt(16) + 8;
            lakeLavaGen.generate(world, rand, blockPos.add(x, y, z));
        }
    }
    MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Pre(world, rand, blockPos));
    MinecraftForge.ORE_GEN_BUS.post(new OreGenEvent.Post(world, rand, blockPos));
    for (int i = 0; i < 10; ++i) {
        x = rand.nextInt(16) + 8;
        y = rand.nextInt(worldHeight - 10);
        z = rand.nextInt(16) + 8;
        acresiaGen.generate(world, rand, blockPos.add(x, y, z));
    }
    for (int i = 0; i < 15; ++i) {
        x = rand.nextInt(16) + 8;
        y = rand.nextInt(worldHeight / 2 - 10) + worldHeight / 2;
        z = rand.nextInt(16) + 8;
        acresiaGen.generate(world, rand, blockPos.add(x, y, z));
    }
    if (TerrainGen.decorate(world, rand, blockPos, Decorate.EventType.SHROOM)) {
        for (int i = 0; i < 5; ++i) {
            x = rand.nextInt(16) + 8;
            y = rand.nextInt(worldHeight - 10);
            z = rand.nextInt(16) + 8;
            decorator.mushroomBrownGen.generate(world, rand, blockPos.add(x, y, z));
        }
        for (int i = 0; i < 5; ++i) {
            x = rand.nextInt(16) + 8;
            y = rand.nextInt(worldHeight - 10);
            z = rand.nextInt(16) + 8;
            decorator.mushroomRedGen.generate(world, rand, blockPos.add(x, y, z));
        }
    }
    if (BiomeDictionary.hasType(biome, Type.SANDY)) {
        if (TerrainGen.decorate(world, rand, blockPos, Decorate.EventType.CACTUS)) {
            for (int i = 0; i < 80; ++i) {
                x = rand.nextInt(16) + 8;
                y = rand.nextInt(worldHeight - 5);
                z = rand.nextInt(16) + 8;
                decorator.cactusGen.generate(world, rand, blockPos.add(x, y, z));
            }
        }
        if (TerrainGen.decorate(world, rand, blockPos, Decorate.EventType.DEAD_BUSH)) {
            for (int i = 0; i < 10; ++i) {
                x = rand.nextInt(16) + 8;
                y = rand.nextInt(worldHeight - 5);
                z = rand.nextInt(16) + 8;
                deadBushGen.generate(world, rand, blockPos.add(x, y, z));
            }
        }
    } else {
        if (TerrainGen.decorate(world, rand, blockPos, Decorate.EventType.FLOWERS)) {
            for (int i = 0; i < 8; ++i) {
                x = rand.nextInt(16) + 8;
                y = rand.nextInt(worldHeight - 5);
                z = rand.nextInt(16) + 8;
                decorator.flowerGen.generate(world, rand, blockPos.add(x, y, z));
            }
        }
        for (int i = 0; i < 18; ++i) {
            x = rand.nextInt(16) + 8;
            y = rand.nextInt(worldHeight - 5);
            z = rand.nextInt(16) + 8;
            biome.getRandomWorldGenForGrass(rand).generate(world, rand, blockPos.add(x, y, z));
        }
        if (TerrainGen.decorate(world, rand, blockPos, Decorate.EventType.TREE)) {
            WorldGenAbstractTree treeGen = null;
            if (BiomeDictionary.hasType(biome, Type.JUNGLE)) {
                treeGen = new WorldGenTreesPerverted(false, 4 + rand.nextInt(7), BlockPlanks.EnumType.JUNGLE, true);
            } else if (BiomeDictionary.hasType(biome, Type.FOREST) || !BiomeDictionary.hasType(biome, Type.PLAINS) || rand.nextInt(10) == 0) {
                if (BiomeDictionary.hasType(biome, Type.COLD)) {
                    treeGen = new WorldGenSpruceTreePerverted(false);
                } else if (rand.nextInt(3) == 0) {
                    treeGen = new WorldGenBirchTreePerverted(false, false);
                } else {
                    treeGen = new WorldGenTreesPerverted(false, 3, BlockPlanks.EnumType.OAK, true);
                }
            }
            if (treeGen != null) {
                for (int i = 0; i < 80; ++i) {
                    x = rand.nextInt(16) + 8;
                    y = rand.nextInt(worldHeight);
                    z = rand.nextInt(16) + 8;
                    BlockPos pos = blockPos.add(x, y, z);
                    if (treeGen.generate(world, rand, pos)) {
                        treeGen.generateSaplings(world, rand, pos);
                    }
                }
                for (int i = 0; i < 60; ++i) {
                    x = rand.nextInt(16) + 8;
                    y = 8 + rand.nextInt(5);
                    z = rand.nextInt(16) + 8;
                    BlockPos pos = blockPos.add(x, y, z);
                    if (treeGen.generate(world, rand, pos)) {
                        treeGen.generateSaplings(world, rand, pos);
                    }
                }
            }
        }
        if (decorator.generateFalls) {
            if (BiomeDictionary.hasType(biome, Type.WATER)) {
                if (TerrainGen.decorate(world, rand, blockPos, Decorate.EventType.LAKE_WATER)) {
                    for (int i = 0; i < 150; ++i) {
                        x = rand.nextInt(16) + 8;
                        y = rand.nextInt(rand.nextInt(worldHeight - 16) + 10);
                        z = rand.nextInt(16) + 8;
                        liquidWaterGen.generate(world, rand, blockPos.add(x, y, z));
                    }
                }
            } else {
                if (TerrainGen.decorate(world, rand, blockPos, Decorate.EventType.LAKE_WATER)) {
                    for (int i = 0; i < 100; ++i) {
                        x = rand.nextInt(16) + 8;
                        y = rand.nextInt(rand.nextInt(worldHeight - 16) + 10);
                        z = rand.nextInt(16) + 8;
                        liquidWaterGen.generate(world, rand, blockPos.add(x, y, z));
                    }
                }
                if (TerrainGen.decorate(world, rand, blockPos, Decorate.EventType.LAKE_LAVA)) {
                    for (int i = 0; i < 20; ++i) {
                        x = rand.nextInt(16) + 8;
                        y = rand.nextInt(worldHeight / 2);
                        z = rand.nextInt(16) + 8;
                        liquidLavaGen.generate(world, rand, blockPos.add(x, y, z));
                    }
                }
            }
        }
    }
    MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Post(world, rand, blockPos));
    ForgeEventFactory.onChunkPopulate(false, this, world, rand, chunkX, chunkZ, false);
    BlockFalling.fallInstantly = false;
}
Also used : OreGenEvent(net.minecraftforge.event.terraingen.OreGenEvent) WorldGenTreesPerverted(cavern.world.gen.WorldGenTreesPerverted) BiomeDecorator(net.minecraft.world.biome.BiomeDecorator) Biome(net.minecraft.world.biome.Biome) WorldGenAbstractTree(net.minecraft.world.gen.feature.WorldGenAbstractTree) BlockPos(net.minecraft.util.math.BlockPos) WorldGenSpruceTreePerverted(cavern.world.gen.WorldGenSpruceTreePerverted) DecorateBiomeEvent(net.minecraftforge.event.terraingen.DecorateBiomeEvent) WorldGenBirchTreePerverted(cavern.world.gen.WorldGenBirchTreePerverted)

Example 2 with WorldGenBirchTreePerverted

use of cavern.world.gen.WorldGenBirchTreePerverted in project Cavern2 by kegare.

the class BlockSaplingPerverted method generateTree.

@Override
public void generateTree(World world, BlockPos pos, IBlockState state, Random rand) {
    if (!TerrainGen.saplingGrowTree(world, rand, pos)) {
        return;
    }
    WorldGenerator treeGen;
    switch(state.getValue(TYPE)) {
        case SPRUCE:
            treeGen = new WorldGenSpruceTreePerverted(true);
            break;
        case BIRCH:
            treeGen = new WorldGenBirchTreePerverted(true, false);
            break;
        case JUNGLE:
            treeGen = new WorldGenTreesPerverted(true, 3 + rand.nextInt(6), BlockPlanks.EnumType.JUNGLE, false);
            break;
        default:
            treeGen = new WorldGenTreesPerverted(true, 3, BlockPlanks.EnumType.OAK, false);
            break;
    }
    world.setBlockState(pos, Blocks.AIR.getDefaultState(), 4);
    if (!treeGen.generate(world, rand, pos)) {
        world.setBlockState(pos, state, 4);
    }
}
Also used : WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator) WorldGenTreesPerverted(cavern.world.gen.WorldGenTreesPerverted) WorldGenSpruceTreePerverted(cavern.world.gen.WorldGenSpruceTreePerverted) WorldGenBirchTreePerverted(cavern.world.gen.WorldGenBirchTreePerverted)

Aggregations

WorldGenBirchTreePerverted (cavern.world.gen.WorldGenBirchTreePerverted)2 WorldGenSpruceTreePerverted (cavern.world.gen.WorldGenSpruceTreePerverted)2 WorldGenTreesPerverted (cavern.world.gen.WorldGenTreesPerverted)2 BlockPos (net.minecraft.util.math.BlockPos)1 Biome (net.minecraft.world.biome.Biome)1 BiomeDecorator (net.minecraft.world.biome.BiomeDecorator)1 WorldGenAbstractTree (net.minecraft.world.gen.feature.WorldGenAbstractTree)1 WorldGenerator (net.minecraft.world.gen.feature.WorldGenerator)1 DecorateBiomeEvent (net.minecraftforge.event.terraingen.DecorateBiomeEvent)1 OreGenEvent (net.minecraftforge.event.terraingen.OreGenEvent)1