@Override
public void populate(Chunk chunk, Random random) {
if (chunk.getY() != 4) {
return;
}
final World world = chunk.getWorld();
HEIGHTS.setSeed((int) world.getSeed() * 51);
final int x = chunk.getBlockX();
final int z = chunk.getBlockZ();
final double[][] heights = WorldGeneratorUtils.fastNoise(SNOW_HEIGHTS, 16, 16, 4, x, 0, z);
for (byte xx = 0; xx < 16; xx++) {
for (byte zz = 0; zz < 16; zz++) {
if (((VanillaBiome) world.getBiome(x + xx, 63, z + zz)).getClimate().hasSnowfall()) {
final int y = getHighestWorkableBlock(world, x + xx, z + zz);
if (y != -1 && ((VanillaBlockMaterial) world.getBlockMaterial(x + xx, y - 1, z + zz)).
canSupport(VanillaMaterials.SNOW, BlockFace.TOP)) {
// normalize [-1, 1] to [0, 1] then scale to [0, 7]
final short height = (short) GenericMath.floor((heights[xx][zz] * 0.5 + 0.5) * 7);
world.setBlockMaterial(x + xx, y, z + zz, Snow.SNOW[height], height, null);
}
}
}
}
}