@bedrock-oss/bedrock-boost
Version:
A utility package with helper functions for developing add-ons with Script API in Minecraft Bedrock Edition
1,376 lines (1,371 loc) • 121 kB
text/typescript
import { Vector3, Direction, Vector2, StructureRotation, VectorXZ, Dimension, BlockPermutation, Entity, EntityQueryOptions, Player, RGBA, EquipmentSlot } from '@minecraft/server';
import { NumberRange } from '@minecraft/common';
declare class MutVec3 implements Vector3 {
x: number;
y: number;
z: number;
constructor(x: number, y: number, z: number);
constructor(x: MutVec3);
constructor(x: Vec3);
constructor(x: Vector3);
constructor(x: Direction);
constructor(x: number[]);
static from(x: number, y: number, z: number): MutVec3;
static from(x: MutVec3): MutVec3;
static from(x: Vec3): MutVec3;
static from(x: Vector3): MutVec3;
static from(x: Direction): MutVec3;
static from(x: number[]): MutVec3;
private static _from;
copy(): MutVec3;
toImmutable(): Vec3;
static fromRotation(rotation: Vector2): MutVec3;
static fromRotation(yaw: number, pitch: number): MutVec3;
toRotation(): {
x: number;
y: number;
};
add(x: number, y: number, z: number): MutVec3;
add(x: Vector3): MutVec3;
add(x: Vec3): MutVec3;
add(x: MutVec3): MutVec3;
add(x: Direction): MutVec3;
add(x: number[]): MutVec3;
add(x: number): MutVec3;
directionTo(x: number, y: number, z: number): MutVec3;
directionTo(x: Vector3): MutVec3;
directionTo(x: Vec3): MutVec3;
directionTo(x: MutVec3): MutVec3;
directionTo(x: Direction): MutVec3;
directionTo(x: number[]): MutVec3;
subtract(x: number, y: number, z: number): MutVec3;
subtract(x: Vector3): MutVec3;
subtract(x: Vec3): MutVec3;
subtract(x: MutVec3): MutVec3;
subtract(x: Direction): MutVec3;
subtract(x: number[]): MutVec3;
subtract(x: number): MutVec3;
multiply(x: number, y: number, z: number): MutVec3;
multiply(x: Vector3): MutVec3;
multiply(x: Vec3): MutVec3;
multiply(x: MutVec3): MutVec3;
multiply(x: Direction): MutVec3;
multiply(x: number[]): MutVec3;
multiply(x: number): MutVec3;
scale(scalar: number): this;
divide(x: number, y: number, z: number): MutVec3;
divide(x: Vector3): MutVec3;
divide(x: Vec3): MutVec3;
divide(x: MutVec3): MutVec3;
divide(x: Direction): MutVec3;
divide(x: number[]): MutVec3;
divide(x: number): MutVec3;
normalize(): this;
length(): number;
lengthSquared(): number;
cross(x: number, y: number, z: number): MutVec3;
cross(x: Vector3): MutVec3;
cross(x: Vec3): MutVec3;
cross(x: MutVec3): MutVec3;
cross(x: Direction): MutVec3;
cross(x: number[]): MutVec3;
distance(x: number, y: number, z: number): number;
distance(x: Vector3): number;
distance(x: Vec3): number;
distance(x: MutVec3): number;
distance(x: Direction): number;
distance(x: number[]): number;
distanceSquared(x: number, y: number, z: number): number;
distanceSquared(x: Vector3): number;
distanceSquared(x: Vec3): number;
distanceSquared(x: MutVec3): number;
distanceSquared(x: Direction): number;
distanceSquared(x: number[]): number;
lerp(v: Vector3, t: number): this;
slerp(v: Vector3, t: number): this;
dot(x: number, y: number, z: number): number;
dot(x: Vector3): number;
dot(x: Vec3): number;
dot(x: MutVec3): number;
dot(x: Direction): number;
dot(x: number[]): number;
angleBetween(x: number, y: number, z: number): number;
angleBetween(x: Vector3): number;
angleBetween(x: Vec3): number;
angleBetween(x: MutVec3): number;
angleBetween(x: Direction): number;
angleBetween(x: number[]): number;
projectOnto(x: number, y: number, z: number): MutVec3;
projectOnto(x: Vector3): MutVec3;
projectOnto(x: Vec3): MutVec3;
projectOnto(x: MutVec3): MutVec3;
projectOnto(x: Direction): MutVec3;
projectOnto(x: number[]): MutVec3;
reflect(x: number, y: number, z: number): MutVec3;
reflect(x: Vector3): MutVec3;
reflect(x: Vec3): MutVec3;
reflect(x: MutVec3): MutVec3;
reflect(x: Direction): MutVec3;
reflect(x: number[]): MutVec3;
rotate(axis: Vector3, angle: number): this;
update(x: ((x: number) => number) | undefined, y: ((y: number) => number) | undefined, z: ((z: number) => number) | undefined): this;
setX(value: number): MutVec3;
setX(value: (x: number) => number): MutVec3;
setY(value: number): MutVec3;
setY(value: (y: number) => number): MutVec3;
setZ(value: number): MutVec3;
setZ(value: (z: number) => number): MutVec3;
floor(): this;
floorX(): MutVec3;
floorY(): MutVec3;
floorZ(): MutVec3;
ceil(): this;
ceilX(): MutVec3;
ceilY(): MutVec3;
ceilZ(): MutVec3;
round(): this;
roundX(): MutVec3;
roundY(): MutVec3;
roundZ(): MutVec3;
up(): MutVec3;
down(): MutVec3;
north(): MutVec3;
south(): MutVec3;
east(): MutVec3;
west(): MutVec3;
isZero(): boolean;
toArray(): number[];
toDirection(): Direction;
toStructureRotation(): StructureRotation;
toBlockLocation(): this;
almostEqual(x: number, y: number, z: number, delta: number): boolean;
almostEqual(x: MutVec3, delta: number): boolean;
almostEqual(x: Vec3, delta: number): boolean;
almostEqual(x: Vector3, delta: number): boolean;
almostEqual(x: Direction, delta: number): boolean;
almostEqual(x: number[], delta: number): boolean;
equals(x: number, y: number, z: number): boolean;
equals(x: MutVec3): boolean;
equals(x: Vec3): boolean;
equals(x: Vector3): boolean;
equals(x: Direction): boolean;
equals(x: number[]): boolean;
toString(format?: 'long' | 'short', separator?: string): string;
static fromString(str: string, format?: 'long' | 'short', separator?: string): MutVec3;
}
declare class Vec3 implements Vector3 {
private static readonly log;
/**
* Zero vector
*/
static readonly Zero: Vec3;
/**
* Down vector, negative towards Y
*/
static readonly Down: Vec3;
/**
* Up vector, positive towards Y
*/
static readonly Up: Vec3;
/**
* North vector, negative towards Z
*/
static readonly North: Vec3;
/**
* South vector, positive towards Z
*/
static readonly South: Vec3;
/**
* East vector, positive towards X
*/
static readonly East: Vec3;
/**
* West vector, negative towards X
*/
static readonly West: Vec3;
readonly x: number;
readonly y: number;
readonly z: number;
constructor(x: number, y: number, z: number);
constructor(x: Vec3);
constructor(x: Vector3);
constructor(x: Direction);
constructor(x: number[]);
/**
* Creates a new vector from the given values.
*/
static from(x: number, y: number, z: number): Vec3;
static from(x: Vec3): Vec3;
static from(x: Vector3): Vec3;
static from(x: Direction): Vec3;
static from(x: number[]): Vec3;
private static _from;
/**
* Creates a copy of the current vector.
*
* @returns A new vector with the same values as the current vector.
*/
copy(): Vec3;
/**
* Converts this immutable vector to a new mutable vector.
*/
toMutable(): MutVec3;
/**
* Creates a new direction vector from yaw and pitch values.
*
* @param rotation - The yaw and pitch values in degrees.
* @returns A new vector representing the direction.
*/
static fromRotation(rotation: Vector2): Vec3;
/**
* Creates a new direction vector from yaw and pitch values.
*
* @param yaw - The yaw value in degrees.
* @param pitch - The pitch value in degrees.
* @returns A new vector representing the direction.
*/
static fromRotation(yaw: number, pitch: number): Vec3;
/**
* Converts the normal vector to yaw and pitch values.
*
* @returns A Vector2 containing the yaw and pitch values.
*/
toRotation(): Vector2;
/**
* Adds three numbers to the current vector.
*
* @param x - The x component to be added.
* @param y - The y component to be added.
* @param z - The z component to be added.
* @returns The updated vector after addition.
*/
add(x: number, y: number, z: number): Vec3;
/**
* Adds another Vec3 to the current vector.
*
* @param x - The Vec3 to be added.
* @returns The updated vector after addition.
*/
add(x: Vec3): Vec3;
/**
* Adds another Vector3 to the current vector.
*
* @param x - The Vector3 to be added.
* @returns The updated vector after addition.
*/
add(x: Vector3): Vec3;
/**
* Adds a Direction to the current vector.
*
* @param x - The Direction to be added.
* @returns The updated vector after addition.
*/
add(x: Direction): Vec3;
/**
* Adds a Scaler to the current vector.
*
* @param x - The Scaler to be added.
* @returns The updated vector after addition.
*/
add(x: number): Vec3;
/**
* Adds an array of numbers to the current vector.
*
* @param x - The array of numbers to be added.
* @returns The updated vector after addition.
*/
add(x: number[]): Vec3;
/**
* Returns the normalized vector pointing from this vector to the input.
*
* @param x - The x component of the target vector.
* @param y - The y component target vector.
* @param z - The z component target vector.
* @returns The direction to the passed in Vector. Equivalent to (B-A).normalized()
*/
directionTo(x: number, y: number, z: number): Vec3;
/**
* Returns the normalized vector pointing from this vector to the input.
*
* @param x - The Vec3 to be added.
* @returns The direction to the passed in Vector. Equivalent to (B-A).normalized()
*/
directionTo(x: Vec3): Vec3;
/**
* Returns the normalized vector pointing from this vector to the input.
*
* @param x - The Vector3 to be added.
* @returns The direction to the passed in Vector. Equivalent to (B-A).normalized()
*/
directionTo(x: Vector3): Vec3;
/**
* Returns the normalized vector pointing from this vector to the input.
*
* @param x - The Direction to be added.
* @returns The direction to the passed in Vector. Equivalent to (B-A).normalized()
*/
directionTo(x: Direction): Vec3;
/**
* Returns the normalized vector pointing from this vector to the input.
*
* @param x - The array of numbers to be added.
* @returns The direction to the passed in Vector. Equivalent to (B-A).normalized()
*/
directionTo(x: number[]): Vec3;
/**
* Subtracts three numbers from the current vector.
*
* @param x - The x component to be subtracted.
* @param y - The y component to be subtracted.
* @param z - The z component to be subtracted.
* @returns The updated vector after subtraction.
*/
subtract(x: number, y: number, z: number): Vec3;
/**
* Subtracts another Vec3 from the current vector.
*
* @param x - The Vec3 to be subtracted.
* @returns The updated vector after subtraction.
*/
subtract(x: Vec3): Vec3;
/**
* Subtracts a Scaler from the current vector.
*
* @param x - The Scaler to be subtracted.
* @returns The updated vector after subtraction.
*/
subtract(x: number): Vec3;
/**
* Subtracts another Vector3 from the current vector.
*
* @param x - The Vector3 to be subtracted.
* @returns The updated vector after subtraction.
*/
subtract(x: Vector3): Vec3;
/**
* Subtracts a Direction from the current vector.
*
* @param x - The Direction to be subtracted.
* @returns The updated vector after subtraction.
*/
subtract(x: Direction): Vec3;
/**
* Subtracts an array of numbers from the current vector.
*
* @param x - The array of numbers to be subtracted.
* @returns The updated vector after subtraction.
*/
subtract(x: number[]): Vec3;
/**
* Subtracts a Scaler from the current vector.
*
* @param x - The number to be subtracted.
* @returns The updated vector after subtraction.
*/
subtract(x: number): Vec3;
/**
* Multiplies the current vector by three numbers.
*
* @param x - The multiplier for the x component.
* @param y - The multiplier for the y component.
* @param z - The multiplier for the z component.
* @returns The updated vector after multiplication.
*/
multiply(x: number, y: number, z: number): Vec3;
/**
* Multiplies the current vector by another Vec3.
*
* @param x - The Vec3 multiplier.
* @returns The updated vector after multiplication.
*/
multiply(x: Vec3): Vec3;
/**
* Multiplies the current vector by another Vector3.
*
* @param x - The Vector3 multiplier.
* @returns The updated vector after multiplication.
*/
multiply(x: Vector3): Vec3;
/**
* Multiplies the current vector by a Direction.
*
* @param x - The Direction multiplier.
* @returns The updated vector after multiplication.
*/
multiply(x: Direction): Vec3;
/**
* Multiplies the current vector by an array of numbers.
*
* @param x - The array multiplier.
* @returns The updated vector after multiplication.
*/
multiply(x: number[]): Vec3;
/**
* Multiplies the current vector by a scalar.
*
* @param x - The scalar multiplier.
* @returns The updated vector after multiplication.
*/
multiply(x: number): Vec3;
/**
* Scales the current vector by a scalar.
*
* @param scalar - The scalar to scale the vector by.
* @returns The updated vector after scaling.
*/
scale(scalar: number): Vec3;
/**
* Divides the current vector by three numbers.
*
* @param x - The divisor for the x component.
* @param y - The divisor for the y component.
* @param z - The divisor for the z component.
* @returns The updated vector after division.
*/
divide(x: number, y: number, z: number): Vec3;
/**
* Divides the current vector by another Vec3.
*
* @param x - The Vec3 divisor.
* @returns The updated vector after division.
*/
divide(x: Vec3): Vec3;
/**
* Divides the current vector by another Vector3.
*
* @param x - The Vector3 divisor.
* @returns The updated vector after division.
*/
divide(x: Vector3): Vec3;
/**
* Divides the current vector by a Direction.
*
* @param x - The Direction divisor.
* @returns The updated vector after division.
*/
divide(x: Direction): Vec3;
/**
* Divides the current vector by an array of numbers.
*
* @param x - The array divisor.
* @returns The updated vector after division.
*/
divide(x: number[]): Vec3;
/**
* Divides the current vector by a scalar.
*
* @param x - The scalar divisor.
* @returns The updated vector after division.
*/
divide(x: number): Vec3;
/**
* Normalizes the vector to have a length (magnitude) of 1.
* Normalized vectors are often used as a direction vectors.
*
* @returns The normalized vector.
*/
normalize(): Vec3;
/**
* Computes the length (magnitude) of the vector.
*
* @returns The length of the vector.
*/
length(): number;
/**
* Computes the squared length of the vector.
* This is faster than computing the actual length and can be useful for comparison purposes.
*
* @returns The squared length of the vector.
*/
lengthSquared(): number;
/**
* Computes the cross product of the current vector with three numbers.
*
* A cross product is a vector that is perpendicular to both vectors.
*
* @param x - The x component of the other vector.
* @param y - The y component of the other vector.
* @param z - The z component of the other vector.
* @returns A new vector representing the cross product.
*/
cross(x: number, y: number, z: number): Vec3;
/**
* Computes the cross product of the current vector with another Vec3.
*
* A cross product is a vector that is perpendicular to both vectors.
*
* @param x - The Vec3 to be crossed.
* @returns A new vector representing the cross product.
*/
cross(x: Vec3): Vec3;
/**
* Computes the cross product of the current vector with another Vector3.
*
* A cross product is a vector that is perpendicular to both vectors.
*
* @param x - The Vector3 to be crossed.
* @returns A new vector representing the cross product.
*/
cross(x: Vector3): Vec3;
/**
* Computes the cross product of the current vector with a Direction.
*
* A cross product is a vector that is perpendicular to both vectors.
*
* @param x - The Direction to be crossed.
* @returns A new vector representing the cross product.
*/
cross(x: Direction): Vec3;
/**
* Computes the cross product of the current vector with an array of numbers.
*
* A cross product is a vector that is perpendicular to both vectors.
*
* @param x - The array of numbers representing a vector.
* @returns A new vector representing the cross product.
*/
cross(x: number[]): Vec3;
/**
* Computes the distance between the current vector and a vector represented by three numbers.
*
* @param x - The x component of the other vector.
* @param y - The y component of the other vector.
* @param z - The z component of the other vector.
* @returns The distance between the two vectors.
*/
distance(x: number, y: number, z: number): number;
/**
* Computes the distance between the current vector and another Vec3.
*
* @param x - The Vec3 to measure the distance to.
* @returns The distance between the two vectors.
*/
distance(x: Vec3): number;
/**
* Computes the distance between the current vector and another Vector3.
*
* @param x - The Vector3 to measure the distance to.
* @returns The distance between the two vectors.
*/
distance(x: Vector3): number;
/**
* Computes the distance between the current vector and a Direction.
*
* @param x - The Direction to measure the distance to.
* @returns The distance between the two vectors.
*/
distance(x: Direction): number;
/**
* Computes the distance between the current vector and a vector represented by an array of numbers.
*
* @param x - The array of numbers representing the other vector.
* @returns The distance between the two vectors.
*/
distance(x: number[]): number;
/**
* Computes the squared distance between the current vector and a vector represented by three numbers.
* This is faster than computing the actual distance and can be useful for comparison purposes.
*
* @param x - The x component of the other vector.
* @param y - The y component of the other vector.
* @param z - The z component of the other vector.
* @returns The squared distance between the two vectors.
*/
distanceSquared(x: number, y: number, z: number): number;
/**
* Computes the squared distance between the current vector and another Vec3.
* This is faster than computing the actual distance and can be useful for comparison purposes.
*
* @param x - The Vec3 to measure the squared distance to.
* @returns The squared distance between the two vectors.
*/
distanceSquared(x: Vec3): number;
/**
* Computes the squared distance between the current vector and another Vector3.
* This is faster than computing the actual distance and can be useful for comparison purposes.
*
* @param x - The Vector3 to measure the squared distance to.
* @returns The squared distance between the two vectors.
*/
distanceSquared(x: Vector3): number;
/**
* Computes the squared distance between the current vector and a Direction.
* This is faster than computing the actual distance and can be useful for comparison purposes.
*
* @param x - The Direction to measure the squared distance to.
* @returns The squared distance between the two vectors.
*/
distanceSquared(x: Direction): number;
/**
* Computes the squared distance between the current vector and a vector represented by an array of numbers.
* This is faster than computing the actual distance and can be useful for comparison purposes.
*
* @param x - The array of numbers representing the other vector.
* @returns The squared distance between the two vectors.
*/
distanceSquared(x: number[]): number;
/**
* Computes the linear interpolation between the current vector and another vector, when t is in the range [0, 1].
* Computes the extrapolation when t is outside this range.
*
* @param v - The other vector.
* @param t - The interpolation factor.
* @returns A new vector after performing the lerp operation.
*/
lerp(v: Vector3, t: number): Vec3;
/**
* Computes the spherical linear interpolation between the current vector and another vector, when t is in the range [0, 1].
* Computes the extrapolation when t is outside this range.
*
* @param v - The other vector.
* @param t - The interpolation factor.
* @returns A new vector after performing the slerp operation.
*/
slerp(v: Vector3, t: number): Vec3;
/**
* Computes the dot product of the current vector with a vector specified by three numbers.
*
* @param x - The x component of the other vector.
* @param y - The y component of the other vector.
* @param z - The z component of the other vector.
* @returns The dot product of the two vectors.
*/
dot(x: number, y: number, z: number): number;
/**
* Computes the dot product of the current vector with another Vec3.
*
* @param x - The Vec3 to compute the dot product with.
* @returns The dot product of the two vectors.
*/
dot(x: Vec3): number;
/**
* Computes the dot product of the current vector with another Vector3.
*
* @param x - The Vector3 to compute the dot product with.
* @returns The dot product of the two vectors.
*/
dot(x: Vector3): number;
/**
* Computes the dot product of the current vector with a Direction.
*
* @param x - The Direction to compute the dot product with.
* @returns The dot product of the two vectors.
*/
dot(x: Direction): number;
/**
* Computes the dot product of the current vector with a vector represented by an array of numbers.
*
* @param x - The array of numbers representing the other vector.
* @returns The dot product of the two vectors.
*/
dot(x: number[]): number;
/**
* Computes the angle (in radians) between the current vector and a vector specified by three numbers.
*
* @param x - The x component of the other vector.
* @param y - The y component of the other vector.
* @param z - The z component of the other vector.
* @returns The angle in radians between the two vectors.
*/
angleBetween(x: number, y: number, z: number): number;
/**
* Computes the angle (in radians) between the current vector and another Vec3.
*
* @param x - The Vec3 to compute the angle with.
* @returns The angle in radians between the two vectors.
*/
angleBetween(x: Vec3): number;
/**
* Computes the angle (in radians) between the current vector and another Vector3.
*
* @param x - The Vector3 to compute the angle with.
* @returns The angle in radians between the two vectors.
*/
angleBetween(x: Vector3): number;
/**
* Computes the angle (in radians) between the current vector and a Direction.
*
* @param x - The Direction to compute the angle with.
* @returns The angle in radians between the two vectors.
*/
angleBetween(x: Direction): number;
/**
* Computes the angle (in radians) between the current vector and a vector represented by an array of numbers.
*
* @param x - The array of numbers representing the other vector.
* @returns The angle in radians between the two vectors.
*/
angleBetween(x: number[]): number;
/**
* Computes the projection of the current vector onto a vector specified by three numbers.
* This method finds how much of the current vector lies in the direction of the given vector.
*
* @param x - The x component of the vector to project onto.
* @param y - The y component of the vector to project onto.
* @param z - The z component of the vector to project onto.
* @returns A new vector representing the projection of the current vector.
*/
projectOnto(x: number, y: number, z: number): Vec3;
/**
* Computes the projection of the current vector onto another Vec3.
* This method finds how much of the current vector lies in the direction of the given vector.
*
* @param x - The Vec3 to project onto.
* @returns A new vector representing the projection of the current vector.
*/
projectOnto(x: Vec3): Vec3;
/**
* Computes the projection of the current vector onto another Vector3.
* This method finds how much of the current vector lies in the direction of the given vector.
*
* @param x - The Vector3 to project onto.
* @returns A new vector representing the projection of the current vector.
*/
projectOnto(x: Vector3): Vec3;
/**
* Computes the projection of the current vector onto a Direction.
* This method finds how much of the current vector lies in the direction of the given vector.
*
* @param x - The Direction to project onto.
* @returns A new vector representing the projection of the current vector.
*/
projectOnto(x: Direction): Vec3;
/**
* Computes the projection of the current vector onto a vector represented by an array of numbers.
* This method finds how much of the current vector lies in the direction of the given vector.
*
* @param x - The array of numbers representing the vector to project onto.
* @returns A new vector representing the projection of the current vector.
*/
projectOnto(x: number[]): Vec3;
/**
* Computes the reflection of the current vector against a normal vector specified by three numbers.
* Useful for simulating light reflections or bouncing objects.
*
* @param x - The x component of the normal vector.
* @param y - The y component of the normal vector.
* @param z - The z component of the normal vector.
* @returns A new vector representing the reflection of the current vector.
*/
reflect(x: number, y: number, z: number): Vec3;
/**
* Computes the reflection of the current vector against another Vec3 normal vector.
* Useful for simulating light reflections or bouncing objects.
*
* @param x - The Vec3 representing the normal vector.
* @returns A new vector representing the reflection of the current vector.
*/
reflect(x: Vec3): Vec3;
/**
* Computes the reflection of the current vector against another Vector3 normal vector.
* Useful for simulating light reflections or bouncing objects.
*
* @param x - The Vector3 representing the normal vector.
* @returns A new vector representing the reflection of the current vector.
*/
reflect(x: Vector3): Vec3;
/**
* Computes the reflection of the current vector against a Direction normal vector.
* Useful for simulating light reflections or bouncing objects.
*
* @param x - The Direction representing the normal vector.
* @returns A new vector representing the reflection of the current vector.
*/
reflect(x: Direction): Vec3;
/**
* Computes the reflection of the current vector against a normal vector represented by an array of numbers.
* Useful for simulating light reflections or bouncing objects.
*
* @param x - The array of numbers representing the normal vector.
* @returns A new vector representing the reflection of the current vector.
*/
reflect(x: number[]): Vec3;
/**
* Rotates the current normalized vector by a given angle around a given axis.
*
* @param axis - The axis of rotation.
* @param angle - The angle of rotation in degrees.
* @returns The rotated vector.
*/
rotate(axis: Vector3, angle: number): Vec3;
/**
* Updates the X, Y, and Z components of the vector.
*
* @param x - The function to use to update the X value.
* @param y - The function to use to update the Y value.
* @param z - The function to use to update the Z value.
* @returns The updated vector with the new values.
*/
update(x: ((x: number) => number) | undefined, y: ((y: number) => number) | undefined, z: ((z: number) => number) | undefined): Vec3;
/**
* Sets the X component of the vector.
*
* @param value - The new X value.
* @returns The updated vector with the new X value.
*/
setX(value: number): Vec3;
setX(value: (x: number) => number): Vec3;
/**
* Sets the Y component of the vector.
*
* @param value - The new Y value.
* @returns The updated vector with the new Y value.
*/
setY(value: number): Vec3;
setY(value: (y: number) => number): Vec3;
/**
* Sets the Z component of the vector.
*
* @param value - The new Z value.
* @returns The updated vector with the new Z value.
*/
setZ(value: number): Vec3;
setZ(value: (z: number) => number): Vec3;
/**
* Calculates the shortest distance between a point (represented by this Vector3 instance) and a line segment.
*
* This method finds the perpendicular projection of the point onto the line defined by the segment. If this
* projection lies outside the line segment, then the method calculates the distance from the point to the
* nearest segment endpoint.
*
* @param start - The starting point of the line segment.
* @param end - The ending point of the line segment.
* @returns The shortest distance between the point and the line segment.
*/
distanceToLineSegment(start: Vector3, end: Vector3): number;
/**
* Floors the X, Y, and Z components of the vector.
* @returns A new vector with the floored components.
*/
floor(): Vec3;
/**
* Floors the X component of the vector.
* @returns A new vector with the floored X component.
*/
floorX(): Vec3;
/**
* Floors the Y component of the vector.
* @returns A new vector with the floored Y component.
*/
floorY(): Vec3;
/**
* Floors the Z component of the vector.
* @returns A new vector with the floored Z component.
*/
floorZ(): Vec3;
/**
* Ceils the X, Y, and Z components of the vector.
* @returns A new vector with the ceiled components.
*/
ceil(): Vec3;
/**
* Ceils the X component of the vector.
* @returns A new vector with the ceiled X component.
*/
ceilX(): Vec3;
/**
* Ceils the Y component of the vector.
* @returns A new vector with the ceiled Y component.
*/
ceilY(): Vec3;
/**
* Ceils the Z component of the vector.
* @returns A new vector with the ceiled Z component.
*/
ceilZ(): Vec3;
/**
* Rounds the X, Y, and Z components of the vector.
* @returns A new vector with the rounded components.
*/
round(): Vec3;
/**
* Rounds the X component of the vector.
* @returns A new vector with the rounded X component.
*/
roundX(): Vec3;
/**
* Rounds the Y component of the vector.
* @returns A new vector with the rounded Y component.
*/
roundY(): Vec3;
/**
* Rounds the Z component of the vector.
* @returns A new vector with the rounded Z component.
*/
roundZ(): Vec3;
/**
* Returns a new vector offset from the current vector up by 1 block.
* @returns A new vector offset from the current vector up by 1 block.
*/
up(): Vec3;
/**
* Returns a new vector offset from the current vector down by 1 block.
* @returns A new vector offset from the current vector down by 1 block.
*/
down(): Vec3;
/**
* Returns a new vector offset from the current vector north by 1 block.
* @returns A new vector offset from the current vector north by 1 block.
*/
north(): Vec3;
/**
* Returns a new vector offset from the current vector south by 1 block.
* @returns A new vector offset from the current vector south by 1 block.
*/
south(): Vec3;
/**
* Returns a new vector offset from the current vector east by 1 block.
* @returns A new vector offset from the current vector east by 1 block.
*/
east(): Vec3;
/**
* Returns a new vector offset from the current vector west by 1 block.
* @returns A new vector offset from the current vector west by 1 block.
*/
west(): Vec3;
/**
* Checks if the current vector is equal to the zero vector.
* @returns true if the vector is equal to the zero vector, else returns false.
*/
isZero(): boolean;
/**
* Converts the vector to an array containing the X, Y, and Z components of the vector.
* @returns An array containing the X, Y, and Z components of the vector.
*/
toArray(): number[];
/**
* Converts the vector to a direction.
* If the vector is not a unit vector, then it will be normalized and rounded to the nearest direction.
*/
toDirection(): Direction;
/**
* Converts the vector to a structure rotation.
* If the vector is not a unit vector, then it will be normalized and rounded to the nearest 90 degrees rotation.
*/
toStructureRotation(): StructureRotation;
/**
* Returns a new vector with the X, Y, and Z components rounded to the nearest block location.
*/
toBlockLocation(): Vec3;
/**
* Checks if the current vector is almost equal to another vector defined by three numbers,
* within a given tolerance (delta).
*
* @param x - The x component of the other vector.
* @param y - The y component of the other vector.
* @param z - The z component of the other vector.
* @param delta - The maximum allowed difference between corresponding components.
* @returns True if the vectors are almost equal; otherwise, false.
*/
almostEqual(x: number, y: number, z: number, delta: number): boolean;
/**
* Checks if the current vector is almost equal to another Vec3 within a given tolerance (delta).
*
* @param x - The Vec3 to compare.
* @param delta - The maximum allowed difference between corresponding components.
* @returns True if the vectors are almost equal; otherwise, false.
*/
almostEqual(x: Vec3, delta: number): boolean;
/**
* Checks if the current vector is almost equal to another Vector3 within a given tolerance (delta).
*
* @param x - The Vector3 to compare.
* @param delta - The maximum allowed difference between corresponding components.
* @returns True if the vectors are almost equal; otherwise, false.
*/
almostEqual(x: Vector3, delta: number): boolean;
/**
* Checks if the current vector is almost equal to a Direction within a given tolerance (delta).
*
* @param x - The Direction to compare.
* @param delta - The maximum allowed difference between corresponding components.
* @returns True if the vectors are almost equal; otherwise, false.
*/
almostEqual(x: Direction, delta: number): boolean;
/**
* Checks if the current vector is almost equal to a vector represented by an array of numbers,
* within a given tolerance (delta).
*
* @param x - The array of numbers representing the vector.
* @param delta - The maximum allowed difference between corresponding components.
* @returns True if the vectors are almost equal; otherwise, false.
*/
almostEqual(x: number[], delta: number): boolean;
/**
* Checks if the current vector is exactly equal to another vector defined by three numbers.
*
* @param x - The x component of the other vector.
* @param y - The y component of the other vector.
* @param z - The z component of the other vector.
* @returns True if the vectors are exactly equal; otherwise, false.
*/
equals(x: number, y: number, z: number): boolean;
/**
* Checks if the current vector is exactly equal to another Vec3.
*
* @param x - The Vec3 to compare.
* @returns True if the vectors are exactly equal; otherwise, false.
*/
equals(x: Vec3): boolean;
/**
* Checks if the current vector is exactly equal to another Vector3.
*
* @param x - The Vector3 to compare.
* @returns True if the vectors are exactly equal; otherwise, false.
*/
equals(x: Vector3): boolean;
/**
* Checks if the current vector is exactly equal to a Direction.
*
* @param x - The Direction to compare.
* @returns True if the vectors are exactly equal; otherwise, false.
*/
equals(x: Direction): boolean;
/**
* Checks if the current vector is exactly equal to a vector represented by an array of numbers.
*
* @param x - The array of numbers representing the vector.
* @returns True if the vectors are exactly equal; otherwise, false.
*/
equals(x: number[]): boolean;
/**
* Converts the vector to a string representation.
*
* @param format - The format of the string representation. Defaults to "long".
* @param separator - The separator to use between components. Defaults to ", ".
* @returns The string representation of the vector.
* @remarks
* The "long" format is "Vec3(x, y, z)".
* The "short" format is "x, y, z".
*/
toString(format?: 'long' | 'short', separator?: string): string;
/**
* Parses a string representation of a vector.
*
* @param str - The string representation of the vector.
* @param format - The format of the string representation. Defaults to "long".
* @param separator - The separator to use between components. Defaults to ", ".
* @returns The vector parsed from the string.
* @throws {Error} If the string format is invalid.
*/
static fromString(str: string, format?: 'long' | 'short', separator?: string): Vec3;
}
declare class MutVec2 implements Vector2 {
x: number;
y: number;
constructor(x: number, y: number);
constructor(x: MutVec2);
constructor(x: Vec2);
constructor(x: Vector2);
constructor(x: VectorXZ);
constructor(x: Direction);
constructor(x: number[]);
static from(x: number, y: number): MutVec2;
static from(x: MutVec2): MutVec2;
static from(x: Vec2): MutVec2;
static from(x: Vector2): MutVec2;
static from(x: VectorXZ): MutVec2;
static from(x: Direction): MutVec2;
static from(x: number[]): MutVec2;
private static _from;
copy(): MutVec2;
toImmutable(): Vec2;
static fromYaw(yaw: number): MutVec2;
toYaw(): number;
add(x: number, y: number): MutVec2;
add(x: MutVec2): MutVec2;
add(x: Vec2): MutVec2;
add(x: Vector2): MutVec2;
add(x: VectorXZ): MutVec2;
add(x: Direction): MutVec2;
add(x: number[]): MutVec2;
add(x: number): MutVec2;
directionTo(x: number, y: number): MutVec2;
directionTo(x: MutVec2): MutVec2;
directionTo(x: Vec2): MutVec2;
directionTo(x: Vector2): MutVec2;
directionTo(x: VectorXZ): MutVec2;
directionTo(x: Direction): MutVec2;
directionTo(x: number[]): MutVec2;
subtract(x: number, y: number): MutVec2;
subtract(x: MutVec2): MutVec2;
subtract(x: Vec2): MutVec2;
subtract(x: Vector2): MutVec2;
subtract(x: VectorXZ): MutVec2;
subtract(x: Direction): MutVec2;
subtract(x: number[]): MutVec2;
subtract(x: number): MutVec2;
multiply(x: number, y: number): MutVec2;
multiply(x: MutVec2): MutVec2;
multiply(x: Vec2): MutVec2;
multiply(x: Vector2): MutVec2;
multiply(x: VectorXZ): MutVec2;
multiply(x: Direction): MutVec2;
multiply(x: number[]): MutVec2;
multiply(x: number): MutVec2;
scale(scalar: number): MutVec2;
divide(x: number, y: number): MutVec2;
divide(x: MutVec2): MutVec2;
divide(x: Vec2): MutVec2;
divide(x: Vector2): MutVec2;
divide(x: VectorXZ): MutVec2;
divide(x: Direction): MutVec2;
divide(x: number[]): MutVec2;
divide(x: number): MutVec2;
normalize(): MutVec2;
length(): number;
lengthSquared(): number;
distance(x: number, y: number): number;
distance(x: MutVec2): number;
distance(x: Vec2): number;
distance(x: Vector2): number;
distance(x: VectorXZ): number;
distance(x: Direction): number;
distance(x: number[]): number;
distanceSquared(x: number, y: number): number;
distanceSquared(x: MutVec2): number;
distanceSquared(x: Vec2): number;
distanceSquared(x: Vector2): number;
distanceSquared(x: VectorXZ): number;
distanceSquared(x: Direction): number;
distanceSquared(x: number[]): number;
lerp(v: Vector2, t: number): MutVec2;
slerp(v: Vector2, t: number): MutVec2;
dot(x: number, y: number): number;
dot(x: MutVec2): number;
dot(x: Vec2): number;
dot(x: Vector2): number;
dot(x: VectorXZ): number;
dot(x: Direction): number;
dot(x: number[]): number;
angleBetween(x: number, y: number): number;
angleBetween(x: MutVec2): number;
angleBetween(x: Vec2): number;
angleBetween(x: Vector2): number;
angleBetween(x: Direction): number;
angleBetween(x: number[]): number;
projectOnto(x: number, y: number): MutVec2;
projectOnto(x: MutVec2): MutVec2;
projectOnto(x: Vec2): MutVec2;
projectOnto(x: Vector2): MutVec2;
projectOnto(x: VectorXZ): MutVec2;
projectOnto(x: Direction): MutVec2;
projectOnto(x: number[]): MutVec2;
reflect(x: number, y: number): MutVec2;
reflect(x: MutVec2): MutVec2;
reflect(x: Vec2): MutVec2;
reflect(x: Vector2): MutVec2;
reflect(x: VectorXZ): MutVec2;
reflect(x: Direction): MutVec2;
reflect(x: number[]): MutVec2;
toVec3(z?: number): Vec3;
setX(value: number): MutVec2;
setX(value: (x: number) => number): MutVec2;
setY(value: number): MutVec2;
setY(value: (y: number) => number): MutVec2;
update(x: ((x: number) => number) | undefined, y: ((y: number) => number) | undefined): MutVec2;
floor(): MutVec2;
floorX(): MutVec2;
floorY(): MutVec2;
ceil(): MutVec2;
ceilX(): MutVec2;
ceilY(): MutVec2;
round(): MutVec2;
roundX(): MutVec2;
roundY(): MutVec2;
north(): MutVec2;
south(): MutVec2;
east(): MutVec2;
west(): MutVec2;
isZero(): boolean;
toArray(): number[];
toDirection(): Direction;
toBlockLocation(): MutVec2;
almostEqual(x: number, y: number, delta: number): boolean;
almostEqual(x: MutVec2, delta: number): boolean;
almostEqual(x: Vec2, delta: number): boolean;
almostEqual(x: Vector2, delta: number): boolean;
almostEqual(x: VectorXZ, delta: number): boolean;
almostEqual(x: Direction, delta: number): boolean;
almostEqual(x: number[], delta: number): boolean;
equals(x: number, y: number): boolean;
equals(x: MutVec2): boolean;
equals(x: Vec2): boolean;
equals(x: Vector2): boolean;
equals(x: VectorXZ): boolean;
equals(x: Direction): boolean;
equals(x: number[]): boolean;
toString(format?: 'long' | 'short', separator?: string): string;
}
declare class Vec2 implements Vector2 {
private static readonly log;
static readonly Zero: Vec2;
static readonly North: Vec2;
static readonly South: Vec2;
static readonly East: Vec2;
static readonly West: Vec2;
readonly x: number;
readonly y: number;
constructor(x: number, y: number);
constructor(x: Vec2);
constructor(x: Vec3);
constructor(x: Vector2);
constructor(x: Direction);
constructor(x: number[]);
/**
* Creates a new vector from the given values.
*/
static from(x: number, y: number): Vec2;
static from(x: Vec2): Vec2;
static from(x: Vector2): Vec2;
static from(x: VectorXZ): Vec2;
static from(x: Direction): Vec2;
static from(x: number[]): Vec2;
private static _from;
/**
* Creates a copy of the current vector.
*
* @returns A new vector with the same values as the current vector.
*/
copy(): Vec2;
/**
* Creates a mutable copy of the current vector.
*
* @returns A mutable vector with the same values as the current vector.
*/
toMutable(): MutVec2;
/**
* Creates a new direction vector from yaw rotation.
*
* @param yaw - The yaw value in degrees.
* @returns A new vector representing the direction.
*/
static fromYaw(yaw: number): Vec2;
/**
* Converts the normal vector to yaw and pitch values.
*
* @returns A Vector2 containing the yaw and pitch values.
*/
toYaw(): number;
/**
* Adds another vector to the current vector.
*
* @param v - The vector to be added.
* @returns The updated vector after addition.
*/
add(x: number, y: number): Vec2;
add(x: Vec2): Vec2;
add(x: Vector2): Vec2;
add(x: VectorXZ): Vec2;
add(x: Direction): Vec2;
add(x: number[]): Vec2;
add(x: number): Vec2;
/**
* Returns the normalized vector pointing from this vector to the input.
*
* @param v - The vector to point towards.
* @returns The direction to the passed in Vector. Equivalent to (B-A).normalized()
*/
directionTo(x: number, y: number): Vec2;
directionTo(x: Vec2): Vec2;
directionTo(x: Vector2): Vec2;
directionTo(x: VectorXZ): Vec2;
directionTo(x: Direction): Vec2;
directionTo(x: number[]): Vec2;
/**
* Subtracts another vector from the current vector.
*
* @param v - The vector to be subtracted.
* @returns The updated vector after subtraction.
*/
subtract(x: number, y: number): Vec2;
subtract(x: Vec2): Vec2;
subtract(x: Vector2): Vec2;
subtract(x: VectorXZ): Vec2;
subtract(x: Direction): Vec2;
subtract(x: number[]): Vec2;
subtract(x: number): Vec2;
/**
* Multiplies the current vector by another vector or scalar.
*
* @param v - The vector or scalar to multiply with.
* @returns The updated vector after multiplication.
*/
multiply(x: number, y: number): Vec2;
multiply(x: Vec2): Vec2;
multiply(x: Vector2): Vec2;
multiply(x: VectorXZ): Vec2;
multiply(x: Direction): Vec2;
multiply(x: number[]): Vec2;
multiply(x: number): Vec2;
/**
* Scales the current vector by a scalar.
*
* @param v - The scalar to scale by.
* @returns The updated vector after scaling.
*/
scale(scalar: number): Vec2;
/**
* Divides the current vector by another vector or scalar.
*
* @param v - The vector or scalar to divide by.
* @returns The updated vector after division.
*/
divide(x: number, y: number): Vec2;
divide(x: Vec2): Vec2;
divide(x: Vector2): Vec2;
divide(x: VectorXZ): Vec2;
divide(x: Direction): Vec2;
divide(x: number[]): Vec2;
divide(x: number): Vec2;
/**
* Normalizes the vector to have a length (magnitude) of 1.
* Normalized vectors are often used as a direction vectors.
*
* @returns The normalized vector.
*/
normalize(): Vec2;
/**
* Computes the length (magnitude) of the vector.
*
* @returns The length of the vector.
*/
length(): number;
/**
* Computes the squared length of the vector.
* This is faster than computing the actual length and can be useful for comparison purposes.
*
* @returns The squared length of the vector.
*/
lengthSquared(): number;
/**
* Computes the distance between the current vector and another vector.
*
* @param v - The other vector.
* @returns The distance between the two vectors.
*/
distance(x: number, y: number): number;
distance(x: Vec2): number;
distance(x: Vector2): number;
distance(x: VectorXZ): number;
distance(x: Direction): number;
distance(x: number[]): number;
/**
* Computes the squared distance between the current vector and another vector.
* This is faster than computing the actual distance and can be useful for comparison purposes.
*
* @param v - The other vector.
* @returns The squared distance between the two vectors.
*/
distanceSquared(x: number, y: number): number;
distanceSquared(x: Vec2): number;
distanceSquared(x: Vector2): number;
distanceSquared(x: VectorXZ): number;
distanceSquared(x: Direction): number;
distanceSquared(x: number[]): number;
/**
* Computes the linear interpolation between the current vector and another vector, when t is in the range [0, 1].
* Computes the extrapolation when t is outside this range.
*
* @param v - The other vector.
* @param t - The interpolation factor.