Package com.marcusslover.plus.lib.world
Class WorldPoint
java.lang.Object
com.marcusslover.plus.lib.world.WorldPoint
WorldPoints allow the storing of sets of coordinates without dealing with
chunk loading or world name storage. Unlike
Vector, Positions allow
us to store a yaw and pitch as well as being easily serializable.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.marcusslover.plus.lib.world.WorldPoint.WorldPointAdapter -
Constructor Summary
ConstructorsConstructorDescriptionWorldPoint(double x, double y, double z) WorldPoint(double x, double y, double z, float yaw, float pitch) WorldPoint(String string) WorldPoint(org.bukkit.Location location) -
Method Summary
Modifier and TypeMethodDescriptionadd(double x, double y, double z) Add x, y, z to WorldPointadd(WorldPoint worldPoint) Add a WorldPoint to WorldPointorg.bukkit.LocationasLocation(org.bukkit.World world) Creates a new Location object from this WorldPoint.Utility method that will set the coordinates to the bottom center of theWorldPointcenter()Utility method that get the center of thisWorldPointon the x, y, z axisclone()doubledistance(double x1, double y1, double z1) Computes the distance between this WorldPoint and WorldPoint(x1, y1, z1).doubledistance(WorldPoint worldPoint) Computes the distance between this WorldPoint and the specifiedWorldPoint.doubledistanceSquared(double x1, double y1, double z1) Computes the distance between this WorldPoint and WorldPoint(x1, y1, z1).doubledistanceSquared(WorldPoint worldPoint) Computes the distance between this WorldPoint and the specifiedWorldPoint.divide(double amount) Divide a WorldPoint (x, y, z) by a double valuedivide(double x, double y, double z) Divide a WorldPoint by x, y, zdivide(WorldPoint worldPoint) Divide a WorldPoint by another WorldPoint.booleanintintintinthashCode()booleanisBetween(WorldPoint min, WorldPoint max) booleanisChunkLoaded(org.bukkit.World world) Check if the chunk is loaded in the world for thisWorldPointmidpoint(double x, double y, double z) Returns a position which lies in the middle between this position and the specified coordinates.midpoint(WorldPoint worldPoint) Returns a WorldPoint which lies in the middle between this WorldPoint and the specified WorldPoint.multiply(double amount) Multiply a WorldPoint (x, y, z) by a double valuemultiply(double x, double y, double z) Multiply a WorldPoint by x, y, zmultiply(WorldPoint worldPoint) Multiply a WorldPoint by another WorldPoint.static WorldPointof(double x, double y, double z) WorldPoints allow the storing of sets of coordinates without dealing with chunk loading or world name storage.static WorldPointof(double x, double y, double z, float yaw, float pitch) WorldPoints allow the storing of sets of coordinates without dealing with chunk loading or world name storage.static WorldPointof(org.bukkit.Location location) WorldPoints allow the storing of sets of coordinates without dealing with chunk loading or world name storage.subtract(double x, double y, double z) Add x, y, z to WorldPointsubtract(WorldPoint worldPoint) Subtract a WorldPoint to WorldPointUtility method that will set the coordinates to the top center of theWorldPointtoString()org.bukkit.util.VectortoVector()zero()Utility method that will floor all values of thisWorldPoint
-
Field Details
-
ADAPTER
public static final com.marcusslover.plus.lib.world.WorldPoint.WorldPointAdapter ADAPTER
-
-
Constructor Details
-
WorldPoint
public WorldPoint() -
WorldPoint
public WorldPoint(org.bukkit.Location location) -
WorldPoint
public WorldPoint(double x, double y, double z) -
WorldPoint
public WorldPoint(double x, double y, double z, float yaw, float pitch) -
WorldPoint
-
-
Method Details
-
of
WorldPoints allow the storing of sets of coordinates without dealing with chunk loading or world name storage. UnlikeVector, Positions allow us to store ayawandpitchas well as being easily serializable. -
of
WorldPoints allow the storing of sets of coordinates without dealing with chunk loading or world name storage. UnlikeVector, Positions allow us to store ayawandpitchas well as being easily serializable. -
of
WorldPoints allow the storing of sets of coordinates without dealing with chunk loading or world name storage. UnlikeVector, Positions allow us to store ayawandpitchas well as being easily serializable. -
asLocation
public org.bukkit.Location asLocation(org.bukkit.World world) Creates a new Location object from this WorldPoint.- Parameters:
world- some valid bukkit world- Returns:
- Location
-
distance
public double distance(double x1, double y1, double z1) Computes the distance between this WorldPoint and WorldPoint(x1, y1, z1).- Parameters:
x1- the x coordinate of other WorldPointy1- the y coordinate of other WorldPointz1- the z coordinate of other WorldPoint- Returns:
- the distance between this WorldPoint and WorldPoint
(x1, y1, z1).
-
distance
Computes the distance between this WorldPoint and the specifiedWorldPoint.- Parameters:
worldPoint- the other WorldPoint- Returns:
- the distance between this WorldPoint and the specified
WorldPoint. - Throws:
NullPointerException- if the specifiedWorldPointis null
-
distanceSquared
public double distanceSquared(double x1, double y1, double z1) Computes the distance between this WorldPoint and WorldPoint(x1, y1, z1).- Parameters:
x1- the x coordinate of other WorldPointy1- the y coordinate of other WorldPointz1- the z coordinate of other WorldPoint- Returns:
- the distance between this WorldPoint and WorldPoint
(x1, y1, z1).
-
distanceSquared
Computes the distance between this WorldPoint and the specifiedWorldPoint.- Parameters:
worldPoint- the other WorldPoint- Returns:
- the distance between this WorldPoint and the specified
WorldPoint. - Throws:
NullPointerException- if the specifiedWorldPointis null
-
add
Add a WorldPoint to WorldPoint- Parameters:
worldPoint- WorldPoint to add- Returns:
- This WorldPoint
-
add
Add x, y, z to WorldPoint- Parameters:
x- X amount to addy- Y amount to addz- Z amount to add- Returns:
- This WorldPoint
-
subtract
Subtract a WorldPoint to WorldPoint- Parameters:
worldPoint- WorldPoint to subtract- Returns:
- This WorldPoint
-
subtract
Add x, y, z to WorldPoint- Parameters:
x- X amount to subtracty- Y amount to subtractz- Z amount to subtract- Returns:
- This WorldPoint
-
multiply
Multiply a WorldPoint by x, y, z- Parameters:
x- X amount to multiplyy- Y amount to multiplyz- Z amount to multiply- Returns:
- This WorldPoint
-
multiply
Multiply a WorldPoint (x, y, z) by a double value- Parameters:
amount- The amount to multiply by- Returns:
- This WorldPoint
-
multiply
Multiply a WorldPoint by another WorldPoint. (Only affects x, y, z)- Parameters:
worldPoint- The WorldPoint to multiply by- Returns:
- This WorldPoint
-
divide
Divide a WorldPoint by x, y, z- Returns:
- This WorldPoint
-
divide
Divide a WorldPoint (x, y, z) by a double value- Parameters:
amount- The amount to divide by- Returns:
- This WorldPoint
-
divide
Divide a WorldPoint by another WorldPoint. (Only affects x, y, z)- Parameters:
worldPoint- The WorldPoint to divide by- Returns:
- This WorldPoint
-
isBetween
- Parameters:
min- Minimum WorldPointmax- Maximum WorldPoint- Returns:
- A boolean
-
midpoint
Returns a position which lies in the middle between this position and the specified coordinates.- Parameters:
x- the X coordinate of the second endpointy- the Y coordinate of the second endpointz- the Z coordinate of the second endpoint- Returns:
- the position in the middle (new instance)
-
midpoint
Returns a WorldPoint which lies in the middle between this WorldPoint and the specified WorldPoint.- Parameters:
worldPoint- the other endpoint- Returns:
- the WorldPoint in the middle (new instance)
- Throws:
NullPointerException- if the specifiedWorldPointis null
-
toVector
public org.bukkit.util.Vector toVector()- Returns:
- A
Vector
-
isChunkLoaded
public boolean isChunkLoaded(org.bukkit.World world) Check if the chunk is loaded in the world for thisWorldPoint- Parameters:
world- World to use- Returns:
- A boolean
-
zero
Utility method that will floor all values of thisWorldPoint- Returns:
- This
WorldPoint
-
topCenter
Utility method that will set the coordinates to the top center of theWorldPoint- Returns:
- This
WorldPoint
-
bottomCenter
Utility method that will set the coordinates to the bottom center of theWorldPoint- Returns:
- This
WorldPoint
-
center
Utility method that get the center of thisWorldPointon the x, y, z axis- Returns:
- This
WorldPoint
-
getBlockX
public int getBlockX() -
getBlockY
public int getBlockY() -
getBlockZ
public int getBlockZ() -
toString
-
equals
-
hashCode
public int hashCode() -
clone
-