Package net.minecraft.util.math
Class Box
java.lang.Object
net.minecraft.util.math.Box
public class Box extends Object
An immutable box with double-valued coordinates. The box is axis-aligned
and the coordinates are minimum inclusive and maximum exclusive.
This box has proper hashCode() and equals(Object)
implementations and can be used as a map key.
- See Also:
BlockBox
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Box(double x1, double y1, double z1, double x2, double y2, double z2)Creates a box of the given positions as corners.Box(BlockPos pos)Creates a box that only contains the given block position.Box(BlockPos pos1, BlockPos pos2)Creates a box of the given positions as corners.Box(Vec3d pos1, Vec3d pos2)Creates a box of the given positions as corners. -
Method Summary
Modifier and Type Method Description booleancontains(double x, double y, double z)Checks if the given position is in this box.booleancontains(Vec3d pos)Checks if the given position is in this box.Boxcontract(double value)booleanequals(Object o)Boxexpand(double value)Boxexpand(double x, double y, double z)static Boxfrom(BlockBox mutable)doublegetAverageSideLength()Vec3dgetCenter()Returns the center position of this box.doublegetMax(Direction.Axis axis)doublegetMin(Direction.Axis axis)doublegetXLength()doublegetYLength()doublegetZLength()inthashCode()Boxintersection(Box box)Creates the maximum box that this box and the given box contain.booleanintersects(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)Checks if this box intersects the box of the given coordinates.booleanintersects(Box box)Checks if this box intersects the given box.booleanintersects(Vec3d pos1, Vec3d pos2)Checks if this box intersects the box of the given positions as corners.booleanisValid()Checks if any of the coordinates of this box is not a number.static Boxmethod_29968(Vec3d vec3d)static Boxmethod_30048(double double2, double double3, double double4)Boxoffset(double x, double y, double z)Creates a box that is translated byx,y,zon each axis from this box.Boxoffset(BlockPos blockPos)Creates a box that is translated byblockPos.getX(),blockPos.getY(),blockPos.getZ()on each axis from this box.Boxoffset(Vec3d vec)Creates a box that is translated byvec.x,vec.y,vec.zon each axis from this box.static BlockHitResultraycast(Iterable<Box> boxes, Vec3d from, Vec3d to, BlockPos pos)Optional<Vec3d>raycast(Vec3d min, Vec3d max)Boxshrink(double x, double y, double z)Boxstretch(double x, double y, double z)Boxstretch(Vec3d scale)StringtoString()private static DirectiontraceCollisionSide(double[] traceDistanceResult, Direction approachDirection, double deltaX, double deltaY, double deltaZ, double begin, double minX, double maxX, double minZ, double maxZ, Direction resultDirection, double startX, double startY, double startZ)private static DirectiontraceCollisionSide(Box box, Vec3d intersectingVector, double[] traceDistanceResult, Direction approachDirection, double deltaX, double deltaY, double deltaZ)Boxunion(Box box)Creates the minimum box that contains this box and the given box.
-
Field Details
-
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
-
Box
public Box(double x1, double y1, double z1, double x2, double y2, double z2)Creates a box of the given positions as corners. -
Box
Creates a box that only contains the given block position. -
Box
Creates a box of the given positions as corners. -
Box
Creates a box of the given positions as corners.
-
-
Method Details
-
from
-
method_29968
-
getMin
-
getMax
-
equals
-
hashCode
public int hashCode() -
shrink
-
stretch
-
stretch
-
expand
-
expand
- See Also:
contract(double)
-
intersection
Creates the maximum box that this box and the given box contain. -
union
Creates the minimum box that contains this box and the given box. -
offset
Creates a box that is translated byx,y,zon each axis from this box. -
offset
Creates a box that is translated byblockPos.getX(),blockPos.getY(),blockPos.getZ()on each axis from this box.- See Also:
offset(double, double, double)
-
offset
Creates a box that is translated byvec.x,vec.y,vec.zon each axis from this box.- See Also:
offset(double, double, double)
-
intersects
Checks if this box intersects the given box. -
intersects
public boolean intersects(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)Checks if this box intersects the box of the given coordinates. -
intersects
Checks if this box intersects the box of the given positions as corners. -
contains
Checks if the given position is in this box. -
contains
public boolean contains(double x, double y, double z)Checks if the given position is in this box. -
getAverageSideLength
public double getAverageSideLength() -
getXLength
public double getXLength() -
getYLength
public double getYLength() -
getZLength
public double getZLength() -
contract
- See Also:
expand(double)
-
raycast
-
raycast
-
traceCollisionSide
-
traceCollisionSide
@Nullable private static Direction traceCollisionSide(double[] traceDistanceResult, @Nullable Direction approachDirection, double deltaX, double deltaY, double deltaZ, double begin, double minX, double maxX, double minZ, double maxZ, Direction resultDirection, double startX, double startY, double startZ) -
toString
-
isValid
@Environment(CLIENT) public boolean isValid()Checks if any of the coordinates of this box is not a number. -
getCenter
Returns the center position of this box. -
method_30048
-