Class WorldPoint

java.lang.Object
com.marcusslover.plus.lib.world.WorldPoint

public class WorldPoint extends Object
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 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

      public WorldPoint(String string)
  • Method Details

    • of

      public static WorldPoint of(double x, double y, double z)
      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.
    • of

      public static WorldPoint of(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. Unlike Vector, Positions allow us to store a yaw and pitch as well as being easily serializable.
    • of

      public static WorldPoint of(org.bukkit.Location location)
      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.
    • 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 WorldPoint
      y1 - the y coordinate of other WorldPoint
      z1 - the z coordinate of other WorldPoint
      Returns:
      the distance between this WorldPoint and WorldPoint (x1, y1, z1).
    • distance

      public double distance(WorldPoint worldPoint)
      Computes the distance between this WorldPoint and the specified WorldPoint.
      Parameters:
      worldPoint - the other WorldPoint
      Returns:
      the distance between this WorldPoint and the specified WorldPoint.
      Throws:
      NullPointerException - if the specified WorldPoint is 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 WorldPoint
      y1 - the y coordinate of other WorldPoint
      z1 - the z coordinate of other WorldPoint
      Returns:
      the distance between this WorldPoint and WorldPoint (x1, y1, z1).
    • distanceSquared

      public double distanceSquared(WorldPoint worldPoint)
      Computes the distance between this WorldPoint and the specified WorldPoint.
      Parameters:
      worldPoint - the other WorldPoint
      Returns:
      the distance between this WorldPoint and the specified WorldPoint.
      Throws:
      NullPointerException - if the specified WorldPoint is null
    • add

      public WorldPoint add(WorldPoint worldPoint)
      Add a WorldPoint to WorldPoint
      Parameters:
      worldPoint - WorldPoint to add
      Returns:
      This WorldPoint
    • add

      public WorldPoint add(double x, double y, double z)
      Add x, y, z to WorldPoint
      Parameters:
      x - X amount to add
      y - Y amount to add
      z - Z amount to add
      Returns:
      This WorldPoint
    • subtract

      public WorldPoint subtract(WorldPoint worldPoint)
      Subtract a WorldPoint to WorldPoint
      Parameters:
      worldPoint - WorldPoint to subtract
      Returns:
      This WorldPoint
    • subtract

      public WorldPoint subtract(double x, double y, double z)
      Add x, y, z to WorldPoint
      Parameters:
      x - X amount to subtract
      y - Y amount to subtract
      z - Z amount to subtract
      Returns:
      This WorldPoint
    • multiply

      public WorldPoint multiply(double x, double y, double z)
      Multiply a WorldPoint by x, y, z
      Parameters:
      x - X amount to multiply
      y - Y amount to multiply
      z - Z amount to multiply
      Returns:
      This WorldPoint
    • multiply

      public WorldPoint multiply(double amount)
      Multiply a WorldPoint (x, y, z) by a double value
      Parameters:
      amount - The amount to multiply by
      Returns:
      This WorldPoint
    • multiply

      public WorldPoint multiply(WorldPoint worldPoint)
      Multiply a WorldPoint by another WorldPoint. (Only affects x, y, z)
      Parameters:
      worldPoint - The WorldPoint to multiply by
      Returns:
      This WorldPoint
    • divide

      public WorldPoint divide(double x, double y, double z)
      Divide a WorldPoint by x, y, z
      Returns:
      This WorldPoint
    • divide

      public WorldPoint divide(double amount)
      Divide a WorldPoint (x, y, z) by a double value
      Parameters:
      amount - The amount to divide by
      Returns:
      This WorldPoint
    • divide

      public WorldPoint divide(WorldPoint worldPoint)
      Divide a WorldPoint by another WorldPoint. (Only affects x, y, z)
      Parameters:
      worldPoint - The WorldPoint to divide by
      Returns:
      This WorldPoint
    • isBetween

      public boolean isBetween(WorldPoint min, WorldPoint max)
      Parameters:
      min - Minimum WorldPoint
      max - Maximum WorldPoint
      Returns:
      A boolean
    • midpoint

      public WorldPoint midpoint(double x, double y, double z)
      Returns a position which lies in the middle between this position and the specified coordinates.
      Parameters:
      x - the X coordinate of the second endpoint
      y - the Y coordinate of the second endpoint
      z - the Z coordinate of the second endpoint
      Returns:
      the position in the middle (new instance)
    • midpoint

      public WorldPoint midpoint(WorldPoint worldPoint)
      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 specified WorldPoint is 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 this WorldPoint
      Parameters:
      world - World to use
      Returns:
      A boolean
    • zero

      public WorldPoint zero()
      Utility method that will floor all values of this WorldPoint
      Returns:
      This WorldPoint
    • topCenter

      public WorldPoint topCenter()
      Utility method that will set the coordinates to the top center of the WorldPoint
      Returns:
      This WorldPoint
    • bottomCenter

      public WorldPoint bottomCenter()
      Utility method that will set the coordinates to the bottom center of the WorldPoint
      Returns:
      This WorldPoint
    • center

      public WorldPoint center()
      Utility method that get the center of this WorldPoint on the x, y, z axis
      Returns:
      This WorldPoint
    • getBlockX

      public int getBlockX()
    • getBlockY

      public int getBlockY()
    • getBlockZ

      public int getBlockZ()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • clone

      public WorldPoint clone()
      Overrides:
      clone in class Object