use of dev.frankheijden.insights.api.objects.chunk.ChunkCuboid in project Insights by InsightsPlugin.
the class Cuboid method toChunkParts.
/**
* Converts this cuboid into a List of ChunkParts.
*/
public List<ChunkPart> toChunkParts() {
ChunkVector minV = ChunkVector.from(this.min);
int minX = this.min.x >> 4;
int minZ = this.min.z >> 4;
ChunkVector maxV = ChunkVector.from(this.max);
int maxX = this.max.x >> 4;
int maxZ = this.max.z >> 4;
List<ChunkPart> parts = new ArrayList<>(maxX - minX + 1 + maxZ - minZ + 1);
for (int x = minX; x <= maxX; x++) {
int xmin = (x == minX) ? minV.getX() : 0;
int ymin = minV.getY();
int xmax = (x == maxX) ? maxV.getX() : 15;
for (int z = minZ; z <= maxZ; z++) {
int zmin = (z == minZ) ? minV.getZ() : 0;
int ymax = maxV.getY();
int zmax = (z == maxZ) ? maxV.getZ() : 15;
ChunkLocation loc = new ChunkLocation(world, x, z);
ChunkVector vmin = new ChunkVector(xmin, ymin, zmin);
ChunkVector vmax = new ChunkVector(xmax, ymax, zmax);
parts.add(new ChunkPart(loc, new ChunkCuboid(vmin, vmax)));
}
}
return parts;
}
Aggregations