Package net.minecraft.world.phys
Class AABB
java.lang.Object
net.minecraft.world.phys.AABB
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BlockHitResultprivate static DirectionclipPoint(double[] minDistance, Direction prevDirection, double distanceSide, double distanceOtherA, double distanceOtherB, double minSide, double minOtherA, double maxOtherA, double minOtherB, double maxOtherB, Direction hitSide, double startSide, double startOtherA, double startOtherB) booleancontains(double x, double y, double z) booleanReturns if the supplied Vec3D is completely inside the bounding boxcontract(double x, double y, double z) Creates a newthat has been contracted by the given amount, with positive changes decreasing max values and negative changes increasing min values.invalid reference
AxisAlignedBBdeflate(double value) Creates a newthat is expanded by the given value in all directions.invalid reference
AxisAlignedBBdeflate(double x, double y, double z) doubledistanceToSqr(Vec3 vec) static AABBencapsulatingFullBlocks(BlockPos startPos, BlockPos endPos) booleanexpandTowards(double x, double y, double z) Creates a newthat has been expanded by the given amount, with positive changes increasing max values and negative changes decreasing min values.invalid reference
AxisAlignedBBexpandTowards(Vec3 vector) private static DirectiongetDirection(AABB aabb, Vec3 start, double[] minDistance, Direction facing, double deltaX, double deltaY, double deltaZ) doublegetSize()doublegetXsize()doublegetYsize()doublegetZsize()inthashCode()booleanhasNaN()inflate(double value) Creates a newthat is expanded by the given value in all directions.invalid reference
AxisAlignedBBinflate(double x, double y, double z) Creates a newthat has been contracted by the given amount in both directions.invalid reference
AxisAlignedBBbooleanintersects(double x1, double y1, double z1, double x2, double y2, double z2) booleanintersects(AABB other) Checks if the bounding box intersects with another.booleanintersects(Vec3 min, Vec3 max) booleanReturns true if this AABB is infinite in all directions.doublemax(Direction.Axis axis) doublemin(Direction.Axis axis) move(double x, double y, double z) Offsets the current bounding box by the specified amount.move(org.joml.Vector3f vec) static AABBof(BoundingBox mutableBox) static AABBsetMaxX(double maxX) setMaxY(double maxY) setMaxZ(double maxZ) setMinX(double minX) setMinY(double minY) setMinZ(double minZ) toString()static AABBunitCubeFromLowerCorner(Vec3 vector)
-
Field Details
-
EPSILON
private static final double EPSILON- See Also:
-
INFINITE
-
minX
public final double minX -
minY
public final double minY -
minZ
public final double minZ -
maxX
public final double maxX -
maxY
public final double maxY -
maxZ
public final double maxZ
-
-
Constructor Details
-
AABB
public AABB(double x1, double y1, double z1, double x2, double y2, double z2) -
AABB
-
AABB
-
-
Method Details
-
of
-
unitCubeFromLowerCorner
-
encapsulatingFullBlocks
-
setMinX
-
setMinY
-
setMinZ
-
setMaxX
-
setMaxY
-
setMaxZ
-
min
-
max
-
equals
-
hashCode
public int hashCode() -
contract
Creates a newthat has been contracted by the given amount, with positive changes decreasing max values and negative changes increasing min values.invalid reference
AxisAlignedBB
If the amount to contract by is larger than the length of a side, then the side will wrap (still creating a valid AABB - see last sample).Samples:
Input Result new AxisAlignedBB(0, 0, 0, 4, 4, 4).contract(2, 2, 2)box[0.0, 0.0, 0.0 -> 2.0, 2.0, 2.0]
new AxisAlignedBB(0, 0, 0, 4, 4, 4).contract(-2, -2, -2)box[2.0, 2.0, 2.0 -> 4.0, 4.0, 4.0]
new AxisAlignedBB(5, 5, 5, 7, 7, 7).contract(0, 1, -1)box[5.0, 5.0, 6.0 -> 7.0, 6.0, 7.0]
new AxisAlignedBB(-2, -2, -2, 2, 2, 2).contract(4, -4, 0)box[-8.0, 2.0, -2.0 -> -2.0, 8.0, 2.0]
See Also:
-
- like this, except for expanding.
invalid reference
#expand(double, double, double) -
and
invalid reference
#grow(double, double, double)- expands in all directions.invalid reference
#grow(double) -
- contracts in all directions (like
invalid reference
#shrink(double))invalid reference
#grow(double)
- Returns:
- A new modified bounding box.
-
-
expandTowards
-
expandTowards
Creates a newthat has been expanded by the given amount, with positive changes increasing max values and negative changes decreasing min values.invalid reference
AxisAlignedBBSamples:
Input Result new AxisAlignedBB(0, 0, 0, 1, 1, 1).expand(2, 2, 2)box[0, 0, 0 -> 3, 3, 3]
new AxisAlignedBB(0, 0, 0, 1, 1, 1).expand(-2, -2, -2)box[-2, -2, -2 -> 1, 1, 1]
new AxisAlignedBB(5, 5, 5, 7, 7, 7).expand(0, 1, -1)box[5, 5, 4, 7, 8, 7]
See Also:
contract(double, double, double)- like this, except for shrinking.-
and
invalid reference
#grow(double, double, double)- expands in all directions.invalid reference
#grow(double) -
- contracts in all directions (like
invalid reference
#shrink(double))invalid reference
#grow(double)
- Returns:
- A modified bounding box that will always be equal or greater in volume to this bounding box.
-
inflate
Creates a newthat has been contracted by the given amount in both directions. Negative values will shrink the AABB instead of expanding it.invalid reference
AxisAlignedBB
Side lengths will be increased by 2 times the value of the parameters, since both min and max are changed.
If contracting and the amount to contract by is larger than the length of a side, then the side will wrap (still creating a valid AABB - see last ample).Samples:
Input Result new AxisAlignedBB(0, 0, 0, 1, 1, 1).grow(2, 2, 2)box[-2.0, -2.0, -2.0 -> 3.0, 3.0, 3.0]
new AxisAlignedBB(0, 0, 0, 6, 6, 6).grow(-2, -2, -2)box[2.0, 2.0, 2.0 -> 4.0, 4.0, 4.0]
new AxisAlignedBB(5, 5, 5, 7, 7, 7).grow(0, 1, -1)box[5.0, 4.0, 6.0 -> 7.0, 8.0, 6.0]
new AxisAlignedBB(1, 1, 1, 3, 3, 3).grow(-4, -2, -3)box[-1.0, 1.0, 0.0 -> 5.0, 3.0, 4.0]
See Also:
-
- expands in only one direction.
invalid reference
#expand(double, double, double) contract(double, double, double)- contracts in only one direction.-
- contracts in all directions
invalid reference
#shrink(double)
- version of this that expands in all directions from one parameter.invalid reference
#grow(double)- Returns:
- A modified bounding box.
-
-
inflate
Creates a newthat is expanded by the given value in all directions. Equivalent toinvalid reference
AxisAlignedBBwith the given value for all 3 params. Negative values will shrink the AABB.invalid reference
#grow(double, double, double)
Side lengths will be increased by 2 times the value of the parameter, since both min and max are changed.
If contracting and the amount to contract by is larger than the length of a side, then the side will wrap (still creating a valid AABB - see samples on).invalid reference
#grow(double, double, double)- Returns:
- A modified AABB.
-
intersect
-
minmax
-
move
Offsets the current bounding box by the specified amount. -
move
-
move
-
move
-
intersects
Checks if the bounding box intersects with another. -
intersects
public boolean intersects(double x1, double y1, double z1, double x2, double y2, double z2) -
intersects
-
contains
Returns if the supplied Vec3D is completely inside the bounding box -
contains
public boolean contains(double x, double y, double z) -
getSize
public double getSize() -
getXsize
public double getXsize() -
getYsize
public double getYsize() -
getZsize
public double getZsize() -
deflate
-
deflate
Creates a newthat is expanded by the given value in all directions. Equivalent toinvalid reference
AxisAlignedBBwith value set to the negative of the value provided here. Passing a negative value to this method values will grow the AABB.invalid reference
#grow(double)
Side lengths will be decreased by 2 times the value of the parameter, since both min and max are changed.
If contracting and the amount to contract by is larger than the length of a side, then the side will wrap (still creating a valid AABB - see samples on).invalid reference
#grow(double, double, double)- Returns:
- A modified AABB.
-
clip
-
clip
-
getDirection
-
clipPoint
@Nullable private static Direction clipPoint(double[] minDistance, @Nullable Direction prevDirection, double distanceSide, double distanceOtherA, double distanceOtherB, double minSide, double minOtherA, double maxOtherA, double minOtherB, double maxOtherB, Direction hitSide, double startSide, double startOtherA, double startOtherB) -
distanceToSqr
-
toString
-
hasNaN
public boolean hasNaN() -
getCenter
-
getBottomCenter
-
getMinPosition
-
getMaxPosition
-
ofSize
-
isInfinite
public boolean isInfinite()Returns true if this AABB is infinite in all directions.- Returns:
- true if this AABB is infinite in all directions
-