Search in sources :

Example 21 with WorldGenerator

use of net.minecraft.world.gen.feature.WorldGenerator in project Realistic-Terrain-Generation by Team-RTG.

the class DecoReed method generate.

@Override
public void generate(IRealisticBiome biome, RTGWorld rtgWorld, Random rand, int worldX, int worldZ, float strength, float river, boolean hasPlacedVillageBlocks) {
    if (this.allowed) {
        if (TerrainGen.decorate(rtgWorld.world, rand, new BlockPos(worldX, 0, worldZ), REED)) {
            WorldGenerator worldGenerator = new WorldGenReed();
            this.setLoops((this.strengthFactor > 0f) ? (int) (this.strengthFactor * strength) : this.loops);
            for (int i = 0; i < this.loops; i++) {
                int intX = worldX + rand.nextInt(16) + 8;
                int intY = rand.nextInt(this.maxY);
                int intZ = worldZ + rand.nextInt(16) + 8;
                if (intY <= this.maxY) {
                    worldGenerator.generate(rtgWorld.world, rand, new BlockPos(intX, intY, intZ));
                }
            }
        }
    }
}
Also used : WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator) BlockPos(net.minecraft.util.math.BlockPos) WorldGenReed(net.minecraft.world.gen.feature.WorldGenReed)

Example 22 with WorldGenerator

use of net.minecraft.world.gen.feature.WorldGenerator in project Realistic-Terrain-Generation by Team-RTG.

the class DecoFlowersRTG method generate.

@Override
public void generate(IRealisticBiome biome, RTGWorld rtgWorld, Random rand, int worldX, int worldZ, float strength, float river, boolean hasPlacedVillageBlocks) {
    if (this.allowed) {
        if (TerrainGen.decorate(rtgWorld.world, rand, new BlockPos(worldX, 0, worldZ), FLOWERS)) {
            WorldGenerator worldGenerator = new WorldGenFlowersRTG(this.flowers);
            this.setLoops((this.strengthFactor > 0f) ? (int) (this.strengthFactor * strength) : this.loops);
            for (int i = 0; i < this.loops * 16; i++) {
                // + 8;
                int intX = worldX + rand.nextInt(16);
                // + 8;
                int intZ = worldZ + rand.nextInt(16);
                int intY;
                switch(this.heightType) {
                    case NEXT_INT:
                        intY = RandomUtil.getRandomInt(rand, this.minY, this.maxY);
                        break;
                    case GET_HEIGHT_VALUE:
                        intY = rtgWorld.world.getHeight(new BlockPos(intX, 0, intZ)).getY();
                        break;
                    default:
                        intY = rand.nextInt(this.maxY);
                        break;
                }
                if (this.notEqualsZeroChance > 1) {
                    if (rand.nextInt(this.notEqualsZeroChance) != 0) {
                        worldGenerator.generate(rtgWorld.world, rand, new BlockPos(intX, intY, intZ));
                    }
                } else {
                    if (rand.nextInt(this.chance) == 0) {
                        worldGenerator.generate(rtgWorld.world, rand, new BlockPos(intX, intY, intZ));
                    }
                }
            }
        }
    }
}
Also used : WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator) BlockPos(net.minecraft.util.math.BlockPos) WorldGenFlowersRTG(rtg.api.world.gen.feature.WorldGenFlowersRTG)

Example 23 with WorldGenerator

use of net.minecraft.world.gen.feature.WorldGenerator in project Realistic-Terrain-Generation by Team-RTG.

the class DecoBoulder method generate.

@Override
public void generate(IRealisticBiome biome, RTGWorld rtgWorld, Random rand, int worldX, int worldZ, float strength, float river, boolean hasPlacedVillageBlocks) {
    if (this.allowed) {
        WorldUtil worldUtil = new WorldUtil(rtgWorld.world);
        WorldGenerator worldGenerator = new WorldGenBlob(boulderBlock, 0, rand, this.water, validGroundBlocks);
        for (int l1 = 0; l1 < this.strengthFactor * strength; ++l1) {
            // + 8;
            int i1 = worldX + rand.nextInt(16);
            // + 8;
            int j1 = worldZ + rand.nextInt(16);
            int k1;
            switch(this.heightType) {
                case NEXT_INT:
                    k1 = RandomUtil.getRandomInt(rand, this.minY, this.maxY);
                    break;
                case GET_HEIGHT_VALUE:
                    k1 = rtgWorld.world.getHeight(new BlockPos(i1, 0, j1)).getY();
                    break;
                default:
                    k1 = rtgWorld.world.getHeight(new BlockPos(i1, 0, j1)).getY();
                    break;
            }
            if (k1 >= this.minY && k1 <= this.maxY && rand.nextInt(this.chance) == 0) {
                // If we're in a village, check to make sure the boulder has extra room to grow to avoid corrupting the village.
                if (hasPlacedVillageBlocks) {
                    if (!worldUtil.isSurroundedByBlock(Blocks.AIR.getDefaultState(), 2, WorldUtil.SurroundCheckType.CARDINAL, rand, i1, k1, j1)) {
                        return;
                    }
                }
                worldGenerator.generate(rtgWorld.world, rand, new BlockPos(i1, k1, j1));
            }
        }
    }
}
Also used : WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator) WorldGenBlob(rtg.api.world.gen.feature.WorldGenBlob) BlockPos(net.minecraft.util.math.BlockPos) WorldUtil(rtg.api.util.WorldUtil)

Example 24 with WorldGenerator

use of net.minecraft.world.gen.feature.WorldGenerator in project Realistic-Terrain-Generation by Team-RTG.

the class DecoDeadBush method generate.

@Override
public void generate(IRealisticBiome biome, RTGWorld rtgWorld, Random rand, int worldX, int worldZ, float strength, float river, boolean hasPlacedVillageBlocks) {
    if (this.allowed) {
        if (TerrainGen.decorate(rtgWorld.world, rand, new BlockPos(worldX, 0, worldZ), DEAD_BUSH)) {
            WorldGenerator worldGenerator = new WorldGenDeadBush();
            int loopCount = this.loops;
            loopCount = (this.strengthFactor > 0f) ? (int) (this.strengthFactor * strength) : loopCount;
            for (int i = 0; i < loopCount; i++) {
                // + 8;
                int intX = worldX + rand.nextInt(16);
                int intY = rand.nextInt(this.maxY);
                // + 8;
                int intZ = worldZ + rand.nextInt(16);
                if (intY <= this.maxY && rand.nextInt(this.chance) == 0) {
                    worldGenerator.generate(rtgWorld.world, rand, new BlockPos(intX, intY, intZ));
                }
            }
        }
    }
}
Also used : WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator) WorldGenDeadBush(net.minecraft.world.gen.feature.WorldGenDeadBush) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

WorldGenerator (net.minecraft.world.gen.feature.WorldGenerator)24 BlockPos (net.minecraft.util.math.BlockPos)22 WorldUtil (rtg.api.util.WorldUtil)7 WorldGenGrass (rtg.api.world.gen.feature.WorldGenGrass)3 IBlockState (net.minecraft.block.state.IBlockState)2 WorldGenBigTrees (betterwithaddons.world.WorldGenBigTrees)1 MapMaker (com.google.common.collect.MapMaker)1 java.util (java.util)1 Predicate (java.util.function.Predicate)1 Nullable (javax.annotation.Nullable)1 RailcraftConfig (mods.railcraft.common.core.RailcraftConfig)1 Metal (mods.railcraft.common.items.Metal)1 NoiseGenSimplex (mods.railcraft.common.worldgen.NoiseGen.NoiseGenSimplex)1 Block (net.minecraft.block.Block)1 World (net.minecraft.world.World)1 Biome (net.minecraft.world.biome.Biome)1 WorldGenBush (net.minecraft.world.gen.feature.WorldGenBush)1 WorldGenDeadBush (net.minecraft.world.gen.feature.WorldGenDeadBush)1 WorldGenDesertWells (net.minecraft.world.gen.feature.WorldGenDesertWells)1 WorldGenMinable (net.minecraft.world.gen.feature.WorldGenMinable)1