Class BlockVector3

java.lang.Object
com.sk89q.worldedit.math.BlockVector3
Direct Known Subclasses:
BlockVector3Imp, DelegateBlockVector3, FilterBlock, MutableBlockVector3

public abstract class BlockVector3 extends Object
An immutable 3-dimensional vector.
  • Field Details

  • Constructor Details

    • BlockVector3

      public BlockVector3()
  • Method Details

    • at

      public static BlockVector3 at(double x, double y, double z)
    • at

      public static BlockVector3 at(int x, int y, int z)
    • isLongPackable

      public static boolean isLongPackable(BlockVector3 location)
    • checkLongPackable

      public static void checkLongPackable(BlockVector3 location)
    • fromLongPackedForm

      public static BlockVector3 fromLongPackedForm(long packed)
    • sortByCoordsYzx

      public static Comparator<BlockVector3> sortByCoordsYzx()
      Returns a comparator that sorts vectors first by Y, then Z, then X.

      Useful for sorting by chunk block storage order.

    • setComponents

      public MutableBlockVector3 setComponents(double x, double y, double z)
    • setComponents

      public MutableBlockVector3 setComponents(int x, int y, int z)
    • toLongPackedForm

      public long toLongPackedForm()
    • mutX

      public MutableBlockVector3 mutX(double x)
    • mutY

      public MutableBlockVector3 mutY(double y)
    • mutZ

      public MutableBlockVector3 mutZ(double z)
    • mutX

      public MutableBlockVector3 mutX(int x)
    • mutY

      public MutableBlockVector3 mutY(int y)
    • mutZ

      public MutableBlockVector3 mutZ(int z)
    • toImmutable

      public BlockVector3 toImmutable()
    • x

      public abstract int x()
      Get the X coordinate.
      Returns:
      the x coordinate
      Since:
      2.11.0
    • getX

      @Deprecated(forRemoval=true, since="2.11.0") public int getX()
      Deprecated, for removal: This API element is subject to removal in a future version.
      use x() instead
      Get the X coordinate.
      Returns:
      the x coordinate
    • getBlockX

      @Deprecated(forRemoval=true, since="2.11.0") public int getBlockX()
      Deprecated, for removal: This API element is subject to removal in a future version.
      use x() instead
      Get the X coordinate.
      Returns:
      the x coordinate
    • withX

      public BlockVector3 withX(int x)
      Set the X coordinate.
      Parameters:
      x - the new X
      Returns:
      a new vector
    • y

      public abstract int y()
      Get the Y coordinate.
      Returns:
      the y coordinate
      Since:
      2.11.0
    • getY

      @Deprecated(forRemoval=true, since="2.11.0") public int getY()
      Deprecated, for removal: This API element is subject to removal in a future version.
      use y() instead
      Get the Y coordinate.
      Returns:
      the y coordinate
    • getBlockY

      @Deprecated(forRemoval=true, since="2.11.0") public int getBlockY()
      Deprecated, for removal: This API element is subject to removal in a future version.
      use y() instead
      Get the Y coordinate.
      Returns:
      the y coordinate
    • withY

      public BlockVector3 withY(int y)
      Set the Y coordinate.
      Parameters:
      y - the new Y
      Returns:
      a new vector
    • z

      public abstract int z()
      Get the Z coordinate.
      Returns:
      the Z coordinate
      Since:
      2.11.0
    • getZ

      @Deprecated(forRemoval=true, since="2.11.0") public int getZ()
      Deprecated, for removal: This API element is subject to removal in a future version.
      use z() instead
      Get the Z coordinate.
      Returns:
      the z coordinate
    • getBlockZ

      @Deprecated(forRemoval=true, since="2.11.0") public int getBlockZ()
      Deprecated, for removal: This API element is subject to removal in a future version.
      use z() instead
      Get the Z coordinate.
      Returns:
      the z coordinate
    • withZ

      public BlockVector3 withZ(int z)
      Set the Z coordinate.
      Parameters:
      z - the new Z
      Returns:
      a new vector
    • add

      public BlockVector3 add(BlockVector3 other)
      Add another vector to this vector and return the result as a new vector.
      Parameters:
      other - the other vector
      Returns:
      a new vector
    • add

      public BlockVector3 add(int x, int y, int z)
      Add another vector to this vector and return the result as a new vector.
      Parameters:
      x - the value to add
      y - the value to add
      z - the value to add
      Returns:
      a new vector
    • add

      public BlockVector3 add(BlockVector3... others)
      Add a list of vectors to this vector and return the result as a new vector.
      Parameters:
      others - an array of vectors
      Returns:
      a new vector
    • subtract

      public BlockVector3 subtract(BlockVector3 other)
      Subtract another vector from this vector and return the result as a new vector.
      Parameters:
      other - the other vector
      Returns:
      a new vector
    • subtract

      public BlockVector3 subtract(int x, int y, int z)
      Subtract another vector from this vector and return the result as a new vector.
      Parameters:
      x - the value to subtract
      y - the value to subtract
      z - the value to subtract
      Returns:
      a new vector
    • subtract

      public BlockVector3 subtract(BlockVector3... others)
      Subtract a list of vectors from this vector and return the result as a new vector.
      Parameters:
      others - an array of vectors
      Returns:
      a new vector
    • multiply

      public BlockVector3 multiply(BlockVector3 other)
      Multiply this vector by another vector on each component.
      Parameters:
      other - the other vector
      Returns:
      a new vector
    • multiply

      public BlockVector3 multiply(int x, int y, int z)
      Multiply this vector by another vector on each component.
      Parameters:
      x - the value to multiply
      y - the value to multiply
      z - the value to multiply
      Returns:
      a new vector
    • multiply

      public BlockVector3 multiply(BlockVector3... others)
      Multiply this vector by zero or more vectors on each component.
      Parameters:
      others - an array of vectors
      Returns:
      a new vector
    • multiply

      public BlockVector3 multiply(int n)
      Perform scalar multiplication and return a new vector.
      Parameters:
      n - the value to multiply
      Returns:
      a new vector
    • divide

      public BlockVector3 divide(BlockVector3 other)
      Divide this vector by another vector on each component.
      Parameters:
      other - the other vector
      Returns:
      a new vector
    • divide

      public BlockVector3 divide(int x, int y, int z)
      Divide this vector by another vector on each component.
      Parameters:
      x - the value to divide by
      y - the value to divide by
      z - the value to divide by
      Returns:
      a new vector
    • divide

      public BlockVector3 divide(int n)
      Perform scalar division and return a new vector.
      Parameters:
      n - the value to divide by
      Returns:
      a new vector
    • shr

      public BlockVector3 shr(int x, int y, int z)
      Shift all components right.
      Parameters:
      x - the value to shift x by
      y - the value to shift y by
      z - the value to shift z by
      Returns:
      a new vector
    • shr

      public BlockVector3 shr(int n)
      Shift all components right by n.
      Parameters:
      n - the value to shift by
      Returns:
      a new vector
    • shl

      public BlockVector3 shl(int x, int y, int z)
      Shift all components left.
      Parameters:
      x - the value to shift x by
      y - the value to shift y by
      z - the value to shift z by
      Returns:
      a new vector
    • shl

      public BlockVector3 shl(int n)
      Shift all components left by n.
      Parameters:
      n - the value to shift by
      Returns:
      a new vector
    • length

      public double length()
      Get the length of the vector.
      Returns:
      length
    • lengthSq

      public int lengthSq()
      Get the length, squared, of the vector.
      Returns:
      length, squared
    • distance

      public double distance(BlockVector3 other)
      Get the distance between this vector and another vector.
      Parameters:
      other - the other vector
      Returns:
      distance
    • distanceSq

      public int distanceSq(BlockVector3 other)
      Get the distance between this vector and another vector, squared.
      Parameters:
      other - the other vector
      Returns:
      distance
    • normalize

      public BlockVector3 normalize()
      Get the normalized vector, which is the vector divided by its length, as a new vector.
      Returns:
      a new vector
    • dot

      public double dot(BlockVector3 other)
      Gets the dot product of this and another vector.
      Parameters:
      other - the other vector
      Returns:
      the dot product of this and the other vector
    • cross

      public BlockVector3 cross(BlockVector3 other)
      Gets the cross product of this and another vector.
      Parameters:
      other - the other vector
      Returns:
      the cross product of this and the other vector
    • containedWithin

      public boolean containedWithin(BlockVector3 min, BlockVector3 max)
      Checks to see if a vector is contained with another.
      Parameters:
      min - the minimum point (X, Y, and Z are the lowest)
      max - the maximum point (X, Y, and Z are the lowest)
      Returns:
      true if the vector is contained
    • clampY

      public BlockVector3 clampY(int min, int max)
      Clamp the Y component.
      Parameters:
      min - the minimum value
      max - the maximum value
      Returns:
      a new vector
    • floor

      public BlockVector3 floor()
      Floors the values of all components.
      Returns:
      a new vector
    • ceil

      public BlockVector3 ceil()
      Rounds all components up.
      Returns:
      a new vector
    • round

      public BlockVector3 round()
      Rounds all components to the closest integer.

      Components < 0.5 are rounded down, otherwise up.

      Returns:
      a new vector
    • abs

      public BlockVector3 abs()
      Returns a vector with the absolute values of the components of this vector.
      Returns:
      a new vector
    • transform2D

      public BlockVector3 transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ)
      Perform a 2D transformation on this vector and return a new one.
      Parameters:
      angle - in degrees
      aboutX - about which x coordinate to rotate
      aboutZ - about which z coordinate to rotate
      translateX - what to add after rotation
      translateZ - what to add after rotation
      Returns:
      a new vector
      See Also:
    • toPitch

      public double toPitch()
      Get this vector's pitch as used within the game.
      Returns:
      pitch in radians
    • toYaw

      public double toYaw()
      Get this vector's yaw as used within the game.
      Returns:
      yaw in radians
    • getMinimum

      public BlockVector3 getMinimum(BlockVector3 v2)
      Gets the minimum components of two vectors.
      Parameters:
      v2 - the second vector
      Returns:
      minimum
    • getMaximum

      public BlockVector3 getMaximum(BlockVector3 v2)
      Gets the maximum components of two vectors.
      Parameters:
      v2 - the second vector
      Returns:
      maximum
    • setOrdinal

      public boolean setOrdinal(Extent orDefault, int ordinal)
    • setBlock

      public boolean setBlock(Extent orDefault, BlockState state)
    • setFullBlock

      public boolean setFullBlock(Extent orDefault, BaseBlock block)
    • getOrdinal

      public int getOrdinal(Extent orDefault)
    • getOrdinalChar

      public char getOrdinalChar(Extent orDefault)
    • getBlock

      public BlockState getBlock(Extent orDefault)
    • getFullBlock

      public BaseBlock getFullBlock(Extent orDefault)
    • setBiome

      public boolean setBiome(Extent orDefault, BiomeType type)
    • getBiome

      public BiomeType getBiome(Extent orDefault)
    • getNbtData

      @Deprecated(forRemoval=true, since="2.11.2") public CompoundTag getNbtData(Extent orDefault)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getOrdinalBelow

      public BlockState getOrdinalBelow(Extent orDefault)
    • getStateAbove

      public BlockState getStateAbove(Extent orDefault)
    • getStateRelativeY

      public BlockState getStateRelativeY(Extent orDefault, int y)
    • toBlockVector2

      public BlockVector2 toBlockVector2()
      Creates a 2D vector by dropping the Y component from this vector.
      Returns:
      a new BlockVector2
    • toVector3

      public Vector3 toVector3()
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • equals

      public final boolean equals(BlockVector3 other)
    • hashCode

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

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

      public String toParserString()
      Returns a string representation that is supported by the parser.
      Returns:
      string
    • plus

      public BlockVector3 plus(BlockVector3 other)