Search in sources :

Example 6 with RealisticBiomeBase

use of rtg.world.biome.realistic.RealisticBiomeBase in project Realistic-Terrain-Generation by Team-RTG.

the class BiomeAnalyzer method setupBeachesForBiomes.

private void setupBeachesForBiomes() {
    preferredBeach = new int[256];
    for (int i = 0; i < preferredBeach.length; i++) {
        // We need to work with the realistic biome, so let's try to get it from the base biome, aborting if necessary.
        Biome biome = Biome.getBiome(i);
        if (biome == null)
            continue;
        RealisticBiomeBase realisticBiome = RealisticBiomeBase.getBiome(i);
        if (realisticBiome == null)
            continue;
        preferredBeach[i] = Biome.getIdForBiome(realisticBiome.beachBiome);
        // If stone beaches aren't allowed in this biome, then determine the best beach to use based on the biome's temperature.
        if (realisticBiome.disallowStoneBeaches) {
            if (Biome.getIdForBiome(realisticBiome.beachBiome) == Biome.getIdForBiome(Biomes.STONE_BEACH)) {
                preferredBeach[i] = Biome.getIdForBiome((biome.getTemperature() <= 0.05f) ? Biomes.COLD_BEACH : Biomes.BEACH);
            }
        }
        // If beaches aren't allowed in this biome, then use this biome as the beach.
        if (realisticBiome.disallowAllBeaches) {
            preferredBeach[i] = i;
        }
    }
}
Also used : Biome(net.minecraft.world.biome.Biome) RealisticBiomeBase(rtg.world.biome.realistic.RealisticBiomeBase)

Example 7 with RealisticBiomeBase

use of rtg.world.biome.realistic.RealisticBiomeBase in project Realistic-Terrain-Generation by Team-RTG.

the class LandscapeGenerator method getNewerNoise.

private synchronized void getNewerNoise(IBiomeProviderRTG cmr, int cx, int cz, ChunkLandscape landscape) {
    // get area biome map
    TimeTracker.manager.start("RTG Noise");
    TimeTracker.manager.start("Biome Layout");
    for (int i = -sampleSize; i < sampleSize + 5; i++) {
        for (int j = -sampleSize; j < sampleSize + 5; j++) {
            biomeData[(i + sampleSize) * sampleArraySize + (j + sampleSize)] = Biome.getIdForBiome(cmr.getBiomeDataAt(cx + ((i * 8)), cz + ((j * 8))).baseBiome);
        }
    }
    TimeTracker.manager.stop("Biome Layout");
    float river;
    // fill the old smallRender
    for (int i = 0; i < 16; i++) {
        for (int j = 0; j < 16; j++) {
            TimeTracker.manager.start("Weighting");
            float totalWeight = 0;
            for (int mapX = 0; mapX < sampleArraySize; mapX++) {
                for (int mapZ = 0; mapZ < sampleArraySize; mapZ++) {
                    float weight = weightings[mapX * sampleArraySize + mapZ][i * 16 + j];
                    if (weight > 0) {
                        totalWeight += weight;
                        weightedBiomes[biomeData[mapX * sampleArraySize + mapZ]] += weight;
                    }
                }
            }
            // normalize biome weights
            for (int biomeIndex = 0; biomeIndex < weightedBiomes.length; biomeIndex++) {
                weightedBiomes[biomeIndex] /= totalWeight;
            }
            // combine mesa biomes
            mesaCombiner.adjust(weightedBiomes);
            landscape.noise[i * 16 + j] = 0f;
            TimeTracker.manager.stop("Weighting");
            TimeTracker.manager.start("Generating");
            river = cmr.getRiverStrength(cx + i, cz + j);
            landscape.river[i * 16 + j] = -river;
            float totalBorder = 0f;
            for (int k = 0; k < 256; k++) {
                if (weightedBiomes[k] > 0f) {
                    totalBorder += weightedBiomes[k];
                    RealisticBiomeBase realisticBiome = RealisticBiomeBase.getBiome(k);
                    // Do we need to patch the biome?
                    if (realisticBiome == null) {
                        realisticBiome = biomePatcher.getPatchedRealisticBiome("NULL biome (" + k + ") found when getting newer noise.");
                    }
                    landscape.noise[i * 16 + j] += realisticBiome.rNoise(this.rtgWorld, cx + i, cz + j, weightedBiomes[k], river + 1f) * weightedBiomes[k];
                    // 0 for the next column
                    weightedBiomes[k] = 0f;
                }
            }
            if (totalBorder < .999 || totalBorder > 1.001)
                throw new RuntimeException("" + totalBorder);
            TimeTracker.manager.stop("Generating");
        }
    }
    //fill biomes array with biomeData
    TimeTracker.manager.start("Biome Layout");
    for (int i = 0; i < 16; i++) {
        for (int j = 0; j < 16; j++) {
            landscape.biome[i * 16 + j] = cmr.getBiomeDataAt(cx + (((i - 7) * 8 + 4)), cz + (((j - 7) * 8 + 4)));
        }
    }
    TimeTracker.manager.stop("Biome Layout");
    TimeTracker.manager.stop("RTG Noise");
}
Also used : RealisticBiomeBase(rtg.world.biome.realistic.RealisticBiomeBase)

Aggregations

RealisticBiomeBase (rtg.world.biome.realistic.RealisticBiomeBase)7 Biome (net.minecraft.world.biome.Biome)2 Random (java.util.Random)1 ChunkPos (net.minecraft.util.math.ChunkPos)1 BiomeProviderRTG (rtg.world.biome.BiomeProviderRTG)1 RealisticBiomePatcher (rtg.world.biome.realistic.RealisticBiomePatcher)1