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 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

      public Box​(BlockPos pos)
      Creates a box that only contains the given block position.
    • Box

      public Box​(BlockPos pos1, BlockPos pos2)
      Creates a box of the given positions as corners.
    • Box

      public Box​(Vec3d pos1, Vec3d pos2)
      Creates a box of the given positions as corners.
  • Method Details

    • from

      public static Box from​(BlockBox mutable)
    • method_29968

      public static Box method_29968​(Vec3d vec3d)
    • getMin

      public double getMin​(Direction.Axis axis)
    • getMax

      public double getMax​(Direction.Axis axis)
    • equals

      public boolean equals​(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • shrink

      public Box shrink​(double x, double y, double z)
    • stretch

      public Box stretch​(Vec3d scale)
    • stretch

      public Box stretch​(double x, double y, double z)
    • expand

      public Box expand​(double x, double y, double z)
    • expand

      public Box expand​(double value)
      See Also:
      contract(double)
    • intersection

      public Box intersection​(Box box)
      Creates the maximum box that this box and the given box contain.
    • union

      public Box union​(Box box)
      Creates the minimum box that contains this box and the given box.
    • offset

      public Box offset​(double x, double y, double z)
      Creates a box that is translated by x, y, z on each axis from this box.
    • offset

      public Box offset​(BlockPos blockPos)
      Creates a box that is translated by blockPos.getX(), blockPos.getY(), blockPos.getZ() on each axis from this box.
      See Also:
      offset(double, double, double)
    • offset

      public Box offset​(Vec3d vec)
      Creates a box that is translated by vec.x, vec.y, vec.z on each axis from this box.
      See Also:
      offset(double, double, double)
    • intersects

      public boolean intersects​(Box box)
      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

      @Environment(CLIENT) public boolean intersects​(Vec3d pos1, Vec3d pos2)
      Checks if this box intersects the box of the given positions as corners.
    • contains

      public boolean contains​(Vec3d pos)
      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

      public Box contract​(double value)
      See Also:
      expand(double)
    • raycast

      public Optional<Vec3d> raycast​(Vec3d min, Vec3d max)
    • raycast

      @Nullable public static BlockHitResult raycast​(Iterable<Box> boxes, Vec3d from, Vec3d to, BlockPos pos)
    • traceCollisionSide

      @Nullable private static Direction traceCollisionSide​(Box box, Vec3d intersectingVector, double[] traceDistanceResult, @Nullable Direction approachDirection, double deltaX, double deltaY, double deltaZ)
    • 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

      public String toString()
      Overrides:
      toString in class Object
    • isValid

      @Environment(CLIENT) public boolean isValid()
      Checks if any of the coordinates of this box is not a number.
    • getCenter

      public Vec3d getCenter()
      Returns the center position of this box.
    • method_30048

      public static Box method_30048​(double double2, double double3, double double4)