java.lang.Object
de.marcely.bedwars.tools.location.XYZ
All Implemented Interfaces:
Cloneable, ConfigurationSerializable
Direct Known Subclasses:
ImmutableXYZ, XYZD, XYZYP

public class XYZ extends Object implements Cloneable, ConfigurationSerializable
Represents a 3-dimensional position
  • Field Details

    • x

      protected double x
    • y

      protected double y
    • z

      protected double z
  • Constructor Details

    • XYZ

      public XYZ()
    • XYZ

      public XYZ(Location loc)
    • XYZ

      public XYZ(Vector vec)
    • XYZ

      public XYZ(XYZ xyz)
    • XYZ

      public XYZ(IntXYZ xyz)
    • XYZ

      public XYZ(double x, double y, double z)
  • Method Details

    • getX

      public double getX()
      Returns the x-coordinate
      Returns:
      The x value
    • getY

      public double getY()
      Returns the y-coordinate
      Returns:
      The y value
    • getZ

      public double getZ()
      Returns the z-coordinate
      Returns:
      The z value
    • getBlockX

      public int getBlockX()
      Returns the floored x-coordinate
      Returns:
      The block x-coordinate
    • getBlockY

      public int getBlockY()
      Returns the floored y-coordinate
      Returns:
      The block y-coordinate
    • getBlockZ

      public int getBlockZ()
      Returns the floored z-coordinate
      Returns:
      The block z-coordinate
    • setX

      public XYZ setX(double x)
      Sets the x-coordinate
      Parameters:
      x - The new x-coordinate
      Returns:
      This XYZ instance
    • setY

      public XYZ setY(double y)
      Sets the y-coordinate
      Parameters:
      y - The new y-coordinate
      Returns:
      This XYZ instance
    • setZ

      public XYZ setZ(double z)
      Sets the z-coordinate
      Parameters:
      z - The new z-coordinate
      Returns:
      This XYZ instance
    • set

      public XYZ set(double x, double y, double z)
      Sets the new coordinates
      Parameters:
      x - The new x-coordinate
      y - The new y-coordinate
      z - The new z-coordinate
      Returns:
      This XYZ instance
    • set

      public XYZ set(XYZ xyz)
      Copies and sets the xyz coordinates from the given object
      Parameters:
      xyz - The object from which it shall be taken from
      Returns:
      This XYZ instance
    • set

      public XYZ set(IntXYZ xyz)
      Copies and sets the xyz coordinates from the given object
      Parameters:
      xyz - The object from which it shall be taken from
      Returns:
      This XYZ instance
    • set

      public XYZ set(Location loc)
      Copies and sets the xyz coordinates from the given object
      Parameters:
      loc - The object from which it shall be taken from
      Returns:
      This XYZ instance
    • add

      public XYZ add(double x, double y, double z)
      Adds the x-coordinates
      Parameters:
      x - The added x-coordinate
      y - The added y-coordinate
      z - The added z-coordinate
      Returns:
      This XYZ instance
    • add

      public XYZ add(XYZ xyz)
    • add

      public XYZ add(IntXYZ xyz)
    • add

      public XYZ add(Location loc)
    • add

      public XYZ add(Vector vec)
    • subtract

      public XYZ subtract(double x, double y, double z)
    • subtract

      public XYZ subtract(XYZ xyz)
    • subtract

      public XYZ subtract(IntXYZ xyz)
    • subtract

      public XYZ subtract(Location loc)
    • subtract

      public XYZ subtract(Vector vec)
    • multiply

      public XYZ multiply(double amount)
    • multiply

      public XYZ multiply(double x, double y, double z)
    • zero

      public XYZ zero()
      Sets all coordinates to 0
      Returns:
      This XYZ instance
    • isZero

      public boolean isZero()
      Get whether all coordinates are set to 0
      Returns:
      true if X, Y and Z are set to 0.0D
    • distance

      public double distance(Location o)
    • distanceSquared

      public double distanceSquared(Location o)
    • distance

      public double distance(XYZ o)
    • distanceSquared

      public double distanceSquared(XYZ o)
    • toLocation

      public Location toLocation(World world)
      Converts this XYZ object to a new Location object
      Parameters:
      world - The world needed for creating the Location
      Returns:
      A new location whose coordinates where taken from this object
    • toVector

      public Vector toVector()
      Converts this XYZ object to a new Vector object
      Returns:
      A new vector whose coordinates where taken from this object
    • getBlock

      public Block getBlock(World world)
      Get the Bukkit block that you can find at the given position.
      Parameters:
      world - The world in which we want to look up the block
      Returns:
      The matching block
    • equalsBlockCoords

      public boolean equalsBlockCoords(XYZ xyz)
      Check whether the block coords (i.a. getBlockX()) match.
      Parameters:
      xyz - The other object to compare with
      Returns:
      true if the floored coordinates match
    • equalsBlockCoords

      public boolean equalsBlockCoords(Location loc)
      Check whether the block coords (i.a. getBlockX()) match.
      Parameters:
      loc - The other object to compare with
      Returns:
      true if the floored coordinates match
    • equalsBlockCoords

      public boolean equalsBlockCoords(Block block)
      Check whether the block coords (i.a. getBlockX()) match.
      Parameters:
      block - The other object to compare with
      Returns:
      true if the floored coordinates match
    • clone

      public XYZ clone()
      Overrides:
      clone in class Object
    • serialize

      public Map<String,Object> serialize()
      Specified by:
      serialize in interface ConfigurationSerializable
    • deserialize

      public static XYZ deserialize(Map<String,Object> data)
      Required method for deserialization
      Parameters:
      data - map to deserialize
      Returns:
      deserialized xyz instance