Class BoundingBox3d

java.lang.Object
dev.ryanhcode.sable.companion.math.BoundingBox3d
All Implemented Interfaces:
BoundingBox3dc

public final class BoundingBox3d extends Object implements BoundingBox3dc
A bounding box with JOML interaction.
Since:
1.0.0
  • Field Details

    • EMPTY

      public static final BoundingBox3d EMPTY
    • CODEC

      public static com.mojang.serialization.Codec<BoundingBox3d> CODEC
    • minX

      public double minX
    • minY

      public double minY
    • minZ

      public double minZ
    • maxX

      public double maxX
    • maxY

      public double maxY
    • maxZ

      public double maxZ
  • Constructor Details

    • BoundingBox3d

      public BoundingBox3d(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
      Creates a new bounding box with the given values
    • BoundingBox3d

      public BoundingBox3d(BoundingBox3dc other)
      Creates a new bounding box with the given values
    • BoundingBox3d

      public BoundingBox3d(net.minecraft.world.phys.AABB other)
      Creates a new bounding box with the given values
    • BoundingBox3d

      public BoundingBox3d(net.minecraft.world.level.levelgen.structure.BoundingBox other)
      Creates a new bounding box with the given values
    • BoundingBox3d

      public BoundingBox3d(net.minecraft.core.BlockPos pos)
      Creates a new bounding box with the given values
    • BoundingBox3d

      public BoundingBox3d(BoundingBox3ic other)
      Creates a new bounding box with the given values
    • BoundingBox3d

      @ScheduledForRemoval(inVersion="2.0.0") @Deprecated public BoundingBox3d(net.minecraft.world.phys.Vec3 from, net.minecraft.world.phys.Vec3 to)
      Deprecated.
      Creates a new bounding box with the given values
    • BoundingBox3d

      public BoundingBox3d(net.minecraft.core.Position from, net.minecraft.core.Position to)
      Creates a new bounding box with the given values
      Since:
      1.2.0
    • BoundingBox3d

      public BoundingBox3d()
      Default constructor for an all-zero bounding box
  • Method Details

    • set

      @Contract(value="_->this", mutates="this") public BoundingBox3d set(BoundingBox3dc other)
      Sets the bounding box to the given values
    • set

      @Contract(value="_->this", mutates="this") public BoundingBox3d set(net.minecraft.world.phys.AABB other)
      Sets the bounding box to the given values
    • set

      @Contract(value="_,_,_,_,_,_->this", mutates="this") public BoundingBox3d set(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
      Sets the bounding box to the given values. Automatically swaps the values to ensure min values are less than max values.
    • setUnchecked

      @Contract(value="_,_,_,_,_,_->this", mutates="this") public BoundingBox3d setUnchecked(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
      Sets the bounding box to the given values.
      Does NOT automatically swap mins/maxes if swapped.
    • setUnchecked

      @Contract(value="_->this", mutates="this") public BoundingBox3d setUnchecked(BoundingBox3dc other)
      Sets the bounding box to the given values.
      Does NOT automatically swap mins/maxes if swapped.
    • expandTo

      @Contract(value="_->this", mutates="this") public BoundingBox3d expandTo(org.joml.Vector3dc point)
      Expands this box to include the given point
      Parameters:
      point - the point to include
      Returns:
      the result stored in dest
    • expandTo

      @Contract(value="_,_,_->this", mutates="this") public BoundingBox3d expandTo(double x, double y, double z)
      Expands this box to include the given point
      Parameters:
      x - the x value of the point
      y - the y value of the point
      z - the z value of the point
      Returns:
      this
    • expandTo

      @Contract(value="_->this", mutates="this") public BoundingBox3d expandTo(BoundingBox3dc other)
      Expands this box to include the given box
      Parameters:
      other - the box to include
      Returns:
      this
    • expand

      @Contract(value="_->this", mutates="this") public BoundingBox3d expand(double amount)
      Expands this box by the given amount on all sides
      Parameters:
      amount - the amount to expand by
      Returns:
      this
    • expand

      @Contract(value="_,_,_->this", mutates="this") public BoundingBox3d expand(double amountX, double amountY, double amountZ)
      Expands this box by the given amount on all sides
      Parameters:
      amountX - the amount to expand by in the x
      amountY - the amount to expand by in the y
      amountZ - the amount to expand by in the z
      Returns:
      this
    • move

      @Contract(value="_,_,_->this", mutates="this") public BoundingBox3d move(double amountX, double amountY, double amountZ)
      Moves this box by the given amount on all sides
      Parameters:
      amountX - The amount to move by in the x
      amountY - The amount to move by in the y
      amountZ - The amount to move by in the z
      Returns:
      this
    • intersect

      @Contract(value="_->this", mutates="this") public BoundingBox3d intersect(BoundingBox3dc box)
      Calculates the bounding box intersect between this box and the specified box.
      Parameters:
      box - The box to intersect with
      Returns:
      this
    • transform

      @Contract(value="_->this", mutates="this") public BoundingBox3d transform(Pose3dc pose)
      Transforms a bounding box by the given pose, picking the maximum bounds around the transformed corners and storing the result in this bounding box.
      Parameters:
      pose - the pose to transform by
      Returns:
      this
    • transform

      @Contract(value="_,_->this", mutates="this") public BoundingBox3d transform(Pose3dc pose, org.joml.Matrix4d bakedMatrix)
      Transforms a bounding box by the given pose, picking the maximum bounds around the transformed corners and storing the result in this bounding box.
      Parameters:
      pose - the pose to transform by
      Returns:
      this
    • transform

      @Contract(value="_->this", mutates="this") public BoundingBox3d transform(org.joml.Matrix4dc mpose)
      Transforms a bounding box by the given pose, picking the maximum bounds around the transformed corners and storing the result in this bounding box.
      Parameters:
      mpose - the pose to transform by
      Returns:
      this
    • transformInverse

      @Contract(value="_->this", mutates="this") public BoundingBox3d transformInverse(Pose3dc pose)
      Transforms a bounding box by the inverse of the given pose, picking the maximum bounds around the transformed corners and storing the result in this bounding box.
      Parameters:
      pose - the pose to transform by
      Returns:
      this
    • transformInverse

      @Contract(value="_,_->this", mutates="this") public BoundingBox3d transformInverse(Pose3dc pose, org.joml.Matrix4d bakedMatrix)
      Transforms a bounding box by the inverse of the given pose, picking the maximum bounds around the transformed corners and storing the result in this bounding box.
      Parameters:
      pose - the pose to transform by
      Returns:
      this
    • transformInverse

      @Contract(value="_->this", mutates="this") public BoundingBox3d transformInverse(org.joml.Matrix4dc mpose)
      Transforms a bounding box by the inverse of the given pose, picking the maximum bounds around the transformed corners and storing the result in this bounding box.
      Parameters:
      mpose - the pose to transform by
      Returns:
      this
    • minX

      public double minX()
      Specified by:
      minX in interface BoundingBox3dc
      Returns:
      the minimum x value of this box
    • minY

      public double minY()
      Specified by:
      minY in interface BoundingBox3dc
      Returns:
      the minimum y value of this box
    • minZ

      public double minZ()
      Specified by:
      minZ in interface BoundingBox3dc
      Returns:
      the minimum z value of this box
    • maxX

      public double maxX()
      Specified by:
      maxX in interface BoundingBox3dc
      Returns:
      the maximum x value of this box
    • maxY

      public double maxY()
      Specified by:
      maxY in interface BoundingBox3dc
      Returns:
      the maximum y value of this box
    • maxZ

      public double maxZ()
      Specified by:
      maxZ in interface BoundingBox3dc
      Returns:
      the maximum z value of this box