Interface Area
- All Known Subinterfaces:
Area.Cuboid, Area.Line, Area.Single, Area.Sphere
@Experimental
public sealed interface Area
extends Iterable<BlockVec>
permits Area.Single, Area.Line, Area.Cuboid, Area.Sphere
Represents a collection of aligned block coordinates in a 3D space.
If switched over, consider a fallback to the iterator as more implementations may be added in the future.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAn area containing all blocks inside an inclusive cuboid.static interfaceAn area containing blocks traced by a line between two block coordinates.static interfaceAn area containing exactly one block.static interfaceAn area containing all blocks within a radius of a center block. -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the number of blocks contained in this area.default Area.Cuboidbound()Returns the bounding box of this area.static Area.CuboidCreates a cuboid centered aroundcenterwith the given size on each axis.booleancontains(int x, int y, int z) Checks whether this area contains the given block coordinate.default booleanChecks whether this area contains the block coordinate ofpoint.static Area.CuboidCreates a cuboid centered aroundcenterwith the same size on each axis.static Area.CuboidCreates a cuboid area from two corners.static Area.LineCreates a line area between two block coordinates.default Areaoffset(int x, int y, int z) Returns this area translated by the given block offset.default AreaReturns this area translated by the block coordinates ofoffset.static Area.Cuboidsection(int sectionX, int sectionY, int sectionZ) Creates a cuboid containing all blocks in the given section.static Area.Singlesingle(int x, int y, int z) Creates an area containing a single block.static Area.SingleCreates an area containing a single block.static Area.SphereCreates a sphere area from a center and non-negative radius.split()Splits this area into multiple cuboids which do not cross section boundaries.Methods inherited from interface Iterable
forEach, iterator, spliterator
-
Method Details
-
offset
Returns this area translated by the given block offset.- Parameters:
x- the X block offsety- the Y block offsetz- the Z block offset- Returns:
- the translated area
-
offset
-
bound
Returns the bounding box of this area.- Returns:
- a cuboid representing the bounding box with the lowest and highest points
-
contains
boolean contains(int x, int y, int z) Checks whether this area contains the given block coordinate.- Parameters:
x- the block X coordinatey- the block Y coordinatez- the block Z coordinate- Returns:
trueif the block coordinate is contained in this area
-
contains
Checks whether this area contains the block coordinate ofpoint.- Parameters:
point- the point to convert to a block coordinate- Returns:
trueif the block coordinate is contained in this area
-
blockCount
long blockCount()Returns the number of blocks contained in this area.Counting a sphere requires scanning its bounding box and may be expensive for large radii.
- Returns:
- the contained block count
-
split
List<Area.Cuboid> split()Splits this area into multiple cuboids which do not cross section boundaries.Single sections may have multiple cuboids if the section-local portion is not a perfect cuboid.
- Returns:
- list of sub-cuboids covering exactly this area
-
single
Creates an area containing a single block.- Parameters:
point- the point to convert to a block coordinate- Returns:
- a single-block area
-
single
Creates an area containing a single block.- Parameters:
x- the block X coordinatey- the block Y coordinatez- the block Z coordinate- Returns:
- a single-block area
-
line
-
cuboid
Creates a cuboid area from two corners. The corners may be supplied in any order.- Parameters:
min- one corner to convert to a block coordinatemax- the other corner to convert to a block coordinate- Returns:
- a cuboid area with ordered minimum and maximum coordinates
-
cube
Creates a cuboid centered aroundcenterwith the same size on each axis.Since the bounds are inclusive block coordinates, even sizes include the center block and extend
size / 2blocks in each direction. The size is a coordinate span, not the final number of blocks.- Parameters:
center- the center point to convert to a block coordinatesize- the size used for each axis- Returns:
- a cuboid area
- Throws:
IllegalArgumentException- ifsizeis negative
-
box
Creates a cuboid centered aroundcenterwith the given size on each axis.Since the bounds are inclusive block coordinates, even sizes include the center block and extend half of the size in each direction. The size is a coordinate span, not the final number of blocks.
- Parameters:
center- the center point to convert to a block coordinatesize- the size point, converted through its coordinates- Returns:
- a cuboid area
- Throws:
IllegalArgumentException- if any size component is negative
-
section
Creates a cuboid containing all blocks in the given section.- Parameters:
sectionX- the section X coordinatesectionY- the section Y coordinatesectionZ- the section Z coordinate- Returns:
- a 16x16x16 section cuboid
-
sphere
Creates a sphere area from a center and non-negative radius.- Parameters:
center- the center point to convert to a block coordinateradius- the radius in blocks- Returns:
- a sphere area
- Throws:
IllegalArgumentException- ifradiusis negative
-