Ejemplo n.º 1
0
        /**
         * @see IBiomeProviderRTG
         */
        //Can't override for some reason, shouldn't matter too much at the moment.
        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(this.getBiomeGenAt(par1, par2).getBiomeID());
            if (output == null)
            {
                output = biomePatcher.getPatchedRealisticBiome("No biome " + par1 + " " + par2);
            }

            /*if (biomeDataMap.size() > 4096) {
            *   biomeDataMap.clear();
            *  }
            *  biomeDataMap.put(coords, output);*/

            return(output);
        }
Ejemplo n.º 2
0
        public void rMapVolcanoes(Chunk 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)
            {
                return;
            }

            // Let's go ahead and generate the volcano. Exciting!!! :D
            if (baseX % 4 == 0 && baseY % 4 == 0)
            {
                int biomeId = cmr.getBiomeGenAt(baseX * 16, baseY * 16).getBiomeID();
                RealisticBiomeBase realisticBiome = RealisticBiomeBase.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)
                {
                    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 == -1 ? rtgConfig.VOLCANO_CHANCE : realisticBiome.getConfig().VOLCANO_CHANCE;
                if (chance < 1)
                {
                    return;
                }
                if (mapRand.Next(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.Next() / 2L * 2L + 1L;
                    long j1 = mapRand.Next() / 2L * 2L + 1L;
                    mapRand = new Random((int)((long)chunkX * i1 + (long)chunkY * j1 ^ world.getSeed()));

                    WorldGenVolcano.build(primer, world, mapRand, baseX, baseY, chunkX, chunkY, simplex, cell, noise);
                }
            }
        }
Ejemplo n.º 3
0
        private void getNewerNoise(IBiomeProviderRTG cmr, int cx, int cz, ChunkLandscape landscape)
        {
            // get area biome map

            for (int i = -sampleSize; i < sampleSize + 5; i++)
            {
                for (int j = -sampleSize; j < sampleSize + 5; j++)
                {
                    biomeData[(i + sampleSize) * sampleArraySize + (j + sampleSize)] =
                        cmr.getBiomeDataAt(cx + ((i * 8)), cz + ((j * 8))).baseBiome.getBiomeID();
                }
            }

            float river;

            // fill the old smallRender
            for (int i = 0; i < 16; i++)
            {
                for (int j = 0; j < 16; j++)
                {
                    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;
                    }

                    landscape.noise[i * 16 + j] = 0f;

                    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 Exception("" + totalBorder);
                    }
                }
            }

            //fill biomes array with biomeData

            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)));
                }
            }
        }
Ejemplo n.º 4
0
        /* 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 Exception("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 = realisticBiome.baseBiome.getBiomeID();

                bool canBeRiver = riverStrength[i] > 0.7;

                // save what's there since the jitter keeps changing
                savedJittered[i] = jitteredBiomes[i];
                //if (savedJittered[i]== null) throw new RuntimeException();

                if (noise[i] > 61.5)
                {
                    // replace
                    jitteredBiomes[i] = realisticBiome;
                }
                else
                {
                    // check for river
                    if (canBeRiver && !oceanBiome[realisticBiomeId] && !swampBiome[realisticBiomeId])
                    {
                        // make river
                        int riverBiomeID = realisticBiome.riverBiome.getBiomeID();
                        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++)
            {
                if (beachSearch.absent)
                {
                    break;                     //no point
                }
                float beachBottom = 61.5f;
                if (noise[i] < beachBottom || noise[i] > riverAdjusted(beachTop, riverStrength[i]))
                {
                    continue;                                                                                // this block isn't beach level
                }
                int biomeID = jitteredBiomes[i].baseBiome.getBiomeID();
                if (swampBiome[biomeID])
                {
                    continue;                     // swamps are acceptable at beach level
                }
                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++)
            {
                if (landSearch.absent && beachSearch.absent)
                {
                    break;                                          //no point
                }
                // 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 = jitteredBiomes[i].baseBiome.getBiomeID();
                // 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++)
            {
                if (oceanSearch.absent)
                {
                    break;                     //no point
                }
                float oceanTop = 61.5f;
                if (noise[i] > oceanTop)
                {
                    continue;                     // too hight
                }
                int biomeID = jitteredBiomes[i].baseBiome.getBiomeID();
                if (oceanBiome[biomeID])
                {
                    continue;                     // obviously ocean is OK
                }
                if (swampBiome[biomeID])
                {
                    continue;                     // swamps are acceptable
                }
                if (riverBiome[biomeID])
                {
                    continue;                     // rivers stay rivers
                }
                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 = jitteredBiomes[i].baseBiome.getBiomeID();
                if (noise[i] <= 61.5 && !riverBiome[biomeID])
                {
                    // check for river
                    if (!oceanBiome[biomeID] &&
                        !swampBiome[biomeID] &&
                        !beachBiome[biomeID])
                    {
                        int riverReplacement = jitteredBiomes[i].riverBiome.getBiomeID(); // make river
                        if (riverReplacement == Biomes.FROZEN_RIVER.getBiomeID())
                        {
                            jitteredBiomes[i] = scenicFrozenLakeBiome;
                        }
                        else
                        {
                            jitteredBiomes[i] = scenicLakeBiome;
                        }
                    }
                }
            }
        }