MCPcopy Create free account
hub / github.com/Teneted/Tenet / intersection

Method intersection

src/main/java/org/bukkit/util/BoundingBox.java:647–658  ·  view source on GitHub ↗

Resizes this bounding box to represent the intersection of this and the given bounding box. @param other the other bounding box @return this bounding box (now representing the intersection) @throws IllegalArgumentException if the bounding boxes don't overlap

(@NotNull BoundingBox other)

Source from the content-addressed store, hash-verified

645 * @throws IllegalArgumentException if the bounding boxes don't overlap
646 */
647 @NotNull
648 public BoundingBox intersection(@NotNull BoundingBox other) {
649 Validate.notNull(other, "Other bounding box is null!");
650 Validate.isTrue(this.overlaps(other), "The bounding boxes do not overlap!");
651 double newMinX = Math.max(this.minX, other.minX);
652 double newMinY = Math.max(this.minY, other.minY);
653 double newMinZ = Math.max(this.minZ, other.minZ);
654 double newMaxX = Math.min(this.maxX, other.maxX);
655 double newMaxY = Math.min(this.maxY, other.maxY);
656 double newMaxZ = Math.min(this.maxZ, other.maxZ);
657 return this.resize(newMinX, newMinY, newMinZ, newMaxX, newMaxY, newMaxZ);
658 }
659
660 /**
661 * Shifts this bounding box by the given amounts.

Callers 1

createRegistryMethod · 0.80

Calls 2

overlapsMethod · 0.95
resizeMethod · 0.95

Tested by

no test coverage detected