Search in sources :

Example 6 with BiomeProvider

use of net.minecraft.world.biome.BiomeProvider in project RFToolsDimensions by McJty.

the class GenericWorldProvider method createBiomeProviderInternal.

private void createBiomeProviderInternal() {
    getDimensionInformation();
    if (dimensionInformation != null) {
        ControllerType type = dimensionInformation.getControllerType();
        if (type == ControllerType.CONTROLLER_SINGLE) {
            this.biomeProvider = new BiomeProviderSingle(dimensionInformation.getBiomes().get(0));
        } else if (type == ControllerType.CONTROLLER_DEFAULT) {
            WorldInfo worldInfo = world.getWorldInfo();
            worldInfo = new WorldInfo(worldInfo) {

                @Override
                public long getSeed() {
                    return seed;
                }
            };
            this.biomeProvider = new BiomeProvider(worldInfo);
        } else {
            this.biomeProvider = new GenericBiomeProvider(world.getWorldInfo()) {

                @Override
                public DimensionInformation getDimensionInformation() {
                    // Hack to get the dimension information in the superclass.
                    return dimensionInformation;
                }
            };
        }
    } else {
        this.biomeProvider = new BiomeProvider(world.getWorldInfo());
    }
    if (dimensionInformation != null) {
        this.hasSkyLight = dimensionInformation.getTerrainType().hasSky();
        setupSkyRenderers();
    }
}
Also used : BiomeProvider(net.minecraft.world.biome.BiomeProvider) WorldInfo(net.minecraft.world.storage.WorldInfo) ControllerType(mcjty.rftoolsdim.dimensions.types.ControllerType) BiomeProviderSingle(net.minecraft.world.biome.BiomeProviderSingle)

Example 7 with BiomeProvider

use of net.minecraft.world.biome.BiomeProvider in project SpongeCommon by SpongePowered.

the class MixinChunkGeneratorOverworld method getBiomesFromGenerator.

private Biome[] getBiomesFromGenerator(int x, int z) {
    if (this.biomegen instanceof BiomeProvider) {
        return ((BiomeProvider) this.biomegen).getBiomesForGeneration(this.biomesForGeneration, x * 4 - 2, z * 4 - 2, 10, 10);
    }
    // If its not a WorldChunkManager then we have to perform a reverse of
    // the voronoi zoom biome generation layer to get a zoomed out version
    // of the biomes that the terrain generator expects. While not an exact
    // reverse of the algorithm this should be accurate 99.997% of the time
    // (based on testing).
    ObjectArrayMutableBiomeBuffer buffer = new ObjectArrayMutableBiomeBuffer(new Vector3i(x * 16 - 6, 0, z * 16 - 6), new Vector3i(37, 1, 37));
    this.biomegen.generateBiomes(buffer);
    if (this.biomesForGeneration == null || this.biomesForGeneration.length < 100) {
        this.biomesForGeneration = new Biome[100];
    }
    for (int bx = 0; bx < 40; bx += 4) {
        int absX = bx + x * 16 - 6;
        for (int bz = 0; bz < 40; bz += 4) {
            int absZ = bz + z * 16 - 6;
            Biome type = buffer.getNativeBiome(absX, 0, absZ);
            this.biomesForGeneration[(bx / 4) + (bz / 4) * 10] = type;
        }
    }
    return this.biomesForGeneration;
}
Also used : BiomeProvider(net.minecraft.world.biome.BiomeProvider) ObjectArrayMutableBiomeBuffer(org.spongepowered.common.util.gen.ObjectArrayMutableBiomeBuffer) Biome(net.minecraft.world.biome.Biome) Vector3i(com.flowpowered.math.vector.Vector3i)

Example 8 with BiomeProvider

use of net.minecraft.world.biome.BiomeProvider 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

BiomeProvider (net.minecraft.world.biome.BiomeProvider)8 BlockPos (net.minecraft.util.math.BlockPos)3 MutableBlockPos (net.minecraft.util.math.BlockPos.MutableBlockPos)2 ChunkPos (net.minecraft.util.math.ChunkPos)2 WorldServer (net.minecraft.world.WorldServer)2 Biome (net.minecraft.world.biome.Biome)2 IRealisticBiome (rtg.api.world.biome.IRealisticBiome)2 CustomSeedData (cavern.world.CustomSeedData)1 Vector3i (com.flowpowered.math.vector.Vector3i)1 Nonnull (javax.annotation.Nonnull)1 ControllerType (mcjty.rftoolsdim.dimensions.types.ControllerType)1 WorldProvider (net.minecraft.world.WorldProvider)1 WorldType (net.minecraft.world.WorldType)1 BiomeProviderSingle (net.minecraft.world.biome.BiomeProviderSingle)1 Chunk (net.minecraft.world.chunk.Chunk)1 ChunkPrimer (net.minecraft.world.chunk.ChunkPrimer)1 IChunkGenerator (net.minecraft.world.gen.IChunkGenerator)1 WorldGenDungeons (net.minecraft.world.gen.feature.WorldGenDungeons)1 WorldGenLakes (net.minecraft.world.gen.feature.WorldGenLakes)1 WorldInfo (net.minecraft.world.storage.WorldInfo)1