noiseTable = new NoiseTable(seed);
}
@Override
public void process(GeneratingRegion region) {
PlantFacet facet = new PlantFacet(region.getRegion(), region.getBorderForFacet(PlantFacet.class));
SurfaceHeightFacet surface = region.getRegionFacet(SurfaceHeightFacet.class);
DensityFacet density = region.getRegionFacet(DensityFacet.class);
BiomeFacet biomeFacet = region.getRegionFacet(BiomeFacet.class);
int minY = facet.getWorldRegion().minY();
int maxY = facet.getWorldRegion().maxY();
for (int z = facet.getRelativeRegion().minZ(); z <= facet.getRelativeRegion().maxZ(); ++z) {
for (int x = facet.getRelativeRegion().minX(); x <= facet.getRelativeRegion().maxX(); ++x) {
int height = TeraMath.floorToInt(surface.get(x, z));
if (height >= minY && height < maxY) {
CoreBiome biome = biomeFacet.get(x, z);
height = height - minY + facet.getRelativeRegion().minY();
if ((biome == CoreBiome.FOREST || biome == CoreBiome.PLAINS) && density.get(x, height, z) > 0
&& density.get(x, height + 1, z) <= 0 && noiseTable.noise(x, z) < configuration.density) {
facet.set(x, height + 1, z, true);
}
}
}
}
region.setRegionFacet(PlantFacet.class, facet);