Class Position

java.lang.Object
me.gamercoder215.mobchip.util.Position
All Implemented Interfaces:
Cloneable

public final class Position extends Object implements Cloneable
Represents a Location without a World
  • Constructor Summary

    Constructors
    Constructor
    Description
    Position(double x, double y, double z)
    Constructs a Position at these coordinates.
    Position(int x, int y, int z)
    Constructs a Position at these coordinates.
    Position(@NotNull Location loc)
    Constructs a Position at this Location.
    Position(@NotNull Entity en)
    Constructs a Position at this Entity.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull Position
    add(int x, int y, int z)
    Adds an amount to each coordinate.
    @NotNull Position
    add(@NotNull Position node)
    Adds a Position to this Position.
    @NotNull Position
    add(@NotNull Location loc)
    Adds a location to this Position.
    @NotNull Position
    add(@NotNull Entity en)
    Adds an entity's location to this Position.
     
    double
    distance(@NotNull Position node)
    Gets the distance of this Position to another Position.
    double
    distance(@NotNull Location loc)
    Gets the distance of this Position to another Location.
    double
    distance(@NotNull Entity en)
    Gets the distance of this Position to another Entity.
    double
    distanceManhattan(@NotNull Position node)
    Fetches the Manhattan distance to another Position.
    double
    Fetches the Manhattan distance to another Location.
    double
    distanceSquared(double x, double y, double z)
    GEts the distance, squared, of this Position to these coordinates.
    double
    distanceSquared(@NotNull Position node)
    Gets the distance, squared, of this Position to another Position.
    double
    distanceSquared(@NotNull Location loc)
    Gets the distance, squared, of this Position to another Location.
    double
    distanceSquared(@NotNull Entity en)
    Gets the distance, squared, of this Position to another Entity.
    int
    Fetches the current X value of this Position.
    int
    Fetches the current Y value of this Position.
    int
    Fetches the current Z value of this Position.
    @NotNull Position
    remove(int x, int y, int z)
    Removes an amount to each coordinate.
    @NotNull Position
    remove(@NotNull Position node)
    Removes a Position from this Position.
    @NotNull Position
    remove(@NotNull Location loc)
    Removes a Location from this Position.
    @NotNull Position
    remove(@NotNull Entity en)
    Removes an entity's location from this Position.
    @NotNull Position
    setX(int x)
    Sets the Position's X value.
    @NotNull Position
    setY(int y)
    Sets the Position's Y value.
    @NotNull Position
    setZ(int z)
    Sets the Position's Z value.
    @NotNull Location
    toLocation(@Nullable World w)
    Converts this Position to a Bukkit Location.
    @NotNull Vector
    Converts this Position to a Bukkit Vector.

    Methods inherited from class Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Position

      public Position(@NotNull @NotNull Entity en)
      Constructs a Position at this Entity.
      Parameters:
      en - Entity to use
    • Position

      public Position(@NotNull @NotNull Location loc)
      Constructs a Position at this Location.
      Parameters:
      loc - Location
    • Position

      public Position(double x, double y, double z)
      Constructs a Position at these coordinates.
      Parameters:
      x - X coord
      y - Y Coord
      z - Z coord
    • Position

      public Position(int x, int y, int z)
      Constructs a Position at these coordinates.
      Parameters:
      x - X coord
      y - Y Coord
      z - Z coord
  • Method Details

    • distance

      public double distance(@NotNull @NotNull Position node)
      Gets the distance of this Position to another Position.
      Parameters:
      node - Position to use
      Returns:
      distance
    • distance

      public double distance(@NotNull @NotNull Location loc)
      Gets the distance of this Position to another Location.
      Parameters:
      loc - Location to use
      Returns:
      distance
    • distance

      public double distance(@NotNull @NotNull Entity en)
      Gets the distance of this Position to another Entity.
      Parameters:
      en - Entity to use
      Returns:
      distance
    • distanceSquared

      public double distanceSquared(@NotNull @NotNull Position node)
      Gets the distance, squared, of this Position to another Position.
      Parameters:
      node - Position to use
      Returns:
      distance squared
    • distanceSquared

      public double distanceSquared(@NotNull @NotNull Location loc)
      Gets the distance, squared, of this Position to another Location.
      Parameters:
      loc - Location to use
      Returns:
      distance squared
    • distanceSquared

      public double distanceSquared(@NotNull @NotNull Entity en)
      Gets the distance, squared, of this Position to another Entity.
      Parameters:
      en - Entity to use
      Returns:
      distance squared
    • distanceSquared

      public double distanceSquared(double x, double y, double z)
      GEts the distance, squared, of this Position to these coordinates.
      Parameters:
      x - X coord
      y - Y Coord
      z - Z coord
      Returns:
      distance squared
    • distanceManhattan

      public double distanceManhattan(@NotNull @NotNull Position node)
      Fetches the Manhattan distance to another Position.
      Parameters:
      node - Position to use
      Returns:
      Manhattan distance
    • distanceManhattan

      public double distanceManhattan(@NotNull @NotNull Location loc)
      Fetches the Manhattan distance to another Location.
      Parameters:
      loc - Location to use
      Returns:
      Manhattan distance
    • getX

      public int getX()
      Fetches the current X value of this Position.
      Returns:
      X coordinate
    • getY

      public int getY()
      Fetches the current Y value of this Position.
      Returns:
      Y coordinate
    • getZ

      public int getZ()
      Fetches the current Z value of this Position.
      Returns:
      Z coordinate
    • add

      @NotNull public @NotNull Position add(int x, int y, int z)
      Adds an amount to each coordinate.
      Parameters:
      x - Amount of X to add
      y - Amount of Y to add
      z - Amount of Z to add
      Returns:
      this class, for chaining
    • remove

      @NotNull public @NotNull Position remove(int x, int y, int z)
      Removes an amount to each coordinate.
      Parameters:
      x - Amount of X to remove
      y - Amount of Y to remove
      z - Amount of Z to remove
      Returns:
      this class, for chaining
    • add

      @NotNull public @NotNull Position add(@NotNull @NotNull Position node)
      Adds a Position to this Position.
      Parameters:
      node - Position to add
      Returns:
      this class, for chaining
    • add

      @NotNull public @NotNull Position add(@NotNull @NotNull Location loc)
      Adds a location to this Position.
      Parameters:
      loc - Location to add
      Returns:
      this class, for chaining
    • add

      @NotNull public @NotNull Position add(@NotNull @NotNull Entity en)
      Adds an entity's location to this Position.
      Parameters:
      en - Entity to add
      Returns:
      this class, for chaining
    • remove

      @NotNull public @NotNull Position remove(@NotNull @NotNull Location loc)
      Removes a Location from this Position.
      Parameters:
      loc - Location to remove
      Returns:
      this class, for chaining
    • remove

      @NotNull public @NotNull Position remove(@NotNull @NotNull Entity en)
      Removes an entity's location from this Position.
      Parameters:
      en - Entity to remove
      Returns:
      this class, for chaining
    • remove

      @NotNull public @NotNull Position remove(@NotNull @NotNull Position node)
      Removes a Position from this Position.
      Parameters:
      node - Position to remove
      Returns:
      this class, for chaining
    • toLocation

      @NotNull public @NotNull Location toLocation(@Nullable @Nullable World w)
      Converts this Position to a Bukkit Location.
      Parameters:
      w - World to use
      Returns:
      Bukkit Location created
    • toVector

      @NotNull public @NotNull Vector toVector()
      Converts this Position to a Bukkit Vector.
      Returns:
      Bukkit Vector created
    • setX

      @NotNull public @NotNull Position setX(int x)
      Sets the Position's X value.
      Parameters:
      x - X value to set
      Returns:
      this class, for chaining
    • setY

      @NotNull public @NotNull Position setY(int y)
      Sets the Position's Y value.
      Parameters:
      y - Y value to set
      Returns:
      this class, for chaining
    • setZ

      @NotNull public @NotNull Position setZ(int z)
      Sets the Position's Z value.
      Parameters:
      z - Z value to set
      Returns:
      this class, for chaining
    • clone

      public Position clone()
      Overrides:
      clone in class Object