Class CuboidRegion

All Implemented Interfaces:
Cloneable

public class CuboidRegion extends Overlappable
Represents a cuboid region in a world
  • Field Details

    • start

      protected org.bukkit.Location start
    • end

      protected org.bukkit.Location end
  • Constructor Details

    • CuboidRegion

      public CuboidRegion(org.bukkit.Location start, org.bukkit.Location end)
      Construct a Region using 2 corners
      Parameters:
      start - The first corner
      end - The second corner
    • CuboidRegion

      protected CuboidRegion()
  • Method Details

    • cubeRadius

      public static CuboidRegion cubeRadius(org.bukkit.Location loc, int radius)
      Gets a Region covering a cubic radius centered around a Location
      Parameters:
      loc - The center
      radius - The block radius
      Returns:
      A Region covering the specified radius
    • setLocations

      protected void setLocations(org.bukkit.Location start, org.bukkit.Location end)
    • getStart

      public org.bukkit.Location getStart()
      Get the minimum corner of this Region
      Specified by:
      getStart in class Region
      Returns:
      The corner with the lowest X, Y, and Z values
    • getEnd

      public org.bukkit.Location getEnd()
      Get the maximum corner of this Region
      Specified by:
      getEnd in class Region
      Returns:
      The corner with the highest X, Y, and Z values
    • contains

      public boolean contains(org.bukkit.Location loc)
      Check whether a location is inside this Region
      Specified by:
      contains in class Region
      Parameters:
      loc - The location to check
      Returns:
      Whether this Region contains the given Location
    • getVolume

      public double getVolume()
      Specified by:
      getVolume in class Region
      Returns:
      The volume of this Region, in cubic meters
    • getBlockVolume

      public int getBlockVolume()
      Specified by:
      getBlockVolume in class Region
      Returns:
      The volume of this Region, in blocks
    • getState

      public CuboidRegion.RegionState getState()
      Gets the current state of this Region
      Returns:
      The state of this Region
    • clone

      public CuboidRegion clone()
      Clones this Region
      Specified by:
      clone in class Region
      Returns:
      A clone of this Region
    • expand

      public CuboidRegion expand(double amount)
      Expands the region in all directions, or retracts if negative. If this is a MultiRegion, makes 6 calls to MultiRegion.expand(BlockFace, double), meaning it is very expensive. Check if this is a MultiRegion before expanding.
      Parameters:
      amount - The amount to expand the region by
      Returns:
      Itself
    • expand

      public CuboidRegion expand(double posX, double negX, double posY, double negY, double posZ, double negZ)
      Expands the region, or retracts where negative values are passed
      Specified by:
      expand in class Region
      Parameters:
      posX - The amount to expand the region in the positive X direction
      negX - The amount to expand the region in the negative X direction
      posY - The amount to expand the region in the positive Y direction
      negY - The amount to expand the region in the negative Y direction
      posZ - The amount to expand the region in the positive Z direction
      negZ - The amount to expand the region in the negative Z direction
      Returns:
      Itself
    • expand

      public CuboidRegion expand(org.bukkit.block.BlockFace direction, double amount)
      Expand the region in a given direction, or retracts if negative.
      Specified by:
      expand in class Region
      Parameters:
      direction - The direction to expand the region in
      amount - The amount to expand the region in the given direction
      Returns:
      Itself
    • move

      public CuboidRegion move(org.bukkit.util.Vector v)
      Move the region
      Specified by:
      move in class Region
      Parameters:
      v - The vector to be applied to both corners of the region
      Returns:
      Itself
    • move

      public CuboidRegion move(double x, double y, double z)
      Specified by:
      move in class Region
    • setWorld

      public CuboidRegion setWorld(org.bukkit.World world)
      Set the world of this region, while keeping the coordinates the same
      Specified by:
      setWorld in class Region
      Parameters:
      world - The world to set
      Returns:
      Itself
    • isMulti

      public boolean isMulti()
      Returns:
      Whether this Region is a non-cuboid variant
    • forEachBlock

      public void forEachBlock(Consumer<org.bukkit.block.Block> lambda)
      Run a lambda on every Block in this Region
      Overrides:
      forEachBlock in class Region
      Parameters:
      lambda - The lambda to be run on each Block
    • getWorld

      public org.bukkit.World getWorld()
      Overrides:
      getWorld in class Region
      Returns:
      The World this Region is in
    • overlaps

      public boolean overlaps(Overlappable overlap)
      Check if this Region overlaps with another.
      Specified by:
      overlaps in class Overlappable
      Parameters:
      overlap - The Overlappable Region to check against
      Returns:
      Whether this Region overlaps with the given Region
    • rotate

      public CuboidRegion rotate(org.bukkit.Location center, int rotations)
      Rotates this Region around a point
      Specified by:
      rotate in class Region
      Parameters:
      center - The point to rotate this Region around
      rotations - The number of clockwise rotations to apply
      Returns:
      Itself
    • rotate

      public CuboidRegion rotate(int rotations)
      Rotates this Region around its center
      Parameters:
      rotations - The number of clockwise rotations to apply
      Returns:
      Itself
    • getIntersection

      public Region getIntersection(Overlappable overlap)
      Gets the cuboid intersection of this Region and another cuboid Region
      Specified by:
      getIntersection in class Overlappable
      Parameters:
      overlap - The Region to get the intersection with
      Returns:
      The intersection Region, or null if there is no intersection
    • stream

      public Stream<org.bukkit.block.Block> stream()
      Description copied from class: Region
      Streams all Blocks inside this Region
      Specified by:
      stream in class Region
      Returns:
      A Stream of all the blocks in this Region
    • getFace

      public CuboidRegion getFace(org.bukkit.block.BlockFace face)
      Gets a CuboidRegion representing a 1-block thick slice on a face of this Region
      Parameters:
      face - The face to get a slice of
      Returns:
      A CuboidRegion representing a slice of the given face
    • toString

      public String toString()
      Converts this Region to a String which can be converted back with fromString(String) later
      Overrides:
      toString in class Object
      Returns:
      The String representation of this Region
    • fromString

      public static CuboidRegion fromString(String input)
      Converts a String generated by toString() back to a Region
      Parameters:
      input - The String representation of a Region
      Returns:
      The Region