Class BlockPosition

java.lang.Object
com.comphenix.protocol.wrappers.BlockPosition

public class BlockPosition extends Object
Copies a immutable net.minecraft.server.BlockPosition, which represents a integer 3D vector.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Represents the null (0, 0, 0) origin.
    protected final int
     
    protected final int
     
    protected final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    BlockPosition(int x, int y, int z)
    Construct an immutable 3D vector.
    BlockPosition(org.bukkit.util.Vector vector)
    Construct an immutable integer 3D vector from a mutable Bukkit vector.
  • Method Summary

    Modifier and Type
    Method
    Description
    Adds the current position and a given position together, producing a result position.
    divide(int divisor)
    Divide each dimension in the current position by the given divisor.
    boolean
     
    Used to convert between NMS ChunkPosition and the wrapper instance.
    int
    Retrieve the x-coordinate.
    int
    Retrieve the y-coordinate.
    int
    Retrieve the z-coordinate.
    int
     
    multiply(int factor)
    Multiply each dimension in the current position by the given factor.
    Adds the current position and a given position together, producing a result position.
    org.bukkit.Location
    toLocation(org.bukkit.World world)
    Convert this instance to an equivalent Location.
     
    org.bukkit.util.Vector
    Convert this instance to an equivalent real 3D vector.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • ORIGIN

      public static BlockPosition ORIGIN
      Represents the null (0, 0, 0) origin.
    • x

      protected final int x
    • y

      protected final int y
    • z

      protected final int z
  • Constructor Details

    • BlockPosition

      public BlockPosition(int x, int y, int z)
      Construct an immutable 3D vector.
      Parameters:
      x - - x coordinate
      y - - y coordinate
      z - - z coordinate
    • BlockPosition

      public BlockPosition(org.bukkit.util.Vector vector)
      Construct an immutable integer 3D vector from a mutable Bukkit vector.
      Parameters:
      vector - - the mutable real Bukkit vector to copy.
  • Method Details

    • toVector

      public org.bukkit.util.Vector toVector()
      Convert this instance to an equivalent real 3D vector.
      Returns:
      Real 3D vector.
    • toLocation

      public org.bukkit.Location toLocation(org.bukkit.World world)
      Convert this instance to an equivalent Location.
      Parameters:
      world - World for the location
      Returns:
      Location
    • getX

      public int getX()
      Retrieve the x-coordinate.
      Returns:
      X coordinate.
    • getY

      public int getY()
      Retrieve the y-coordinate.
      Returns:
      Y coordinate.
    • getZ

      public int getZ()
      Retrieve the z-coordinate.
      Returns:
      Z coordinate.
    • add

      public BlockPosition add(BlockPosition other)
      Adds the current position and a given position together, producing a result position.
      Parameters:
      other - - the other position.
      Returns:
      The new result position.
    • subtract

      public BlockPosition subtract(BlockPosition other)
      Adds the current position and a given position together, producing a result position.
      Parameters:
      other - - the other position.
      Returns:
      The new result position.
    • multiply

      public BlockPosition multiply(int factor)
      Multiply each dimension in the current position by the given factor.
      Parameters:
      factor - - multiplier.
      Returns:
      The new result.
    • divide

      public BlockPosition divide(int divisor)
      Divide each dimension in the current position by the given divisor.
      Parameters:
      divisor - - the divisor.
      Returns:
      The new result.
    • getConverter

      public static EquivalentConverter<BlockPosition> getConverter()
      Used to convert between NMS ChunkPosition and the wrapper instance.
      Returns:
      A new converter.
    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object