Exemple #1
0
        public void generateMapGen(Chunk primer, long seed, World world, IBiomeProviderRTG cmr, Random mapRand, int chunkX, int chunkY, OpenSimplexNoise simplex, CellNoise cell, float[] noise)
        {
            // Have volcanoes been disabled in the global config?
            if (!rtgConfig.ENABLE_VOLCANOES)
            {
                return;
            }

            int mapGenRadius     = 5;
            int volcanoGenRadius = 15;

            mapRand = new Random((int)seed);
            long l  = (mapRand.Next() / 2L) * 2L + 1L;
            long l1 = (mapRand.Next() / 2L) * 2L + 1L;

            // Volcanoes generation
            for (int baseX = chunkX - volcanoGenRadius; baseX <= chunkX + volcanoGenRadius; baseX++)
            {
                for (int baseY = chunkY - volcanoGenRadius; baseY <= chunkY + volcanoGenRadius; baseY++)
                {
                    mapRand = new Random((int)((long)baseX * l + (long)baseY * l1 ^ seed));
                    rMapVolcanoes(primer, world, cmr, mapRand, baseX, baseY, chunkX, chunkY, simplex, cell, noise);
                }
            }
        }
Exemple #2
0
        public void generateMapGen(Chunk primer, long unusedSeed, World world, IBiomeProviderRTG cmr, Random unusedMapRand, int chunkX, int chunkY, OpenSimplexNoise simplex, CellNoise cell, float[] noise)
        {
            // Have volcanoes been disabled in the global config?
            if (!rtgConfig.ENABLE_VOLCANOES)
            {
                return;
            }

            int mapGenRadius     = 5;
            int volcanoGenRadius = 15;

            //if (!seed.equals(currentSeed)) {
            //currentSeed = seed;
            //}


            // Volcanoes generation
            for (int baseX = chunkX - volcanoGenRadius; baseX <= chunkX + volcanoGenRadius; baseX++)
            {
                for (int baseY = chunkY - volcanoGenRadius; baseY <= chunkY + volcanoGenRadius; baseY++)
                {
                    ChunkPos probe = new ChunkPos(baseX, baseY);
                    if (noVolcano.Contains(probe))
                    {
                        continue;
                    }
                    noVolcano.Add(probe);
                    mapRand = new Random((int)((long)baseX * l + (long)baseY * l1 ^ seed));
                    rMapVolcanoes(primer, world, cmr, baseX, baseY, chunkX, chunkY, simplex, cell, noise);
                }
            }
        }
        int getBiomeDataAt(IBiomeProviderRTG cmr, int cx, int cz)
        {
            int            cx2    = cx & 15;
            int            cz2    = cz & 15;
            ChunkLandscape target = this.landscape(cmr, cx - cx2, cz - cz2);

            return(target.biome[cx2 * 16 + cz2].baseBiome.getBiomeID());
        }
Exemple #4
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);
                }
            }
        }
        /*
         * All of the 'cx' and 'cz' parameters have been flipped when passing them.
         * Prior to flipping, the terrain was being XZ-chunk-flipped. - WhichOnesPink
         */
        ChunkLandscape landscape(IBiomeProviderRTG cmr, int cx, int cz)
        {
            ChunkPos       chunkPos    = new ChunkPos(cx, cz);
            ChunkLandscape preExisting = this.storage[chunkPos];

            if (preExisting != null)
            {
                return(preExisting);
            }
            ChunkLandscape result = new ChunkLandscape();

            getNewerNoise(cmr, cx, cz, result);
            int[] biomeIndices = cmr.getBiomesGens(cx, cz, 16, 16);
            analyzer.newRepair(biomeIndices, result.biome, this.biomeData, this.sampleSize, result.noise, result.river);
            //-cmr.getRiverStrength(cx * 16 + 7, cy * 16 + 7));
            storage[chunkPos] = result;
            return(result);
        }
        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)));
                }
            }
        }