for (byte count = 0; count < groupsPerLayer; count++) {
final float scale = widthScale * layerSize * (random.nextFloat() + 0.328f);
Vector2f randomOffset = Vector2f.createRandomDirection(random).mul(scale);
final int groupX = (int) (randomOffset.getX() + x + 0.5);
final int groupZ = (int) (randomOffset.getY() + z + 0.5);
final Point group = new Point(world, groupX, groupY, groupZ);
if (getAvailableBlockSpace(group, group.add(0, leafDistanceLimit, 0)) != -1) {
continue;
}
final byte xOff = (byte) (x - groupX);
final byte zOff = (byte) (z - groupZ);
final float horizontalDistanceToTrunk = (float) Math.sqrt(xOff * xOff + zOff * zOff);
final float verticalDistanceToTrunk = horizontalDistanceToTrunk * branchSlope;
final int base;
final int yDiff = (int) (groupY - verticalDistanceToTrunk);
if (yDiff > trunkTopY) {
base = trunkTopY;
} else {
base = yDiff;
}
if (getAvailableBlockSpace(new Point(world, x, base, z), group) == -1) {
groups.add(new PointBase(group, base));
}
}
groupY--;
}