Package redempt.redlib.region
Class SpheroidRegion
java.lang.Object
redempt.redlib.region.Region
redempt.redlib.region.SpheroidRegion
- All Implemented Interfaces:
Cloneable
Represents a spheroid region in a world
-
Constructor Summary
ConstructorDescriptionSpheroidRegion
(org.bukkit.Location center, double radius) Creates a SpheroidRegion from a center and a radiusSpheroidRegion
(org.bukkit.Location center, double xRad, double yRad, double zRad) Creates a SpheroidRegion from a center and a radius in each directionSpheroidRegion
(org.bukkit.Location start, org.bukkit.Location end) Creates a SpheroidRegion from two corners, using their midpoint as the center and their distance in each direction as the radius on each axis -
Method Summary
Modifier and TypeMethodDescriptionclone()
boolean
contains
(org.bukkit.Location loc) Checks if this SpheroidRegion contains a given pointboolean
Determines whether this SpheroidRegion equals another object based on itsgetCenter()
,getXRadius()
,getYRadius()
, andgetZRadius()
expand
(double amount) Expands this SpheroidRegion in all directionsexpand
(double posX, double negX, double posY, double negY, double posZ, double negZ) Expands this SpheroidRegion in all directionsexpand
(org.bukkit.block.BlockFace face, double amount) Expands this SpheroidRegion in a specific directionstatic SpheroidRegion
fromString
(String string) Deserializes a SpheroidRegion serialized withtoString()
int
org.bukkit.Location
org.bukkit.Location
getEnd()
org.bukkit.Location
getStart()
Set<org.bukkit.block.Block>
org.bukkit.Location
getSurfacePoint
(org.bukkit.util.Vector v) Gets a point on the surface of this SpheroidRegion in the given directiondouble
org.bukkit.World
getWorld()
double
double
double
int
hashCode()
Generates a hash code for this SpheroidRegionboolean
isSphere()
move
(double x, double y, double z) Moves this SpheroidRegionmove
(org.bukkit.util.Vector vec) Moves this SpheroidRegion according to a Vectorrotate
(org.bukkit.Location center, int rotations) Rotates this SpheroidRegionsetWorld
(org.bukkit.World world) Sets the world of this SpheroidRegionsetXRadius
(double xRad) Sets the radius of the spheroid on the X axissetYRadius
(double yRad) Sets the radius of the spheroid on the Y axissetZRadius
(double zRad) Sets the radius of the spheroid on the Z axisStream<org.bukkit.block.Block>
stream()
Streams all Blocks inside this Regionboolean
surfaceContains
(org.bukkit.block.Block block) Determines whether a block is on the surface of this SpheroidRegiontoCuboid()
toString()
Methods inherited from class redempt.redlib.region.Region
contains, disableEvents, enableEvents, forEachBlock, getBlockDimensions, getChunks, getCorners, getDimensions, getEntities, getEntities, getLoadedChunks, getPlayers, measure, measureBlocks, protect, protect
-
Constructor Details
-
SpheroidRegion
public SpheroidRegion(org.bukkit.Location start, org.bukkit.Location end) Creates a SpheroidRegion from two corners, using their midpoint as the center and their distance in each direction as the radius on each axis- Parameters:
start
- The first cornerend
- The second corner- Throws:
IllegalArgumentException
- if the Locations are not in the same world
-
SpheroidRegion
public SpheroidRegion(org.bukkit.Location center, double xRad, double yRad, double zRad) Creates a SpheroidRegion from a center and a radius in each direction- Parameters:
center
- The centerxRad
- The radius on the X axisyRad
- The radius on the Y axiszRad
- The radius on the Z axis
-
SpheroidRegion
public SpheroidRegion(org.bukkit.Location center, double radius) Creates a SpheroidRegion from a center and a radius- Parameters:
center
- The centerradius
- The radius
-
-
Method Details
-
getVolume
public double getVolume() -
getBlockVolume
public int getBlockVolume()- Specified by:
getBlockVolume
in classRegion
- Returns:
- The *approximate* block volume of this SpheroidRegion
-
expand
public SpheroidRegion expand(double posX, double negX, double posY, double negY, double posZ, double negZ) Expands this SpheroidRegion in all directions- Specified by:
expand
in classRegion
- Parameters:
posX
- The amount to increase in the positive X directionnegX
- The amount to increase in the negative X directionposY
- The amount to increase in the positive Y directionnegY
- The amount to increase in the negative Y directionposZ
- The amount to increase in the positive Z directionnegZ
- The amount to increase in the negative Z direction- Returns:
- Itself
-
expand
Expands this SpheroidRegion in a specific direction -
expand
Expands this SpheroidRegion in all directions- Parameters:
amount
- The amount to expand by in all directions- Returns:
- Itself
-
move
Moves this SpheroidRegion according to a Vector -
move
Moves this SpheroidRegion -
contains
public boolean contains(org.bukkit.Location loc) Checks if this SpheroidRegion contains a given point -
isSphere
public boolean isSphere()- Returns:
- True if the radius in all directions of this SpheroidRegion are the same
-
clone
-
rotate
Rotates this SpheroidRegion -
setWorld
Sets the world of this SpheroidRegion -
stream
Description copied from class:Region
Streams all Blocks inside this Region -
toCuboid
-
getXRadius
public double getXRadius()- Returns:
- The radius of the spheroid on the X axis
-
getYRadius
public double getYRadius()- Returns:
- The radius of the spheroid on the Y axis
-
getZRadius
public double getZRadius()- Returns:
- The radius of the spheroid on the Z axis
-
setXRadius
Sets the radius of the spheroid on the X axis- Parameters:
xRad
- The radius on the X axis- Returns:
- Itself
-
setYRadius
Sets the radius of the spheroid on the Y axis- Parameters:
yRad
- The radius on the Y axis- Returns:
- Itself
-
setZRadius
Sets the radius of the spheroid on the Z axis- Parameters:
zRad
- The radius on the Z axis- Returns:
- Itself
-
getStart
public org.bukkit.Location getStart() -
getEnd
public org.bukkit.Location getEnd() -
getWorld
public org.bukkit.World getWorld() -
getCenter
public org.bukkit.Location getCenter() -
getSurfacePoint
public org.bukkit.Location getSurfacePoint(org.bukkit.util.Vector v) Gets a point on the surface of this SpheroidRegion in the given direction- Parameters:
v
- The direction to get the point in- Returns:
- The point on the surface of this SpheroidRegion
-
getSurface
- Returns:
- A Set containing all of the blocks on the surface of this SpheroidRegion
-
surfaceContains
public boolean surfaceContains(org.bukkit.block.Block block) Determines whether a block is on the surface of this SpheroidRegion- Parameters:
block
- The block to check- Returns:
- Whether the block is on the surface of this SpheroidRegion
-
equals
Determines whether this SpheroidRegion equals another object based on itsgetCenter()
,getXRadius()
,getYRadius()
, andgetZRadius()
-
hashCode
public int hashCode()Generates a hash code for this SpheroidRegion -
toString
- Overrides:
toString
in classObject
- Returns:
- A String representation of this SpheroidRegion which can later be deserialized with
fromString(String)
-
fromString
Deserializes a SpheroidRegion serialized withtoString()
- Parameters:
string
- The serialized SpheroidRegion String- Returns:
- The deserialized SpheroidRegion
-