Search in sources :

Example 1 with BiomeProvider

use of net.minecraft.world.biome.BiomeProvider in project Realistic-Terrain-Generation by Team-RTG.

the class WorldTypeRTG method getBiomeProvider.

@Override
@Nonnull
public BiomeProvider getBiomeProvider(@Nonnull World world) {
    if (DimensionManagerRTG.isValidDimension(world.provider.getDimension())) {
        if (biomeProvider == null) {
            biomeProvider = new BiomeProviderRTG(world, this);
            RTG.instance.runOnNextServerCloseOnly(clearProvider(biomeProvider));
        }
        Logger.debug("WorldTypeRTG#getBiomeProvider() returning BiomeProviderRTG");
        return biomeProvider;
    } else {
        Logger.debug("WorldTypeRTG#getBiomeProvider() returning vanilla BiomeProvider");
        return new BiomeProvider(world.getWorldInfo());
    }
}
Also used : BiomeProvider(net.minecraft.world.biome.BiomeProvider) BiomeProviderRTG(rtg.world.biome.BiomeProviderRTG) Nonnull(javax.annotation.Nonnull)

Example 2 with BiomeProvider

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

the class MixinWorldServer method createWorldGenerator.

@Override
public SpongeWorldGenerator createWorldGenerator(String settings) {
    final WorldServer worldServer = (WorldServer) (Object) this;
    final WorldType worldType = worldServer.getWorldType();
    final IChunkGenerator chunkGenerator;
    final BiomeProvider biomeProvider;
    if (worldType instanceof SpongeWorldType) {
        chunkGenerator = ((SpongeWorldType) worldType).getChunkGenerator(worldServer, settings);
        biomeProvider = ((SpongeWorldType) worldType).getBiomeProvider(worldServer);
    } else {
        final IChunkGenerator currentGenerator = this.getChunkProvider().chunkGenerator;
        if (currentGenerator != null) {
            chunkGenerator = currentGenerator;
        } else {
            final WorldProvider worldProvider = worldServer.provider;
            ((IMixinWorldProvider) worldProvider).setGeneratorSettings(settings);
            chunkGenerator = worldProvider.createChunkGenerator();
        }
        biomeProvider = worldServer.provider.biomeProvider;
    }
    return new SpongeWorldGenerator(worldServer, (BiomeGenerator) biomeProvider, SpongeGenerationPopulator.of(worldServer, chunkGenerator));
}
Also used : BiomeProvider(net.minecraft.world.biome.BiomeProvider) IMixinWorldProvider(org.spongepowered.common.interfaces.world.IMixinWorldProvider) SpongeWorldType(org.spongepowered.common.world.type.SpongeWorldType) WorldType(net.minecraft.world.WorldType) IChunkGenerator(net.minecraft.world.gen.IChunkGenerator) IMixinWorldProvider(org.spongepowered.common.interfaces.world.IMixinWorldProvider) WorldProvider(net.minecraft.world.WorldProvider) WorldServer(net.minecraft.world.WorldServer) IMixinWorldServer(org.spongepowered.common.interfaces.world.IMixinWorldServer) SpongeWorldGenerator(org.spongepowered.common.world.gen.SpongeWorldGenerator) SpongeWorldType(org.spongepowered.common.world.type.SpongeWorldType)

Example 3 with BiomeProvider

use of net.minecraft.world.biome.BiomeProvider in project Cavern2 by kegare.

the class WorldProviderCrownCliffs method init.

@Override
protected void init() {
    hasSkyLight = true;
    biomeProvider = new BiomeProvider(world.getWorldInfo());
    seedData = world instanceof WorldServer ? new CustomSeedData(world.getWorldInfo().getDimensionData(getDimension())) : new CustomSeedData();
}
Also used : BiomeProvider(net.minecraft.world.biome.BiomeProvider) CustomSeedData(cavern.world.CustomSeedData) WorldServer(net.minecraft.world.WorldServer)

Example 4 with BiomeProvider

use of net.minecraft.world.biome.BiomeProvider in project BiomesOPlenty by Glitchfiend.

the class BiomeUtils method spiralOutwardsLookingForBiome.

// sample points in an archimedean spiral starting from startX,startY each one sampleSpace apart
// stop when the specified biome is found (and return the position it was found at) or when we reach maxDistance (and return null)
public static BlockPos spiralOutwardsLookingForBiome(World world, Biome biomeToFind, double startX, double startZ, int maxDist, int sampleSpace) {
    if (maxDist <= 0 || sampleSpace <= 0) {
        throw new IllegalArgumentException("maxDist and sampleSpace must be positive");
    }
    BiomeProvider chunkManager = world.getBiomeProvider();
    double a = sampleSpace / Math.sqrt(Math.PI);
    double b = 2 * Math.sqrt(Math.PI);
    double x = 0;
    double z = 0;
    double dist = 0;
    int n = 0;
    String biomeName = FMLCommonHandler.instance().getSide() == Side.CLIENT ? biomeToFind.getBiomeName() : "biome";
    for (n = 0; dist < maxDist; ++n) {
        double rootN = Math.sqrt(n);
        dist = a * rootN;
        x = startX + (dist * Math.sin(b * rootN));
        z = startZ + (dist * Math.cos(b * rootN));
        // chunkManager.genBiomes is the first layer returned from initializeAllBiomeGenerators()
        // chunkManager.biomeIndexLayer is the second layer returned from initializeAllBiomeGenerators(), it's zoomed twice from genBiomes (>> 2) this one is actual size
        // chunkManager.getBiomeGenAt uses biomeIndexLayer to get the biome
        Biome[] biomesAtSample = chunkManager.getBiomes(null, (int) x, (int) z, 1, 1, false);
        if (biomesAtSample[0] == biomeToFind) {
            BiomesOPlenty.logger.info("Found " + biomeName + " after " + n + " samples, spaced " + sampleSpace + " blocks apart at (" + ((int) x) + "," + ((int) z) + ") distance " + ((int) dist));
            return new BlockPos((int) x, 0, (int) z);
        }
    }
    BiomesOPlenty.logger.info("Failed to find " + biomeName + " gave up after " + n + " samples, spaced " + sampleSpace + " blocks apart distance " + ((int) dist));
    return null;
}
Also used : BiomeProvider(net.minecraft.world.biome.BiomeProvider) Biome(net.minecraft.world.biome.Biome) BlockPos(net.minecraft.util.math.BlockPos)

Example 5 with BiomeProvider

use of net.minecraft.world.biome.BiomeProvider in project Realistic-Terrain-Generation by Team-RTG.

the class ChunkGeneratorRTG method generateChunk.

@Override
public Chunk generateChunk(final int cx, final int cz) {
    final ChunkPos chunkPos = new ChunkPos(cx, cz);
    final BlockPos blockPos = new BlockPos(cx * 16, 0, cz * 16);
    final BiomeProvider biomeProvider = this.world.getBiomeProvider();
    this.rand.setSeed(cx * 341873128712L + cz * 132897987541L);
    final ChunkPrimer primer = new ChunkPrimer();
    final ChunkLandscape landscape = getLandscape(biomeProvider, chunkPos);
    generateTerrain(primer, landscape.noise);
    // get standard biome Data
    for (int i = 0; i < 256; i++) {
        this.baseBiomesList[i] = landscape.biome[i].baseBiome();
    }
    ISimplexData2D jitterData = SimplexData2D.newDisk();
    IRealisticBiome[] jitteredBiomes = new IRealisticBiome[256];
    IRealisticBiome jitterbiome, actualbiome;
    for (int i = 0; i < 16; i++) {
        for (int j = 0; j < 16; j++) {
            int x = blockPos.getX() + i;
            int z = blockPos.getZ() + j;
            this.rtgWorld.simplexInstance(0).multiEval2D(x, z, jitterData);
            int pX = (int) Math.round(x + jitterData.getDeltaX() * RTGConfig.surfaceBlendRadius());
            int pZ = (int) Math.round(z + jitterData.getDeltaY() * RTGConfig.surfaceBlendRadius());
            actualbiome = landscape.biome[(x & 15) * 16 + (z & 15)];
            jitterbiome = landscape.biome[(pX & 15) * 16 + (pZ & 15)];
            jitteredBiomes[i * 16 + j] = (actualbiome.getConfig().SURFACE_BLEED_IN.get() && jitterbiome.getConfig().SURFACE_BLEED_OUT.get()) ? jitterbiome : actualbiome;
        }
    }
    replaceBiomeBlocks(cx, cz, primer, jitteredBiomes, this.baseBiomesList, landscape.noise);
    if (this.settings.useCaves) {
        this.caveGenerator.generate(this.world, cx, cz, primer);
    }
    if (this.settings.useRavines) {
        this.ravineGenerator.generate(this.world, cx, cz, primer);
    }
    if (this.mapFeaturesEnabled) {
        if (settings.useMineShafts) {
            this.mineshaftGenerator.generate(this.world, cx, cz, primer);
        }
        if (settings.useStrongholds) {
            this.strongholdGenerator.generate(this.world, cx, cz, primer);
        }
        if (settings.useVillages) {
            this.villageGenerator.generate(this.world, cx, cz, primer);
        }
        if (settings.useTemples) {
            this.scatteredFeatureGenerator.generate(this.world, cx, cz, primer);
        }
        if (settings.useMonuments) {
            this.oceanMonumentGenerator.generate(this.world, cx, cz, primer);
        }
        if (settings.useMansions) {
            this.woodlandMansionGenerator.generate(this.world, cx, cz, primer);
        }
    }
    // store in the in process pile
    Chunk chunk = new Chunk(this.world, primer, cx, cz);
    byte[] abyte1 = chunk.getBiomeArray();
    for (int i = 0; i < abyte1.length; ++i) {
        // Biomes are y-first and terrain x-first
        byte b = (byte) Biome.getIdForBiome(this.baseBiomesList[this.xyinverted[i]]);
        abyte1[i] = b;
    }
    chunk.setBiomeArray(abyte1);
    chunk.generateSkylightMap();
    return chunk;
}
Also used : BiomeProvider(net.minecraft.world.biome.BiomeProvider) ISimplexData2D(rtg.api.util.noise.ISimplexData2D) ChunkPos(net.minecraft.util.math.ChunkPos) MutableBlockPos(net.minecraft.util.math.BlockPos.MutableBlockPos) BlockPos(net.minecraft.util.math.BlockPos) IRealisticBiome(rtg.api.world.biome.IRealisticBiome) Chunk(net.minecraft.world.chunk.Chunk) ChunkPrimer(net.minecraft.world.chunk.ChunkPrimer)

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