Class CuboidRegion

java.lang.Object
com.sk89q.worldedit.regions.AbstractRegion
com.sk89q.worldedit.regions.CuboidRegion
All Implemented Interfaces:
FlatRegion, Region, Cloneable, Iterable<BlockVector3>

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
  • 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
    • getFaces

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

      public Region 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
    • getBoundingBox

      public CuboidRegion getBoundingBox()
      Description copied from interface: Region
      Get the bounding box of this region as a CuboidRegion.
      Specified by:
      getBoundingBox in interface Region
      Returns:
      the bounding box
    • getMinimumY

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

      public int getMaximumY()
      Description copied from interface: FlatRegion
      Gets the maximum Y value.
      Specified by:
      getMaximumY in interface FlatRegion
      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
    • iterator

      public Iterator<BlockVector3> iterator()
      Description copied from class: AbstractRegion
      Get the iterator.
      Specified by:
      iterator in interface Iterable<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()
      Overrides:
      toString in class Object
    • 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
    • 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