}
private void generateRavineNodes(CuboidBlockMaterialBuffer blockData, Vector3f chunk, Vector3f target, double horizontalScale, double verticalScale,
double horizontalAngle, double verticalAngle, int startingNode, int nodeAmount, Random random) {
final Vector3f middle = new Vector3f(chunk.getX() + 8, 0, chunk.getZ() + 8);
double horizontalOffset = 0;
double verticalOffset = 0;
if (nodeAmount <= 0) {
final int size = (OVERLAP - 1) * 16;
nodeAmount = size - random.nextInt(size / 4);
}
final boolean lastNode;
if (startingNode == -1) {
startingNode = nodeAmount / 2;
lastNode = true;
} else {
lastNode = false;
}
final double[] horizontalScales = new double[128];
for (short y = 0; y < 128; y++) {
final double xzScale = y == 0 || random.nextInt(3) == 0 ? 1 + random.nextDouble() * random.nextDouble() : 1;
horizontalScales[y] = xzScale * xzScale;
}
for (; startingNode < nodeAmount; startingNode++) {
double horizontalSize = 1.5 + TrigMath.sin((float) (startingNode * Math.PI / nodeAmount)) * horizontalScale;
double verticalSize = horizontalSize * verticalScale;
target = target.add(Vector3f.createDirection((float) horizontalAngle, (float) verticalAngle));
horizontalSize *= random.nextDouble() * 0.25 + 0.75;
verticalSize *= random.nextDouble() * 0.25 + 0.75;
verticalAngle *= 0.7;
verticalAngle += verticalOffset * 0.05;
horizontalAngle += horizontalOffset * 0.05;
verticalOffset *= 0.8;
horizontalOffset *= 0.5;
verticalOffset += (random.nextDouble() - random.nextDouble()) * random.nextDouble() * 2;
horizontalOffset += (random.nextDouble() - random.nextDouble()) * random.nextDouble() * 4;
if (!lastNode && random.nextInt(4) == 0) {
continue;
}
final double xOffset = target.getX() - middle.getX();
final double zOffset = target.getZ() - middle.getZ();
final double nodesLeft = nodeAmount - startingNode;
final double offsetHorizontalScale = horizontalScale + 18;
if ((xOffset * xOffset + zOffset * zOffset) - nodesLeft * nodesLeft > offsetHorizontalScale * offsetHorizontalScale) {
return;
}
if (target.getX() < middle.getX() - 16 - horizontalSize * 2
|| target.getZ() < middle.getZ() - 16 - horizontalSize * 2
|| target.getX() > middle.getX() + 16 + horizontalSize * 2
|| target.getZ() > middle.getZ() + 16 + horizontalSize * 2) {
continue;
}
final Vector3f start = new Vector3f(GenericMath.floor(target.getX() - horizontalSize) - chunk.getFloorX() - 1,
GenericMath.floor(target.getY() - verticalSize) - 1, GenericMath.floor(target.getZ() - horizontalSize) - chunk.getFloorZ() - 1);
final Vector3f end = new Vector3f(GenericMath.floor(target.getX() + horizontalSize) - chunk.getFloorX() + 1,
GenericMath.floor(target.getY() + verticalSize) + 1, GenericMath.floor(target.getZ() + horizontalSize) - chunk.getFloorZ() + 1);
final RavineNode node = new RavineNode(blockData, chunk, start, end, target, verticalSize, horizontalSize, horizontalScales);
if (node.canPlace()) {
node.place();