use of gregtech.api.util.PositionedRect in project GregTech by GregTechCE.
the class StonePileModelGenerator method generateCuboidList.
private static List<IndexedCuboid6> generateCuboidList(Random random) {
ArrayList<IndexedCuboid6> result = new ArrayList<>();
List<PositionedRect> occupiedAreas = new ArrayList<>();
int stonePlaceAttempts = 64;
int maxStones = 8;
int stonesPlaced = 0;
for (int i = 0; i < stonePlaceAttempts && stonesPlaced < maxStones; i++) {
int sizeX = 2 + random.nextInt(3);
int sizeZ = 2 + random.nextInt(3);
int stoneHeight = 4 + random.nextInt(4);
int posX = random.nextInt(16 - sizeX);
int posZ = random.nextInt(16 - sizeZ);
PositionedRect rect = new PositionedRect(new Position(posX, posZ), new Size(sizeX, sizeZ));
if (occupiedAreas.stream().noneMatch(rect::intersects)) {
Vector3 minVector = new Vector3(posX / 16.0, 0 / 16.0, posZ / 16.0);
Cuboid6 bounds = new Cuboid6(minVector, minVector.copy());
bounds.max.add(sizeX / 16.0, stoneHeight / 16.0, sizeZ / 16.0);
int brightness = 100 + random.nextInt(130);
result.add(new IndexedCuboid6(brightness, bounds));
occupiedAreas.add(rect);
stonesPlaced++;
}
}
return result;
}
Aggregations