示例#1
0
        public virtual Biome[] GetBlockGeneratorData(Biome[] biomes, int a, int b, int c, int d)
        {
            if (biomes == null || biomes.Length < c * d)
                biomes = new Biome[c * d];

            Temperatures = TempNoise.GetNoise(Temperatures, a, b, c, c, 0.025, 0.025, 0.25);
            Humidities = HumidityNoise.GetNoise(Humidities, a, b, c, c, 0.05, 0.05, 0.33);
            FactorA = NoiseGen3.GetNoise(FactorA, a, b, c, c, 0.25, 0.25, 0.59);

            int i = 0;
            for (int j1 = 0; j1 < c; j1++)
            {
                for (int k1 = 0; k1 < d; k1++)
                {
                    double d0 = FactorA[i] * 1.1 + 0.5;
                    double d1 = 0.01;
                    double d2 = 1.0 - d1;
                    double temp = (Temperatures[i] * 0.15 + 0.7) * d2 + d0 * d1;
                    d1 = 0.002;
                    d2 = 1.0 - d1;
                    double humidity = (Humidities[i] * 0.15 + 0.5) * d2 + d0 * d1;
                    temp = 1.0d - (1.0d - temp) * (1.0D - temp);

                    Temperatures[i] = temp <= 0.0d ? 0.0d : (temp >= 1.0d ? 1.0d : temp);
                    Humidities[i] = humidity <= 0.0d ? 0.0d : (humidity >= 1.0d ? 1.0d : humidity);

                    biomes[i++] = Biome.GetBiomeFromLookup(temp, humidity);
                }
            }

            return biomes;
        }
示例#2
0
        public void GenerateTerrain(int startX, int startZ, byte[] data, Biome[] biomes, double[] noise)
        {
            byte byte0 = 4;
            byte byte1 = 64;
            int k = byte0 + 1;
            byte byte2 = 17;
            int l = byte0 + 1;
            Noise = GenerateNoise(Noise, startX * byte0, 0, startZ * byte0, k, byte2, l);
            for (int i1 = 0; i1 < byte0; i1++)
            {
                for (int i2 = 0; i2 < byte0; i2++)
                {
                    for (int i3 = 0; i3 < 16; i3++)
                    {
                        double d = 0.125D;
                        double d1 = Noise[((i1 + 0) * l + (i2 + 0)) * byte2 + (i3 + 0)];
                        double d2 = Noise[((i1 + 0) * l + (i2 + 1)) * byte2 + (i3 + 0)];
                        double d3 = Noise[((i1 + 1) * l + (i2 + 0)) * byte2 + (i3 + 0)];
                        double d4 = Noise[((i1 + 1) * l + (i2 + 1)) * byte2 + (i3 + 0)];
                        double d5 = (Noise[((i1 + 0) * l + (i2 + 0)) * byte2 + (i3 + 1)] - d1) * d;
                        double d6 = (Noise[((i1 + 0) * l + (i2 + 1)) * byte2 + (i3 + 1)] - d2) * d;
                        double d7 = (Noise[((i1 + 1) * l + (i2 + 0)) * byte2 + (i3 + 1)] - d3) * d;
                        double d8 = (Noise[((i1 + 1) * l + (i2 + 1)) * byte2 + (i3 + 1)] - d4) * d;
                        for (int i4 = 0; i4 < 8; i4++)
                        {
                            double d9 = 0.25D;
                            double d10 = d1;
                            double d11 = d2;
                            double d12 = (d3 - d1) * d9;
                            double d13 = (d4 - d2) * d9;
                            for (int i5 = 0; i5 < 4; i5++)
                            {
                                int j2 = i5 + i1 * 4 << 11 | 0 + i2 * 4 << 7 | i3 * 8 + i4;
                                char c = '\x0080'; // '\200';
                                double d14 = 0.25D;
                                double stone = d10;
                                double d16 = (d11 - d10) * d14;
                                for (int k2 = 0; k2 < 4; k2++)
                                {
                                    double temperature = noise[(i1 * 4 + i5) * 16 + (i2 * 4 + k2)];
                                    int l2 = 0;
                                    if (i3 * 8 + i4 < byte1)
                                    {
                                        if (temperature < 0.5D && i3 * 8 + i4 >= byte1 - 1)
                                        {
                                            l2 = (int)BlockData.Blocks.Ice;
                                        }
                                        else
                                        {
                                            l2 = (byte)BlockData.Blocks.Water;
                                        }
                                    }
                                    if (stone > 0.0D)
                                    {
                                        l2 = (byte)BlockData.Blocks.Stone;
                                    }

                                    data[j2] = (byte)l2;
                                    j2 += c;
                                    stone += d16;
                                }

                                d10 += d12;
                                d11 += d13;
                            }

                            d1 += d5;
                            d2 += d6;
                            d3 += d7;
                            d4 += d8;
                        }
                    }
                }
            }
        }
示例#3
0
 private void ReplaceBlocksForBiome(int i, int j, byte[] data, Biome[] amobspawnerbase)
 {
     byte byte0 = 64;
     double d = 0.03125D;
     SandNoise = Noise4.GenerateNoiseOctaves(SandNoise, i * 16, j * 16, 0.0D, 16, 16, 1, d, d, 1.0D);
     GravelNoise = Noise4.GenerateNoiseOctaves(GravelNoise, i * 16, 109.0134D, j * 16, 16, 1, 16, d, 1.0D, d);
     StoneNoise = Noise5.GenerateNoiseOctaves(StoneNoise, i * 16, j * 16, 0.0D, 16, 16, 1, d * 2D, d * 2D, d * 2D);
     for (int x = 0; x < 16; x++)
     {
         for (int z = 0; z < 16; z++)
         {
             Biome mobspawnerbase = amobspawnerbase[x + z * 16];
             bool flag = SandNoise[x + z * 16] + Rand.nextDouble() * 0.20000000000000001D > 0.0D;
             bool flag1 = GravelNoise[x + z * 16] + Rand.nextDouble() * 0.20000000000000001D > 3D;
             int i1 = (int)(StoneNoise[x + z * 16] / 3D + 3D + Rand.nextDouble() * 0.25D);
             int j1 = -1;
             byte byte1 = mobspawnerbase.TopBlock;
             byte byte2 = mobspawnerbase.FillerBlock;
             for (int y = 127; y >= 0; y--)
             {
                 int l1 = (z * 16 + x) * 128 + y;
                 if (y <= 0 + Rand.nextInt(5))
                 {
                     data[l1] = (byte)BlockData.Blocks.Bedrock;
                     continue;
                 }
                 byte byte3 = data[l1];
                 if (byte3 == 0)
                 {
                     j1 = -1;
                     continue;
                 }
                 if (byte3 != (byte)BlockData.Blocks.Stone)
                 {
                     continue;
                 }
                 if (j1 == -1)
                 {
                     if (i1 <= 0)
                     {
                         byte1 = 0;
                         byte2 = (byte)(byte)BlockData.Blocks.Stone;
                     }
                     else if (y >= byte0 - 4 && y <= byte0 + 1)
                     {
                         byte1 = mobspawnerbase.TopBlock;
                         byte2 = mobspawnerbase.FillerBlock;
                         if (flag1)
                         {
                             byte1 = 0;
                         }
                         if (flag1)
                         {
                             byte2 = (byte)BlockData.Blocks.Gravel;
                         }
                         if (flag)
                         {
                             byte1 = (byte)BlockData.Blocks.Sand;
                             byte2 = (byte)BlockData.Blocks.Sand;
                         }
                     }
                     if (y < byte0 && byte1 == 0)
                     {
                         byte1 = (byte)BlockData.Blocks.Water;
                     }
                     j1 = i1;
                     if (y >= byte0 - 1)
                     {
                         data[l1] = byte1;
                     }
                     else
                     {
                         data[l1] = byte2;
                     }
                     continue;
                 }
                 if (j1 <= 0)
                 {
                     continue;
                 }
                 j1--;
                 data[l1] = byte2;
                 if (j1 == 0 && byte2 == (byte)BlockData.Blocks.Sand)
                 {
                     j1 = Rand.nextInt(4);
                     byte2 = (byte)BlockData.Blocks.Sandstone;
                 }
             }
         }
     }
 }