java.lang.Object
net.minecraft.world.level.levelgen.structure.BoundingBox

public class BoundingBox extends Object
A simple three-dimensional mutable integer bounding box. Note that this box is both mutable, and has an implementation of hashCode() and equals(). This can be used as HashMap keys for example, if the user can ensure the instances themselves are not modified.
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • CODEC

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

      private int minX
    • minY

      private int minY
    • minZ

      private int minZ
    • maxX

      private int maxX
    • maxY

      private int maxY
    • maxZ

      private int maxZ
  • Constructor Details

    • BoundingBox

      public BoundingBox(BlockPos pos)
    • BoundingBox

      public BoundingBox(int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
  • Method Details

    • fromCorners

      public static BoundingBox fromCorners(Vec3i first, Vec3i second)
    • infinite

      public static BoundingBox infinite()
    • orientBox

      public static BoundingBox orientBox(int structureMinX, int structureMinY, int structureMinZ, int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, Direction facing)
      Create a bounding box with the specified dimensions and rotate it. Used to project a possible new component Bounding Box - to check if it would cut anything already spawned.
    • intersectingChunks

      public Stream<ChunkPos> intersectingChunks()
    • intersects

      public boolean intersects(BoundingBox box)
      Returns:
      true if box intersects this box.
    • intersects

      public boolean intersects(int minX, int minZ, int maxX, int maxZ)
      Returns:
      true if this bounding box intersects the horizontal x/z region described by the min and max parameters.
    • encapsulatingPositions

      public static Optional<BoundingBox> encapsulatingPositions(Iterable<BlockPos> positions)
    • encapsulatingBoxes

      public static Optional<BoundingBox> encapsulatingBoxes(Iterable<BoundingBox> boxes)
    • encapsulate

      @Deprecated public BoundingBox encapsulate(BoundingBox box)
      Deprecated.
      Expands this box to be at least large enough to contain box.
    • encapsulate

      @Deprecated public BoundingBox encapsulate(BlockPos pos)
      Deprecated.
      Expands this box to be at least large enough to contain pos.
    • move

      @Deprecated public BoundingBox move(int x, int y, int z)
      Deprecated.
      Translates this box by the given coordinates, modifying the current box.
    • move

      @Deprecated public BoundingBox move(Vec3i vector)
      Deprecated.
      Translates this box by the given vector, modifying the current box.
    • moved

      public BoundingBox moved(int x, int y, int z)
      Returns:
      A new bounding box equal to this box, translated by the given coordinates.
    • inflatedBy

      public BoundingBox inflatedBy(int value)
      Expands this box by a fixed value in all directions.
    • inflatedBy

      public BoundingBox inflatedBy(int x, int y, int z)
    • isInside

      public boolean isInside(Vec3i vector)
      Returns:
      true if the bounding box contains the vector.
    • isInside

      public boolean isInside(int x, int y, int z)
    • getLength

      public Vec3i getLength()
    • getXSpan

      public int getXSpan()
    • getYSpan

      public int getYSpan()
    • getZSpan

      public int getZSpan()
    • getCenter

      public BlockPos getCenter()
    • forAllCorners

      public void forAllCorners(Consumer<BlockPos> pos)
    • toString

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

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

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

      public int minX()
    • minY

      public int minY()
    • minZ

      public int minZ()
    • maxX

      public int maxX()
    • maxY

      public int maxY()
    • maxZ

      public int maxZ()