MCPcopy Index your code
hub / github.com/PaperMC/Paper / expand

Method expand

paper-api/src/main/java/org/bukkit/util/BoundingBox.java:371–418  ·  view source on GitHub ↗

Expands this bounding box by the given values in the corresponding directions. Negative values will shrink the bounding box in the corresponding direction. Shrinking will be limited to the point where the affected opposite faces would meet if they shrank at uniform speeds. @param negativeX the

(double negativeX, double negativeY, double negativeZ, double positiveX, double positiveY, double positiveZ)

Source from the content-addressed store, hash-verified

369 * @return this bounding box (now expanded)
370 */
371 @NotNull
372 public BoundingBox expand(double negativeX, double negativeY, double negativeZ, double positiveX, double positiveY, double positiveZ) {
373 if (negativeX == 0.0D && negativeY == 0.0D && negativeZ == 0.0D && positiveX == 0.0D && positiveY == 0.0D && positiveZ == 0.0D) {
374 return this;
375 }
376 double newMinX = this.minX - negativeX;
377 double newMinY = this.minY - negativeY;
378 double newMinZ = this.minZ - negativeZ;
379 double newMaxX = this.maxX + positiveX;
380 double newMaxY = this.maxY + positiveY;
381 double newMaxZ = this.maxZ + positiveZ;
382
383 // limit shrinking:
384 if (newMinX > newMaxX) {
385 double centerX = this.getCenterX();
386 if (newMaxX >= centerX) {
387 newMinX = newMaxX;
388 } else if (newMinX <= centerX) {
389 newMaxX = newMinX;
390 } else {
391 newMinX = centerX;
392 newMaxX = centerX;
393 }
394 }
395 if (newMinY > newMaxY) {
396 double centerY = this.getCenterY();
397 if (newMaxY >= centerY) {
398 newMinY = newMaxY;
399 } else if (newMinY <= centerY) {
400 newMaxY = newMinY;
401 } else {
402 newMinY = centerY;
403 newMaxY = centerY;
404 }
405 }
406 if (newMinZ > newMaxZ) {
407 double centerZ = this.getCenterZ();
408 if (newMaxZ >= centerZ) {
409 newMinZ = newMaxZ;
410 } else if (newMinZ <= centerZ) {
411 newMaxZ = newMinZ;
412 } else {
413 newMinZ = centerZ;
414 newMaxZ = centerZ;
415 }
416 }
417 return this.resize(newMinX, newMinY, newMinZ, newMaxX, newMaxY, newMaxZ);
418 }
419
420 /**
421 * Expands this bounding box uniformly by the given values in both positive

Callers 3

expandDirectionalMethod · 0.95
testExpansionMethod · 0.80
rayTraceEntitiesMethod · 0.80

Calls 8

getCenterXMethod · 0.95
getCenterYMethod · 0.95
getCenterZMethod · 0.95
resizeMethod · 0.95
getXMethod · 0.65
getYMethod · 0.65
getZMethod · 0.65
getDirectionMethod · 0.65

Tested by 1

testExpansionMethod · 0.64