Class Vector3d

java.lang.Object
com.github.retrooper.packetevents.util.Vector3d

public class Vector3d extends Object
3D double Vector. This vector can represent coordinates, angles, or anything you want. You can use this to represent an array if you really want.
Since:
1.8
  • Field Details

    • x

      public final double x
      X (coordinate/angle/whatever you wish)
    • y

      public final double y
      Y (coordinate/angle/whatever you wish)
    • z

      public final double z
      Z (coordinate/angle/whatever you wish)
  • Constructor Details

    • Vector3d

      public Vector3d()
      Default constructor setting all coordinates/angles/values to their default values (=0).
    • Vector3d

      public Vector3d(double x, double y, double z)
      Constructor allowing you to set the values.
      Parameters:
      x - X
      y - Y
      z - Z
    • Vector3d

      public Vector3d(double[] array)
      Constructor allowing you to specify an array. X will be set to the first index of an array(if it exists, otherwise 0). Y will be set to the second index of an array(if it exists, otherwise 0). Z will be set to the third index of an array(if it exists, otherwise 0).
      Parameters:
      array - Array.
  • Method Details

    • read

      public static Vector3d read(PacketWrapper<?> wrapper)
    • write

      public static void write(PacketWrapper<?> wrapper, Vector3d vector)
    • decode

      public static Vector3d decode(NBT tag, ClientVersion version)
    • encode

      public static NBT encode(Vector3d vector3d, ClientVersion version)
    • getX

      public double getX()
    • getY

      public double getY()
    • getZ

      public double getZ()
    • equals

      public boolean equals(Object obj)
      Is the object we are comparing to equal to us? It must be of type Vector3d or Vector3i and all values must be equal to the values in this class.
      Overrides:
      equals in class Object
      Parameters:
      obj - Compared object.
      Returns:
      Are they equal?
    • hashCode

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

      public Vector3d add(double x, double y, double z)
    • add

      public Vector3d add(Vector3d other)
    • offset

      public Vector3d offset(BlockFace face)
    • subtract

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

      public Vector3d subtract(Vector3d other)
    • multiply

      public Vector3d multiply(double x, double y, double z)
    • multiply

      public Vector3d multiply(Vector3d other)
    • multiply

      public Vector3d multiply(double value)
    • crossProduct

      public Vector3d crossProduct(Vector3d other)
    • dot

      public double dot(Vector3d other)
    • with

      public Vector3d with(Double x, Double y, Double z)
    • withX

      public Vector3d withX(double x)
    • withY

      public Vector3d withY(double y)
    • withZ

      public Vector3d withZ(double z)
    • distance

      public double distance(Vector3d other)
    • length

      public double length()
    • lengthSquared

      public double lengthSquared()
    • normalize

      public Vector3d normalize()
    • distanceSquared

      public double distanceSquared(Vector3d other)
    • toVector3i

      public Vector3i toVector3i()
    • toString

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

      public static Vector3d zero()