@Override
public void generateChunk(CoreChunk chunk, Region chunkRegion) {
DensityFacet solidityFacet = chunkRegion.getFacet(DensityFacet.class);
SurfaceHeightFacet surfaceFacet = chunkRegion.getFacet(SurfaceHeightFacet.class);
BiomeFacet biomeFacet = chunkRegion.getFacet(BiomeFacet.class);
Vector2i pos2d = new Vector2i();
for (Vector3i pos : ChunkConstants.CHUNK_REGION) {
pos2d.set(pos.x, pos.z);
CoreBiome biome = biomeFacet.get(pos2d);
chunk.setBiome(pos.x, pos.y, pos.z, biome);
float density = solidityFacet.get(pos);
if (density >= 32) {
chunk.setBlock(pos, stone);
} else if (density >= 0) {
int depth = TeraMath.floorToInt(surfaceFacet.get(pos2d)) - pos.y - chunk.getChunkWorldOffsetY();
Block block = getSurfaceBlock(depth, pos.y + chunk.getChunkWorldOffsetY(), biome);
chunk.setBlock(pos, block);
} else {
int posY = pos.y + chunk.getChunkWorldOffsetY();
if (posY == 32 && CoreBiome.SNOW == biomeFacet.get(pos2d)) {
chunk.setBlock(pos, ice);
} else if (posY <= 32) {
chunk.setBlock(pos, water);
}
}