Search in sources :

Example 1 with WorldGenPond

use of rtg.api.world.gen.feature.WorldGenPond in project Realistic-Terrain-Generation by Team-RTG.

the class BiomeDecoratorRTG method rPopulatePreDecorate.

public void rPopulatePreDecorate(IChunkGenerator ichunkgenerator, World worldObj, Random rand, int chunkX, int chunkZ, boolean villageBuilding) {
    int worldX = chunkX * 16;
    int worldZ = chunkZ * 16;
    boolean gen = true;
    gen = TerrainGen.populate(ichunkgenerator, worldObj, rand, chunkX, chunkZ, villageBuilding, PopulateChunkEvent.Populate.EventType.LAKE);
    // Underground water lakes.
    if (rtgConfig.ENABLE_WATER_UNDERGROUND_LAKES.get()) {
        if (gen && (rtgConfig.WATER_UNDERGROUND_LAKE_CHANCE.get() > 0) && (rbb.waterUndergroundLakeChance() > 0)) {
            // + 8;
            int i2 = worldX + rand.nextInt(16);
            int l4 = RandomUtil.getRandomInt(rand, 1, 50);
            // + 8;
            int i8 = worldZ + rand.nextInt(16);
            if (rand.nextInt(rtgConfig.WATER_UNDERGROUND_LAKE_CHANCE.get()) == 0 && rand.nextInt(rbb.waterUndergroundLakeChance()) == 0) {
                (new WorldGenLakes(Blocks.WATER)).generate(worldObj, rand, new BlockPos(new BlockPos(i2, l4, i8)));
            }
        }
    }
    // Surface water lakes.
    if (rtgConfig.ENABLE_WATER_SURFACE_LAKES.get() && !villageBuilding) {
        if (gen && (rtgConfig.WATER_SURFACE_LAKE_CHANCE.get() > 0) && (rbb.waterSurfaceLakeChance() > 0)) {
            // + 8;
            int i2 = worldX + rand.nextInt(16);
            // + 8;
            int i8 = worldZ + rand.nextInt(16);
            int l4 = worldObj.getHeight(new BlockPos(i2, 0, i8)).getY();
            //Surface lakes.
            if (rand.nextInt(rtgConfig.WATER_SURFACE_LAKE_CHANCE.get()) == 0 && rand.nextInt(rbb.waterSurfaceLakeChance()) == 0) {
                if (l4 > 63) {
                    (new WorldGenPond(Blocks.WATER.getDefaultState())).generate(worldObj, rand, new BlockPos(i2, l4, i8));
                }
            }
        }
    }
    gen = TerrainGen.populate(ichunkgenerator, worldObj, rand, chunkX, chunkZ, villageBuilding, PopulateChunkEvent.Populate.EventType.LAVA);
    // Underground lava lakes.
    if (rtgConfig.ENABLE_LAVA_UNDERGROUND_LAKES.get()) {
        if (gen && (rtgConfig.LAVA_UNDERGROUND_LAKE_CHANCE.get() > 0) && (rbb.lavaUndergroundLakeChance() > 0)) {
            // + 8;
            int i2 = worldX + rand.nextInt(16);
            int l4 = RandomUtil.getRandomInt(rand, 1, 50);
            // + 8;
            int i8 = worldZ + rand.nextInt(16);
            if (rand.nextInt(rtgConfig.LAVA_UNDERGROUND_LAKE_CHANCE.get()) == 0 && rand.nextInt(rbb.lavaUndergroundLakeChance()) == 0) {
                (new WorldGenLakes(Blocks.LAVA)).generate(worldObj, rand, new BlockPos(i2, l4, i8));
            }
        }
    }
    // Surface lava lakes.
    if (rtgConfig.ENABLE_LAVA_SURFACE_LAKES.get() && !villageBuilding) {
        if (gen && (rtgConfig.LAVA_SURFACE_LAKE_CHANCE.get() > 0) && (rbb.lavaSurfaceLakeChance() > 0)) {
            // + 8;
            int i2 = worldX + rand.nextInt(16);
            // + 8;
            int i8 = worldZ + rand.nextInt(16);
            int l4 = worldObj.getHeight(new BlockPos(i2, 0, i8)).getY();
            //Surface lakes.
            if (rand.nextInt(rtgConfig.LAVA_SURFACE_LAKE_CHANCE.get()) == 0 && rand.nextInt(rbb.lavaSurfaceLakeChance()) == 0) {
                if (l4 > 63) {
                    (new WorldGenPond(Blocks.LAVA.getDefaultState())).generate(worldObj, rand, new BlockPos(i2, l4, i8));
                }
            }
        }
    }
    if (rtgConfig.GENERATE_DUNGEONS.get()) {
        gen = TerrainGen.populate(ichunkgenerator, worldObj, rand, chunkX, chunkZ, villageBuilding, PopulateChunkEvent.Populate.EventType.DUNGEON);
        if (gen) {
            for (int k1 = 0; k1 < rtgConfig.DUNGEON_FREQUENCY.get(); k1++) {
                // + 8;
                int j5 = worldX + rand.nextInt(16);
                int k8 = rand.nextInt(128);
                // + 8;
                int j11 = worldZ + rand.nextInt(16);
                (new WorldGenDungeons()).generate(worldObj, rand, new BlockPos(j5, k8, j11));
            }
        }
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) WorldGenPond(rtg.api.world.gen.feature.WorldGenPond)

Example 2 with WorldGenPond

use of rtg.api.world.gen.feature.WorldGenPond in project Realistic-Terrain-Generation by Team-RTG.

the class RealisticBiomeBYGDeadSea method initDecos.

@Override
public void initDecos() {
    WorldGenPond pond = new WorldGenPond(Blocks.WATER.getDefaultState());
    DecoWorldGen decoPond = new DecoWorldGen(pond);
    decoPond.setChance(1);
    decoPond.setMinY(62);
    decoPond.setMaxY(66);
    decoPond.setEventType(DecorateBiomeEvent.Decorate.EventType.LAKE_WATER);
    this.addDeco(decoPond);
}
Also used : WorldGenPond(rtg.api.world.gen.feature.WorldGenPond) DecoWorldGen(rtg.api.world.deco.DecoWorldGen)

Example 3 with WorldGenPond

use of rtg.api.world.gen.feature.WorldGenPond in project Realistic-Terrain-Generation by Team-RTG.

the class ChunkGeneratorRTG method populate.

// false-positive on `hasVillage`, IDEA is probably not looking deep enough.
@SuppressWarnings("ConstantConditions")
@Override
public void populate(int chunkX, int chunkZ) {
    BlockFalling.fallInstantly = true;
    final BiomeProvider biomeProvider = this.world.getBiomeProvider();
    final ChunkPos chunkPos = new ChunkPos(chunkX, chunkZ);
    final BlockPos blockPos = new BlockPos(chunkX * 16, 0, chunkZ * 16);
    final BlockPos offsetpos = blockPos.add(8, 0, 8);
    IRealisticBiome biome = RTGAPI.getRTGBiome(biomeProvider.getBiome(blockPos.add(16, 0, 16)));
    this.rand.setSeed(rtgWorld.getChunkSeed(chunkX, chunkZ));
    boolean hasVillage = false;
    ForgeEventFactory.onChunkPopulate(true, this, this.world, this.rand, chunkX, chunkZ, false);
    if (this.mapFeaturesEnabled) {
        if (settings.useMineShafts) {
            mineshaftGenerator.generateStructure(world, rand, chunkPos);
        }
        if (settings.useStrongholds) {
            strongholdGenerator.generateStructure(world, rand, chunkPos);
        }
        if (settings.useVillages) {
            hasVillage = villageGenerator.generateStructure(world, rand, chunkPos);
        }
        if (settings.useTemples) {
            scatteredFeatureGenerator.generateStructure(world, rand, chunkPos);
        }
        if (settings.useMonuments) {
            oceanMonumentGenerator.generateStructure(this.world, rand, chunkPos);
        }
        if (settings.useMansions) {
            woodlandMansionGenerator.generateStructure(world, rand, chunkPos);
        }
    }
    // water lakes.
    if (settings.useWaterLakes && settings.waterLakeChance > 0 && !hasVillage) {
        final long nextchance = rand.nextLong();
        final int surfacechance = settings.getSurfaceWaterLakeChance(biome.waterLakeMult());
        final BlockPos pos = offsetpos.add(rand.nextInt(16), 0, rand.nextInt(16));
        // possibly reduced chance to generate anywhere, including on surface
        if (surfacechance > 0 && nextchance % surfacechance == 0) {
            if (TerrainGen.populate(this, world, rand, chunkX, chunkZ, hasVillage, PopulateChunkEvent.Populate.EventType.LAKE)) {
                (new WorldGenPond(Blocks.WATER.getDefaultState())).generate(world, rand, pos.up(rand.nextInt(256)));
            }
        } else // normal chance to generate underground
        if (nextchance % settings.waterLakeChance == 0) {
            if (TerrainGen.populate(this, world, rand, chunkX, chunkZ, hasVillage, PopulateChunkEvent.Populate.EventType.LAKE)) {
                // make sure that underground lakes are sufficiently underground
                (new WorldGenLakes(Blocks.WATER)).generate(world, rand, pos.up(rand.nextInt(50) + 4));
            }
        }
    }
    // lava lakes.
    if (settings.useLavaLakes && settings.lavaLakeChance > 0 && !hasVillage) {
        final long nextchance = rand.nextLong();
        final int surfacechance = settings.getSurfaceLavaLakeChance(biome.lavaLakeMult());
        final BlockPos pos = offsetpos.add(rand.nextInt(16), 0, rand.nextInt(16));
        // possibly reduced chance to generate anywhere, including on surface
        if (surfacechance > 0 && nextchance % surfacechance == 0) {
            if (TerrainGen.populate(this, world, rand, chunkX, chunkZ, hasVillage, PopulateChunkEvent.Populate.EventType.LAVA)) {
                (new WorldGenPond(Blocks.LAVA.getDefaultState())).generate(world, rand, pos.up(rand.nextInt(256)));
            }
        } else // normal chance to generate underground
        if (nextchance % settings.lavaLakeChance == 0) {
            if (TerrainGen.populate(this, world, rand, chunkX, chunkZ, hasVillage, PopulateChunkEvent.Populate.EventType.LAVA)) {
                // make sure that underground lakes are sufficiently underground
                (new WorldGenLakes(Blocks.LAVA)).generate(world, rand, pos.up(rand.nextInt(50) + 4));
            }
        }
    }
    if (settings.useDungeons) {
        if (TerrainGen.populate(this, world, rand, chunkX, chunkZ, hasVillage, PopulateChunkEvent.Populate.EventType.DUNGEON)) {
            for (int i = 0; i < settings.dungeonChance; i++) {
                (new WorldGenDungeons()).generate(world, rand, offsetpos.add(rand.nextInt(16), rand.nextInt(256), rand.nextInt(16)));
            }
        }
    }
    float river = -TerrainBase.getRiverStrength(blockPos.add(16, 0, 16), rtgWorld);
    if (RTG.decorationsDisable() || biome.getConfig().DISABLE_RTG_DECORATIONS.get()) {
        if (river > 0.9f) {
            biome.getRiverBiome().baseBiome().decorate(this.world, this.rand, blockPos);
        } else {
            biome.baseBiome().decorate(this.world, this.rand, blockPos);
        }
    } else {
        if (river > 0.9f) {
            biome.getRiverBiome().rDecorate(this.rtgWorld, this.rand, chunkPos, river, hasVillage);
        } else {
            biome.rDecorate(this.rtgWorld, this.rand, chunkPos, river, hasVillage);
        }
    }
    if (TerrainGen.populate(this, this.world, this.rand, chunkX, chunkZ, hasVillage, PopulateChunkEvent.Populate.EventType.ANIMALS)) {
        WorldEntitySpawner.performWorldGenSpawning(this.world, biome.baseBiome(), blockPos.getX() + 8, blockPos.getZ() + 8, 16, 16, this.rand);
    }
    if (TerrainGen.populate(this, this.world, this.rand, chunkX, chunkZ, hasVillage, PopulateChunkEvent.Populate.EventType.ICE)) {
        for (int x = 0; x < 16; ++x) {
            for (int z = 0; z < 16; ++z) {
                // Ice.
                final BlockPos freezePos = world.getPrecipitationHeight(offsetpos.add(x, 0, z)).down();
                if (this.world.canBlockFreezeWater(freezePos)) {
                    this.world.setBlockState(freezePos, Blocks.ICE.getDefaultState(), 2);
                }
                // Snow layers.
                final BlockPos surfacePos = world.getTopSolidOrLiquidBlock(offsetpos.add(x, 0, z));
                if (settings.useSnowLayers) {
                    // snow layers on any leaves, or the surface block, if the temperature permits it.
                    for (BlockPos checkPos = surfacePos.up(32); checkPos.getY() >= surfacePos.getY(); checkPos = checkPos.down()) {
                        if (world.getBlockState(checkPos).getMaterial() == Material.AIR) {
                            final float temp = biomeProvider.getBiome(surfacePos).getTemperature(checkPos);
                            if (temp <= settings.getClampedSnowLayerTemp()) {
                                if (Blocks.SNOW_LAYER.canPlaceBlockAt(world, checkPos)) {
                                    this.world.setBlockState(checkPos, Blocks.SNOW_LAYER.getDefaultState(), 2);
                                    // we already know the next check block is not air, so skip ahead.
                                    checkPos = checkPos.down();
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    ForgeEventFactory.onChunkPopulate(false, this, this.world, this.rand, chunkX, chunkZ, hasVillage);
    BlockFalling.fallInstantly = false;
}
Also used : BiomeProvider(net.minecraft.world.biome.BiomeProvider) WorldGenLakes(net.minecraft.world.gen.feature.WorldGenLakes) ChunkPos(net.minecraft.util.math.ChunkPos) MutableBlockPos(net.minecraft.util.math.BlockPos.MutableBlockPos) BlockPos(net.minecraft.util.math.BlockPos) WorldGenPond(rtg.api.world.gen.feature.WorldGenPond) WorldGenDungeons(net.minecraft.world.gen.feature.WorldGenDungeons) IRealisticBiome(rtg.api.world.biome.IRealisticBiome)

Aggregations

WorldGenPond (rtg.api.world.gen.feature.WorldGenPond)3 BlockPos (net.minecraft.util.math.BlockPos)2 MutableBlockPos (net.minecraft.util.math.BlockPos.MutableBlockPos)1 ChunkPos (net.minecraft.util.math.ChunkPos)1 BiomeProvider (net.minecraft.world.biome.BiomeProvider)1 WorldGenDungeons (net.minecraft.world.gen.feature.WorldGenDungeons)1 WorldGenLakes (net.minecraft.world.gen.feature.WorldGenLakes)1 IRealisticBiome (rtg.api.world.biome.IRealisticBiome)1 DecoWorldGen (rtg.api.world.deco.DecoWorldGen)1