Interface Position
- All Known Subinterfaces:
BlockPosition, FinePosition
- All Known Implementing Classes:
Location
@Experimental
public interface Position
Common interface for
FinePosition and BlockPosition.
May see breaking changes until Experimental annotation is removed.
- Since:
- 1.19.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BlockPositionA block position at the origin (0, 0, 0).static final FinePositionA fine position at the origin (0, 0, 0). -
Method Summary
Modifier and TypeMethodDescriptionstatic BlockPositionblock(int x, int y, int z) Creates a position at the coordinates.static BlockPositionCreates a position from the location.intblockX()Gets the block x value for this position.intblockY()Gets the block y value for this position.intblockZ()Gets the block z value for this position.static FinePositionfine(double x, double y, double z) Creates a position at the coordinates.static FinePositionCreates a position from the location.booleanisBlock()Checks of this position represents aBlockPosition.booleanisFine()Checks if this position represents aFinePosition.default booleanisFinite()Checks if each component of this position is finite.offset(double x, double y, double z) Returns a position offset by the specified amounts.offset(int x, int y, int z) Returns a position offset by the specified amounts.toBlock()Returns the block position of this position or itself if it already is a block position.default FinePositiontoCenter()Returns a new position at the center of the block position this represents.default LocationtoLocation(World world) Creates a new location object at this position with the specified world.default VectortoVector()Converts this position to a vector.doublex()Gets the x value for this position.doubley()Gets the y value for this position.doublez()Gets the z value for this position.
-
Field Details
-
FINE_ZERO
-
BLOCK_ZERO
-
-
Method Details
-
blockX
int blockX()Gets the block x value for this position.- Returns:
- the block x value
- Since:
- 1.19.3
-
blockY
int blockY()Gets the block y value for this position.- Returns:
- the block y value
- Since:
- 1.19.3
-
blockZ
int blockZ()Gets the block z value for this position.- Returns:
- the block z value
- Since:
- 1.19.3
-
x
double x()Gets the x value for this position.- Returns:
- the x value
- Since:
- 1.19.3
-
y
double y()Gets the y value for this position.- Returns:
- the y value
- Since:
- 1.19.3
-
z
double z()Gets the z value for this position.- Returns:
- the z value
- Since:
- 1.19.3
-
isBlock
boolean isBlock()Checks of this position represents aBlockPosition.- Returns:
- true if block
- Since:
- 1.19.3
-
isFine
boolean isFine()Checks if this position represents aFinePosition.- Returns:
- true if fine
- Since:
- 1.19.3
-
isFinite
default boolean isFinite()Checks if each component of this position is finite.- Returns:
- true if each component of this position is finite
- Since:
- 1.20.2
-
offset
Returns a position offset by the specified amounts.- Parameters:
x- x value to offsety- y value to offsetz- z value to offset- Returns:
- the offset position
- Since:
- 1.19.3
-
offset
Returns a position offset by the specified amounts.- Parameters:
x- x value to offsety- y value to offsetz- z value to offset- Returns:
- the offset position
- Since:
- 1.19.3
-
toCenter
Returns a new position at the center of the block position this represents.- Returns:
- a new center position
- Since:
- 1.19.3
-
toBlock
Returns the block position of this position or itself if it already is a block position.- Returns:
- the block position
- Since:
- 1.19.3
-
toVector
Converts this position to a vector.- Returns:
- a new vector
- Since:
- 1.19.3
-
toLocation
-
block
Creates a position at the coordinates.- Parameters:
x- x coordy- y coordz- z coord- Returns:
- a position with those coords
- Since:
- 1.19.3
-
block
Creates a position from the location.- Parameters:
location- the location to copy the position of- Returns:
- a new position at that location
- Since:
- 1.19.3
-
fine
Creates a position at the coordinates.- Parameters:
x- x coordy- y coordz- z coord- Returns:
- a position with those coords
- Since:
- 1.19.3
-
fine
Creates a position from the location.- Parameters:
location- the location to copy the position of- Returns:
- a new position at that location
- Since:
- 1.19.3
-