API reference / @jsprismarine/prismarine / Position
Class: Position
Defined in: prismarine/src/world/Position.ts:7
Represents the coordinates of a Vector3 in a given World.
Extends
Constructors
Constructor
new Position(
x,y,z,world):Position
Defined in: prismarine/src/world/Position.ts:16
Create a new position
Parameters
x
number
The x coordinate of the position.
y
number
The y coordinate of the position.
z
number
The z coordinate of the position.
world
The world of the position.
Returns
Position
The new position.
Overrides
Properties
ZERO
readonlystaticZERO:Vector3
Defined in: math/src/Vector3.ts:10
Returns a Vector3 with 0 on all axis.
Inherited from
Methods
distanceSquaredTo()
distanceSquaredTo(
vector):number
Defined in: math/src/Vector3.ts:150
The squared distance to another vector.
Squared, and offered first, because almost every caller compares a distance against another distance - and a comparison of squares gives the same answer without the square root. Prefer this to Vector3.distanceTo wherever the number itself is not shown to anyone.
Parameters
vector
The vector to measure to.
Returns
number
The squared distance.
Example
if (a.distanceSquaredTo(b) <= range * range) {
// within range, with no square root taken
}Inherited from
distanceTo()
distanceTo(
vector):number
Defined in: math/src/Vector3.ts:166
The distance to another vector.
Parameters
vector
The vector to measure to.
Returns
number
The distance.
Example
const meters = player.getPosition().distanceTo(target.getPosition());Inherited from
equals()
equals(
vector):boolean
Defined in: math/src/Vector3.ts:130
Compare an instance of Vector3 with another.
The parameter type matches the base declaration because ahead-of-time compilation only lowers overrides with identical signatures; a plain Vector2 is never equal to a Vector3.
Parameters
vector
The vector to compare to.
Returns
boolean
true if they're equal otherwise false.
Inherited from
floor()
floor():
this
Defined in: math/src/Vector3.ts:109
Returns a new Vector3 with each component rounded down to the nearest integer.
Returns
this
A new vector with rounded down components.
Inherited from
getWorld()
getWorld():
World
Defined in: prismarine/src/world/Position.ts:64
Get the world of the position.
Returns
The world of the position.
getX()
getX():
number
Defined in: math/src/Vector2.ts:67
Get the x coordinate.
Returns
number
The x coordinate's value.
Inherited from
getY()
getY():
number
Defined in: math/src/Vector3.ts:101
Get the y coordinate.
Returns
number
The y coordinate's value.
Inherited from
getZ()
getZ():
number
Defined in: math/src/Vector2.ts:75
Get the z coordinate.
Returns
number
The z coordinate's value.
Inherited from
toString()
toString():
string
Defined in: prismarine/src/world/Position.ts:33
Returns
string
Overrides
trunc()
trunc():
this
Defined in: math/src/Vector3.ts:117
Returns a new Vector3 with each component truncated to the nearest integer.
Returns
this
A new vector with truncated axis.
Inherited from
withWorld()
withWorld(
world):Position
Defined in: prismarine/src/world/Position.ts:73
Returns the same coordinates in another world.
Parameters
world
The world to move to.
Returns
Position
A new position; this one is left alone.
withX()
withX(
x):this
Defined in: math/src/Vector3.ts:67
Returns a copy with a different X coordinate.
Parameters
x
number
The X coordinate.
Returns
this
A new vector; this one is left alone.
Example
const moved = vector.withX(10);Inherited from
withY()
withY(
y):this
Defined in: math/src/Vector3.ts:80
Returns a copy with a different Y coordinate.
Parameters
y
number
The Y coordinate.
Returns
this
A new vector; this one is left alone.
Example
const moved = vector.withY(10);Inherited from
withZ()
withZ(
z):this
Defined in: math/src/Vector3.ts:93
Returns a copy with a different Z coordinate.
Parameters
z
number
The Z coordinate.
Returns
this
A new vector; this one is left alone.
Example
const moved = vector.withZ(10);Inherited from
fromObject()
staticfromObject(obj):Vector3
Defined in: math/src/Vector3.ts:39
Creates a new Vector3 instance from an object with x, y, and z properties.
Parameters
obj
The object containing x, y, and z properties.
x
number
y
number
z
number
Returns
A new Vector3 instance.
Inherited from
fromVector3()
staticfromVector3(vector,world):Position
Defined in: prismarine/src/world/Position.ts:43
Creates a Position from a Vector3 and a World.
Parameters
vector
The vector to create the position from.
world
The world of the position.
Returns
Position
The new position.