@Override
  public void populate(IChunkProvider ichunkprovider, int x, int z) {
    rand.setSeed((long) x * 0x12f88dd3L + (long) z * 0x36d41eecL);
    int x1 = x << 4;
    int z1 = z << 4;
    if (mapFeaturesEnabled) {
      if (ODNBXlite.Structures[2]) {
        strongholdGenerator.generateStructuresInChunk(worldObj, rand, x, z);
      }
      if (ODNBXlite.Structures[1]) {
        villageGenerator.generateStructuresInChunk(worldObj, rand, x, z);
      }
      if (ODNBXlite.Structures[3]) {
        mineshaftGenerator.generateStructuresInChunk(worldObj, rand, x, z);
      }
    }
    for (int i = 0; i < 20; i++) {
      int x2 = x1 + rand.nextInt(16);
      int y2 = rand.nextInt(128);
      int z2 = z1 + rand.nextInt(16);
      (new SuperOldWorldGenMinable(Block.oreCoal.blockID))
          .generate_infdev(worldObj, rand, x2, y2, z2);
    }

    for (int i = 0; i < 10; i++) {
      int x2 = x1 + rand.nextInt(16);
      int y2 = rand.nextInt(64);
      int z2 = z1 + rand.nextInt(16);
      (new SuperOldWorldGenMinable(Block.oreIron.blockID))
          .generate_infdev(worldObj, rand, x2, y2, z2);
    }

    if (rand.nextInt(2) == 0) {
      int x2 = x1 + rand.nextInt(16);
      int y2 = rand.nextInt(32);
      int z2 = z1 + rand.nextInt(16);
      (new SuperOldWorldGenMinable(Block.oreGold.blockID))
          .generate_infdev(worldObj, rand, x2, y2, z2);
    }
    if (rand.nextInt(8) == 0) {
      int x2 = x1 + rand.nextInt(16);
      int y2 = rand.nextInt(16);
      int z2 = z1 + rand.nextInt(16);
      (new SuperOldWorldGenMinable(Block.oreDiamond.blockID))
          .generate_infdev(worldObj, rand, x2, y2, z2);
    }
    if (ODNBXlite.getFlag("newores")) {
      for (int i = 0; i < 8; i++) {
        int x2 = x1 + rand.nextInt(16);
        int y2 = rand.nextInt(16);
        int z2 = z1 + rand.nextInt(16);
        (new SuperOldWorldGenMinable(Block.oreRedstone.blockID))
            .generate_infdev(worldObj, rand, x2, y2, z2);
      }
      for (int i = 0; i < 1; i++) {
        int x2 = x1 + rand.nextInt(16);
        int y2 = rand.nextInt(16) + rand.nextInt(16);
        int z2 = z1 + rand.nextInt(16);
        (new SuperOldWorldGenMinable(Block.oreLapis.blockID))
            .generate_infdev(worldObj, rand, x2, y2, z2);
      }
      int max = 0;
      detection:
      for (int i = x1; i < x1 + 16; i++) {
        for (int j = z1; j < z1 + 16; j++) {
          int h = worldObj.getPrecipitationHeight(i, j);
          if (max < h) {
            max = h;
          }
          if (max > 108) {
            break detection;
          }
        }
      }
      if (max > 108) {
        for (int i = 0; i < 3 + rand.nextInt(6); i++) {
          int x2 = x1 + rand.nextInt(16);
          int y2 = rand.nextInt(28) + 4;
          int z2 = z1 + rand.nextInt(16);
          int id = worldObj.getBlockId(x2, y2, z2);
          if (id == Block.stone.blockID) {
            worldObj.setBlock(x2, y2, z2, Block.oreEmerald.blockID);
          }
        }
      }
    }
    int trees =
        (int)
            (treeGen.func_806_a(
                    (double) x1 * 0.050000000000000003D, (double) z1 * 0.050000000000000003D)
                - rand.nextDouble());
    if (trees < 0) {
      trees = 0;
    }
    WorldGenerator treegen =
        ODNBXlite.MapFeatures == ODNBXlite.FEATURES_INFDEV0608
            ? new OldWorldGenTrees(false)
            : new OldWorldGenBigTree();
    if (rand.nextInt(100) == 0) {
      trees++;
    }
    if (ODNBXlite.MapTheme == ODNBXlite.THEME_WOODS) {
      trees += 20;
    }
    for (int i = 0; i < trees; i++) {
      int x2 = x1 + rand.nextInt(16) + 8;
      int z2 = z1 + rand.nextInt(16) + 8;
      treegen.setScale(1.0D, 1.0D, 1.0D);
      treegen.generate(worldObj, rand, x2, worldObj.getHeightValue(x2, z2), z2);
    }
    spawnAnimals(x * 16, z * 16);
  }
 @Override
 protected void replaceBlocks(int i, int j, byte abyte0[]) {
   for (int l1 = 0; l1 < 16; l1++) {
     for (int j2 = 0; j2 < 16; j2++) {
       double d2 = (i << 4) + l1;
       double d4 = (j << 4) + j2;
       double asd = 0.0D;
       if (ODNBXlite.MapTheme == ODNBXlite.THEME_PARADISE) {
         asd = -0.29999999999999999D;
       }
       boolean flag =
           noiseSandGen.generateNoise(d2 * 0.03125D, d4 * 0.03125D, 0.0D)
                   + rand.nextDouble() * 0.20000000000000001D
               > asd;
       boolean flag1 =
           noiseSandGen.generateNoise(d4 * 0.03125D, 109.0134D, d2 * 0.03125D)
                   + rand.nextDouble() * 0.20000000000000001D
               > 3D;
       int i4 =
           (int)
               (rockSandGen.func_806_a(d2 * 0.03125D * 2D, d4 * 0.03125D * 2D) / 3D
                   + 3D
                   + rand.nextDouble() * 0.25D);
       int j4 = l1 << 11 | j2 << 7 | 0x7f;
       int k4 = -1;
       int l4;
       if (ODNBXlite.MapTheme == ODNBXlite.THEME_HELL) {
         l4 = Block.dirt.blockID;
       } else {
         l4 = Block.grass.blockID;
       }
       int i5 = Block.dirt.blockID;
       for (int j5 = 127; j5 >= 0; j5--) {
         if (abyte0[j4] == 0) {
           k4 = -1;
         } else if (abyte0[j4] == Block.stone.blockID) {
           if (k4 == -1) {
             if (i4 <= 0) {
               l4 = 0;
               i5 = (byte) Block.stone.blockID;
             } else if (j5 >= 60 && j5 <= 65) {
               if (ODNBXlite.MapTheme == ODNBXlite.THEME_HELL) {
                 l4 = Block.dirt.blockID;
                 i5 = Block.dirt.blockID;
                 if (flag1) {
                   l4 = 0;
                 }
                 if (flag1) {
                   i5 = Block.gravel.blockID;
                 }
                 if (flag) {
                   l4 = Block.grass.blockID;
                 }
                 if (flag) {
                   i5 = Block.sand.blockID;
                 }
               } else {
                 l4 = Block.grass.blockID;
                 i5 = Block.dirt.blockID;
                 if (flag1) {
                   l4 = 0;
                 }
                 if (flag1) {
                   i5 = Block.gravel.blockID;
                 }
                 if (flag) {
                   l4 = Block.sand.blockID;
                 }
                 if (flag) {
                   i5 = Block.sand.blockID;
                 }
               }
             }
             if (j5 < 64 && l4 == 0) {
               if (ODNBXlite.MapTheme == ODNBXlite.THEME_HELL) {
                 l4 = Block.lavaStill.blockID;
               } else {
                 l4 = Block.waterStill.blockID;
               }
             }
             k4 = i4;
             if (j5 >= 63) {
               abyte0[j4] = (byte) l4;
             } else {
               abyte0[j4] = (byte) i5;
             }
           } else if (k4 > 0) {
             k4--;
             abyte0[j4] = (byte) i5;
           }
         }
         j4--;
       }
     }
   }
 }