Position

data class Position(val x: Double, val y: Double, val z: Double, val yaw: Float, val pitch: Float) : Record

A position with coordinates and rotation.

This is primarily used to represent the position of an entity in a world.

Constructors

Link copied to clipboard
constructor(x: Double, y: Double, z: Double)

Creates a new position with the given x, y, and z coordinates.

constructor(x: Double, y: Double, z: Double, yaw: Float, pitch: Float)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun add(amount: Double): Position

Adds the given amount to this position and returns the result.

fun add(other: Position): Position

Adds the given other position to this position and returns the result.

fun add(other: Vec3d): Position
fun add(other: Vec3i): Position

Adds the given other vector to this position and returns the result.

fun add(x: Double, y: Double, z: Double): Position

Adds the given x, y, and z values to this position and returns the result.

Link copied to clipboard
fun asVec3d(): Vec3d

Converts this position to an equivalent double vector.

Link copied to clipboard
fun asVec3i(): Vec3i

Converts this position to an equivalent integer vector.

Link copied to clipboard
fun blockX(): Int

Gets the block X coordinate of this position.

Link copied to clipboard
fun blockY(): Int

Gets the block Y coordinate of this position.

Link copied to clipboard
fun blockZ(): Int

Gets the block Z coordinate of this position.

Link copied to clipboard
fun chunkX(): Int

Gets the chunk X coordinate of this position.

Link copied to clipboard
fun chunkZ(): Int

Gets the chunk Z coordinate of this position.

Link copied to clipboard

Gets a unit vector pointing in the direction that this position is facing.

Link copied to clipboard
fun distance(other: Position): Double

Calculates the distance between this position and the given other position.

fun distance(other: Vec3d): Double
fun distance(other: Vec3i): Double

Calculates the distance between this position and the given other vector.

Calculates the distance between this position and the given x, y, and z values.

Link copied to clipboard

Calculates the squared distance between this position and the given other position.

Calculates the squared distance between this position and the given other vector.

Calculates the squared distance between this position and the given x, y, and z values.

Link copied to clipboard
fun divide(factor: Double): Position

Divides this position by the given factor and returns the result.

fun divide(other: Position): Position

Divides this position by the given other position and returns the result.

fun divide(other: Vec3d): Position
fun divide(other: Vec3i): Position

Divides this position by the given other vector and returns the result.

Divides this position by the given x, y, and z values and returns the result.

Link copied to clipboard
fun multiply(factor: Double): Position

Multiplies this position by the given factor and returns the result.

Multiplies this position by the given other position and returns the result.

fun multiply(other: Vec3d): Position
fun multiply(other: Vec3i): Position

Multiplies this position by the given other vector and returns the result.

Multiplies this position by the given x, y, and z values and returns the result.

Link copied to clipboard
fun subtract(amount: Double): Position

Subtracts the given amount from this position and returns the result.

Subtracts the given other position from this position and returns the result.

fun subtract(other: Vec3d): Position
fun subtract(other: Vec3i): Position

Subtracts the given other vector from this position and returns the result.

Subtracts the given x, y, and z values from this vector and returns the result.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard

Creates a new position with the given x, y, and z coordinates and the rotation of this position.

Link copied to clipboard
fun withLookAt(target: Vec3d): Position

Creates a new position with the rotation such that they are looking at the given target vector.

Link copied to clipboard
fun withPitch(pitch: Float): Position

Creates a new position with the given pitch.

Link copied to clipboard
fun withRotation(yaw: Float, pitch: Float): Position

Creates a new position with the given yaw and pitch and the coordinates of this position.

Link copied to clipboard

Creates a new position with the given x component.

Link copied to clipboard

Creates a new position with the given y component.

Link copied to clipboard

Creates a new position with the given yaw.

Link copied to clipboard

Creates a new position with the given z component.

Properties

Link copied to clipboard

The rotation on the X axis.

Link copied to clipboard
val x: Double

The X component.

Link copied to clipboard
val y: Double

The Y component.

Link copied to clipboard
val yaw: Float

The rotation on the Y axis.

Link copied to clipboard
val z: Double

The Z component.