Class CuboidRegion

All Implemented Interfaces:
IBatchProcessor, FlatRegion, Region, Cloneable, Iterable<BlockVector3>, Collection<BlockVector3>, Set<BlockVector3>
Direct Known Subclasses:
RegionWrapper

public class CuboidRegion extends AbstractRegion implements FlatRegion
An axis-aligned cuboid. It can be defined using two corners of the cuboid.
  • Constructor Details

    • CuboidRegion

      public CuboidRegion(BlockVector3 pos1, BlockVector3 pos2)
      Construct a new instance of this cuboid using two corners of the cuboid.
      Parameters:
      pos1 - the first position
      pos2 - the second position
    • CuboidRegion

      public CuboidRegion(World world, BlockVector3 pos1, BlockVector3 pos2)
      Construct a new instance of this cuboid using two corners of the cuboid.
      Parameters:
      world - the world
      pos1 - the first position
      pos2 - the second position
    • CuboidRegion

      public CuboidRegion(World world, BlockVector3 pos1, BlockVector3 pos2, boolean clampY)
      Construct a new instance of this cuboid using two corners of the cuboid.
      Parameters:
      world - the world
      pos1 - the first position
      pos2 - the second position
      clampY - if the min/max Y of the region should be clamped to the world
      Since:
      2.1.0
  • Method Details

    • getPos1

      public BlockVector3 getPos1()
      Get the first cuboid-defining corner.
      Returns:
      a position
    • setPos1

      public void setPos1(BlockVector3 pos1)
      Set the first cuboid-defining corner.
      Parameters:
      pos1 - a position
    • getPos2

      public BlockVector3 getPos2()
      Get the second cuboid-defining corner.
      Returns:
      a position
    • setPos2

      public void setPos2(BlockVector3 pos2)
      Set the second cuboid-defining corner.
      Parameters:
      pos2 - a position
    • recalculate

      protected void recalculate()
      Sets the cached min and max x/y/z and clamps Y to world y min/max
    • recalculateNoClamp

      protected void recalculateNoClamp()
      Sets the cached min and max x/y/z
    • getFaces

      public RegionIntersection getFaces()
      Get a region that contains the faces of this cuboid.
      Returns:
      a new complex region
    • getWalls

      public RegionIntersection getWalls()
      Get a region that contains the walls (all faces but the ones parallel to the X-Z plane) of this cuboid.
      Returns:
      a new complex region
    • getMinimumPoint

      public BlockVector3 getMinimumPoint()
      Description copied from interface: Region
      Get the lower point of a region.
      Specified by:
      getMinimumPoint in interface Region
      Returns:
      min. point
    • getMaximumPoint

      public BlockVector3 getMaximumPoint()
      Description copied from interface: Region
      Get the upper point of a region.
      Specified by:
      getMaximumPoint in interface Region
      Returns:
      max. point
    • getMinimumY

      public int getMinimumY()
      Description copied from interface: FlatRegion
      Gets the minimum Y value.
      Specified by:
      getMinimumY in interface FlatRegion
      Specified by:
      getMinimumY in interface Region
      Returns:
      the Y value
    • getMaximumY

      public int getMaximumY()
      Description copied from interface: FlatRegion
      Gets the maximum Y value.
      Specified by:
      getMaximumY in interface FlatRegion
      Specified by:
      getMaximumY in interface Region
      Returns:
      the Y value
    • expand

      public void expand(BlockVector3... changes)
      Description copied from interface: Region
      Expand the region.
      Specified by:
      expand in interface Region
      Parameters:
      changes - array/arguments with multiple related changes
    • contract

      public void contract(BlockVector3... changes)
      Description copied from interface: Region
      Contract the region.
      Specified by:
      contract in interface Region
      Parameters:
      changes - array/arguments with multiple related changes
    • shift

      public void shift(BlockVector3 change) throws RegionOperationException
      Description copied from interface: Region
      Shift the region.
      Specified by:
      shift in interface Region
      Overrides:
      shift in class AbstractRegion
      Parameters:
      change - the change
      Throws:
      RegionOperationException - if the operation cannot be performed
    • getChunks

      public Set<BlockVector2> getChunks()
      Description copied from class: AbstractRegion
      Get a list of chunks.
      Specified by:
      getChunks in interface Region
      Overrides:
      getChunks in class AbstractRegion
      Returns:
      a set of chunks
    • getChunkCubes

      public Set<BlockVector3> getChunkCubes()
      Description copied from interface: Region
      Return a list of 16*16*16 chunks in a region.
      Specified by:
      getChunkCubes in interface Region
      Overrides:
      getChunkCubes in class AbstractRegion
      Returns:
      the chunk cubes this region overlaps with
    • contains

      public boolean contains(BlockVector3 position)
      Description copied from interface: Region
      Returns true based on whether the region contains the point.
      Specified by:
      contains in interface Region
      Parameters:
      position - the position
      Returns:
      true if contained
    • contains

      public boolean contains(int x, int y, int z)
      Specified by:
      contains in interface Region
    • contains

      public boolean contains(int x, int z)
      Specified by:
      contains in interface Region
    • iterator

      public Iterator<BlockVector3> iterator()
      Description copied from class: AbstractRegion
      Get the iterator.
      Specified by:
      iterator in interface Collection<BlockVector3>
      Specified by:
      iterator in interface Iterable<BlockVector3>
      Specified by:
      iterator in interface Set<BlockVector3>
      Overrides:
      iterator in class AbstractRegion
      Returns:
      iterator of points inside the region
    • iterator_old

      public Iterator<BlockVector3> iterator_old()
    • asFlatRegion

      public Iterable<BlockVector2> asFlatRegion()
      Description copied from interface: FlatRegion
      Get this region as an iterable flat region.
      Specified by:
      asFlatRegion in interface FlatRegion
      Returns:
      a flat region iterable
    • toString

      public String toString()
      Overrides:
      toString in class AbstractCollection<BlockVector3>
    • clone

      public CuboidRegion clone()
      Description copied from interface: Region
      Make a clone of the region.
      Specified by:
      clone in interface Region
      Overrides:
      clone in class AbstractRegion
      Returns:
      a cloned version
    • makeCuboid

      public static CuboidRegion makeCuboid(Region region)
      Make a cuboid region out of the given region using the minimum and maximum bounds of the provided region.
      Parameters:
      region - the region
      Returns:
      a new cuboid region
    • contains

      public static boolean contains(CuboidRegion region)
    • fromCenter

      public static CuboidRegion fromCenter(BlockVector3 origin, int apothem)
      Make a cuboid from the center.
      Parameters:
      origin - the origin
      apothem - the apothem, where 0 is the minimum value to make a 1x1 cuboid
      Returns:
      a cuboid region
    • getMinimumX

      public int getMinimumX()
    • getMinimumZ

      public int getMinimumZ()
    • getMaximumX

      public int getMaximumX()
    • getMaximumZ

      public int getMaximumZ()
    • filter

      public void filter(IChunk chunk, Filter filter, ChunkFilterBlock block, IChunkGet get, IChunkSet set, boolean full)
      Specified by:
      filter in interface Region
    • processSet

      public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set)
      Description copied from interface: IBatchProcessor
      Process a chunk that has been set.
      Specified by:
      processSet in interface IBatchProcessor
      Specified by:
      processSet in interface Region
    • processSet

      public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set, boolean asBlacklist)
      Description copied from interface: Region
      Process the chunk, with the option to process as if the region is a blacklisted region, and thus any contained blocks should be removed, rather than uncontained blocks being removed.
      Specified by:
      processSet in interface Region
      asBlacklist - If any blocks contained by the region should be removed