UNPKG

@bedrock-oss/bedrock-boost

Version:

A utility package with helper functions for developing add-ons with Script API in Minecraft Bedrock Edition

1,444 lines (1,436 loc) 74.3 kB
import { Vector3, Direction, Vector2, Dimension, BlockPermutation, Entity, EntityQueryOptions, Player, RGBA, EquipmentSlot } from '@minecraft/server'; import { NumberRange } from '@minecraft/common'; 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; /** * 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. * @deprecated Use fromRotation() instead. This method returns inverted values and will be removed in the future. */ static fromYawPitch(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. * @deprecated Use fromRotation() instead. This method returns inverted values and will be removed in the future. */ static fromYawPitch(yaw: number, pitch: number): Vec3; /** * 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. * @deprecated Use toRotation() instead. This method returns inverted values and will be removed in the future. */ toYawPitch(): Vector2; /** * 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 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; /** * 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 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; /** * 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; /** * 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; } /** * A simple class to measure the time it takes to perform an operation. */ declare class Timings { private static readonly log; static lastTime: number; static lastOperation: string; /** * Begin measuring the time it takes to perform an operation. * @remarks * If another operation is already being measured, the measurement will be ended. * * @param operation The name of the operation. */ static begin(operation: string): void; /** * End measuring the time it takes to perform an operation and log the result. * @remarks * If no operation is being measured, this method will do nothing. */ static end(): void; } /** * Schedules a dummy function each tick to fix the issues with the profiler. * Somehow the profiler adds the idle time waiting for the next tick to the last * function that was called. This is a workaround to fix that. * * Ensure, that you call this function so that the `system.runInterval` inside will * run the dummy function always as the last function in a tick. * * The call that was chosen to be the dummy function is `system.currentTick`. */ declare function addIdleDummy(): void; /** * Clears the dummy function that was scheduled by `addIdleDummy`. */ declare function clearIdleDummy(): void; /** * Returns a dimension from the cache or gets it from the API and caches it. * @param name The name of the dimension. * @returns The dimension. */ declare function getDimension(name: string): Dimension; /** * Returns a dimension height range from the cache or gets it from the API and caches it. * @param name The name of the dimension. * @returns The dimension height range. */ declare function getDimensionHeightRange(name: string): NumberRange; /** * Returns a block permutation from the cache or gets it from the API and caches it. * @param blockName The name of the block. * @param states The block states. * @returns The block permutation. */ declare function getBlockPermutation(blockName: string, states?: Record<string, boolean | number | string>): BlockPermutation; /** * ChatColor is a class for defining color codes. */ declare class ChatColor { private code; private color?; /** * Black color code. (0) */ static readonly BLACK: ChatColor; /** * Dark blue color code. (1) */ static readonly DARK_BLUE: ChatColor; /** * Dark green color code. (2) */ static readonly DARK_GREEN: ChatColor; /** * Dark aqua color code. (3) */ static readonly DARK_AQUA: ChatColor; /** * Dark red color code. (4) */ static readonly DARK_RED: ChatColor; /** * Dark purple color code. (5) */ static readonly DARK_PURPLE: ChatColor; /** * Gold color code. (6) */ static readonly GOLD: ChatColor; /** * Gray color code. (7) */ static readonly GRAY: ChatColor; /** * Dark gray color code. (8) */ static readonly DARK_GRAY: ChatColor; /** * Blue color code. (9) */ static readonly BLUE: ChatColor; /** * Green color code. (a) */ static readonly GREEN: ChatColor; /** * Aqua color code. (b) */ static readonly AQUA: ChatColor; /** * Red color code. (c) */ static readonly RED: ChatColor; /** * Light purple color code. (d) */ static readonly LIGHT_PURPLE: ChatColor; /** * Yellow color code. (e) */ static readonly YELLOW: ChatColor; /** * White color code. (f) */ static readonly WHITE: ChatColor; /** * MineCoin gold color code. (g) */ static readonly MINECOIN_GOLD: ChatColor; /** * Material quartz color code. (h) */ static readonly MATERIAL_QUARTZ: ChatColor; /** * Material iron color code. (i) */ static readonly MATERIAL_IRON: ChatColor; /** * Material netherite color code. (j) */ static readonly MATERIAL_NETHERITE: ChatColor; /** * Material redstone color code. (m) */ static readonly MATERIAL_REDSTONE: ChatColor; /** * Material copper color code. (n) */ static readonly MATERIAL_COPPER: ChatColor; /** * Material gold color code. (p) */ static readonly MATERIAL_GOLD: ChatColor; /** * Material emerald color code. (q) */ static readonly MATERIAL_EMERALD: ChatColor; /** * Material diamond color code. (s) */ static readonly MATERIAL_DIAMOND: ChatColor; /** * Material lapis color code. (t) */ static readonly MATERIAL_LAPIS: ChatColor; /** * Material amethyst color code. (u) */ static readonly MATERIAL_AMETHYST: ChatColor; /** * Obfuscated color code. (k) */ static readonly OBFUSCATED: ChatColor; /** * Bold color code. (l) */ static readonly BOLD: ChatColor; /** * Italic color code. (o) */ static readonly ITALIC: ChatColor; /** * Reset color code. (r) */ static readonly RESET: ChatColor; /** * All available color codes. */ static readonly VALUES: ChatColor[]; /** * All available color codes excluding the formatting codes. */ static readonly ALL_COLORS: ChatColor[]; private r?; private g?; private b?; /** * Class ChatColor Constructor. * @param code - The color code as a string. * @param color - The color code as a hexadecimal number. Can be undefined. */ constructor(code: string, color?: number | undefined); /** * PREFIX is the section sign (§) used in Minecraft color codes. */ private static readonly PREFIX; /** * Returns the string representation of the ChatColor instance, * which includes the PREFIX followed by the color code. * @returns A string representing the ChatColor instance */ toString(): string; /** * Returns the color code of the ChatColor instance. * @returns The color code of this ChatColor instance. */ toRGB(): number | undefined; /** * Returns the hexadecimal string representation of the color code * @returns {string | undefined} The hexadecimal representation of the color. */ toHex(): string | undefined; /** * Retrieve the value of the red component. * * @returns {number | undefined} The value of the red component, or undefined if it is not set. */ getRed(): number | undefined; /** * Retrieves the green value of the current color. * * @returns {number | undefined} The green value of the color, or undefined if it is not set. */ getGreen(): number | undefined; /** * Retrieves the blue value of a color. * * @returns The blue value of the color. * @type {number | undefined} */ getBlue(): number | undefined; /** * Retrieves the format code associated with the chat color. * * @returns {string} The format code of the chat color. */ getCode(): string; /** * Removes color codes from the specified string * @param str - The string from which color codes will be removed. * @returns The string cleared from color codes. */ static stripColor(str: string): string; /** * Finds the closest ChatColor code for the given RGB values * @param r - Red part of the color. * @param g - Green part of the color. * @param b - Blue part of the color. * @returns The closest ChatColor for the given RGB values. */ static findClosestColor(r: number, g: number, b: number): ChatColor; } interface Context { indentLevel: number; visited: WeakSet<any>; } declare class ColorJSON { OpenObject: string; CloseObject: string; OpenArray: string; CloseArray: string; Comma: string; KeyValueSeparator: string; StringDelimiter: string; KeyDelimiter: string; Indent: string; NewLine: string; Space: string; InlineThreshold: number; MaxDepth: number; IncludeClassNames: boolean; FunctionValue: string; NullValue: string; UndefinedValue: string; TrueValue: string; FalseValue: string; CycleValue: string; TruncatedObjectValue: string; OpenCloseObjectColor: ChatColor | string; OpenCloseArrayColor: ChatColor | string; NumberColor: ChatColor | string; StringColor: ChatColor | string; BooleanColor: ChatColor | string; NullColor: ChatColor | string; KeyColor: ChatColor | string; EscapeColor: ChatColor | string; FunctionColor: ChatColor | string; ClassColor: ChatColor | string; ClassStyle: ChatColor | string; CycleColor: ChatColor | string; /** * The default ColorJSON instance */ static readonly DEFAULT: ColorJSON; private static createPlain; /** * A ColorJSON instance that does not colorize anything. */ static readonly PLAIN: ColorJSON; /** * Transforms a value into a chat-friendly, colored JSON representation. * @param value - The value to transform. */ stringify(value: unknown): string; /** * Transforms a string into a JSON representation. * @param value - The string to transform. */ protected stringifyString(value: string): string; /** * Transforms a number into a JSON representation. * @param value - The number to transform. */ protected stringifyNumber(value: number): string; /** * Transforms a boolean into a JSON representation. * @param value - The boolean to transform. */ protected stringifyBoolean(value: boolean): string; /** * Transforms a function into a JSON representation. * @param value - The function to transform. */ protected stringifyFunction(value: Function): string; /** * Returns a null JSON representation. */ protected stringifyNull(): string; /** * Returns an undefined JSON representation. */ protected stringifyUndefined(): string; /** * Returns a cycle JSON representation. */ protected stringifyCycle(): string; /** * Transforms an array into a JSON representation. * @param value - The array to transform. * @param indentLevel - The indentation level for pretty-printing. */ protected stringifyArray(value: unknown[], ctx: Context): string; /** * Transforms an object into a truncated JSON representation. * @param value - The object to transform. * @param className - Class Name of the object. * @param indentLevel - The indentation level for pretty-printing. */ protected stringifyTruncatedObject(value: object, className: string, ctx: Context): string; /** * Transforms an object into a JSON representation. * @param value - The object to transform. * @param className - Class Name of the object. * @param entries - Entries of the object to transform. * @param indentLevel - The indentation level for pretty-printing. */ protected stringifyObject(value: object, className: string, entries: any[][], ctx: Context): string; protected shouldTruncateObject(value: object, className: string, ctx: Context): boolean; /** * Transforms a value of any type into a JSON representation. This function is not meant to be overridden. * @param value - The value to transform. * @param indentLevel - The indentation level for pretty-printing. */ protected stringifyValue(value: unknown, ctx: Context): string; /** * Escapes a string for JSON. * @param str - The string to escape. */ protected escapeString(str: string): string; private markCycle; private isCycle; private clearCycle; private indent; } /** * The `OutputType` enum defines the various types of outputs that the logger can use. */ declare enum OutputType { /** * Uses `world.sendMessage` to send the log message to the chat. */ Chat = 0, /** * Uses `console.log` to send the log message to the console. */ ConsoleInfo = 1, /** * Uses `console.warn` to send the log message to the console as a warning. */ ConsoleWarn = 2, /** * Uses `console.error` to send the log message to the console as an error. */ ConsoleError = 3 } /** * The `LogLevel` class defines the various logging levels used by the logger. */ declare class LogLevel { readonly level: number; readonly name: string; color: ChatColor; static All: LogLevel; static Trace: LogLevel; static Debug: LogLevel; static Info: LogLevel; static Warn: LogLevel; static Error: LogLevel; static Fatal: LogLevel; static Off: LogLevel; /** * The list of all available log levels. */ static values: LogLevel[]; /** * The constructor for each log level. * * @param {number} level - The numerical level for this logger. * @param {string} name - The string name for this logger. * @param {ChatColor} color - The color to use for this logger. Defaults to `ChatColor.RESET`. */ private constructor(); /** * Return the logging level as a string. * * @returns {string} The string representation of the logging level. */ toString(): string; /** * Parse a string to get the corresponding `LogLevel`. * * @param {string} str - The string to parse. * @returns {LogLevel} The corresponding `LogLevel`, or `undefined` if none was found. */ static parse(str: string): LogLevel | undefined; } /** * The `OutputConfig` type defines the configuration for the logger's outputs. * It is a mapping of `LogLevel` to an array of `OutputType`. */ type OutputConfig = { [key in LogLevel["level"]]?: OutputType[]; }; /** * The Logger class. */ declare class Logger { name: string; tags: string[]; private static initialized; /** * Initialize logger class */ static init(): void; /** * @param {LogLevel} level - The level to set. */ static setLevel(level: LogLevel): void; /** * Filter the loggers by the given tags. Tags can use the `*` wildcard. * @param {'*' | string[]} filter - The filter to set. */ static setFilter(filter: "*" | string[]): void; /** * Set the format function for the logger. * @param {function} func - The function to set. */ static setFormatFunction(func: (level: LogLevel, logger: Logger, message: string) => string): void; /** * Set the function, that joins multiple messages into one for the logger. * @param {function} func - The function to set. */ static setMessagesJoinFunction(func: (messages: string[]) => string): void; /** * Set the tag visibility for the logger. When true, tags will be printed in the log. Disabled by default. * @param visible */ static setTagsOutputVisibility(visible: boolean): void; /** * Set the JSON formatter for the logger. * @param {ColorJSON} formatter - The json formatter to set. */ static setJsonFormatter(formatter: ColorJSON): void; /** * Get the output configuration for the logger. * @returns {OutputConfig} The output configuration. */ static getOutputConfig(): OutputConfig; /** * Returns a new Logger. * * @param {string} name - The name of the Logger. * @param {string[]} tags - The tags for the Logger as strings. * * @returns {Logger} A new Logger. */ static getLogger(name: string, ...tags: string[]): Logger; /** * Construct a new Logger * * @param {string} name - The name of the Logger. * @param {string[]} tags - The tags for the logger as strings. */ private constructor(); /** * Log messages with the level set. * * @param {LogLevel} level - The LogLevel to log the messages at. * @param {array} message - An array of the messages to log. */ private log; private stringifyError; /** * Internal function to log messages with the level set, that bypasses the filters. * * @param {LogLevel} level - The LogLevel to log the messages at. * @param {array} message - An array of the messages to log. */ private logRaw; /** * Logs a trace message. * * @param {...unknown} message - The message(s) to be logged. */ trace(...message: unknown[]): void; /** * Logs debug message. * * @param {...unknown[]} message - The message(s) to be logged. */ debug(...message: unknown[]): void; /** * Logs an informational message. * * @param {...unknown[]} message - The message(s) to be logged. */ info(...message: unknown[]): void; /** * Logs a warning message. * * @param {...unknown[]} message - The warning message or messages to be logged. */ warn(...message: unknown[]): void; /** * Logs an error message. * * @param {...unknown[]} message - The error message(s) to log. */ error(...message: unknown[]): void; /** * Logs a fatal error. * * @param {unknown[]} message - The error message to log. */ fatal(...message: unknown[]): void; } declare class Polyfill { private static _installed; /** * Installs the polyfill for the console. * * This polyfill makes `console.log` send a message to the world chat. */ static installConsole(): void; /** * Installs the polyfill for the player. * * This polyfill adds the following methods to the player: *