コード例 #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="w"></param>
        /// <param name="c"></param>
        public override void Generate(World w, Chunk c)
        {
            random = new Random(w.seed);
            int cx = c.x << 4, cz = c.z << 4;
            int waterLevel = 64 + 15 / 2 - 4;
            if (w.seed == 0)
            {
                for (int x = 0; x < 16; ++x)
                    for (int z = 0; z < 16; ++z)
                    {
                        for (int y = 0; y < 1; ++y)
                            c.UNCHECKEDPlaceBlock(x, y, z, 0x07);
                        for (int y = 1; y < 50; ++y)
                            c.UNCHECKEDPlaceBlock(x, y, z, 0x01);
                        for (int y = 50; y < 65; ++y)
                            c.UNCHECKEDPlaceBlock(x, y, z, 0x03);
                        c.UNCHECKEDPlaceBlock(x, 65, z, 0x02);
                    }
            }
            else
            {
                for (int x = 0; x < 16; x++)
                {
                    for (int z = 0; z < 16; z++)
                    {

                        int v = (int)(64 + voronoi.GetValue(cx + x, 5, cz + z) * 7 + (perlin2.GetValue(cx + x, 7, cz + z) + (perlin.GetValue(cx + x, 10, cz + z))) * 15);

                        // Bedrock
                        int bedrockHeight = random.Next(1, 6);
                        for (int y = 0; y < bedrockHeight; y++)
                            c.UNCHECKEDPlaceBlock(x, y, z, 0x07);

                        // Stone
                        for (int y = bedrockHeight; y < v - 5; y++)
                            c.UNCHECKEDPlaceBlock(x, y, z, 0x01);

                        // Dirt
                        for (int y = v - 5; y < v; y++)
                            c.UNCHECKEDPlaceBlock(x, y, z, (byte)(desertSelector.GetValue(cx + x, y, cz + z) > 0.4 ? 0x0C : 0x03));

                        if (v <= waterLevel)
                        {
                            c.UNCHECKEDPlaceBlock(x, v, z, 0x0C); // Send
                        }
                        else
                        {
                            c.UNCHECKEDPlaceBlock(x, v, z, (byte)(desertSelector.GetValue(cx + x, v, cz + z) > 0.35 ? 0x0C : 0x02));
                        }
                    }
                }

                for (int x = 0; x < 16; x++)
                {
                    //for( int y = 0; y < 128; y++ ) {
                    for (int z = 0; z < 16; z++)
                    {
                        var d = 0.0;
                        var prevV = (64 + voronoi.GetValue(cx + x, 5, cz + z) * 7 + (perlin2.GetValue(cx + x, 7, cz + z) + (perlin.GetValue(cx + x, 10, cz + z))) * 15);
                        if (prevV < waterLevel)
                            d = (waterLevel - prevV) * 0.78;

                        var v = (-mountains.GetValue(cx + x, 127, cz + z));
                        if (v >= d)
                        {
                            var h = (64 + (int)(v * 39));

                            int lvl = 0;

                            for (int y = h - 1; y >= 0; y--)
                            {
                                var mv = mountains2.GetValue(cx + x, y, cz + z);
                                bool desert = desertSelector.GetValue(cx + x, y, cz + z) > 0.4;
                                //if( mv > 0.4 ) {
                                if (lvl == 0)
                                    c.UNCHECKEDPlaceBlock(x, y, z, (byte)(desert ? 0x0C : 0x02));
                                else if (lvl < 5)
                                    c.UNCHECKEDPlaceBlock(x, y, z, (byte)(desert ? 0x0C : 0x03));
                                else
                                    c.UNCHECKEDPlaceBlock(x, y, z, 0x01);

                                ++lvl;
                                //}
                            }
                        }
                    }
                    //}
                }

                for (int x = 0; x < 16; x++)
                {
                    for (int z = 0; z < 16; z++)
                    {
                        for (int y = 0; y < 128; y++)
                        {
                            if (caves.GetValue(cx + x, y, cz + z) > (128 - y) * 0.0132)
                            {
                                c.UNCHECKEDPlaceBlock(x, y, z, 0x00);
                                if (c.SGB(x, y - 1, z) == 0x03)
                                    c.UNCHECKEDPlaceBlock(x, y - 1, z, 0x02);
                            }

                            if (y <= waterLevel && c.SGB(x, y, z) == 0x00)
                            {
                                c.UNCHECKEDPlaceBlock(x, y, z, 0x08);
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: GenStandard.cs プロジェクト: eszanto8/ForgeCraft
 /// <summary>
 /// 
 /// </summary>
 /// <param name="w"></param>
 /// <param name="c"></param>
 public override void Generate(World w, Chunk c)
 {
     //DateTime start = DateTime.Now;
     //int cx = c.x << 4, cz = c.z << 4;
     //int waterLevel = 64 + 15 / 2 - 4;
     if (w.seed == 0)
     {
         for (int x = 0; x < 16; ++x)
             for (int z = 0; z < 16; ++z)
             {
                 for (int y = 0; y < 1; ++y)
                     c.UNCHECKEDPlaceBlock(x, y, z, 0x07);
                 for (int y = 1; y < 50; ++y)
                     c.UNCHECKEDPlaceBlock(x, y, z, 0x01);
                 for (int y = 50; y < 65; ++y)
                     c.UNCHECKEDPlaceBlock(x, y, z, 0x03);
                 c.UNCHECKEDPlaceBlock(x, 65, z, 0x02);
             }
     }
     else
     {
         lock (this.blarg) // We have to do this otherwise shit gets f****d.
         {
             random.setSeed((long)c.x * 0x4f9939f508L + (long)c.z * 0x1ef1565bd5L);
             generateTerrain(c.x, c.z, c.blocks);
             //biomesForGeneration = worldObj.getWorldChunkManager().loadBlockGeneratorData(biomesForGeneration, i * 16, j * 16, 16, 16);
             replaceBlocksForBiome(c.x, c.z, c.blocks/*, biomesForGeneration*/);
             caveGenerator.generate(worldObj, c.x, c.z, c.blocks);
             if (field_35563_t)
             {
                 //field_35559_d.generate(this, worldObj, i, j, abyte0);
                 //field_35558_f.generate(this, worldObj, i, j, abyte0);
                 //field_35560_e.generate(this, worldObj, i, j, abyte0);
             }
             field_35564_x.generate(worldObj, c.x, c.z, c.blocks);
         }
     }
     //TimeSpan took = DateTime.Now - start;
     //Console.WriteLine(took.TotalMilliseconds);
 }