@Override
 public BiomeManager generate(CuboidShortBuffer blockData, int chunkX, int chunkY, int chunkZ) {
   if (chunkY >= 0) {
     return super.generate(blockData, chunkX, chunkY, chunkZ);
   }
   blockData.flood(VanillaMaterials.BEDROCK.getId());
   return new EmptyBiomeManager(chunkX, chunkY, chunkZ);
 }
Example #2
0
 private short getBlockId(int top, int dy) {
   short id;
   if (dy > top) {
     id = VanillaMaterials.AIR.getId();
   } else if (dy + 4 >= top) {
     id = VanillaMaterials.SAND.getId();
   } else if (dy + 5 == top) {
     id = VanillaMaterials.SANDSTONE.getId();
   } else if (dy != 0) {
     id = VanillaMaterials.STONE.getId();
   } else {
     id = VanillaMaterials.BEDROCK.getId();
   }
   return id;
 }
 @Override
 protected void generateTerrain(
     CuboidShortBuffer blockData, int x, int y, int z, BiomeManager biomes, long seed) {
   if (y >= HEIGHT) {
     return;
   }
   final Vector3 size = blockData.getSize();
   final int sizeX = size.getFloorX();
   final int sizeY = MathHelper.clamp(size.getFloorY(), 0, HEIGHT);
   final int sizeZ = size.getFloorZ();
   ELEVATION.setSeed((int) seed * 23);
   ROUGHNESS.setSeed((int) seed * 29);
   DETAIL.setSeed((int) seed * 17);
   TURBULENCE.setSeed((int) seed * 53);
   final Random random = WorldGeneratorUtils.getRandom(seed, x, y, z, 6516);
   final double[][][] noise =
       WorldGeneratorUtils.fastNoise(FINAL, sizeX, sizeY, sizeZ, 4, x, y, z);
   final BiomeSelector selector = getSelector();
   final TIntPairObjectHashMap<NormalBiome> biomeCache = new TIntPairObjectHashMap<NormalBiome>();
   for (int xx = 0; xx < sizeX; xx++) {
     for (int zz = 0; zz < sizeZ; zz++) {
       float maxSum = 0;
       float minSum = 0;
       byte count = 0;
       for (int sx = -SMOOTH_SIZE; sx <= SMOOTH_SIZE; sx++) {
         for (int sz = -SMOOTH_SIZE; sz <= SMOOTH_SIZE; sz++) {
           final NormalBiome adjacent;
           if (xx + sx < 0 || zz + sz < 0 || xx + sx >= sizeX || zz + sz >= sizeZ) {
             if (biomeCache.containsKey(x + xx + sx, z + zz + sz)) {
               adjacent = biomeCache.get(x + xx + sx, z + zz + sz);
             } else {
               adjacent = (NormalBiome) selector.pickBiome(x + xx + sx, y, z + zz + sz, seed);
               biomeCache.put(x + xx + sx, z + zz + sz, adjacent);
             }
           } else {
             adjacent = (NormalBiome) biomes.getBiome(xx + sx, y, zz + sz);
           }
           minSum += adjacent.getMin();
           maxSum += adjacent.getMax();
           count++;
         }
       }
       final double minElevation = minSum / count;
       final double smoothHeight = (maxSum / count - minElevation) / 2d;
       for (int yy = 0; yy < sizeY; yy++) {
         double noiseValue =
             noise[xx][yy][zz] - 1 / smoothHeight * (y + yy - smoothHeight - minElevation);
         if (noiseValue >= 0) {
           blockData.set(x + xx, y + yy, z + zz, VanillaMaterials.STONE.getId());
         } else {
           if (y + yy <= SEA_LEVEL) {
             if (y + yy == SEA_LEVEL
                 && ((NormalBiome) biomes.getBiome(xx, 0, zz)).getClimate() == Climate.COLD) {
               blockData.set(x + xx, y + yy, z + zz, VanillaMaterials.ICE.getId());
             } else {
               blockData.set(x + xx, y + yy, z + zz, VanillaMaterials.WATER.getId());
             }
           } else {
             blockData.set(x + xx, y + yy, z + zz, VanillaMaterials.AIR.getId());
           }
         }
       }
       if (y == 0) {
         final byte bedrockDepth = (byte) (random.nextInt(BEDROCK_DEPTH) + 1);
         for (byte yy = 0; yy < bedrockDepth; yy++) {
           blockData.set(x + xx, yy, z + zz, VanillaMaterials.BEDROCK.getId());
         }
       }
     }
   }
 }