Class CylinderRegion

All Implemented Interfaces:
IBatchProcessor, FlatRegion, Region, Cloneable, Iterable<BlockVector3>, Collection<BlockVector3>, Set<BlockVector3>

public class CylinderRegion extends AbstractRegion implements FlatRegion
Represents a cylindrical region.
  • Constructor Details

    • CylinderRegion

      public CylinderRegion()
      Construct the region.
    • CylinderRegion

      public CylinderRegion(World world)
      Construct the region.
      Parameters:
      world - the world
    • CylinderRegion

      public CylinderRegion(World world, BlockVector3 center, Vector2 radius, int minY, int maxY)
      Construct the region.
      Parameters:
      world - the world
      center - the center position
      radius - the radius along the X and Z axes
      minY - the minimum Y, inclusive
      maxY - the maximum Y, inclusive
    • CylinderRegion

      public CylinderRegion(BlockVector3 center, Vector2 radius, int minY, int maxY)
      Construct the region.
      Parameters:
      center - the center position
      radius - the radius along the X and Z axes
      minY - the minimum Y, inclusive
      maxY - the maximum Y, inclusive
    • CylinderRegion

      public CylinderRegion(CylinderRegion region)
  • Method Details

    • getCenter

      public Vector3 getCenter()
      Description copied from interface: Region
      Get the center point of a region. Note: Coordinates will not be integers if the corresponding lengths are even.
      Specified by:
      getCenter in interface Region
      Overrides:
      getCenter in class AbstractRegion
      Returns:
      center point
    • setCenter

      public void setCenter(BlockVector2 center)
      Sets the main center point of the region.
      Parameters:
      center - the center point
    • getRadius

      public Vector2 getRadius()
      Returns the radius of the cylinder.
      Returns:
      the radius along the X and Z axes
    • setRadius

      public void setRadius(Vector2 radius)
      Sets the radius of the cylinder.
      Parameters:
      radius - the radius along the X and Z axes
    • extendRadius

      public void extendRadius(Vector2 minRadius)
      Extends the radius to be at least the given radius.
      Parameters:
      minRadius - the minimum radius
    • setMinimumY

      public void setMinimumY(int y)
      Set the minimum Y.
      Parameters:
      y - the y
    • setMaximumY

      public void setMaximumY(int y)
      Se the maximum Y.
      Parameters:
      y - the y
    • 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
    • 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
    • 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
    • getVolume

      public long getVolume()
      Description copied from interface: Region
      Get the number of blocks in the region.
      Specified by:
      getVolume in interface Region
      Overrides:
      getVolume in class AbstractRegion
      Returns:
      number of blocks
    • getWidth

      public int getWidth()
      Description copied from class: AbstractRegion
      Get X-size.
      Specified by:
      getWidth in interface Region
      Overrides:
      getWidth in class AbstractRegion
      Returns:
      width
    • getHeight

      public int getHeight()
      Description copied from class: AbstractRegion
      Get Y-size.
      Specified by:
      getHeight in interface Region
      Overrides:
      getHeight in class AbstractRegion
      Returns:
      height
    • getLength

      public int getLength()
      Description copied from class: AbstractRegion
      Get Z-size.
      Specified by:
      getLength in interface Region
      Overrides:
      getLength in class AbstractRegion
      Returns:
      length
    • expand

      public void expand(BlockVector3... changes) throws RegionOperationException
      Expand the region. Expand the region.
      Specified by:
      expand in interface Region
      Parameters:
      changes - array/arguments with multiple related changes
      Throws:
      RegionOperationException - if the operation cannot be performed
    • contract

      public void contract(BlockVector3... changes) throws RegionOperationException
      Contract the region.
      Specified by:
      contract in interface Region
      Parameters:
      changes - array/arguments with multiple related changes
      Throws:
      RegionOperationException - if the operation cannot be performed
    • 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
    • contains

      public boolean contains(int x, int y, int z)
      Checks to see if a point is inside this region.
      Specified by:
      contains in interface Region
    • contains

      public boolean contains(int x, int z)
      Specified by:
      contains in interface Region
    • 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
    • setY

      public boolean setY(int y)
      Sets the height of the cylinder to fit the specified Y.
      Parameters:
      y - the y value
      Returns:
      true if the area was expanded
    • 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
    • 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()
      Returns string representation in the format. "(centerX, centerZ) - (radiusX, radiusZ) - (minY, maxY)"
      Overrides:
      toString in class AbstractCollection<BlockVector3>
      Returns:
      string
    • clone

      public CylinderRegion 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
    • polygonize

      public List<BlockVector2> polygonize(int maxPoints)
      Description copied from interface: Region
      Polygonizes a cross-section or a 2D projection of the region orthogonal to the Y axis.
      Specified by:
      polygonize in interface Region
      Overrides:
      polygonize in class AbstractRegion
      Parameters:
      maxPoints - maximum number of points to generate. -1 for no limit.
      Returns:
      the points.
    • createRadius

      public static CylinderRegion createRadius(Extent extent, BlockVector3 center, double radius)
      Return a new instance with the given center and radius in the X and Z axes with a Y that extends from the bottom of the extent to the top of the extent.
      Parameters:
      extent - the extent
      center - the center position
      radius - the radius in the X and Z axes
      Returns:
      a region
    • filter

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