Package redempt.redlib.region
Class CuboidRegion
java.lang.Object
redempt.redlib.region.Region
redempt.redlib.region.Overlappable
redempt.redlib.region.CuboidRegion
- All Implemented Interfaces:
Cloneable
Represents a cuboid region in a world
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Represents a state of a Region, not necessarily at the current point in time -
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
CuboidRegion
(org.bukkit.Location start, org.bukkit.Location end) Construct a Region using 2 corners -
Method Summary
Modifier and TypeMethodDescriptionclone()
Clones this Regionboolean
contains
(org.bukkit.Location loc) Check whether a location is inside this Regionstatic CuboidRegion
cubeRadius
(org.bukkit.Location loc, int radius) Gets a Region covering a cubic radius centered around a Locationexpand
(double amount) Expands the region in all directions, or retracts if negative.expand
(double posX, double negX, double posY, double negY, double posZ, double negZ) Expands the region, or retracts where negative values are passedexpand
(org.bukkit.block.BlockFace direction, double amount) Expand the region in a given direction, or retracts if negative.void
forEachBlock
(Consumer<org.bukkit.block.Block> lambda) Run a lambda on every Block in this Regionstatic CuboidRegion
fromString
(String input) Converts a String generated bytoString()
back to a Regionint
org.bukkit.Location
getEnd()
Get the maximum corner of this RegiongetFace
(org.bukkit.block.BlockFace face) Gets a CuboidRegion representing a 1-block thick slice on a face of this RegiongetIntersection
(Overlappable overlap) Gets the cuboid intersection of this Region and another cuboid Regionorg.bukkit.Location
getStart()
Get the minimum corner of this RegiongetState()
Gets the current state of this Regiondouble
org.bukkit.World
getWorld()
boolean
isMulti()
move
(double x, double y, double z) move
(org.bukkit.util.Vector v) Move the regionboolean
overlaps
(Overlappable overlap) Check if this Region overlaps with another.rotate
(int rotations) Rotates this Region around its centerrotate
(org.bukkit.Location center, int rotations) Rotates this Region around a pointprotected void
setLocations
(org.bukkit.Location start, org.bukkit.Location end) setWorld
(org.bukkit.World world) Set the world of this region, while keeping the coordinates the sameStream<org.bukkit.block.Block>
stream()
Streams all Blocks inside this RegiontoString()
Converts this Region to a String which can be converted back withfromString(String)
laterMethods inherited from class redempt.redlib.region.Region
contains, disableEvents, enableEvents, equals, getBlockDimensions, getCenter, getChunks, getCorners, getDimensions, getEntities, getEntities, getLoadedChunks, getPlayers, hashCode, measure, measureBlocks, protect, protect, toCuboid
-
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 cornerend
- The second corner
-
CuboidRegion
protected CuboidRegion()
-
-
Method Details
-
cubeRadius
Gets a Region covering a cubic radius centered around a Location- Parameters:
loc
- The centerradius
- 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 -
getEnd
public org.bukkit.Location getEnd()Get the maximum corner of this Region -
contains
public boolean contains(org.bukkit.Location loc) Check whether a location is inside this Region -
getVolume
public double getVolume() -
getBlockVolume
public int getBlockVolume()- Specified by:
getBlockVolume
in classRegion
- Returns:
- The volume of this Region, in blocks
-
getState
Gets the current state of this Region- Returns:
- The state of this Region
-
clone
Clones this Region -
expand
Expands the region in all directions, or retracts if negative. If this is a MultiRegion, makes 6 calls toMultiRegion.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 classRegion
- Parameters:
posX
- The amount to expand the region in the positive X directionnegX
- The amount to expand the region in the negative X directionposY
- The amount to expand the region in the positive Y directionnegY
- The amount to expand the region in the negative Y directionposZ
- The amount to expand the region in the positive Z directionnegZ
- The amount to expand the region in the negative Z direction- Returns:
- Itself
-
expand
Expand the region in a given direction, or retracts if negative. -
move
Move the region -
move
-
setWorld
Set the world of this region, while keeping the coordinates the same -
isMulti
public boolean isMulti()- Returns:
- Whether this Region is a non-cuboid variant
-
forEachBlock
Run a lambda on every Block in this Region- Overrides:
forEachBlock
in classRegion
- Parameters:
lambda
- The lambda to be run on each Block
-
getWorld
public org.bukkit.World getWorld() -
overlaps
Check if this Region overlaps with another.- Specified by:
overlaps
in classOverlappable
- Parameters:
overlap
- The Overlappable Region to check against- Returns:
- Whether this Region overlaps with the given Region
-
rotate
Rotates this Region around a point -
rotate
Rotates this Region around its center- Parameters:
rotations
- The number of clockwise rotations to apply- Returns:
- Itself
-
getIntersection
Gets the cuboid intersection of this Region and another cuboid Region- Specified by:
getIntersection
in classOverlappable
- Parameters:
overlap
- The Region to get the intersection with- Returns:
- The intersection Region, or null if there is no intersection
-
stream
Description copied from class:Region
Streams all Blocks inside this Region -
getFace
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
Converts this Region to a String which can be converted back withfromString(String)
later -
fromString
Converts a String generated bytoString()
back to a Region- Parameters:
input
- The String representation of a Region- Returns:
- The Region
-