OpenMinecraft.InfdevHandler.Generate C# (CSharp) Method

Generate() public method

public Generate ( long X, long Z, double &min, double &max ) : bool
X long
Z long
min double
max double
return bool
		public override bool Generate(long X, long Z, out double min, out double max)
        {
            min = 0;
            max = (double)ChunkY;
            if (treeNoise == null)
            {
                treeNoise = new Perlin();
                treeNoise.Seed = (int)this.RandomSeed + 4;
                treeNoise.Frequency = 1;
                treeNoise.Persistence = 0.5;
                treeNoise.OctaveCount = 1;
                dungeonNoise = new Random((int)RandomSeed);
                cavernNoise = new RidgedMultifractal();
                cavernNoise.Seed = (int)this.RandomSeed + 5;
                cavernNoise.Frequency = 0.025;
                //caveNoise.Persistence = 0.25;
                cavernNoise.OctaveCount = 1;
                caveNoise = new Perlin();
                caveNoise.Seed = (int)RandomSeed + 2;
                caveNoise.Frequency = 0.03;
                caveNoise.Lacunarity = 0.01;
                caveNoise.Persistence = 0.01;
                caveNoise.OctaveCount = 1;
            }
            if (_Generator == null)
            {
                return false;
            }
			string lockfile = Path.ChangeExtension(GetChunkFilename((int)X,(int)Z), "genlock");
			if (!_Generator.NoPreservation)
			{
				if (File.Exists(lockfile))
					return true;
			}
			else
			{
				if (File.Exists(lockfile))
					File.Delete(lockfile);
			}
            //Console.WriteLine("GEN");
            profGen.Start();
			double[,] hm = _Generator.Generate(this, X, Z,out min, out max);
            profGen.Stop();

            if (hm == null)
            {
                Console.WriteLine("ERROR: hm==null");
                return false;
            }

            // Erosion shit here.

            Chunk _c = NewChunk(X, Z);
            byte[, ,] blocks = _c.Blocks;

            //Console.WriteLine("BIOME");
            profBiome.Start();
            BiomeType[,] biomes = _Generator.DetermineBiomes(ChunkScale, X, Z);
            profBiome.Stop();

            IMapHandler mh = this;
            // These use the block array.

            profVoxelize.Start();
            HeightmapToVoxelspace(hm, ref blocks);                                       AssertBottomBarrierIntegrity(blocks, "HeightmapToVoxelspace");
            profVoxelize.Stop();

            profSoil.Start();
            _Generator.AddSoil(X,Z,cavernNoise, caveNoise, hm,ref blocks, biomes, 63, 6, _Generator.Materials);         AssertBottomBarrierIntegrity(blocks, "AddSoil");
            profSoil.Stop();

            //profDgn.Start();
            //_Generator.AddDungeons(ref blocks, ref mh, dungeonNoise, X, Z);              AssertBottomBarrierIntegrity(blocks, "AddDungeons");
            //profDgn.Stop();

            profPrecip.Start();
            _Generator.Precipitate(ref blocks, biomes, _Generator.Materials, X, Z);      AssertBottomBarrierIntegrity(blocks, "Precipitate");
            profPrecip.Stop();

            profSave.Start();
            mh.SaveAll();

            _c.Blocks = blocks;
            //_c.UpdateOverview();
            SetChunk(_c);
            File.WriteAllText(lockfile, _Generator.ToString());


            // These use SetBlockAt() and company.

            //Console.WriteLine("SAVE");
            SaveAll();
            profSave.Stop();

            string profres = profBiome.ToString();
            profres += "\r\n";
            profres += profDgn.ToString();
            profres += "\r\n";
            profres += profErode.ToString();
            profres += "\r\n";
            profres += profGen.ToString();
            profres += "\r\n";
            profres += profPrecip.ToString();
            profres += "\r\n";
            profres += profSave.ToString();
            profres += "\r\n";
            profres += profSoil.ToString();
            profres += "\r\n";
            profres += profVoxelize.ToString();

            File.WriteAllText("GEN_PROFILE.txt", profres);
            return true;
		}