Search in sources :

Example 1 with RealisticBiomeBase

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

the class VolcanoGenerator method rMapVolcanoes.

public void rMapVolcanoes(ChunkPrimer primer, World world, IBiomeProviderRTG cmr, int baseX, int baseY, int chunkX, int chunkY, OpenSimplexNoise simplex, CellNoise cell, float[] noise) {
    // Have volcanoes been disabled in the global config?
    if (!rtgConfig.ENABLE_VOLCANOES.get())
        return;
    // Let's go ahead and generate the volcano. Exciting!!! :D
    if (baseX % 4 == 0 && baseY % 4 == 0) {
        int biomeId = Biome.getIdForBiome(cmr.getBiomeGenAt(baseX * 16, baseY * 16));
        RealisticBiomeBase realisticBiome = getBiome(biomeId);
        // Do we need to patch the biome?
        if (realisticBiome == null) {
            RealisticBiomePatcher biomePatcher = new RealisticBiomePatcher();
            realisticBiome = biomePatcher.getPatchedRealisticBiome("NULL biome found when mapping volcanoes.");
        }
        if (!realisticBiome.getConfig().ALLOW_VOLCANOES.get())
            return;
        // Have volcanoes been disabled via frequency?
        // Use the global frequency unless the biome frequency has been explicitly set.
        int chance = realisticBiome.getConfig().VOLCANO_CHANCE.get() == -1 ? rtgConfig.VOLCANO_CHANCE.get() : realisticBiome.getConfig().VOLCANO_CHANCE.get();
        if (chance < 1)
            return;
        if (mapRand.nextInt(chance) > 0)
            return;
        float river = cmr.getRiverStrength(baseX * 16, baseY * 16) + 1f;
        if (river > 0.98f && cmr.isBorderlessAt(baseX * 16, baseY * 16)) {
            // we have to pull it out of noVolcano. We do it this way to avoid having to make a ChunkPos twice
            ChunkPos probe = new ChunkPos(baseX, baseY);
            noVolcano.remove(probe);
            long i1 = mapRand.nextLong() / 2L * 2L + 1L;
            long j1 = mapRand.nextLong() / 2L * 2L + 1L;
            mapRand.setSeed((long) chunkX * i1 + (long) chunkY * j1 ^ world.getSeed());
            WorldGenVolcano.build(primer, world, mapRand, baseX, baseY, chunkX, chunkY, simplex, cell, noise);
        }
    }
}
Also used : RealisticBiomePatcher(rtg.world.biome.realistic.RealisticBiomePatcher) RealisticBiomeBase(rtg.world.biome.realistic.RealisticBiomeBase) ChunkPos(net.minecraft.util.math.ChunkPos)

Example 2 with RealisticBiomeBase

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

the class MapGenVillageRTG method canSpawnStructureAtCoords.

@Override
protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ) {
    boolean canSpawnVillage = false;
    int i = chunkX;
    int j = chunkZ;
    if (chunkX < 0)
        chunkX -= this.distance - 1;
    if (chunkZ < 0)
        chunkZ -= this.distance - 1;
    int k = chunkX / this.distance;
    int l = chunkZ / this.distance;
    Random random = this.world.setRandomSeed(k, l, 10387312);
    k = k * this.distance;
    l = l * this.distance;
    k = k + random.nextInt(this.distance - 8);
    l = l + random.nextInt(this.distance - 8);
    if (i == k && j == l) {
        boolean booRTGWorld = DimensionManagerRTG.isValidDimension(world.provider.getDimension());
        boolean booRTGChunkManager = world.getBiomeProvider() instanceof BiomeProviderRTG;
        int worldX = i * 16 + 8;
        int worldZ = j * 16 + 8;
        if (booRTGWorld && booRTGChunkManager) {
            BiomeProviderRTG cmr = (BiomeProviderRTG) world.getBiomeProvider();
            //Why are we flipping XZ here? No idea, but it works. - Pink
            RealisticBiomeBase realisticBiome = cmr.getBiomeDataAt(worldX, worldZ);
            if (realisticBiome.getConfig().ALLOW_VILLAGES.get()) {
                canSpawnVillage = true;
                Logger.debug("Potential village in %s at %d %d", realisticBiome.baseBiome.getBiomeName(), worldX, worldZ);
            }
        } else
            canSpawnVillage = this.world.getBiomeProvider().areBiomesViable(worldX, worldZ, 0, VILLAGE_SPAWN_BIOMES);
    }
    return canSpawnVillage;
}
Also used : Random(java.util.Random) RealisticBiomeBase(rtg.world.biome.realistic.RealisticBiomeBase) BiomeProviderRTG(rtg.world.biome.BiomeProviderRTG)

Example 3 with RealisticBiomeBase

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

the class BiomeAnalyzer method newRepair.

/* HUNTING
     *
     */
public void newRepair(int[] genLayerBiomes, RealisticBiomeBase[] jitteredBiomes, int[] biomeNeighborhood, int neighborhoodSize, float[] noise, float[] riverStrength) {
    int sampleSize = 8;
    RealisticBiomeBase realisticBiome;
    int realisticBiomeId;
    if (neighborhoodSize != sampleSize)
        throw new RuntimeException("mismatch between chunk and analyzer neighborhood sizes");
    // currently just stuffs the genLayer into the jitter;
    for (int i = 0; i < 256; i++) {
        realisticBiome = RealisticBiomeBase.getBiome(genLayerBiomes[i]);
        // Do we need to patch the biome?
        if (realisticBiome == null) {
            realisticBiome = biomePatcher.getPatchedRealisticBiome("NULL biome (" + i + ") found when performing new repair.");
        }
        realisticBiomeId = Biome.getIdForBiome(realisticBiome.baseBiome);
        boolean canBeRiver = riverStrength[i] > 0.7;
        // save what's there since the jitter keeps changing
        savedJittered[i] = jitteredBiomes[i];
        if (noise[i] > 61.5) {
            // replace
            jitteredBiomes[i] = realisticBiome;
        } else {
            // check for river
            if (canBeRiver && !oceanBiome[realisticBiomeId] && !swampBiome[realisticBiomeId]) {
                // make river
                int riverBiomeID = Biome.getIdForBiome(realisticBiome.riverBiome);
                jitteredBiomes[i] = RealisticBiomeBase.getBiome(riverBiomeID);
            } else {
                // replace
                jitteredBiomes[i] = realisticBiome;
            }
        }
    }
    // put beaches on shores
    beachSearch.notHunted = true;
    beachSearch.absent = false;
    float beachTop = 64.5f;
    for (int i = 0; i < 256; i++) {
        //no point
        if (beachSearch.absent)
            break;
        float beachBottom = 61.5f;
        // this block isn't beach level
        if (noise[i] < beachBottom || noise[i] > riverAdjusted(beachTop, riverStrength[i]))
            continue;
        int biomeID = Biome.getIdForBiome(jitteredBiomes[i].baseBiome);
        // swamps are acceptable at beach level
        if (swampBiome[biomeID])
            continue;
        if (beachSearch.notHunted) {
            beachSearch.hunt(biomeNeighborhood);
            landSearch.hunt(biomeNeighborhood);
        }
        int foundBiome = beachSearch.biomes[i];
        if (foundBiome != NO_BIOME) {
            int nearestLandBiome = landSearch.biomes[i];
            if (nearestLandBiome > -1) {
                foundBiome = preferredBeach[nearestLandBiome];
            }
            realisticBiome = RealisticBiomeBase.getBiome(foundBiome);
            // Do we need to patch the biome?
            if (realisticBiome == null) {
                realisticBiome = biomePatcher.getPatchedRealisticBiome("NULL biome (" + i + ") found when performing new repair.");
            }
            jitteredBiomes[i] = realisticBiome;
        }
    }
    // put land higher up;
    landSearch.absent = false;
    landSearch.notHunted = true;
    for (int i = 0; i < 256; i++) {
        //no point
        if (landSearch.absent && beachSearch.absent)
            break;
        // skip if this block isn't above beach level, adjusted for river effect to prevent abrupt beach stops
        if (noise[i] < riverAdjusted(beachTop, riverStrength[i]))
            continue;
        int biomeID = Biome.getIdForBiome(jitteredBiomes[i].baseBiome);
        // already land
        if (landBiome[biomeID])
            continue;
        // swamps are acceptable above water
        if (swampBiome[biomeID])
            continue;
        if (landSearch.notHunted)
            landSearch.hunt(biomeNeighborhood);
        int foundBiome = landSearch.biomes[i];
        if (foundBiome == NO_BIOME) {
            // no land found; try for a beach
            if (beachSearch.notHunted) {
                beachSearch.hunt(biomeNeighborhood);
            }
            foundBiome = beachSearch.biomes[i];
        }
        if (foundBiome != NO_BIOME) {
            realisticBiome = RealisticBiomeBase.getBiome(foundBiome);
            // Do we need to patch the biome?
            if (realisticBiome == null) {
                realisticBiome = biomePatcher.getPatchedRealisticBiome("NULL biome (" + i + ") found when performing new repair.");
            }
            jitteredBiomes[i] = realisticBiome;
        }
    }
    // put ocean below sea level
    oceanSearch.absent = false;
    oceanSearch.notHunted = true;
    for (int i = 0; i < 256; i++) {
        //no point
        if (oceanSearch.absent)
            break;
        float oceanTop = 61.5f;
        // too hight
        if (noise[i] > oceanTop)
            continue;
        int biomeID = Biome.getIdForBiome(jitteredBiomes[i].baseBiome);
        // obviously ocean is OK
        if (oceanBiome[biomeID])
            continue;
        // swamps are acceptable
        if (swampBiome[biomeID])
            continue;
        // rivers stay rivers
        if (riverBiome[biomeID])
            continue;
        if (oceanSearch.notHunted)
            oceanSearch.hunt(biomeNeighborhood);
        int foundBiome = oceanSearch.biomes[i];
        if (foundBiome != NO_BIOME) {
            realisticBiome = RealisticBiomeBase.getBiome(foundBiome);
            // Do we need to patch the biome?
            if (realisticBiome == null) {
                realisticBiome = biomePatcher.getPatchedRealisticBiome("NULL biome (" + i + ") found when performing new repair.");
            }
            jitteredBiomes[i] = realisticBiome;
        }
    }
    // convert remainder below sea level to lake biome
    for (int i = 0; i < 256; i++) {
        int biomeID = Biome.getIdForBiome(jitteredBiomes[i].baseBiome);
        if (noise[i] <= 61.5 && !riverBiome[biomeID]) {
            // check for river
            if (!oceanBiome[biomeID] && !swampBiome[biomeID] && !beachBiome[biomeID]) {
                // make river
                int riverReplacement = Biome.getIdForBiome(jitteredBiomes[i].riverBiome);
                if (riverReplacement == Biome.getIdForBiome(Biomes.FROZEN_RIVER))
                    jitteredBiomes[i] = scenicFrozenLakeBiome;
                else
                    jitteredBiomes[i] = scenicLakeBiome;
            }
        }
    }
}
Also used : RealisticBiomeBase(rtg.world.biome.realistic.RealisticBiomeBase)

Example 4 with RealisticBiomeBase

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

the class BiomeProviderRTG method getBiomeDataAt.

/**
     * @see IBiomeProviderRTG
     */
@Override
public RealisticBiomeBase getBiomeDataAt(int par1, int par2) {
    /*long coords = ChunkCoordIntPair.chunkXZ2Int(par1, par2);
        if (biomeDataMap.containsKey(coords)) {
            return biomeDataMap.get(coords);
        }*/
    RealisticBiomeBase output;
    output = RealisticBiomeBase.getBiome(Biome.getIdForBiome(this.getBiomeGenAt(par1, par2)));
    if (output == null)
        output = biomePatcher.getPatchedRealisticBiome("No biome " + par1 + " " + par2);
    return output;
}
Also used : RealisticBiomeBase(rtg.world.biome.realistic.RealisticBiomeBase)

Example 5 with RealisticBiomeBase

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

the class RealisticBiomePresenceTester method doBiomeCheck.

public static void doBiomeCheck() {
    for (Biome biome : Biome.REGISTRY) {
        int biomeId = Biome.getIdForBiome(biome);
        String biomeName = biome.getBiomeName();
        String biomeClass = biome.getBiomeClass().getName();
        switch(biomeId) {
            // The Nether
            case 8:
            // The End
            case 9:
            case // The Void
            127:
                // Do nothing.
                break;
            default:
                try {
                    RealisticBiomeBase rBiome = RealisticBiomeBase.getBiome(biomeId);
                    String rBiomeName = rBiome.biomeSlug();
                    Logger.info("Found biome (%d) %s from %s with a %s beach.", biomeId, biomeName, biomeClass, rBiome.beachBiome().getBiomeName());
                } catch (Exception e) {
                    Logger.warn("WARNING! RTG could not find a realistic version of %s (%d) from %s. (If %s is a non-Overworld biome, then this is not an error.)", biomeName, biomeId, biomeClass, biomeName);
                }
                break;
        }
    }
}
Also used : Biome(net.minecraft.world.biome.Biome) 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