if (region.containsBlock(x, y, z)) {
if (weather.isSnowingAt(x, y, z)) {
//Try to find the surface
for (int dy = 1; dy < 16; dy++) {
if (region.containsBlock(x, y - dy, z)) {
Block block = region.getBlock(x, y - dy, z);
BlockMaterial mat = block.getMaterial();
if (mat instanceof VanillaBlockMaterial) {
VanillaBlockMaterial vbm = (VanillaBlockMaterial) mat;
//Place snow ontop of solid
if (vbm.canSupport(VanillaMaterials.SNOW, BlockFace.TOP)) {
Block above = block.translate(BlockFace.TOP);
if (!VanillaMaterials.SNOW.willMeltAt(above)) {
above.setMaterial(VanillaMaterials.SNOW);
}
return;
//Try to grow snow
} else if (vbm instanceof Snow) {
short data = block.getBlockData();
if (data == 0x7) {
Block above = block.translate(BlockFace.TOP);
if (above.getMaterial() == BlockMaterial.AIR) {
above.setMaterial(VanillaMaterials.SNOW);
}
} else {
block.setData(data + 1);
}
return;