예제 #1
0
  @Override
  public void generateColumn(CuboidShortBuffer blockData, int x, int chunkY, int z) {
    int y = chunkY * 16;
    noise.setSeed((int) blockData.getWorld().getSeed());

    int height =
        (int) ((noise.GetValue(x / 32.0 + 0.005, 0.05, z / 32.0 + 0.005) + 1.0) * 2.0 + 60.0 + 3.0);

    for (int dy = y; dy < y + 16; dy++) {
      short id = getBlockId(height, dy);
      blockData.set(x, dy, z, id);
    }
  }
예제 #2
0
  @Override
  public void generate(CuboidShortBuffer blockData, int chunkX, int chunkY, int chunkZ) {
    final int x = chunkX << Chunk.CHUNK_SIZE_BITS;
    final int z = chunkZ << Chunk.CHUNK_SIZE_BITS;
    final long seed = blockData.getWorld().getSeed();

    if (chunkY << Chunk.CHUNK_SIZE_BITS > blockData.getWorld().getHeight() - 1) {
      blockData.flood((short) 0);
      return;
    }

    for (int dx = x; dx < x + 16; ++dx) {
      for (int dz = z; dz < z + 16; ++dz) {
        biomes.getBiome(dx, dz, seed).generateColumn(blockData, dx, chunkY, dz);
      }
    }
  }
예제 #3
0
 @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);
 }
예제 #4
0
  @Override
  public void generateColumn(CuboidShortBuffer blockData, int x, int chunkY, int z) {
    base.setSeed((int) blockData.getWorld().getSeed());
    noise.setSeed((int) blockData.getWorld().getSeed());
    int y = chunkY * 16;
    double seaLevel = 60.0;
    double perlinRange = 0.005;
    double colSize = 16.0;
    int height =
        (int)
            ((noise.GetValue(x / colSize + perlinRange, 0.05, z / colSize + perlinRange) + 1.0)
                    * 4.0
                + seaLevel);

    for (int dy = y; dy < y + 16; dy++) {
      blockData.set(x, dy, z, getBlockId(height, dy));
    }
  }
예제 #5
0
 @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());
         }
       }
     }
   }
 }