private double[] initializeNoiseField(double ad[], int i, int j, int k, int l, int i1, int j1) {
    if (ad == null) {
      ad = new double[l * i1 * j1];
    }
    double d = 684.41200000000003D;
    double d1 = 684.41200000000003D;
    double ad1[] = BWG4WorldChunkManager.temperature;
    double ad2[] = BWG4WorldChunkManager.humidity;
    field_4182_g = field_922_a.func_4109_a(field_4182_g, i, k, l, j1, 1.121D, 1.121D, 0.5D);
    field_4181_h = field_921_b.func_4109_a(field_4181_h, i, k, l, j1, 200D, 200D, 0.5D);
    field_4185_d =
        field_910_m.func_807_a(field_4185_d, i, j, k, l, i1, j1, d / 80D, d1 / 160D, d / 80D);
    field_4184_e = field_912_k.func_807_a(field_4184_e, i, j, k, l, i1, j1, d, d1, d);
    field_4183_f = field_911_l.func_807_a(field_4183_f, i, j, k, l, i1, j1, d, d1, d);
    int k1 = 0;
    int l1 = 0;
    int i2 = 16 / l;
    for (int j2 = 0; j2 < l; j2++) {
      int k2 = j2 * i2 + i2 / 2;
      for (int l2 = 0; l2 < j1; l2++) {
        int i3 = l2 * i2 + i2 / 2;
        double d2 = ad1[k2 * 16 + i3];
        double d3 = ad2[k2 * 16 + i3] * d2;
        double d4 = 1.0D - d3;
        d4 *= d4;
        d4 *= d4;
        d4 = 1.0D - d4;
        double d5 = (field_4182_g[l1] + 256D) / 512D;
        d5 *= d4;
        if (d5 > 1.0D) {
          d5 = 1.0D;
        }
        double d6 = field_4181_h[l1] / 8000D;
        if (d6 < 0.0D) {
          d6 = -d6 * 0.29999999999999999D;
        }
        d6 = d6 * 3D - 2D;
        if (d6 < 0.0D) {
          d6 /= 2D;
          if (d6 < -1D) {
            d6 = -1D;
          }
          d6 /= 1.3999999999999999D;
          d6 /= 2D;
          d5 = 0.0D;
        } else {
          if (d6 > 1.0D) {
            d6 = 1.0D;
          }
          d6 /= 8D;
        }
        if (d5 < 0.0D) {
          d5 = 0.0D;
        }
        d5 += 0.5D;
        d6 = (d6 * (double) i1) / 16D;
        double d7 = (double) i1 / 2D + d6 * 4D;
        l1++;
        for (int j3 = 0; j3 < i1; j3++) {
          double d8 = 0.0D;
          double d9 = (((double) j3 - d7) * 12D) / d5;
          if (d9 < 0.0D) {
            d9 *= 4D;
          }
          double d10 = field_4184_e[k1] / 512D;
          double d11 = field_4183_f[k1] / 512D;
          double d12 = (field_4185_d[k1] / 10D + 1.0D) / 2D;
          if (d12 < 0.0D) {
            d8 = d10;
          } else if (d12 > 1.0D) {
            d8 = d11;
          } else {
            d8 = d10 + (d11 - d10) * d12;
          }
          d8 -= d9;
          if (j3 > i1 - 4) {
            double d13 = (float) (j3 - (i1 - 4)) / 3F;
            d8 = d8 * (1.0D - d13) + -10D * d13;
          }
          ad[k1] = d8;
          k1++;
        }
      }
    }

    return ad;
  }
 public void replaceBlocksForBiome(int i, int j, byte abyte0[], BiomeGenBase abiomegenbase[]) {
   byte byte0 = 64;
   double d = 0.03125D;
   field_905_r = field_909_n.func_807_a(field_905_r, i * 16, j * 16, 0.0D, 16, 16, 1, d, d, 1.0D);
   field_904_s =
       field_909_n.func_807_a(field_904_s, j * 16, 109.0134D, i * 16, 16, 1, 16, d, 1.0D, d);
   field_903_t =
       field_908_o.func_807_a(
           field_903_t, i * 16, j * 16, 0.0D, 16, 16, 1, d * 2D, d * 2D, d * 2D);
   for (int k = 0; k < 16; k++) {
     for (int l = 0; l < 16; l++) {
       BiomeGenBase biomegenbase = abiomegenbase[k * 16 + l];
       boolean flag =
           field_905_r[k + l * 16] + field_913_j.nextDouble() * 0.20000000000000001D > 0.0D;
       boolean flag1 =
           field_904_s[k + l * 16] + field_913_j.nextDouble() * 0.20000000000000001D > 3D;
       int i1 = (int) (field_903_t[k + l * 16] / 3D + 3D + field_913_j.nextDouble() * 0.25D);
       int j1 = -1;
       byte byte1 = biomegenbase.topBlock;
       byte byte2 = biomegenbase.fillerBlock;
       for (int k1 = 127; k1 >= 0; k1--) {
         int l1 = (k * 16 + l) * 128 + k1;
         if (k1 <= 0 + field_913_j.nextInt(5)) {
           abyte0[l1] = (byte) Block.bedrock.blockID;
           continue;
         }
         byte byte3 = abyte0[l1];
         if (byte3 == 0) {
           j1 = -1;
           continue;
         }
         if (byte3 != Block.stone.blockID) {
           continue;
         }
         if (j1 == -1) {
           if (i1 <= 0) {
             byte1 = 0;
             byte2 = (byte) Block.stone.blockID;
           } else if (k1 >= byte0 - 4 && k1 <= byte0 + 1) {
             byte1 = biomegenbase.topBlock;
             byte2 = biomegenbase.fillerBlock;
             if (flag1) {
               byte1 = 0;
             }
             if (flag1) {
               byte2 = (byte) Block.gravel.blockID;
             }
             if (flag) {
               byte1 = (byte) Block.sand.blockID;
             }
             if (flag) {
               byte2 = (byte) Block.sand.blockID;
             }
           }
           if (k1 < byte0 && byte1 == 0) {
             byte1 = (byte) Block.waterMoving.blockID;
           }
           j1 = i1;
           if (k1 >= byte0 - 1) {
             abyte0[l1] = byte1;
           } else {
             abyte0[l1] = byte2;
           }
           continue;
         }
         if (j1 > 0) {
           j1--;
           abyte0[l1] = byte2;
         }
       }
     }
   }
 }