From 42955eee3dfea1ddb53dd8fd5665161d0107f57a Mon Sep 17 00:00:00 2001 From: NIANIANKNIA Date: Tue, 3 Oct 2023 08:37:21 +0800 Subject: [PATCH] Delete development_behavior_packs/NIA_V4.0_BP/node_modules directory --- .../node_modules/.package-lock.json | 38 - .../@minecraft/server-admin/.eslintrc.json | 23 - .../@minecraft/server-admin/README.md | 9 - .../@minecraft/server-admin/index.d.ts | 81 - .../@minecraft/server-admin/package.json | 16 - .../@minecraft/server-admin/tests.ts | 142 - .../@minecraft/server-admin/tsconfig.json | 20 - .../@minecraft/server-net/.eslintrc.json | 23 - .../@minecraft/server-net/README.md | 9 - .../@minecraft/server-net/index.d.ts | 255 - .../@minecraft/server-net/package.json | 19 - .../@minecraft/server-net/tests.ts | 139 - .../@minecraft/server-net/tsconfig.json | 20 - .../@minecraft/server-ui/.eslintrc.json | 23 - .../@minecraft/server-ui/README.md | 15 - .../@minecraft/server-ui/index.d.ts | 303 - .../@minecraft/server/.eslintrc.json | 23 - .../node_modules/@minecraft/server/README.md | 7 - .../node_modules/@minecraft/server/index.d.ts | 6119 -------- .../@minecraft/server/package.json | 16 - .../node_modules/@minecraft/server/tests.ts | 292 - .../@minecraft/server/tsconfig.json | 20 - .../@minecraft/server-ui/package.json | 19 - .../@minecraft/server-ui/tests.ts | 172 - .../@minecraft/server-ui/tsconfig.json | 20 - .../@minecraft/server/.eslintrc.json | 23 - .../node_modules/@minecraft/server/README.md | 9 - .../node_modules/@minecraft/server/index.d.ts | 12953 ---------------- .../@minecraft/server/package.json | 16 - .../node_modules/@minecraft/server/tests.ts | 292 - .../@minecraft/server/tsconfig.json | 20 - 31 files changed, 21136 deletions(-) delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/.package-lock.json delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/.eslintrc.json delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/README.md delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/index.d.ts delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/package.json delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/tests.ts delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/tsconfig.json delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/.eslintrc.json delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/README.md delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/index.d.ts delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/package.json delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/tests.ts delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/tsconfig.json delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/.eslintrc.json delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/README.md delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/index.d.ts delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/.eslintrc.json delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/README.md delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/index.d.ts delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/package.json delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/tests.ts delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/tsconfig.json delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/package.json delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/tests.ts delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/tsconfig.json delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/.eslintrc.json delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/README.md delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/index.d.ts delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/package.json delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/tests.ts delete mode 100644 development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/tsconfig.json diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/.package-lock.json b/development_behavior_packs/NIA_V4.0_BP/node_modules/.package-lock.json deleted file mode 100644 index 05a8a57..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/.package-lock.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "name": "NIA_V4.0_BP", - "lockfileVersion": 3, - "requires": true, - "packages": { - "node_modules/@minecraft/server": { - "version": "1.6.0-beta.1.20.30-preview.25", - "resolved": "https://registry.npmmirror.com/@minecraft/server/-/server-1.6.0-beta.1.20.30-preview.25.tgz", - "integrity": "sha512-AL1vCn61Ola5NV5EjSlIJSSDhYaom6VW6Q8lyb6wrDZ0ad43GtaMBwZ8hhSBZzZDE4Z/IvFYWomU7zy/VUSO2A==" - }, - "node_modules/@minecraft/server-admin": { - "version": "1.0.0-beta.11940b24", - "resolved": "https://registry.npmmirror.com/@minecraft/server-admin/-/server-admin-1.0.0-beta.11940b24.tgz", - "integrity": "sha512-UZ8YyB8mvF31f22+uM67gJums9d6NDgz9AQ2l4a++EHUP9uen0m3aaBaqM9RyumJpRBJbv/hslAKOyeDT01qew==" - }, - "node_modules/@minecraft/server-net": { - "version": "1.0.0-beta.1.20.10-stable", - "resolved": "https://registry.npmmirror.com/@minecraft/server-net/-/server-net-1.0.0-beta.1.20.10-stable.tgz", - "integrity": "sha512-1UW6Qyh3uLkaAILm6yXtH2WCI0lZTNyhelDCPDXuqcRgveWOrgPPIzJNJSYMUWc6Z9BQkMR3yTvHUCjPEgiNIA==", - "dependencies": { - "@minecraft/server-admin": "^1.0.0-beta.1.20.10-stable" - } - }, - "node_modules/@minecraft/server-ui": { - "version": "1.2.0-beta.1.20.10-stable", - "resolved": "https://registry.npmmirror.com/@minecraft/server-ui/-/server-ui-1.2.0-beta.1.20.10-stable.tgz", - "integrity": "sha512-ciStJuaHMxQhddJzZPiaJJBi6LjVEugr5LoamUaQhdd2qfgILAz/k3Nfwsx7YYDSTrg6jmMrAj4+Na5IJ7VITw==", - "dependencies": { - "@minecraft/server": "^1.4.0-beta.1.20.10-stable" - } - }, - "node_modules/@minecraft/server-ui/node_modules/@minecraft/server": { - "version": "1.5.0", - "resolved": "https://registry.npmmirror.com/@minecraft/server/-/server-1.5.0.tgz", - "integrity": "sha512-4R50srYzksXaOXZp1M4RkQ9KMw26F3Y3YC+YEInFpIjVmQr9OEitAgjUm4+mmIRwxuh7JsuBcE5yinDpYx59/g==" - } - } -} diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/.eslintrc.json b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/.eslintrc.json deleted file mode 100644 index 746934f..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/.eslintrc.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "env": { - "browser": true, - "es2021": true - }, - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended" - ], - "overrides": [ - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module" - }, - "plugins": [ - "@typescript-eslint" - ], - "rules": { - "@typescript-eslint/no-explicit-any": "off" - } -} diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/README.md b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/README.md deleted file mode 100644 index b0f728b..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# `@minecraft/server-admin` - -Contains types related to administering a Bedrock Dedicated Server. These types allow for the configuration of variables and secrets in JSON files in the Bedrock Dedicated Server folder. These types cannot be used on Minecraft clients. - -## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.** - -See full documentation for this module here: - -https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/@minecraft/server-admin/@minecraft/server-admin \ No newline at end of file diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/index.d.ts b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/index.d.ts deleted file mode 100644 index 5453fee..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/index.d.ts +++ /dev/null @@ -1,81 +0,0 @@ -// Type definitions for Minecraft Bedrock Edition script APIs -// Project: https://docs.microsoft.com/minecraft/creator/ -// Definitions by: Jake Shirley -// Mike Ammerlaan - -/* ***************************************************************************** - Copyright (c) Microsoft Corporation. - ***************************************************************************** */ -/** - * @packageDocumentation - * Contains types related to administering a Bedrock Dedicated - * Server. These types allow for the configuration of variables - * and secrets in JSON files in the Bedrock Dedicated Server - * folder. These types cannot be used on Minecraft clients. - * - * Manifest Details - * ```json - * { - * "module_name": "@minecraft/server-admin", - * "version": "1.0.0-beta.11940b24" - * } - * ``` - * - */ -/** - * This represents a placeholder object that represents a - * secret string. The contents of that string are not available - * to script; this object is just a placeholder. - */ -// tslint:disable-next-line:no-unnecessary-class -export class SecretString { - constructor(value: string); -} -/** - * A collection of server secrets defined in dedicated server - * configuration. - */ -export class ServerSecrets { - /** - * A list of available, configured server secrets. - */ - readonly names: string[]; - /** - * @remarks - * Returns a SecretString that is a placeholder for a secret - * configured in a JSON file. In certain objects, like an - * HttpHeader, this Secret is resolved at the time of execution - * but is not made available to the script environment. - * @param name - */ - get(name: string): SecretString; - protected constructor(); -} -/** - * A collection of server variables defined in dedicated server - * configuration. - */ -export class ServerVariables { - /** - * A list of available, configured server variables. - */ - readonly names: string[]; - /** - * @remarks - * Returns the value of variable that has been configured in a - * dedicated server configuration JSON file. - * @param name - */ - get(name: string): any; - protected constructor(); -} -/** - * A globally available object that returns a list of - * dedicated-server configured secrets. - */ -export const secrets: ServerSecrets; -/** - * A globally available object that returns a list of - * dedicated-server configured variables. - */ -export const variables: ServerVariables; diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/package.json b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/package.json deleted file mode 100644 index bd1a8b4..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "@minecraft/server-admin", - "version": "1.0.0-beta.11940b24", - "description": "", - "contributors": [ - { - "name": "Jake Shirley", - "email": "jake@xbox.com" - }, - { - "name": "Mike Ammerlaan", - "email": "mikeam@microsoft.com" - } - ], - "license": "MIT" -} \ No newline at end of file diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/tests.ts b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/tests.ts deleted file mode 100644 index 4a0405c..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/tests.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unused-vars */ -import * as mc from '@minecraft/server'; - -export async function getPlayerProfile(log: (message: string, status?: number) => void, targetLocation: mc.Location) { - const serverUrl = mcsa.variables.get('serverEndpoint'); - - const req = new mcnet.HttpRequest(serverUrl + 'getPlayerProfile'); - - req.body = JSON.stringify({ - playerId: 'johndoe', - }); - - req.method = mcnet.HttpRequestMethod.POST; - req.headers = [ - new mcnet.HttpHeader('Content-Type', 'application/json'), - new mcnet.HttpHeader('auth', mcsa.secrets.get('authtoken')), - ]; - - await mcnet.http.request(req); -} - -export default class SampleManager { - tickCount = 0; - - _availableFuncs: { - [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Location) => void>; - }; - - pendingFuncs: Array<{ - name: string; - func: (log: (message: string, status?: number) => void, location: mc.Location) => void; - location: mc.Location; - }> = []; - - gameplayLogger(message: string, status?: number) { - if (status !== undefined && status > 0) { - message = 'SUCCESS: ' + message; - } else if (status !== undefined && status < 0) { - message = 'FAIL: ' + message; - } - - this.say(message); - } - say(message: string) { - mc.world.getDimension('overworld').runCommand('say ' + message); - } - - newChatMessage(chatEvent: mc.ChatEvent) { - const message = chatEvent.message.toLowerCase(); - - if (message.startsWith('howto') && chatEvent.sender) { - const nearbyBlock = chatEvent.sender.getBlockFromViewVector(); - if (!nearbyBlock) { - this.gameplayLogger('Please look at the block where you want me to run this.'); - return; - } - - const nearbyBlockLoc = nearbyBlock.location; - const nearbyLoc = new mc.Location(nearbyBlockLoc.x, nearbyBlockLoc.y + 1, nearbyBlockLoc.z); - - const sampleId = message.substring(5).trim(); - - if (sampleId.length < 2) { - let availableFuncStr = 'Here is my list of available samples:'; - - for (const sampleFuncKey in this._availableFuncs) { - availableFuncStr += ' ' + sampleFuncKey; - } - - this.say(availableFuncStr); - } else { - for (const sampleFuncKey in this._availableFuncs) { - if (sampleFuncKey.toLowerCase() === sampleId) { - const sampleFunc = this._availableFuncs[sampleFuncKey]; - - this.runSample(sampleFuncKey + this.tickCount, sampleFunc, nearbyLoc); - - return; - } - } - - this.say(`I couldn't find the sample '${sampleId}"'`); - } - } - } - - runSample( - sampleId: string, - snippetFunctions: Array<(log: (message: string, status?: number) => void, location: mc.Location) => void>, - targetLocation: mc.Location, - ) { - for (let i = snippetFunctions.length - 1; i >= 0; i--) { - this.pendingFuncs.push({ name: sampleId, func: snippetFunctions[i], location: targetLocation }); - } - } - - worldTick() { - if (this.tickCount % 10 === 0) { - if (this.pendingFuncs.length > 0) { - const funcSet = this.pendingFuncs.pop(); - - if (funcSet) { - funcSet.func(this.gameplayLogger, funcSet.location); - } - } - } - - this.tickCount++; - } - - constructor() { - this._availableFuncs = {}; - - this.gameplayLogger = this.gameplayLogger.bind(this); - - mc.world.events.tick.subscribe(this.worldTick.bind(this)); - mc.world.events.chat.subscribe(this.newChatMessage.bind(this)); - } - - registerSamples(sampleSet: { - [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Location) => void>; - }) { - for (const sampleKey in sampleSet) { - if (sampleKey.length > 1 && sampleSet[sampleKey]) { - this._availableFuncs[sampleKey] = sampleSet[sampleKey]; - } - } - } -} - -import * as mcsa from '@minecraft/server-admin'; -import * as mcnet from '@minecraft/server-net'; // keep in for net samples - -const mojangServerAdminTestFuncs: { - [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Location) => void>; -} = { - getPlayerProfile: [getPlayerProfile], -}; - -export function register(sampleManager: SampleManager) { - sampleManager.registerSamples(mojangServerAdminTestFuncs); -} diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/tsconfig.json b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/tsconfig.json deleted file mode 100644 index 2f66b0c..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-admin/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": ["es6"], - "target": "es6", - "forceConsistentCasingInFileNames": true, - "noEmit": true, - "noImplicitAny": true, - "noImplicitThis": true, - "strictFunctionTypes": true, - "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": ["../"], - "types": [] - }, - "files": [ - "index.d.ts", - "tests.ts" - ] -} \ No newline at end of file diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/.eslintrc.json b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/.eslintrc.json deleted file mode 100644 index 746934f..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/.eslintrc.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "env": { - "browser": true, - "es2021": true - }, - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended" - ], - "overrides": [ - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module" - }, - "plugins": [ - "@typescript-eslint" - ], - "rules": { - "@typescript-eslint/no-explicit-any": "off" - } -} diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/README.md b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/README.md deleted file mode 100644 index caee002..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# `@minecraft/server-net` - -The `@minecraft/server-net` module contains types for executing HTTP-based requests. This module can only be used on Bedrock Dedicated Server. - -## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.** - -See full documentation for this module here: - -https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/@minecraft/server-net/@minecraft/server-net \ No newline at end of file diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/index.d.ts b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/index.d.ts deleted file mode 100644 index 41c98fe..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/index.d.ts +++ /dev/null @@ -1,255 +0,0 @@ -// Type definitions for Minecraft Bedrock Edition script APIs -// Project: https://docs.microsoft.com/minecraft/creator/ -// Definitions by: Jake Shirley -// Mike Ammerlaan - -/* ***************************************************************************** - Copyright (c) Microsoft Corporation. - ***************************************************************************** */ -/** - * @beta - * @packageDocumentation - * The `@minecraft/server-net` module contains types for - * executing HTTP-based requests. This module can only be used - * on Bedrock Dedicated Server. - * - * Manifest Details - * ```json - * { - * "module_name": "@minecraft/server-net", - * "version": "1.0.0-beta.1.20.10-stable" - * } - * ``` - * - */ -import * as minecraftserveradmin from '@minecraft/server-admin'; -export enum HttpRequestMethod { - /** - * @remarks - * Represents the method for an HTTP HEAD request. HEAD - * requests are similar to a GET request, but are commonly used - * to retrieve just the HTTP response headers from the - * specified URI, and not the body contents. - * - */ - Delete = 'Delete', - /** - * @remarks - * Represents the method for an HTTP PUT request. POST requests - * are commonly used to create a new resource that is a - * subordinate of the specified URI. - * - */ - Get = 'Get', - /** - * @remarks - * Represents the method for an HTTP PUT request. GET requests - * are commonly used to retrieve information about a resource - * at the specified URI. - * - */ - Head = 'Head', - /** - * @remarks - * Represents the method for an HTTP PUT request. GET requests - * are commonly used to retrieve information about a resource - * at the specified URI. - * - */ - Post = 'Post', - /** - * @remarks - * Represents the method for an HTTP PUT request. PUT requests - * are commonly used to update a single resource that already - * exists in a resource collection. - * - */ - Put = 'Put', -} - -export class HttpClient { - private constructor(); - /** - * @remarks - * Cancels all pending requests. - * - * This function can't be called in read-only mode. - * - */ - cancelAll(reason: string): void; - /** - * @remarks - * Performs a simple HTTP get request. - * - * This function can't be called in read-only mode. - * - * @param uri - * URL to make an HTTP Request to. - * @returns - * An awaitable promise that contains the HTTP response. - */ - get(uri: string): Promise; - /** - * @remarks - * Performs an HTTP request. - * - * This function can't be called in read-only mode. - * - * @param config - * Contains an HTTP Request object with configuration data on - * the HTTP request. - * @returns - * An awaitable promise that contains the HTTP response. - */ - request(config: HttpRequest): Promise; -} - -/** - * Represents an HTTP header - a key/value pair of - * meta-information about a request. - */ -export class HttpHeader { - /** - * @remarks - * Key of the HTTP header. - * - * This property can't be edited in read-only mode. - * - */ - key: string; - /** - * @remarks - * Value of the HTTP header. - * - * This property can't be edited in read-only mode. - * - */ - value: minecraftserveradmin.SecretString | string; - constructor(key: string, value: minecraftserveradmin.SecretString | string); -} - -/** - * Main object for structuring a request. - */ -export class HttpRequest { - /** - * @remarks - * Content of the body of the HTTP request. - * - * This property can't be edited in read-only mode. - * - */ - body: string; - /** - * @remarks - * A collection of HTTP headers to add to the outbound request. - * - * This property can't be edited in read-only mode. - * - */ - headers: HttpHeader[]; - /** - * @remarks - * HTTP method (e.g., GET or PUT or PATCH) to use for making - * the request. - * - * This property can't be edited in read-only mode. - * - */ - method: HttpRequestMethod; - /** - * @remarks - * Amount of time, in seconds, before the request times out and - * is abandoned. - * - * This property can't be edited in read-only mode. - * - */ - timeout: number; - /** - * @remarks - * The HTTP resource to access. - * - * This property can't be edited in read-only mode. - * - */ - uri: string; - constructor(uri: string); - /** - * @remarks - * Adds an additional header to the overall list of headers - * used in the corresponding HTTP request. - * - * This function can't be called in read-only mode. - * - */ - addHeader(key: string, value: minecraftserveradmin.SecretString | string): HttpRequest; - /** - * @remarks - * Updates the content of the body of the HTTP request. - * - * This function can't be called in read-only mode. - * - */ - setBody(body: string): HttpRequest; - /** - * @remarks - * Replaces and applies a set of HTTP Headers for the request. - * - * This function can't be called in read-only mode. - * - */ - setHeaders(headers: HttpHeader[]): HttpRequest; - /** - * @remarks - * Sets the desired HTTP method (e.g., GET or PUT or PATCH) to - * use for making the request. - * - * This function can't be called in read-only mode. - * - */ - setMethod(method: HttpRequestMethod): HttpRequest; - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - setTimeout(timeout: number): HttpRequest; -} - -/** - * Main object that contains result information from a request. - */ -export class HttpResponse { - private constructor(); - /** - * @remarks - * Body content of the HTTP response. - * - */ - readonly body: string; - /** - * @remarks - * A collection of HTTP response headers returned from the - * request. - * - */ - readonly headers: HttpHeader[]; - /** - * @remarks - * Information that was used to formulate the HTTP response - * that this object represents. - * - */ - readonly request: HttpRequest; - /** - * @remarks - * HTTP response code for the request. For example, 404 - * represents resource not found, and 500 represents an - * internal server error. - * - */ - readonly status: number; -} - -export const http: HttpClient; diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/package.json b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/package.json deleted file mode 100644 index ba2464c..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "@minecraft/server-net", - "version": "1.0.0-beta.1.20.10-stable", - "description": "", - "contributors": [ - { - "name": "Jake Shirley", - "email": "jake@xbox.com" - }, - { - "name": "Mike Ammerlaan", - "email": "mikeam@microsoft.com" - } - ], - "dependencies": { - "@minecraft/server-admin": "^1.0.0-beta.1.20.10-stable" - }, - "license": "MIT" -} \ No newline at end of file diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/tests.ts b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/tests.ts deleted file mode 100644 index 08ae4bb..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/tests.ts +++ /dev/null @@ -1,139 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unused-vars */ -import * as mc from '@minecraft/server'; - -export async function updateScore(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) { - const req = new mcnet.HttpRequest('http://localhost:3000/updateScore'); - - req.body = JSON.stringify({ - score: 22, - }); - - req.method = mcnet.HttpRequestMethod.POST; - req.headers = [ - new mcnet.HttpHeader('Content-Type', 'application/json'), - new mcnet.HttpHeader('auth', 'my-auth-token'), - ]; - - await mcnet.http.request(req); -} - -export default class SampleManager { - tickCount = 0; - - _availableFuncs: { - [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>; - }; - - pendingFuncs: Array<{ - name: string; - func: (log: (message: string, status?: number) => void, location: mc.Vector3) => void; - location: mc.Vector3; - }> = []; - - gameplayLogger(message: string, status?: number) { - if (status !== undefined && status > 0) { - message = 'SUCCESS: ' + message; - } else if (status !== undefined && status < 0) { - message = 'FAIL: ' + message; - } - - this.say(message); - } - say(message: string) { - mc.world.getDimension('overworld').runCommand('say ' + message); - } - - newChatMessage(chatEvent: mc.ChatEvent) { - const message = chatEvent.message.toLowerCase(); - - if (message.startsWith('howto') && chatEvent.sender) { - const nearbyBlock = chatEvent.sender.getBlockFromViewVector(); - if (!nearbyBlock) { - this.gameplayLogger('Please look at the block where you want me to run this.'); - return; - } - - const nearbyBlockLoc = nearbyBlock.location; - const nearbyLoc = { x: nearbyBlockLoc.x, y: nearbyBlockLoc.y + 1, z: nearbyBlockLoc.z }; - - const sampleId = message.substring(5).trim(); - - if (sampleId.length < 2) { - let availableFuncStr = 'Here is my list of available samples:'; - - for (const sampleFuncKey in this._availableFuncs) { - availableFuncStr += ' ' + sampleFuncKey; - } - - this.say(availableFuncStr); - } else { - for (const sampleFuncKey in this._availableFuncs) { - if (sampleFuncKey.toLowerCase() === sampleId) { - const sampleFunc = this._availableFuncs[sampleFuncKey]; - - this.runSample(sampleFuncKey + this.tickCount, sampleFunc, nearbyLoc); - - return; - } - } - - this.say(`I couldn't find the sample '${sampleId}"'`); - } - } - } - - runSample( - sampleId: string, - snippetFunctions: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>, - targetLocation: mc.Vector3, - ) { - for (let i = snippetFunctions.length - 1; i >= 0; i--) { - this.pendingFuncs.push({ name: sampleId, func: snippetFunctions[i], location: targetLocation }); - } - } - - worldTick() { - if (this.tickCount % 10 === 0) { - if (this.pendingFuncs.length > 0) { - const funcSet = this.pendingFuncs.pop(); - - if (funcSet) { - funcSet.func(this.gameplayLogger, funcSet.location); - } - } - } - - this.tickCount++; - } - - constructor() { - this._availableFuncs = {}; - - this.gameplayLogger = this.gameplayLogger.bind(this); - - mc.world.events.tick.subscribe(this.worldTick.bind(this)); - mc.world.events.chat.subscribe(this.newChatMessage.bind(this)); - } - - registerSamples(sampleSet: { - [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>; - }) { - for (const sampleKey in sampleSet) { - if (sampleKey.length > 1 && sampleSet[sampleKey]) { - this._availableFuncs[sampleKey] = sampleSet[sampleKey]; - } - } - } -} - -import * as mcnet from '@minecraft/server-net'; // keep in for net samples - -const mojangNetAdminTestFuncs: { - [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>; -} = { - updateScore: [updateScore], -}; - -export function register(sampleManager: SampleManager) { - sampleManager.registerSamples(mojangNetAdminTestFuncs); -} diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/tsconfig.json b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/tsconfig.json deleted file mode 100644 index 2f66b0c..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-net/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": ["es6"], - "target": "es6", - "forceConsistentCasingInFileNames": true, - "noEmit": true, - "noImplicitAny": true, - "noImplicitThis": true, - "strictFunctionTypes": true, - "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": ["../"], - "types": [] - }, - "files": [ - "index.d.ts", - "tests.ts" - ] -} \ No newline at end of file diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/.eslintrc.json b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/.eslintrc.json deleted file mode 100644 index 746934f..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/.eslintrc.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "env": { - "browser": true, - "es2021": true - }, - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended" - ], - "overrides": [ - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module" - }, - "plugins": [ - "@typescript-eslint" - ], - "rules": { - "@typescript-eslint/no-explicit-any": "off" - } -} diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/README.md b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/README.md deleted file mode 100644 index d327864..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# `@minecraft/server-ui` - -The `@minecraft/server-ui` module contains types for expressing simple dialog-based user experiences. - - - - * [*@minecraft/server-ui.ActionFormData*](../../minecraft/server-ui/ActionFormData.md) contain a list of buttons with captions and images that can be used for presenting a set of options to a player. - - * [*@minecraft/server-ui.MessageFormData*](../../minecraft/server-ui/MessageFormData.md) are simple two-button message experiences that are functional for Yes/No or OK/Cancel questions. - - * [*@minecraft/server-ui.ModalFormData*](../../minecraft/server-ui/ModalFormData.md) allow for a more flexible "questionnaire-style" list of controls that can be used to take input. - -See full documentation for this module here: - -https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/@minecraft/server-ui/@minecraft/server-ui \ No newline at end of file diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/index.d.ts b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/index.d.ts deleted file mode 100644 index 9182c5b..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/index.d.ts +++ /dev/null @@ -1,303 +0,0 @@ -// Type definitions for Minecraft Bedrock Edition script APIs -// Project: https://docs.microsoft.com/minecraft/creator/ -// Definitions by: Jake Shirley -// Mike Ammerlaan - -/* ***************************************************************************** - Copyright (c) Microsoft Corporation. - ***************************************************************************** */ -/** - * @packageDocumentation - * The `@minecraft/server-ui` module contains types for - * expressing simple dialog-based user experiences. - * - * * {@link ActionFormData} contain a list of buttons with - * captions and images that can be used for presenting a set of - * options to a player. - * * {@link MessageFormData} are simple two-button message - * experiences that are functional for Yes/No or OK/Cancel - * questions. - * * {@link ModalFormData} allow for a more flexible - * "questionnaire-style" list of controls that can be used to - * take input. - * @example createActionForm.js - * ```typescript - * const form = new ActionFormData() - * .title("Months") - * .body("Choose your favorite month!") - * .button("January") - * .button("February") - * .button("March") - * .button("April") - * .button("May"); - * - * form.show(players[0]).then((response) => { - * if (response.selection === 3) { - * dimension.runCommand("say I like April too!"); - * } - * }); - * ``` - * - * Manifest Details - * ```json - * { - * "module_name": "@minecraft/server-ui", - * "version": "1.1.0" - * } - * ``` - * - */ -import * as minecraftserver from '@minecraft/server'; -export enum FormCancelationReason { - UserBusy = 'UserBusy', - UserClosed = 'UserClosed', -} - -export enum FormRejectReason { - MalformedResponse = 'MalformedResponse', - PlayerQuit = 'PlayerQuit', - ServerShutdown = 'ServerShutdown', -} - -/** - * Builds a simple player form with buttons that let the player - * take action. - */ -export class ActionFormData { - /** - * @remarks - * Method that sets the body text for the modal form. - * - * This function can't be called in read-only mode. - * - */ - body(bodyText: minecraftserver.RawMessage | string): ActionFormData; - /** - * @remarks - * Adds a button to this form with an icon from a resource - * pack. - * - * This function can't be called in read-only mode. - * - */ - button(text: minecraftserver.RawMessage | string, iconPath?: string): ActionFormData; - /** - * @remarks - * Creates and shows this modal popup form. Returns - * asynchronously when the player confirms or cancels the - * dialog. - * - * This function can't be called in read-only mode. - * - * @param player - * Player to show this dialog to. - * @throws This function can throw errors. - */ - show(player: minecraftserver.Player): Promise; - /** - * @remarks - * This builder method sets the title for the modal dialog. - * - * This function can't be called in read-only mode. - * - */ - title(titleText: minecraftserver.RawMessage | string): ActionFormData; -} - -/** - * Returns data about the player results from a modal action - * form. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class ActionFormResponse extends FormResponse { - private constructor(); - /** - * @remarks - * Returns the index of the button that was pushed. - * - */ - readonly selection?: number; -} - -/** - * Base type for a form response. - */ -export class FormResponse { - private constructor(); - /** - * @remarks - * Contains additional details as to why a form was canceled. - * - */ - readonly cancelationReason?: FormCancelationReason; - /** - * @remarks - * If true, the form was canceled by the player (e.g., they - * selected the pop-up X close button). - * - */ - readonly canceled: boolean; -} - -/** - * Builds a simple two-button modal dialog. - */ -export class MessageFormData { - /** - * @remarks - * Method that sets the body text for the modal form. - * - * This function can't be called in read-only mode. - * - */ - body(bodyText: minecraftserver.RawMessage | string): MessageFormData; - /** - * @remarks - * Method that sets the text for the first button of the - * dialog. - * - * This function can't be called in read-only mode. - * - */ - button1(text: minecraftserver.RawMessage | string): MessageFormData; - /** - * @remarks - * This method sets the text for the second button on the - * dialog. - * - * This function can't be called in read-only mode. - * - */ - button2(text: minecraftserver.RawMessage | string): MessageFormData; - /** - * @remarks - * Creates and shows this modal popup form. Returns - * asynchronously when the player confirms or cancels the - * dialog. - * - * This function can't be called in read-only mode. - * - * @param player - * Player to show this dialog to. - * @throws This function can throw errors. - */ - show(player: minecraftserver.Player): Promise; - /** - * @remarks - * This builder method sets the title for the modal dialog. - * - * This function can't be called in read-only mode. - * - */ - title(titleText: minecraftserver.RawMessage | string): MessageFormData; -} - -/** - * Returns data about the player results from a modal message - * form. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class MessageFormResponse extends FormResponse { - private constructor(); - /** - * @remarks - * Returns the index of the button that was pushed. - * - */ - readonly selection?: number; -} - -/** - * Used to create a fully customizable pop-up form for a - * player. - */ -export class ModalFormData { - /** - * @remarks - * Adds a dropdown with choices to the form. - * - * This function can't be called in read-only mode. - * - */ - dropdown( - label: minecraftserver.RawMessage | string, - options: (minecraftserver.RawMessage | string)[], - defaultValueIndex?: number, - ): ModalFormData; - /** - * @remarks - * Creates and shows this modal popup form. Returns - * asynchronously when the player confirms or cancels the - * dialog. - * - * This function can't be called in read-only mode. - * - * @param player - * Player to show this dialog to. - * @throws This function can throw errors. - */ - show(player: minecraftserver.Player): Promise; - /** - * @remarks - * Adds a numeric slider to the form. - * - * This function can't be called in read-only mode. - * - */ - slider( - label: minecraftserver.RawMessage | string, - minimumValue: number, - maximumValue: number, - valueStep: number, - defaultValue?: number, - ): ModalFormData; - /** - * @remarks - * Adds a textbox to the form. - * - * This function can't be called in read-only mode. - * - */ - textField( - label: minecraftserver.RawMessage | string, - placeholderText: minecraftserver.RawMessage | string, - defaultValue?: string, - ): ModalFormData; - /** - * @remarks - * This builder method sets the title for the modal dialog. - * - * This function can't be called in read-only mode. - * - */ - title(titleText: minecraftserver.RawMessage | string): ModalFormData; - /** - * @remarks - * Adds a toggle checkbox button to the form. - * - * This function can't be called in read-only mode. - * - */ - toggle(label: minecraftserver.RawMessage | string, defaultValue?: boolean): ModalFormData; -} - -/** - * Returns data about player responses to a modal form. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class ModalFormResponse extends FormResponse { - private constructor(); - /** - * @remarks - * An ordered set of values based on the order of controls - * specified by ModalFormData. - * - */ - readonly formValues?: (boolean | number | string)[]; -} - -// @ts-ignore Class inheritance allowed for native defined classes -export class FormRejectError extends Error { - private constructor(); - reason: FormRejectReason; -} diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/.eslintrc.json b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/.eslintrc.json deleted file mode 100644 index 746934f..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/.eslintrc.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "env": { - "browser": true, - "es2021": true - }, - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended" - ], - "overrides": [ - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module" - }, - "plugins": [ - "@typescript-eslint" - ], - "rules": { - "@typescript-eslint/no-explicit-any": "off" - } -} diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/README.md b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/README.md deleted file mode 100644 index 4dab112..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# `@minecraft/server` - -Contains many types related to manipulating a Minecraft world, including entities, blocks, dimensions, and more. - -See full documentation for this module here: - -https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/minecraft-server \ No newline at end of file diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/index.d.ts b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/index.d.ts deleted file mode 100644 index 2daf73b..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/index.d.ts +++ /dev/null @@ -1,6119 +0,0 @@ -// Type definitions for Minecraft Bedrock Edition script APIs -// Project: https://docs.microsoft.com/minecraft/creator/ -// Definitions by: Jake Shirley -// Mike Ammerlaan - -/* ***************************************************************************** - Copyright (c) Microsoft Corporation. - ***************************************************************************** */ -/** - * @packageDocumentation - * Contains many types related to manipulating a Minecraft - * world, including entities, blocks, dimensions, and more. - * - * Manifest Details - * ```json - * { - * "module_name": "@minecraft/server", - * "version": "1.5.0" - * } - * ``` - * - */ -/** - * A general purpose relative direction enumeration. - */ -export enum Direction { - /** - * @remarks - * Returns the block beneath (y - 1) of this item. - * - */ - Down = 'Down', - /** - * @remarks - * Returns the block to the east (x + 1) of this item. - * - */ - East = 'East', - /** - * @remarks - * Returns the block to the east (z + 1) of this item. - * - */ - North = 'North', - /** - * @remarks - * Returns the block to the south (z - 1) of this item. - * - */ - South = 'South', - /** - * @remarks - * Returns the block above (y + 1) of this item. - * - */ - Up = 'Up', - /** - * @remarks - * Returns the block to the west (x - 1) of this item. - * - */ - West = 'West', -} - -/** - * Specifies a mechanism for displaying scores on a scoreboard. - */ -export enum DisplaySlotId { - /** - * @remarks - * Displays the score below the player's name. - * - */ - BelowName = 'BelowName', - /** - * @remarks - * Displays the score as a list on the pause screen. - * - */ - List = 'List', - /** - * @remarks - * Displays the score on the side of the player's screen. - * - */ - Sidebar = 'Sidebar', -} - -export enum EntityDamageCause { - anvil = 'anvil', - blockExplosion = 'blockExplosion', - charging = 'charging', - contact = 'contact', - drowning = 'drowning', - entityAttack = 'entityAttack', - entityExplosion = 'entityExplosion', - fall = 'fall', - fallingBlock = 'fallingBlock', - fire = 'fire', - fireTick = 'fireTick', - fireworks = 'fireworks', - flyIntoWall = 'flyIntoWall', - freezing = 'freezing', - lava = 'lava', - lightning = 'lightning', - magic = 'magic', - magma = 'magma', - none = 'none', - override = 'override', - piston = 'piston', - projectile = 'projectile', - stalactite = 'stalactite', - stalagmite = 'stalagmite', - starve = 'starve', - suffocation = 'suffocation', - suicide = 'suicide', - temperature = 'temperature', - thorns = 'thorns', - 'void' = 'void', - wither = 'wither', -} - -/** - * The equipment slot of the mob. This includes armor, offhand - * and mainhand slots. - */ -export enum EquipmentSlot { - /** - * @remarks - * The chest slot. This slot is used to hold items such as - * Chestplate or Elytra. - * - */ - Chest = 'Chest', - /** - * @remarks - * The feet slot. This slot is used to hold items such as - * Boots. - * - */ - Feet = 'Feet', - /** - * @remarks - * The head slot. This slot is used to hold items such as - * Helmets or Carved Pumpkins. - * - */ - Head = 'Head', - /** - * @remarks - * The legs slot. This slot is used to hold items such as - * Leggings. - * - */ - Legs = 'Legs', - /** - * @remarks - * The mainhand slot. For players, the mainhand slot refers to - * the currently active hotbar slot. - * - */ - Mainhand = 'Mainhand', - /** - * @remarks - * The offhand slot. This slot is used to hold items such as - * shields and maps. - * - */ - Offhand = 'Offhand', -} - -/** - * Represents a game mode for the current world experience. - */ -export enum GameMode { - /** - * @remarks - * World is in a more locked-down experience, where blocks may - * not be manipulated. - * - */ - adventure = 'adventure', - /** - * @remarks - * World is in a full creative mode. In creative mode, the - * player has all the resources available in the item selection - * tabs and the survival selection tab. They can also destroy - * blocks instantly including those which would normally be - * indestructible. Command and structure blocks can also be - * used in creative mode. Items also do not lose durability or - * disappear. - * - */ - creative = 'creative', - /** - * @remarks - * World is in spectator mode. In spectator mode, spectators - * are always flying and cannot become grounded. Spectators can - * pass through solid blocks and entities without any - * collisions, and cannot use items or interact with blocks or - * mobs. Spectators cannot be seen by mobs or other players, - * except for other spectators; spectators appear as a - * transparent floating head. - * - */ - spectator = 'spectator', - /** - * @remarks - * World is in a survival mode, where players can take damage - * and entities may not be peaceful. Survival mode is where the - * player must collect resources, build structures while - * surviving in their generated world. Activities can, over - * time, chip away at player health and hunger bar. - * - */ - survival = 'survival', -} - -/** - * Describes how an an item can be moved within a container. - */ -export enum ItemLockMode { - /** - * @remarks - * The item cannot be dropped or crafted with. - * - */ - inventory = 'inventory', - /** - * @remarks - * The item has no container restrictions. - * - */ - none = 'none', - /** - * @remarks - * The item cannot be moved from its slot, dropped or crafted - * with. - * - */ - slot = 'slot', -} - -/** - * Used for specifying a sort order for how to display an - * objective and its list of participants. - */ -export enum ObjectiveSortOrder { - /** - * @remarks - * Objective participant list is displayed in ascending (e.g., - * A-Z) order. - * - */ - Ascending = 0, - /** - * @remarks - * Objective participant list is displayed in descending (e.g., - * Z-A) order. - * - */ - Descending = 1, -} - -/** - * Contains objectives and participants for the scoreboard. - */ -export enum ScoreboardIdentityType { - /** - * @remarks - * This scoreboard participant is tied to an entity. - * - */ - Entity = 'Entity', - /** - * @remarks - * This scoreboard participant is tied to a pseudo player - * entity - typically this is used to store scores as data or - * as abstract progress. - * - */ - FakePlayer = 'FakePlayer', - /** - * @remarks - * This scoreboard participant is tied to a player. - * - */ - Player = 'Player', -} - -/** - * Describes where the script event originated from. - */ -export enum ScriptEventSource { - /** - * @remarks - * The script event originated from a Block such as a Command - * Block. - * - */ - Block = 'Block', - /** - * @remarks - * The script event originated from an Entity such as a Player, - * Command Block Minecart or Animation Controller. - * - */ - Entity = 'Entity', - /** - * @remarks - * The script event originated from an NPC dialogue. - * - */ - NPCDialogue = 'NPCDialogue', - /** - * @remarks - * The script event originated from the server, such as from a - * runCommand API call or a dedicated server console. - * - */ - Server = 'Server', -} - -/** - * Provides numeric values for common periods in the Minecraft - * day. - */ -export enum TimeOfDay { - Day = 1000, - Noon = 6000, - Sunset = 12000, - Night = 13000, - Midnight = 18000, - Sunrise = 23000, -} - -/** - * Represents a block in a dimension. A block represents a - * unique X, Y, and Z within a dimension and get/sets the state - * of the block at that location. This type was significantly - * updated in version 1.17.10.21. - */ -export class Block { - private constructor(); - /** - * @remarks - * Returns the dimension that the block is within. - * - */ - readonly dimension: Dimension; - /** - * @remarks - * Coordinates of the specified block. - * - * @throws This property can throw when used. - */ - readonly location: Vector3; - /** - * @remarks - * Additional block configuration data that describes the - * block. - * - * @throws This property can throw when used. - * - * {@link LocationInUnloadedChunkError} - * - * {@link LocationOutOfWorldBoundariesError} - */ - readonly permutation: BlockPermutation; - /** - * @remarks - * X coordinate of the block. - * - */ - readonly x: number; - /** - * @remarks - * Y coordinate of the block. - * - */ - readonly y: number; - /** - * @remarks - * Z coordinate of the block. - * - */ - readonly z: number; - /** - * @remarks - * Gets additional configuration properties (a component) for - * specific capabilities of particular blocks - for example, an - * inventory component of a chest block. - * - * @param componentName - * Identifier of the component. If a namespace is not - * specified, minecraft: is assumed. - * @returns - * Returns the component object if it is present on the - * particular block. - * @throws This function can throw errors. - * - * {@link LocationInUnloadedChunkError} - * - * {@link LocationOutOfWorldBoundariesError} - */ - getComponent(componentName: string): BlockComponent | undefined; - /** - * @remarks - * Returns true if this reference to a block is still valid - * (for example, if the block is unloaded, references to that - * block will no longer be valid.) - * - * @returns - * True if this block object is still working and valid. - */ - isValid(): boolean; - /** - * @remarks - * Sets the block in the dimension to the state of the - * permutation. - * - * This function can't be called in read-only mode. - * - * @param permutation - * Permutation that contains a set of property states for the - * Block. - * @throws This function can throw errors. - * - * {@link LocationInUnloadedChunkError} - * - * {@link LocationOutOfWorldBoundariesError} - */ - setPermutation(permutation: BlockPermutation): void; -} - -/** - * Base type for components associated with blocks. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class BlockComponent extends Component { - private constructor(); - /** - * @remarks - * Block instance that this component pertains to. - * - */ - readonly block: Block; -} - -/** - * Contains information regarding an event that impacts a - * specific block. - */ -export class BlockEvent { - private constructor(); - /** - * @remarks - * Block impacted by this event. - * - */ - readonly block: Block; - /** - * @remarks - * Dimension that contains the block that is the subject of - * this event. - * - */ - readonly dimension: Dimension; -} - -/** - * Represents the inventory of a block in the world. Used with - * blocks like chests. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class BlockInventoryComponent extends BlockComponent { - private constructor(); - /** - * @remarks - * The container which holds an {@link ItemStack}. - * - * @throws This property can throw when used. - */ - readonly container: Container; - static readonly componentId = 'minecraft:inventory'; -} - -/** - * Contains the combination of type {@link BlockType} and - * properties (also sometimes called block state) which - * describe a block (but does not belong to a specific {@link - * Block}). - */ -export class BlockPermutation { - private constructor(); - /** - * @remarks - * Returns a boolean whether a specified permutation matches - * this permutation. If states is not specified, matches checks - * against the set of types more broadly. - * - * @param blockName - * An optional set of states to compare against. - */ - matches(blockName: string, states?: Record): boolean; - /** - * @remarks - * Given a type identifier and an optional set of properties, - * will return a BlockPermutation object that is usable in - * other block APIs (e.g., block.setPermutation) - * - * @param blockName - * Identifier of the block to check. - * @throws This function can throw errors. - * @example addBlockColorCube.ts - * ```typescript - * const allColorNames: string[] = [ - * "white", - * "orange", - * "magenta", - * "light_blue", - * "yellow", - * "lime", - * "pink", - * "gray", - * "silver", - * "cyan", - * "purple", - * "blue", - * "brown", - * "green", - * "red", - * "black", - * ]; - * - * const cubeDim = 7; - * - * let colorIndex = 0; - * - * for (let x = 0; x <= cubeDim; x++) { - * for (let y = 0; y <= cubeDim; y++) { - * for (let z = 0; z <= cubeDim; z++) { - * colorIndex++; - * overworld - * .getBlock({ x: targetLocation.x + x, y: targetLocation.y + y, z: targetLocation.z + z }) - * ?.setPermutation( - * mc.BlockPermutation.resolve("minecraft:wool", { - * color: allColorNames[colorIndex % allColorNames.length], - * }) - * ); - * } - * } - * } - * ``` - */ - static resolve(blockName: string, states?: Record): BlockPermutation; -} - -/** - * Contains information related to changes to a button push. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class ButtonPushAfterEvent extends BlockEvent { - private constructor(); - /** - * @remarks - * Optional source that triggered the button push. - * - */ - readonly source: Entity; -} - -/** - * Manages callbacks that are connected to when a button is - * pushed. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class ButtonPushAfterEventSignal extends IButtonPushAfterEventSignal { - private constructor(); -} - -/** - * Contains return data on the result of a command execution. - */ -export class CommandResult { - private constructor(); - /** - * @remarks - * If the command operates against a number of entities, - * blocks, or items, this returns the number of successful - * applications of this command. - * - */ - readonly successCount: number; -} - -/** - * Base class for downstream Component implementations. - */ -export class Component { - private constructor(); - /** - * @remarks - * Identifier of the component. - * - */ - readonly typeId: string; - /** - * @remarks - * Returns whether the component is valid. A component is - * considered valid if its owner is valid, in addition to any - * addition to any additional validation required by the - * component. - * - * @returns - * Whether the component is valid. - */ - isValid(): boolean; -} - -/** - * Represents a container that can hold sets of items. Used - * with entities such as Players, Chest Minecarts, Llamas, and - * more. - */ -export class Container { - private constructor(); - /** - * @remarks - * Count of the slots in the container that are empty. - * - * @throws - * Throws if the container is invalid. - */ - readonly emptySlotsCount: number; - /** - * @remarks - * The number of slots in this container. For example, a - * standard single-block chest has a size of 27. Note, a - * player's inventory container contains a total of 36 slots, 9 - * hotbar slots plus 27 inventory slots. - * - * @throws - * Throws if the container is invalid. - */ - readonly size: number; - /** - * @remarks - * Adds an item to the container. The item is placed in the - * first available slot(s) and can be stacked with existing - * items of the same type. Note, use {@link Container.setItem} - * if you wish to set the item in a particular slot. - * - * This function can't be called in read-only mode. - * - * @param itemStack - * The stack of items to add. - * @throws This function can throw errors. - */ - addItem(itemStack: ItemStack): ItemStack; - /** - * @remarks - * Clears all inventory items in the container. - * - * This function can't be called in read-only mode. - * - * @throws - * Throws if the container is invalid. - */ - clearAll(): void; - /** - * @remarks - * Gets an {@link ItemStack} of the item at the specified slot. - * If the slot is empty, returns `undefined`. This method does - * not change or clear the contents of the specified slot. To - * get a reference to a particular slot, see {@link - * Container.getSlot}. - * - * @param slot - * Zero-based index of the slot to retrieve items from. - * @throws - * Throws if the container is invalid or if the `slot` index is - * out of bounds. - * @example getItem.ts - * ```typescript - * // Get a copy of the first item in the player's hotbar - * const inventory = player.getComponent("inventory") as EntityInventoryComponent; - * const itemStack = inventory.container.getItem(0); - * ``` - */ - getItem(slot: number): ItemStack | undefined; - /** - * @remarks - * Returns whether a container object (or the entity or block - * that this container is associated with) is still available - * for use in this context. - * - */ - isValid(): boolean; - /** - * @remarks - * Moves an item from one slot to another, potentially across - * containers. - * - * This function can't be called in read-only mode. - * - * @param fromSlot - * Zero-based index of the slot to transfer an item from, on - * this container. - * @param toSlot - * Zero-based index of the slot to transfer an item to, on - * `toContainer`. - * @param toContainer - * Target container to transfer to. Note this can be the same - * container as the source. - * @throws - * Throws if either this container or `toContainer` are invalid - * or if the `fromSlot` or `toSlot` indices out of bounds. - * @example moveItem.ts - * ```typescript - * // Move an item from the first slot of fromPlayer's inventory to the fifth slot of toPlayer's inventory - * const fromInventory = fromPlayer.getComponent('inventory') as EntityInventoryComponent; - * const toInventory = toPlayer.getComponent('inventory') as EntityInventoryComponent; - * fromInventory.container.moveItem(0, 4, toInventory.container); - * ``` - */ - moveItem(fromSlot: number, toSlot: number, toContainer: Container): void; - /** - * @remarks - * Sets an item stack within a particular slot. - * - * This function can't be called in read-only mode. - * - * @param slot - * Zero-based index of the slot to set an item at. - * @param itemStack - * Stack of items to place within the specified slot. Setting - * `itemStack` to undefined will clear the slot. - * @throws - * Throws if the container is invalid or if the `slot` index is - * out of bounds. - */ - setItem(slot: number, itemStack?: ItemStack): void; - /** - * @remarks - * Swaps items between two different slots within containers. - * - * This function can't be called in read-only mode. - * - * @param slot - * Zero-based index of the slot to swap from this container. - * @param otherSlot - * Zero-based index of the slot to swap with. - * @param otherContainer - * Target container to swap with. Note this can be the same - * container as this source. - * @throws - * Throws if either this container or `otherContainer` are - * invalid or if the `slot` or `otherSlot` are out of bounds. - * @example swapItems.ts - * ```typescript - * // Swaps an item between slots 0 and 4 in the player's inventory - * const inventory = fromPlayer.getComponent('inventory') as EntityInventoryComponent; - * inventory.container.swapItems(0, 4, inventory); - * ``` - */ - swapItems(slot: number, otherSlot: number, otherContainer: Container): void; - /** - * @remarks - * Moves an item from one slot to another container, or to the - * first available slot in the same container. - * - * This function can't be called in read-only mode. - * - * @param fromSlot - * Zero-based index of the slot to transfer an item from, on - * this container. - * @param toContainer - * Target container to transfer to. Note this can be the same - * container as the source. - * @throws - * Throws if either this container or `toContainer` are invalid - * or if the `fromSlot` or `toSlot` indices out of bounds. - * @example transferItem.ts - * ```typescript - * // Transfer an item from the first slot of fromPlayer's inventory to toPlayer's inventory - * const fromInventory = fromPlayer.getComponent('inventory') as EntityInventoryComponent; - * const toInventory = toPlayer.getComponent('inventory') as EntityInventoryComponent; - * fromInventory.container.transferItem(0, toInventory.container); - * ``` - */ - transferItem(fromSlot: number, toContainer: Container): ItemStack; -} - -/** - * A class that represents a particular dimension (e.g., The - * End) within a world. - */ -export class Dimension { - private constructor(); - /** - * @remarks - * Identifier of the dimension. - * - */ - readonly id: string; - /** - * @remarks - * Returns a block instance at the given location. - * - * @param location - * The location at which to return a block. - * @returns - * Block at the specified location, or 'undefined' if asking - * for a block at an unloaded chunk. - * @throws - * PositionInUnloadedChunkError: Exception thrown when trying - * to interact with a Block object that isn't in a loaded and - * ticking chunk anymore - * - * PositionOutOfWorldBoundariesError: Exception thrown when - * trying to interact with a position outside of dimension - * height range - * - * - * {@link LocationInUnloadedChunkError} - * - * {@link LocationOutOfWorldBoundariesError} - */ - getBlock(location: Vector3): Block | undefined; - /** - * @remarks - * Gets the first block that intersects with a vector emanating - * from a location. - * - * @param location - * Location from where to initiate the ray check. - * @param direction - * Vector direction to cast the ray. - * @param options - * Additional options for processing this raycast query. - */ - getBlockFromRay(location: Vector3, direction: Vector3, options?: BlockRaycastOptions): BlockRaycastHit | undefined; - /** - * @remarks - * Returns a set of entities based on a set of conditions - * defined via the EntityQueryOptions set of filter criteria. - * - * @param options - * Additional options that can be used to filter the set of - * entities returned. - * @returns - * An entity array. - * @throws This function can throw errors. - * @example bounceSkeletons.ts - * ```typescript - * let mobs = ["creeper", "skeleton", "sheep"]; - * - * // create some sample mob data - * for (let i = 0; i < 10; i++) { - * overworld.spawnEntity(mobs[i % mobs.length], targetLocation); - * } - * - * let eqo: mc.EntityQueryOptions = { - * type: "skeleton", - * }; - * - * for (let entity of overworld.getEntities(eqo)) { - * entity.applyKnockback(0, 0, 0, 1); - * } - * ``` - * @example tagsQuery.ts - * ```typescript - * let mobs = ["creeper", "skeleton", "sheep"]; - * - * // create some sample mob data - * for (let i = 0; i < 10; i++) { - * let mobTypeId = mobs[i % mobs.length]; - * let entity = overworld.spawnEntity(mobTypeId, targetLocation); - * entity.addTag("mobparty." + mobTypeId); - * } - * - * let eqo: mc.EntityQueryOptions = { - * tags: ["mobparty.skeleton"], - * }; - * - * for (let entity of overworld.getEntities(eqo)) { - * entity.kill(); - * } - * ``` - * @example testThatEntityIsFeatherItem.ts - * ```typescript - * const overworld = mc.world.getDimension("overworld"); - * - * const items = overworld.getEntities({ - * location: targetLocation, - * maxDistance: 20, - * }); - * - * for (const item of items) { - * const itemComp = item.getComponent("item") as mc.EntityItemComponent; - * - * if (itemComp) { - * if (itemComp.itemStack.typeId.endsWith("feather")) { - * log("Success! Found a feather", 1); - * } - * } - * } - * ``` - */ - getEntities(options?: EntityQueryOptions): Entity[]; - /** - * @remarks - * Returns a set of entities at a particular location. - * - * @param location - * The location at which to return entities. - * @returns - * Zero or more entities at the specified location. - */ - getEntitiesAtBlockLocation(location: Vector3): Entity[]; - /** - * @remarks - * Gets entities that intersect with a specified vector - * emanating from a location. - * - * @param options - * Additional options for processing this raycast query. - */ - getEntitiesFromRay(location: Vector3, direction: Vector3, options?: EntityRaycastOptions): EntityRaycastHit[]; - /** - * @remarks - * Returns a set of players based on a set of conditions - * defined via the EntityQueryOptions set of filter criteria. - * - * @param options - * Additional options that can be used to filter the set of - * players returned. - * @returns - * A player array. - * @throws This function can throw errors. - */ - getPlayers(options?: EntityQueryOptions): Player[]; - /** - * @remarks - * Runs a command synchronously using the context of the - * broader dimenion. - * - * This function can't be called in read-only mode. - * - * @param commandString - * Command to run. Note that command strings should not start - * with slash. - * @returns - * Returns a command result with a count of successful values - * from the command. - * @throws - * Throws an exception if the command fails due to incorrect - * parameters or command syntax, or in erroneous cases for the - * command. Note that in many cases, if the command does not - * operate (e.g., a target selector found no matches), this - * method will not throw an exception. - * - * {@link CommandError} - */ - runCommand(commandString: string): CommandResult; - /** - * @remarks - * Runs a particular command asynchronously from the context of - * the broader dimension. Note that there is a maximum queue - * of 128 asynchronous commands that can be run in a given - * tick. - * - * @param commandString - * Command to run. Note that command strings should not start - * with slash. - * @returns - * For commands that return data, returns a CommandResult with - * an indicator of command results. - * @throws - * Throws an exception if the command fails due to incorrect - * parameters or command syntax, or in erroneous cases for the - * command. Note that in many cases, if the command does not - * operate (e.g., a target selector found no matches), this - * method will not throw an exception. - */ - runCommandAsync(commandString: string): Promise; - /** - * @remarks - * Creates a new entity (e.g., a mob) at the specified - * location. - * - * This function can't be called in read-only mode. - * - * @param identifier - * Identifier of the type of entity to spawn. If no namespace - * is specified, 'minecraft:' is assumed. - * @param location - * The location at which to create the entity. - * @returns - * Newly created entity at the specified location. - * @throws This function can throw errors. - * - * {@link LocationInUnloadedChunkError} - * - * {@link LocationOutOfWorldBoundariesError} - * @example createOldHorse.ts - * ```typescript - * const overworld = mc.world.getDimension("overworld"); - * - * log("Create a horse and triggering the 'ageable_grow_up' event, ensuring the horse is created as an adult"); - * overworld.spawnEntity("minecraft:horse", targetLocation); - * ``` - * @example quickFoxLazyDog.ts - * ```typescript - * const overworld = mc.world.getDimension("overworld"); - * - * const fox = overworld.spawnEntity("minecraft:fox", { - * x: targetLocation.x + 1, - * y: targetLocation.y + 2, - * z: targetLocation.z + 3, - * }); - * - * fox.addEffect("speed", 10, { - * amplifier: 2, - * }); - * log("Created a fox."); - * - * const wolf = overworld.spawnEntity("minecraft:wolf", { - * x: targetLocation.x + 4, - * y: targetLocation.y + 2, - * z: targetLocation.z + 3, - * }); - * wolf.addEffect("slowness", 10, { - * amplifier: 2, - * }); - * wolf.isSneaking = true; - * log("Created a sneaking wolf.", 1); - * ``` - * @example triggerEvent.ts - * ```typescript - * const creeper = overworld.spawnEntity("minecraft:creeper", targetLocation); - * - * creeper.triggerEvent("minecraft:start_exploding_forced"); - * ``` - */ - spawnEntity(identifier: string, location: Vector3): Entity; - /** - * @remarks - * Creates a new item stack as an entity at the specified - * location. - * - * This function can't be called in read-only mode. - * - * @param location - * The location at which to create the item stack. - * @returns - * Newly created item stack entity at the specified location. - * @throws This function can throw errors. - * - * {@link LocationInUnloadedChunkError} - * - * {@link LocationOutOfWorldBoundariesError} - * @example itemStacks.ts - * ```typescript - * const overworld = mc.world.getDimension('overworld'); - * - * const oneItemLoc = { x: targetLocation.x + targetLocation.y + 3, y: 2, z: targetLocation.z + 1 }; - * const fiveItemsLoc = { x: targetLocation.x + 1, y: targetLocation.y + 2, z: targetLocation.z + 1 }; - * const diamondPickaxeLoc = { x: targetLocation.x + 2, y: targetLocation.y + 2, z: targetLocation.z + 4 }; - * - * const oneEmerald = new mc.ItemStack(mc.MinecraftItemTypes.Emerald, 1); - * const onePickaxe = new mc.ItemStack(mc.MinecraftItemTypes.DiamondPickaxe, 1); - * const fiveEmeralds = new mc.ItemStack(mc.MinecraftItemTypes.Emerald, 5); - * - * log(`Spawning an emerald at (${oneItemLoc.x}, ${oneItemLoc.y}, ${oneItemLoc.z})`); - * overworld.spawnItem(oneEmerald, oneItemLoc); - * - * log(`Spawning five emeralds at (${fiveItemsLoc.x}, ${fiveItemsLoc.y}, ${fiveItemsLoc.z})`); - * overworld.spawnItem(fiveEmeralds, fiveItemsLoc); - * - * log(`Spawning a diamond pickaxe at (${diamondPickaxeLoc.x}, ${diamondPickaxeLoc.y}, ${diamondPickaxeLoc.z})`); - * overworld.spawnItem(onePickaxe, diamondPickaxeLoc); - * ``` - * @example spawnItem.ts - * ```typescript - * const featherItem = new mc.ItemStack(mc.MinecraftItemTypes.Feather, 1); - * - * overworld.spawnItem(featherItem, targetLocation); - * log(`New feather created at ${targetLocation.x}, ${targetLocation.y}, ${targetLocation.z}!`); - * ``` - */ - spawnItem(itemStack: ItemStack, location: Vector3): Entity; - /** - * @remarks - * Creates a new particle emitter at a specified location in - * the world. - * - * This function can't be called in read-only mode. - * - * @param effectName - * Identifier of the particle to create. - * @param location - * The location at which to create the particle emitter. - * @param molangVariables - * A set of optional, customizable variables that can be - * adjusted for this particle. - * @throws This function can throw errors. - * - * {@link LocationInUnloadedChunkError} - * - * {@link LocationOutOfWorldBoundariesError} - * @example spawnParticle.ts - * ```typescript - * for (let i = 0; i < 100; i++) { - * const molang = new mc.MolangVariableMap(); - * - * molang.setColorRGB("variable.color", { red: Math.random(), green: Math.random(), blue: Math.random(), alpha: 1 }); - * - * let newLocation = { - * x: targetLocation.x + Math.floor(Math.random() * 8) - 4, - * y: targetLocation.y + Math.floor(Math.random() * 8) - 4, - * z: targetLocation.z + Math.floor(Math.random() * 8) - 4, - * }; - * overworld.spawnParticle("minecraft:colored_flame_particle", newLocation, molang); - * } - * ``` - */ - spawnParticle(effectName: string, location: Vector3, molangVariables?: MolangVariableMap): void; -} - -/** - * Represents an effect - like poison - that has been added to - * an Entity. - */ -export class Effect { - private constructor(); - /** - * @remarks - * Gets an amplifier that may have been applied to this effect. - * Sample values range typically from 0 to 4. Example: The - * effect 'Jump Boost II' will have an amplifier value of 1. - * - * @throws This property can throw when used. - */ - readonly amplifier: number; - /** - * @remarks - * Gets the player-friendly name of this effect. - * - * @throws This property can throw when used. - */ - readonly displayName: string; - /** - * @remarks - * Gets the entire specified duration, in ticks, of this - * effect. There are 20 ticks per second. Use {@link - * TicksPerSecond} constant to convert between ticks and - * seconds. - * - * @throws This property can throw when used. - */ - readonly duration: number; - /** - * @remarks - * Gets the type id of this effect. - * - * @throws This property can throw when used. - */ - readonly typeId: string; - /** - * @remarks - * Returns whether an effect instance is available for use in - * this context. - * - */ - isValid(): boolean; -} - -/** - * Represents a type of effect - like poison - that can be - * applied to an entity. - */ -export class EffectType { - private constructor(); - /** - * @remarks - * Identifier name of this effect type. - * - * @returns - * Identifier of the effect type. - */ - getName(): string; -} - -/** - * Represents the state of an entity (a mob, the player, or - * other moving objects like minecarts) in the world. - */ -export class Entity { - private constructor(); - /** - * @remarks - * Dimension that the entity is currently within. - * - * @throws This property can throw when used. - */ - readonly dimension: Dimension; - /** - * @remarks - * Unique identifier of the entity. This identifier is intended - * to be consistent across loads of a world instance. No - * meaning should be inferred from the value and structure of - * this unique identifier - do not parse or interpret it. This - * property is accessible even if {@link Entity.isValid} is - * false. - * - */ - readonly id: string; - /** - * @remarks - * Current location of the entity. - * - * @throws This property can throw when used. - */ - readonly location: Vector3; - /** - * @remarks - * Given name of the entity. - * - * This property can't be edited in read-only mode. - * - */ - nameTag: string; - /** - * @remarks - * Returns a scoreboard identity that represents this entity. - * Will remain valid when the entity is killed. - * - */ - readonly scoreboardIdentity?: ScoreboardIdentity; - /** - * @remarks - * Identifier of the type of the entity - for example, - * 'minecraft:skeleton'. This property is accessible even if - * {@link Entity.isValid} is false. - * - */ - readonly typeId: string; - /** - * @remarks - * Adds or updates an effect, like poison, to the entity. - * - * This function can't be called in read-only mode. - * - * @param effectType - * Type of effect to add to the entity. - * @param duration - * Amount of time, in ticks, for the effect to apply. There are - * 20 ticks per second. Use {@link TicksPerSecond} constant to - * convert between ticks and seconds. The value must be within - * the range [0, 20000000]. - * @param options - * Additional options for the effect. - * @returns - * Returns nothing if the effect was added or updated - * successfully. This can throw an error if the duration or - * amplifier are outside of the valid ranges, or if the effect - * does not exist. - * @throws This function can throw errors. - * @example addEffect.js - * ```typescript - * const villagerId = 'minecraft:villager_v2'; - * const villagerLoc: mc.Vector3 = { x: 1, y: 2, z: 1 }; - * const villager = test.spawn(villagerId, villagerLoc); - * const duration = 20; - * - * villager.addEffect(EffectTypes.get('poison'), duration, { amplifier: 1 }); - * ``` - * @example quickFoxLazyDog.ts - * ```typescript - * const overworld = mc.world.getDimension("overworld"); - * - * const fox = overworld.spawnEntity("minecraft:fox", { - * x: targetLocation.x + 1, - * y: targetLocation.y + 2, - * z: targetLocation.z + 3, - * }); - * - * fox.addEffect("speed", 10, { - * amplifier: 2, - * }); - * log("Created a fox."); - * - * const wolf = overworld.spawnEntity("minecraft:wolf", { - * x: targetLocation.x + 4, - * y: targetLocation.y + 2, - * z: targetLocation.z + 3, - * }); - * wolf.addEffect("slowness", 10, { - * amplifier: 2, - * }); - * wolf.isSneaking = true; - * log("Created a sneaking wolf.", 1); - * ``` - */ - addEffect(effectType: EffectType | string, duration: number, options?: EntityEffectOptions): void; - /** - * @remarks - * Adds a specified tag to an entity. - * - * This function can't be called in read-only mode. - * - * @param tag - * Content of the tag to add. The tag must be less than 256 - * characters. - * @returns - * Returns true if the tag was added successfully. This can - * fail if the tag already exists on the entity. - * @throws This function can throw errors. - * @example tagsQuery.ts - * ```typescript - * let mobs = ["creeper", "skeleton", "sheep"]; - * - * // create some sample mob data - * for (let i = 0; i < 10; i++) { - * let mobTypeId = mobs[i % mobs.length]; - * let entity = overworld.spawnEntity(mobTypeId, targetLocation); - * entity.addTag("mobparty." + mobTypeId); - * } - * - * let eqo: mc.EntityQueryOptions = { - * tags: ["mobparty.skeleton"], - * }; - * - * for (let entity of overworld.getEntities(eqo)) { - * entity.kill(); - * } - * ``` - */ - addTag(tag: string): boolean; - /** - * @remarks - * Applies a set of damage to an entity. - * - * This function can't be called in read-only mode. - * - * @param amount - * Amount of damage to apply. - * @param options - * Additional options about the source of damage, which may add - * additional effects or spur additional behaviors on this - * entity. - * @returns - * Whether the entity takes any damage. This can return false - * if the entity is invulnerable or if the damage applied is - * less than or equal to 0. - * @throws This function can throw errors. - * @example applyDamageThenHeal.ts - * ```typescript - * const skelly = overworld.spawnEntity("minecraft:skeleton", targetLocation); - * - * skelly.applyDamage(19); // skeletons have max damage of 20 so this is a near-death skeleton - * - * mc.system.runTimeout(() => { - * let health = skelly.getComponent("health") as mc.EntityHealthComponent; - * log("Skeleton health before heal: " + health.currentValue); - * health.resetToMaxValue(); - * log("Skeleton health after heal: " + health.currentValue); - * }, 20); - * ``` - */ - applyDamage(amount: number, options?: EntityApplyDamageByProjectileOptions | EntityApplyDamageOptions): boolean; - /** - * @remarks - * Applies impulse vector to the current velocity of the - * entity. - * - * This function can't be called in read-only mode. - * - * @param vector - * Impulse vector. - * @throws This function can throw errors. - * @example applyImpulse.ts - * ```typescript - * const zombie = overworld.spawnEntity("minecraft:zombie", targetLocation); - * - * zombie.clearVelocity(); - * - * // throw the zombie up in the air - * zombie.applyImpulse({ x: 0, y: 0.5, z: 0 }); - * ``` - */ - applyImpulse(vector: Vector3): void; - /** - * @remarks - * Applies impulse vector to the current velocity of the - * entity. - * - * This function can't be called in read-only mode. - * - * @param directionX - * X direction in horizontal plane. - * @param directionZ - * Z direction in horizontal plane. - * @param horizontalStrength - * Knockback strength for the horizontal vector. - * @param verticalStrength - * Knockback strength for the vertical vector. - * @throws This function can throw errors. - * @example bounceSkeletons.ts - * ```typescript - * let mobs = ["creeper", "skeleton", "sheep"]; - * - * // create some sample mob data - * for (let i = 0; i < 10; i++) { - * overworld.spawnEntity(mobs[i % mobs.length], targetLocation); - * } - * - * let eqo: mc.EntityQueryOptions = { - * type: "skeleton", - * }; - * - * for (let entity of overworld.getEntities(eqo)) { - * entity.applyKnockback(0, 0, 0, 1); - * } - * ``` - */ - applyKnockback(directionX: number, directionZ: number, horizontalStrength: number, verticalStrength: number): void; - /** - * @remarks - * Sets the current velocity of the Entity to zero. Note that - * this method may not have an impact on Players. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - * @example applyImpulse.ts - * ```typescript - * const zombie = overworld.spawnEntity("minecraft:zombie", targetLocation); - * - * zombie.clearVelocity(); - * - * // throw the zombie up in the air - * zombie.applyImpulse({ x: 0, y: 0.5, z: 0 }); - * ``` - */ - clearVelocity(): void; - /** - * @remarks - * Returns the first intersecting block from the direction that - * this entity is looking at. - * - * @param options - * Additional configuration options for the ray cast. - * @returns - * Returns the first intersecting block from the direction that - * this entity is looking at. - * @throws This function can throw errors. - */ - getBlockFromViewDirection(options?: BlockRaycastOptions): BlockRaycastHit | undefined; - /** - * @remarks - * Gets a component (that represents additional capabilities) - * for an entity. - * - * @param componentId - * The identifier of the component (e.g., 'minecraft:rideable') - * to retrieve. If no namespace prefix is specified, - * 'minecraft:' is assumed. If the component is not present on - * the entity, undefined is returned. - * @returns - * Returns the component if it exists on the entity, otherwise - * undefined. - */ - getComponent(componentId: string): EntityComponent | undefined; - /** - * @remarks - * Returns all components that are both present on this entity - * and supported by the API. - * - * @returns - * Returns all components that are both present on this entity - * and supported by the API. - */ - getComponents(): EntityComponent[]; - /** - * @remarks - * Returns the effect for the specified EffectType on the - * entity, undefined if the effect is not present, or throws an - * error if the effect does not exist. - * - * @param effectType - * The effect identifier. - * @returns - * Effect object for the specified effect, undefined if the - * effect is not present, or throws an error if the effect does - * not exist. - * @throws This function can throw errors. - */ - getEffect(effectType: EffectType | string): Effect | undefined; - /** - * @remarks - * Returns a set of effects applied to this entity. - * - * @returns - * List of effects. - * @throws This function can throw errors. - */ - getEffects(): Effect[]; - /** - * @remarks - * Gets the entities that this entity is looking at by - * performing a ray cast from the view of this entity. - * - * @param options - * Additional configuration options for the ray cast. - * @returns - * Returns a set of entities from the direction that this - * entity is looking at. - * @throws This function can throw errors. - */ - getEntitiesFromViewDirection(options?: EntityRaycastOptions): EntityRaycastHit[]; - /** - * @remarks - * Returns the current location of the head component of this - * entity. - * - * @returns - * Returns the current location of the head component of this - * entity. - * @throws This function can throw errors. - */ - getHeadLocation(): Vector3; - /** - * @remarks - * Returns all tags associated with an entity. - * - * @returns - * Returns the current rotation component of this entity. - * @throws This function can throw errors. - */ - getTags(): string[]; - /** - * @remarks - * Returns the current velocity vector of the entity. - * - * @returns - * Returns the current velocity vector of the entity. - * @throws This function can throw errors. - * @example getFireworkVelocity.ts - * ```typescript - * const fireworkRocket = overworld.spawnEntity("minecraft:fireworks_rocket", targetLocation); - * - * mc.system.runTimeout(() => { - * let velocity = fireworkRocket.getVelocity(); - * - * log("Velocity of firework is: (x: " + velocity.x + ", y:" + velocity.y + ", z:" + velocity.z + ")"); - * }, 5); - * ``` - */ - getVelocity(): Vector3; - /** - * @remarks - * Returns the current view direction of the entity. - * - * @returns - * Returns the current view direction of the entity. - * @throws This function can throw errors. - */ - getViewDirection(): Vector3; - /** - * @remarks - * Returns true if the specified component is present on this - * entity. - * - * @param componentId - * The identifier of the component (e.g., 'minecraft:rideable') - * to retrieve. If no namespace prefix is specified, - * 'minecraft:' is assumed. - * @returns - * Returns true if the specified component is present on this - * entity. - */ - hasComponent(componentId: string): boolean; - /** - * @remarks - * Returns whether an entity has a particular tag. - * - * @param tag - * Identifier of the tag to test for. - * @returns - * Returns whether an entity has a particular tag. - * @throws This function can throw errors. - */ - hasTag(tag: string): boolean; - /** - * @remarks - * Returns whether the entity can be manipulated by script. A - * Player is considered valid when it's EntityLifetimeState is - * set to Loaded. - * - * @returns - * Whether the entity is valid. - */ - isValid(): boolean; - /** - * @remarks - * Kills this entity. The entity will drop loot as normal. - * - * This function can't be called in read-only mode. - * - * @returns - * Returns true if entity can be killed (even if it is already - * dead), otherwise it returns false. - * @throws This function can throw errors. - * @example tagsQuery.ts - * ```typescript - * let mobs = ["creeper", "skeleton", "sheep"]; - * - * // create some sample mob data - * for (let i = 0; i < 10; i++) { - * let mobTypeId = mobs[i % mobs.length]; - * let entity = overworld.spawnEntity(mobTypeId, targetLocation); - * entity.addTag("mobparty." + mobTypeId); - * } - * - * let eqo: mc.EntityQueryOptions = { - * tags: ["mobparty.skeleton"], - * }; - * - * for (let entity of overworld.getEntities(eqo)) { - * entity.kill(); - * } - * ``` - */ - kill(): boolean; - /** - * @remarks - * Removes the specified EffectType on the entity, or returns - * false if the effect is not present. - * - * This function can't be called in read-only mode. - * - * @param effectType - * The effect identifier. - * @returns - * Returns true if the effect has been removed. Returns false - * if the effect is not found or does not exist. - * @throws This function can throw errors. - */ - removeEffect(effectType: EffectType | string): boolean; - /** - * @remarks - * Removes a specified tag from an entity. - * - * This function can't be called in read-only mode. - * - * @param tag - * Content of the tag to remove. - * @returns - * Returns whether the tag existed on the entity. - * @throws This function can throw errors. - */ - removeTag(tag: string): boolean; - /** - * @remarks - * Runs a synchronous command on the entity. - * - * This function can't be called in read-only mode. - * - * @param commandString - * The command string. Note: This should not include a leading - * forward slash. - * @returns - * A command result containing whether the command was - * successful. - * @throws This function can throw errors. - * - * {@link CommandError} - * - * {@link Error} - */ - runCommand(commandString: string): CommandResult; - /** - * @remarks - * Runs a particular command asynchronously from the context of - * this entity. Note that there is a maximum queue of 128 - * asynchronous commands that can be run in a given tick. - * - * @param commandString - * Command to run. Note that command strings should not start - * with slash. - * @returns - * For commands that return data, returns a JSON structure with - * command response values. - * @throws This function can throw errors. - */ - runCommandAsync(commandString: string): Promise; - /** - * @remarks - * Teleports the selected entity to a new location - * - * This function can't be called in read-only mode. - * - * @param location - * New location for the entity. - * @param teleportOptions - * Options regarding the teleport operation. - * @throws This function can throw errors. - * @example teleportMovement.ts - * ```typescript - * const pig = overworld.spawnEntity("minecraft:pig", targetLocation); - * - * let inc = 1; - * let runId = mc.system.runInterval(() => { - * pig.teleport( - * { x: targetLocation.x + inc / 4, y: targetLocation.y + inc / 4, z: targetLocation.z + inc / 4 }, - * { - * facingLocation: targetLocation, - * } - * ); - * - * if (inc > 100) { - * mc.system.clearRun(runId); - * } - * inc++; - * }, 4); - * ``` - */ - teleport(location: Vector3, teleportOptions?: TeleportOptions): void; - /** - * @remarks - * Triggers an entity type event. For every entity, a number of - * events are defined in an entities' definition for key entity - * behaviors; for example, creepers have a - * minecraft:start_exploding type event. - * - * This function can't be called in read-only mode. - * - * @param eventName - * Name of the entity type event to trigger. If a namespace is - * not specified, minecraft: is assumed. - * @throws - * If the event is not defined in the definition of the entity, - * an error will be thrown. - * @example triggerEvent.ts - * ```typescript - * const creeper = overworld.spawnEntity("minecraft:creeper", targetLocation); - * - * creeper.triggerEvent("minecraft:start_exploding_forced"); - * ``` - */ - triggerEvent(eventName: string): void; - /** - * @remarks - * Attempts to try a teleport, but may not complete the - * teleport operation (for example, if there are blocks at the - * destination.) - * - * This function can't be called in read-only mode. - * - * @param location - * Location to teleport the entity to. - * @param teleportOptions - * Options regarding the teleport operation. - * @returns - * Returns whether the teleport succeeded. This can fail if the - * destination chunk is unloaded or if the teleport would - * result in intersecting with blocks. - * @throws This function can throw errors. - */ - tryTeleport(location: Vector3, teleportOptions?: TeleportOptions): boolean; -} - -/** - * This is a base abstract class for any entity component that - * centers around a number and can have a minimum, maximum, and - * default defined value. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityAttributeComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Current value of this attribute for this instance. - * - * @throws This property can throw when used. - */ - readonly currentValue: number; - /** - * @remarks - * Returns the default defined value for this attribute. - * - * @throws This property can throw when used. - */ - readonly defaultValue: number; - /** - * @remarks - * Returns the effective max of this attribute given any other - * ambient components or factors. - * - * @throws This property can throw when used. - */ - readonly effectiveMax: number; - /** - * @remarks - * Returns the effective min of this attribute given any other - * ambient components or factors. - * - * @throws This property can throw when used. - */ - readonly effectiveMin: number; - /** - * @remarks - * Resets the current value of this attribute to the defined - * default value. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - resetToDefaultValue(): void; - /** - * @remarks - * Resets the current value of this attribute to the maximum - * defined value. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - resetToMaxValue(): void; - /** - * @remarks - * Resets the current value of this attribute to the minimum - * defined value. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - resetToMinValue(): void; - /** - * @remarks - * Sets the current value of this attribute. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - setCurrentValue(value: number): boolean; -} - -/** - * Base class for a family of entity movement events. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityBaseMovementComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Maximum turn rate for this movement modality of the mob. - * - * @throws This property can throw when used. - */ - readonly maxTurn: number; -} - -/** - * When added, this component signifies that the entity can - * climb up ladders. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityCanClimbComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:can_climb'; -} - -/** - * When added, this component signifies that the entity can - * fly, and the pathfinder won't be restricted to paths where a - * solid block is required underneath it. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityCanFlyComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:can_fly'; -} - -/** - * When added, this component signifies that the entity can - * power jump like the horse does within Minecraft. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityCanPowerJumpComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:can_power_jump'; -} - -/** - * Defines the entity's color. Only works on certain entities - * that have predefined color values (e.g., sheep, llama, - * shulker). - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityColorComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Value of this particular color. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - static readonly componentId = 'minecraft:color'; -} - -/** - * Base class for downstream entity components. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityComponent extends Component { - private constructor(); -} - -/** - * Contains data related to the death of an entity in the game. - */ -export class EntityDieAfterEvent { - private constructor(); - /** - * @remarks - * If specified, provides more information on the source of - * damage that caused the death of this entity. - * - */ - readonly damageSource: EntityDamageSource; - /** - * @remarks - * Now-dead entity object. - * - */ - readonly deadEntity: Entity; -} - -/** - * Supports registering for an event that fires after an entity - * has died. - */ -export class EntityDieAfterEventSignal { - private constructor(); - /** - * @remarks - * Subscribes to an event that fires when an entity dies. - * - * This function can't be called in read-only mode. - * - * @param callback - * Function to call when an entity dies. - * @param options - * Additional filtering options for when the subscription - * fires. - * @returns - * Returns the closure that can be used in future downstream - * calls to unsubscribe. - */ - subscribe( - callback: (arg: EntityDieAfterEvent) => void, - options?: EntityEventOptions, - ): (arg: EntityDieAfterEvent) => void; - /** - * @remarks - * Stops this event from calling your function when an entity - * dies. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: EntityDieAfterEvent) => void): void; -} - -/** - * Provides access to a mob's equipment slots. This component - * exists for all mob entities. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityEquippableComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:equippable'; - /** - * @remarks - * Gets the equipped item for the given EquipmentSlot. - * - * This function can't be called in read-only mode. - * - * @param equipmentSlot - * The equipment slot. e.g. "head", "chest", "offhand" - * @returns - * Returns the item equipped to the given EquipmentSlot. If - * empty, returns undefined. - * @throws This function can throw errors. - */ - getEquipment(equipmentSlot: EquipmentSlot): ItemStack | undefined; - /** - * @remarks - * Replaces the item in the given EquipmentSlot. - * - * This function can't be called in read-only mode. - * - * @param equipmentSlot - * The equipment slot. e.g. "head", "chest", "offhand". - * @param itemStack - * The item to equip. If undefined, clears the slot. - * @throws This function can throw errors. - */ - setEquipment(equipmentSlot: EquipmentSlot, itemStack?: ItemStack): boolean; -} - -/** - * When added, this component signifies that this entity - * doesn't take damage from fire. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityFireImmuneComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:fire_immune'; -} - -/** - * When added, this component signifies that this entity can - * float in liquid blocks. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityFloatsInLiquidComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:floats_in_liquid'; -} - -/** - * Represents the flying speed of an entity. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityFlyingSpeedComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Current value of the flying speed of the associated entity. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - static readonly componentId = 'minecraft:flying_speed'; -} - -/** - * Defines how much friction affects this entity. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityFrictionModifierComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Current value of the friction modifier of the associated - * entity. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - static readonly componentId = 'minecraft:friction_modifier'; -} - -/** - * Sets the offset from the ground that the entity is actually - * at. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityGroundOffsetComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Value of this particular ground offset. Note that this value - * is effectively read only; setting the ground offset value - * will not have an impact on the related entity. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - static readonly componentId = 'minecraft:ground_offset'; -} - -/** - * Defines the interactions with this entity for healing it. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityHealableComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Determines if an item can be used regardless of the entity - * being at full health. - * - * @throws This property can throw when used. - */ - readonly forceUse: boolean; - static readonly componentId = 'minecraft:healable'; - /** - * @remarks - * A set of items that can specifically heal this entity. - * - * @returns - * Entity that this component is associated with. - * @throws This function can throw errors. - */ - getFeedItems(): FeedItem[]; -} - -/** - * Contains information related to an entity when its health - * changes. Warning: don't change the health of an entity in - * this event, or it will cause an infinite loop! - */ -export class EntityHealthChangedAfterEvent { - private constructor(); - /** - * @remarks - * Entity whose health changed. - * - */ - readonly entity: Entity; - /** - * @remarks - * New health value of the entity. - * - */ - readonly newValue: number; - /** - * @remarks - * Old health value of the entity. - * - */ - readonly oldValue: number; -} - -/** - * Manages callbacks that are connected to when the health of - * an entity changes. - */ -export class EntityHealthChangedAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when the health of an - * entity changes. - * - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: EntityHealthChangedAfterEvent) => void, - options?: EntityEventOptions, - ): (arg: EntityHealthChangedAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when the health of an - * entity changes. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: EntityHealthChangedAfterEvent) => void): void; -} - -/** - * Defines the health properties of an entity. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityHealthComponent extends EntityAttributeComponent { - private constructor(); - static readonly componentId = 'minecraft:health'; -} - -/** - * Contains information related to an entity hitting a block. - */ -export class EntityHitBlockAfterEvent { - private constructor(); - /** - * @remarks - * Face of the block that was hit. - * - */ - readonly blockFace: Direction; - /** - * @remarks - * Entity that made the attack. - * - */ - readonly damagingEntity: Entity; - /** - * @remarks - * Block that was hit by the attack. - * - */ - readonly hitBlock: Block; -} - -/** - * Manages callbacks that are connected to when an entity hits - * a block. - */ -export class EntityHitBlockAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when an entity hits a - * block. - * - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: EntityHitBlockAfterEvent) => void, - options?: EntityEventOptions, - ): (arg: EntityHitBlockAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when an entity hits a - * block. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: EntityHitBlockAfterEvent) => void): void; -} - -/** - * Contains information related to an entity hitting (melee - * attacking) another entity. - */ -export class EntityHitEntityAfterEvent { - private constructor(); - /** - * @remarks - * Entity that made a hit/melee attack. - * - */ - readonly damagingEntity: Entity; - /** - * @remarks - * Entity that was hit by the attack. - * - */ - readonly hitEntity: Entity; -} - -/** - * Manages callbacks that are connected to when an entity makes - * a melee attack on another entity. - */ -export class EntityHitEntityAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when an entity hits - * another entity. - * - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: EntityHitEntityAfterEvent) => void, - options?: EntityEventOptions, - ): (arg: EntityHitEntityAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when an entity makes a - * melee attack on another entity. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: EntityHitEntityAfterEvent) => void): void; -} - -/** - * Contains information related to an entity getting hurt. - */ -export class EntityHurtAfterEvent { - private constructor(); - /** - * @remarks - * Describes the amount of damage caused. - * - */ - readonly damage: number; - /** - * @remarks - * Source information on the entity that may have applied this - * damage. - * - */ - readonly damageSource: EntityDamageSource; - /** - * @remarks - * Entity that was hurt. - * - */ - readonly hurtEntity: Entity; -} - -/** - * Manages callbacks that are connected to when an entity is - * hurt. - */ -export class EntityHurtAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when an entity is hurt. - * - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: EntityHurtAfterEvent) => void, - options?: EntityEventOptions, - ): (arg: EntityHurtAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when an entity is hurt. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: EntityHurtAfterEvent) => void): void; -} - -/** - * Defines this entity's inventory properties. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityInventoryComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Number of slots that this entity can gain per extra - * strength. - * - * @throws This property can throw when used. - */ - readonly additionalSlotsPerStrength: number; - /** - * @remarks - * If true, the contents of this inventory can be removed by a - * hopper. - * - * @throws This property can throw when used. - */ - readonly canBeSiphonedFrom: boolean; - /** - * @remarks - * Defines the container for this entity. - * - * @throws This property can throw when used. - */ - readonly container: Container; - /** - * @remarks - * Type of container this entity has. - * - * @throws This property can throw when used. - */ - readonly containerType: string; - /** - * @remarks - * Number of slots the container has. - * - * @throws This property can throw when used. - */ - readonly inventorySize: number; - /** - * @remarks - * If true, the entity will not drop it's inventory on death. - * - * @throws This property can throw when used. - */ - readonly 'private': boolean; - /** - * @remarks - * If true, the entity's inventory can only be accessed by its - * owner or itself. - * - * @throws This property can throw when used. - */ - readonly restrictToOwner: boolean; - static readonly componentId = 'minecraft:inventory'; -} - -/** - * When added, this component signifies that this entity is a - * baby. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsBabyComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_baby'; -} - -/** - * When added, this component signifies that this entity is - * charged. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsChargedComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_charged'; -} - -/** - * When added, this component signifies that this entity is - * currently carrying a chest. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsChestedComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_chested'; -} - -/** - * When added, this component signifies that dyes can be used - * on this entity to change its color. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsDyeableComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_dyeable'; -} - -/** - * When added, this component signifies that this entity can - * hide from hostile mobs while invisible. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsHiddenWhenInvisibleComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_hidden_when_invisible'; -} - -/** - * When added, this component signifies that this entity this - * currently on fire. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsIgnitedComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_ignited'; -} - -/** - * When added, this component signifies that this entity is an - * illager captain. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsIllagerCaptainComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_illager_captain'; -} - -/** - * When added, this component signifies that this entity is - * currently saddled. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsSaddledComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_saddled'; -} - -/** - * When added, this component signifies that this entity is - * currently shaking. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsShakingComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_shaking'; -} - -/** - * When added, this component signifies that this entity is - * currently sheared. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsShearedComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_sheared'; -} - -/** - * When added, this component signifies that this entity can be - * stacked. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsStackableComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_stackable'; -} - -/** - * When added, this component signifies that this entity is - * currently stunned. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsStunnedComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_stunned'; -} - -/** - * When added, this component signifies that this entity is - * currently tamed. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsTamedComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_tamed'; -} - -/** - * If added onto the entity, this indicates that the entity - * represents a free-floating item in the world. Lets you - * retrieve the actual item stack contents via the itemStack - * property. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityItemComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Item stack represented by this entity in the world. - * - * @throws This property can throw when used. - */ - readonly itemStack: ItemStack; - static readonly componentId = 'minecraft:item'; -} - -/** - * Additional variant value. Can be used to further - * differentiate variants. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityMarkVariantComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Value of the mark variant value for this entity. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - static readonly componentId = 'minecraft:mark_variant'; -} - -/** - * When added, this movement control allows the mob to swim in - * water and walk on land. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityMovementAmphibiousComponent extends EntityBaseMovementComponent { - private constructor(); - static readonly componentId = 'minecraft:movement.amphibious'; -} - -/** - * This component accents the movement of an entity. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityMovementBasicComponent extends EntityBaseMovementComponent { - private constructor(); - static readonly componentId = 'minecraft:movement.basic'; -} - -/** - * When added, this move control causes the mob to fly. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityMovementFlyComponent extends EntityBaseMovementComponent { - private constructor(); - static readonly componentId = 'minecraft:movement.fly'; -} - -/** - * When added, this move control allows a mob to fly, swim, - * climb, etc. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityMovementGenericComponent extends EntityBaseMovementComponent { - private constructor(); - static readonly componentId = 'minecraft:movement.generic'; -} - -/** - * When added, this move control causes the mob to hover. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityMovementHoverComponent extends EntityBaseMovementComponent { - private constructor(); - static readonly componentId = 'minecraft:movement.hover'; -} - -/** - * Move control that causes the mob to jump as it moves with a - * specified delay between jumps. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityMovementJumpComponent extends EntityBaseMovementComponent { - private constructor(); - static readonly componentId = 'minecraft:movement.jump'; -} - -/** - * When added, this move control causes the mob to hop as it - * moves. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityMovementSkipComponent extends EntityBaseMovementComponent { - private constructor(); - static readonly componentId = 'minecraft:movement.skip'; -} - -/** - * Sets the distance through which the entity can push through. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityPushThroughComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Value of the push through distances of this entity. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - static readonly componentId = 'minecraft:push_through'; -} - -/** - * Sets the entity's visual size. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityScaleComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Current value for the scale property set on entities. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - static readonly componentId = 'minecraft:scale'; -} - -/** - * Skin Id value. Can be used to differentiate skins, such as - * base skins for villagers. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntitySkinIdComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Returns the value of the skin Id identifier of the entity. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - static readonly componentId = 'minecraft:skin_id'; -} - -/** - * Used to differentiate the component group of a variant of an - * entity from others. (e.g. ocelot, villager). - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityVariantComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Current value for variant for this entity, as specified via - * components. - * - * @throws This property can throw when used. - */ - readonly value: number; - static readonly componentId = 'minecraft:variant'; -} - -/** - * When added, this component signifies that this entity wants - * to become a jockey. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityWantsJockeyComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:wants_jockey'; -} - -/** - * As part of the Healable component, represents a specific - * item that can be fed to an entity to cause health effects. - */ -export class FeedItem { - private constructor(); - /** - * @remarks - * The amount of health this entity gains when fed this item. - * This number is an integer starting at 0. Sample values can - * go as high as 40. - * - */ - readonly healAmount: number; - /** - * @remarks - * Identifier of type of item that can be fed. If a namespace - * is not specified, 'minecraft:' is assumed. Example values - * include 'wheat' or 'golden_apple'. - * - */ - readonly item: string; - /** - * @remarks - * As part of the Healable component, an optional collection of - * side effects that can occur from being fed an item. - * - */ - getEffects(): FeedItemEffect[]; -} - -/** - * Represents an effect that is applied as a result of a food - * item being fed to an entity. - */ -export class FeedItemEffect { - private constructor(); - /** - * @remarks - * Gets an amplifier that may have been applied to this effect. - * Valid values are integers starting at 0 and up - but usually - * ranging between 0 and 4. - * - */ - readonly amplifier: number; - /** - * @remarks - * Chance that this effect is applied as a result of the entity - * being fed this item. Valid values range between 0 and 1. - * - */ - readonly chance: number; - /** - * @remarks - * Gets the duration, in ticks, of this effect. - * - */ - readonly duration: number; - /** - * @remarks - * Gets the identifier of the effect to apply. Example values - * include 'fire_resistance' or 'regeneration'. - * - */ - readonly name: string; -} - -/** - * Provides an adaptable interface for callers to subscribe to - * an event that fires when a button is pushed. - */ -export class IButtonPushAfterEventSignal { - private constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ButtonPushAfterEvent) => void): (arg: ButtonPushAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ButtonPushAfterEvent) => void): void; -} - -/** - * Provides an adaptable interface for callers to subscribe to - * an event that fires after a lever is used. - */ -export class ILeverActionAfterEventSignal { - private constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: LeverActionAfterEvent) => void): (arg: LeverActionAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: LeverActionAfterEvent) => void): void; -} - -/** - * Provides an adaptable interface for callers to subscribe to - * an event that fires after a player joins a world. - */ -export class IPlayerJoinAfterEventSignal { - private constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: PlayerJoinAfterEvent) => void): (arg: PlayerJoinAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: PlayerJoinAfterEvent) => void): void; -} - -/** - * Provides an adaptable interface for callers to subscribe to - * an event that fires after a player leaves a world. - */ -export class IPlayerLeaveAfterEventSignal { - private constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: PlayerLeaveAfterEvent) => void): (arg: PlayerLeaveAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: PlayerLeaveAfterEvent) => void): void; -} - -/** - * Provides an adaptable interface for callers to subscribe to - * an event that fires after a player spawns. - */ -export class IPlayerSpawnAfterEventSignal { - private constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: PlayerSpawnAfterEvent) => void): (arg: PlayerSpawnAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: PlayerSpawnAfterEvent) => void): void; -} - -/** - * Contains information related to a chargeable item completing - * being charged. - */ -export class ItemCompleteUseAfterEvent { - private constructor(); - /** - * @remarks - * Returns the item stack that has completed charging. - * - */ - readonly itemStack: ItemStack; - /** - * @remarks - * Returns the source entity that triggered this item event. - * - */ - readonly source: Player; - /** - * @remarks - * Returns the time, in ticks, for the remaining duration left - * before the charge completes its cycle. - * - */ - readonly useDuration: number; -} - -/** - * Manages callbacks that are connected to the completion of - * charging for a chargeable item. - */ -export class ItemCompleteUseAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a chargeable item - * completes charging. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemCompleteUseAfterEvent) => void): (arg: ItemCompleteUseAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a chargeable item - * completes charging. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemCompleteUseAfterEvent) => void): void; -} - -/** - * Base class for item components. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class ItemComponent extends Component { - private constructor(); -} - -/** - * Contains information related to a chargeable item when the - * player has finished using the item and released the build - * action. - */ -export class ItemReleaseUseAfterEvent { - private constructor(); - /** - * @remarks - * Returns the item stack that triggered this item event. - * - */ - readonly itemStack: ItemStack; - /** - * @remarks - * Returns the source entity that triggered this item event. - * - */ - readonly source: Player; - /** - * @remarks - * Returns the time, in ticks, for the remaining duration left - * before the charge completes its cycle. - * - */ - readonly useDuration: number; -} - -/** - * Manages callbacks that are connected to the releasing of - * charging for a chargeable item. - */ -export class ItemReleaseUseAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a chargeable item - * is released from charging. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemReleaseUseAfterEvent) => void): (arg: ItemReleaseUseAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a chargeable item - * is released from charging. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemReleaseUseAfterEvent) => void): void; -} - -/** - * Defines a collection of items. - */ -export class ItemStack { - /** - * @remarks - * Returns whether the item is stackable. An item is considered - * stackable if the item's maximum stack size is greater than 1 - * and the item does not contain any custom data or properties. - * - */ - readonly isStackable: boolean; - /** - * @remarks - * The maximum stack size. This value varies depending on the - * type of item. For example, torches have a maximum stack size - * of 64, while eggs have a maximum stack size of 16. - * - */ - readonly maxAmount: number; - /** - * @remarks - * The type of the item. - * - */ - readonly 'type': ItemType; - /** - * @remarks - * Identifier of the type of items for the stack. If a - * namespace is not specified, 'minecraft:' is assumed. - * Examples include 'wheat' or 'apple'. - * - */ - readonly typeId: string; - /** - * @remarks - * Creates a new instance of a stack of items for use in the - * world. - * - * @param itemType - * Type of item to create. See the {@link - * @minecraft/vanilla-data.MinecraftItemTypes} enumeration for - * a list of standard item types in Minecraft experiences. - * @param amount - * Number of items to place in the stack, between 1-255. The - * provided value will be clamped to the item's maximum stack - * size. Note that certain items can only have one item in the - * stack. - * @throws - * Throws if `itemType` is invalid, or if `amount` is outside - * the range of 1-255. - */ - constructor(itemType: ItemType | string, amount?: number); - /** - * @remarks - * Gets a component (that represents additional capabilities) - * for an item stack. - * - * @param componentId - * The identifier of the component (e.g., 'minecraft:food') to - * retrieve. If no namespace prefix is specified, 'minecraft:' - * is assumed. If the component is not present on the item - * stack or doesn't exist, undefined is returned. - * @example durability.ts - * ```typescript - * // Get the maximum durability of a custom sword item - * const itemStack = new ItemStack("custom:sword"); - * const durability = itemStack.getComponent("minecraft:durability") as ItemDurabilityComponent; - * const maxDurability = durability.maxDurability; - * ``` - */ - getComponent(componentId: string): ItemComponent | undefined; - /** - * @remarks - * Returns all components that are both present on this item - * stack and supported by the API. - * - */ - getComponents(): ItemComponent[]; - /** - * @remarks - * Returns the lore value - a secondary display string - for an - * ItemStack. - * - * @returns - * An array of lore lines. If the item does not have lore, - * returns an empty array. - */ - getLore(): string[]; - /** - * @remarks - * Returns true if the specified component is present on this - * item stack. - * - * @param componentId - * The identifier of the component (e.g., 'minecraft:food') to - * retrieve. If no namespace prefix is specified, 'minecraft:' - * is assumed. - */ - hasComponent(componentId: string): boolean; - /** - * @remarks - * Returns whether this item stack can be stacked with the - * given `itemStack`. This is determined by comparing the item - * type and any custom data and properties associated with the - * item stacks. The amount of each item stack is not taken into - * consideration. - * - * @param itemStack - * ItemStack to check stacking compatability with. - * @returns - * True if the Item Stack is stackable with the itemStack - * passed in. - */ - isStackableWith(itemStack: ItemStack): boolean; - /** - * @remarks - * Sets the lore value - a secondary display string - for an - * ItemStack. The lore list is cleared if set to an empty - * string or undefined. - * - * This function can't be called in read-only mode. - * - * @param loreList - * List of lore lines. Each element in the list represents a - * new line. The maximum lore line count is 20. The maximum - * lore line length is 50 characters. - * @throws This function can throw errors. - * @example diamondAwesomeSword.ts - * ```typescript - * const diamondAwesomeSword = new mc.ItemStack(mc.MinecraftItemTypes.diamondSword, 1); - * let players = mc.world.getAllPlayers(); - * - * diamondAwesomeSword.setLore(["§c§lDiamond Sword of Awesome§r", "+10 coolness", "§p+4 shiny§r"]); - * - * // hover over/select the item in your inventory to see the lore. - * const inventory = players[0].getComponent("inventory") as mc.EntityInventoryComponent; - * inventory.container.setItem(0, diamondAwesomeSword); - * - * let item = inventory.container.getItem(0); - * - * if (item) { - * let enchants = item.getComponent("minecraft:enchantments") as mc.ItemEnchantsComponent; - * let knockbackEnchant = new mc.Enchantment("knockback", 3); - * enchants.enchantments.addEnchantment(knockbackEnchant); - * } - * ``` - * @example multilineLore.ts - * ```typescript - * // Set the lore of an item to multiple lines of text - * const itemStack = new ItemStack("minecraft:diamond_sword"); - * itemStack.setLore(["Line 1", "Line 2", "Line 3"]); - * ``` - */ - setLore(loreList?: string[]): void; -} - -/** - * Contains information related to a chargeable item starting - * to be charged. - */ -export class ItemStartUseAfterEvent { - private constructor(); - /** - * @remarks - * The impacted item stack that is starting to be charged. - * - */ - readonly itemStack: ItemStack; - /** - * @remarks - * Returns the source entity that triggered this item event. - * - */ - readonly source: Player; - /** - * @remarks - * Returns the time, in ticks, for the remaining duration left - * before the charge completes its cycle. - * - */ - readonly useDuration: number; -} - -/** - * Manages callbacks that are connected to the start of - * charging for a chargeable item. - */ -export class ItemStartUseAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a chargeable item - * starts charging. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemStartUseAfterEvent) => void): (arg: ItemStartUseAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a chargeable item - * starts charging. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemStartUseAfterEvent) => void): void; -} - -/** - * Contains information related to an item being used on a - * block. This event fires when a player presses the the Use - * Item / Place Block button to successfully use an item or - * place a block. Fires for the first block that is interacted - * with when performing a build action. Note: This event cannot - * be used with Hoe or Axe items. - */ -export class ItemStartUseOnAfterEvent { - private constructor(); - /** - * @remarks - * The block that the item is used on. - * - */ - readonly block: Block; - /** - * @remarks - * The face of the block that an item is being used on. - * - */ - readonly blockFace: Direction; - /** - * @remarks - * The impacted item stack that is starting to be used. - * - */ - readonly itemStack: ItemStack; - /** - * @remarks - * Returns the source entity that triggered this item event. - * - */ - readonly source: Player; -} - -/** - * Manages callbacks that are connected to an item starting - * being used on a block event. - */ -export class ItemStartUseOnAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when an item is used on - * a block. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemStartUseOnAfterEvent) => void): (arg: ItemStartUseOnAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when an item is used on - * a block. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemStartUseOnAfterEvent) => void): void; -} - -/** - * Contains information related to a chargeable item has - * finished an items use cycle, or when the player has released - * the use action with the item. - */ -export class ItemStopUseAfterEvent { - private constructor(); - /** - * @remarks - * The impacted item stack that is stopping being charged. - * - */ - readonly itemStack: ItemStack; - /** - * @remarks - * Returns the source entity that triggered this item event. - * - */ - readonly source: Player; - /** - * @remarks - * Returns the time, in ticks, for the remaining duration left - * before the charge completes its cycle. - * - */ - readonly useDuration: number; -} - -/** - * Manages callbacks that are connected to the stopping of - * charging for an item that has a registered - * minecraft:chargeable component. - */ -export class ItemStopUseAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a chargeable item - * stops charging. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemStopUseAfterEvent) => void): (arg: ItemStopUseAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a chargeable item - * stops charging. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemStopUseAfterEvent) => void): void; -} - -/** - * Contains information related to an item that has stopped - * being used on a block. This event fires when a player - * successfully uses an item or places a block by pressing the - * Use Item / Place Block button. If multiple blocks are - * placed, this event will only occur once at the beginning of - * the block placement. Note: This event cannot be used with - * Hoe or Axe items. - */ -export class ItemStopUseOnAfterEvent { - private constructor(); - /** - * @remarks - * The block that the item is used on. - * - */ - readonly block: Block; - /** - * @remarks - * The impacted item stack that is being used on a block. - * - */ - readonly itemStack?: ItemStack; - /** - * @remarks - * Returns the source entity that triggered this item event. - * - */ - readonly source: Player; -} - -/** - * Manages callbacks that are connected to an item stops used - * on a block event. - */ -export class ItemStopUseOnAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when an item stops being - * used on a block. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemStopUseOnAfterEvent) => void): (arg: ItemStopUseOnAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when an item is used on - * a block. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemStopUseOnAfterEvent) => void): void; -} - -/** - * Represents the type of an item - for example, Wool. - */ -export class ItemType { - private constructor(); - /** - * @remarks - * Returns the identifier of the item type - for example, - * 'minecraft:apple'. - * - */ - readonly id: string; -} - -/** - * Contains information related to an item being used. This - * event fires when an item is successfully used by a player. - */ -export class ItemUseAfterEvent { - private constructor(); - /** - * @remarks - * The impacted item stack that is being used. - * - */ - itemStack: ItemStack; - /** - * @remarks - * Returns the source entity that triggered this item event. - * - */ - readonly source: Player; -} - -/** - * Manages callbacks that are connected to an item use event. - */ -export class ItemUseAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when an item is used. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemUseAfterEvent) => void): (arg: ItemUseAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when an item is used. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemUseAfterEvent) => void): void; -} - -/** - * Contains information related to an item being used. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class ItemUseBeforeEvent extends ItemUseAfterEvent { - private constructor(); - /** - * @remarks - * If set to true, this will cancel the item use behavior. - * - */ - cancel: boolean; -} - -/** - * Manages callbacks that fire before an item is used. - */ -export class ItemUseBeforeEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called before an item is used. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemUseBeforeEvent) => void): (arg: ItemUseBeforeEvent) => void; - /** - * @remarks - * Removes a callback from being called before an item is used. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemUseBeforeEvent) => void): void; -} - -/** - * Contains information related to an item being used on a - * block. This event fires when an item is successfully used on - * a block by a player. - */ -export class ItemUseOnAfterEvent { - private constructor(); - /** - * @remarks - * The block that the item is used on. - * - */ - readonly block: Block; - /** - * @remarks - * The face of the block that an item is being used on. - * - */ - readonly blockFace: Direction; - /** - * @remarks - * Location relative to the bottom north-west corner of the - * block where the item is placed. - * - */ - readonly faceLocation: Vector3; - /** - * @remarks - * The impacted item stack that is being used on a block. - * - */ - readonly itemStack: ItemStack; - /** - * @remarks - * Returns the source entity that triggered this item event. - * - */ - readonly source: Player; -} - -/** - * Manages callbacks that are connected to an item being used - * on a block event. - */ -export class ItemUseOnAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when an item is used on - * a block. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemUseOnAfterEvent) => void): (arg: ItemUseOnAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when an item is used on - * a block. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemUseOnAfterEvent) => void): void; -} - -/** - * Contains information related to an item being used on a - * block. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class ItemUseOnBeforeEvent extends ItemUseOnAfterEvent { - private constructor(); - /** - * @remarks - * If set to true, this will cancel the item use behavior. - * - */ - cancel: boolean; -} - -/** - * Manages callbacks that fire before an item being used on a - * block event. - */ -export class ItemUseOnBeforeEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called before an item is used - * on a block. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemUseOnBeforeEvent) => void): (arg: ItemUseOnBeforeEvent) => void; - /** - * @remarks - * Removes a callback from being called before an item is used - * on a block. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemUseOnBeforeEvent) => void): void; -} - -/** - * Contains information related to changes to a lever - * activating or deactivating. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class LeverActionAfterEvent extends BlockEvent { - private constructor(); - /** - * @remarks - * True if the lever is activated (that is, transmitting - * power). - * - */ - readonly isPowered: boolean; - /** - * @remarks - * Optional player that triggered the lever activation. - * - */ - readonly player: Player; -} - -/** - * Manages callbacks that are connected to lever moves - * (activates or deactivates). - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class LeverActionAfterEventSignal extends ILeverActionAfterEventSignal { - private constructor(); -} - -/** - * DEPRECATED - * Use @minecraft/vanilla-data.MinecraftDimensionTypes - * A collection of default Minecraft dimension types. - */ -export class MinecraftDimensionTypes { - private constructor(); - /** - * @remarks - * The Nether is a collection of biomes separate from the - * Overworld, including Soul Sand Valleys and Crimson forests. - * Nether fortresses contain exclusive resources. Mobs such as - * Blaze, Hoglins, Piglins, and Ghasts congregate here. - * - */ - static readonly nether = 'minecraft:nether'; - /** - * @remarks - * The overworld is a collection of biomes, including forests, - * plains, jungles, mountains, deserts, taiga, and more. This - * is the default starter dimension for Minecraft. Mobs such as - * Axolotl, Cows, Creepers, and Zombies congregate here. - * - */ - static readonly overworld = 'minecraft:overworld'; - /** - * @remarks - * The End is separate from the Overworld and the Nether and is - * generated whenever you create an End portal. Here, a giant - * center island is surrounded by several smaller areas and - * islands. You can find Endermen here. End midlands are larger - * areas that transition you from the center to the outer edges - * of the End. They contain Shulkers, Endermen, End gateway - * portals, and End cities. End gateway portals are commonly - * found at the outermost edge of the void. You usually find - * End barrens toward the edges of the main areas or land in - * the End. - * - */ - static readonly theEnd = 'minecraft:the_end'; -} - -/** - * Contains a set of additional variable values for further - * defining how rendering and animations function. - */ -export class MolangVariableMap { - /** - * @remarks - * Adds the following variables to Molang: - * - `.r` - Red color value [0-1] - * - `.g` - Green color value [0-1] - * - `.b` - Blue color value [0-1] - * - * @throws This function can throw errors. - */ - setColorRGB(variableName: string, color: RGB): void; - /** - * @remarks - * Adds the following variables to Molang: - * - `.r` - Red color value [0-1] - * - `.g` - Green color value [0-1] - * - `.b` - Blue color value [0-1] - * - `.a` - Alpha (transparency) color value - * [0-1] - * - * @throws This function can throw errors. - */ - setColorRGBA(variableName: string, color: RGBA): void; - /** - * @remarks - * Sets a numeric (decimal) value within the Molang variable - * map. - * - * @param variableName - * Name of the float-based number to set. - * @param number - * Value for the Molang-based variable to set. - * @throws This function can throw errors. - */ - setFloat(variableName: string, number: number): void; - /** - * @remarks - * Adds the following variables to Molang: - * - `.speed` - Speed number provided - * - `.direction_x` - X value from the {@link - * Vector3} provided - * - `.direction_y` - Y value from the {@link - * Vector3} provided - * - `.direction_z` - Z value from the {@link - * Vector3} provided - * - * @throws This function can throw errors. - */ - setSpeedAndDirection(variableName: string, speed: number, direction: Vector3): void; - /** - * @remarks - * Adds the following variables to Molang: - * - `.x` - X value from the {@link Vector3} - * provided - * - `.y` - Y value from the {@link Vector3} - * provided - * - `.z` - Z value from the {@link Vector3} - * provided - * - * @throws This function can throw errors. - */ - setVector3(variableName: string, vector: Vector3): void; -} - -/** - * Represents a player within the world. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class Player extends Entity { - private constructor(); - /** - * @remarks - * Name of the player. - * - * @throws This property can throw when used. - */ - readonly name: string; - /** - * @remarks - * Contains methods for manipulating the on-screen display of a - * Player. - * - * @throws This property can throw when used. - */ - readonly onScreenDisplay: ScreenDisplay; - /** - * @remarks - * Gets the current spawn point of the player. - * - * @throws This function can throw errors. - */ - getSpawnPoint(): DimensionLocation | undefined; - /** - * @remarks - * Plays a sound that only this particular player can hear. - * - * This function can't be called in read-only mode. - * - * @param soundID - * Identifier of the sound to play. - * @param soundOptions - * Additional optional options for the sound. - * @throws This function can throw errors. - * @example playMusicAndSound.ts - * ```typescript - * let players = mc.world.getPlayers(); - * - * const musicOptions: mc.MusicOptions = { - * fade: 0.5, - * loop: true, - * volume: 1.0, - * }; - * mc.world.playMusic("music.menu", musicOptions); - * - * const worldSoundOptions: mc.WorldSoundOptions = { - * pitch: 0.5, - * volume: 4.0, - * }; - * mc.world.playSound("ambient.weather.thunder", targetLocation, worldSoundOptions); - * - * const playerSoundOptions: mc.PlayerSoundOptions = { - * pitch: 1.0, - * volume: 1.0, - * }; - * - * players[0].playSound("bucket.fill_water", playerSoundOptions); - * ``` - */ - playSound(soundID: string, soundOptions?: PlayerSoundOptions): void; - /** - * @remarks - * Sends a message to the player. - * - * @param message - * The message to be displayed. - * @throws - * This method can throw if the provided {@link RawMessage} is - * in an invalid format. For example, if an empty `name` string - * is provided to `score`. - * @example nestedTranslation.ts - * ```typescript - * // Displays "Apple or Coal" - * let rawMessage = { - * translate: "accessibility.list.or.two", - * with: { rawtext: [{ translate: "item.apple.name" }, { translate: "item.coal.name" }] }, - * }; - * player.sendMessage(rawMessage); - * ``` - * @example scoreWildcard.ts - * ```typescript - * // Displays the player's score for objective "obj". Each player will see their own score. - * const rawMessage = { score: { name: "*", objective: "obj" } }; - * world.sendMessage(rawMessage); - * ``` - * @example sendBasicMessage.ts - * ```typescript - * let players = mc.world.getPlayers(); - * - * players[0].sendMessage("Hello World!"); - * ``` - * @example sendTranslatedMessage.ts - * ```typescript - * let players = mc.world.getPlayers(); - * - * players[0].sendMessage({ translate: "authentication.welcome", with: ["Amazing Player 1"] }); - * ``` - * @example simpleString.ts - * ```typescript - * // Displays "Hello, world!" - * world.sendMessage("Hello, world!"); - * ``` - * @example translation.ts - * ```typescript - * // Displays "First or Second" - * const rawMessage = { translate: "accessibility.list.or.two", with: ["First", "Second"] }; - * player.sendMessage(rawMessage); - * ``` - */ - sendMessage(message: (RawMessage | string)[] | RawMessage | string): void; - /** - * @remarks - * Sets the current starting spawn point for this particular - * player. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - * - * {@link Error} - * - * {@link LocationOutOfWorldBoundariesError} - */ - setSpawnPoint(spawnPoint?: DimensionLocation): void; -} - -/** - * Contains information regarding a player that has joined. - * See the playerSpawn event for more detailed information that - * could be returned after the first time a player has spawned - * within the game. - */ -export class PlayerJoinAfterEvent { - private constructor(); - /** - * @remarks - * Opaque string identifier of the player that joined the game. - * - */ - readonly playerId: string; - /** - * @remarks - * Name of the player that has joined. - * - */ - readonly playerName: string; -} - -/** - * Manages callbacks that are connected to a player joining the - * world. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class PlayerJoinAfterEventSignal extends IPlayerJoinAfterEventSignal { - private constructor(); -} - -/** - * Contains information regarding a player that has left the - * world. - */ -export class PlayerLeaveAfterEvent { - private constructor(); - /** - * @remarks - * Opaque string identifier of the player that has left the - * event. - * - */ - readonly playerId: string; - /** - * @remarks - * Player that has left the world. - * - */ - readonly playerName: string; -} - -/** - * Manages callbacks that are connected to a player leaving the - * world. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class PlayerLeaveAfterEventSignal extends IPlayerLeaveAfterEventSignal { - private constructor(); -} - -/** - * An event that contains more information about a player - * spawning. - */ -export class PlayerSpawnAfterEvent { - private constructor(); - /** - * @remarks - * If true, this is the initial spawn of a player after joining - * the game. - * - * This property can't be edited in read-only mode. - * - */ - initialSpawn: boolean; - /** - * @remarks - * Object that represents the player that joined the game. - * - * This property can't be edited in read-only mode. - * - */ - player: Player; -} - -/** - * Registers an event when a player is spawned (or re-spawned - * after death) and fully ready within the world. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class PlayerSpawnAfterEventSignal extends IPlayerSpawnAfterEventSignal { - private constructor(); -} - -/** - * Contains information related to changes to a pressure plate - * pop. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class PressurePlatePopAfterEvent extends BlockEvent { - private constructor(); - /** - * @remarks - * The redstone power of the pressure plate before it was - * popped. - * - */ - readonly previousRedstonePower: number; - /** - * @remarks - * The redstone power of the pressure plate at the time of the - * pop. - * - */ - readonly redstonePower: number; -} - -/** - * Manages callbacks that are connected to when a pressure - * plate is popped. - */ -export class PressurePlatePopAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a pressure plate is - * popped. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: PressurePlatePopAfterEvent) => void): (arg: PressurePlatePopAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a pressure plate - * is popped. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: PressurePlatePopAfterEvent) => void): void; -} - -/** - * Contains information related to changes to a pressure plate - * push. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class PressurePlatePushAfterEvent extends BlockEvent { - private constructor(); - /** - * @remarks - * The redstone power of the pressure plate before it was - * pushed. - * - */ - readonly previousRedstonePower: number; - /** - * @remarks - * The redstone power of the pressure plate at the time of the - * push. - * - */ - readonly redstonePower: number; - /** - * @remarks - * Source that triggered the pressure plate push. - * - */ - readonly source: Entity; -} - -/** - * Manages callbacks that are connected to when a pressure - * plate is pushed. - */ -export class PressurePlatePushAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a pressure plate is - * pushed. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: PressurePlatePushAfterEvent) => void): (arg: PressurePlatePushAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a pressure plate - * is pushed. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: PressurePlatePushAfterEvent) => void): void; -} - -/** - * Contains information related to a projectile hitting a - * block. - */ -export class ProjectileHitBlockAfterEvent { - private constructor(); - /** - * @remarks - * Dimension where this projectile hit took place. - * - */ - readonly dimension: Dimension; - /** - * @remarks - * Direction vector of the projectile as it hit a block. - * - */ - readonly hitVector: Vector3; - /** - * @remarks - * Location where the projectile hit occurred. - * - */ - readonly location: Vector3; - /** - * @remarks - * Entity for the projectile that hit a block. - * - */ - readonly projectile: Entity; - /** - * @remarks - * Optional source entity that fired the projectile. - * - */ - readonly source?: Entity; - /** - * @remarks - * Contains additional information about the block that was hit - * by the projectile. - * - * This function can't be called in read-only mode. - * - */ - getBlockHit(): BlockHitInformation; -} - -/** - * Manages callbacks that are connected to when a projectile - * hits a block. - */ -export class ProjectileHitBlockAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a projectile hits a - * block. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ProjectileHitBlockAfterEvent) => void): (arg: ProjectileHitBlockAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a projectile hits - * a block. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ProjectileHitBlockAfterEvent) => void): void; -} - -/** - * Contains information related to a projectile hitting an - * entity. - */ -export class ProjectileHitEntityAfterEvent { - private constructor(); - /** - * @remarks - * Dimension where this projectile hit took place. - * - */ - readonly dimension: Dimension; - /** - * @remarks - * Direction vector of the projectile as it hit an entity. - * - */ - readonly hitVector: Vector3; - /** - * @remarks - * Location where the projectile hit occurred. - * - */ - readonly location: Vector3; - /** - * @remarks - * Entity for the projectile that hit an entity. - * - */ - readonly projectile: Entity; - /** - * @remarks - * Optional source entity that fired the projectile. - * - */ - readonly source?: Entity; - /** - * @remarks - * Contains additional information about an entity that was - * hit. - * - * This function can't be called in read-only mode. - * - */ - getEntityHit(): EntityHitInformation; -} - -/** - * Manages callbacks that are connected to when a projectile - * hits an entity. - */ -export class ProjectileHitEntityAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a projectile hits - * an entity. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ProjectileHitEntityAfterEvent) => void): (arg: ProjectileHitEntityAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a projectile hits - * an entity. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ProjectileHitEntityAfterEvent) => void): void; -} - -/** - * Contains objectives and participants for the scoreboard. - */ -export class Scoreboard { - private constructor(); - /** - * @remarks - * Adds a new objective to the scoreboard. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - addObjective(objectiveId: string, displayName: string): ScoreboardObjective; - /** - * @remarks - * Clears the objective that occupies a display slot. - * - * This function can't be called in read-only mode. - * - */ - clearObjectiveAtDisplaySlot(displaySlotId: DisplaySlotId): ScoreboardObjective | undefined; - /** - * @remarks - * Returns a specific objective (by id). - * - * @param objectiveId - * Identifier of the objective. - */ - getObjective(objectiveId: string): ScoreboardObjective | undefined; - /** - * @remarks - * Returns an objective that occupies the specified display - * slot. - * - */ - getObjectiveAtDisplaySlot(displaySlotId: DisplaySlotId): ScoreboardObjectiveDisplayOptions | undefined; - /** - * @remarks - * Returns all defined objectives. - * - */ - getObjectives(): ScoreboardObjective[]; - /** - * @remarks - * Returns all defined scoreboard identities. - * - */ - getParticipants(): ScoreboardIdentity[]; - /** - * @remarks - * Removes an objective from the scoreboard. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - removeObjective(objectiveId: ScoreboardObjective | string): boolean; - /** - * @remarks - * Sets an objective into a display slot with specified - * additional display settings. - * - * This function can't be called in read-only mode. - * - * @returns - * Returns the previous `ScoreboardObjective` set at the - * display slot, if no objective was previously set it returns - * `undefined`. - * @throws This function can throw errors. - */ - setObjectiveAtDisplaySlot( - displaySlotId: DisplaySlotId, - objectiveDisplaySetting: ScoreboardObjectiveDisplayOptions, - ): ScoreboardObjective | undefined; -} - -/** - * Contains an identity of the scoreboard item. - */ -export class ScoreboardIdentity { - private constructor(); - /** - * @remarks - * Returns the player-visible name of this identity. - * - */ - readonly displayName: string; - /** - * @remarks - * Identifier of the scoreboard identity. - * - */ - readonly id: number; - /** - * @remarks - * Type of the scoreboard identity. - * - */ - readonly 'type': ScoreboardIdentityType; - /** - * @remarks - * If the scoreboard identity is an entity or player, returns - * the entity that this scoreboard item corresponds to. - * - * @throws This function can throw errors. - */ - getEntity(): Entity | undefined; - /** - * @remarks - * Returns true if the ScoreboardIdentity reference is still - * valid. - * - */ - isValid(): boolean; -} - -/** - * Contains objectives and participants for the scoreboard. - */ -export class ScoreboardObjective { - private constructor(); - /** - * @remarks - * Returns the player-visible name of this scoreboard - * objective. - * - * @throws This property can throw when used. - */ - readonly displayName: string; - /** - * @remarks - * Identifier of the scoreboard objective. - * - * @throws This property can throw when used. - */ - readonly id: string; - /** - * @remarks - * Adds a score to the given participant and objective. - * - * This function can't be called in read-only mode. - * - * @param participant - * Participant to apply the scoreboard value addition to. - * @throws This function can throw errors. - */ - addScore(participant: Entity | ScoreboardIdentity | string, scoreToAdd: number): number; - /** - * @remarks - * Returns all objective participant identities. - * - * @throws This function can throw errors. - */ - getParticipants(): ScoreboardIdentity[]; - /** - * @remarks - * Returns a specific score for a participant. - * - * @param participant - * Identifier of the participant to retrieve a score for. - * @throws This function can throw errors. - */ - getScore(participant: Entity | ScoreboardIdentity | string): number | undefined; - /** - * @remarks - * Returns specific scores for this objective for all - * participants. - * - * @throws This function can throw errors. - */ - getScores(): ScoreboardScoreInfo[]; - /** - * @remarks - * Returns if the specified identity is a participant of the - * scoreboard objective. - * - * @throws This function can throw errors. - */ - hasParticipant(participant: Entity | ScoreboardIdentity | string): boolean; - /** - * @remarks - * Returns true if the ScoreboardObjective reference is still - * valid. - * - */ - isValid(): boolean; - /** - * @remarks - * Removes a participant from this scoreboard objective. - * - * This function can't be called in read-only mode. - * - * @param participant - * Participant to remove from being tracked with this - * objective. - * @throws This function can throw errors. - */ - removeParticipant(participant: Entity | ScoreboardIdentity | string): boolean; - /** - * @remarks - * Sets a score for a participant. - * - * This function can't be called in read-only mode. - * - * @param participant - * Identity of the participant. - * @param score - * New value of the score. - * @throws This function can throw errors. - */ - setScore(participant: Entity | ScoreboardIdentity | string, score: number): void; -} - -/** - * Contains a pair of a scoreboard participant and its - * respective score. - */ -export class ScoreboardScoreInfo { - private constructor(); - /** - * @remarks - * This scoreboard participant for this score. - * - */ - readonly participant: ScoreboardIdentity; - /** - * @remarks - * Score value of the identity for this objective. - * - */ - readonly score: number; -} - -/** - * Contains information about user interface elements that are - * showing up on the screen. - */ -export class ScreenDisplay { - private constructor(); - /** - * @remarks - * Returns true if the current reference to this screen display - * manager object is valid and functional. - * - */ - isValid(): boolean; - /** - * @remarks - * Set the action bar text - a piece of text that displays - * beneath the title and above the hot-bar. - * - * This function can't be called in read-only mode. - * - * @param text - * New value for the action bar text. - * @throws This function can throw errors. - */ - setActionBar(text: (RawMessage | string)[] | RawMessage | string): void; - /** - * @remarks - * Will cause a title to show up on the player's on screen - * display. Will clear the title if set to empty string. You - * can optionally specify an additional subtitle as well as - * fade in, stay and fade out times. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - * @example countdown.ts - * ```typescript - * let players = mc.world.getPlayers(); - * - * players[0].onScreenDisplay.setTitle("Get ready!", { - * stayDuration: 220, - * fadeInDuration: 2, - * fadeOutDuration: 4, - * subtitle: "10", - * }); - * - * let countdown = 10; - * - * let intervalId = mc.system.runInterval(() => { - * countdown--; - * players[0].onScreenDisplay.updateSubtitle(countdown.toString()); - * - * if (countdown == 0) { - * mc.system.clearRun(intervalId); - * } - * }, 20); - * ``` - * @example setTitle.ts - * ```typescript - * let players = mc.world.getPlayers(); - * - * players[0].onScreenDisplay.setTitle("§o§6Fancy Title§r"); - * ``` - * @example setTitleAndSubtitle.ts - * ```typescript - * let players = mc.world.getPlayers(); - * - * players[0].onScreenDisplay.setTitle("Chapter 1", { - * stayDuration: 100, - * fadeInDuration: 2, - * fadeOutDuration: 4, - * subtitle: "Trouble in Block Town", - * }); - * ``` - */ - setTitle(title: (RawMessage | string)[] | RawMessage | string, options?: TitleDisplayOptions): void; - /** - * @remarks - * Updates the subtitle if the subtitle was previously - * displayed via the setTitle method. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - updateSubtitle(subtitle: (RawMessage | string)[] | RawMessage | string): void; -} - -/** - * Returns additional data about a /scriptevent command - * invocation. - */ -export class ScriptEventCommandMessageAfterEvent { - private constructor(); - /** - * @remarks - * Identifier of this ScriptEvent command message. - * - */ - readonly id: string; - /** - * @remarks - * If this command was initiated via an NPC, returns the entity - * that initiated the NPC dialogue. - * - */ - readonly initiator?: Entity; - /** - * @remarks - * Optional additional data passed in with the script event - * command. - * - */ - readonly message: string; - /** - * @remarks - * Source block if this command was triggered via a block - * (e.g., a commandblock.) - * - */ - readonly sourceBlock?: Block; - /** - * @remarks - * Source entity if this command was triggered by an entity - * (e.g., a NPC). - * - */ - readonly sourceEntity?: Entity; - /** - * @remarks - * Returns the type of source that fired this command. - * - */ - readonly sourceType: ScriptEventSource; -} - -/** - * Allows for registering an event handler that responds to - * inbound /scriptevent commands. - */ -export class ScriptEventCommandMessageAfterEventSignal { - private constructor(); - /** - * @remarks - * Registers a new ScriptEvent handler. - * - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: ScriptEventCommandMessageAfterEvent) => void, - options?: ScriptEventMessageFilterOptions, - ): (arg: ScriptEventCommandMessageAfterEvent) => void; - /** - * @remarks - * Unsubscribes a particular handler for a ScriptEvent event. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ScriptEventCommandMessageAfterEvent) => void): void; -} - -/** - * A class that provides system-level events and functions. - */ -export class System { - private constructor(); - /** - * @remarks - * Returns a collection of after-events for system-level - * operations. - * - */ - readonly afterEvents: SystemAfterEvents; - /** - * @remarks - * Represents the current world tick of the server. - * - */ - readonly currentTick: number; - /** - * @remarks - * Cancels the execution of a function run that was previously - * scheduled via the `run` function. - * - */ - clearRun(runId: number): void; - /** - * @remarks - * Runs a specified function at a future time. This is - * frequently used to implement delayed behaviors and game - * loops. - * - * @param callback - * Function callback to run when the tickDelay time criteria is - * met. - * @returns - * An opaque identifier that can be used with the `clearRun` - * function to cancel the execution of this run. - * @example trapTick.ts - * ```typescript - * const overworld = mc.world.getDimension("overworld"); - * - * try { - * // Minecraft runs at 20 ticks per second. - * if (mc.system.currentTick % 1200 === 0) { - * mc.world.sendMessage("Another minute passes..."); - * } - * } catch (e) { - * console.warn("Error: " + e); - * } - * - * mc.system.run(trapTick); - * ``` - */ - run(callback: () => void): number; - /** - * @remarks - * Runs a set of code on an interval. - * - * @param callback - * Functional code that will run when this interval occurs. - * @param tickInterval - * An interval of every N ticks that the callback will be - * called upon. - * @returns - * An opaque handle that can be used with the clearRun method - * to stop the run of this function on an interval. - * @example every30Seconds.ts - * ```typescript - * let intervalRunIdentifier = Math.floor(Math.random() * 10000); - * - * mc.system.runInterval(() => { - * mc.world.sendMessage("This is an interval run " + intervalRunIdentifier + " sending a message every 30 seconds."); - * }, 600); - * ``` - */ - runInterval(callback: () => void, tickInterval?: number): number; - /** - * @remarks - * Runs a set of code at a future time specified by tickDelay. - * - * @param callback - * Functional code that will run when this timeout occurs. - * @param tickDelay - * Amount of time, in ticks, before the interval will be - * called. - * @returns - * An opaque handle that can be used with the clearRun method - * to stop the run of this function on an interval. - */ - runTimeout(callback: () => void, tickDelay?: number): number; -} - -/** - * Provides a set of events that fire within the broader - * scripting system within Minecraft. - */ -export class SystemAfterEvents { - private constructor(); - /** - * @remarks - * An event that fires when a /scriptevent command is set. This - * provides a way for commands and other systems to trigger - * behavior within script. - * - */ - readonly scriptEventReceive: ScriptEventCommandMessageAfterEventSignal; -} - -/** - * Contains information related to changes to a target block - * hit. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class TargetBlockHitAfterEvent extends BlockEvent { - private constructor(); - /** - * @remarks - * The position where the source hit the block. - * - */ - readonly hitVector: Vector3; - /** - * @remarks - * The redstone power before the block is hit. - * - */ - readonly previousRedstonePower: number; - /** - * @remarks - * The redstone power at the time the block is hit. - * - */ - readonly redstonePower: number; - /** - * @remarks - * Optional source that hit the target block. - * - */ - readonly source: Entity; -} - -/** - * Manages callbacks that are connected to when a target block - * is hit. - */ -export class TargetBlockHitAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a target block is - * hit. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: TargetBlockHitAfterEvent) => void): (arg: TargetBlockHitAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a target block is - * hit. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: TargetBlockHitAfterEvent) => void): void; -} - -/** - * Contains information related to changes to a trip wire trip. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class TripWireTripAfterEvent extends BlockEvent { - private constructor(); - /** - * @remarks - * Whether or not the block has redstone power. - * - */ - readonly isPowered: boolean; - /** - * @remarks - * The sources that triggered the trip wire to trip. - * - */ - readonly sources: Entity[]; -} - -/** - * Manages callbacks that are connected to when a trip wire is - * tripped. - */ -export class TripWireTripAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a trip wire is - * tripped. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: TripWireTripAfterEvent) => void): (arg: TripWireTripAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a trip wire is - * tripped. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: TripWireTripAfterEvent) => void): void; -} - -/** - * A class that wraps the state of a world - a set of - * dimensions and the environment of Minecraft. - */ -export class World { - private constructor(); - /** - * @remarks - * Contains a set of events that are applicable to the entirety - * of the world. Event callbacks are called in a deferred - * manner. Event callbacks are executed in read-write mode. - * - */ - readonly afterEvents: WorldAfterEvents; - /** - * @remarks - * Contains a set of events that are applicable to the entirety - * of the world. Event callbacks are called immediately. Event - * callbacks are executed in read-only mode. - * - */ - readonly beforeEvents: WorldBeforeEvents; - /** - * @remarks - * Returns the general global scoreboard that applies to the - * world. - * - */ - readonly scoreboard: Scoreboard; - /** - * @remarks - * Returns the absolute time since the start of the world. - * - */ - getAbsoluteTime(): number; - /** - * @remarks - * Returns an array of all active players within the world. - * - * @throws This function can throw errors. - */ - getAllPlayers(): Player[]; - /** - * @remarks - * Returns the current day. - * - * @returns - * The current day, determined by the world time divided by the - * number of ticks per day. New worlds start at day 0. - */ - getDay(): number; - /** - * @remarks - * Returns the default Overworld spawn location. - * - * @returns - * The default Overworld spawn location. By default, the Y - * coordinate is 32767, indicating a player's spawn height is - * not fixed and will be determined by surrounding blocks. - */ - getDefaultSpawnLocation(): Vector3; - /** - * @remarks - * Returns a dimension object. - * - * @param dimensionId - * The name of the dimension. For example, "overworld", - * "nether" or "the_end". - * @returns - * The requested dimension - * @throws - * Throws if the given dimension name is invalid - */ - getDimension(dimensionId: string): Dimension; - /** - * @remarks - * Returns a set of players based on a set of conditions - * defined via the EntityQueryOptions set of filter criteria. - * - * @param options - * Additional options that can be used to filter the set of - * players returned. - * @returns - * A player array. - * @throws - * Throws if the provided EntityQueryOptions are invalid. - */ - getPlayers(options?: EntityQueryOptions): Player[]; - /** - * @remarks - * Returns the time of day. - * - * @returns - * The time of day, in ticks, between 0 and 24000. - */ - getTimeOfDay(): number; - /** - * @remarks - * Plays a particular music track for all players. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - * @example playMusicAndSound.ts - * ```typescript - * let players = mc.world.getPlayers(); - * - * const musicOptions: mc.MusicOptions = { - * fade: 0.5, - * loop: true, - * volume: 1.0, - * }; - * mc.world.playMusic("music.menu", musicOptions); - * - * const worldSoundOptions: mc.WorldSoundOptions = { - * pitch: 0.5, - * volume: 4.0, - * }; - * mc.world.playSound("ambient.weather.thunder", targetLocation, worldSoundOptions); - * - * const playerSoundOptions: mc.PlayerSoundOptions = { - * pitch: 1.0, - * volume: 1.0, - * }; - * - * players[0].playSound("bucket.fill_water", playerSoundOptions); - * ``` - */ - playMusic(trackID: string, musicOptions?: MusicOptions): void; - /** - * @remarks - * Plays a sound for all players. - * - * This function can't be called in read-only mode. - * - * @throws - * An error will be thrown if volume is less than 0.0. - * An error will be thrown if fade is less than 0.0. - * An error will be thrown if pitch is less than 0.01. - * An error will be thrown if volume is less than 0.0. - * @example playMusicAndSound.ts - * ```typescript - * let players = mc.world.getPlayers(); - * - * const musicOptions: mc.MusicOptions = { - * fade: 0.5, - * loop: true, - * volume: 1.0, - * }; - * mc.world.playMusic("music.menu", musicOptions); - * - * const worldSoundOptions: mc.WorldSoundOptions = { - * pitch: 0.5, - * volume: 4.0, - * }; - * mc.world.playSound("ambient.weather.thunder", targetLocation, worldSoundOptions); - * - * const playerSoundOptions: mc.PlayerSoundOptions = { - * pitch: 1.0, - * volume: 1.0, - * }; - * - * players[0].playSound("bucket.fill_water", playerSoundOptions); - * ``` - */ - playSound(soundID: string, location: Vector3, soundOptions?: WorldSoundOptions): void; - /** - * @remarks - * Queues an additional music track for players. If a track is - * not playing, a music track will play. - * - * This function can't be called in read-only mode. - * - * @param musicOptions - * Additional options for the music track. - * @throws - * An error will be thrown if volume is less than 0.0. - * An error will be thrown if fade is less than 0.0. - * - */ - queueMusic(trackID: string, musicOptions?: MusicOptions): void; - /** - * @remarks - * Sends a message to all players. - * - * @param message - * The message to be displayed. - * @throws - * This method can throw if the provided {@link RawMessage} is - * in an invalid format. For example, if an empty `name` string - * is provided to `score`. - * @example nestedTranslation.ts - * ```typescript - * // Displays "Apple or Coal" - * let rawMessage = { - * translate: "accessibility.list.or.two", - * with: { rawtext: [{ translate: "item.apple.name" }, { translate: "item.coal.name" }] }, - * }; - * world.sendMessage(rawMessage); - * ``` - * @example scoreWildcard.ts - * ```typescript - * // Displays the player's score for objective "obj". Each player will see their own score. - * const rawMessage = { score: { name: "*", objective: "obj" } }; - * world.sendMessage(rawMessage); - * ``` - * @example simpleString.ts - * ```typescript - * // Displays "Hello, world!" - * world.sendMessage("Hello, world!"); - * ``` - * @example translation.ts - * ```typescript - * // Displays "First or Second" - * const rawMessage = { translate: "accessibility.list.or.two", with: ["First", "Second"] }; - * world.sendMessage(rawMessage); - * ``` - */ - sendMessage(message: (RawMessage | string)[] | RawMessage | string): void; - /** - * @remarks - * Sets the world time. - * - * This function can't be called in read-only mode. - * - * @param absoluteTime - * The world time, in ticks. - */ - setAbsoluteTime(absoluteTime: number): void; - /** - * @remarks - * Sets a default spawn location for all players. - * - * This function can't be called in read-only mode. - * - * @param spawnLocation - * Location of the spawn point. Note that this is assumed to be - * within the overworld dimension. - * @throws - * Throws if the provided spawn location is out of bounds. - * - * {@link Error} - * - * {@link LocationOutOfWorldBoundariesError} - */ - setDefaultSpawnLocation(spawnLocation: Vector3): void; - /** - * @remarks - * Sets the time of day. - * - * This function can't be called in read-only mode. - * - * @param timeOfDay - * The time of day, in ticks, between 0 and 24000. - * @throws - * Throws if the provided time of day is not within the valid - * range. - */ - setTimeOfDay(timeOfDay: number | TimeOfDay): void; - /** - * @remarks - * Stops any music tracks from playing. - * - * This function can't be called in read-only mode. - * - */ - stopMusic(): void; -} - -/** - * Contains a set of events that are available across the scope - * of the World. - */ -export class WorldAfterEvents { - private constructor(); - /** - * @remarks - * This event fires when a button is pushed. - * - */ - readonly buttonPush: ButtonPushAfterEventSignal; - /** - * @remarks - * This event fires when an entity dies. - * - */ - readonly entityDie: EntityDieAfterEventSignal; - /** - * @remarks - * This event fires when entity health changes in any degree. - * - */ - readonly entityHealthChanged: EntityHealthChangedAfterEventSignal; - /** - * @remarks - * This event fires when an entity hits (that is, melee - * attacks) a block. - * - */ - readonly entityHitBlock: EntityHitBlockAfterEventSignal; - /** - * @remarks - * This event fires when an entity hits (that is, melee - * attacks) another entity. - * - */ - readonly entityHitEntity: EntityHitEntityAfterEventSignal; - /** - * @remarks - * This event fires when an entity is hurt (takes damage). - * - */ - readonly entityHurt: EntityHurtAfterEventSignal; - /** - * @remarks - * This event fires when a chargeable item completes charging. - * - */ - readonly itemCompleteUse: ItemCompleteUseAfterEventSignal; - /** - * @remarks - * This event fires when a chargeable item is released from - * charging. - * - */ - readonly itemReleaseUse: ItemReleaseUseAfterEventSignal; - /** - * @remarks - * This event fires when a chargeable item starts charging. - * - */ - readonly itemStartUse: ItemStartUseAfterEventSignal; - /** - * @remarks - * This event fires when a player successfully uses an item or - * places a block by pressing the Use Item / Place Block - * button. If multiple blocks are placed, this event will only - * occur once at the beginning of the block placement. Note: - * This event cannot be used with Hoe or Axe items. - * - */ - readonly itemStartUseOn: ItemStartUseOnAfterEventSignal; - /** - * @remarks - * This event fires when a chargeable item stops charging. - * - */ - readonly itemStopUse: ItemStopUseAfterEventSignal; - /** - * @remarks - * This event fires when a player releases the Use Item / Place - * Block button after successfully using an item. Note: This - * event cannot be used with Hoe or Axe items. - * - */ - readonly itemStopUseOn: ItemStopUseOnAfterEventSignal; - /** - * @remarks - * This event fires when an item is successfully used by a - * player. - * - */ - readonly itemUse: ItemUseAfterEventSignal; - /** - * @remarks - * This event fires when an item is used on a block by a - * player. - * - */ - readonly itemUseOn: ItemUseOnAfterEventSignal; - /** - * @remarks - * A lever has been pulled. - * - */ - readonly leverAction: LeverActionAfterEventSignal; - /** - * @remarks - * This event fires when a player joins a world. See also - * playerSpawn for another related event you can trap for when - * a player is spawned the first time within a world. - * - */ - readonly playerJoin: PlayerJoinAfterEventSignal; - /** - * @remarks - * This event fires when a player leaves a world. - * - */ - readonly playerLeave: PlayerLeaveAfterEventSignal; - /** - * @remarks - * This event fires when a player spawns or respawns. Note that - * an additional flag within this event will tell you whether - * the player is spawning right after join vs. a respawn. - * - */ - readonly playerSpawn: PlayerSpawnAfterEventSignal; - /** - * @remarks - * A pressure plate has popped back up (i.e., there are no - * entities on the pressure plate.) - * - */ - readonly pressurePlatePop: PressurePlatePopAfterEventSignal; - /** - * @remarks - * A pressure plate has pushed (at least one entity has moved - * onto a pressure plate.) - * - */ - readonly pressurePlatePush: PressurePlatePushAfterEventSignal; - /** - * @remarks - * This event fires when a projectile hits a block. - * - */ - readonly projectileHitBlock: ProjectileHitBlockAfterEventSignal; - /** - * @remarks - * This event fires when a projectile hits an entity. - * - */ - readonly projectileHitEntity: ProjectileHitEntityAfterEventSignal; - /** - * @remarks - * A target block was hit. - * - */ - readonly targetBlockHit: TargetBlockHitAfterEventSignal; - /** - * @remarks - * A trip wire was tripped. - * - */ - readonly tripWireTrip: TripWireTripAfterEventSignal; -} - -/** - * A set of events that fire before an actual action occurs. In - * most cases, you can potentially cancel or modify the - * impending event. Note that in before events any APIs that - * modify gameplay state will not function and will throw an - * error. (e.g., dimension.spawnEntity) - */ -export class WorldBeforeEvents { - private constructor(); - /** - * @remarks - * This event fires when an item is successfully used by a - * player. - * - */ - readonly itemUse: ItemUseBeforeEventSignal; - /** - * @remarks - * This event fires when an item is used on a block by a - * player. - * - */ - readonly itemUseOn: ItemUseOnBeforeEventSignal; -} - -/** - * Contains more information for events where a block is hit. - */ -export interface BlockHitInformation { - /** - * @remarks - * Block that was hit. - * - */ - block: Block; - /** - * @remarks - * Face of the block that was hit. - * - */ - face: Direction; - /** - * @remarks - * Location relative to the bottom north-west corner of the - * block. - * - */ - faceLocation: Vector3; -} - -/** - * Contains information for block raycast hit results. - */ -export interface BlockRaycastHit { - /** - * @remarks - * Block that was hit. - * - */ - block: Block; - /** - * @remarks - * Face of the block that was hit. - * - */ - face: Direction; - /** - * @remarks - * Hit location relative to the bottom north-west corner of the - * block. - * - */ - faceLocation: Vector3; -} - -/** - * Contains additional options for configuring a block raycast - * query. - */ -export interface BlockRaycastOptions { - /** - * @remarks - * If true, liquid blocks will be considered as blocks that - * 'stop' the raycast. - * - */ - includeLiquidBlocks?: boolean; - /** - * @remarks - * If true, passable blocks like vines and flowers will be - * considered as blocks that 'stop' the raycast. - * - */ - includePassableBlocks?: boolean; - /** - * @remarks - * Maximum distance, in blocks, to process the raycast. - * - */ - maxDistance?: number; -} - -/** - * An exact coordinate within the world, including its - * dimension and location. - */ -export interface DimensionLocation { - /** - * @remarks - * Dimension that this coordinate is associated with. - * - */ - dimension: Dimension; - /** - * @remarks - * X component of this dimension-location. - * - */ - x: number; - /** - * @remarks - * Y component of this dimension-location. - * - */ - y: number; - /** - * @remarks - * Z component of this dimension-location. - * - */ - z: number; -} - -/** - * Additional options for when damage has been applied via a - * projectile. - */ -export interface EntityApplyDamageByProjectileOptions { - /** - * @remarks - * Optional entity that fired the projectile. - * - */ - damagingEntity?: Entity; - /** - * @remarks - * Projectile that caused damage. - * - */ - damagingProjectile: Entity; -} - -/** - * Additional descriptions and metadata for a damage event. - */ -export interface EntityApplyDamageOptions { - /** - * @remarks - * Underlying cause of the damage. - * - */ - cause: EntityDamageCause; - /** - * @remarks - * Optional entity that caused the damage. - * - */ - damagingEntity?: Entity; -} - -/** - * Provides information about how damage has been applied to an - * entity. - */ -export interface EntityDamageSource { - /** - * @remarks - * Cause enumeration of damage. - * - */ - cause: EntityDamageCause; - /** - * @remarks - * Optional entity that caused the damage. - * - */ - damagingEntity?: Entity; - /** - * @remarks - * Optional projectile that may have caused damage. - * - */ - damagingProjectile?: Entity; -} - -/** - * Contains additional options for entity effects. - */ -export interface EntityEffectOptions { - /** - * @remarks - * The strength of the effect. - * - */ - amplifier?: number; - /** - * @remarks - * If true, will show particles when effect is on the entity. - * - */ - showParticles?: boolean; -} - -/** - * Contains optional parameters for registering an entity - * event. - */ -export interface EntityEventOptions { - /** - * @remarks - * If this value is set, this event will only fire for entities - * that match the entities within this collection. - * - */ - entities?: Entity[]; - /** - * @remarks - * If this value is set, this event will only fire if the - * impacted entities' type matches this parameter. - * - */ - entityTypes?: string[]; -} - -/** - * Contains additional information about an entity that was - * hit. - */ -export interface EntityHitInformation { - /** - * @remarks - * Entity that was hit. - * - */ - entity: Entity; -} - -/** - * Contains options for selecting entities within an area. - */ -export interface EntityQueryOptions { - /** - * @remarks - * Limits the number of entities to return, opting for the - * closest N entities as specified by this property. The - * location value must also be specified on the query options - * object. - * - */ - closest?: number; - /** - * @remarks - * Excludes entities that match one or more of the specified - * families. - * - */ - excludeFamilies?: string[]; - /** - * @remarks - * Excludes entities if have a specific gamemode that matches - * the specified gamemode. - * - */ - excludeGameModes?: GameMode[]; - /** - * @remarks - * Excludes entities that have a name that match one of the - * specified values. - * - */ - excludeNames?: string[]; - /** - * @remarks - * Excludes entities with a tag that matches one of the - * specified values. - * - */ - excludeTags?: string[]; - /** - * @remarks - * Excludes entities if they are one of the specified types. - * - */ - excludeTypes?: string[]; - /** - * @remarks - * If specified, includes entities that match all of the - * specified families. - * - */ - families?: string[]; - /** - * @remarks - * Limits the number of entities to return, opting for the - * farthest N entities as specified by this property. The - * location value must also be specified on the query options - * object. - * - */ - farthest?: number; - /** - * @remarks - * If specified, includes entities with a gamemode that matches - * the specified gamemode. - * - */ - gameMode?: GameMode; - /** - * @remarks - * Adds a seed location to the query that is used in - * conjunction with closest, farthest, limit, volume, and - * distance properties. - * - */ - location?: Vector3; - /** - * @remarks - * If specified, includes entities that are less than this - * distance away from the location specified in the location - * property. - * - */ - maxDistance?: number; - /** - * @remarks - * If specified, will only include entities that have at most - * this horizontal rotation. - * - */ - maxHorizontalRotation?: number; - /** - * @remarks - * If defined, only players that have at most this level are - * returned. - * - */ - maxLevel?: number; - /** - * @remarks - * If specified, only entities that have at most this vertical - * rotation are returned. - * - */ - maxVerticalRotation?: number; - /** - * @remarks - * If specified, includes entities that are least this distance - * away from the location specified in the location property. - * - */ - minDistance?: number; - /** - * @remarks - * If specified, will only include entities that have at a - * minimum this horizontal rotation. - * - */ - minHorizontalRotation?: number; - /** - * @remarks - * If defined, only players that have at least this level are - * returned. - * - */ - minLevel?: number; - /** - * @remarks - * If specified, will only include entities that have at least - * this vertical rotation. - * - */ - minVerticalRotation?: number; - /** - * @remarks - * Includes entities with the specified name. - * - */ - name?: string; - /** - * @remarks - * Gets/sets a collection of EntityQueryScoreOptions objects - * with filters for specific scoreboard objectives. - * - */ - scoreOptions?: EntityQueryScoreOptions[]; - /** - * @remarks - * Includes entities that match all of the specified tags. - * - */ - tags?: string[]; - /** - * @remarks - * If defined, entities that match this type are included. - * - */ - type?: string; -} - -/** - * Contains additional options for filtering players based on - * their score for an objective. - */ -export interface EntityQueryScoreOptions { - /** - * @remarks - * If set to true, entities and players within this score range - * are excluded from query results. - * - */ - exclude?: boolean; - /** - * @remarks - * If defined, only players that have a score equal to or under - * maxScore are included. - * - */ - maxScore?: number; - /** - * @remarks - * If defined, only players that have a score equal to or over - * minScore are included. - * - */ - minScore?: number; - /** - * @remarks - * Identifier of the scoreboard objective to filter on. - * - */ - objective?: string; -} - -/** - * Contains information for entity raycast hit results. - */ -export interface EntityRaycastHit { - /** - * @remarks - * Distance from ray origin to entity bounds. - * - */ - distance: number; - /** - * @remarks - * Entity that was hit. - * - */ - entity: Entity; -} - -/** - * Contains additional options for an entity raycast operation. - */ -export interface EntityRaycastOptions { - /** - * @remarks - * Maximum distance, in blocks, to process the raycast. - * - */ - maxDistance?: number; -} - -/** - * Additional configuration options for {@link - * World.playMusic}/{@link World.queueMusic} methods. - */ -export interface MusicOptions { - /** - * @remarks - * Specifies a fade overlap for music at the end of play. - * - */ - fade?: number; - /** - * @remarks - * If set to true, this music track will play repeatedly. - * - */ - loop?: boolean; - /** - * @remarks - * Relative volume level of the music. - * - */ - volume?: number; -} - -/** - * Additional options for how a sound plays for a player. - */ -export interface PlayerSoundOptions { - /** - * @remarks - * Location of the sound; if not specified, the sound is played - * near a player. - * - */ - location?: Vector3; - /** - * @remarks - * Optional pitch of the sound. - * - */ - pitch?: number; - /** - * @remarks - * Optional volume of the sound. - * - */ - volume?: number; -} - -/** - * Defines a JSON structure that is used for more flexible. - */ -export interface RawMessage { - /** - * @remarks - * Provides a raw-text equivalent of the current message. - * - */ - rawtext?: RawMessage[]; - /** - * @remarks - * Provides a token that will get replaced with the value of a - * score. - * - */ - score?: RawMessageScore; - /** - * @remarks - * Provides a string literal value to use. - * - */ - text?: string; - /** - * @remarks - * Provides a translation token where, if the client has an - * available resource in the players' language which matches - * the token, will get translated on the client. - * - */ - translate?: string; - /** - * @remarks - * Arguments for the translation token. Can be either an array - * of strings or RawMessage containing an array of raw text - * objects. - * - */ - with?: string[] | RawMessage; -} - -/** - * Provides a description of a score token to use within a raw - * message. - */ -export interface RawMessageScore { - /** - * @remarks - * Name of the score value to match. - * - */ - name?: string; - /** - * @remarks - * Name of the score value to match. - * - */ - objective?: string; -} - -/** - * Represents a fully customizable color within Minecraft. - */ -export interface RGB { - /** - * @remarks - * Determines a color's blue component. Valid values are - * between 0 and 1.0. - * - */ - blue: number; - /** - * @remarks - * Determines a color's green component. Valid values are - * between 0 and 1.0. - * - */ - green: number; - /** - * @remarks - * Determines a color's red component. Valid values are between - * 0 and 1.0. - * - */ - red: number; -} - -/** - * Represents a fully customizable color within Minecraft. - */ -export interface RGBA { - /** - * @remarks - * Determines a color's alpha (opacity) component. Valid values - * are between 0 (transparent) and 1.0 (opaque). - * - */ - alpha: number; - /** - * @remarks - * Determines a color's blue component. Valid values are - * between 0 and 1.0. - * - */ - blue: number; - /** - * @remarks - * Determines a color's green component. Valid values are - * between 0 and 1.0. - * - */ - green: number; - /** - * @remarks - * Determines a color's red component. Valid values are between - * 0 and 1.0. - * - */ - red: number; -} - -/** - * Contains additional options for how a scoreboard should be - * displayed within its display slot. - */ -export interface ScoreboardObjectiveDisplayOptions { - /** - * @remarks - * Objective to be displayed. - * - */ - objective: ScoreboardObjective; - /** - * @remarks - * The sort order to display the objective items within. - * - */ - sortOrder?: ObjectiveSortOrder; -} - -/** - * Contains additional options for registering a script event - * event callback. - */ -export interface ScriptEventMessageFilterOptions { - /** - * @remarks - * Optional list of namespaces to filter inbound script event - * messages. - * - */ - namespaces: string[]; -} - -/** - * Contains additional options for teleporting an entity. - */ -export interface TeleportOptions { - /** - * @remarks - * Whether to check whether blocks will block the entity after - * teleport. - * - */ - checkForBlocks?: boolean; - /** - * @remarks - * Dimension to potentially move the entity to. If not - * specified, the entity is teleported within the dimension - * that they reside. - * - */ - dimension?: Dimension; - /** - * @remarks - * Location that the entity should be facing after teleport. - * - */ - facingLocation?: Vector3; - /** - * @remarks - * Whether to retain the entities velocity after teleport. - * - */ - keepVelocity?: boolean; - /** - * @remarks - * Rotation of the entity after teleport. - * - */ - rotation?: Vector2; -} - -/** - * Contains additional options for displaying a title and - * optional subtitle. - */ -export interface TitleDisplayOptions { - /** - * @remarks - * Fade-in duration for the title and subtitle, in ticks. There - * are 20 ticks per second. Use {@link TicksPerSecond} constant - * to convert between ticks and seconds. - * - */ - fadeInDuration: number; - /** - * @remarks - * Fade-out time for the title and subtitle, in ticks. There - * are 20 ticks per second. Use {@link TicksPerSecond} constant - * to convert between ticks and seconds. - * - */ - fadeOutDuration: number; - /** - * @remarks - * Amount of time for the title and subtitle to stay in place, - * in ticks. There are 20 ticks per second. Use {@link - * TicksPerSecond} constant to convert between ticks and - * seconds. - * - */ - stayDuration: number; - /** - * @remarks - * Optional subtitle text. - * - */ - subtitle?: (RawMessage | string)[] | RawMessage | string; -} - -/** - * Represents a two-directional vector. - */ -export interface Vector2 { - /** - * @remarks - * X component of the two-dimensional vector. - * - */ - x: number; - /** - * @remarks - * Y component of the two-dimensional vector. - * - */ - y: number; -} - -/** - * Contains a description of a vector. - */ -export interface Vector3 { - /** - * @remarks - * X component of this vector. - * - */ - x: number; - /** - * @remarks - * Y component of this vector. - * - */ - y: number; - /** - * @remarks - * Z component of this vector. - * - */ - z: number; -} - -/** - * Contains additional options for a world-level playSound - * occurrence. - */ -export interface WorldSoundOptions { - /** - * @remarks - * Pitch of the sound played at the world level. - * - */ - pitch?: number; - /** - * @remarks - * Relative volume and space by which this sound is heard. - * - */ - volume?: number; -} - -// @ts-ignore Class inheritance allowed for native defined classes -export class CommandError extends Error { - private constructor(); -} - -// @ts-ignore Class inheritance allowed for native defined classes -export class LocationInUnloadedChunkError extends Error { - private constructor(); -} - -// @ts-ignore Class inheritance allowed for native defined classes -export class LocationOutOfWorldBoundariesError extends Error { - private constructor(); -} - -/** - * @remarks - * A class that provides system-level events and functions. - * - */ -export const system: System; -/** - * @remarks - * A class that wraps the state of a world - a set of - * dimensions and the environment of Minecraft. - * - */ -export const world: World; diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/package.json b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/package.json deleted file mode 100644 index 30d28b2..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "@minecraft/server", - "version": "1.5.0", - "description": "", - "contributors": [ - { - "name": "Jake Shirley", - "email": "jake@xbox.com" - }, - { - "name": "Mike Ammerlaan", - "email": "mikeam@microsoft.com" - } - ], - "license": "MIT" -} \ No newline at end of file diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/tests.ts b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/tests.ts deleted file mode 100644 index 08757c6..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/tests.ts +++ /dev/null @@ -1,292 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unused-vars */ -import * as mc from '@minecraft/server'; - -export function createExplosion(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) { - const overworld = mc.world.getDimension('overworld'); - - log('Creating an explosion of radius 10.'); - overworld.createExplosion(targetLocation, 10); -} - -export function createNoBlockExplosion(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) { - const overworld = mc.world.getDimension('overworld'); - - const explodeNoBlocksLoc = { - x: Math.floor(targetLocation.x + 1), - y: Math.floor(targetLocation.y + 2), - z: Math.floor(targetLocation.z + 1), - }; - - log('Creating an explosion of radius 15 that does not break blocks.'); - overworld.createExplosion(explodeNoBlocksLoc, 15, { breaksBlocks: false }); -} - -export function createFireAndWaterExplosions( - log: (message: string, status?: number) => void, - targetLocation: mc.Vector3, -) { - const overworld = mc.world.getDimension('overworld'); - - const explosionLoc: mc.Vector3 = { - x: targetLocation.x + 0.5, - y: targetLocation.y + 0.5, - z: targetLocation.z + 0.5, - }; - - log('Creating an explosion of radius 15 that causes fire.'); - overworld.createExplosion(explosionLoc, 15, { causesFire: true }); - - const belowWaterLoc: mc.Vector3 = { x: targetLocation.x + 3, y: targetLocation.y + 1, z: targetLocation.z + 3 }; - - log('Creating an explosion of radius 10 that can go underwater.'); - overworld.createExplosion(belowWaterLoc, 10, { allowUnderwater: true }); -} - -export function itemStacks(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) { - const overworld = mc.world.getDimension('overworld'); - - const oneItemLoc: mc.Vector3 = { x: targetLocation.x + targetLocation.y + 3, y: 2, z: targetLocation.z + 1 }; - const fiveItemsLoc: mc.Vector3 = { x: targetLocation.x + 1, y: targetLocation.y + 2, z: targetLocation.z + 1 }; - const diamondPickaxeLoc: mc.Vector3 = { x: targetLocation.x + 2, y: targetLocation.y + 2, z: targetLocation.z + 4 }; - - const oneEmerald = new mc.ItemStack(mc.MinecraftItemTypes.emerald, 1, 0); - const onePickaxe = new mc.ItemStack(mc.MinecraftItemTypes.diamondPickaxe, 1, 0); - const fiveEmeralds = new mc.ItemStack(mc.MinecraftItemTypes.emerald, 5, 0); - - log(`Spawning an emerald at (${oneItemLoc.x}, ${oneItemLoc.y}, ${oneItemLoc.z})`); - overworld.spawnItem(oneEmerald, oneItemLoc); - - log(`Spawning five emeralds at (${fiveItemsLoc.x}, ${fiveItemsLoc.y}, ${fiveItemsLoc.z})`); - overworld.spawnItem(fiveEmeralds, fiveItemsLoc); - - log(`Spawning a diamond pickaxe at (${diamondPickaxeLoc.x}, ${diamondPickaxeLoc.y}, ${diamondPickaxeLoc.z})`); - overworld.spawnItem(onePickaxe, diamondPickaxeLoc); -} - -export function quickFoxLazyDog(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) { - const overworld = mc.world.getDimension('overworld'); - - const fox = overworld.spawnEntity('minecraft:fox', { - x: targetLocation.x + 1, - y: targetLocation.y + 2, - z: targetLocation.z + 3, - }); - fox.addEffect(mc.MinecraftEffectTypes.speed, 10, 20); - log('Created a fox.'); - - const wolf = overworld.spawnEntity('minecraft:wolf', { - x: targetLocation.x + 4, - y: targetLocation.y + 2, - z: targetLocation.z + 3, - }); - wolf.addEffect(mc.MinecraftEffectTypes.slowness, 10, 20); - wolf.isSneaking = true; - log('Created a sneaking wolf.', 1); -} - -export function runEntityCreatedEvent(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) { - // register a new function that is called when a new entity is created. - mc.world.events.entityCreate.subscribe((entityEvent: mc.EntityCreateEvent) => { - if (entityEvent && entityEvent.entity) { - log(`New entity of type '${entityEvent.entity}' created!`, 1); - } else { - log(`The entity event didn't work as expected.`, -1); - } - }); -} - -export function createOldHorse(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) { - const overworld = mc.world.getDimension('overworld'); - - log("Create a horse and triggering the 'ageable_grow_up' event, ensuring the horse is created as an adult"); - overworld.spawnEntity('minecraft:horse', targetLocation); -} - -export function pistonEvent(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) { - const pistonLoc: mc.Vector3 = { - x: Math.floor(targetLocation.x) + 1, - y: Math.floor(targetLocation.y) + 2, - z: Math.floor(targetLocation.z) + 1, - }; - - mc.world.events.beforePistonActivate.subscribe((pistonEvent: mc.BeforePistonActivateEvent) => { - if (pistonEvent.piston.location.equals(pistonLoc)) { - log('Cancelling piston event'); - pistonEvent.cancel = true; - } - }); -} - -export function spawnItem(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) { - const featherItem = new mc.ItemStack(mc.MinecraftItemTypes.feather, 1, 0); - - overworld.spawnItem(featherItem, targetLocation); - log(`New feather created at ${targetLocation.x}, ${targetLocation.y}, ${targetLocation.z}!`); -} - -export function testThatEntityIsFeatherItem( - log: (message: string, status?: number) => void, - targetLocation: mc.Vector3, -) { - const overworld = mc.world.getDimension('overworld'); - - const items = overworld.getEntities({ - location: targetLocation, - maxDistance: 20, - }); - - for (const item of items) { - const itemComp = item.getComponent('item') as any; - - if (itemComp) { - if (itemComp.itemStack.id.endsWith('feather')) { - log('Success! Found a feather', 1); - } - } - } -} - -export function trapTick() { - const overworld = mc.world.getDimension('overworld'); - - try { - // Minecraft runs at 20 ticks per second - if (ticks % 1200 === 0) { - overworld.runCommandAsync('say Another minute passes...'); - } - - ticks++; - } catch (e) { - console.warn('Error: ' + e); - } - - mc.system.run(trapTick); -} - -export default class SampleManager { - tickCount = 0; - - _availableFuncs: { - [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>; - }; - - pendingFuncs: Array<{ - name: string; - func: (log: (message: string, status?: number) => void, location: mc.Vector3) => void; - location: mc.Vector3; - }> = []; - - gameplayLogger(message: string, status?: number) { - if (status !== undefined && status > 0) { - message = 'SUCCESS: ' + message; - } else if (status !== undefined && status < 0) { - message = 'FAIL: ' + message; - } - - this.say(message); - } - say(message: string) { - mc.world.getDimension('overworld').runCommand('say ' + message); - } - - newChatMessage(chatEvent: mc.ChatEvent) { - const message = chatEvent.message.toLowerCase(); - - if (message.startsWith('howto') && chatEvent.sender) { - const nearbyBlock = chatEvent.sender.getBlockFromViewVector(); - if (!nearbyBlock) { - this.gameplayLogger('Please look at the block where you want me to run this.'); - return; - } - - const nearbyBlockLoc = nearbyBlock.location; - const nearbyLoc: mc.Vector3 = { x: nearbyBlockLoc.x, y: nearbyBlockLoc.y + 1, z: nearbyBlockLoc.z }; - - const sampleId = message.substring(5).trim(); - - if (sampleId.length < 2) { - let availableFuncStr = 'Here is my list of available samples:'; - - for (const sampleFuncKey in this._availableFuncs) { - availableFuncStr += ' ' + sampleFuncKey; - } - - this.say(availableFuncStr); - } else { - for (const sampleFuncKey in this._availableFuncs) { - if (sampleFuncKey.toLowerCase() === sampleId) { - const sampleFunc = this._availableFuncs[sampleFuncKey]; - - this.runSample(sampleFuncKey + this.tickCount, sampleFunc, nearbyLoc); - - return; - } - } - - this.say(`I couldn't find the sample '${sampleId}"'`); - } - } - } - - runSample( - sampleId: string, - snippetFunctions: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>, - targetLocation: mc.Vector3, - ) { - for (let i = snippetFunctions.length - 1; i >= 0; i--) { - this.pendingFuncs.push({ name: sampleId, func: snippetFunctions[i], location: targetLocation }); - } - } - - worldTick() { - if (this.tickCount % 10 === 0) { - if (this.pendingFuncs.length > 0) { - const funcSet = this.pendingFuncs.pop(); - - if (funcSet) { - funcSet.func(this.gameplayLogger, funcSet.location); - } - } - } - - this.tickCount++; - } - - constructor() { - this._availableFuncs = {}; - - this.gameplayLogger = this.gameplayLogger.bind(this); - - mc.world.events.tick.subscribe(this.worldTick.bind(this)); - mc.world.events.chat.subscribe(this.newChatMessage.bind(this)); - } - - registerSamples(sampleSet: { - [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>; - }) { - for (const sampleKey in sampleSet) { - if (sampleKey.length > 1 && sampleSet[sampleKey]) { - this._availableFuncs[sampleKey] = sampleSet[sampleKey]; - } - } - } -} - -const mojangMinecraftFuncs: { - [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>; -} = { - runEntityCreatedEvent: [runEntityCreatedEvent, createOldHorse], - createOldHorse: [createOldHorse], - spawnItem: [spawnItem, testThatEntityIsFeatherItem], - createNoBlockExplosion: [createExplosion], - createFireAndWaterExplosions: [createFireAndWaterExplosions], - createExplosion: [createExplosion], - itemStacks: [itemStacks], - quickFoxLazyDog: [quickFoxLazyDog], - pistonEvent: [pistonEvent], - trapTick: [trapTick], -}; - -export function register(sampleManager: SampleManager) { - sampleManager.registerSamples(mojangMinecraftFuncs); -} diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/tsconfig.json b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/tsconfig.json deleted file mode 100644 index 2f66b0c..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/node_modules/@minecraft/server/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": ["es6"], - "target": "es6", - "forceConsistentCasingInFileNames": true, - "noEmit": true, - "noImplicitAny": true, - "noImplicitThis": true, - "strictFunctionTypes": true, - "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": ["../"], - "types": [] - }, - "files": [ - "index.d.ts", - "tests.ts" - ] -} \ No newline at end of file diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/package.json b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/package.json deleted file mode 100644 index e9b5476..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "@minecraft/server-ui", - "version": "1.2.0-beta.1.20.10-stable", - "description": "", - "contributors": [ - { - "name": "Jake Shirley", - "email": "jake@xbox.com" - }, - { - "name": "Mike Ammerlaan", - "email": "mikeam@microsoft.com" - } - ], - "dependencies": { - "@minecraft/server": "^1.4.0-beta.1.20.10-stable" - }, - "license": "MIT" -} \ No newline at end of file diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/tests.ts b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/tests.ts deleted file mode 100644 index 79e5a62..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/tests.ts +++ /dev/null @@ -1,172 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unused-vars */ -import * as mc from '@minecraft/server'; - -export async function showActionForm(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) { - const players = mc.world.getPlayers(); - - const playerList = Array.from(players); - - if (playerList.length >= 1) { - const form = new mcui.ActionFormData() - .title('Test Title') - .body('Body text here!') - .button('btn 1') - .button('btn 2') - .button('btn 3') - .button('btn 4') - .button('btn 5'); - - const result = await form.show(playerList[0]); - - if (result.canceled) { - log('Player exited out of the dialog.'); - } else { - log('Your result was: ' + result.selection); - } - } -} - -export function showFavoriteMonth(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) { - const players = mc.world.getPlayers(); - - const playerList = Array.from(players); - - if (playerList.length >= 1) { - const form = new mcui.ActionFormData() - .title('Months') - .body('Choose your favorite month!') - .button('January') - .button('February') - .button('March') - .button('April') - .button('May'); - - form.show(playerList[0]).then((response: mcui.ActionFormResponse) => { - if (response.selection === 3) { - log('I like April too!'); - } - }); - } -} - -export default class SampleManager { - tickCount = 0; - - _availableFuncs: { - [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>; - }; - - pendingFuncs: Array<{ - name: string; - func: (log: (message: string, status?: number) => void, location: mc.Vector3) => void; - location: mc.Vector3; - }> = []; - - gameplayLogger(message: string, status?: number) { - if (status !== undefined && status > 0) { - message = 'SUCCESS: ' + message; - } else if (status !== undefined && status < 0) { - message = 'FAIL: ' + message; - } - - this.say(message); - } - say(message: string) { - mc.world.getDimension('overworld').runCommand('say ' + message); - } - - newChatMessage(chatEvent: mc.ChatEvent) { - const message = chatEvent.message.toLowerCase(); - - if (message.startsWith('howto') && chatEvent.sender) { - const nearbyBlock = chatEvent.sender.getBlockFromViewVector(); - if (!nearbyBlock) { - this.gameplayLogger('Please look at the block where you want me to run this.'); - return; - } - - const nearbyBlockLoc = nearbyBlock.location; - const nearbyLoc = { x: nearbyBlockLoc.x, y: nearbyBlockLoc.y + 1, z: nearbyBlockLoc.z }; - - const sampleId = message.substring(5).trim(); - - if (sampleId.length < 2) { - let availableFuncStr = 'Here is my list of available samples:'; - - for (const sampleFuncKey in this._availableFuncs) { - availableFuncStr += ' ' + sampleFuncKey; - } - - this.say(availableFuncStr); - } else { - for (const sampleFuncKey in this._availableFuncs) { - if (sampleFuncKey.toLowerCase() === sampleId) { - const sampleFunc = this._availableFuncs[sampleFuncKey]; - - this.runSample(sampleFuncKey + this.tickCount, sampleFunc, nearbyLoc); - - return; - } - } - - this.say(`I couldn't find the sample '${sampleId}"'`); - } - } - } - - runSample( - sampleId: string, - snippetFunctions: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>, - targetLocation: mc.Vector3, - ) { - for (let i = snippetFunctions.length - 1; i >= 0; i--) { - this.pendingFuncs.push({ name: sampleId, func: snippetFunctions[i], location: targetLocation }); - } - } - - worldTick() { - if (this.tickCount % 10 === 0) { - if (this.pendingFuncs.length > 0) { - const funcSet = this.pendingFuncs.pop(); - - if (funcSet) { - funcSet.func(this.gameplayLogger, funcSet.location); - } - } - } - - this.tickCount++; - } - - constructor() { - this._availableFuncs = {}; - - this.gameplayLogger = this.gameplayLogger.bind(this); - - mc.world.events.tick.subscribe(this.worldTick.bind(this)); - mc.world.events.chat.subscribe(this.newChatMessage.bind(this)); - } - - registerSamples(sampleSet: { - [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>; - }) { - for (const sampleKey in sampleSet) { - if (sampleKey.length > 1 && sampleSet[sampleKey]) { - this._availableFuncs[sampleKey] = sampleSet[sampleKey]; - } - } - } -} - -import * as mcui from '@minecraft/server-ui'; // keep in for ui samples - -const mojangMinecraftUIFuncs: { - [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>; -} = { - showActionForm: [showActionForm], - showFavoriteMonth: [showFavoriteMonth], -}; - -export function register(sampleManager: SampleManager) { - sampleManager.registerSamples(mojangMinecraftUIFuncs); -} diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/tsconfig.json b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/tsconfig.json deleted file mode 100644 index 2f66b0c..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server-ui/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": ["es6"], - "target": "es6", - "forceConsistentCasingInFileNames": true, - "noEmit": true, - "noImplicitAny": true, - "noImplicitThis": true, - "strictFunctionTypes": true, - "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": ["../"], - "types": [] - }, - "files": [ - "index.d.ts", - "tests.ts" - ] -} \ No newline at end of file diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/.eslintrc.json b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/.eslintrc.json deleted file mode 100644 index 746934f..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/.eslintrc.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "env": { - "browser": true, - "es2021": true - }, - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended" - ], - "overrides": [ - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module" - }, - "plugins": [ - "@typescript-eslint" - ], - "rules": { - "@typescript-eslint/no-explicit-any": "off" - } -} diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/README.md b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/README.md deleted file mode 100644 index 0b4dcd1..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# `@minecraft/server` - -Contains many types related to manipulating a Minecraft world, including entities, blocks, dimensions, and more. - -## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.** - -See full documentation for this module here: - -https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/@minecraft/server/@minecraft/server \ No newline at end of file diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/index.d.ts b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/index.d.ts deleted file mode 100644 index 297eb53..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/index.d.ts +++ /dev/null @@ -1,12953 +0,0 @@ -// Type definitions for Minecraft Bedrock Edition script APIs -// Project: https://docs.microsoft.com/minecraft/creator/ -// Definitions by: Jake Shirley -// Mike Ammerlaan - -/* ***************************************************************************** - Copyright (c) Microsoft Corporation. - ***************************************************************************** */ -/** - * @beta - * @packageDocumentation - * Contains many types related to manipulating a Minecraft - * world, including entities, blocks, dimensions, and more. - * - * Manifest Details - * ```json - * { - * "module_name": "@minecraft/server", - * "version": "1.6.0-internal.1.20.30-preview.25" - * } - * ``` - * - */ -/** - * @beta - * Description of the resulting intersection test on two - * BlockVolume objects - */ -export enum BlockVolumeIntersection { - /** - * @beta - * @remarks - * Volume B has no intersection points with Volume A - * - */ - Disjoint = 0, - /** - * @beta - * @remarks - * Volume B resides completely inside Volume A - * - */ - Contains = 1, - /** - * @beta - * @remarks - * Volume B partially intersects Volume A - * - */ - Intersects = 2, -} - -/** - * @beta - * The Action enum determines how the CompoundBlockVolume - * considers the associated CompoundBlockVolumeItem when - * performing inside/outside calculations. - */ -export enum CompoundBlockVolumeAction { - /** - * @beta - * @remarks - * The associated BlockVolume is considered a positive space, - * and any intersection tests are considered hits - * - */ - Add = 0, - /** - * @beta - * @remarks - * The associated BlockVolume is considered a negative or void - * space, and any intersection tests are considered misses. - * Using the Subtract action, it is possible to `punch holes` - * in block volumes so that any intersection tests may pass - * through such spaces - * - */ - Subtract = 1, -} - -/** - * @beta - * An enum describing the relativity of the - * CompoundBlockVolumeItem, relative to the parent - * CompoundVolume. - */ -export enum CompoundBlockVolumePositionRelativity { - /** - * @beta - * @remarks - * The locations within the associated BlockVolume are relative - * to the CompoundBlockVolume to which they were added - * - */ - Relative = 0, - /** - * @beta - * @remarks - * The locations within the associated BlockVolume are in - * absolute world space - * - */ - Absolute = 1, -} - -/** - * @beta - * A general purpose relative direction enumeration. - */ -export enum Direction { - /** - * @beta - * @remarks - * Returns the block beneath (y - 1) of this item. - * - */ - Down = 'Down', - /** - * @beta - * @remarks - * Returns the block to the east (x + 1) of this item. - * - */ - East = 'East', - /** - * @beta - * @remarks - * Returns the block to the east (z + 1) of this item. - * - */ - North = 'North', - /** - * @beta - * @remarks - * Returns the block to the south (z - 1) of this item. - * - */ - South = 'South', - /** - * @beta - * @remarks - * Returns the block above (y + 1) of this item. - * - */ - Up = 'Up', - /** - * @beta - * @remarks - * Returns the block to the west (x - 1) of this item. - * - */ - West = 'West', -} - -/** - * @beta - */ -export enum DisplaySlotId { - BelowName = 'BelowName', - List = 'List', - Sidebar = 'Sidebar', -} - -/** - * @beta - */ -export enum DyeColor { - Black = 'Black', - Blue = 'Blue', - Brown = 'Brown', - Cyan = 'Cyan', - Gray = 'Gray', - Green = 'Green', - LightBlue = 'LightBlue', - Lime = 'Lime', - Magenta = 'Magenta', - Orange = 'Orange', - Pink = 'Pink', - Purple = 'Purple', - Red = 'Red', - Silver = 'Silver', - White = 'White', - Yellow = 'Yellow', -} - -/** - * @beta - */ -export enum EasingType { - InBack = 'InBack', - InBounce = 'InBounce', - InCirc = 'InCirc', - InCubic = 'InCubic', - InElastic = 'InElastic', - InExpo = 'InExpo', - InOutBack = 'InOutBack', - InOutBounce = 'InOutBounce', - InOutCirc = 'InOutCirc', - InOutCubic = 'InOutCubic', - InOutElastic = 'InOutElastic', - InOutExpo = 'InOutExpo', - InOutQuad = 'InOutQuad', - InOutQuart = 'InOutQuart', - InOutQuint = 'InOutQuint', - InOutSine = 'InOutSine', - InQuad = 'InQuad', - InQuart = 'InQuart', - InQuint = 'InQuint', - InSine = 'InSine', - Linear = 'Linear', - OutBack = 'OutBack', - OutBounce = 'OutBounce', - OutCirc = 'OutCirc', - OutCubic = 'OutCubic', - OutElastic = 'OutElastic', - OutExpo = 'OutExpo', - OutQuad = 'OutQuad', - OutQuart = 'OutQuart', - OutQuint = 'OutQuint', - OutSine = 'OutSine', - Spring = 'Spring', -} - -/** - * @beta - */ -export enum EntityDamageCause { - anvil = 'anvil', - blockExplosion = 'blockExplosion', - charging = 'charging', - contact = 'contact', - drowning = 'drowning', - entityAttack = 'entityAttack', - entityExplosion = 'entityExplosion', - fall = 'fall', - fallingBlock = 'fallingBlock', - fire = 'fire', - fireTick = 'fireTick', - fireworks = 'fireworks', - flyIntoWall = 'flyIntoWall', - freezing = 'freezing', - lava = 'lava', - lightning = 'lightning', - magic = 'magic', - magma = 'magma', - none = 'none', - override = 'override', - piston = 'piston', - projectile = 'projectile', - stalactite = 'stalactite', - stalagmite = 'stalagmite', - starve = 'starve', - suffocation = 'suffocation', - suicide = 'suicide', - temperature = 'temperature', - thorns = 'thorns', - 'void' = 'void', - wither = 'wither', -} - -/** - * @beta - * An enumeration describing initialization cause of an entity. - */ -export enum EntityInitializationCause { - /** - * @beta - * @remarks - * Case when an entity is created as child of other entity or - * entities, e.g., cows making a cow or slimes making smaller - * slimes after dying. - * - */ - Born = 'Born', - /** - * @beta - * @remarks - * Case when an entity is created by an event, e.g., Wandering - * trader spawning llamas. - * - */ - Event = 'Event', - Loaded = 'Loaded', - /** - * @beta - * @remarks - * Case when an entity is naturally spawned in the world. - * - */ - Spawned = 'Spawned', - /** - * @beta - * @remarks - * Case when an entity is transformed into another entity. - * - */ - Transformed = 'Transformed', -} - -/** - * @beta - * Describes the lifetime state of an Entity. For example, - * Entities can be loaded or unloaded depending on whether - * their chunks are loaded or when they move across dimensions. - */ -export enum EntityLifetimeState { - /** - * @beta - * @remarks - * Corresponding object is loaded. - * - */ - Loaded = 'Loaded', - /** - * @beta - * @remarks - * Corresponding object is now unloaded. Unloaded entities - * cannot be manipulated. However, if an unloaded Entity later - * reloads, it becomes valid and can once again be manipulated. - * - */ - Unloaded = 'Unloaded', -} - -/** - * @beta - * The equipment slot of the mob. This includes armor, offhand - * and mainhand slots. - */ -export enum EquipmentSlot { - /** - * @beta - * @remarks - * The chest slot. This slot is used to hold items such as - * Chestplate or Elytra. - * - */ - Chest = 'Chest', - /** - * @beta - * @remarks - * The feet slot. This slot is used to hold items such as - * Boots. - * - */ - Feet = 'Feet', - /** - * @beta - * @remarks - * The head slot. This slot is used to hold items such as - * Helmets or Carved Pumpkins. - * - */ - Head = 'Head', - /** - * @beta - * @remarks - * The legs slot. This slot is used to hold items such as - * Leggings. - * - */ - Legs = 'Legs', - /** - * @beta - * @remarks - * The mainhand slot. For players, the mainhand slot refers to - * the currently active hotbar slot. - * - */ - Mainhand = 'Mainhand', - /** - * @beta - * @remarks - * The offhand slot. This slot is used to hold items such as - * shields and maps. - * - */ - Offhand = 'Offhand', -} - -/** - * @beta - * Represents the type of fluid for use within a fluid - * containing block, like a cauldron. - */ -export enum FluidType { - /** - * @beta - * @remarks - * Represents lava as a type of fluid. - * - */ - Lava = 'Lava', - /** - * @beta - * @remarks - * Represents a potion as a type of fluid. - * - */ - Potion = 'Potion', - /** - * @beta - * @remarks - * Represents powder snow as a type of fluid. - * - */ - PowderSnow = 'PowderSnow', - /** - * @beta - * @remarks - * Represents water as a type of fluida. - * - */ - Water = 'Water', -} - -/** - * @beta - * Represents a game mode for the current world experience. - */ -export enum GameMode { - /** - * @beta - * @remarks - * World is in a more locked-down experience, where blocks may - * not be manipulated. - * - */ - adventure = 'adventure', - /** - * @beta - * @remarks - * World is in a full creative mode. In creative mode, the - * player has all the resources available in the item selection - * tabs and the survival selection tab. They can also destroy - * blocks instantly including those which would normally be - * indestructible. Command and structure blocks can also be - * used in creative mode. Items also do not lose durability or - * disappear. - * - */ - creative = 'creative', - /** - * @beta - * @remarks - * World is in spectator mode. In spectator mode, spectators - * are always flying and cannot become grounded. Spectators can - * pass through solid blocks and entities without any - * collisions, and cannot use items or interact with blocks or - * mobs. Spectators cannot be seen by mobs or other players, - * except for other spectators; spectators appear as a - * transparent floating head. - * - */ - spectator = 'spectator', - /** - * @beta - * @remarks - * World is in a survival mode, where players can take damage - * and entities may not be peaceful. Survival mode is where the - * player must collect resources, build structures while - * surviving in their generated world. Activities can, over - * time, chip away at player health and hunger bar. - * - */ - survival = 'survival', -} - -/** - * @beta - * Describes how an an item can be moved within a container. - */ -export enum ItemLockMode { - /** - * @beta - * @remarks - * The item cannot be dropped or crafted with. - * - */ - inventory = 'inventory', - /** - * @beta - * @remarks - * The item has no container restrictions. - * - */ - none = 'none', - /** - * @beta - * @remarks - * The item cannot be moved from its slot, dropped or crafted - * with. - * - */ - slot = 'slot', -} - -/** - * @beta - * Enum containing the different phases of the moon based on - * the current day. - * Obtain the current MoonPhase using world.getMoonPhase - */ -export enum MoonPhase { - FullMoon = 0, - WaningGibbous = 1, - FirstQuarter = 2, - WaningCrescent = 3, - NewMoon = 4, - WaxingCrescent = 5, - LastQuarter = 6, - WaxingGibbous = 7, -} - -/** - * @beta - * Used for specifying a sort order for how to display an - * objective and its list of participants. - */ -export enum ObjectiveSortOrder { - /** - * @beta - * @remarks - * Objective participant list is displayed in ascending (e.g., - * A-Z) order. - * - */ - Ascending = 0, - /** - * @beta - * @remarks - * Objective participant list is displayed in descending (e.g., - * Z-A) order. - * - */ - Descending = 1, -} - -/** - * @beta - * Contains objectives and participants for the scoreboard. - */ -export enum ScoreboardIdentityType { - /** - * @beta - * @remarks - * This scoreboard participant is tied to an entity. - * - */ - Entity = 'Entity', - /** - * @beta - * @remarks - * This scoreboard participant is tied to a pseudo player - * entity - typically this is used to store scores as data or - * as abstract progress. - * - */ - FakePlayer = 'FakePlayer', - /** - * @beta - * @remarks - * This scoreboard participant is tied to a player. - * - */ - Player = 'Player', -} - -/** - * @beta - * Describes where the script event originated from. - */ -export enum ScriptEventSource { - /** - * @beta - * @remarks - * The script event originated from a Block such as a Command - * Block. - * - */ - Block = 'Block', - /** - * @beta - * @remarks - * The script event originated from an Entity such as a Player, - * Command Block Minecart or Animation Controller. - * - */ - Entity = 'Entity', - /** - * @beta - * @remarks - * The script event originated from an NPC dialogue. - * - */ - NPCDialogue = 'NPCDialogue', - /** - * @beta - * @remarks - * The script event originated from the server, such as from a - * runCommand API call or a dedicated server console. - * - */ - Server = 'Server', -} - -/** - * @beta - * Represents a side of a sign. - */ -export enum SignSide { - /** - * @beta - * @remarks - * The back of the sign. - * - */ - Back = 'Back', - /** - * @beta - * @remarks - * The front of the sign. - * - */ - Front = 'Front', -} - -/** - * @beta - * Provides numeric values for common periods in the Minecraft - * day. - */ -export enum TimeOfDay { - Day = 1000, - Noon = 6000, - Sunset = 12000, - Night = 13000, - Midnight = 18000, - Sunrise = 23000, -} - -/** - * @beta - * An enumeration with the reason that a watchdog is deciding - * to terminate execution of a behavior packs' script. - */ -export enum WatchdogTerminateReason { - /** - * @beta - * @remarks - * Script runtime for a behavior pack is terminated due to - * non-responsiveness from script (a hang or infinite loop). - * - */ - Hang = 'Hang', - /** - * @beta - * @remarks - * Script runtime for a behavior pack is terminated due to a - * stack overflow (a long, and potentially infinite) chain of - * function calls. - * - */ - StackOverflow = 'StackOverflow', -} - -/** - * @beta - */ -export enum WeatherType { - Clear = 'Clear', - Rain = 'Rain', - Thunder = 'Thunder', -} - -/** - * @beta - * Represents a block in a dimension. A block represents a - * unique X, Y, and Z within a dimension and get/sets the state - * of the block at that location. This type was significantly - * updated in version 1.17.10.21. - */ -export class Block { - private constructor(); - /** - * @remarks - * Returns the dimension that the block is within. - * - */ - readonly dimension: Dimension; - /** - * @beta - * @remarks - * Returns true if this block is an air block (i.e., empty - * space). - * - * @throws This property can throw when used. - */ - readonly isAir: boolean; - /** - * @beta - * @remarks - * Returns true if this block is a liquid block - (e.g., a - * water block and a lava black are liquid, while an air block - * and a stone block are not. Water logged blocks are not - * liquid blocks). - * - * @throws This property can throw when used. - */ - readonly isLiquid: boolean; - /** - * @beta - * @remarks - * Returns true if this block is solid and impassible - (e.g., - * a cobblestone block and a diamond block are solid, while a - * ladder block and a fence block are not). - * - * @throws This property can throw when used. - */ - readonly isSolid: boolean; - /** - * @beta - * @remarks - * Returns or sets whether this block has a liquid on it. - * - * This property can't be edited in read-only mode. - * - */ - isWaterlogged: boolean; - /** - * @remarks - * Coordinates of the specified block. - * - * @throws This property can throw when used. - */ - readonly location: Vector3; - /** - * @remarks - * Additional block configuration data that describes the - * block. - * - * @throws This property can throw when used. - */ - readonly permutation: BlockPermutation; - /** - * @beta - * @remarks - * Gets the type of block. - * - * @throws This property can throw when used. - */ - readonly 'type': BlockType; - /** - * @beta - * @remarks - * Identifier of the type of block for this block. - * - * @throws This property can throw when used. - */ - readonly typeId: string; - /** - * @remarks - * X coordinate of the block. - * - */ - readonly x: number; - /** - * @remarks - * Y coordinate of the block. - * - */ - readonly y: number; - /** - * @remarks - * Z coordinate of the block. - * - */ - readonly z: number; - /** - * @beta - * @remarks - * Checks to see whether it is valid to place the specified - * block type or block permutation, on a specified face on this - * block - * - * @param blockToPlace - * Block type or block permutation to check placement for. - * @param faceToPlaceOn - * Optional specific face of this block to check placement - * against. - * @returns - * Returns `true` if the block type or permutation can be - * placed on this block, else `false`. - * @throws This function can throw errors. - */ - canPlace(blockToPlace: BlockPermutation | BlockType | string, faceToPlaceOn?: Direction): boolean; - /** - * @beta - * @remarks - * Gets additional configuration properties (a component) for - * specific capabilities of particular blocks - for example, an - * inventory component of a chest block. - * - * @param componentName - * Identifier of the component. If a namespace is not - * specified, minecraft: is assumed. - * @returns - * Returns the component object if it is present on the - * particular block. - * @throws This function can throw errors. - */ - getComponent(componentName: string): BlockComponent | undefined; - /** - * @beta - * @remarks - * Creates a prototype item stack based on this block that can - * be used with Container/ContainerSlot APIs. - * - * @param amount - * Number of instances of this block to place in the item - * stack. - * @param withData - * Whether additional data facets of the item stack are - * included. - * @throws This function can throw errors. - */ - getItemStack(amount?: number, withData?: boolean): ItemStack; - /** - * @beta - * @remarks - * Returns the net redstone power of this block. - * - * @returns - * Returns undefined if redstone power is not applicable to - * this block. - * @throws This function can throw errors. - */ - getRedstonePower(): number | undefined; - /** - * @beta - * @remarks - * Returns a set of tags for a block. - * - * @returns - * The list of tags that the block has. - * @throws This function can throw errors. - */ - getTags(): string[]; - /** - * @beta - * @remarks - * Checks to see if the permutation of this block has a - * specific tag. - * - * @param tag - * Tag to check for. - * @returns - * Returns `true` if the permutation of this block has the tag, - * else `false`. - * @throws This function can throw errors. - * @example check_block_tags.js - * ```typescript - * import { world } from "@minecraft/server"; - * - * // Fetch the block - * const block = world.getDimension("overworld").getBlock({ x: 1, y: 2, z: 3 }); - * - * console.log(`Block is dirt: ${block.hasTag("dirt")}`); - * console.log(`Block is wood: ${block.hasTag("wood")}`); - * console.log(`Block is stone: ${block.hasTag("stone")}`); - * ``` - */ - hasTag(tag: string): boolean; - /** - * @beta - * @remarks - * Returns true if this reference to a block is still valid - * (for example, if the block is unloaded, references to that - * block will no longer be valid.) - * - * @returns - * True if this block object is still working and valid. - */ - isValid(): boolean; - /** - * @remarks - * Sets the block in the dimension to the state of the - * permutation. - * - * This function can't be called in read-only mode. - * - * @param permutation - * Permutation that contains a set of property states for the - * Block. - * @throws This function can throw errors. - */ - setPermutation(permutation: BlockPermutation): void; - /** - * @beta - * @remarks - * Sets the type of block. - * - * This function can't be called in read-only mode. - * - * @param blockType - * Identifier of the type of block to apply - for example, - * minecraft:powered_repeater. - * @throws This function can throw errors. - */ - setType(blockType: BlockType | string): void; - /** - * @beta - * @remarks - * Tries to set the block in the dimension to the state of the - * permutation by first checking if the placement is valid. - * - * This function can't be called in read-only mode. - * - * @param permutation - * Permutation that contains a set of property states for the - * Block. - * @returns - * Returns `true` if the block permutation data was - * successfully set, else `false`. - * @throws This function can throw errors. - */ - trySetPermutation(permutation: BlockPermutation): boolean; -} - -/** - * @beta - * Holds information for expressing the net size of a volume of - * blocks. - */ -export class BlockAreaSize { - /** - * @remarks - * X size (west to east) component of this block area. - * - */ - x: number; - /** - * @remarks - * Y size (down to up) of this block area size. - * - */ - y: number; - /** - * @remarks - * Z size (south to north) of this block area size. - * - */ - z: number; - /** - * @remarks - * Creates a new BlockAreaSize object. - * - */ - constructor(x: number, y: number, z: number); - /** - * @remarks - * Tests whether this block area size is equal to another - * BlockAreaSize object. - * - */ - equals(other: BlockAreaSize): boolean; -} - -/** - * @beta - * Base type for components associated with blocks. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class BlockComponent extends Component { - private constructor(); - /** - * @beta - * @remarks - * Block instance that this component pertains to. - * - */ - readonly block: Block; -} - -/** - * @beta - * Contains information regarding an event that impacts a - * specific block. - */ -export class BlockEvent { - private constructor(); - /** - * @remarks - * Block impacted by this event. - * - */ - readonly block: Block; - /** - * @remarks - * Dimension that contains the block that is the subject of - * this event. - * - */ - readonly dimension: Dimension; -} - -/** - * @beta - * Contains information regarding an explosion that has - * occurred for a specific block. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class BlockExplodeAfterEvent extends BlockEvent { - private constructor(); - /** - * @remarks - * Description of the block that has exploded. - * - */ - readonly explodedBlockPermutation: BlockPermutation; - /** - * @remarks - * Optional source of the explosion. - * - */ - readonly source?: Entity; -} - -/** - * @beta - * Manages callbacks that are connected to when an explosion - * occurs, as it impacts individual blocks. - */ -export class BlockExplodeAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when an explosion - * occurs, as it impacts individual blocks. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: BlockExplodeAfterEvent) => void): (arg: BlockExplodeAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when an explosion - * occurs, as it impacts individual blocks. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: BlockExplodeAfterEvent) => void): void; -} - -/** - * @beta - * Represents the inventory of a block in the world. Used with - * blocks like chests. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class BlockInventoryComponent extends BlockComponent { - private constructor(); - /** - * @remarks - * The container which holds an {@link ItemStack}. - * - * @throws This property can throw when used. - */ - readonly container: Container; - static readonly componentId = 'minecraft:inventory'; -} - -/** - * @beta - * Represents a fluid container block that currently contains - * lava. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class BlockLavaContainerComponent extends BlockLiquidContainerComponent { - private constructor(); - static readonly componentId = 'minecraft:lavaContainer'; -} - -/** - * @beta - * For blocks that can contain a liquid (e.g., a cauldron), - * this is a base component for liquid containers. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class BlockLiquidContainerComponent extends BlockComponent { - private constructor(); - /** - * @remarks - * Relative fill level of the liquid container. - * - * This property can't be edited in read-only mode. - * - */ - fillLevel: number; - /** - * @remarks - * Returns true if this reference to a liquid container is - * still valid and contains the liquid of the type you have a - * reference for (for example, if the block is unloaded, no - * longer a liquid container or contains lava when you have a - * potion container component, isValidLiquid will not be true.) - * - * @returns - * True if this liquid container still exists, is valid and - * contains the expected liquid type. - */ - isValidLiquid(): boolean; -} - -/** - * @beta - * A BlockLocationIterator returns the next block location of - * the block volume across which it is iterating. - * The BlockLocationIterator is used to abstract the shape of - * the block volume it was fetched from (so it can represent - * all the block locations that make up rectangles, cubes, - * spheres, lines and complex shapes). - * Each iteration pass returns the next valid block location in - * the parent shape. - * Unless otherwise specified by the parent shape - the - * BlockLocationIterator will iterate over a 3D space in the - * order of increasing X, followed by increasing Z followed by - * increasing Y. - * (Effectively stepping across the XZ plane, and when all the - * locations in that plane are exhausted, increasing the Y - * coordinate to the next XZ slice) - */ -export class BlockLocationIterator implements Iterable { - private constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - [Symbol.iterator](): Iterator; - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - next(): IteratorResult; -} - -/** - * @beta - * Contains the combination of type {@link BlockType} and - * properties (also sometimes called block state) which - * describe a block (but does not belong to a specific {@link - * Block}). - */ -export class BlockPermutation { - private constructor(); - /** - * @beta - * @remarks - * The {@link BlockType} that the permutation has. - * - */ - readonly 'type': BlockType; - /** - * @beta - * @remarks - * Creates a copy of this permutation. - * - * @returns - * A copy of the permutation. - */ - clone(): BlockPermutation; - /** - * @beta - * @remarks - * Returns all available block states associated with this - * block. - * - * @returns - * Returns the list of all of the block states that the - * permutation has. - */ - getAllStates(): Record; - /** - * @beta - * @remarks - * Retrieves a prototype item stack based on this block - * permutation that can be used with item - * Container/ContainerSlot APIs. - * - * @param amount - * Number of instances of this block to place in the prototype - * item stack. - */ - getItemStack(amount?: number): ItemStack; - /** - * @beta - * @remarks - * Gets a state for the permutation. - * - * @param stateName - * Name of the block state who's value is to be returned. - * @returns - * Returns the state if the permutation has it, else - * `undefined`. - */ - getState(stateName: string): boolean | number | string | undefined; - /** - * @beta - * @remarks - * Creates a copy of the permutation. - * - */ - getTags(): string[]; - /** - * @beta - * @remarks - * Checks to see if the permutation has a specific tag. - * - * @returns - * Returns `true` if the permutation has the tag, else `false`. - * @example check_block_tags.js - * ```typescript - * import { world } from "@minecraft/server"; - * - * // Fetch the block - * const block = world.getDimension("overworld").getBlock({ x: 1, y: 2, z: 3 }); - * const blockPerm = block.getPermutation(); - * - * console.log(`Block is dirt: ${blockPerm.hasTag("dirt")}`); - * console.log(`Block is wood: ${blockPerm.hasTag("wood")}`); - * console.log(`Block is stone: ${blockPerm.hasTag("stone")}`); - * ``` - */ - hasTag(tag: string): boolean; - /** - * @remarks - * Returns a boolean whether a specified permutation matches - * this permutation. If states is not specified, matches checks - * against the set of types more broadly. - * - * @param blockName - * An optional set of states to compare against. - */ - matches(blockName: string, states?: Record): boolean; - /** - * @beta - * @remarks - * Returns a derived BlockPermutation with a specific property - * set. - * - * @param name - * Identifier of the block property. - * @param value - * Value of the block property. - * @throws This function can throw errors. - */ - withState(name: string, value: boolean | number | string): BlockPermutation; - /** - * @remarks - * Given a type identifier and an optional set of properties, - * will return a BlockPermutation object that is usable in - * other block APIs (e.g., block.setPermutation) - * - * @param blockName - * Identifier of the block to check. - * @throws This function can throw errors. - * @example addBlockColorCube.ts - * ```typescript - * const allColorNames: string[] = [ - * "white", - * "orange", - * "magenta", - * "light_blue", - * "yellow", - * "lime", - * "pink", - * "gray", - * "silver", - * "cyan", - * "purple", - * "blue", - * "brown", - * "green", - * "red", - * "black", - * ]; - * - * const cubeDim = 7; - * - * let colorIndex = 0; - * - * for (let x = 0; x <= cubeDim; x++) { - * for (let y = 0; y <= cubeDim; y++) { - * for (let z = 0; z <= cubeDim; z++) { - * colorIndex++; - * overworld - * .getBlock({ x: targetLocation.x + x, y: targetLocation.y + y, z: targetLocation.z + z }) - * ?.setPermutation( - * mc.BlockPermutation.resolve("minecraft:wool", { - * color: allColorNames[colorIndex % allColorNames.length], - * }) - * ); - * } - * } - * } - * ``` - */ - static resolve(blockName: string, states?: Record): BlockPermutation; -} - -/** - * @beta - * When present, this block has piston-like behavior. Contains - * additional properties for discovering block piston state. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class BlockPistonComponent extends BlockComponent { - private constructor(); - /** - * @remarks - * Whether the piston is fully expanded. - * - * @throws This property can throw when used. - */ - readonly isExpanded: boolean; - /** - * @remarks - * Whether the piston is in the process of expanding. - * - * @throws This property can throw when used. - */ - readonly isExpanding: boolean; - /** - * @remarks - * Whether the piston is in the process of expanding or - * retracting. - * - * @throws This property can throw when used. - */ - readonly isMoving: boolean; - /** - * @remarks - * Whether the piston is fully retracted. - * - * @throws This property can throw when used. - */ - readonly isRetracted: boolean; - /** - * @remarks - * Whether the piston is in the process of retracting. - * - * @throws This property can throw when used. - */ - readonly isRetracting: boolean; - static readonly componentId = 'minecraft:piston'; - /** - * @remarks - * Retrieves a set of blocks that this piston is connected - * with. - * - * @throws This function can throw errors. - */ - getAttachedBlocks(): Vector3[]; -} - -/** - * @beta - * Represents a fluid container block that currently contains a - * potion. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class BlockPotionContainerComponent extends BlockLiquidContainerComponent { - private constructor(); - static readonly componentId = 'minecraft:potionContainer'; - /** - * @remarks - * Sets the potion type based on an item stack. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - setPotionType(itemStack: ItemStack): void; -} - -/** - * @beta - * Represents a block that can play a record. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class BlockRecordPlayerComponent extends BlockComponent { - private constructor(); - static readonly componentId = 'minecraft:recordPlayer'; - /** - * @remarks - * Clears the currently playing record of this record-playing - * block. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - clearRecord(): void; - /** - * @remarks - * Returns true if the record-playing block is currently - * playing a record. - * - * @throws This function can throw errors. - */ - isPlaying(): boolean; - /** - * @remarks - * Sets and plays a record based on an item type. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - setRecord(recordItemType: ItemType | string): void; -} - -/** - * @beta - * Represents a block that can display text on it. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class BlockSignComponent extends BlockComponent { - private constructor(); - /** - * @remarks - * Whether or not players can edit the sign. This happens if a - * sign has had a honeycomb used on it or `setWaxed` was called - * on the sign. - * - * @throws This property can throw when used. - */ - readonly isWaxed: boolean; - static readonly componentId = 'minecraft:sign'; - /** - * @remarks - * Returns the RawText of the sign if `setText` was called with - * a RawMessage or a RawText object, otherwise returns - * undefined. - * - * @param side - * The side of the sign to read the message from. If not - * provided, this will return the message from the front side - * of the sign. - * @throws This function can throw errors. - */ - getRawText(side?: SignSide): RawText | undefined; - /** - * @remarks - * Returns the text of the sign if `setText` was called with a - * string, otherwise returns undefined. - * - * @param side - * The side of the sign to read the message from. If not - * provided, this will return the message from the front side - * of the sign. - * @throws This function can throw errors. - */ - getText(side?: SignSide): string | undefined; - /** - * @remarks - * Gets the dye that is on the text or undefined if the sign - * has not been dyed. - * - * @param side - * The side of the sign to read the dye from. If not provided, - * this will return the dye on the front side of the sign. - * @throws This function can throw errors. - */ - getTextDyeColor(side?: SignSide): DyeColor | undefined; - /** - * @remarks - * Sets the text of the sign component. - * - * This function can't be called in read-only mode. - * - * @param message - * The message to set on the sign. If set to a string, then - * call `getText` to read that string. If set to a RawMessage, - * then calling `getRawText` will return a RawText. If set to a - * RawText, then calling `getRawText` will return the same - * object that was passed in. - * @param side - * The side of the sign the message will be set on. If not - * provided, the message will be set on the front side of the - * sign. - * @throws This function can throw errors. - * @example SetRawMessage.ts - * ```typescript - * const helloWorldMessage: RawMessage = { text: 'Hello World' }; - * sign.setText(helloWorldMessage); - * - * // Sign text will be saved as a RawText - * const result: RawText = sign.getRawText(); - * JSON.stringify(result); // { rawtext: [{ text: 'Hello World' }] }; - * ``` - * @example SetRawText.ts - * ```typescript - * const helloWorldText: RawText = { rawtext: [{ text: 'Hello World' }] }; - * sign.setText(helloWorldText); - * - * // There will be no data transformation unlike calling setText with a RawMessage - * const result: RawText = sign.getRawText(); - * JSON.stringify(result); // { rawtext: [{ text: 'Hello World' }] }; - * ``` - * @example SetString.ts - * ```typescript - * // Set sign to say 'Hello' - * sign.setText('Hello'); - * sign.getText(); // 'Hello' - * ``` - */ - setText(message: RawMessage | RawText | string, side?: SignSide): void; - /** - * @remarks - * Sets the dye color of the text. - * - * This function can't be called in read-only mode. - * - * @param color - * The dye color to apply to the sign or undefined to clear the - * dye on the sign. - * @param side - * The side of the sign the color will be set on. If not - * provided, the color will be set on the front side of the - * sign. - * @throws This function can throw errors. - */ - setTextDyeColor(color?: DyeColor, side?: SignSide): void; - /** - * @remarks - * Makes it so players cannot edit this sign. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - setWaxed(): void; -} - -/** - * @beta - * Represents a fluid container block that currently contains - * snow. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class BlockSnowContainerComponent extends BlockLiquidContainerComponent { - private constructor(); - static readonly componentId = 'minecraft:snowContainer'; -} - -/** - * @beta - * Enumerates all {@link BlockStateType}s. - */ -export class BlockStates { - private constructor(); - /** - * @remarks - * Retrieves a specific block state instance. - * - * @returns - * Returns the block state instance if it is found. If the - * block state instance is not found returns undefined. - */ - static get(stateName: string): BlockStateType; - /** - * @remarks - * Retrieves a set of all available block states. - * - */ - static getAll(): BlockStateType[]; -} - -/** - * @beta - * Represents a configurable state value of a block instance. - * For example, the facing direction of stairs is accessible as - * a block state. - */ -export class BlockStateType { - private constructor(); - /** - * @remarks - * Identifier of the block property. - * - */ - readonly id: string; - /** - * @remarks - * A set of valid values for the block property. - * - */ - readonly validValues: (boolean | number | string)[]; -} - -/** - * @beta - * The type (or template) of a block. Does not contain - * permutation data (state) other than the type of block it - * represents. This type was introduced as of version - * 1.17.10.21. - */ -export class BlockType { - private constructor(); - /** - * @remarks - * Represents whether this type of block can be waterlogged. - * - */ - readonly canBeWaterlogged: boolean; - /** - * @remarks - * Block type name - for example, `minecraft:acacia_stairs`. - * - */ - readonly id: string; -} - -/** - * @beta - */ -export class BlockTypes { - private constructor(); - static get(typeName: string): BlockType | undefined; - static getAll(): BlockType[]; -} - -/** - * @beta - * Block Volume Utils is a utility class that provides a number - * of useful functions for the creation and utility of {@link - * @minecraft-server.BlockVolume} objects - */ -export class BlockVolumeUtils { - private constructor(); - /** - * @remarks - * Check to see if the given location is directly adjacent to - * the outer surface of a BlockVolume. - * - * - * This function can't be called in read-only mode. - * - * @param volume - * The volume to test against - * @param pos - * The world block location to test - * @returns - * If the location is either inside or more than 0 blocks away, - * the function will return false. - * If the location is directly contacting the outer surface of - * the BlockVolume, the function will return true. - */ - static doesLocationTouchFaces(volume: BlockVolume, pos: Vector3): boolean; - /** - * @remarks - * Check to see if a two block volumes are directly adjacent - * and two faces touch. - * - * This function can't be called in read-only mode. - * - * @param volume - * The volume to test against - * @param other - * The volume to test - * @returns - * If the outer faces of both block volumes touch and are - * directly adjacent at any point, return true. - */ - static doesVolumeTouchFaces(volume: BlockVolume, other: BlockVolume): boolean; - /** - * @remarks - * Test the equality of two block volumes - * - * This function can't be called in read-only mode. - * - * @returns - * Return true if two block volumes are identical - */ - static equals(volume: BlockVolume, other: BlockVolume): boolean; - /** - * @remarks - * Fetch a {@link BlockLocationIterator} that represents all of - * the block world locations within the specified volume - * - * This function can't be called in read-only mode. - * - */ - static getBlockLocationIterator(volume: BlockVolume): BlockLocationIterator; - /** - * @remarks - * Return a {@link BoundingBox} object which represents the - * validated min and max coordinates of the volume - * - * This function can't be called in read-only mode. - * - */ - static getBoundingBox(volume: BlockVolume): BoundingBox; - /** - * @remarks - * Return the capacity (volume) of the BlockVolume (W*D*H) - * - * This function can't be called in read-only mode. - * - */ - static getCapacity(volume: BlockVolume): number; - /** - * @remarks - * Get the largest corner position of the volume (guaranteed to - * be >= min) - * - * This function can't be called in read-only mode. - * - */ - static getMax(volume: BlockVolume): Vector3; - /** - * @remarks - * Get the smallest corner position of the volume (guaranteed - * to be <= max) - * - * This function can't be called in read-only mode. - * - */ - static getMin(volume: BlockVolume): Vector3; - /** - * @remarks - * Get a {@link Vector3} object where each component represents - * the number of blocks along that axis - * - * This function can't be called in read-only mode. - * - */ - static getSpan(volume: BlockVolume): Vector3; - /** - * @remarks - * Return an enumeration which represents the intersection - * between two BlockVolume objects - * - * This function can't be called in read-only mode. - * - */ - static intersects(volume: BlockVolume, other: BlockVolume): BlockVolumeIntersection; - /** - * @remarks - * Check to see if a given world block location is inside a - * BlockVolume - * - * This function can't be called in read-only mode. - * - */ - static isInside(volume: BlockVolume, pos: Vector3): boolean; - /** - * @remarks - * Move a BlockVolume by a specified amount - * - * This function can't be called in read-only mode. - * - * @param delta - * Amount of blocks to move by - * @returns - * Returns a new BlockVolume object which represents the new - * volume - */ - static translate(volume: BlockVolume, delta: Vector3): BlockVolume; -} - -/** - * @beta - * Represents a fluid container block that currently contains - * water. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class BlockWaterContainerComponent extends BlockLiquidContainerComponent { - private constructor(); - static readonly componentId = 'minecraft:waterContainer'; - /** - * @remarks - * Adds an item and colors the water based on a dye item type. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - addDye(itemType: ItemType): void; - /** - * @remarks - * Retrieves a custom base color used for the sign text. - * - * @returns - * Color that is used as the base color for sign text. - * @throws This function can throw errors. - */ - getCustomColor(): RGBA; - /** - * @remarks - * Sets a custom base color used for the sign text. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - setCustomColor(color: RGBA): void; -} - -/** - * @beta - * Bounding Box Utils is a utility class that provides a number - * of useful functions for the creation and utility of {@link - * @minecraft-server.BoundingBox} objects - */ -export class BoundingBoxUtils { - private constructor(); - /** - * @remarks - * Create a validated instance of a {@link - * @minecraft-server.BoundingBox} where the min and max - * components are guaranteed to be (min <= max) - * - * This function can't be called in read-only mode. - * - * @param min - * A corner world location - * @param max - * A corner world location diametrically opposite - */ - static createValid(min: Vector3, max: Vector3): BoundingBox; - /** - * @remarks - * Expand a {@link @minecraft-server.BoundingBox} by a given - * amount along each axis. - * Sizes can be negative to perform contraction. - * Note: corners can be inverted if the contraction size is - * greater than the span, but the min/max relationship will - * remain correct - * - * This function can't be called in read-only mode. - * - * @returns - * Return a new {@link @minecraft-server.BoundingBox} object - * representing the changes - */ - static dilate(box: BoundingBox, size: Vector3): BoundingBox; - /** - * @remarks - * Check if two {@link @minecraft-server.BoundingBox} objects - * are identical - * - * This function can't be called in read-only mode. - * - */ - static equals(box: BoundingBox, other: BoundingBox): boolean; - /** - * @remarks - * Expand the initial box object bounds to include the 2nd box - * argument. The resultant {@link - * @minecraft-server.BoundingBox} object will be a BoundingBox - * which exactly encompasses the two boxes. - * - * This function can't be called in read-only mode. - * - * @returns - * A new {@link @minecraft-server.BoundingBox} instance - * representing the smallest possible bounding box which can - * encompass both - */ - static expand(box: BoundingBox, other: BoundingBox): BoundingBox; - /** - * @remarks - * Calculate the center block of a given {@link - * @minecraft-server.BoundingBox} object. - * - * This function can't be called in read-only mode. - * - * @returns - * Note that {@link @minecraft-server.BoundingBox} objects - * represent whole blocks, so the center of boxes which have - * odd numbered bounds are not mathematically centered... - * i.e. a BoundingBox( 0,0,0 -> 3,3,3 ) would have a center of - * (1,1,1) (not (1.5, 1.5, 1.5) as expected) - */ - static getCenter(box: BoundingBox): Vector3; - /** - * @remarks - * Calculate the BoundingBox which represents the union area of - * two intersecting BoundingBoxes - * - * This function can't be called in read-only mode. - * - */ - static getIntersection(box: BoundingBox, other: BoundingBox): BoundingBox | undefined; - /** - * @remarks - * Get the Span of each of the BoundingBox Axis components - * - * This function can't be called in read-only mode. - * - */ - static getSpan(box: BoundingBox): Vector3; - /** - * @remarks - * Check to see if two BoundingBox objects intersect - * - * This function can't be called in read-only mode. - * - */ - static intersects(box: BoundingBox, other: BoundingBox): boolean; - /** - * @remarks - * Check to see if a given coordinate is inside a BoundingBox - * - * This function can't be called in read-only mode. - * - */ - static isInside(box: BoundingBox, pos: Vector3): boolean; - /** - * @remarks - * Check to see if a BoundingBox is valid (i.e. (min <= max)) - * - * This function can't be called in read-only mode. - * - */ - static isValid(box: BoundingBox): boolean; - /** - * @remarks - * Move a BoundingBox by a given amount - * - * This function can't be called in read-only mode. - * - * @returns - * Return a new BoundingBox object which represents the change - */ - static translate(box: BoundingBox, delta: Vector3): BoundingBox; -} - -/** - * @beta - * Contains information related to changes to a button push. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class ButtonPushAfterEvent extends BlockEvent { - private constructor(); - /** - * @remarks - * Optional source that triggered the button push. - * - */ - readonly source: Entity; -} - -/** - * @beta - * Manages callbacks that are connected to when a button is - * pushed. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class ButtonPushAfterEventSignal extends IButtonPushAfterEventSignal { - private constructor(); -} - -/** - * @beta - */ -export class Camera { - private constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - clear(): void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - fade(fadeCameraOptions?: CameraFadeOptions): void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - setCamera( - cameraPreset: string, - setOptions?: - | ScriptCameraDefaultOptions - | ScriptCameraSetFacingOptions - | ScriptCameraSetLocationOptions - | ScriptCameraSetPosOptions - | ScriptCameraSetRotOptions, - ): void; -} - -/** - * @beta - * An event that fires as players enter chat messages. - */ -export class ChatSendAfterEvent { - private constructor(); - /** - * @remarks - * Message that is being broadcast. In a beforeChat event - * handler, _message_ can be updated with edits before the - * message is displayed to players. - * - */ - message: string; - /** - * @remarks - * Player that sent the chat message. - * - */ - sender: Player; - /** - * @remarks - * If true, this message is directly targeted to one or more - * players (i.e., is not broadcast.) - * - */ - sendToTargets: boolean; - /** - * @remarks - * List of players that will receive this message. - * - * @returns - * List of player objects. - */ - getTargets(): Player[]; -} - -/** - * @beta - * Manages callbacks that are connected to chat messages being - * sent. - */ -export class ChatSendAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when new chat messages - * are sent. - * - * This function can't be called in read-only mode. - * - * @example custom_command.js - * ```typescript - * const chatCallback = World.beforeEvents.chatSend.subscribe((eventData) => { - * if (eventData.message.includes("cancel")) { - * // Cancel event if the message contains "cancel" - * eventData.canceled = true; - * } else { - * // Modify chat message being sent - * eventData.message = `Modified '${eventData.message}'`; - * } - * }); - * ``` - */ - subscribe(callback: (arg: ChatSendAfterEvent) => void): (arg: ChatSendAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when new chat messages - * are sent. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ChatSendAfterEvent) => void): void; -} - -/** - * @beta - * An event that fires as players enter chat messages. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class ChatSendBeforeEvent extends ChatSendAfterEvent { - private constructor(); - /** - * @remarks - * If set to true in a beforeChat event handler, this message - * is not broadcast out. - * - */ - cancel: boolean; - /** - * @remarks - * Sets an updated list of players that will receive this - * message. - * - * @param players - * Updated array of players that should receive this message. - */ - setTargets(players: Player[]): void; -} - -/** - * @beta - * Manages callbacks that are connected to an event that fires - * before chat messages are sent. - */ -export class ChatSendBeforeEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called before new chat messages - * are sent. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ChatSendBeforeEvent) => void): (arg: ChatSendBeforeEvent) => void; - /** - * @remarks - * Removes a callback from being called before new chat - * messages are sent. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ChatSendBeforeEvent) => void): void; -} - -/** - * Contains return data on the result of a command execution. - */ -export class CommandResult { - private constructor(); - /** - * @remarks - * If the command operates against a number of entities, - * blocks, or items, this returns the number of successful - * applications of this command. - * - */ - readonly successCount: number; -} - -/** - * @beta - * Base class for downstream Component implementations. - */ -export class Component { - private constructor(); - /** - * @remarks - * Identifier of the component. - * - */ - readonly typeId: string; - /** - * @beta - * @remarks - * Returns whether the component is valid. A component is - * considered valid if its owner is valid, in addition to any - * addition to any additional validation required by the - * component. - * - * @returns - * Whether the component is valid. - */ - isValid(): boolean; -} - -/** - * @beta - * The Compound Block Volume is a collection of individual - * block volume definitions which, as a collection, define a - * larger volume of (sometimes non-contiguous) irregular - * shapes. - * This class is loosely based on the concept of CSG - * (Computational Solid Geometry) and allows a user to create - * complex volumes by building a stack of volumes and voids to - * make a larger single volume. - * For example - normally a creator would create a hollow cube - * by creating 6 "wall" surfaces for each face. - * With a Compound Block Volume, a creator can define a hollow - * cube by creating a single outer solid cube, and then - * defining a further single 'void' cube inside the larger one. - * Similarly, the Compound Block Volume can represent irregular - * shaped volumes (e.g. a tree consists of a trunk and lots of - * leaf cubes which are not necessarily contiguously placed). - * Each of the volumes added to the CompoundBlockVolume are (by - * default) relative to the origin set (either at construction - * or via one of the set functions). - * However, it is also possible to push volumes to the compound - * collection which are absolute in nature and are not affected - * by origin changes. - */ -export class CompoundBlockVolume { - /** - * @remarks - * Return the 'capacity' of the bounding rectangle which - * represents the collection of volumes in the stack - * - */ - readonly capacity: number; - /** - * @remarks - * Return the number of volumes (positive and negative) in the - * volume stack - * - */ - readonly volumeCount: number; - /** - * @remarks - * Create a CompoundBlockVolume object - * - * @param origin - * An optional world space origin on which to center the - * compound volume. - * If not specified, the origin is set to (0,0,0) - */ - constructor(origin?: Vector3); - /** - * @remarks - * Clear the contents of the volume stack - * - * This function can't be called in read-only mode. - * - */ - clear(): void; - /** - * @remarks - * Fetch a Block Location Iterator for the Compound Block - * Volume. This iterator will allow a creator to iterate - * across all of the selected volumes within the larger - * bounding area. - * Areas of a volume which have been overridden by a - * subtractive volume will not be included in the iterator - * step. - * (i.e. if you push a cube to the stack, and then push a - * subtractive volume to the same location, then the iterator - * will step over the initial volume because it is considered - * negative space) - * Note that the Block Locations returned by this iterator are - * in absolute world space (irrespective of whether the - * compound volume items pushed are absolute or relative) - * - * This function can't be called in read-only mode. - * - */ - getBlockLocationIterator(): BlockLocationIterator; - /** - * @remarks - * Get the largest bounding box that represents a container for - * all of the volumes on the stack - * Note that the bounding box returned is represented in - * absolute world space (irrespective of whether the compound - * volume items pushed are absolute or relative) - * - * This function can't be called in read-only mode. - * - */ - getBoundingBox(): BoundingBox; - /** - * @remarks - * Get the max block location of the outermost bounding - * rectangle which represents the volumes on the stack. - * Note that the max location returned is in absolute world - * space (irrespective of whether the compound volume items - * pushed are absolute or relative) - * - * This function can't be called in read-only mode. - * - */ - getMax(): Vector3; - /** - * @remarks - * Get the min block location of the outermost bounding - * rectangle which represents the volumes on the stack. - * Note that the min location returned is in absolute world - * space (irrespective of whether the compound volume items - * pushed are absolute or relative) - * - * This function can't be called in read-only mode. - * - */ - getMin(): Vector3; - /** - * @remarks - * Fetch the origin in world space of the compound volume - * - * This function can't be called in read-only mode. - * - */ - getOrigin(): Vector3; - /** - * @remarks - * Return a boolean which signals if there are any volume items - * pushed to the volume - * - * This function can't be called in read-only mode. - * - */ - isEmpty(): boolean; - /** - * @remarks - * Return a boolean representing whether or not a given - * absolute world space block location is inside a positive - * block volume. - * E.g. if the stack contains a large cube followed by a - * slightly smaller negative cube, and the test location is - * within the negative cube - the function will return false - * because it's not 'inside' a volume (it IS inside the - * bounding rectangle, but it is not inside a positively - * defined location) - * - * This function can't be called in read-only mode. - * - */ - isInside(worldLocation: Vector3): boolean; - /** - * @remarks - * Inspect the last entry pushed to the volume stack without - * affecting the stack contents. - * - * This function can't be called in read-only mode. - * - * @param forceRelativity - * Determine whether the function returns a - * CompoundBlockVolumeItem which is forced into either relative - * or absolute coordinate system. - * `true` = force returned item to be relative to volume origin - * `false` = force returned item to be absolute world space - * location - * - * If no flag is specified, the item returned retains whatever - * relativity it had when it was pushed - * @returns - * Returns undefined if the stack is empty - */ - peekLastVolume(forceRelativity?: CompoundBlockVolumePositionRelativity): CompoundBlockVolumeItem | undefined; - /** - * @remarks - * Remove the last entry from the volume stack. This will - * reduce the stack size by one - * - * This function can't be called in read-only mode. - * - */ - popVolume(): boolean; - /** - * @remarks - * Push a volume item to the stack. The volume item contains - * an 'action' parameter which determines whether this volume - * is a positive or negative space. - * The item also contains a `locationRelativity` which - * determines whether it is relative or absolute to the - * compound volume origin - * - * This function can't be called in read-only mode. - * - * @param item - * Item to push to the end of the stack - */ - pushVolume(item: CompoundBlockVolumeItem): void; - /** - * @remarks - * If the volume stack is empty, this function will push the - * specified item to the stack. - * If the volume stack is NOT empty, this function will replace - * the last item on the stack with the new item. - * - * This function can't be called in read-only mode. - * - * @param item - * Item to add or replace - */ - replaceOrAddLastVolume(item: CompoundBlockVolumeItem): boolean; - /** - * @remarks - * Set the origin of the compound volume to an absolute world - * space location - * - * This function can't be called in read-only mode. - * - * @param preserveExistingVolumes - * This optional boolean flag determines whether the relative - * `CompoundBlockVolumeItem`'s are frozen in place, or are - * affected by the new origin. - * Imagine a scenario where you have a series of relative - * locations around an origin which make up a sphere; all of - * these locations are in the range of -2 to 2. - * Push each of these locations to the compound volume as - * relative items. - * Now, move the origin and all of the locations representing - * the sphere move accordingly. - * However, let's say you want to add a 2nd sphere next to the - * 1st. - * In this case, set the new origin a few locations over, but - * 'preserveExistingVolumes' = true. - * This will set a new origin, but the existing sphere - * locations will remain relative to the original origin. - * Now, you can push the relative sphere locations again (this - * time they will be relative to the new origin) - resulting in - * 2 spheres next to each other. - */ - setOrigin(position: Vector3, preserveExistingVolumes?: boolean): void; - /** - * @remarks - * Similar to {@link - * @minecraft-server/CompoundBlockVolume.setOrigin} - this - * function will translate the origin by a given delta to a new - * position - * - * This function can't be called in read-only mode. - * - * @param preserveExistingVolumes - * See the description for the arguments to {@link - * @minecraft-server/CompoundBlockVolume.setOrigin} - */ - translateOrigin(delta: Vector3, preserveExistingVolumes?: boolean): void; -} - -/** - * @beta - * Represents a container that can hold sets of items. Used - * with entities such as Players, Chest Minecarts, Llamas, and - * more. - */ -export class Container { - private constructor(); - /** - * @remarks - * Count of the slots in the container that are empty. - * - * @throws - * Throws if the container is invalid. - */ - readonly emptySlotsCount: number; - /** - * @remarks - * The number of slots in this container. For example, a - * standard single-block chest has a size of 27. Note, a - * player's inventory container contains a total of 36 slots, 9 - * hotbar slots plus 27 inventory slots. - * - * @throws - * Throws if the container is invalid. - */ - readonly size: number; - /** - * @remarks - * Adds an item to the container. The item is placed in the - * first available slot(s) and can be stacked with existing - * items of the same type. Note, use {@link Container.setItem} - * if you wish to set the item in a particular slot. - * - * This function can't be called in read-only mode. - * - * @param itemStack - * The stack of items to add. - * @throws This function can throw errors. - */ - addItem(itemStack: ItemStack): ItemStack; - /** - * @remarks - * Clears all inventory items in the container. - * - * This function can't be called in read-only mode. - * - * @throws - * Throws if the container is invalid. - */ - clearAll(): void; - /** - * @remarks - * Gets an {@link ItemStack} of the item at the specified slot. - * If the slot is empty, returns `undefined`. This method does - * not change or clear the contents of the specified slot. To - * get a reference to a particular slot, see {@link - * Container.getSlot}. - * - * @param slot - * Zero-based index of the slot to retrieve items from. - * @throws - * Throws if the container is invalid or if the `slot` index is - * out of bounds. - * @example getItem.ts - * ```typescript - * // Get a copy of the first item in the player's hotbar - * const inventory = player.getComponent("inventory") as EntityInventoryComponent; - * const itemStack = inventory.container.getItem(0); - * ``` - */ - getItem(slot: number): ItemStack | undefined; - /** - * @beta - * @remarks - * Returns a container slot. This acts as a reference to a slot - * at the given index for this container. - * - * @param slot - * The index of the slot to return. This index must be within - * the bounds of the container. - * @throws - * Throws if the container is invalid or if the `slot` index is - * out of bounds. - */ - getSlot(slot: number): ContainerSlot; - /** - * @beta - * @remarks - * Returns whether a container object (or the entity or block - * that this container is associated with) is still available - * for use in this context. - * - */ - isValid(): boolean; - /** - * @remarks - * Moves an item from one slot to another, potentially across - * containers. - * - * This function can't be called in read-only mode. - * - * @param fromSlot - * Zero-based index of the slot to transfer an item from, on - * this container. - * @param toSlot - * Zero-based index of the slot to transfer an item to, on - * `toContainer`. - * @param toContainer - * Target container to transfer to. Note this can be the same - * container as the source. - * @throws - * Throws if either this container or `toContainer` are invalid - * or if the `fromSlot` or `toSlot` indices out of bounds. - * @example moveItem.ts - * ```typescript - * // Move an item from the first slot of fromPlayer's inventory to the fifth slot of toPlayer's inventory - * const fromInventory = fromPlayer.getComponent('inventory') as EntityInventoryComponent; - * const toInventory = toPlayer.getComponent('inventory') as EntityInventoryComponent; - * fromInventory.container.moveItem(0, 4, toInventory.container); - * ``` - */ - moveItem(fromSlot: number, toSlot: number, toContainer: Container): void; - /** - * @remarks - * Sets an item stack within a particular slot. - * - * This function can't be called in read-only mode. - * - * @param slot - * Zero-based index of the slot to set an item at. - * @param itemStack - * Stack of items to place within the specified slot. Setting - * `itemStack` to undefined will clear the slot. - * @throws - * Throws if the container is invalid or if the `slot` index is - * out of bounds. - */ - setItem(slot: number, itemStack?: ItemStack): void; - /** - * @remarks - * Swaps items between two different slots within containers. - * - * This function can't be called in read-only mode. - * - * @param slot - * Zero-based index of the slot to swap from this container. - * @param otherSlot - * Zero-based index of the slot to swap with. - * @param otherContainer - * Target container to swap with. Note this can be the same - * container as this source. - * @throws - * Throws if either this container or `otherContainer` are - * invalid or if the `slot` or `otherSlot` are out of bounds. - * @example swapItems.ts - * ```typescript - * // Swaps an item between slots 0 and 4 in the player's inventory - * const inventory = fromPlayer.getComponent('inventory') as EntityInventoryComponent; - * inventory.container.swapItems(0, 4, inventory); - * ``` - */ - swapItems(slot: number, otherSlot: number, otherContainer: Container): void; - /** - * @remarks - * Moves an item from one slot to another container, or to the - * first available slot in the same container. - * - * This function can't be called in read-only mode. - * - * @param fromSlot - * Zero-based index of the slot to transfer an item from, on - * this container. - * @param toContainer - * Target container to transfer to. Note this can be the same - * container as the source. - * @throws - * Throws if either this container or `toContainer` are invalid - * or if the `fromSlot` or `toSlot` indices out of bounds. - * @example transferItem.ts - * ```typescript - * // Transfer an item from the first slot of fromPlayer's inventory to toPlayer's inventory - * const fromInventory = fromPlayer.getComponent('inventory') as EntityInventoryComponent; - * const toInventory = toPlayer.getComponent('inventory') as EntityInventoryComponent; - * fromInventory.container.transferItem(0, toInventory.container); - * ``` - */ - transferItem(fromSlot: number, toContainer: Container): ItemStack; -} - -/** - * @beta - * Represents a slot within a broader container (e.g., entity - * inventory.) - */ -export class ContainerSlot { - private constructor(); - /** - * @remarks - * Number of the items in the stack. Valid values range between - * 1-255. The provided value will be clamped to the item's - * maximum stack size. - * - * This property can't be edited in read-only mode. - * - * @throws - * Throws if the value is outside the range of 1-255. - */ - amount: number; - /** - * @remarks - * Returns whether the item is stackable. An item is considered - * stackable if the item's maximum stack size is greater than 1 - * and the item does not contain any custom data or properties. - * - * @throws - * Throws if the slot's container is invalid. - */ - readonly isStackable: boolean; - /** - * @remarks - * Gets or sets whether the item is kept on death. - * - * This property can't be edited in read-only mode. - * - * @throws - * Throws if the slot's container is invalid. - */ - keepOnDeath: boolean; - /** - * @remarks - * Gets or sets the item's lock mode. The default value is - * `ItemLockMode.none`. - * - * This property can't be edited in read-only mode. - * - * @throws - * Throws if the slot's container is invalid. - */ - lockMode: ItemLockMode; - /** - * @remarks - * The maximum stack size. This value varies depending on the - * type of item. For example, torches have a maximum stack size - * of 64, while eggs have a maximum stack size of 16. - * - * @throws - * Throws if the slot's container is invalid. - */ - readonly maxAmount: number; - /** - * @remarks - * Given name of this stack of items. The name tag is displayed - * when hovering over the item. Setting the name tag to an - * empty string or `undefined` will remove the name tag. - * - * This property can't be edited in read-only mode. - * - * @throws - * Throws if the slot's container is invalid. Also throws if - * the length exceeds 255 characters. - */ - nameTag?: string; - /** - * @remarks - * The type of the item. - * - * @throws - * Throws if the slot's container is invalid. - */ - readonly 'type': ItemType; - /** - * @remarks - * Identifier of the type of items for the stack. If a - * namespace is not specified, 'minecraft:' is assumed. - * Examples include 'wheat' or 'apple'. - * - * @throws - * Throws if the slot's container is invalid. - */ - readonly typeId?: string; - /** - * @remarks - * Creates an exact copy of the item stack, including any - * custom data or properties. - * - * @returns - * Returns a copy of the item in the slot. Returns undefined if - * the slot is empty. - * @throws This function can throw errors. - */ - getItem(): ItemStack | undefined; - /** - * @remarks - * Returns the lore value - a secondary display string - for an - * ItemStack. - * - * @returns - * An array of lore strings. If the item does not have lore, - * returns an empty array. - * @throws - * Throws if the slot's container is invalid. - */ - getLore(): string[]; - /** - * @remarks - * Returns all tags for the item in the slot. - * - * @returns - * Returns all tags for the item in the slot. Return an empty - * array if the the slot is empty. - * @throws This function can throw errors. - */ - getTags(): string[]; - /** - * @remarks - * Returns whether the item in the slot slot has the given tag. - * - * @param tag - * The item tag. - * @returns - * Returns false when the slot is empty or the item in the slot - * does not have the given tag. - * @throws This function can throw errors. - */ - hasTag(tag: string): boolean; - /** - * @remarks - * Returns whether this item stack can be stacked with the - * given `itemStack`. This is determined by comparing the item - * type and any custom data and properties associated with the - * item stacks. The amount of each item stack is not taken into - * consideration. - * - * @param itemStack - * The ItemStack that is being compared. - * @returns - * Returns whether this item stack can be stacked with the - * given `itemStack`. - * @throws - * Throws if the slot's container is invalid. - */ - isStackableWith(itemStack: ItemStack): boolean; - /** - * @remarks - * Returns whether the ContainerSlot is valid. The container - * slot is valid if the container exists and is loaded, and the - * slot index is valid. - * - */ - isValid(): boolean; - /** - * @remarks - * The list of block types this item can break in Adventure - * mode. The block names are displayed in the item's tooltip. - * Setting the value to undefined will clear the list. - * - * This function can't be called in read-only mode. - * - * @param blockIdentifiers - * The list of blocks, given by their identifiers. - * @throws - * Throws if the slot's container is invalid. Also throws if - * any of the provided block identifiers are invalid. - */ - setCanDestroy(blockIdentifiers?: string[]): void; - /** - * @remarks - * The list of block types this item can be placed on in - * Adventure mode. This is only applicable to block items. The - * block names are displayed in the item's tooltip. Setting the - * value to undefined will clear the list. - * - * This function can't be called in read-only mode. - * - * @param blockIdentifiers - * The list of blocks, given by their identifiers. - * @throws - * Throws if the slot's container is invalid. Also throws if - * any of the provided block identifiers are invalid. - */ - setCanPlaceOn(blockIdentifiers?: string[]): void; - /** - * @remarks - * Sets the given ItemStack in the slot, replacing any existing - * item. - * - * This function can't be called in read-only mode. - * - * @param itemStack - * The ItemStack to be placed in the slot. - * @throws This function can throw errors. - */ - setItem(itemStack?: ItemStack): void; - /** - * @remarks - * Sets the lore value - a secondary display string - for an - * ItemStack. - * - * This function can't be called in read-only mode. - * - * @param loreList - * A list of lore strings. Setting this argument to undefined - * will clear the lore. - * @throws - * Throws if the slot's container is invalid. - */ - setLore(loreList?: string[]): void; -} - -/** - * @beta - * Contains information related to firing of a data driven - * entity event - for example, the minecraft:ageable_grow_up - * event on a chicken. - */ -export class DataDrivenEntityTriggerAfterEvent { - private constructor(); - /** - * @remarks - * Entity that the event triggered on. - * - */ - readonly entity: Entity; - /** - * @remarks - * Name of the data driven event being triggered. - * - */ - readonly id: string; - /** - * @remarks - * An updateable list of modifications to component state that - * are the effect of this triggered event. - * - * This function can't be called in read-only mode. - * - */ - getModifiers(): DefinitionModifier[]; -} - -/** - * @beta - * Contains event registration related to firing of a data - * driven entity event - for example, the - * minecraft:ageable_grow_up event on a chicken. - */ -export class DataDrivenEntityTriggerAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called after a data driven - * entity event is triggered. - * - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: DataDrivenEntityTriggerAfterEvent) => void, - options?: EntityDataDrivenTriggerEventOptions, - ): (arg: DataDrivenEntityTriggerAfterEvent) => void; - /** - * @remarks - * Removes a callback that will be called after a data driven - * entity event is triggered. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: DataDrivenEntityTriggerAfterEvent) => void): void; -} - -/** - * @beta - * Contains information related to firing of a data driven - * entity event - for example, the minecraft:ageable_grow_up - * event on a chicken. - */ -export class DataDrivenEntityTriggerBeforeEvent { - private constructor(); - /** - * @remarks - * If set to true, this entity event is not triggered. - * - */ - cancel: boolean; - /** - * @remarks - * Entity that the event triggered on. - * - */ - readonly entity: Entity; - /** - * @remarks - * Name of the data driven event being triggered. - * - */ - readonly id: string; - /** - * @remarks - * An updateable list of modifications to component state that - * are the effect of this triggered event. - * - */ - getModifiers(): DefinitionModifier[]; - /** - * @remarks - * Changes a list of modifications to component state that are - * the effect of this triggered event. - * - * @param modifiers - * An updated list of modifications to component state. - */ - setModifiers(modifiers: DefinitionModifier[]): void; -} - -/** - * @beta - * Contains information related to firing of a data driven - * entity event - for example, the minecraft:ageable_grow_up - * event on a chicken. - */ -export class DataDrivenEntityTriggerBeforeEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called before a data driven - * entity event is triggered. - * - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: DataDrivenEntityTriggerBeforeEvent) => void, - options?: EntityDataDrivenTriggerEventOptions, - ): (arg: DataDrivenEntityTriggerBeforeEvent) => void; - /** - * @remarks - * Removes a callback that will be called before a data driven - * entity event is triggered. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: DataDrivenEntityTriggerBeforeEvent) => void): void; -} - -/** - * @beta - * Contains a set of updates to the component definition state - * of an entity. - */ -export class DefinitionModifier { - /** - * @remarks - * Retrieves the list of component groups that will be added - * via this definition modification. - * - */ - getComponentGroupsToAdd(): string[]; - /** - * @remarks - * Retrieves the list of component groups that will be removed - * via this definition modification. - * - */ - getComponentGroupsToRemove(): string[]; - /** - * @remarks - * Retrieves the list of entity definition events that will be - * fired via this update. - * - */ - getTriggers(): Trigger[]; - /** - * @remarks - * Updates the list of component groups that will be added via - * this definition modification. - * - */ - setComponentGroupsToAdd(newGroups: string[]): void; - /** - * @remarks - * Updates the list of component groups that will be removed - * via this definition modification. - * - */ - setComponentGroupsToRemove(removedGroups: string[]): void; - /** - * @remarks - * Updates the list of entity definition events that will be - * fired via this update. - * - */ - setTriggers(newTriggers: Trigger[]): void; -} - -/** - * A class that represents a particular dimension (e.g., The - * End) within a world. - */ -export class Dimension { - private constructor(); - /** - * @beta - * @remarks - * Height range of the dimension. - * - * @throws This property can throw when used. - */ - readonly heightRange: NumberRange; - /** - * @remarks - * Identifier of the dimension. - * - */ - readonly id: string; - /** - * @beta - * @remarks - * Creates an explosion at the specified location. - * - * This function can't be called in read-only mode. - * - * @param location - * The location of the explosion. - * @param radius - * Radius, in blocks, of the explosion to create. - * @param explosionOptions - * Additional configurable options for the explosion. - * @throws This function can throw errors. - * @example createExplosion.ts - * ```typescript - * const overworld = mc.world.getDimension("overworld"); - * - * log("Creating an explosion of radius 10."); - * overworld.createExplosion(targetLocation, 10); - * ``` - * @example createFireAndWaterExplosions.ts - * ```typescript - * const overworld = mc.world.getDimension("overworld"); - * - * const explosionLoc = { x: targetLocation.x + 0.5, y: targetLocation.y + 0.5, z: targetLocation.z + 0.5}; - * - * log("Creating an explosion of radius 15 that causes fire."); - * overworld.createExplosion(explosionLoc, 15, { causesFire: true }); - * - * const belowWaterLoc = { x: targetLocation.x + 3, y: targetLocation.y + 1,z: targetLocation.z + 3}; - * - * log("Creating an explosion of radius 10 that can go underwater."); - * overworld.createExplosion(belowWaterLoc, 10, { allowUnderwater: true }); - * ``` - * @example createNoBlockExplosion.ts - * ```typescript - * const overworld = mc.world.getDimension("overworld"); - * - * const explodeNoBlocksLoc = { - * x: Math.floor(targetLocation.x + 1), - * y: Math.floor(targetLocation.y + 2), - * z: Math.floor(targetLocation.z + 1) - * }; - * - * log("Creating an explosion of radius 15 that does not break blocks."); - * overworld.createExplosion(explodeNoBlocksLoc, 15, { breaksBlocks: false }); - * ``` - */ - createExplosion(location: Vector3, radius: number, explosionOptions?: ExplosionOptions): void; - /** - * @beta - * @remarks - * Fills an area between begin and end with block of type - * block. - * - * This function can't be called in read-only mode. - * - * @param begin - * The lower northwest starting corner of the area. - * @param end - * The upper southeast ending corner of the area. - * @param block - * Type of block to fill the volume with. - * @param options - * A set of additional options, such as a matching block to - * potentially replace this fill block with. - * @returns - * Returns number of blocks placed. - * @throws This function can throw errors. - */ - fillBlocks( - begin: Vector3, - end: Vector3, - block: BlockPermutation | BlockType | string, - options?: BlockFillOptions, - ): number; - /** - * @beta - * @remarks - * Returns a block instance at the given location. - * - * @param location - * The location at which to return a block. - * @returns - * Block at the specified location, or 'undefined' if asking - * for a block at an unloaded chunk. - * @throws - * PositionInUnloadedChunkError: Exception thrown when trying - * to interact with a Block object that isn't in a loaded and - * ticking chunk anymore - * - * PositionOutOfWorldBoundariesError: Exception thrown when - * trying to interact with a position outside of dimension - * height range - * - */ - getBlock(location: Vector3): Block | undefined; - /** - * @beta - * @remarks - * Gets the first block that intersects with a vector emanating - * from a location. - * - * @param location - * Location from where to initiate the ray check. - * @param direction - * Vector direction to cast the ray. - * @param options - * Additional options for processing this raycast query. - */ - getBlockFromRay(location: Vector3, direction: Vector3, options?: BlockRaycastOptions): BlockRaycastHit | undefined; - /** - * @beta - * @remarks - * Returns a set of entities based on a set of conditions - * defined via the EntityQueryOptions set of filter criteria. - * - * @param options - * Additional options that can be used to filter the set of - * entities returned. - * @returns - * An entity array. - * @throws This function can throw errors. - * @example bounceSkeletons.ts - * ```typescript - * let mobs = ["creeper", "skeleton", "sheep"]; - * - * // create some sample mob data - * for (let i = 0; i < 10; i++) { - * overworld.spawnEntity(mobs[i % mobs.length], targetLocation); - * } - * - * let eqo: mc.EntityQueryOptions = { - * type: "skeleton", - * }; - * - * for (let entity of overworld.getEntities(eqo)) { - * entity.applyKnockback(0, 0, 0, 1); - * } - * ``` - * @example tagsQuery.ts - * ```typescript - * let mobs = ["creeper", "skeleton", "sheep"]; - * - * // create some sample mob data - * for (let i = 0; i < 10; i++) { - * let mobTypeId = mobs[i % mobs.length]; - * let entity = overworld.spawnEntity(mobTypeId, targetLocation); - * entity.addTag("mobparty." + mobTypeId); - * } - * - * let eqo: mc.EntityQueryOptions = { - * tags: ["mobparty.skeleton"], - * }; - * - * for (let entity of overworld.getEntities(eqo)) { - * entity.kill(); - * } - * ``` - * @example testThatEntityIsFeatherItem.ts - * ```typescript - * const overworld = mc.world.getDimension("overworld"); - * - * const items = overworld.getEntities({ - * location: targetLocation, - * maxDistance: 20, - * }); - * - * for (const item of items) { - * const itemComp = item.getComponent("item") as mc.EntityItemComponent; - * - * if (itemComp) { - * if (itemComp.itemStack.typeId.endsWith("feather")) { - * log("Success! Found a feather", 1); - * } - * } - * } - * ``` - */ - getEntities(options?: EntityQueryOptions): Entity[]; - /** - * @beta - * @remarks - * Returns a set of entities at a particular location. - * - * @param location - * The location at which to return entities. - * @returns - * Zero or more entities at the specified location. - */ - getEntitiesAtBlockLocation(location: Vector3): Entity[]; - /** - * @beta - * @remarks - * Gets entities that intersect with a specified vector - * emanating from a location. - * - * @param options - * Additional options for processing this raycast query. - */ - getEntitiesFromRay(location: Vector3, direction: Vector3, options?: EntityRaycastOptions): EntityRaycastHit[]; - /** - * @beta - * @remarks - * Returns a set of players based on a set of conditions - * defined via the EntityQueryOptions set of filter criteria. - * - * @param options - * Additional options that can be used to filter the set of - * players returned. - * @returns - * A player array. - * @throws This function can throw errors. - */ - getPlayers(options?: EntityQueryOptions): Player[]; - /** - * @beta - * @remarks - * Runs a command synchronously using the context of the - * broader dimenion. - * - * This function can't be called in read-only mode. - * - * @param commandString - * Command to run. Note that command strings should not start - * with slash. - * @returns - * Returns a command result with a count of successful values - * from the command. - * @throws - * Throws an exception if the command fails due to incorrect - * parameters or command syntax, or in erroneous cases for the - * command. Note that in many cases, if the command does not - * operate (e.g., a target selector found no matches), this - * method will not throw an exception. - */ - runCommand(commandString: string): CommandResult; - /** - * @remarks - * Runs a particular command asynchronously from the context of - * the broader dimension. Note that there is a maximum queue - * of 128 asynchronous commands that can be run in a given - * tick. - * - * @param commandString - * Command to run. Note that command strings should not start - * with slash. - * @returns - * For commands that return data, returns a CommandResult with - * an indicator of command results. - * @throws - * Throws an exception if the command fails due to incorrect - * parameters or command syntax, or in erroneous cases for the - * command. Note that in many cases, if the command does not - * operate (e.g., a target selector found no matches), this - * method will not throw an exception. - */ - runCommandAsync(commandString: string): Promise; - /** - * @beta - * @remarks - * Sets the current weather within the dimension - * - * This function can't be called in read-only mode. - * - * @param weatherType - * Set the type of weather to apply. - * @param duration - * Sets the duration of the weather (in ticks). If no duration - * is provided, the duration will be set to a random duration - * between 300 and 900 seconds. - * @throws This function can throw errors. - */ - setWeather(weatherType: WeatherType, duration?: number): void; - /** - * @beta - * @remarks - * Creates a new entity (e.g., a mob) at the specified - * location. - * - * This function can't be called in read-only mode. - * - * @param identifier - * Identifier of the type of entity to spawn. If no namespace - * is specified, 'minecraft:' is assumed. - * @param location - * The location at which to create the entity. - * @returns - * Newly created entity at the specified location. - * @throws This function can throw errors. - * @example createOldHorse.ts - * ```typescript - * const overworld = mc.world.getDimension("overworld"); - * - * log("Create a horse and triggering the 'ageable_grow_up' event, ensuring the horse is created as an adult"); - * overworld.spawnEntity("minecraft:horse", targetLocation); - * ``` - * @example quickFoxLazyDog.ts - * ```typescript - * const overworld = mc.world.getDimension("overworld"); - * - * const fox = overworld.spawnEntity("minecraft:fox", { - * x: targetLocation.x + 1, - * y: targetLocation.y + 2, - * z: targetLocation.z + 3, - * }); - * - * fox.addEffect("speed", 10, { - * amplifier: 2, - * }); - * log("Created a fox."); - * - * const wolf = overworld.spawnEntity("minecraft:wolf", { - * x: targetLocation.x + 4, - * y: targetLocation.y + 2, - * z: targetLocation.z + 3, - * }); - * wolf.addEffect("slowness", 10, { - * amplifier: 2, - * }); - * wolf.isSneaking = true; - * log("Created a sneaking wolf.", 1); - * ``` - * @example triggerEvent.ts - * ```typescript - * const creeper = overworld.spawnEntity("minecraft:creeper", targetLocation); - * - * creeper.triggerEvent("minecraft:start_exploding_forced"); - * ``` - */ - spawnEntity(identifier: string, location: Vector3): Entity; - /** - * @beta - * @remarks - * Creates a new item stack as an entity at the specified - * location. - * - * This function can't be called in read-only mode. - * - * @param location - * The location at which to create the item stack. - * @returns - * Newly created item stack entity at the specified location. - * @throws This function can throw errors. - * @example itemStacks.ts - * ```typescript - * const overworld = mc.world.getDimension('overworld'); - * - * const oneItemLoc = { x: targetLocation.x + targetLocation.y + 3, y: 2, z: targetLocation.z + 1 }; - * const fiveItemsLoc = { x: targetLocation.x + 1, y: targetLocation.y + 2, z: targetLocation.z + 1 }; - * const diamondPickaxeLoc = { x: targetLocation.x + 2, y: targetLocation.y + 2, z: targetLocation.z + 4 }; - * - * const oneEmerald = new mc.ItemStack(mc.MinecraftItemTypes.Emerald, 1); - * const onePickaxe = new mc.ItemStack(mc.MinecraftItemTypes.DiamondPickaxe, 1); - * const fiveEmeralds = new mc.ItemStack(mc.MinecraftItemTypes.Emerald, 5); - * - * log(`Spawning an emerald at (${oneItemLoc.x}, ${oneItemLoc.y}, ${oneItemLoc.z})`); - * overworld.spawnItem(oneEmerald, oneItemLoc); - * - * log(`Spawning five emeralds at (${fiveItemsLoc.x}, ${fiveItemsLoc.y}, ${fiveItemsLoc.z})`); - * overworld.spawnItem(fiveEmeralds, fiveItemsLoc); - * - * log(`Spawning a diamond pickaxe at (${diamondPickaxeLoc.x}, ${diamondPickaxeLoc.y}, ${diamondPickaxeLoc.z})`); - * overworld.spawnItem(onePickaxe, diamondPickaxeLoc); - * ``` - * @example spawnItem.ts - * ```typescript - * const featherItem = new mc.ItemStack(mc.MinecraftItemTypes.Feather, 1); - * - * overworld.spawnItem(featherItem, targetLocation); - * log(`New feather created at ${targetLocation.x}, ${targetLocation.y}, ${targetLocation.z}!`); - * ``` - */ - spawnItem(itemStack: ItemStack, location: Vector3): Entity; - /** - * @beta - * @remarks - * Creates a new particle emitter at a specified location in - * the world. - * - * This function can't be called in read-only mode. - * - * @param effectName - * Identifier of the particle to create. - * @param location - * The location at which to create the particle emitter. - * @param molangVariables - * A set of optional, customizable variables that can be - * adjusted for this particle. - * @throws This function can throw errors. - * @example spawnParticle.ts - * ```typescript - * for (let i = 0; i < 100; i++) { - * const molang = new mc.MolangVariableMap(); - * - * molang.setColorRGB("variable.color", { red: Math.random(), green: Math.random(), blue: Math.random(), alpha: 1 }); - * - * let newLocation = { - * x: targetLocation.x + Math.floor(Math.random() * 8) - 4, - * y: targetLocation.y + Math.floor(Math.random() * 8) - 4, - * z: targetLocation.z + Math.floor(Math.random() * 8) - 4, - * }; - * overworld.spawnParticle("minecraft:colored_flame_particle", newLocation, molang); - * } - * ``` - */ - spawnParticle(effectName: string, location: Vector3, molangVariables?: MolangVariableMap): void; -} - -/** - * @beta - * Represents a type of dimension. - */ -export class DimensionType { - private constructor(); - readonly typeId: string; -} - -/** - * @beta - * Used for accessing all available dimension types. - */ -export class DimensionTypes { - private constructor(); - /** - * @remarks - * Retrieves a dimension type using a string-based identifier. - * - */ - static get(dimensionTypeId: string): DimensionType | undefined; - /** - * @remarks - * Retrieves an array of all dimension types. - * - */ - static getAll(): DimensionType[]; -} - -/** - * @beta - * Class used in conjunction with {@link PropertyRegistry} to - * define dynamic properties that can be used on entities of a - * specified type or at the global World- level. - */ -export class DynamicPropertiesDefinition { - /** - * @remarks - * Defines a boolean dynamic property. - * - * @throws This function can throw errors. - */ - defineBoolean(identifier: string, defaultValue?: boolean): DynamicPropertiesDefinition; - /** - * @remarks - * Defines a number dynamic property. - * - * @throws This function can throw errors. - */ - defineNumber(identifier: string, defaultValue?: number): DynamicPropertiesDefinition; - /** - * @remarks - * Defines a string dynamic property. - * - * @throws This function can throw errors. - */ - defineString(identifier: string, maxLength: number, defaultValue?: string): DynamicPropertiesDefinition; - /** - * @remarks - * Defines a new Vector3-based dynamic property. - * - * @param identifier - * Identifier of the Vector3 property. - * @param defaultValue - * Optional default starting Vector for this property. - * @throws This function can throw errors. - */ - defineVector(identifier: string, defaultValue?: Vector3): DynamicPropertiesDefinition; -} - -/** - * @beta - * Represents an effect - like poison - that has been added to - * an Entity. - */ -export class Effect { - private constructor(); - /** - * @remarks - * Gets an amplifier that may have been applied to this effect. - * Sample values range typically from 0 to 4. Example: The - * effect 'Jump Boost II' will have an amplifier value of 1. - * - * @throws This property can throw when used. - */ - readonly amplifier: number; - /** - * @remarks - * Gets the player-friendly name of this effect. - * - * @throws This property can throw when used. - */ - readonly displayName: string; - /** - * @remarks - * Gets the entire specified duration, in ticks, of this - * effect. There are 20 ticks per second. Use {@link - * TicksPerSecond} constant to convert between ticks and - * seconds. - * - * @throws This property can throw when used. - */ - readonly duration: number; - /** - * @remarks - * Gets the type id of this effect. - * - * @throws This property can throw when used. - */ - readonly typeId: string; - /** - * @remarks - * Returns whether an effect instance is available for use in - * this context. - * - */ - isValid(): boolean; -} - -/** - * @beta - * Contains information related to changes to an effect - like - * poison - being added to an entity. - */ -export class EffectAddAfterEvent { - private constructor(); - /** - * @remarks - * Additional properties and details of the effect. - * - * This property can't be edited in read-only mode. - * - */ - effect: Effect; - /** - * @remarks - * Additional variant number for the effect. - * - * This property can't be edited in read-only mode. - * - */ - effectState: number; - /** - * @remarks - * Entity that the effect is being added to. - * - * This property can't be edited in read-only mode. - * - */ - entity: Entity; -} - -/** - * @beta - * Manages callbacks that are connected to when an effect is - * added to an entity. - */ -export class EffectAddAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when an effect is added - * to an entity. - * - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: EffectAddAfterEvent) => void, - options?: EntityEventOptions, - ): (arg: EffectAddAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when an effect is added - * to an entity. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: EffectAddAfterEvent) => void): void; -} - -/** - * @beta - * Represents a type of effect - like poison - that can be - * applied to an entity. - */ -export class EffectType { - private constructor(); - /** - * @remarks - * Identifier name of this effect type. - * - * @returns - * Identifier of the effect type. - */ - getName(): string; -} - -/** - * @beta - * Represents a type of effect - like poison - that can be - * applied to an entity. - */ -export class EffectTypes { - private constructor(); - /** - * @remarks - * Effect type for the given identifier. - * - * This function can't be called in read-only mode. - * - * @returns - * Effect type for the given identifier or undefined if the - * effect does not exist. - */ - static get(identifier: string): EffectType | undefined; - /** - * @remarks - * Gets all effects. - * - * This function can't be called in read-only mode. - * - * @returns - * A list of all effects. - */ - static getAll(): EffectType[]; -} - -/** - * @beta - * This class represents a specific leveled enchantment that is - * applied to an item. - */ -export class Enchantment { - /** - * @remarks - * The level of this enchantment instance. - * - * This property can't be edited in read-only mode. - * - */ - level: number; - /** - * @remarks - * The enchantment type of this instance. - * - */ - readonly 'type': EnchantmentType; - /** - * @remarks - * Creates a new particular type of enchantment configuration. - * - * @param enchantmentType - * Type of the enchantment. - * @param level - * Level of the enchantment. - * @throws This function can throw errors. - */ - constructor(enchantmentType: EnchantmentType | string, level?: number); -} - -/** - * @beta - * This class represents a collection of enchantments that can - * be applied to an item. - */ -export class EnchantmentList implements Iterable { - /** - * @remarks - * The item slot/type that this collection is applied to. - * - */ - readonly slot: number; - /** - * @remarks - * Creates a new EnchantmentList. - * - */ - constructor(enchantmentSlot: number); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - [Symbol.iterator](): Iterator; - /** - * @remarks - * Attempts to add the enchantment to this collection. Returns - * true if successful. - * - * This function can't be called in read-only mode. - * - */ - addEnchantment(enchantment: Enchantment): boolean; - /** - * @remarks - * Returns whether or not the provided EnchantmentInstance can - * be added to this collection. - * - * This function can't be called in read-only mode. - * - */ - canAddEnchantment(enchantment: Enchantment): boolean; - /** - * @remarks - * Returns an enchantment associated with a type. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - getEnchantment(enchantmentType: EnchantmentType | string): Enchantment | undefined; - /** - * @remarks - * If this collection has an EnchantmentInstance with type, - * returns the level of the enchantment. Returns 0 if not - * present. - * - * @throws This function can throw errors. - */ - hasEnchantment(enchantmentType: EnchantmentType | string): number; - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - next(): IteratorResult; - /** - * @remarks - * Removes an EnchantmentInstance with type from this - * collection if present. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - removeEnchantment(enchantmentType: EnchantmentType | string): void; -} - -/** - * @beta - * This enum represents the item slot or type that an - * enchantment can be applied to. - */ -export class EnchantmentSlot { - private constructor(); - static readonly all = -1; - static readonly armorFeet = 4; - static readonly armorHead = 1; - static readonly armorLegs = 8; - static readonly armorTorso = 2; - static readonly axe = 512; - static readonly bow = 32; - static readonly carrotStick = 8192; - static readonly cosmeticHead = 262144; - static readonly crossbow = 65536; - static readonly elytra = 16384; - static readonly fishingRod = 4096; - static readonly flintsteel = 256; - static readonly gArmor = 15; - static readonly gDigging = 3648; - static readonly gTool = 131520; - static readonly hoe = 64; - static readonly none = 0; - static readonly pickaxe = 1024; - static readonly shears = 128; - static readonly shield = 131072; - static readonly shovel = 2048; - static readonly spear = 32768; - static readonly sword = 16; -} - -/** - * @beta - * Contains information on a type of enchantment. - */ -export class EnchantmentType { - private constructor(); - /** - * @remarks - * The name of the enchantment type. - * - */ - readonly id: string; - /** - * @remarks - * The maximum level this type of enchantment can have. - * - */ - readonly maxLevel: number; -} - -/** - * @beta - * Provides a list of enchantment types. - */ -export class EnchantmentTypes { - private constructor(); - /** - * @remarks - * Retrieves an enchantment with the specified identifier. - * - * @param enchantmentId - * Identifier of the enchantment. For example, - * "minecraft:flame". - * @returns - * If available, returns an EnchantmentType object that - * represents the specified enchantment. - */ - static get(enchantmentId: string): EnchantmentType | undefined; -} - -/** - * Represents the state of an entity (a mob, the player, or - * other moving objects like minecarts) in the world. - */ -export class Entity { - private constructor(); - /** - * @beta - * @remarks - * Dimension that the entity is currently within. - * - * @throws This property can throw when used. - */ - readonly dimension: Dimension; - /** - * @beta - * @remarks - * The distance an entity has fallen. The value is reset when - * the entity is teleported. The value is always 1 when gliding - * with Elytra. - * - * @throws This property can throw when used. - */ - readonly fallDistance: number; - /** - * @remarks - * Unique identifier of the entity. This identifier is intended - * to be consistent across loads of a world instance. No - * meaning should be inferred from the value and structure of - * this unique identifier - do not parse or interpret it. This - * property is accessible even if {@link Entity.isValid} is - * false. - * - */ - readonly id: string; - /** - * @beta - * @remarks - * Whether the entity is touching a climbable block. For - * example, a player next to a ladder or a spider next to a - * stone wall. - * - * @throws This property can throw when used. - */ - readonly isClimbing: boolean; - /** - * @beta - * @remarks - * Whether the entity has a fall distance greater than 0, or - * greater than 1 while gliding. - * - * @throws This property can throw when used. - */ - readonly isFalling: boolean; - /** - * @beta - * @remarks - * Whether any part of the entity is inside a water block. - * - * @throws This property can throw when used. - */ - readonly isInWater: boolean; - /** - * @beta - * @remarks - * Whether the entity is on top of a solid block. - * - * @throws This property can throw when used. - */ - readonly isOnGround: boolean; - /** - * @beta - * @remarks - * If true, the entity is currently sleeping. - * - * @throws This property can throw when used. - */ - readonly isSleeping: boolean; - /** - * @beta - * @remarks - * Whether the entity is sneaking - that is, moving more slowly - * and more quietly. - * - * This property can't be edited in read-only mode. - * - */ - isSneaking: boolean; - /** - * @beta - * @remarks - * Whether the entity is sprinting. For example, a player using - * the sprint action, an ocelot running away or a pig boosting - * with Carrot on a Stick. - * - * @throws This property can throw when used. - */ - readonly isSprinting: boolean; - /** - * @beta - * @remarks - * Whether the entity is in the swimming state. For example, a - * player using the swim action or a fish in water. - * - * @throws This property can throw when used. - */ - readonly isSwimming: boolean; - /** - * @beta - * @remarks - * Whether the entity reference that you have is valid or not. - * For example, an entity may be unloaded if it moves into a - * chunk that is unloaded, but may be reactivated if the chunk - * it is within gets reloaded. - * - */ - readonly lifetimeState: EntityLifetimeState; - /** - * @beta - * @remarks - * Current location of the entity. - * - * @throws This property can throw when used. - */ - readonly location: Vector3; - /** - * @beta - * @remarks - * Given name of the entity. - * - * This property can't be edited in read-only mode. - * - */ - nameTag: string; - /** - * @beta - * @remarks - * Returns a scoreboard identity that represents this entity. - * Will remain valid when the entity is killed. - * - */ - readonly scoreboardIdentity?: ScoreboardIdentity; - /** - * @beta - * @remarks - * Retrieves or sets an entity that is used as the target of - * AI-related behaviors, like attacking. - * - * @throws This property can throw when used. - */ - readonly target: Entity; - /** - * @remarks - * Identifier of the type of the entity - for example, - * 'minecraft:skeleton'. This property is accessible even if - * {@link Entity.isValid} is false. - * - */ - readonly typeId: string; - /** - * @beta - * @remarks - * Adds or updates an effect, like poison, to the entity. - * - * This function can't be called in read-only mode. - * - * @param effectType - * Type of effect to add to the entity. - * @param duration - * Amount of time, in ticks, for the effect to apply. There are - * 20 ticks per second. Use {@link TicksPerSecond} constant to - * convert between ticks and seconds. The value must be within - * the range [0, 20000000]. - * @param options - * Additional options for the effect. - * @returns - * Returns nothing if the effect was added or updated - * successfully. This can throw an error if the duration or - * amplifier are outside of the valid ranges, or if the effect - * does not exist. - * @throws This function can throw errors. - * @example addEffect.js - * ```typescript - * const villagerId = 'minecraft:villager_v2'; - * const villagerLoc: mc.Vector3 = { x: 1, y: 2, z: 1 }; - * const villager = test.spawn(villagerId, villagerLoc); - * const duration = 20; - * - * villager.addEffect(EffectTypes.get('poison'), duration, { amplifier: 1 }); - * ``` - * @example quickFoxLazyDog.ts - * ```typescript - * const overworld = mc.world.getDimension("overworld"); - * - * const fox = overworld.spawnEntity("minecraft:fox", { - * x: targetLocation.x + 1, - * y: targetLocation.y + 2, - * z: targetLocation.z + 3, - * }); - * - * fox.addEffect("speed", 10, { - * amplifier: 2, - * }); - * log("Created a fox."); - * - * const wolf = overworld.spawnEntity("minecraft:wolf", { - * x: targetLocation.x + 4, - * y: targetLocation.y + 2, - * z: targetLocation.z + 3, - * }); - * wolf.addEffect("slowness", 10, { - * amplifier: 2, - * }); - * wolf.isSneaking = true; - * log("Created a sneaking wolf.", 1); - * ``` - */ - addEffect(effectType: EffectType | string, duration: number, options?: EntityEffectOptions): void; - /** - * @beta - * @remarks - * Adds a specified tag to an entity. - * - * This function can't be called in read-only mode. - * - * @param tag - * Content of the tag to add. The tag must be less than 256 - * characters. - * @returns - * Returns true if the tag was added successfully. This can - * fail if the tag already exists on the entity. - * @throws This function can throw errors. - * @example tagsQuery.ts - * ```typescript - * let mobs = ["creeper", "skeleton", "sheep"]; - * - * // create some sample mob data - * for (let i = 0; i < 10; i++) { - * let mobTypeId = mobs[i % mobs.length]; - * let entity = overworld.spawnEntity(mobTypeId, targetLocation); - * entity.addTag("mobparty." + mobTypeId); - * } - * - * let eqo: mc.EntityQueryOptions = { - * tags: ["mobparty.skeleton"], - * }; - * - * for (let entity of overworld.getEntities(eqo)) { - * entity.kill(); - * } - * ``` - */ - addTag(tag: string): boolean; - /** - * @beta - * @remarks - * Applies a set of damage to an entity. - * - * This function can't be called in read-only mode. - * - * @param amount - * Amount of damage to apply. - * @param options - * Additional options about the source of damage, which may add - * additional effects or spur additional behaviors on this - * entity. - * @returns - * Whether the entity takes any damage. This can return false - * if the entity is invulnerable or if the damage applied is - * less than or equal to 0. - * @throws This function can throw errors. - * @example applyDamageThenHeal.ts - * ```typescript - * const skelly = overworld.spawnEntity("minecraft:skeleton", targetLocation); - * - * skelly.applyDamage(19); // skeletons have max damage of 20 so this is a near-death skeleton - * - * mc.system.runTimeout(() => { - * let health = skelly.getComponent("health") as mc.EntityHealthComponent; - * log("Skeleton health before heal: " + health.currentValue); - * health.resetToMaxValue(); - * log("Skeleton health after heal: " + health.currentValue); - * }, 20); - * ``` - */ - applyDamage(amount: number, options?: EntityApplyDamageByProjectileOptions | EntityApplyDamageOptions): boolean; - /** - * @beta - * @remarks - * Applies impulse vector to the current velocity of the - * entity. - * - * This function can't be called in read-only mode. - * - * @param vector - * Impulse vector. - * @throws This function can throw errors. - * @example applyImpulse.ts - * ```typescript - * const zombie = overworld.spawnEntity("minecraft:zombie", targetLocation); - * - * zombie.clearVelocity(); - * - * // throw the zombie up in the air - * zombie.applyImpulse({ x: 0, y: 0.5, z: 0 }); - * ``` - */ - applyImpulse(vector: Vector3): void; - /** - * @beta - * @remarks - * Applies impulse vector to the current velocity of the - * entity. - * - * This function can't be called in read-only mode. - * - * @param directionX - * X direction in horizontal plane. - * @param directionZ - * Z direction in horizontal plane. - * @param horizontalStrength - * Knockback strength for the horizontal vector. - * @param verticalStrength - * Knockback strength for the vertical vector. - * @throws This function can throw errors. - * @example bounceSkeletons.ts - * ```typescript - * let mobs = ["creeper", "skeleton", "sheep"]; - * - * // create some sample mob data - * for (let i = 0; i < 10; i++) { - * overworld.spawnEntity(mobs[i % mobs.length], targetLocation); - * } - * - * let eqo: mc.EntityQueryOptions = { - * type: "skeleton", - * }; - * - * for (let entity of overworld.getEntities(eqo)) { - * entity.applyKnockback(0, 0, 0, 1); - * } - * ``` - */ - applyKnockback(directionX: number, directionZ: number, horizontalStrength: number, verticalStrength: number): void; - /** - * @beta - * @remarks - * Sets the current velocity of the Entity to zero. Note that - * this method may not have an impact on Players. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - * @example applyImpulse.ts - * ```typescript - * const zombie = overworld.spawnEntity("minecraft:zombie", targetLocation); - * - * zombie.clearVelocity(); - * - * // throw the zombie up in the air - * zombie.applyImpulse({ x: 0, y: 0.5, z: 0 }); - * ``` - */ - clearVelocity(): void; - /** - * @beta - * @remarks - * Extinguishes the fire if the entity is on fire. Note that - * you can call getComponent('minecraft:onfire') and, if - * present, the entity is on fire. - * - * This function can't be called in read-only mode. - * - * @param useEffects - * Whether to show any visual effects connected to the - * extinguishing. - * @returns - * Returns whether the entity was on fire. - * @throws This function can throw errors. - * @example setOnFire.ts - * ```typescript - * const skelly = overworld.spawnEntity("minecraft:skeleton", targetLocation); - * - * skelly.setOnFire(20, true); - * - * mc.system.runTimeout(() => { - * let onfire = skelly.getComponent("onfire") as mc.EntityOnFireComponent; - * log(onfire.onFireTicksRemaining + " fire ticks remaining."); - * - * skelly.extinguishFire(true); - * log("Never mind. Fire extinguished."); - * }, 20); - * ``` - * @example teleport.ts - * ```typescript - * const cow = overworld.spawnEntity("minecraft:cow", targetLocation); - * - * mc.system.runTimeout(() => { - * cow.teleport( - * { x: targetLocation.x + 2, y: targetLocation.y + 2, z: targetLocation.z + 2 }, - * { - * facingLocation: targetLocation, - * } - * ); - * }, 20); - * ``` - */ - extinguishFire(useEffects?: boolean): boolean; - /** - * @beta - * @remarks - * Returns the first intersecting block from the direction that - * this entity is looking at. - * - * @param options - * Additional configuration options for the ray cast. - * @returns - * Returns the first intersecting block from the direction that - * this entity is looking at. - * @throws This function can throw errors. - */ - getBlockFromViewDirection(options?: BlockRaycastOptions): BlockRaycastHit | undefined; - /** - * @beta - * @remarks - * Gets a component (that represents additional capabilities) - * for an entity. - * - * @param componentId - * The identifier of the component (e.g., 'minecraft:rideable') - * to retrieve. If no namespace prefix is specified, - * 'minecraft:' is assumed. If the component is not present on - * the entity, undefined is returned. - * @returns - * Returns the component if it exists on the entity, otherwise - * undefined. - */ - getComponent(componentId: string): EntityComponent | undefined; - /** - * @beta - * @remarks - * Returns all components that are both present on this entity - * and supported by the API. - * - * @returns - * Returns all components that are both present on this entity - * and supported by the API. - */ - getComponents(): EntityComponent[]; - /** - * @beta - * @remarks - * Returns a property value. - * - * @param identifier - * The property identifier. - * @returns - * Returns the value for the property, or undefined if the - * property has not been set. - * @throws This function can throw errors. - */ - getDynamicProperty(identifier: string): boolean | number | string | Vector3 | undefined; - /** - * @beta - * @remarks - * Returns the effect for the specified EffectType on the - * entity, undefined if the effect is not present, or throws an - * error if the effect does not exist. - * - * @param effectType - * The effect identifier. - * @returns - * Effect object for the specified effect, undefined if the - * effect is not present, or throws an error if the effect does - * not exist. - * @throws This function can throw errors. - */ - getEffect(effectType: EffectType | string): Effect | undefined; - /** - * @beta - * @remarks - * Returns a set of effects applied to this entity. - * - * @returns - * List of effects. - * @throws This function can throw errors. - */ - getEffects(): Effect[]; - /** - * @beta - * @remarks - * Gets the entities that this entity is looking at by - * performing a ray cast from the view of this entity. - * - * @param options - * Additional configuration options for the ray cast. - * @returns - * Returns a set of entities from the direction that this - * entity is looking at. - * @throws This function can throw errors. - */ - getEntitiesFromViewDirection(options?: EntityRaycastOptions): EntityRaycastHit[]; - /** - * @beta - * @remarks - * Returns the current location of the head component of this - * entity. - * - * @returns - * Returns the current location of the head component of this - * entity. - * @throws This function can throw errors. - */ - getHeadLocation(): Vector3; - /** - * @beta - * @remarks - * Gets an entity Property value. If the property was set using - * the setProperty function within the same tick, the updated - * value will not be reflected until the subsequent tick. - * - * @param identifier - * The entity Property identifier. - * @returns - * Returns the current property value. For enum properties, a - * string is returned. For float and int properties, a number - * is returned. For undefined properties, undefined is - * returned. - * @throws - * Throws if the entity is invalid. - */ - getProperty(identifier: string): boolean | number | string | undefined; - /** - * @beta - * @remarks - * Returns the current rotation component of this entity. - * - * @returns - * Returns a Vec2 containing the rotation of this entity (in - * degrees). - * @throws This function can throw errors. - */ - getRotation(): Vector2; - /** - * @beta - * @remarks - * Returns all tags associated with an entity. - * - * @returns - * Returns the current rotation component of this entity. - * @throws This function can throw errors. - */ - getTags(): string[]; - /** - * @beta - * @remarks - * Returns the current velocity vector of the entity. - * - * @returns - * Returns the current velocity vector of the entity. - * @throws This function can throw errors. - * @example getFireworkVelocity.ts - * ```typescript - * const fireworkRocket = overworld.spawnEntity("minecraft:fireworks_rocket", targetLocation); - * - * mc.system.runTimeout(() => { - * let velocity = fireworkRocket.getVelocity(); - * - * log("Velocity of firework is: (x: " + velocity.x + ", y:" + velocity.y + ", z:" + velocity.z + ")"); - * }, 5); - * ``` - */ - getVelocity(): Vector3; - /** - * @beta - * @remarks - * Returns the current view direction of the entity. - * - * @returns - * Returns the current view direction of the entity. - * @throws This function can throw errors. - */ - getViewDirection(): Vector3; - /** - * @beta - * @remarks - * Returns true if the specified component is present on this - * entity. - * - * @param componentId - * The identifier of the component (e.g., 'minecraft:rideable') - * to retrieve. If no namespace prefix is specified, - * 'minecraft:' is assumed. - * @returns - * Returns true if the specified component is present on this - * entity. - */ - hasComponent(componentId: string): boolean; - /** - * @beta - * @remarks - * Returns whether an entity has a particular tag. - * - * @param tag - * Identifier of the tag to test for. - * @returns - * Returns whether an entity has a particular tag. - * @throws This function can throw errors. - */ - hasTag(tag: string): boolean; - /** - * @beta - * @remarks - * Returns whether the entity can be manipulated by script. A - * Player is considered valid when it's EntityLifetimeState is - * set to Loaded. - * - * @returns - * Whether the entity is valid. - */ - isValid(): boolean; - /** - * @beta - * @remarks - * Kills this entity. The entity will drop loot as normal. - * - * This function can't be called in read-only mode. - * - * @returns - * Returns true if entity can be killed (even if it is already - * dead), otherwise it returns false. - * @throws This function can throw errors. - * @example tagsQuery.ts - * ```typescript - * let mobs = ["creeper", "skeleton", "sheep"]; - * - * // create some sample mob data - * for (let i = 0; i < 10; i++) { - * let mobTypeId = mobs[i % mobs.length]; - * let entity = overworld.spawnEntity(mobTypeId, targetLocation); - * entity.addTag("mobparty." + mobTypeId); - * } - * - * let eqo: mc.EntityQueryOptions = { - * tags: ["mobparty.skeleton"], - * }; - * - * for (let entity of overworld.getEntities(eqo)) { - * entity.kill(); - * } - * ``` - */ - kill(): boolean; - /** - * @beta - * @remarks - * Cause the entity to play the given animation. - * - * This function can't be called in read-only mode. - * - * @param animationName - * The animation identifier. e.g. animation.creeper.swelling - * @param options - * Additional options to control the playback and transitions - * of the animation. - * @throws This function can throw errors. - */ - playAnimation(animationName: string, options?: PlayAnimationOptions): void; - /** - * @beta - * @remarks - * Immediately removes the entity from the world. The removed - * entity will not perform a death animation or drop loot upon - * removal. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - remove(): void; - /** - * @beta - * @remarks - * Removes a specified property. - * - * @param identifier - * The property identifier. - * @returns - * Returns whether the given property existed on the entity. - * @throws This function can throw errors. - */ - removeDynamicProperty(identifier: string): boolean; - /** - * @beta - * @remarks - * Removes the specified EffectType on the entity, or returns - * false if the effect is not present. - * - * This function can't be called in read-only mode. - * - * @param effectType - * The effect identifier. - * @returns - * Returns true if the effect has been removed. Returns false - * if the effect is not found or does not exist. - * @throws This function can throw errors. - */ - removeEffect(effectType: EffectType | string): boolean; - /** - * @beta - * @remarks - * Removes a specified tag from an entity. - * - * This function can't be called in read-only mode. - * - * @param tag - * Content of the tag to remove. - * @returns - * Returns whether the tag existed on the entity. - * @throws This function can throw errors. - */ - removeTag(tag: string): boolean; - /** - * @beta - * @remarks - * Resets an Entity Property back to its default value, as - * specified in the Entity's definition. This property change - * is not applied until the next tick. - * - * This function can't be called in read-only mode. - * - * @param identifier - * The Entity Property identifier. - * @returns - * Returns the default property value. For enum properties, a - * string is returned. For float and int properties, a number - * is returned. For undefined properties, undefined is - * returned. - * @throws - * Throws if the entity is invalid. - */ - resetProperty(identifier: string): boolean | number | string; - /** - * @beta - * @remarks - * Runs a synchronous command on the entity. - * - * This function can't be called in read-only mode. - * - * @param commandString - * The command string. Note: This should not include a leading - * forward slash. - * @returns - * A command result containing whether the command was - * successful. - * @throws This function can throw errors. - */ - runCommand(commandString: string): CommandResult; - /** - * @remarks - * Runs a particular command asynchronously from the context of - * this entity. Note that there is a maximum queue of 128 - * asynchronous commands that can be run in a given tick. - * - * @param commandString - * Command to run. Note that command strings should not start - * with slash. - * @returns - * For commands that return data, returns a JSON structure with - * command response values. - * @throws This function can throw errors. - */ - runCommandAsync(commandString: string): Promise; - /** - * @beta - * @remarks - * Sets a specified property to a value. - * - * @param identifier - * The property identifier. - * @param value - * Data value of the property to set. - * @throws This function can throw errors. - */ - setDynamicProperty(identifier: string, value: boolean | number | string | Vector3): void; - /** - * @beta - * @remarks - * Sets an entity on fire (if it is not in water or rain). Note - * that you can call getComponent('minecraft:onfire') and, if - * present, the entity is on fire. - * - * This function can't be called in read-only mode. - * - * @param seconds - * Length of time to set the entity on fire. - * @param useEffects - * Whether side-effects should be applied (e.g. thawing freeze) - * and other conditions such as rain or fire protection should - * be taken into consideration. - * @returns - * Whether the entity was set on fire. This can fail if seconds - * is less than or equal to zero, the entity is wet or the - * entity is immune to fire. - * @throws This function can throw errors. - * @example setOnFire.ts - * ```typescript - * const skelly = overworld.spawnEntity("minecraft:skeleton", targetLocation); - * - * skelly.setOnFire(20, true); - * - * mc.system.runTimeout(() => { - * let onfire = skelly.getComponent("onfire") as mc.EntityOnFireComponent; - * log(onfire.onFireTicksRemaining + " fire ticks remaining."); - * - * skelly.extinguishFire(true); - * log("Never mind. Fire extinguished."); - * }, 20); - * ``` - * @example teleport.ts - * ```typescript - * const cow = overworld.spawnEntity("minecraft:cow", targetLocation); - * - * mc.system.runTimeout(() => { - * cow.teleport( - * { x: targetLocation.x + 2, y: targetLocation.y + 2, z: targetLocation.z + 2 }, - * { - * facingLocation: targetLocation, - * } - * ); - * }, 20); - * ``` - */ - setOnFire(seconds: number, useEffects?: boolean): boolean; - /** - * @beta - * @remarks - * Sets an Entity Property to the provided value. This property - * change is not applied until the next tick. - * - * This function can't be called in read-only mode. - * - * @param identifier - * The Entity Property identifier. - * @param value - * The property value. The provided type must be compatible - * with the type specified in the entity's definition. - * @throws - * Throws if the entity is invalid. - * Throws if an invalid identifier is provided. - * Throws if the provided value type does not match the - * property type. - * Throws if the provided value is outside the expected range - * (int, float properties). - * Throws if the provided string value does not match the set - * of accepted enum values (enum properties - */ - setProperty(identifier: string, value: boolean | number | string): void; - /** - * @beta - * @remarks - * Sets the main rotation of the entity. - * - * This function can't be called in read-only mode. - * - * @param rotation - * The x and y rotation of the entity (in degrees). For most - * mobs, the x rotation controls the head tilt and the y - * rotation controls the body rotation. - * @throws This function can throw errors. - */ - setRotation(rotation: Vector2): void; - /** - * @beta - * @remarks - * Teleports the selected entity to a new location - * - * This function can't be called in read-only mode. - * - * @param location - * New location for the entity. - * @param teleportOptions - * Options regarding the teleport operation. - * @throws This function can throw errors. - * @example teleportMovement.ts - * ```typescript - * const pig = overworld.spawnEntity("minecraft:pig", targetLocation); - * - * let inc = 1; - * let runId = mc.system.runInterval(() => { - * pig.teleport( - * { x: targetLocation.x + inc / 4, y: targetLocation.y + inc / 4, z: targetLocation.z + inc / 4 }, - * { - * facingLocation: targetLocation, - * } - * ); - * - * if (inc > 100) { - * mc.system.clearRun(runId); - * } - * inc++; - * }, 4); - * ``` - */ - teleport(location: Vector3, teleportOptions?: TeleportOptions): void; - /** - * @beta - * @remarks - * Triggers an entity type event. For every entity, a number of - * events are defined in an entities' definition for key entity - * behaviors; for example, creepers have a - * minecraft:start_exploding type event. - * - * This function can't be called in read-only mode. - * - * @param eventName - * Name of the entity type event to trigger. If a namespace is - * not specified, minecraft: is assumed. - * @throws - * If the event is not defined in the definition of the entity, - * an error will be thrown. - * @example triggerEvent.ts - * ```typescript - * const creeper = overworld.spawnEntity("minecraft:creeper", targetLocation); - * - * creeper.triggerEvent("minecraft:start_exploding_forced"); - * ``` - */ - triggerEvent(eventName: string): void; - /** - * @beta - * @remarks - * Attempts to try a teleport, but may not complete the - * teleport operation (for example, if there are blocks at the - * destination.) - * - * This function can't be called in read-only mode. - * - * @param location - * Location to teleport the entity to. - * @param teleportOptions - * Options regarding the teleport operation. - * @returns - * Returns whether the teleport succeeded. This can fail if the - * destination chunk is unloaded or if the teleport would - * result in intersecting with blocks. - * @throws This function can throw errors. - */ - tryTeleport(location: Vector3, teleportOptions?: TeleportOptions): boolean; -} - -/** - * @beta - * When added, this component makes the entity spawn with a - * rider of the specified entityType. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityAddRiderComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * The type of entity that is added as a rider for this entity - * when spawned under certain conditions. - * - * @throws This property can throw when used. - */ - readonly entityType: string; - /** - * @remarks - * Optional spawn event to trigger on the rider when that rider - * is spawned for this entity. - * - * @throws This property can throw when used. - */ - readonly spawnEvent: string; - static readonly componentId = 'minecraft:addrider'; -} - -/** - * @beta - * Adds a timer for the entity to grow up. It can be - * accelerated by giving the entity the items it likes as - * defined by feedItems. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityAgeableComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Amount of time before the entity grows up, -1 for always a - * baby. - * - * @throws This property can throw when used. - */ - readonly duration: number; - /** - * @remarks - * Event to run when this entity grows up. - * - * @throws This property can throw when used. - */ - readonly growUp: Trigger; - static readonly componentId = 'minecraft:ageable'; - /** - * @remarks - * List of items that the entity drops when it grows up. - * - * @throws This function can throw errors. - */ - getDropItems(): string[]; - /** - * @remarks - * List of items that can be fed to the entity. Includes 'item' - * for the item name and 'growth' to define how much time it - * grows up by. - * - * @throws This function can throw errors. - */ - getFeedItems(): EntityDefinitionFeedItem[]; -} - -/** - * @beta - * This is a base abstract class for any entity component that - * centers around a number and can have a minimum, maximum, and - * default defined value. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityAttributeComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Current value of this attribute for this instance. - * - * @throws This property can throw when used. - */ - readonly currentValue: number; - /** - * @remarks - * Returns the default defined value for this attribute. - * - * @throws This property can throw when used. - */ - readonly defaultValue: number; - /** - * @remarks - * Returns the effective max of this attribute given any other - * ambient components or factors. - * - * @throws This property can throw when used. - */ - readonly effectiveMax: number; - /** - * @remarks - * Returns the effective min of this attribute given any other - * ambient components or factors. - * - * @throws This property can throw when used. - */ - readonly effectiveMin: number; - /** - * @remarks - * Resets the current value of this attribute to the defined - * default value. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - resetToDefaultValue(): void; - /** - * @remarks - * Resets the current value of this attribute to the maximum - * defined value. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - resetToMaxValue(): void; - /** - * @remarks - * Resets the current value of this attribute to the minimum - * defined value. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - resetToMinValue(): void; - /** - * @remarks - * Sets the current value of this attribute. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - setCurrentValue(value: number): boolean; -} - -/** - * @beta - * Base class for a family of entity movement events. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityBaseMovementComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Maximum turn rate for this movement modality of the mob. - * - * @throws This property can throw when used. - */ - readonly maxTurn: number; -} - -/** - * @beta - * Defines what blocks this entity can breathe in and gives - * them the ability to suffocate. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityBreathableComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * If true, this entity can breathe in air. - * - * @throws This property can throw when used. - */ - readonly breathesAir: boolean; - /** - * @remarks - * If true, this entity can breathe in lava. - * - * @throws This property can throw when used. - */ - readonly breathesLava: boolean; - /** - * @remarks - * If true, this entity can breathe in solid blocks. - * - * @throws This property can throw when used. - */ - readonly breathesSolids: boolean; - /** - * @remarks - * If true, this entity can breathe in water. - * - * @throws This property can throw when used. - */ - readonly breathesWater: boolean; - /** - * @remarks - * If true, this entity will have visible bubbles while in - * water. - * - * @throws This property can throw when used. - */ - readonly generatesBubbles: boolean; - /** - * @remarks - * Time in seconds to recover breath to maximum. - * - * @throws This property can throw when used. - */ - readonly inhaleTime: number; - /** - * @remarks - * Time in seconds between suffocation damage. - * - * @throws This property can throw when used. - */ - readonly suffocateTime: number; - /** - * @remarks - * Time in seconds the entity can hold its breath. - * - * @throws This property can throw when used. - */ - readonly totalSupply: number; - static readonly componentId = 'minecraft:breathable'; - /** - * @remarks - * List of blocks this entity can breathe in, in addition to - * the separate properties for classes of blocks. - * - * @throws This function can throw errors. - */ - getBreatheBlocks(): BlockPermutation[]; - /** - * @remarks - * List of blocks this entity can't breathe in. - * - * @throws This function can throw errors. - */ - getNonBreatheBlocks(): BlockPermutation[]; - /** - * @remarks - * Sets the current air supply of the entity. - * - * @param value - * New air supply for the entity. - * @throws This function can throw errors. - */ - setAirSupply(value: number): void; -} - -/** - * @beta - * When added, this component signifies that the entity can - * climb up ladders. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityCanClimbComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:can_climb'; -} - -/** - * @beta - * When added, this component signifies that the entity can - * fly, and the pathfinder won't be restricted to paths where a - * solid block is required underneath it. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityCanFlyComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:can_fly'; -} - -/** - * @beta - * When added, this component signifies that the entity can - * power jump like the horse does within Minecraft. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityCanPowerJumpComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:can_power_jump'; -} - -/** - * @beta - * Defines the entity's color. Only works on certain entities - * that have predefined color values (e.g., sheep, llama, - * shulker). - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityColorComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Value of this particular color. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - static readonly componentId = 'minecraft:color'; -} - -/** - * @beta - * Base class for downstream entity components. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityComponent extends Component { - private constructor(); - /** - * @beta - * @remarks - * The entity that owns this component. - * - */ - readonly entity: Entity; -} - -/** - * @beta - * As part of the Ageable component, represents a set of items - * that can be fed to an entity and the rate at which that - * causes them to grow. - */ -export class EntityDefinitionFeedItem { - private constructor(); - /** - * @remarks - * The amount by which an entity's age will increase when fed - * this item. Values usually range between 0 and 1. - * - */ - readonly growth: number; - /** - * @remarks - * Identifier of type of item that can be fed. If a namespace - * is not specified, 'minecraft:' is assumed. Example values - * include 'wheat' or 'golden_apple'. - * - */ - readonly item: string; -} - -/** - * @beta - * Contains data related to the death of an entity in the game. - */ -export class EntityDieAfterEvent { - private constructor(); - /** - * @remarks - * If specified, provides more information on the source of - * damage that caused the death of this entity. - * - */ - readonly damageSource: EntityDamageSource; - /** - * @remarks - * Now-dead entity object. - * - */ - readonly deadEntity: Entity; -} - -/** - * @beta - * Supports registering for an event that fires after an entity - * has died. - */ -export class EntityDieAfterEventSignal { - private constructor(); - /** - * @remarks - * Subscribes to an event that fires when an entity dies. - * - * This function can't be called in read-only mode. - * - * @param callback - * Function to call when an entity dies. - * @param options - * Additional filtering options for when the subscription - * fires. - * @returns - * Returns the closure that can be used in future downstream - * calls to unsubscribe. - */ - subscribe( - callback: (arg: EntityDieAfterEvent) => void, - options?: EntityEventOptions, - ): (arg: EntityDieAfterEvent) => void; - /** - * @remarks - * Stops this event from calling your function when an entity - * dies. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: EntityDieAfterEvent) => void): void; -} - -/** - * @beta - * Provides access to a mob's equipment slots. This component - * exists for all mob entities. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityEquippableComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:equippable'; - /** - * @remarks - * Gets the equipped item for the given EquipmentSlot. - * - * This function can't be called in read-only mode. - * - * @param equipmentSlot - * The equipment slot. e.g. "head", "chest", "offhand" - * @returns - * Returns the item equipped to the given EquipmentSlot. If - * empty, returns undefined. - * @throws This function can throw errors. - */ - getEquipment(equipmentSlot: EquipmentSlot): ItemStack | undefined; - /** - * @beta - * @remarks - * Gets the ContainerSlot corresponding to the given - * EquipmentSlot. - * - * This function can't be called in read-only mode. - * - * @param equipmentSlot - * The equipment slot. e.g. "head", "chest", "offhand". - * @returns - * Returns the ContainerSlot corresponding to the given - * EquipmentSlot. - * @throws This function can throw errors. - */ - getEquipmentSlot(equipmentSlot: EquipmentSlot): ContainerSlot; - /** - * @remarks - * Replaces the item in the given EquipmentSlot. - * - * This function can't be called in read-only mode. - * - * @param equipmentSlot - * The equipment slot. e.g. "head", "chest", "offhand". - * @param itemStack - * The item to equip. If undefined, clears the slot. - * @throws This function can throw errors. - */ - setEquipment(equipmentSlot: EquipmentSlot, itemStack?: ItemStack): boolean; -} - -/** - * @beta - * When added, this component signifies that this entity - * doesn't take damage from fire. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityFireImmuneComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:fire_immune'; -} - -/** - * @beta - * When added, this component signifies that this entity can - * float in liquid blocks. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityFloatsInLiquidComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:floats_in_liquid'; -} - -/** - * @beta - * Represents the flying speed of an entity. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityFlyingSpeedComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Current value of the flying speed of the associated entity. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - static readonly componentId = 'minecraft:flying_speed'; -} - -/** - * @beta - * Defines how much friction affects this entity. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityFrictionModifierComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Current value of the friction modifier of the associated - * entity. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - static readonly componentId = 'minecraft:friction_modifier'; -} - -/** - * @beta - * Sets the offset from the ground that the entity is actually - * at. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityGroundOffsetComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Value of this particular ground offset. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - static readonly componentId = 'minecraft:ground_offset'; -} - -/** - * @beta - * Defines the interactions with this entity for healing it. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityHealableComponent extends EntityComponent { - private constructor(); - /** - * @beta - * @remarks - * A set of filters that healable items might be associated - * with. - * - * @throws This property can throw when used. - */ - readonly filters: FilterGroup; - /** - * @remarks - * Determines if an item can be used regardless of the entity - * being at full health. - * - * @throws This property can throw when used. - */ - readonly forceUse: boolean; - static readonly componentId = 'minecraft:healable'; - /** - * @remarks - * A set of items that can specifically heal this entity. - * - * @returns - * Entity that this component is associated with. - * @throws This function can throw errors. - */ - getFeedItems(): FeedItem[]; -} - -/** - * @beta - * Contains information related to an entity when its health - * changes. Warning: don't change the health of an entity in - * this event, or it will cause an infinite loop! - */ -export class EntityHealthChangedAfterEvent { - private constructor(); - /** - * @remarks - * Entity whose health changed. - * - */ - readonly entity: Entity; - /** - * @remarks - * New health value of the entity. - * - */ - readonly newValue: number; - /** - * @remarks - * Old health value of the entity. - * - */ - readonly oldValue: number; -} - -/** - * @beta - * Manages callbacks that are connected to when the health of - * an entity changes. - */ -export class EntityHealthChangedAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when the health of an - * entity changes. - * - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: EntityHealthChangedAfterEvent) => void, - options?: EntityEventOptions, - ): (arg: EntityHealthChangedAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when the health of an - * entity changes. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: EntityHealthChangedAfterEvent) => void): void; -} - -/** - * @beta - * Defines the health properties of an entity. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityHealthComponent extends EntityAttributeComponent { - private constructor(); - static readonly componentId = 'minecraft:health'; -} - -/** - * @beta - * Contains information related to an entity hitting a block. - */ -export class EntityHitBlockAfterEvent { - private constructor(); - /** - * @remarks - * Face of the block that was hit. - * - */ - readonly blockFace: Direction; - /** - * @remarks - * Entity that made the attack. - * - */ - readonly damagingEntity: Entity; - /** - * @remarks - * Block that was hit by the attack. - * - */ - readonly hitBlock: Block; -} - -/** - * @beta - * Manages callbacks that are connected to when an entity hits - * a block. - */ -export class EntityHitBlockAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when an entity hits a - * block. - * - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: EntityHitBlockAfterEvent) => void, - options?: EntityEventOptions, - ): (arg: EntityHitBlockAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when an entity hits a - * block. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: EntityHitBlockAfterEvent) => void): void; -} - -/** - * @beta - * Contains information related to an entity hitting (melee - * attacking) another entity. - */ -export class EntityHitEntityAfterEvent { - private constructor(); - /** - * @remarks - * Entity that made a hit/melee attack. - * - */ - readonly damagingEntity: Entity; - /** - * @remarks - * Entity that was hit by the attack. - * - */ - readonly hitEntity: Entity; -} - -/** - * @beta - * Manages callbacks that are connected to when an entity makes - * a melee attack on another entity. - */ -export class EntityHitEntityAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when an entity hits - * another entity. - * - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: EntityHitEntityAfterEvent) => void, - options?: EntityEventOptions, - ): (arg: EntityHitEntityAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when an entity makes a - * melee attack on another entity. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: EntityHitEntityAfterEvent) => void): void; -} - -/** - * @beta - * Contains information related to an entity getting hurt. - */ -export class EntityHurtAfterEvent { - private constructor(); - /** - * @remarks - * Describes the amount of damage caused. - * - */ - readonly damage: number; - /** - * @remarks - * Source information on the entity that may have applied this - * damage. - * - */ - readonly damageSource: EntityDamageSource; - /** - * @remarks - * Entity that was hurt. - * - */ - readonly hurtEntity: Entity; -} - -/** - * @beta - * Manages callbacks that are connected to when an entity is - * hurt. - */ -export class EntityHurtAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when an entity is hurt. - * - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: EntityHurtAfterEvent) => void, - options?: EntityEventOptions, - ): (arg: EntityHurtAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when an entity is hurt. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: EntityHurtAfterEvent) => void): void; -} - -/** - * @beta - * Defines this entity's inventory properties. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityInventoryComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Number of slots that this entity can gain per extra - * strength. - * - * @throws This property can throw when used. - */ - readonly additionalSlotsPerStrength: number; - /** - * @remarks - * If true, the contents of this inventory can be removed by a - * hopper. - * - * @throws This property can throw when used. - */ - readonly canBeSiphonedFrom: boolean; - /** - * @remarks - * Defines the container for this entity. - * - * @throws This property can throw when used. - */ - readonly container: Container; - /** - * @remarks - * Type of container this entity has. - * - * @throws This property can throw when used. - */ - readonly containerType: string; - /** - * @remarks - * Number of slots the container has. - * - * @throws This property can throw when used. - */ - readonly inventorySize: number; - /** - * @remarks - * If true, the entity will not drop it's inventory on death. - * - * @throws This property can throw when used. - */ - readonly 'private': boolean; - /** - * @remarks - * If true, the entity's inventory can only be accessed by its - * owner or itself. - * - * @throws This property can throw when used. - */ - readonly restrictToOwner: boolean; - static readonly componentId = 'minecraft:inventory'; -} - -/** - * @beta - * When added, this component signifies that this entity is a - * baby. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsBabyComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_baby'; -} - -/** - * @beta - * When added, this component signifies that this entity is - * charged. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsChargedComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_charged'; -} - -/** - * @beta - * When added, this component signifies that this entity is - * currently carrying a chest. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsChestedComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_chested'; -} - -/** - * @beta - * When added, this component signifies that dyes can be used - * on this entity to change its color. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsDyeableComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_dyeable'; -} - -/** - * @beta - * When added, this component signifies that this entity can - * hide from hostile mobs while invisible. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsHiddenWhenInvisibleComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_hidden_when_invisible'; -} - -/** - * @beta - * When added, this component signifies that this entity this - * currently on fire. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsIgnitedComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_ignited'; -} - -/** - * @beta - * When added, this component signifies that this entity is an - * illager captain. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsIllagerCaptainComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_illager_captain'; -} - -/** - * @beta - * When added, this component signifies that this entity is - * currently saddled. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsSaddledComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_saddled'; -} - -/** - * @beta - * When added, this component signifies that this entity is - * currently shaking. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsShakingComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_shaking'; -} - -/** - * @beta - * When added, this component signifies that this entity is - * currently sheared. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsShearedComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_sheared'; -} - -/** - * @beta - * When added, this component signifies that this entity can be - * stacked. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsStackableComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_stackable'; -} - -/** - * @beta - * When added, this component signifies that this entity is - * currently stunned. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsStunnedComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_stunned'; -} - -/** - * @beta - * When added, this component signifies that this entity is - * currently tamed. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityIsTamedComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:is_tamed'; -} - -/** - * @beta - * If added onto the entity, this indicates that the entity - * represents a free-floating item in the world. Lets you - * retrieve the actual item stack contents via the itemStack - * property. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityItemComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Item stack represented by this entity in the world. - * - * @throws This property can throw when used. - */ - readonly itemStack: ItemStack; - static readonly componentId = 'minecraft:item'; -} - -/** - * @beta - * This type is usable for iterating over a set of entities. - * This means it can be used in statements like for...of - * statements, Array.from(iterator), and more. - */ -export class EntityIterator implements Iterable { - private constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - [Symbol.iterator](): Iterator; - /** - * @remarks - * Retrieves the next item in this iteration. The resulting - * IteratorResult contains .done and .value properties which - * can be used to see the next Entity in the iteration. - * - * This function can't be called in read-only mode. - * - */ - next(): IteratorResult; -} - -/** - * @beta - * Defines the base movement speed in lava of this entity. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityLavaMovementComponent extends EntityAttributeComponent { - private constructor(); - static readonly componentId = 'minecraft:lava_movement'; -} - -/** - * @beta - * Allows this entity to be leashed and defines the conditions - * and events for this entity when is leashed. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityLeashableComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Distance in blocks at which the 'spring' effect starts - * acting to keep this entity close to the entity that leashed - * it. - * - * @throws This property can throw when used. - */ - readonly softDistance: number; - static readonly componentId = 'minecraft:leashable'; - /** - * @remarks - * Leashes this entity to another entity. - * - * This function can't be called in read-only mode. - * - * @param leashHolder - * The entity to leash this entity to. - * @throws This function can throw errors. - */ - leash(leashHolder: Entity): void; - /** - * @remarks - * Unleashes this entity if it is leashed to another entity. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unleash(): void; -} - -/** - * @beta - * Contains data related to an entity loaded within the world. - * This could happen when an unloaded chunk is reloaded, or - * when an entity changes dimensions. - */ -export class EntityLoadAfterEvent { - private constructor(); - /** - * @remarks - * Entity that was loaded. - * - * This property can't be edited in read-only mode. - * - */ - entity: Entity; -} - -/** - * @beta - * Registers a script-based event handler for handling what - * happens when an entity loads. - */ -export class EntityLoadAfterEventSignal { - private constructor(); - /** - * @remarks - * Method to register an event handler for what happens when an - * entity loads. - * - * This function can't be called in read-only mode. - * - * @param callback - * Function that handles the load event. - */ - subscribe(callback: (arg: EntityLoadAfterEvent) => void): (arg: EntityLoadAfterEvent) => void; - /** - * @remarks - * Unregisters a method that was previously subscribed to the - * subscription event. - * - * This function can't be called in read-only mode. - * - * @param callback - * Original function that was passed into the subscribe event, - * that is to be unregistered. - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: EntityLoadAfterEvent) => void): void; -} - -/** - * @beta - * Additional variant value. Can be used to further - * differentiate variants. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityMarkVariantComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Value of the mark variant value for this entity. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - static readonly componentId = 'minecraft:mark_variant'; -} - -/** - * @beta - * Contains options for taming a rideable entity based on the - * entity that mounts it. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityMountTamingComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:tamemount'; - /** - * @remarks - * Sets this rideable entity as tamed. - * - * This function can't be called in read-only mode. - * - * @param showParticles - * Whether to show effect particles when this entity is tamed. - * @throws This function can throw errors. - */ - setTamed(showParticles: boolean): void; -} - -/** - * @beta - * When added, this movement control allows the mob to swim in - * water and walk on land. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityMovementAmphibiousComponent extends EntityBaseMovementComponent { - private constructor(); - static readonly componentId = 'minecraft:movement.amphibious'; -} - -/** - * @beta - * This component accents the movement of an entity. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityMovementBasicComponent extends EntityBaseMovementComponent { - private constructor(); - static readonly componentId = 'minecraft:movement.basic'; -} - -/** - * @beta - * Defines the general movement speed of this entity. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityMovementComponent extends EntityAttributeComponent { - private constructor(); - static readonly componentId = 'minecraft:movement'; -} - -/** - * @beta - * When added, this move control causes the mob to fly. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityMovementFlyComponent extends EntityBaseMovementComponent { - private constructor(); - static readonly componentId = 'minecraft:movement.fly'; -} - -/** - * @beta - * When added, this move control allows a mob to fly, swim, - * climb, etc. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityMovementGenericComponent extends EntityBaseMovementComponent { - private constructor(); - static readonly componentId = 'minecraft:movement.generic'; -} - -/** - * @beta - * When added, this movement control allows the mob to glide. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityMovementGlideComponent extends EntityBaseMovementComponent { - private constructor(); - /** - * @remarks - * Speed in effect when the entity is turning. - * - * @throws This property can throw when used. - */ - readonly speedWhenTurning: number; - /** - * @remarks - * Start speed during a glide. - * - * @throws This property can throw when used. - */ - readonly startSpeed: number; - static readonly componentId = 'minecraft:movement.glide'; -} - -/** - * @beta - * When added, this move control causes the mob to hover. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityMovementHoverComponent extends EntityBaseMovementComponent { - private constructor(); - static readonly componentId = 'minecraft:movement.hover'; -} - -/** - * @beta - * Move control that causes the mob to jump as it moves with a - * specified delay between jumps. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityMovementJumpComponent extends EntityBaseMovementComponent { - private constructor(); - static readonly componentId = 'minecraft:movement.jump'; -} - -/** - * @beta - * When added, this move control causes the mob to hop as it - * moves. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityMovementSkipComponent extends EntityBaseMovementComponent { - private constructor(); - static readonly componentId = 'minecraft:movement.skip'; -} - -/** - * @beta - * When added, this move control causes the mob to sway side to - * side giving the impression it is swimming. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityMovementSwayComponent extends EntityBaseMovementComponent { - private constructor(); - /** - * @remarks - * Amplitude of the sway motion. - * - * @throws This property can throw when used. - */ - readonly swayAmplitude: number; - /** - * @remarks - * Amount of sway frequency. - * - * @throws This property can throw when used. - */ - readonly swayFrequency: number; - static readonly componentId = 'minecraft:movement.sway'; -} - -/** - * @beta - * Allows this entity to generate paths that include vertical - * walls (for example, like Minecraft spiders do.) - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityNavigationClimbComponent extends EntityNavigationComponent { - private constructor(); - static readonly componentId = 'minecraft:navigation.climb'; -} - -/** - * @beta - * Allows this entity to generate paths that include vertical - * walls (for example, like Minecraft spiders do.) - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityNavigationComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Tells the pathfinder to avoid blocks that cause damage when - * finding a path. - * - * @throws This property can throw when used. - */ - readonly avoidDamageBlocks: boolean; - /** - * @remarks - * Tells the pathfinder to avoid portals (like nether portals) - * when finding a path. - * - * @throws This property can throw when used. - */ - readonly avoidPortals: boolean; - /** - * @remarks - * Whether or not the pathfinder should avoid tiles that are - * exposed to the sun when creating paths. - * - * @throws This property can throw when used. - */ - readonly avoidSun: boolean; - /** - * @remarks - * Tells the pathfinder to avoid water when creating a path. - * - * @throws This property can throw when used. - */ - readonly avoidWater: boolean; - /** - * @remarks - * Tells the pathfinder whether or not it can jump out of water - * (like a dolphin). - * - * @throws This property can throw when used. - */ - readonly canBreach: boolean; - /** - * @remarks - * Tells the pathfinder that it can path through a closed door - * and break it. - * - * @throws This property can throw when used. - */ - readonly canBreakDoors: boolean; - /** - * @remarks - * Tells the pathfinder whether or not it can float. - * - * @throws This property can throw when used. - */ - readonly canFloat: boolean; - /** - * @remarks - * Tells the pathfinder whether or not it can jump up blocks. - * - * @throws This property can throw when used. - */ - readonly canJump: boolean; - /** - * @remarks - * Tells the pathfinder that it can path through a closed door - * assuming the AI will open the door. - * - * @throws This property can throw when used. - */ - readonly canOpenDoors: boolean; - /** - * @remarks - * Tells the pathfinder that it can path through a closed iron - * door assuming the AI will open the door. - * - * @throws This property can throw when used. - */ - readonly canOpenIronDoors: boolean; - /** - * @remarks - * Whether a path can be created through a door. - * - * @throws This property can throw when used. - */ - readonly canPassDoors: boolean; - /** - * @remarks - * Tells the pathfinder that it can start pathing when in the - * air. - * - * @throws This property can throw when used. - */ - readonly canPathFromAir: boolean; - /** - * @remarks - * Tells the pathfinder whether or not it can travel on the - * surface of the lava. - * - * @throws This property can throw when used. - */ - readonly canPathOverLava: boolean; - /** - * @remarks - * Tells the pathfinder whether or not it can travel on the - * surface of the water. - * - * @throws This property can throw when used. - */ - readonly canPathOverWater: boolean; - /** - * @remarks - * Tells the pathfinder whether or not it will be pulled down - * by gravity while in water. - * - * @throws This property can throw when used. - */ - readonly canSink: boolean; - /** - * @remarks - * Tells the pathfinder whether or not it can path anywhere - * through water and plays swimming animation along that path. - * - * @throws This property can throw when used. - */ - readonly canSwim: boolean; - /** - * @remarks - * Tells the pathfinder whether or not it can walk on the - * ground outside water. - * - * @throws This property can throw when used. - */ - readonly canWalk: boolean; - /** - * @remarks - * Tells the pathfinder whether or not it can travel in lava - * like walking on ground. - * - * @throws This property can throw when used. - */ - readonly canWalkInLava: boolean; - /** - * @remarks - * Tells the pathfinder whether or not it can walk on the - * ground or go underwater. - * - * @throws This property can throw when used. - */ - readonly isAmphibious: boolean; -} - -/** - * @beta - * Allows this entity to generate paths by flying around the - * air like the regular Ghast. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityNavigationFloatComponent extends EntityNavigationComponent { - private constructor(); - static readonly componentId = 'minecraft:navigation.float'; -} - -/** - * @beta - * Allows this entity to generate paths in the air (for - * example, like Minecraft parrots do.) - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityNavigationFlyComponent extends EntityNavigationComponent { - private constructor(); - static readonly componentId = 'minecraft:navigation.fly'; -} - -/** - * @beta - * Allows this entity to generate paths by walking, swimming, - * flying and/or climbing around and jumping up and down a - * block. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityNavigationGenericComponent extends EntityNavigationComponent { - private constructor(); - static readonly componentId = 'minecraft:navigation.generic'; -} - -/** - * @beta - * Allows this entity to generate paths in the air (for - * example, like the Minecraft Bees do.) Keeps them from - * falling out of the skies and doing predictive movement. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityNavigationHoverComponent extends EntityNavigationComponent { - private constructor(); - static readonly componentId = 'minecraft:navigation.hover'; -} - -/** - * @beta - * Allows this entity to generate paths by walking around and - * jumping up and down a block like regular mobs. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityNavigationWalkComponent extends EntityNavigationComponent { - private constructor(); - static readonly componentId = 'minecraft:navigation.walk'; -} - -/** - * @beta - * When present on an entity, this entity is on fire. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityOnFireComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * The number of ticks remaining before the fire goes out. - * - */ - readonly onFireTicksRemaining: number; - static readonly componentId = 'minecraft:onfire'; -} - -/** - * @beta - * Sets the distance through which the entity can push through. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityPushThroughComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Value of the push through distances of this entity. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - static readonly componentId = 'minecraft:push_through'; -} - -/** - * @beta - * Data for an event that happens when an entity is removed - * from the world (for example, the entity is unloaded because - * it is not close to players.) - */ -export class EntityRemoveAfterEvent { - private constructor(); - /** - * @remarks - * Id of the entity that was removed. - * - */ - readonly removedEntityId: string; - /** - * @remarks - * Identifier of the type of the entity removed - for example, - * 'minecraft:skeleton'. - * - */ - readonly typeId: string; -} - -/** - * @beta - * Allows registration for an event that fires when an entity - * is removed from the game (for example, unloaded, or a few - * seconds after they are dead.) - */ -export class EntityRemoveAfterEventSignal { - private constructor(); - /** - * @remarks - * Will call your function every time an entity is removed from - * the game. - * - * This function can't be called in read-only mode. - * - * @param callback - * Function to call. - * @param options - * Additional filtering options for this event. - * @returns - * Returns a closure that can be used in subsequent unsubscribe - * operations. - */ - subscribe( - callback: (arg: EntityRemoveAfterEvent) => void, - options?: EntityEventOptions, - ): (arg: EntityRemoveAfterEvent) => void; - /** - * @remarks - * Unsubscribes your function from subsequent calls when an - * entity is removed. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: EntityRemoveAfterEvent) => void): void; -} - -/** - * @beta - * Data for an event that happens when an entity is being - * removed from the world (for example, the entity is unloaded - * because it is not close to players.) - */ -export class EntityRemoveBeforeEvent { - private constructor(); - /** - * @remarks - * Reference to an entity that is being removed. - * - */ - readonly removedEntity: Entity; -} - -/** - * @beta - * Allows registration for an event that fires when an entity - * is being removed from the game (for example, unloaded, or a - * few seconds after they are dead.) - */ -export class EntityRemoveBeforeEventSignal { - private constructor(); - /** - * @remarks - * Will call your function every time an entity is being - * removed from the game. - * - * This function can't be called in read-only mode. - * - * @param callback - * Function to call. - * @returns - * Returns a closure that can be used in subsequent unsubscribe - * operations. - */ - subscribe(callback: (arg: EntityRemoveBeforeEvent) => void): (arg: EntityRemoveBeforeEvent) => void; - /** - * @remarks - * Unsubscribes your function from subsequent calls when an - * entity is being removed. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: EntityRemoveBeforeEvent) => void): void; -} - -/** - * @beta - * When added, this component adds the capability that an - * entity can be ridden by another entity. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityRideableComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Zero-based index of the seat that can used to control this - * entity. - * - * @throws This property can throw when used. - */ - readonly controllingSeat: number; - /** - * @remarks - * Determines whether interactions are not supported if the - * entity is crouching. - * - * @throws This property can throw when used. - */ - readonly crouchingSkipInteract: boolean; - /** - * @remarks - * Set of text that should be displayed when a player is - * looking to ride on this entity (commonly with touch-screen - * controls). - * - * @throws This property can throw when used. - */ - readonly interactText: string; - /** - * @remarks - * If true, this entity will pull in entities that are in the - * correct family_types into any available seat. - * - * @throws This property can throw when used. - */ - readonly pullInEntities: boolean; - /** - * @remarks - * If true, this entity will be picked when looked at by the - * rider. - * - * @throws This property can throw when used. - */ - readonly riderCanInteract: boolean; - /** - * @remarks - * Number of seats for riders defined for this entity. - * - * @throws This property can throw when used. - */ - readonly seatCount: number; - static readonly componentId = 'minecraft:rideable'; - /** - * @remarks - * Adds an entity to this entity as a rider. - * - * This function can't be called in read-only mode. - * - * @param rider - * Entity that will become the rider of this entity. - * @returns - * True if the rider entity was successfully added. - * @throws This function can throw errors. - */ - addRider(rider: Entity): boolean; - /** - * @remarks - * Ejects the specified rider of this entity. - * - * This function can't be called in read-only mode. - * - * @param rider - * Entity that should be ejected from this entity. - * @throws This function can throw errors. - */ - ejectRider(rider: Entity): void; - /** - * @remarks - * Ejects all riders of this entity. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - ejectRiders(): void; - /** - * @remarks - * A string-list of entity types that this entity can support - * as riders. - * - * @throws This function can throw errors. - */ - getFamilyTypes(): string[]; - /** - * @remarks - * Gets a list of the all the entities currently riding this - * entity. - * - * @throws This function can throw errors. - */ - getRiders(): Entity[]; - /** - * @remarks - * Gets a list of positions and number of riders for each - * position for entities riding this entity. - * - * @throws This function can throw errors. - */ - getSeats(): Seat[]; -} - -/** - * @beta - * This component is added to any entity when it is riding - * another entity. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityRidingComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * The entity this entity is currently riding on. - * - * @throws This property can throw when used. - */ - readonly entityRidingOn: Entity; - static readonly componentId = 'minecraft:riding'; -} - -/** - * @beta - * Sets the entity's visual size. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityScaleComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Current value for the scale property set on entities. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - static readonly componentId = 'minecraft:scale'; -} - -/** - * @beta - * Skin Id value. Can be used to differentiate skins, such as - * base skins for villagers. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntitySkinIdComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Returns the value of the skin Id identifier of the entity. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - static readonly componentId = 'minecraft:skin_id'; -} - -/** - * @beta - * Contains data related to an entity spawning within the - * world. - */ -export class EntitySpawnAfterEvent { - private constructor(); - /** - * @remarks - * Initialization cause (Spawned, Born ...). - * - */ - readonly cause: EntityInitializationCause; - /** - * @remarks - * Entity that was spawned. - * - * This property can't be edited in read-only mode. - * - */ - entity: Entity; -} - -/** - * @beta - * Registers a script-based event handler for handling what - * happens when an entity spawns. - */ -export class EntitySpawnAfterEventSignal { - private constructor(); - /** - * @remarks - * Method to register an event handler for what happens when an - * entity spawns. - * - * This function can't be called in read-only mode. - * - * @param callback - * Function that handles the spawn event. - * @example runEntitySpawnEvent.ts - * ```typescript - * // register a new function that is called when a new entity is created. - * mc.world.afterEvents.entitySpawn.subscribe((entityEvent: mc.EntitySpawnAfterEvent) => { - * if (entityEvent && entityEvent.entity) { - * log(`New entity of type '${entityEvent.entity.typeId}' created!`, 1); - * } else { - * log(`The entity event didn't work as expected.`, -1); - * } - * }); - * - * mc.system.runTimeout(() => { - * createOldHorse(log, targetLocation); - * }, 20); - * ``` - */ - subscribe(callback: (arg: EntitySpawnAfterEvent) => void): (arg: EntitySpawnAfterEvent) => void; - /** - * @remarks - * Unregisters a method that was previously subscribed to the - * subscription event. - * - * This function can't be called in read-only mode. - * - * @param callback - * Original function that was passed into the subscribe event, - * that is to be unregistered. - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: EntitySpawnAfterEvent) => void): void; -} - -/** - * @beta - * Defines the entity's strength to carry items. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityStrengthComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Maximum strength of this entity, as defined in the entity - * type definition. - * - * @throws This property can throw when used. - */ - readonly max: number; - /** - * @remarks - * Current value of the strength component that has been set - * for entities. - * - * @throws This property can throw when used. - */ - readonly value: number; - static readonly componentId = 'minecraft:strength'; -} - -/** - * @beta - * Defines the rules for an entity to be tamed by the player. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityTameableComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * The chance of taming the entity with each item use between - * 0.0 and 1.0, where 1.0 is 100% - * - * @throws This property can throw when used. - */ - readonly probability: number; - static readonly componentId = 'minecraft:tameable'; - /** - * @remarks - * Returns a set of items that can be used to tame this entity. - * - * @throws This function can throw errors. - */ - getTameItems(): string[]; - /** - * @remarks - * Tames this entity. - * - * This function can't be called in read-only mode. - * - * @returns - * Returns true if the entity was tamed. - * @throws This function can throw errors. - */ - tame(): boolean; -} - -/** - * @beta - * Represents information about a type of entity. - */ -export class EntityType { - private constructor(); - /** - * @remarks - * Identifier of this entity type - for example, - * 'minecraft:skeleton'. - * - */ - readonly id: string; -} - -/** - * @beta - * An iterator that loops through available entity types. - */ -export class EntityTypeIterator implements Iterable { - private constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - [Symbol.iterator](): Iterator; - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - next(): IteratorResult; -} - -/** - * @beta - * Used for accessing all entity types currently available for - * use within the world. - */ -export class EntityTypes { - private constructor(); - /** - * @remarks - * Retrieves an entity type using a string-based identifier. - * - */ - static get(identifier: string): EntityType; - /** - * @remarks - * Retrieves an iterator of all entity types within this world. - * - */ - static getAll(): EntityTypeIterator; -} - -/** - * @beta - * Defines the general movement speed underwater of this - * entity. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityUnderwaterMovementComponent extends EntityAttributeComponent { - private constructor(); - static readonly componentId = 'minecraft:underwater_movement'; -} - -/** - * @beta - * Used to differentiate the component group of a variant of an - * entity from others. (e.g. ocelot, villager). - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityVariantComponent extends EntityComponent { - private constructor(); - /** - * @remarks - * Current value for variant for this entity, as specified via - * components. - * - * @throws This property can throw when used. - */ - readonly value: number; - static readonly componentId = 'minecraft:variant'; -} - -/** - * @beta - * When added, this component signifies that this entity wants - * to become a jockey. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class EntityWantsJockeyComponent extends EntityComponent { - private constructor(); - static readonly componentId = 'minecraft:wants_jockey'; -} - -/** - * @beta - * Contains information regarding an explosion that has - * happened. - */ -export class ExplosionAfterEvent { - private constructor(); - /** - * @remarks - * Dimension where the explosion has occurred. - * - */ - readonly dimension: Dimension; - /** - * @remarks - * Optional source of the explosion. - * - */ - readonly source?: Entity; - /** - * @remarks - * A collection of blocks impacted by this explosion event. - * - */ - getImpactedBlocks(): Vector3[]; -} - -/** - * @beta - * Manages callbacks that are connected to when an explosion - * occurs. - */ -export class ExplosionAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when an explosion - * occurs. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ExplosionAfterEvent) => void): (arg: ExplosionAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when an explosion - * occurs. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ExplosionAfterEvent) => void): void; -} - -/** - * @beta - * Contains information regarding an explosion that has - * happened. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class ExplosionBeforeEvent extends ExplosionAfterEvent { - private constructor(); - /** - * @remarks - * If set to true, cancels the explosion event. - * - */ - cancel: boolean; - /** - * @remarks - * Updates a collection of blocks impacted by this explosion - * event. - * - * @param blocks - * New list of blocks that are impacted by this explosion. - */ - setImpactedBlocks(blocks: Vector3[]): void; -} - -/** - * @beta - * Manages callbacks that are connected to before an explosion - * occurs. - */ -export class ExplosionBeforeEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when before an explosion - * occurs. The callback can optionally change or cancel - * explosion behavior. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ExplosionBeforeEvent) => void): (arg: ExplosionBeforeEvent) => void; - /** - * @remarks - * Removes a callback from being called from before when an - * explosion would occur. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ExplosionBeforeEvent) => void): void; -} - -/** - * @beta - * As part of the Healable component, represents a specific - * item that can be fed to an entity to cause health effects. - */ -export class FeedItem { - private constructor(); - /** - * @remarks - * The amount of health this entity gains when fed this item. - * This number is an integer starting at 0. Sample values can - * go as high as 40. - * - */ - readonly healAmount: number; - /** - * @remarks - * Identifier of type of item that can be fed. If a namespace - * is not specified, 'minecraft:' is assumed. Example values - * include 'wheat' or 'golden_apple'. - * - */ - readonly item: string; - /** - * @remarks - * As part of the Healable component, an optional collection of - * side effects that can occur from being fed an item. - * - */ - getEffects(): FeedItemEffect[]; -} - -/** - * @beta - * Represents an effect that is applied as a result of a food - * item being fed to an entity. - */ -export class FeedItemEffect { - private constructor(); - /** - * @remarks - * Gets an amplifier that may have been applied to this effect. - * Valid values are integers starting at 0 and up - but usually - * ranging between 0 and 4. - * - */ - readonly amplifier: number; - /** - * @remarks - * Chance that this effect is applied as a result of the entity - * being fed this item. Valid values range between 0 and 1. - * - */ - readonly chance: number; - /** - * @remarks - * Gets the duration, in ticks, of this effect. - * - */ - readonly duration: number; - /** - * @remarks - * Gets the identifier of the effect to apply. Example values - * include 'fire_resistance' or 'regeneration'. - * - */ - readonly name: string; -} - -/** - * @beta - * Represents a set of filters for when an event should occur. - */ -export class FilterGroup { - private constructor(); -} - -/** - * @beta - * Represents constants related to fluid containers. - */ -export class FluidContainer { - private constructor(); - /** - * @remarks - * Constant that represents the maximum fill level of a fluid - * container. - * - */ - static readonly maxFillLevel = 6; - /** - * @remarks - * Constant that represents the minimum fill level of a fluid - * container. - * - */ - static readonly minFillLevel = 0; -} - -/** - * @beta - * Provides an adaptable interface for callers to subscribe to - * an event that fires when a button is pushed. - */ -export class IButtonPushAfterEventSignal { - private constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ButtonPushAfterEvent) => void): (arg: ButtonPushAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ButtonPushAfterEvent) => void): void; -} - -/** - * @beta - * Provides an adaptable interface for callers to subscribe to - * an event that fires after a lever is used. - */ -export class ILeverActionAfterEventSignal { - private constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: LeverActionAfterEvent) => void): (arg: LeverActionAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: LeverActionAfterEvent) => void): void; -} - -/** - * @beta - * Provides an adaptable interface for callers to subscribe to - * an event that fires after a player joins a world. - */ -export class IPlayerJoinAfterEventSignal { - private constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: PlayerJoinAfterEvent) => void): (arg: PlayerJoinAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: PlayerJoinAfterEvent) => void): void; -} - -/** - * @beta - * Provides an adaptable interface for callers to subscribe to - * an event that fires after a player leaves a world. - */ -export class IPlayerLeaveAfterEventSignal { - private constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: PlayerLeaveAfterEvent) => void): (arg: PlayerLeaveAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: PlayerLeaveAfterEvent) => void): void; -} - -/** - * @beta - * Provides an adaptable interface for callers to subscribe to - * an event that fires after a player spawns. - */ -export class IPlayerSpawnAfterEventSignal { - private constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: PlayerSpawnAfterEvent) => void): (arg: PlayerSpawnAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: PlayerSpawnAfterEvent) => void): void; -} - -/** - * @beta - * Contains information related to a chargeable item completing - * being charged. - */ -export class ItemCompleteUseAfterEvent { - private constructor(); - /** - * @remarks - * Returns the item stack that has completed charging. - * - */ - readonly itemStack: ItemStack; - /** - * @remarks - * Returns the source entity that triggered this item event. - * - */ - readonly source: Player; - /** - * @remarks - * Returns the time, in ticks, for the remaining duration left - * before the charge completes its cycle. - * - */ - readonly useDuration: number; -} - -/** - * @beta - * Manages callbacks that are connected to the completion of - * charging for a chargeable item. - */ -export class ItemCompleteUseAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a chargeable item - * completes charging. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemCompleteUseAfterEvent) => void): (arg: ItemCompleteUseAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a chargeable item - * completes charging. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemCompleteUseAfterEvent) => void): void; -} - -/** - * @beta - * Base class for item components. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class ItemComponent extends Component { - private constructor(); -} - -/** - * @beta - * When present on an item, this item has a cooldown effect - * when used by entities. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class ItemCooldownComponent extends ItemComponent { - private constructor(); - /** - * @remarks - * Represents the cooldown category that this item is - * associated with. - * - * @throws This property can throw when used. - */ - readonly cooldownCategory: string; - /** - * @remarks - * Amount of time, in ticks, that remain for this item - * cooldown. - * - * @throws This property can throw when used. - */ - readonly cooldownTicks: number; - static readonly componentId = 'minecraft:cooldown'; - /** - * @remarks - * Starts a new cooldown period for this item. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - startCooldown(player: Player): void; -} - -/** - * @beta - * Manages callbacks that are connected to an item's definition - * and components changing. - */ -export class ItemDefinitionAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when an item's - * definition and components change. - * - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: ItemDefinitionTriggeredAfterEvent) => void, - ): (arg: ItemDefinitionTriggeredAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when an item's - * definition and components change. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemDefinitionTriggeredAfterEvent) => void): void; -} - -/** - * @beta - * Manages callbacks that are connected to an item's definition - * and components changing. - */ -export class ItemDefinitionBeforeEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when an item's - * definition and components change. - * - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: ItemDefinitionTriggeredBeforeEvent) => void, - ): (arg: ItemDefinitionTriggeredBeforeEvent) => void; - /** - * @remarks - * Removes a callback from being called when an item's - * definition and components change. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemDefinitionTriggeredBeforeEvent) => void): void; -} - -/** - * @beta - * Contains information related to a custom item having a data - * definition change being triggered. - */ -export class ItemDefinitionTriggeredAfterEvent { - private constructor(); - /** - * @remarks - * Name of the data-driven item event that is triggering this - * change. - * - */ - readonly eventName: string; - /** - * @remarks - * Related item stack that the definitional change has been - * triggered upon. - * - */ - itemStack: ItemStack; - /** - * @remarks - * Returns the source entity that triggered this item event. - * - */ - readonly source: Player; -} - -/** - * @beta - * Contains information related to a triggering of a custom - * item definition change. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class ItemDefinitionTriggeredBeforeEvent extends ItemDefinitionTriggeredAfterEvent { - private constructor(); - /** - * @remarks - * If set to true, will cancel the application of this item - * definition change. - * - */ - cancel: boolean; -} - -/** - * @beta - * When present on an item, this item can take damage in the - * process of being used. Note that this component only applies - * to data-driven items. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class ItemDurabilityComponent extends ItemComponent { - private constructor(); - /** - * @remarks - * Returns the current damage level of this particular item. - * - * This property can't be edited in read-only mode. - * - */ - damage: number; - /** - * @remarks - * Represents the amount of damage that this item can take - * before breaking. - * - * @throws This property can throw when used. - */ - readonly maxDurability: number; - static readonly componentId = 'minecraft:durability'; - /** - * @remarks - * Returns the maximum chance that this item would be damaged - * using the damageRange property, given an unbreaking level. - * - * This function can't be called in read-only mode. - * - * @param unbreaking - * Unbreaking factor to consider in factoring the damage - * chance. Incoming unbreaking parameter must be greater than - * 0. - * @throws This function can throw errors. - */ - getDamageChance(unbreaking?: number): number; - /** - * @remarks - * A range of numbers that describes the chance of the item - * losing durability. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - getDamageRange(): NumberRange; -} - -/** - * @beta - * When present on an item, this item has applied enchantment - * effects. Note that this component only applies to - * data-driven items. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class ItemEnchantsComponent extends ItemComponent { - private constructor(); - /** - * @remarks - * Returns a collection of the enchantments applied to this - * item stack. - * - * This property can't be edited in read-only mode. - * - */ - enchantments: EnchantmentList; - static readonly componentId = 'minecraft:enchantments'; - /** - * @remarks - * Removes all enchantments applied to this item stack. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - removeAllEnchantments(): void; -} - -/** - * @beta - * When present on an item, this item is consumable by - * entities. Note that this component only applies to - * data-driven items. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class ItemFoodComponent extends ItemComponent { - private constructor(); - /** - * @remarks - * If true, the player can always eat this item (even when not - * hungry). - * - * @throws This property can throw when used. - */ - readonly canAlwaysEat: boolean; - /** - * @remarks - * Represents how much nutrition this food item will give an - * entity when eaten. - * - * @throws This property can throw when used. - */ - readonly nutrition: number; - /** - * @remarks - * When an item is eaten, this value is used according to this - * formula (nutrition * saturation_modifier * 2) to apply a - * saturation buff. - * - * @throws This property can throw when used. - */ - readonly saturationModifier: number; - /** - * @remarks - * When specified, converts the active item to the one - * specified by this property. - * - * @throws This property can throw when used. - */ - readonly usingConvertsTo: string; - static readonly componentId = 'minecraft:food'; -} - -/** - * @beta - * Contains information related to a chargeable item when the - * player has finished using the item and released the build - * action. - */ -export class ItemReleaseUseAfterEvent { - private constructor(); - /** - * @remarks - * Returns the item stack that triggered this item event. - * - */ - readonly itemStack: ItemStack; - /** - * @remarks - * Returns the source entity that triggered this item event. - * - */ - readonly source: Player; - /** - * @remarks - * Returns the time, in ticks, for the remaining duration left - * before the charge completes its cycle. - * - */ - readonly useDuration: number; -} - -/** - * @beta - * Manages callbacks that are connected to the releasing of - * charging for a chargeable item. - */ -export class ItemReleaseUseAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a chargeable item - * is released from charging. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemReleaseUseAfterEvent) => void): (arg: ItemReleaseUseAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a chargeable item - * is released from charging. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemReleaseUseAfterEvent) => void): void; -} - -/** - * @beta - * Defines a collection of items. - */ -export class ItemStack { - /** - * @beta - * @remarks - * Number of the items in the stack. Valid values range between - * 1-255. The provided value will be clamped to the item's - * maximum stack size. - * - * This property can't be edited in read-only mode. - * - * @throws - * Throws if the value is outside the range of 1-255. - */ - amount: number; - /** - * @remarks - * Returns whether the item is stackable. An item is considered - * stackable if the item's maximum stack size is greater than 1 - * and the item does not contain any custom data or properties. - * - */ - readonly isStackable: boolean; - /** - * @beta - * @remarks - * Gets or sets whether the item is kept on death. - * - * This property can't be edited in read-only mode. - * - */ - keepOnDeath: boolean; - /** - * @beta - * @remarks - * Gets or sets the item's lock mode. The default value is - * `ItemLockMode.none`. - * - * This property can't be edited in read-only mode. - * - */ - lockMode: ItemLockMode; - /** - * @remarks - * The maximum stack size. This value varies depending on the - * type of item. For example, torches have a maximum stack size - * of 64, while eggs have a maximum stack size of 16. - * - */ - readonly maxAmount: number; - /** - * @beta - * @remarks - * Given name of this stack of items. The name tag is displayed - * when hovering over the item. Setting the name tag to an - * empty string or `undefined` will remove the name tag. - * - * This property can't be edited in read-only mode. - * - * @throws - * Throws if the length exceeds 255 characters. - */ - nameTag?: string; - /** - * @remarks - * The type of the item. - * - */ - readonly 'type': ItemType; - /** - * @remarks - * Identifier of the type of items for the stack. If a - * namespace is not specified, 'minecraft:' is assumed. - * Examples include 'wheat' or 'apple'. - * - */ - readonly typeId: string; - /** - * @remarks - * Creates a new instance of a stack of items for use in the - * world. - * - * @param itemType - * Type of item to create. See the {@link - * @minecraft/vanilla-data.MinecraftItemTypes} enumeration for - * a list of standard item types in Minecraft experiences. - * @param amount - * Number of items to place in the stack, between 1-255. The - * provided value will be clamped to the item's maximum stack - * size. Note that certain items can only have one item in the - * stack. - * @throws - * Throws if `itemType` is invalid, or if `amount` is outside - * the range of 1-255. - */ - constructor(itemType: ItemType | string, amount?: number); - /** - * @beta - * @remarks - * Creates an exact copy of the item stack, including any - * custom data or properties. - * - * @returns - * Returns a copy of this item stack. - */ - clone(): ItemStack; - /** - * @beta - * @remarks - * Get the list of block types this item can break in Adventure - * mode. - * - * This function can't be called in read-only mode. - * - */ - getCanDestroy(): string[]; - /** - * @beta - * @remarks - * Get the list of block types this item can be placed on in - * Adventure mode. - * - * This function can't be called in read-only mode. - * - */ - getCanPlaceOn(): string[]; - /** - * @remarks - * Gets a component (that represents additional capabilities) - * for an item stack. - * - * @param componentId - * The identifier of the component (e.g., 'minecraft:food') to - * retrieve. If no namespace prefix is specified, 'minecraft:' - * is assumed. If the component is not present on the item - * stack or doesn't exist, undefined is returned. - * @example durability.ts - * ```typescript - * // Get the maximum durability of a custom sword item - * const itemStack = new ItemStack("custom:sword"); - * const durability = itemStack.getComponent("minecraft:durability") as ItemDurabilityComponent; - * const maxDurability = durability.maxDurability; - * ``` - */ - getComponent(componentId: string): ItemComponent | undefined; - /** - * @remarks - * Returns all components that are both present on this item - * stack and supported by the API. - * - */ - getComponents(): ItemComponent[]; - /** - * @beta - * @remarks - * Returns the lore value - a secondary display string - for an - * ItemStack. - * - * @returns - * An array of lore lines. If the item does not have lore, - * returns an empty array. - */ - getLore(): string[]; - /** - * @beta - * @remarks - * Returns a set of tags associated with this item stack. - * - */ - getTags(): string[]; - /** - * @remarks - * Returns true if the specified component is present on this - * item stack. - * - * @param componentId - * The identifier of the component (e.g., 'minecraft:food') to - * retrieve. If no namespace prefix is specified, 'minecraft:' - * is assumed. - */ - hasComponent(componentId: string): boolean; - /** - * @beta - * @remarks - * Checks whether this item stack has a particular tag - * associated with it. - * - * @param tag - * Tag to search for. - * @returns - * True if the Item Stack has the tag associated with it, else - * false. - */ - hasTag(tag: string): boolean; - /** - * @remarks - * Returns whether this item stack can be stacked with the - * given `itemStack`. This is determined by comparing the item - * type and any custom data and properties associated with the - * item stacks. The amount of each item stack is not taken into - * consideration. - * - * @param itemStack - * ItemStack to check stacking compatability with. - * @returns - * True if the Item Stack is stackable with the itemStack - * passed in. - */ - isStackableWith(itemStack: ItemStack): boolean; - /** - * @beta - * @remarks - * The list of block types this item can break in Adventure - * mode. The block names are displayed in the item's tooltip. - * Setting the value to undefined will clear the list. - * - * This function can't be called in read-only mode. - * - * @param blockIdentifiers - * String list of block types that the item can destroy. - * @throws - * Throws if any of the provided block identifiers are invalid. - * @example example.ts - * ```typescript - * // Creates a diamond pickaxe that can destroy cobblestone and obsidian - * const specialPickaxe = new ItemStack("minecraft:diamond_pickaxe"); - * specialPickaxe.setCanDestroy(["minecraft:cobblestone", "minecraft:obsidian"]); - * ``` - */ - setCanDestroy(blockIdentifiers?: string[]): void; - /** - * @beta - * @remarks - * The list of block types this item can be placed on in - * Adventure mode. This is only applicable to block items. The - * block names are displayed in the item's tooltip. Setting the - * value to undefined will clear the list. - * - * This function can't be called in read-only mode. - * - * @param blockIdentifiers - * String list of block types that the item can be placed on. - * @throws - * Throws if any of the provided block identifiers are invalid. - * @example example.ts - * ```typescript - * // Creates a gold block that can be placed on grass and dirt - * const specialGoldBlock = new ItemStack("minecraft:gold_block"); - * specialPickaxe.setCanPlaceOn(["minecraft:grass", "minecraft:dirt"]); - * ``` - */ - setCanPlaceOn(blockIdentifiers?: string[]): void; - /** - * @beta - * @remarks - * Sets the lore value - a secondary display string - for an - * ItemStack. The lore list is cleared if set to an empty - * string or undefined. - * - * This function can't be called in read-only mode. - * - * @param loreList - * List of lore lines. Each element in the list represents a - * new line. The maximum lore line count is 20. The maximum - * lore line length is 50 characters. - * @throws This function can throw errors. - * @example diamondAwesomeSword.ts - * ```typescript - * const diamondAwesomeSword = new mc.ItemStack(mc.MinecraftItemTypes.diamondSword, 1); - * let players = mc.world.getAllPlayers(); - * - * diamondAwesomeSword.setLore(["§c§lDiamond Sword of Awesome§r", "+10 coolness", "§p+4 shiny§r"]); - * - * // hover over/select the item in your inventory to see the lore. - * const inventory = players[0].getComponent("inventory") as mc.EntityInventoryComponent; - * inventory.container.setItem(0, diamondAwesomeSword); - * - * let item = inventory.container.getItem(0); - * - * if (item) { - * let enchants = item.getComponent("minecraft:enchantments") as mc.ItemEnchantsComponent; - * let knockbackEnchant = new mc.Enchantment("knockback", 3); - * enchants.enchantments.addEnchantment(knockbackEnchant); - * } - * ``` - * @example multilineLore.ts - * ```typescript - * // Set the lore of an item to multiple lines of text - * const itemStack = new ItemStack("minecraft:diamond_sword"); - * itemStack.setLore(["Line 1", "Line 2", "Line 3"]); - * ``` - */ - setLore(loreList?: string[]): void; - /** - * @beta - * @remarks - * Triggers an item type event. For custom items, a number of - * events are defined in an items' definition for key item - * behaviors. - * - * This function can't be called in read-only mode. - * - * @param eventName - * Name of the item type event to trigger. If a namespace is - * not specified, minecraft: is assumed. - */ - triggerEvent(eventName: string): void; -} - -/** - * @beta - * Contains information related to a chargeable item starting - * to be charged. - */ -export class ItemStartUseAfterEvent { - private constructor(); - /** - * @remarks - * The impacted item stack that is starting to be charged. - * - */ - readonly itemStack: ItemStack; - /** - * @remarks - * Returns the source entity that triggered this item event. - * - */ - readonly source: Player; - /** - * @remarks - * Returns the time, in ticks, for the remaining duration left - * before the charge completes its cycle. - * - */ - readonly useDuration: number; -} - -/** - * @beta - * Manages callbacks that are connected to the start of - * charging for a chargeable item. - */ -export class ItemStartUseAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a chargeable item - * starts charging. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemStartUseAfterEvent) => void): (arg: ItemStartUseAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a chargeable item - * starts charging. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemStartUseAfterEvent) => void): void; -} - -/** - * @beta - * Contains information related to an item being used on a - * block. This event fires when a player presses the the Use - * Item / Place Block button to successfully use an item or - * place a block. Fires for the first block that is interacted - * with when performing a build action. Note: This event cannot - * be used with Hoe or Axe items. - */ -export class ItemStartUseOnAfterEvent { - private constructor(); - /** - * @remarks - * The block that the item is used on. - * - */ - readonly block: Block; - /** - * @remarks - * The face of the block that an item is being used on. - * - */ - readonly blockFace: Direction; - /** - * @remarks - * The impacted item stack that is starting to be used. - * - */ - readonly itemStack: ItemStack; - /** - * @remarks - * Returns the source entity that triggered this item event. - * - */ - readonly source: Player; -} - -/** - * @beta - * Manages callbacks that are connected to an item starting - * being used on a block event. - */ -export class ItemStartUseOnAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when an item is used on - * a block. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemStartUseOnAfterEvent) => void): (arg: ItemStartUseOnAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when an item is used on - * a block. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemStartUseOnAfterEvent) => void): void; -} - -/** - * @beta - * Contains information related to a chargeable item has - * finished an items use cycle, or when the player has released - * the use action with the item. - */ -export class ItemStopUseAfterEvent { - private constructor(); - /** - * @remarks - * The impacted item stack that is stopping being charged. - * - */ - readonly itemStack: ItemStack; - /** - * @remarks - * Returns the source entity that triggered this item event. - * - */ - readonly source: Player; - /** - * @remarks - * Returns the time, in ticks, for the remaining duration left - * before the charge completes its cycle. - * - */ - readonly useDuration: number; -} - -/** - * @beta - * Manages callbacks that are connected to the stopping of - * charging for an item that has a registered - * minecraft:chargeable component. - */ -export class ItemStopUseAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a chargeable item - * stops charging. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemStopUseAfterEvent) => void): (arg: ItemStopUseAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a chargeable item - * stops charging. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemStopUseAfterEvent) => void): void; -} - -/** - * @beta - * Contains information related to an item that has stopped - * being used on a block. This event fires when a player - * successfully uses an item or places a block by pressing the - * Use Item / Place Block button. If multiple blocks are - * placed, this event will only occur once at the beginning of - * the block placement. Note: This event cannot be used with - * Hoe or Axe items. - */ -export class ItemStopUseOnAfterEvent { - private constructor(); - /** - * @remarks - * The block that the item is used on. - * - */ - readonly block: Block; - /** - * @remarks - * The impacted item stack that is being used on a block. - * - */ - readonly itemStack?: ItemStack; - /** - * @remarks - * Returns the source entity that triggered this item event. - * - */ - readonly source: Player; -} - -/** - * @beta - * Manages callbacks that are connected to an item stops used - * on a block event. - */ -export class ItemStopUseOnAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when an item stops being - * used on a block. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemStopUseOnAfterEvent) => void): (arg: ItemStopUseOnAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when an item is used on - * a block. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemStopUseOnAfterEvent) => void): void; -} - -/** - * @beta - * Represents the type of an item - for example, Wool. - */ -export class ItemType { - private constructor(); - /** - * @remarks - * Returns the identifier of the item type - for example, - * 'minecraft:apple'. - * - */ - readonly id: string; -} - -/** - * @beta - * Returns the set of item types registered within Minecraft. - */ -export class ItemTypes { - private constructor(); - /** - * @remarks - * Returns a specific item type, if available within Minecraft. - * - */ - static get(itemId: string): ItemType; - /** - * @remarks - * Retrieves all available item types registered within - * Minecraft. - * - */ - static getAll(): ItemType[]; -} - -/** - * @beta - * Contains information related to an item being used. This - * event fires when an item is successfully used by a player. - */ -export class ItemUseAfterEvent { - private constructor(); - /** - * @remarks - * The impacted item stack that is being used. - * - */ - itemStack: ItemStack; - /** - * @remarks - * Returns the source entity that triggered this item event. - * - */ - readonly source: Player; -} - -/** - * @beta - * Manages callbacks that are connected to an item use event. - */ -export class ItemUseAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when an item is used. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemUseAfterEvent) => void): (arg: ItemUseAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when an item is used. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemUseAfterEvent) => void): void; -} - -/** - * @beta - * Contains information related to an item being used. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class ItemUseBeforeEvent extends ItemUseAfterEvent { - private constructor(); - /** - * @remarks - * If set to true, this will cancel the item use behavior. - * - */ - cancel: boolean; -} - -/** - * @beta - * Manages callbacks that fire before an item is used. - */ -export class ItemUseBeforeEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called before an item is used. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemUseBeforeEvent) => void): (arg: ItemUseBeforeEvent) => void; - /** - * @remarks - * Removes a callback from being called before an item is used. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemUseBeforeEvent) => void): void; -} - -/** - * @beta - * Contains information related to an item being used on a - * block. This event fires when an item is successfully used on - * a block by a player. - */ -export class ItemUseOnAfterEvent { - private constructor(); - /** - * @remarks - * The block that the item is used on. - * - */ - readonly block: Block; - /** - * @remarks - * The face of the block that an item is being used on. - * - */ - readonly blockFace: Direction; - /** - * @remarks - * Location relative to the bottom north-west corner of the - * block where the item is placed. - * - */ - readonly faceLocation: Vector3; - /** - * @remarks - * The impacted item stack that is being used on a block. - * - */ - readonly itemStack: ItemStack; - /** - * @remarks - * Returns the source entity that triggered this item event. - * - */ - readonly source: Player; -} - -/** - * @beta - * Manages callbacks that are connected to an item being used - * on a block event. - */ -export class ItemUseOnAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when an item is used on - * a block. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemUseOnAfterEvent) => void): (arg: ItemUseOnAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when an item is used on - * a block. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemUseOnAfterEvent) => void): void; -} - -/** - * @beta - * Contains information related to an item being used on a - * block. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class ItemUseOnBeforeEvent extends ItemUseOnAfterEvent { - private constructor(); - /** - * @remarks - * If set to true, this will cancel the item use behavior. - * - */ - cancel: boolean; -} - -/** - * @beta - * Manages callbacks that fire before an item being used on a - * block event. - */ -export class ItemUseOnBeforeEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called before an item is used - * on a block. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemUseOnBeforeEvent) => void): (arg: ItemUseOnBeforeEvent) => void; - /** - * @remarks - * Removes a callback from being called before an item is used - * on a block. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemUseOnBeforeEvent) => void): void; -} - -/** - * @beta - * Contains information related to changes to a lever - * activating or deactivating. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class LeverActionAfterEvent extends BlockEvent { - private constructor(); - /** - * @remarks - * True if the lever is activated (that is, transmitting - * power). - * - */ - readonly isPowered: boolean; - /** - * @remarks - * Optional player that triggered the lever activation. - * - */ - readonly player: Player; -} - -/** - * @beta - * Manages callbacks that are connected to lever moves - * (activates or deactivates). - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class LeverActionAfterEventSignal extends ILeverActionAfterEventSignal { - private constructor(); -} - -/** - * @beta - * A specific currently-internal event used for passing - * messages from client to server. - */ -export class MessageReceiveAfterEvent { - private constructor(); - /** - * @remarks - * The message identifier. - * - */ - readonly id: string; - /** - * @remarks - * The message. - * - */ - readonly message: string; - /** - * @remarks - * The player who sent the message. - * - */ - readonly player: Player; -} - -/** - * DEPRECATED - * Use @minecraft/vanilla-data.MinecraftDimensionTypes - * A collection of default Minecraft dimension types. - */ -export class MinecraftDimensionTypes { - private constructor(); - /** - * @remarks - * The Nether is a collection of biomes separate from the - * Overworld, including Soul Sand Valleys and Crimson forests. - * Nether fortresses contain exclusive resources. Mobs such as - * Blaze, Hoglins, Piglins, and Ghasts congregate here. - * - */ - static readonly nether = 'minecraft:nether'; - /** - * @remarks - * The overworld is a collection of biomes, including forests, - * plains, jungles, mountains, deserts, taiga, and more. This - * is the default starter dimension for Minecraft. Mobs such as - * Axolotl, Cows, Creepers, and Zombies congregate here. - * - */ - static readonly overworld = 'minecraft:overworld'; - /** - * @remarks - * The End is separate from the Overworld and the Nether and is - * generated whenever you create an End portal. Here, a giant - * center island is surrounded by several smaller areas and - * islands. You can find Endermen here. End midlands are larger - * areas that transition you from the center to the outer edges - * of the End. They contain Shulkers, Endermen, End gateway - * portals, and End cities. End gateway portals are commonly - * found at the outermost edge of the void. You usually find - * End barrens toward the edges of the main areas or land in - * the End. - * - */ - static readonly theEnd = 'minecraft:the_end'; -} - -/** - * @beta - * Contains a set of additional variable values for further - * defining how rendering and animations function. - */ -export class MolangVariableMap { - /** - * @remarks - * Adds the following variables to Molang: - * - `.r` - Red color value [0-1] - * - `.g` - Green color value [0-1] - * - `.b` - Blue color value [0-1] - * - * @throws This function can throw errors. - */ - setColorRGB(variableName: string, color: RGB): void; - /** - * @remarks - * Adds the following variables to Molang: - * - `.r` - Red color value [0-1] - * - `.g` - Green color value [0-1] - * - `.b` - Blue color value [0-1] - * - `.a` - Alpha (transparency) color value - * [0-1] - * - * @throws This function can throw errors. - */ - setColorRGBA(variableName: string, color: RGBA): void; - setFloat(variableName: string, number: number): void; - /** - * @remarks - * Adds the following variables to Molang: - * - `.speed` - Speed number provided - * - `.direction_x` - X value from the {@link - * Vector3} provided - * - `.direction_y` - Y value from the {@link - * Vector3} provided - * - `.direction_z` - Z value from the {@link - * Vector3} provided - * - * @throws This function can throw errors. - */ - setSpeedAndDirection(variableName: string, speed: number, direction: Vector3): void; - /** - * @remarks - * Adds the following variables to Molang: - * - `.x` - X value from the {@link Vector3} - * provided - * - `.y` - Y value from the {@link Vector3} - * provided - * - `.z` - Z value from the {@link Vector3} - * provided - * - * @throws This function can throw errors. - */ - setVector3(variableName: string, vector: Vector3): void; -} - -/** - * @beta - * Contains data resulting from a navigation operation, - * including whether the navigation is possible and the path of - * navigation. - */ -export class NavigationResult { - private constructor(); - /** - * @remarks - * Whether the navigation result contains a full path, - * including to the requested destination. - * - */ - readonly isFullPath: boolean; - /** - * @remarks - * A set of block locations that comprise the navigation route. - * - */ - getPath(): Vector3[]; -} - -/** - * @beta - * Contains information related to changes to a piston - * expanding or retracting. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class PistonActivateAfterEvent extends BlockEvent { - private constructor(); - /** - * @remarks - * True if the piston is the process of expanding. - * - */ - readonly isExpanding: boolean; - /** - * @remarks - * Contains additional properties and details of the piston. - * - */ - readonly piston: BlockPistonComponent; -} - -/** - * @beta - * Manages callbacks that are connected to piston activations. - */ -export class PistonActivateAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a piston expands or - * retracts. - * - * This function can't be called in read-only mode. - * - * @example pistonAfterEvent.ts - * ```typescript - * // set up a couple of piston blocks - * let piston = overworld.getBlock(targetLocation); - * let button = overworld.getBlock({ x: targetLocation.x, y: targetLocation.y + 1, z: targetLocation.z }); - * - * if (piston === undefined || button === undefined) { - * log("Could not find block at location."); - * return -1; - * } - * - * piston.setPermutation(mc.BlockPermutation.resolve('piston').withState('facing_direction', 3)); - * button.setPermutation(mc.BlockPermutation.resolve('acacia_button').withState('facing_direction', 1)); - * - * mc.world.afterEvents.pistonActivate.subscribe((pistonEvent: mc.PistonActivateAfterEvent) => { - * let eventLoc = pistonEvent.piston.block.location; - * - * if (eventLoc.x === targetLocation.x && eventLoc.y === targetLocation.y && eventLoc.z === targetLocation.z) { - * log( - * "Piston event at " + - * mc.system.currentTick + - * (pistonEvent.piston.isMoving ? " Moving" : "") + - * (pistonEvent.piston.isExpanding ? " Expanding" : "") + - * (pistonEvent.piston.isExpanded ? " Expanded" : "") + - * (pistonEvent.piston.isRetracting ? " Retracting" : "") + - * (pistonEvent.piston.isRetracted ? " Retracted" : "") - * ); - * } - * }); - * ``` - * @example pistonEvent.ts - * ```typescript - * let canceled = false; - * - * const pistonLoc: mc.Vector3 = { - * x: Math.floor(targetLocation.x) + 1, - * y: Math.floor(targetLocation.y) + 2, - * z: Math.floor(targetLocation.z) + 1, - * }; - * - * const pistonCallback = mc.world.beforeEvents.pistonActivate.subscribe((pistonEvent: mc.PistonActivateBeforeEvent) => { - * if (pistonEvent.piston.location.equals(pistonLoc)) { - * log("Cancelling piston event"); - * pistonEvent.cancel = true; - * canceled = true; - * } - * }); - * - * ``` - */ - subscribe(callback: (arg: PistonActivateAfterEvent) => void): (arg: PistonActivateAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a piston expands - * or retracts. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: PistonActivateAfterEvent) => void): void; -} - -/** - * @beta - * Contains information related to changes before a piston - * expands or retracts. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class PistonActivateBeforeEvent extends BlockEvent { - private constructor(); - /** - * @remarks - * If this is set to true within an event handler, the piston - * activation is canceled. - * - */ - cancel: boolean; - /** - * @remarks - * True if the piston is the process of expanding. - * - */ - readonly isExpanding: boolean; - /** - * @remarks - * Contains additional properties and details of the piston. - * - */ - readonly piston: BlockPistonComponent; -} - -/** - * @beta - * Manages callbacks that are connected to an event that fires - * before a piston is activated. - */ -export class PistonActivateBeforeEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called before a piston expands - * or retracts. - * - * This function can't be called in read-only mode. - * - * @example pistonBeforeEvent.ts - * ```typescript - * // set up a couple of piston blocks - * let piston = overworld.getBlock(targetLocation); - * let button = overworld.getBlock({ x: targetLocation.x, y: targetLocation.y + 1, z: targetLocation.z }); - * - * if (piston === undefined || button === undefined) { - * log("Could not find block at location."); - * return -1; - * } - * - * piston.setPermutation(mc.BlockPermutation.resolve('piston').withState('facing_direction', 3)); - * button.setPermutation(mc.BlockPermutation.resolve('acacia_button').withState('facing_direction', 1)); - * - * const uncanceledPistonLoc = { - * x: Math.floor(targetLocation.x) + 2, - * y: Math.floor(targetLocation.y), - * z: Math.floor(targetLocation.z) + 2, - * }; - * - * // this is our control. - * let uncanceledPiston = overworld.getBlock(uncanceledPistonLoc); - * let uncanceledButton = overworld.getBlock({ - * x: uncanceledPistonLoc.x, - * y: uncanceledPistonLoc.y + 1, - * z: uncanceledPistonLoc.z, - * }); - * - * if (uncanceledPiston === undefined || uncanceledButton === undefined) { - * log("Could not find block at location."); - * return -1; - * } - * - * uncanceledPiston.setPermutation(mc.BlockPermutation.resolve('piston').withState('facing_direction', 3)); - * uncanceledButton.setPermutation(mc.BlockPermutation.resolve('acacia_button').withState('facing_direction', 1)); - * - * mc.world.beforeEvents.pistonActivate.subscribe((pistonEvent: mc.PistonActivateBeforeEvent) => { - * let eventLoc = pistonEvent.piston.block.location; - * if (eventLoc.x === targetLocation.x && eventLoc.y === targetLocation.y && eventLoc.z === targetLocation.z) { - * log("Cancelling piston event"); - * pistonEvent.cancel = true; - * } - * }); - * ``` - */ - subscribe(callback: (arg: PistonActivateBeforeEvent) => void): (arg: PistonActivateBeforeEvent) => void; - /** - * @remarks - * Removes a callback from being called before a piston expands - * or retracts. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: PistonActivateBeforeEvent) => void): void; -} - -/** - * Represents a player within the world. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class Player extends Entity { - private constructor(); - /** - * @beta - * @remarks - * The player's Camera. - * - * @throws This property can throw when used. - */ - readonly camera: Camera; - /** - * @beta - * @remarks - * If true, the player is currently emoting. - * - * @throws This property can throw when used. - */ - readonly isEmoting: boolean; - /** - * @beta - * @remarks - * Whether the player is flying. For example, in Creative or - * Spectator mode. - * - * @throws This property can throw when used. - */ - readonly isFlying: boolean; - /** - * @beta - * @remarks - * Whether the player is gliding with Elytra. - * - * @throws This property can throw when used. - */ - readonly isGliding: boolean; - /** - * @beta - * @remarks - * Whether the player is jumping. This will remain true while - * the player is holding the jump action. - * - * @throws This property can throw when used. - */ - readonly isJumping: boolean; - /** - * @beta - * @remarks - * The current overall level for the player, based on their - * experience. - * - * @throws This property can throw when used. - */ - readonly level: number; - /** - * @remarks - * Name of the player. - * - * @throws This property can throw when used. - */ - readonly name: string; - /** - * @beta - * @remarks - * Contains methods for manipulating the on-screen display of a - * Player. - * - * @throws This property can throw when used. - */ - readonly onScreenDisplay: ScreenDisplay; - /** - * @beta - * @remarks - * Manages the selected slot in the player's hotbar. - * - * This property can't be edited in read-only mode. - * - */ - selectedSlot: number; - /** - * @beta - * @remarks - * The overall total set of experience needed to achieve the - * next level for a player. - * - * @throws This property can throw when used. - */ - readonly totalXpNeededForNextLevel: number; - /** - * @beta - * @remarks - * The current set of experience achieved for the player. - * - * @throws This property can throw when used. - */ - readonly xpEarnedAtCurrentLevel: number; - /** - * @beta - * @remarks - * Adds/removes experience to/from the Player and returns the - * current experience of the Player. - * - * This function can't be called in read-only mode. - * - * @param amount - * Amount of experience to add. Note that this can be negative. - * Min/max bounds at -2^24 ~ 2^24 - * @returns - * Returns the current experience of the Player. - * @throws This function can throw errors. - */ - addExperience(amount: number): number; - /** - * @beta - * @remarks - * Adds/removes level to/from the Player and returns the - * current level of the Player. - * - * This function can't be called in read-only mode. - * - * @param amount - * Amount to add to the player. Min/max bounds at -2^24 ~ 2^24 - * @returns - * Returns the current level of the Player. - * @throws This function can throw errors. - */ - addLevels(amount: number): number; - /** - * @beta - * @remarks - * Gets the current item cooldown time for a particular - * cooldown category. - * - * @param itemCategory - * Specifies the cooldown category to retrieve the current - * cooldown for. - * @throws This function can throw errors. - */ - getItemCooldown(itemCategory: string): number; - /** - * @beta - * @remarks - * Gets the current spawn point of the player. - * - * @throws This function can throw errors. - */ - getSpawnPoint(): DimensionLocation | undefined; - /** - * @beta - * @remarks - * Gets the total experience of the Player. - * - * @throws This function can throw errors. - */ - getTotalXp(): number; - /** - * @beta - * @remarks - * Returns true if this player has operator-level permissions. - * - * @throws This function can throw errors. - */ - isOp(): boolean; - /** - * @beta - * @remarks - * Plays a sound that only this particular player can hear. - * - * This function can't be called in read-only mode. - * - * @param soundID - * Identifier of the sound to play. - * @param soundOptions - * Additional optional options for the sound. - * @throws This function can throw errors. - * @example playMusicAndSound.ts - * ```typescript - * let players = mc.world.getPlayers(); - * - * const musicOptions: mc.MusicOptions = { - * fade: 0.5, - * loop: true, - * volume: 1.0, - * }; - * mc.world.playMusic("music.menu", musicOptions); - * - * const worldSoundOptions: mc.WorldSoundOptions = { - * pitch: 0.5, - * volume: 4.0, - * }; - * mc.world.playSound("ambient.weather.thunder", targetLocation, worldSoundOptions); - * - * const playerSoundOptions: mc.PlayerSoundOptions = { - * pitch: 1.0, - * volume: 1.0, - * }; - * - * players[0].playSound("bucket.fill_water", playerSoundOptions); - * ``` - */ - playSound(soundID: string, soundOptions?: PlayerSoundOptions): void; - /** - * @beta - * @remarks - * This is an internal-facing method for posting a system - * message to downstream clients. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - postClientMessage(id: string, value: string): void; - /** - * @beta - * @remarks - * Resets the level of the player. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - resetLevel(): void; - /** - * @beta - * @remarks - * Sends a message to the player. - * - * @param message - * The message to be displayed. - * @throws - * This method can throw if the provided {@link RawMessage} is - * in an invalid format. For example, if an empty `name` string - * is provided to `score`. - * @example nestedTranslation.ts - * ```typescript - * // Displays "Apple or Coal" - * let rawMessage = { - * translate: "accessibility.list.or.two", - * with: { rawtext: [{ translate: "item.apple.name" }, { translate: "item.coal.name" }] }, - * }; - * player.sendMessage(rawMessage); - * ``` - * @example scoreWildcard.ts - * ```typescript - * // Displays the player's score for objective "obj". Each player will see their own score. - * const rawMessage = { score: { name: "*", objective: "obj" } }; - * world.sendMessage(rawMessage); - * ``` - * @example sendBasicMessage.ts - * ```typescript - * let players = mc.world.getPlayers(); - * - * players[0].sendMessage("Hello World!"); - * ``` - * @example sendTranslatedMessage.ts - * ```typescript - * let players = mc.world.getPlayers(); - * - * players[0].sendMessage({ translate: "authentication.welcome", with: ["Amazing Player 1"] }); - * ``` - * @example simpleString.ts - * ```typescript - * // Displays "Hello, world!" - * world.sendMessage("Hello, world!"); - * ``` - * @example translation.ts - * ```typescript - * // Displays "First or Second" - * const rawMessage = { translate: "accessibility.list.or.two", with: ["First", "Second"] }; - * player.sendMessage(rawMessage); - * ``` - */ - sendMessage(message: (RawMessage | string)[] | RawMessage | string): void; - /** - * @beta - * @remarks - * Will change the specified players permissions, and whether - * they are operator or not. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - setOp(isOp: boolean): void; - /** - * @beta - * @remarks - * Sets the current starting spawn point for this particular - * player. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - setSpawnPoint(spawnPoint?: DimensionLocation): void; - /** - * @beta - * @remarks - * Sets the item cooldown time for a particular cooldown - * category. - * - * This function can't be called in read-only mode. - * - * @param itemCategory - * Specifies the cooldown category to retrieve the current - * cooldown for. - * @param tickDuration - * Duration in ticks of the item cooldown. - * @throws This function can throw errors. - */ - startItemCooldown(itemCategory: string, tickDuration: number): void; -} - -/** - * @beta - * Contains information regarding an event after a player - * breaks a block. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class PlayerBreakBlockAfterEvent extends BlockEvent { - private constructor(); - /** - * @remarks - * Returns permutation information about this block before it - * was broken. - * - */ - readonly brokenBlockPermutation: BlockPermutation; - /** - * @remarks - * The item stack that was used to break the block after the - * block was broken, or undefined if empty hand. - * - */ - readonly itemStackAfterBreak?: ItemStack; - /** - * @remarks - * The item stack that was used to break the block before the - * block was broken, or undefined if empty hand. - * - */ - readonly itemStackBeforeBreak?: ItemStack; - /** - * @remarks - * Player that broke the block for this event. - * - */ - readonly player: Player; -} - -/** - * @beta - * Manages callbacks that are connected to when a player breaks - * a block. - */ -export class PlayerBreakBlockAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a block is broken - * by a player. - * - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: PlayerBreakBlockAfterEvent) => void, - options?: BlockEventOptions, - ): (arg: PlayerBreakBlockAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a player breaks a - * block. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: PlayerBreakBlockAfterEvent) => void): void; -} - -/** - * @beta - * Contains information regarding an event before a player - * breaks a block. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class PlayerBreakBlockBeforeEvent extends BlockEvent { - private constructor(); - /** - * @remarks - * If set to true, cancels the block break event. - * - */ - cancel: boolean; - /** - * @remarks - * The item stack that is being used to break the block, or - * undefined if empty hand. - * - */ - itemStack?: ItemStack; - /** - * @remarks - * Player breaking the block for this event. - * - */ - readonly player: Player; -} - -/** - * @beta - * Manages callbacks that are connected to before a player - * breaks a block. - */ -export class PlayerBreakBlockBeforeEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called before a block is broken - * by a player. - * - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: PlayerBreakBlockBeforeEvent) => void, - options?: BlockEventOptions, - ): (arg: PlayerBreakBlockBeforeEvent) => void; - /** - * @remarks - * Removes a callback from being called before a player breaks - * a block. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: PlayerBreakBlockBeforeEvent) => void): void; -} - -/** - * @beta - * This type is usable for iterating over a set of players. - * This means it can be used in statements like for...of - * statements, Array.from(iterator), and more. - */ -export class PlayerIterator implements Iterable { - private constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - [Symbol.iterator](): Iterator; - /** - * @remarks - * Retrieves the next item in this iteration. The resulting - * IteratorResult contains .done and .value properties which - * can be used to see the next Player in the iteration. - * - * This function can't be called in read-only mode. - * - */ - next(): IteratorResult; -} - -/** - * @beta - * Contains information regarding a player that has joined. - * See the playerSpawn event for more detailed information that - * could be returned after the first time a player has spawned - * within the game. - */ -export class PlayerJoinAfterEvent { - private constructor(); - /** - * @remarks - * Opaque string identifier of the player that joined the game. - * - */ - readonly playerId: string; - /** - * @remarks - * Name of the player that has joined. - * - */ - readonly playerName: string; -} - -/** - * @beta - * Manages callbacks that are connected to a player joining the - * world. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class PlayerJoinAfterEventSignal extends IPlayerJoinAfterEventSignal { - private constructor(); -} - -/** - * @beta - * Contains information regarding a player that has left the - * world. - */ -export class PlayerLeaveAfterEvent { - private constructor(); - /** - * @remarks - * Opaque string identifier of the player that has left the - * event. - * - */ - readonly playerId: string; - /** - * @remarks - * Player that has left the world. - * - */ - readonly playerName: string; -} - -/** - * @beta - * Manages callbacks that are connected to a player leaving the - * world. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class PlayerLeaveAfterEventSignal extends IPlayerLeaveAfterEventSignal { - private constructor(); -} - -/** - * @beta - * Contains information regarding an event where a player - * places a block. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class PlayerPlaceBlockAfterEvent extends BlockEvent { - private constructor(); - /** - * @remarks - * Player that placed the block for this event. - * - */ - readonly player: Player; -} - -/** - * @beta - * Manages callbacks that are connected to when a block is - * placed by a player. - */ -export class PlayerPlaceBlockAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a block is placed - * by a player. - * - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: PlayerPlaceBlockAfterEvent) => void, - options?: BlockEventOptions, - ): (arg: PlayerPlaceBlockAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when an block is placed - * by a player. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: PlayerPlaceBlockAfterEvent) => void): void; -} - -/** - * @beta - * Contains information regarding an event before a player - * places a block. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class PlayerPlaceBlockBeforeEvent extends BlockEvent { - private constructor(); - /** - * @remarks - * If set to true, cancels the block place event. - * - */ - cancel: boolean; - /** - * @remarks - * The face of the block that the new block is being placed on. - * - */ - readonly face: Direction; - /** - * @remarks - * Location relative to the bottom north-west corner of the - * block where the new block is being placed onto. - * - */ - readonly faceLocation: Vector3; - /** - * @remarks - * The item being used to place the block. - * - */ - itemStack: ItemStack; - /** - * @remarks - * Player that is placing the block for this event. - * - */ - readonly player: Player; -} - -/** - * @beta - * Manages callbacks that are connected to before a block is - * placed by a player. - */ -export class PlayerPlaceBlockBeforeEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called before a block is placed - * by a player. - * - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: PlayerPlaceBlockBeforeEvent) => void, - options?: BlockEventOptions, - ): (arg: PlayerPlaceBlockBeforeEvent) => void; - /** - * @remarks - * Removes a callback from being called before an block is - * placed by a player. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: PlayerPlaceBlockBeforeEvent) => void): void; -} - -/** - * @beta - * An event that contains more information about a player - * spawning. - */ -export class PlayerSpawnAfterEvent { - private constructor(); - /** - * @remarks - * If true, this is the initial spawn of a player after joining - * the game. - * - * This property can't be edited in read-only mode. - * - */ - initialSpawn: boolean; - /** - * @remarks - * Object that represents the player that joined the game. - * - * This property can't be edited in read-only mode. - * - */ - player: Player; -} - -/** - * @beta - * Registers an event when a player is spawned (or re-spawned - * after death) and fully ready within the world. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class PlayerSpawnAfterEventSignal extends IPlayerSpawnAfterEventSignal { - private constructor(); -} - -/** - * @beta - * Contains information related to changes to a pressure plate - * pop. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class PressurePlatePopAfterEvent extends BlockEvent { - private constructor(); - /** - * @remarks - * The redstone power of the pressure plate before it was - * popped. - * - */ - readonly previousRedstonePower: number; - /** - * @remarks - * The redstone power of the pressure plate at the time of the - * pop. - * - */ - readonly redstonePower: number; -} - -/** - * @beta - * Manages callbacks that are connected to when a pressure - * plate is popped. - */ -export class PressurePlatePopAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a pressure plate is - * popped. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: PressurePlatePopAfterEvent) => void): (arg: PressurePlatePopAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a pressure plate - * is popped. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: PressurePlatePopAfterEvent) => void): void; -} - -/** - * @beta - * Contains information related to changes to a pressure plate - * push. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class PressurePlatePushAfterEvent extends BlockEvent { - private constructor(); - /** - * @remarks - * The redstone power of the pressure plate before it was - * pushed. - * - */ - readonly previousRedstonePower: number; - /** - * @remarks - * The redstone power of the pressure plate at the time of the - * push. - * - */ - readonly redstonePower: number; - /** - * @remarks - * Source that triggered the pressure plate push. - * - */ - readonly source: Entity; -} - -/** - * @beta - * Manages callbacks that are connected to when a pressure - * plate is pushed. - */ -export class PressurePlatePushAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a pressure plate is - * pushed. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: PressurePlatePushAfterEvent) => void): (arg: PressurePlatePushAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a pressure plate - * is pushed. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: PressurePlatePushAfterEvent) => void): void; -} - -/** - * @beta - * Contains information related to a projectile hitting a - * block. - */ -export class ProjectileHitBlockAfterEvent { - private constructor(); - /** - * @remarks - * Dimension where this projectile hit took place. - * - */ - readonly dimension: Dimension; - /** - * @remarks - * Direction vector of the projectile as it hit a block. - * - */ - readonly hitVector: Vector3; - /** - * @remarks - * Location where the projectile hit occurred. - * - */ - readonly location: Vector3; - /** - * @remarks - * Entity for the projectile that hit a block. - * - */ - readonly projectile: Entity; - /** - * @remarks - * Optional source entity that fired the projectile. - * - */ - readonly source?: Entity; - /** - * @remarks - * Contains additional information about the block that was hit - * by the projectile. - * - * This function can't be called in read-only mode. - * - */ - getBlockHit(): BlockHitInformation; -} - -/** - * @beta - * Manages callbacks that are connected to when a projectile - * hits a block. - */ -export class ProjectileHitBlockAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a projectile hits a - * block. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ProjectileHitBlockAfterEvent) => void): (arg: ProjectileHitBlockAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a projectile hits - * a block. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ProjectileHitBlockAfterEvent) => void): void; -} - -/** - * @beta - * Contains information related to a projectile hitting an - * entity. - */ -export class ProjectileHitEntityAfterEvent { - private constructor(); - /** - * @remarks - * Dimension where this projectile hit took place. - * - */ - readonly dimension: Dimension; - /** - * @remarks - * Direction vector of the projectile as it hit an entity. - * - */ - readonly hitVector: Vector3; - /** - * @remarks - * Location where the projectile hit occurred. - * - */ - readonly location: Vector3; - /** - * @remarks - * Entity for the projectile that hit an entity. - * - */ - readonly projectile: Entity; - /** - * @remarks - * Optional source entity that fired the projectile. - * - */ - readonly source?: Entity; - /** - * @remarks - * Contains additional information about an entity that was - * hit. - * - * This function can't be called in read-only mode. - * - */ - getEntityHit(): EntityHitInformation; -} - -/** - * @beta - * Manages callbacks that are connected to when a projectile - * hits an entity. - */ -export class ProjectileHitEntityAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a projectile hits - * an entity. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ProjectileHitEntityAfterEvent) => void): (arg: ProjectileHitEntityAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a projectile hits - * an entity. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ProjectileHitEntityAfterEvent) => void): void; -} - -/** - * @beta - * Provides methods that should be used within the World - * Initialize event to register dynamic properties that can be - * used and stored within Minecraft. - */ -export class PropertyRegistry { - private constructor(); - /** - * @remarks - * Registers a dynamic property for a particular entity type - * (e.g., a minecraft:skeleton.). - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - registerEntityTypeDynamicProperties( - propertiesDefinition: DynamicPropertiesDefinition, - entityTypeOrId: EntityType | string, - ): void; - /** - * @remarks - * Registers a globally available dynamic property for a world. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - registerWorldDynamicProperties(propertiesDefinition: DynamicPropertiesDefinition): void; -} - -/** - * @beta - * Contains objectives and participants for the scoreboard. - */ -export class Scoreboard { - private constructor(); - /** - * @remarks - * Adds a new objective to the scoreboard. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - addObjective(objectiveId: string, displayName: string): ScoreboardObjective; - /** - * @remarks - * Clears the objective that occupies a display slot. - * - * This function can't be called in read-only mode. - * - */ - clearObjectiveAtDisplaySlot(displaySlotId: DisplaySlotId): ScoreboardObjective | undefined; - /** - * @remarks - * Returns a specific objective (by id). - * - * @param objectiveId - * Identifier of the objective. - */ - getObjective(objectiveId: string): ScoreboardObjective | undefined; - /** - * @remarks - * Returns an objective that occupies the specified display - * slot. - * - */ - getObjectiveAtDisplaySlot(displaySlotId: DisplaySlotId): ScoreboardObjectiveDisplayOptions | undefined; - /** - * @remarks - * Returns all defined objectives. - * - */ - getObjectives(): ScoreboardObjective[]; - /** - * @remarks - * Returns all defined scoreboard identities. - * - */ - getParticipants(): ScoreboardIdentity[]; - /** - * @remarks - * Removes an objective from the scoreboard. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - removeObjective(objectiveId: ScoreboardObjective | string): boolean; - /** - * @remarks - * Sets an objective into a display slot with specified - * additional display settings. - * - * This function can't be called in read-only mode. - * - * @returns - * Returns the previous `ScoreboardObjective` set at the - * display slot, if no objective was previously set it returns - * `undefined`. - * @throws This function can throw errors. - */ - setObjectiveAtDisplaySlot( - displaySlotId: DisplaySlotId, - objectiveDisplaySetting: ScoreboardObjectiveDisplayOptions, - ): ScoreboardObjective | undefined; -} - -/** - * @beta - * Contains an identity of the scoreboard item. - */ -export class ScoreboardIdentity { - private constructor(); - /** - * @remarks - * Returns the player-visible name of this identity. - * - */ - readonly displayName: string; - /** - * @remarks - * Identifier of the scoreboard identity. - * - */ - readonly id: number; - /** - * @remarks - * Type of the scoreboard identity. - * - */ - readonly 'type': ScoreboardIdentityType; - /** - * @remarks - * If the scoreboard identity is an entity or player, returns - * the entity that this scoreboard item corresponds to. - * - * @throws This function can throw errors. - */ - getEntity(): Entity | undefined; - isValid(): boolean; -} - -/** - * @beta - * Contains objectives and participants for the scoreboard. - */ -export class ScoreboardObjective { - private constructor(); - /** - * @remarks - * Returns the player-visible name of this scoreboard - * objective. - * - * @throws This property can throw when used. - */ - readonly displayName: string; - /** - * @remarks - * Identifier of the scoreboard objective. - * - * @throws This property can throw when used. - */ - readonly id: string; - /** - * @remarks - * Adds a score to the given participant and objective. - * - * This function can't be called in read-only mode. - * - * @param participant - * Participant to apply the scoreboard value addition to. - * @throws This function can throw errors. - */ - addScore(participant: Entity | ScoreboardIdentity | string, scoreToAdd: number): number; - /** - * @remarks - * Returns all objective participant identities. - * - * @throws This function can throw errors. - */ - getParticipants(): ScoreboardIdentity[]; - /** - * @remarks - * Returns a specific score for a participant. - * - * @param participant - * Identifier of the participant to retrieve a score for. - * @throws This function can throw errors. - */ - getScore(participant: Entity | ScoreboardIdentity | string): number | undefined; - /** - * @remarks - * Returns specific scores for this objective for all - * participants. - * - * @throws This function can throw errors. - */ - getScores(): ScoreboardScoreInfo[]; - /** - * @remarks - * Returns if the specified identity is a participant of the - * scoreboard objective. - * - * @throws This function can throw errors. - */ - hasParticipant(participant: Entity | ScoreboardIdentity | string): boolean; - isValid(): boolean; - /** - * @remarks - * Removes a participant from this scoreboard objective. - * - * This function can't be called in read-only mode. - * - * @param participant - * Participant to remove from being tracked with this - * objective. - * @throws This function can throw errors. - */ - removeParticipant(participant: Entity | ScoreboardIdentity | string): boolean; - /** - * @remarks - * Sets a score for a participant. - * - * This function can't be called in read-only mode. - * - * @param participant - * Identity of the participant. - * @param score - * New value of the score. - * @throws This function can throw errors. - */ - setScore(participant: Entity | ScoreboardIdentity | string, score: number): void; -} - -/** - * @beta - * Contains a pair of a scoreboard participant and its - * respective score. - */ -export class ScoreboardScoreInfo { - private constructor(); - /** - * @remarks - * This scoreboard participant for this score. - * - */ - readonly participant: ScoreboardIdentity; - /** - * @remarks - * Score value of the identity for this objective. - * - */ - readonly score: number; -} - -/** - * @beta - * Contains information about user interface elements that are - * showing up on the screen. - */ -export class ScreenDisplay { - private constructor(); - /** - * @remarks - * Returns true if the current reference to this screen display - * manager object is valid and functional. - * - */ - isValid(): boolean; - /** - * @remarks - * Set the action bar text - a piece of text that displays - * beneath the title and above the hot-bar. - * - * This function can't be called in read-only mode. - * - * @param text - * New value for the action bar text. - * @throws This function can throw errors. - */ - setActionBar(text: (RawMessage | string)[] | RawMessage | string): void; - /** - * @remarks - * Will cause a title to show up on the player's on screen - * display. Will clear the title if set to empty string. You - * can optionally specify an additional subtitle as well as - * fade in, stay and fade out times. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - * @example countdown.ts - * ```typescript - * let players = mc.world.getPlayers(); - * - * players[0].onScreenDisplay.setTitle("Get ready!", { - * stayDuration: 220, - * fadeInDuration: 2, - * fadeOutDuration: 4, - * subtitle: "10", - * }); - * - * let countdown = 10; - * - * let intervalId = mc.system.runInterval(() => { - * countdown--; - * players[0].onScreenDisplay.updateSubtitle(countdown.toString()); - * - * if (countdown == 0) { - * mc.system.clearRun(intervalId); - * } - * }, 20); - * ``` - * @example setTitle.ts - * ```typescript - * let players = mc.world.getPlayers(); - * - * players[0].onScreenDisplay.setTitle("§o§6Fancy Title§r"); - * ``` - * @example setTitleAndSubtitle.ts - * ```typescript - * let players = mc.world.getPlayers(); - * - * players[0].onScreenDisplay.setTitle("Chapter 1", { - * stayDuration: 100, - * fadeInDuration: 2, - * fadeOutDuration: 4, - * subtitle: "Trouble in Block Town", - * }); - * ``` - */ - setTitle(title: (RawMessage | string)[] | RawMessage | string, options?: TitleDisplayOptions): void; - /** - * @remarks - * Updates the subtitle if the subtitle was previously - * displayed via the setTitle method. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - updateSubtitle(subtitle: (RawMessage | string)[] | RawMessage | string): void; -} - -/** - * @beta - * Returns additional data about a /scriptevent command - * invocation. - */ -export class ScriptEventCommandMessageAfterEvent { - private constructor(); - /** - * @remarks - * Identifier of this ScriptEvent command message. - * - */ - readonly id: string; - /** - * @remarks - * If this command was initiated via an NPC, returns the entity - * that initiated the NPC dialogue. - * - */ - readonly initiator?: Entity; - /** - * @remarks - * Optional additional data passed in with the script event - * command. - * - */ - readonly message: string; - /** - * @remarks - * Source block if this command was triggered via a block - * (e.g., a commandblock.) - * - */ - readonly sourceBlock?: Block; - /** - * @remarks - * Source entity if this command was triggered by an entity - * (e.g., a NPC). - * - */ - readonly sourceEntity?: Entity; - /** - * @remarks - * Returns the type of source that fired this command. - * - */ - readonly sourceType: ScriptEventSource; -} - -/** - * @beta - * Allows for registering an event handler that responds to - * inbound /scriptevent commands. - */ -export class ScriptEventCommandMessageAfterEventSignal { - private constructor(); - /** - * @remarks - * Registers a new ScriptEvent handler. - * - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: ScriptEventCommandMessageAfterEvent) => void, - options?: ScriptEventMessageFilterOptions, - ): (arg: ScriptEventCommandMessageAfterEvent) => void; - /** - * @remarks - * Unsubscribes a particular handler for a ScriptEvent event. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ScriptEventCommandMessageAfterEvent) => void): void; -} - -/** - * @beta - * Describes a particular seating position on this rideable - * entity. - */ -export class Seat { - private constructor(); - /** - * @remarks - * If specified, contains a forced rotation that the riders in - * this seat are facing. - * - */ - readonly lockRiderRotation: number; - /** - * @remarks - * A maximum number of riders that this seat can support. - * - */ - readonly maxRiderCount: number; - /** - * @remarks - * A minimum number of riders that can be placed in this seat - * position, if this seat is to be filled. - * - */ - readonly minRiderCount: number; - /** - * @remarks - * Physical location of this seat, relative to the entity's - * location. - * - */ - readonly position: Vector3; -} - -/** - * @beta - * Manages callbacks that are message passing to a server. This - * event is not currently fully implemented, and should not be - * used. - */ -export class ServerMessageAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when an internal message - * is passed. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: MessageReceiveAfterEvent) => void): (arg: MessageReceiveAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when an internal - * message is passed. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: MessageReceiveAfterEvent) => void): void; -} - -/** - * A class that provides system-level events and functions. - */ -export class System { - private constructor(); - /** - * @beta - * @remarks - * Returns a collection of after-events for system-level - * operations. - * - */ - readonly afterEvents: SystemAfterEvents; - /** - * @beta - * @remarks - * Returns a collection of before-events for system-level - * operations. - * - */ - readonly beforeEvents: SystemBeforeEvents; - /** - * @beta - * @remarks - * Represents the current world tick of the server. - * - */ - readonly currentTick: number; - /** - * @beta - * @remarks - * Cancels the execution of a function run that was previously - * scheduled via the `run` function. - * - */ - clearRun(runId: number): void; - /** - * @remarks - * Runs a specified function at a future time. This is - * frequently used to implement delayed behaviors and game - * loops. - * - * @param callback - * Function callback to run when the tickDelay time criteria is - * met. - * @returns - * An opaque identifier that can be used with the `clearRun` - * function to cancel the execution of this run. - * @example trapTick.ts - * ```typescript - * const overworld = mc.world.getDimension("overworld"); - * - * try { - * // Minecraft runs at 20 ticks per second. - * if (mc.system.currentTick % 1200 === 0) { - * mc.world.sendMessage("Another minute passes..."); - * } - * } catch (e) { - * console.warn("Error: " + e); - * } - * - * mc.system.run(trapTick); - * ``` - */ - run(callback: () => void): number; - /** - * @beta - * @remarks - * Runs a set of code on an interval. - * - * @param callback - * Functional code that will run when this interval occurs. - * @param tickInterval - * An interval of every N ticks that the callback will be - * called upon. - * @returns - * An opaque handle that can be used with the clearRun method - * to stop the run of this function on an interval. - * @example every30Seconds.ts - * ```typescript - * let intervalRunIdentifier = Math.floor(Math.random() * 10000); - * - * mc.system.runInterval(() => { - * mc.world.sendMessage("This is an interval run " + intervalRunIdentifier + " sending a message every 30 seconds."); - * }, 600); - * ``` - */ - runInterval(callback: () => void, tickInterval?: number): number; - /** - * @beta - * @remarks - * Runs a set of code at a future time specified by tickDelay. - * - * @param callback - * Functional code that will run when this timeout occurs. - * @param tickDelay - * Amount of time, in ticks, before the interval will be - * called. - * @returns - * An opaque handle that can be used with the clearRun method - * to stop the run of this function on an interval. - */ - runTimeout(callback: () => void, tickDelay?: number): number; -} - -/** - * @beta - * Provides a set of events that fire within the broader - * scripting system within Minecraft. - */ -export class SystemAfterEvents { - private constructor(); - /** - * @remarks - * An event that fires when a /scriptevent command is set. This - * provides a way for commands and other systems to trigger - * behavior within script. - * - */ - readonly scriptEventReceive: ScriptEventCommandMessageAfterEventSignal; -} - -/** - * @beta - * A set of events that fire before an actual action occurs. In - * most cases, you can potentially cancel or modify the - * impending event. Note that in before events any APIs that - * modify gameplay state will not function and will throw an - * error. - */ -export class SystemBeforeEvents { - private constructor(); - /** - * @remarks - * Fires when the scripting watchdog shuts down the server. The - * can be due to using too much memory, or by causing - * significant slowdown or hang. - * To prevent shutdown, set the event's cancel property to - * true. - * - */ - readonly watchdogTerminate: WatchdogTerminateBeforeEventSignal; -} - -/** - * @beta - * Contains information related to changes to a target block - * hit. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class TargetBlockHitAfterEvent extends BlockEvent { - private constructor(); - /** - * @remarks - * The position where the source hit the block. - * - */ - readonly hitVector: Vector3; - /** - * @remarks - * The redstone power before the block is hit. - * - */ - readonly previousRedstonePower: number; - /** - * @remarks - * The redstone power at the time the block is hit. - * - */ - readonly redstonePower: number; - /** - * @remarks - * Optional source that hit the target block. - * - */ - readonly source: Entity; -} - -/** - * @beta - * Manages callbacks that are connected to when a target block - * is hit. - */ -export class TargetBlockHitAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a target block is - * hit. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: TargetBlockHitAfterEvent) => void): (arg: TargetBlockHitAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a target block is - * hit. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: TargetBlockHitAfterEvent) => void): void; -} - -/** - * @beta - * Represents a trigger for firing an event. - */ -export class Trigger { - /** - * @remarks - * Event name of the trigger. - * - */ - eventName: string; - /** - * @remarks - * Creates a new trigger. - * - */ - constructor(eventName: string); -} - -/** - * @beta - * Contains information related to changes to a trip wire trip. - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class TripWireTripAfterEvent extends BlockEvent { - private constructor(); - /** - * @remarks - * Whether or not the block has redstone power. - * - */ - readonly isPowered: boolean; - /** - * @remarks - * The sources that triggered the trip wire to trip. - * - */ - readonly sources: Entity[]; -} - -/** - * @beta - * Manages callbacks that are connected to when a trip wire is - * tripped. - */ -export class TripWireTripAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a trip wire is - * tripped. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: TripWireTripAfterEvent) => void): (arg: TripWireTripAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when a trip wire is - * tripped. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: TripWireTripAfterEvent) => void): void; -} - -/** - * @beta - * Contains a description of a vector. - */ -export class Vector { - /** - * @remarks - * X component of this vector. - * - */ - x: number; - /** - * @remarks - * Y component of this vector. - * - */ - y: number; - /** - * @remarks - * Z component of this vector. - * - */ - z: number; - /** - * @remarks - * A constant vector that represents (0, 0, -1). - * - */ - static readonly back: Vector; - /** - * @remarks - * A constant vector that represents (0, -1, 0). - * - */ - static readonly down: Vector; - /** - * @remarks - * A constant vector that represents (0, 0, 1). - * - */ - static readonly forward: Vector; - /** - * @remarks - * A constant vector that represents (-1, 0, 0). - * - */ - static readonly left: Vector; - /** - * @remarks - * A constant vector that represents (1, 1, 1). - * - */ - static readonly one: Vector; - /** - * @remarks - * A constant vector that represents (1, 0, 0). - * - */ - static readonly right: Vector; - /** - * @remarks - * A constant vector that represents (0, 1, 0). - * - */ - static readonly up: Vector; - /** - * @remarks - * A constant vector that represents (0, 0, 0). - * - */ - static readonly zero: Vector; - /** - * @remarks - * Creates a new instance of an abstract vector. - * - * @param x - * X component of the vector. - * @param y - * Y component of the vector. - * @param z - * Z component of the vector. - */ - constructor(x: number, y: number, z: number); - /** - * @remarks - * Compares this vector and another vector to one another. - * - * @param other - * Other vector to compare this vector to. - * @returns - * True if the two vectors are equal. - */ - equals(other: Vector): boolean; - /** - * @remarks - * Returns the length of this vector. - * - */ - length(): number; - /** - * @remarks - * Returns the squared length of this vector. - * - */ - lengthSquared(): number; - /** - * @remarks - * Returns this vector as a normalized vector. - * - */ - normalized(): Vector; - /** - * @remarks - * Returns the addition of these vectors. - * - */ - static add(a: Vector3, b: Vector3): Vector; - /** - * @remarks - * Returns the cross product of these two vectors. - * - */ - static cross(a: Vector3, b: Vector3): Vector; - /** - * @remarks - * Returns the distance between two vectors. - * - */ - static distance(a: Vector3, b: Vector3): number; - /** - * @remarks - * Returns the component-wise division of these vectors. - * - * @throws This function can throw errors. - */ - static divide(a: Vector3, b: number | Vector3): Vector; - /** - * @remarks - * Returns the linear interpolation between a and b using t as - * the control. - * - */ - static lerp(a: Vector3, b: Vector3, t: number): Vector; - /** - * @remarks - * Returns a vector that is made from the largest components of - * two vectors. - * - */ - static max(a: Vector3, b: Vector3): Vector; - /** - * @remarks - * Returns a vector that is made from the smallest components - * of two vectors. - * - */ - static min(a: Vector3, b: Vector3): Vector; - /** - * @remarks - * Returns the component-wise product of these vectors. - * - */ - static multiply(a: Vector3, b: number | Vector3): Vector; - /** - * @remarks - * Returns the spherical linear interpolation between a and b - * using s as the control. - * - */ - static slerp(a: Vector3, b: Vector3, s: number): Vector; - /** - * @remarks - * Returns the subtraction of these vectors. - * - */ - static subtract(a: Vector3, b: Vector3): Vector; -} - -/** - * @beta - * Contains information related to a script watchdog - * termination. - */ -export class WatchdogTerminateBeforeEvent { - private constructor(); - /** - * @remarks - * If set to true, cancels the termination of the script - * runtime. Note that depending on server configuration - * settings, cancellation of the termination may not be - * allowed. - * - */ - cancel: boolean; - /** - * @remarks - * Contains the reason why a script runtime is to be - * terminated. - * - */ - readonly terminateReason: WatchdogTerminateReason; -} - -/** - * @beta - * Manages callbacks that are connected to a callback that will - * be called when a script runtime is being terminated due to a - * violation of the performance watchdog system. - */ -export class WatchdogTerminateBeforeEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when a script runtime is - * being terminated due to a violation of the performance - * watchdog system. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: WatchdogTerminateBeforeEvent) => void): (arg: WatchdogTerminateBeforeEvent) => void; - /** - * @remarks - * Removes a callback from being called when a script runtime - * is being terminated due to a violation of the performance - * watchdog system. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: WatchdogTerminateBeforeEvent) => void): void; -} - -/** - * @beta - * Contains information related to changes in weather in the - * environment. - */ -export class WeatherChangeAfterEvent { - private constructor(); - /** - * @remarks - * Dimension in which the weather has changed. - * - */ - readonly dimension: string; - /** - * @remarks - * Whether it is lightning after the change in weather. - * - */ - readonly lightning: boolean; - /** - * @remarks - * Whether it is raining after the change in weather. - * - */ - readonly raining: boolean; -} - -/** - * @beta - * Manages callbacks that are connected to weather changing. - */ -export class WeatherChangeAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when weather changes. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: WeatherChangeAfterEvent) => void): (arg: WeatherChangeAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called when weather changes. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: WeatherChangeAfterEvent) => void): void; -} - -/** - * A class that wraps the state of a world - a set of - * dimensions and the environment of Minecraft. - */ -export class World { - private constructor(); - /** - * @beta - * @remarks - * Contains a set of events that are applicable to the entirety - * of the world. Event callbacks are called in a deferred - * manner. Event callbacks are executed in read-write mode. - * - */ - readonly afterEvents: WorldAfterEvents; - /** - * @beta - * @remarks - * Contains a set of events that are applicable to the entirety - * of the world. Event callbacks are called immediately. Event - * callbacks are executed in read-only mode. - * - */ - readonly beforeEvents: WorldBeforeEvents; - /** - * @beta - * @remarks - * Returns the general global scoreboard that applies to the - * world. - * - */ - readonly scoreboard: Scoreboard; - /** - * @beta - * @remarks - * A method that is internal-only, used for broadcasting - * specific messages between client and server. - * - * This function can't be called in read-only mode. - * - * @param id - * The message identifier. - * @param value - * The message. - */ - broadcastClientMessage(id: string, value: string): void; - /** - * @beta - * @remarks - * Returns the absolute time since the start of the world. - * - */ - getAbsoluteTime(): number; - /** - * @remarks - * Returns an array of all active players within the world. - * - * @throws This function can throw errors. - */ - getAllPlayers(): Player[]; - /** - * @beta - * @remarks - * Returns the current day. - * - * @returns - * The current day, determined by the world time divided by the - * number of ticks per day. New worlds start at day 0. - */ - getDay(): number; - /** - * @beta - * @remarks - * Returns the default Overworld spawn location. - * - * @returns - * The default Overworld spawn location. By default, the Y - * coordinate is 32767, indicating a player's spawn height is - * not fixed and will be determined by surrounding blocks. - */ - getDefaultSpawnLocation(): Vector3; - /** - * @remarks - * Returns a dimension object. - * - * @param dimensionId - * The name of the dimension. For example, "overworld", - * "nether" or "the_end". - * @returns - * The requested dimension - * @throws - * Throws if the given dimension name is invalid - */ - getDimension(dimensionId: string): Dimension; - /** - * @beta - * @remarks - * Returns a property value. - * - * @param identifier - * The property identifier. - * @returns - * Returns the value for the property, or undefined if the - * property has not been set. - * @throws - * Throws if the given dynamic property identifier is not - * defined. - * @example incrementProperty.ts - * ```typescript - * let number = mc.world.getDynamicProperty("samplelibrary:number"); - * - * log("Current value is: " + number); - * - * if (number === undefined) { - * number = 0; - * } - * - * if (typeof number !== "number") { - * log("Number is of an unexpected type."); - * return -1; - * } - * - * mc.world.setDynamicProperty("samplelibrary:number", number + 1); - * ``` - * @example incrementPropertyInJsonBlob.ts - * ```typescript - * let paintStr = mc.world.getDynamicProperty("samplelibrary:longerjson"); - * let paint: { color: string; intensity: number } | undefined = undefined; - * - * log("Current value is: " + paintStr); - * - * if (paintStr === undefined) { - * paint = { - * color: "purple", - * intensity: 0, - * }; - * } else { - * if (typeof paintStr !== "string") { - * log("Paint is of an unexpected type."); - * return -1; - * } - * - * try { - * paint = JSON.parse(paintStr); - * } catch (e) { - * log("Error parsing serialized struct."); - * return -1; - * } - * } - * - * if (!paint) { - * log("Error parsing serialized struct."); - * return -1; - * } - * - * paint.intensity++; - * paintStr = JSON.stringify(paint); // be very careful to ensure your serialized JSON str cannot exceed limits - * mc.world.setDynamicProperty("samplelibrary:longerjson", paintStr); - * ``` - */ - getDynamicProperty(identifier: string): boolean | number | string | Vector3 | undefined; - /** - * @beta - * @remarks - * Returns an entity based on the provided id. - * - * @param id - * The id of the entity. - * @returns - * The requested entity object. - * @throws - * Throws if the given entity id is invalid. - */ - getEntity(id: string): Entity | undefined; - /** - * @beta - * @remarks - * Returns the MoonPhase for the current time. - * - */ - getMoonPhase(): MoonPhase; - /** - * @beta - * @remarks - * Returns a set of players based on a set of conditions - * defined via the EntityQueryOptions set of filter criteria. - * - * @param options - * Additional options that can be used to filter the set of - * players returned. - * @returns - * A player array. - * @throws - * Throws if the provided EntityQueryOptions are invalid. - */ - getPlayers(options?: EntityQueryOptions): Player[]; - /** - * @beta - * @remarks - * Returns the time of day. - * - * @returns - * The time of day, in ticks, between 0 and 24000. - */ - getTimeOfDay(): number; - /** - * @beta - * @remarks - * Plays a particular music track for all players. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - * @example playMusicAndSound.ts - * ```typescript - * let players = mc.world.getPlayers(); - * - * const musicOptions: mc.MusicOptions = { - * fade: 0.5, - * loop: true, - * volume: 1.0, - * }; - * mc.world.playMusic("music.menu", musicOptions); - * - * const worldSoundOptions: mc.WorldSoundOptions = { - * pitch: 0.5, - * volume: 4.0, - * }; - * mc.world.playSound("ambient.weather.thunder", targetLocation, worldSoundOptions); - * - * const playerSoundOptions: mc.PlayerSoundOptions = { - * pitch: 1.0, - * volume: 1.0, - * }; - * - * players[0].playSound("bucket.fill_water", playerSoundOptions); - * ``` - */ - playMusic(trackID: string, musicOptions?: MusicOptions): void; - /** - * @beta - * @remarks - * Plays a sound for all players. - * - * This function can't be called in read-only mode. - * - * @throws - * An error will be thrown if volume is less than 0.0. - * An error will be thrown if fade is less than 0.0. - * An error will be thrown if pitch is less than 0.01. - * An error will be thrown if volume is less than 0.0. - * @example playMusicAndSound.ts - * ```typescript - * let players = mc.world.getPlayers(); - * - * const musicOptions: mc.MusicOptions = { - * fade: 0.5, - * loop: true, - * volume: 1.0, - * }; - * mc.world.playMusic("music.menu", musicOptions); - * - * const worldSoundOptions: mc.WorldSoundOptions = { - * pitch: 0.5, - * volume: 4.0, - * }; - * mc.world.playSound("ambient.weather.thunder", targetLocation, worldSoundOptions); - * - * const playerSoundOptions: mc.PlayerSoundOptions = { - * pitch: 1.0, - * volume: 1.0, - * }; - * - * players[0].playSound("bucket.fill_water", playerSoundOptions); - * ``` - */ - playSound(soundID: string, location: Vector3, soundOptions?: WorldSoundOptions): void; - /** - * @beta - * @remarks - * Queues an additional music track for players. If a track is - * not playing, a music track will play. - * - * This function can't be called in read-only mode. - * - * @throws - * An error will be thrown if volume is less than 0.0. - * An error will be thrown if fade is less than 0.0. - * - */ - queueMusic(trackID: string, musicOptions?: MusicOptions): void; - /** - * @beta - * @remarks - * Removes a specified property. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - removeDynamicProperty(identifier: string): boolean; - /** - * @beta - * @remarks - * Sends a message to all players. - * - * @param message - * The message to be displayed. - * @throws - * This method can throw if the provided {@link RawMessage} is - * in an invalid format. For example, if an empty `name` string - * is provided to `score`. - * @example nestedTranslation.ts - * ```typescript - * // Displays "Apple or Coal" - * let rawMessage = { - * translate: "accessibility.list.or.two", - * with: { rawtext: [{ translate: "item.apple.name" }, { translate: "item.coal.name" }] }, - * }; - * world.sendMessage(rawMessage); - * ``` - * @example scoreWildcard.ts - * ```typescript - * // Displays the player's score for objective "obj". Each player will see their own score. - * const rawMessage = { score: { name: "*", objective: "obj" } }; - * world.sendMessage(rawMessage); - * ``` - * @example simpleString.ts - * ```typescript - * // Displays "Hello, world!" - * world.sendMessage("Hello, world!"); - * ``` - * @example translation.ts - * ```typescript - * // Displays "First or Second" - * const rawMessage = { translate: "accessibility.list.or.two", with: ["First", "Second"] }; - * world.sendMessage(rawMessage); - * ``` - */ - sendMessage(message: (RawMessage | string)[] | RawMessage | string): void; - /** - * @beta - * @remarks - * Sets the world time. - * - * This function can't be called in read-only mode. - * - * @param absoluteTime - * The world time, in ticks. - */ - setAbsoluteTime(absoluteTime: number): void; - /** - * @beta - * @remarks - * Sets a default spawn location for all players. - * - * This function can't be called in read-only mode. - * - * @param spawnLocation - * Location of the spawn point. Note that this is assumed to be - * within the overworld dimension. - * @throws - * Throws if the provided spawn location is out of bounds. - */ - setDefaultSpawnLocation(spawnLocation: Vector3): void; - /** - * @beta - * @remarks - * Sets a specified property to a value. - * - * This function can't be called in read-only mode. - * - * @param identifier - * The property identifier. - * @param value - * Data value of the property to set. - * @throws - * Throws if the given dynamic property identifier is not - * defined. - * @example incrementProperty.ts - * ```typescript - * let number = mc.world.getDynamicProperty("samplelibrary:number"); - * - * log("Current value is: " + number); - * - * if (number === undefined) { - * number = 0; - * } - * - * if (typeof number !== "number") { - * log("Number is of an unexpected type."); - * return -1; - * } - * - * mc.world.setDynamicProperty("samplelibrary:number", number + 1); - * ``` - * @example incrementPropertyInJsonBlob.ts - * ```typescript - * let paintStr = mc.world.getDynamicProperty("samplelibrary:longerjson"); - * let paint: { color: string; intensity: number } | undefined = undefined; - * - * log("Current value is: " + paintStr); - * - * if (paintStr === undefined) { - * paint = { - * color: "purple", - * intensity: 0, - * }; - * } else { - * if (typeof paintStr !== "string") { - * log("Paint is of an unexpected type."); - * return -1; - * } - * - * try { - * paint = JSON.parse(paintStr); - * } catch (e) { - * log("Error parsing serialized struct."); - * return -1; - * } - * } - * - * if (!paint) { - * log("Error parsing serialized struct."); - * return -1; - * } - * - * paint.intensity++; - * paintStr = JSON.stringify(paint); // be very careful to ensure your serialized JSON str cannot exceed limits - * mc.world.setDynamicProperty("samplelibrary:longerjson", paintStr); - * ``` - */ - setDynamicProperty(identifier: string, value: boolean | number | string | Vector3): void; - /** - * @beta - * @remarks - * Sets the time of day. - * - * This function can't be called in read-only mode. - * - * @param timeOfDay - * The time of day, in ticks, between 0 and 24000. - * @throws - * Throws if the provided time of day is not within the valid - * range. - */ - setTimeOfDay(timeOfDay: number | TimeOfDay): void; - /** - * @beta - * @remarks - * Stops any music tracks from playing. - * - * This function can't be called in read-only mode. - * - */ - stopMusic(): void; -} - -/** - * @beta - * Contains a set of events that are available across the scope - * of the World. - */ -export class WorldAfterEvents { - private constructor(); - /** - * @beta - * @remarks - * This event fires for each BlockLocation destroyed by an - * explosion. It is fired after the blocks have already been - * destroyed. - * - */ - readonly blockExplode: BlockExplodeAfterEventSignal; - /** - * @remarks - * This event fires when a button is pushed. - * - */ - readonly buttonPush: ButtonPushAfterEventSignal; - /** - * @beta - * @remarks - * This event is triggered after a chat message has been - * broadcast or sent to players. - * - */ - readonly chatSend: ChatSendAfterEventSignal; - /** - * @beta - * @remarks - * This event is fired when an entity event has been triggered - * that will update the component definition state of an - * entity. - * - */ - readonly dataDrivenEntityTriggerEvent: DataDrivenEntityTriggerAfterEventSignal; - /** - * @beta - * @remarks - * This event fires when an effect, like poisoning, is added to - * an entity. - * - */ - readonly effectAdd: EffectAddAfterEventSignal; - /** - * @beta - * @remarks - * This event fires when an entity dies. - * - */ - readonly entityDie: EntityDieAfterEventSignal; - /** - * @beta - * @remarks - * This event fires when entity health changes in any degree. - * - */ - readonly entityHealthChanged: EntityHealthChangedAfterEventSignal; - /** - * @beta - * @remarks - * This event fires when an entity hits (that is, melee - * attacks) a block. - * - */ - readonly entityHitBlock: EntityHitBlockAfterEventSignal; - /** - * @beta - * @remarks - * This event fires when an entity hits (that is, melee - * attacks) another entity. - * - */ - readonly entityHitEntity: EntityHitEntityAfterEventSignal; - /** - * @beta - * @remarks - * This event fires when an entity is hurt (takes damage). - * - */ - readonly entityHurt: EntityHurtAfterEventSignal; - /** - * @beta - */ - readonly entityLoad: EntityLoadAfterEventSignal; - /** - * @beta - */ - readonly entityRemove: EntityRemoveAfterEventSignal; - /** - * @beta - * @remarks - * This event fires when an entity is spawned. - * - */ - readonly entitySpawn: EntitySpawnAfterEventSignal; - /** - * @beta - * @remarks - * This event is fired after an explosion occurs. - * - */ - readonly explosion: ExplosionAfterEventSignal; - /** - * @beta - * @remarks - * This event fires when a chargeable item completes charging. - * - */ - readonly itemCompleteUse: ItemCompleteUseAfterEventSignal; - /** - * @beta - * @remarks - * For custom items, this event is triggered when the - * fundamental set of defined components for the item change. - * Note that this event is only fired for custom data-driven - * items. - * - */ - readonly itemDefinitionEvent: ItemDefinitionAfterEventSignal; - /** - * @beta - * @remarks - * This event fires when a chargeable item is released from - * charging. - * - */ - readonly itemReleaseUse: ItemReleaseUseAfterEventSignal; - /** - * @beta - * @remarks - * This event fires when a chargeable item starts charging. - * - */ - readonly itemStartUse: ItemStartUseAfterEventSignal; - /** - * @beta - * @remarks - * This event fires when a player successfully uses an item or - * places a block by pressing the Use Item / Place Block - * button. If multiple blocks are placed, this event will only - * occur once at the beginning of the block placement. Note: - * This event cannot be used with Hoe or Axe items. - * - */ - readonly itemStartUseOn: ItemStartUseOnAfterEventSignal; - /** - * @beta - * @remarks - * This event fires when a chargeable item stops charging. - * - */ - readonly itemStopUse: ItemStopUseAfterEventSignal; - /** - * @beta - * @remarks - * This event fires when a player releases the Use Item / Place - * Block button after successfully using an item. Note: This - * event cannot be used with Hoe or Axe items. - * - */ - readonly itemStopUseOn: ItemStopUseOnAfterEventSignal; - /** - * @beta - * @remarks - * This event fires when an item is successfully used by a - * player. - * - */ - readonly itemUse: ItemUseAfterEventSignal; - /** - * @beta - * @remarks - * This event fires when an item is used on a block by a - * player. - * - */ - readonly itemUseOn: ItemUseOnAfterEventSignal; - /** - * @remarks - * A lever has been pulled. - * - */ - readonly leverAction: LeverActionAfterEventSignal; - /** - * @beta - * @remarks - * This event is an internal implementation detail, and is - * otherwise not currently functional. - * - */ - readonly messageReceive: ServerMessageAfterEventSignal; - /** - * @beta - * @remarks - * This event fires when a piston expands or retracts. - * - */ - readonly pistonActivate: PistonActivateAfterEventSignal; - /** - * @beta - * @remarks - * This event fires for a block that is broken by a player. - * - */ - readonly playerBreakBlock: PlayerBreakBlockAfterEventSignal; - /** - * @remarks - * This event fires when a player joins a world. See also - * playerSpawn for another related event you can trap for when - * a player is spawned the first time within a world. - * - */ - readonly playerJoin: PlayerJoinAfterEventSignal; - /** - * @remarks - * This event fires when a player leaves a world. - * - */ - readonly playerLeave: PlayerLeaveAfterEventSignal; - /** - * @beta - * @remarks - * This event fires for a block that is placed by a player. - * - */ - readonly playerPlaceBlock: PlayerPlaceBlockAfterEventSignal; - /** - * @remarks - * This event fires when a player spawns or respawns. Note that - * an additional flag within this event will tell you whether - * the player is spawning right after join vs. a respawn. - * - */ - readonly playerSpawn: PlayerSpawnAfterEventSignal; - /** - * @beta - * @remarks - * A pressure plate has popped back up (i.e., there are no - * entities on the pressure plate.) - * - */ - readonly pressurePlatePop: PressurePlatePopAfterEventSignal; - /** - * @beta - * @remarks - * A pressure plate has pushed (at least one entity has moved - * onto a pressure plate.) - * - */ - readonly pressurePlatePush: PressurePlatePushAfterEventSignal; - /** - * @beta - * @remarks - * This event fires when a projectile hits a block. - * - */ - readonly projectileHitBlock: ProjectileHitBlockAfterEventSignal; - /** - * @beta - * @remarks - * This event fires when a projectile hits an entity. - * - */ - readonly projectileHitEntity: ProjectileHitEntityAfterEventSignal; - /** - * @beta - * @remarks - * A target block was hit. - * - */ - readonly targetBlockHit: TargetBlockHitAfterEventSignal; - /** - * @beta - * @remarks - * A trip wire was tripped. - * - */ - readonly tripWireTrip: TripWireTripAfterEventSignal; - /** - * @beta - * @remarks - * This event will be triggered when the weather changes within - * Minecraft. - * - */ - readonly weatherChange: WeatherChangeAfterEventSignal; - /** - * @beta - * @remarks - * This event fires when the script environment is initialized - * on a World. In addition, you can register dynamic properties - * within the scope of a world Initialize event. - * - */ - readonly worldInitialize: WorldInitializeAfterEventSignal; -} - -/** - * @beta - * A set of events that fire before an actual action occurs. In - * most cases, you can potentially cancel or modify the - * impending event. Note that in before events any APIs that - * modify gameplay state will not function and will throw an - * error. (e.g., dimension.spawnEntity) - */ -export class WorldBeforeEvents { - private constructor(); - /** - * @beta - * @remarks - * This event is triggered after a chat message has been - * broadcast or sent to players. - * - */ - readonly chatSend: ChatSendBeforeEventSignal; - /** - * @beta - * @remarks - * This event is fired when an entity event has been triggered - * that will update the component definition state of an - * entity. - * - */ - readonly dataDrivenEntityTriggerEvent: DataDrivenEntityTriggerBeforeEventSignal; - /** - * @beta - */ - readonly entityRemove: EntityRemoveBeforeEventSignal; - /** - * @beta - * @remarks - * This event is fired after an explosion occurs. - * - */ - readonly explosion: ExplosionBeforeEventSignal; - /** - * @beta - * @remarks - * For custom items, this event is triggered when the - * fundamental set of defined components for the item change. - * Note that this event is only fired for custom data-driven - * items. - * - */ - readonly itemDefinitionEvent: ItemDefinitionBeforeEventSignal; - /** - * @remarks - * This event fires when an item is successfully used by a - * player. - * - */ - readonly itemUse: ItemUseBeforeEventSignal; - /** - * @remarks - * This event fires when an item is used on a block by a - * player. - * - */ - readonly itemUseOn: ItemUseOnBeforeEventSignal; - /** - * @beta - * @remarks - * This event fires when a piston expands or retracts. - * - */ - readonly pistonActivate: PistonActivateBeforeEventSignal; - /** - * @beta - * @remarks - * This event fires before a block is broken by a player. - * - */ - readonly playerBreakBlock: PlayerBreakBlockBeforeEventSignal; - /** - * @beta - * @remarks - * This event fires before a block is placed by a player. - * - */ - readonly playerPlaceBlock: PlayerPlaceBlockBeforeEventSignal; -} - -/** - * @beta - * Contains information and methods that can be used at the - * initialization of the scripting environment for a World. - * Also, use the supplied propertyRegistry object to register - * any dynamic properties, within the scope of the World - * Initialize execution. - */ -export class WorldInitializeAfterEvent { - private constructor(); - /** - * @remarks - * Contains methods for scripts to initialize and register - * dynamic properties they may wish to use within a world. - * - * @example propertyRegistration.js - * ```typescript - * import { DynamicPropertiesDefinition, EntityTypes, world } from '@minecraft/server'; - * import { MinecraftEntityTypes } from '@minecraft/vanilla-data'; - * - * world.afterEvents.worldInitialize.subscribe(e => { - * let def = new DynamicPropertiesDefinition(); - * - * def.defineNumber('rpgStrength'); - * def.defineString('rpgRole', 16); - * def.defineBoolean('rpgIsHero'); - * - * e.propertyRegistry.registerEntityTypeDynamicProperties(def, EntityTypes.get(MinecraftEntityTypes.Skeleton)); - * }); - * ``` - */ - readonly propertyRegistry: PropertyRegistry; -} - -/** - * @beta - * Manages callbacks that are run at the initialization of the - * scripting environment for a World. Do note that this event - * may run multiple times within a session in the case that the - * /reload command is used. - */ -export class WorldInitializeAfterEventSignal { - private constructor(); - /** - * @remarks - * Adds a callback that will be called when the scripting - * environment is initialized for a World. - * - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: WorldInitializeAfterEvent) => void): (arg: WorldInitializeAfterEvent) => void; - /** - * @remarks - * Removes a callback from being called the scripting - * environment is initialized for a World. - * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: WorldInitializeAfterEvent) => void): void; -} - -/** - * @beta - * Contains optional parameters for registering a block event. - */ -export interface BlockEventOptions { - /** - * @remarks - * If this value is set, this event will only fire if the - * impacted block's type matches this parameter. - * - */ - blockTypes?: string[]; - /** - * @remarks - * If this value is set, this event will only fire if the - * impacted block's permutation matches this parameter. - * - */ - permutations?: BlockPermutation[]; -} - -/** - * @beta - * Contains additional options for a block fill operation. - */ -export interface BlockFillOptions { - /** - * @remarks - * When specified, the fill operation will only apply to blocks - * that match this description. - * - */ - matchingBlock?: BlockPermutation; -} - -/** - * @beta - * Contains more information for events where a block is hit. - */ -export interface BlockHitInformation { - /** - * @remarks - * Block that was hit. - * - */ - block: Block; - /** - * @remarks - * Face of the block that was hit. - * - */ - face: Direction; - /** - * @remarks - * Location relative to the bottom north-west corner of the - * block. - * - */ - faceLocation: Vector3; -} - -/** - * @beta - * Contains information for block raycast hit results. - */ -export interface BlockRaycastHit { - /** - * @remarks - * Block that was hit. - * - */ - block: Block; - /** - * @remarks - * Face of the block that was hit. - * - */ - face: Direction; - /** - * @remarks - * Hit location relative to the bottom north-west corner of the - * block. - * - */ - faceLocation: Vector3; -} - -/** - * @beta - * Contains additional options for configuring a block raycast - * query. - */ -export interface BlockRaycastOptions { - /** - * @remarks - * If true, liquid blocks will be considered as blocks that - * 'stop' the raycast. - * - */ - includeLiquidBlocks?: boolean; - /** - * @remarks - * If true, passable blocks like vines and flowers will be - * considered as blocks that 'stop' the raycast. - * - */ - includePassableBlocks?: boolean; - /** - * @remarks - * Maximum distance, in blocks, to process the raycast. - * - */ - maxDistance?: number; -} - -/** - * @beta - * A BlockVolume is a simple interface to an object which - * represents a 3D rectangle of a given size (in blocks) at a - * world block location. - * Note that these are not analogous to "min" and "max" values, - * in that the vector components are not guaranteed to be in - * any order. - * In addition, these vector positions are not interchangeable - * with BlockLocation. - * If you want to get this volume represented as range of of - * BlockLocations, you can use the getBoundingBox utility - * function. - * This volume class will maintain the ordering of the corner - * indexes as initially set. imagine that each corner is - * assigned in Editor - as you move the corner around - * (potentially inverting the min/max relationship of the - * bounds) - what - * you had originally selected as the top/left corner would - * traditionally become the bottom/right. - * When manually editing these kinds of volumes, you need to - * maintain the identity of the corner as you edit - the - * BlockVolume utility functions do this. - * - * Important to note that this measures block sizes (to/from) - - * a normal AABB (0,0,0) to (0,0,0) would traditionally be of - * size (0,0,0) - * However, because we're measuring blocks - the size or span - * of a BlockVolume would actually be (1,1,1) - * - */ -export interface BlockVolume { - /** - * @remarks - * A world block location that represents a corner in a 3D - * rectangle - * - */ - from: Vector3; - /** - * @remarks - * A world block location that represents the opposite corner - * in a 3D rectangle - * - */ - to: Vector3; -} - -/** - * @beta - * A BoundingBox is an interface to an object which represents - * an AABB aligned rectangle. - * The BoundingBox assumes that it was created in a valid state - * (min <= max) but cannot guarantee it (unless it was created - * using the associated {@link - * @minecraft-server.BoundingBoxUtils} utility functions. - * The min/max coordinates represent the diametrically opposite - * corners of the rectangle. - * The BoundingBox is not a representation of blocks - it has - * no association with any type, it is just a mathematical - * construct - so a rectangle with - * ( 0,0,0 ) -> ( 0,0,0 ) - * has a size of ( 0,0,0 ) (unlike the very similar {@link - * BlockVolume} object) - */ -export interface BoundingBox { - /** - * @remarks - * A {@link @minecraft-server.Vector3} that represents the - * largest corner of the rectangle - * - */ - max: Vector3; - /** - * @remarks - * A {@link @minecraft-server.Vector3} that represents the - * smallest corner of the rectangle - * - */ - min: Vector3; -} - -/** - * @beta - */ -export interface CameraEaseOptions { - easeTime?: number; - easeType?: EasingType; -} - -/** - * @beta - */ -export interface CameraFadeOptions { - fadeColor?: RGB; - fadeTime?: CameraFadeTimeOptions; -} - -/** - * @beta - */ -export interface CameraFadeTimeOptions { - fadeInTime: number; - fadeOutTime: number; - holdTime: number; -} - -/** - * @beta - * This interface defines an entry into the {@link - * @minecraft-server/CompoundBlockVolume} which represents a - * volume of positive or negative space. - * - */ -export interface CompoundBlockVolumeItem { - /** - * @remarks - * The 'action' defines how the block volume is represented in - * the compound block volume stack. - * 'Add' creates a block volume which is positively selected - * 'Subtract' creates a block volume which represents a hole or - * negative space in the overall compound block volume. - * - */ - action?: CompoundBlockVolumeAction; - /** - * @remarks - * The relativity enumeration determines whether the - * BlockVolume specified is positioned relative to the parent - * compound block volume origin, or in absolute world space. - * - */ - locationRelativity?: CompoundBlockVolumePositionRelativity; - /** - * @remarks - * The volume of space - * - */ - volume: BlockVolume; -} - -/** - * @beta - * An exact coordinate within the world, including its - * dimension and location. - */ -export interface DimensionLocation { - /** - * @remarks - * Dimension that this coordinate is associated with. - * - */ - dimension: Dimension; - /** - * @remarks - * X component of this dimension-location. - * - */ - x: number; - /** - * @remarks - * Y component of this dimension-location. - * - */ - y: number; - /** - * @remarks - * Z component of this dimension-location. - * - */ - z: number; -} - -/** - * @beta - * Additional options for when damage has been applied via a - * projectile. - */ -export interface EntityApplyDamageByProjectileOptions { - /** - * @remarks - * Optional entity that fired the projectile. - * - */ - damagingEntity?: Entity; - /** - * @remarks - * Projectile that caused damage. - * - */ - damagingProjectile: Entity; -} - -/** - * @beta - * Additional descriptions and metadata for a damage event. - */ -export interface EntityApplyDamageOptions { - /** - * @remarks - * Underlying cause of the damage. - * - */ - cause: EntityDamageCause; - /** - * @remarks - * Optional entity that caused the damage. - * - */ - damagingEntity?: Entity; -} - -/** - * @beta - * Provides information about how damage has been applied to an - * entity. - */ -export interface EntityDamageSource { - /** - * @remarks - * Cause enumeration of damage. - * - */ - cause: EntityDamageCause; - /** - * @remarks - * Optional entity that caused the damage. - * - */ - damagingEntity?: Entity; - /** - * @remarks - * Optional projectile that may have caused damage. - * - */ - damagingProjectile?: Entity; -} - -/** - * @beta - * Specifies additional filters that are used in registering a - * data driven trigger event for entities. - */ -export interface EntityDataDrivenTriggerEventOptions { - /** - * @remarks - * If this value is set, this event will only fire for entities - * that match the entities within this collection. - * - */ - entities?: Entity[]; - /** - * @remarks - * If this value is set, this event will only fire if the - * impacted entities' type matches this parameter. - * - */ - entityTypes?: string[]; - /** - * @remarks - * If this value is set, this event will only fire if the - * impacted triggered event matches one of the events listed in - * this parameter. - * - */ - eventTypes?: string[]; -} - -/** - * @beta - * Contains additional options for entity effects. - */ -export interface EntityEffectOptions { - /** - * @remarks - * The strength of the effect. - * - */ - amplifier?: number; - /** - * @remarks - * If true, will show particles when effect is on the entity. - * - */ - showParticles?: boolean; -} - -/** - * @beta - * Contains optional parameters for registering an entity - * event. - */ -export interface EntityEventOptions { - /** - * @remarks - * If this value is set, this event will only fire for entities - * that match the entities within this collection. - * - */ - entities?: Entity[]; - /** - * @remarks - * If this value is set, this event will only fire if the - * impacted entities' type matches this parameter. - * - */ - entityTypes?: string[]; -} - -/** - * @beta - * Contains additional information about an entity that was - * hit. - */ -export interface EntityHitInformation { - /** - * @remarks - * Entity that was hit. - * - */ - entity: Entity; -} - -/** - * @beta - * Contains options for selecting entities within an area. - */ -export interface EntityQueryOptions { - /** - * @remarks - * Limits the number of entities to return, opting for the - * closest N entities as specified by this property. The - * location value must also be specified on the query options - * object. - * - */ - closest?: number; - /** - * @remarks - * Excludes entities that match one or more of the specified - * families. - * - */ - excludeFamilies?: string[]; - /** - * @remarks - * Excludes entities if have a specific gamemode that matches - * the specified gamemode. - * - */ - excludeGameModes?: GameMode[]; - /** - * @remarks - * Excludes entities that have a name that match one of the - * specified values. - * - */ - excludeNames?: string[]; - /** - * @remarks - * Excludes entities with a tag that matches one of the - * specified values. - * - */ - excludeTags?: string[]; - /** - * @remarks - * Excludes entities if they are one of the specified types. - * - */ - excludeTypes?: string[]; - /** - * @remarks - * If specified, includes entities that match all of the - * specified families. - * - */ - families?: string[]; - /** - * @remarks - * Limits the number of entities to return, opting for the - * farthest N entities as specified by this property. The - * location value must also be specified on the query options - * object. - * - */ - farthest?: number; - /** - * @remarks - * If specified, includes entities with a gamemode that matches - * the specified gamemode. - * - */ - gameMode?: GameMode; - /** - * @remarks - * Adds a seed location to the query that is used in - * conjunction with closest, farthest, limit, volume, and - * distance properties. - * - */ - location?: Vector3; - /** - * @remarks - * If specified, includes entities that are less than this - * distance away from the location specified in the location - * property. - * - */ - maxDistance?: number; - /** - * @remarks - * If specified, will only include entities that have at most - * this horizontal rotation. - * - */ - maxHorizontalRotation?: number; - /** - * @remarks - * If defined, only players that have at most this level are - * returned. - * - */ - maxLevel?: number; - /** - * @remarks - * If specified, only entities that have at most this vertical - * rotation are returned. - * - */ - maxVerticalRotation?: number; - /** - * @remarks - * If specified, includes entities that are least this distance - * away from the location specified in the location property. - * - */ - minDistance?: number; - /** - * @remarks - * If specified, will only include entities that have at a - * minimum this horizontal rotation. - * - */ - minHorizontalRotation?: number; - /** - * @remarks - * If defined, only players that have at least this level are - * returned. - * - */ - minLevel?: number; - /** - * @remarks - * If specified, will only include entities that have at least - * this vertical rotation. - * - */ - minVerticalRotation?: number; - /** - * @remarks - * Includes entities with the specified name. - * - */ - name?: string; - /** - * @remarks - * Gets/sets a collection of EntityQueryScoreOptions objects - * with filters for specific scoreboard objectives. - * - */ - scoreOptions?: EntityQueryScoreOptions[]; - /** - * @remarks - * Includes entities that match all of the specified tags. - * - */ - tags?: string[]; - /** - * @remarks - * If defined, entities that match this type are included. - * - */ - type?: string; - /** - * @beta - * @remarks - * In conjunction with location, specified a cuboid volume of - * entities to include. - * - */ - volume?: BlockAreaSize; -} - -/** - * @beta - * Contains additional options for filtering players based on - * their score for an objective. - */ -export interface EntityQueryScoreOptions { - /** - * @remarks - * If set to true, entities and players within this score range - * are excluded from query results. - * - */ - exclude?: boolean; - /** - * @remarks - * If defined, only players that have a score equal to or under - * maxScore are included. - * - */ - maxScore?: number; - /** - * @remarks - * If defined, only players that have a score equal to or over - * minScore are included. - * - */ - minScore?: number; - /** - * @remarks - * Identifier of the scoreboard objective to filter on. - * - */ - objective?: string; -} - -/** - * @beta - * Contains information for entity raycast hit results. - */ -export interface EntityRaycastHit { - /** - * @remarks - * Distance from ray origin to entity bounds. - * - */ - distance: number; - /** - * @remarks - * Entity that was hit. - * - */ - entity: Entity; -} - -/** - * @beta - * Contains additional options for an entity raycast operation. - */ -export interface EntityRaycastOptions { - /** - * @remarks - * Maximum distance, in blocks, to process the raycast. - * - */ - maxDistance?: number; -} - -/** - * @beta - * Additional configuration options for the {@link - * Dimension.createExplosion} method. - */ -export interface ExplosionOptions { - /** - * @remarks - * Whether parts of the explosion also impact underwater. - * - */ - allowUnderwater?: boolean; - /** - * @remarks - * Whether the explosion will break blocks within the blast - * radius. - * - */ - breaksBlocks?: boolean; - /** - * @remarks - * If true, the explosion is accompanied by fires within or - * near the blast radius. - * - */ - causesFire?: boolean; - /** - * @remarks - * Optional source of the explosion. - * - */ - source?: Entity; -} - -/** - * @beta - * Additional configuration options for {@link - * World.playMusic}/{@link World.queueMusic} methods. - */ -export interface MusicOptions { - /** - * @remarks - * Specifies a fade overlap for music at the end of play. - * - */ - fade?: number; - /** - * @remarks - * If set to true, this music track will play repeatedly. - * - */ - loop?: boolean; - /** - * @remarks - * Relative volume level of the music. - * - */ - volume?: number; -} - -/** - * @beta - * Represents a min/max structure for expressing a potential - * range of numbers. - */ -export interface NumberRange { - /** - * @remarks - * Maximum value within a range. - * - */ - max: number; - /** - * @remarks - * Minimum value within a range. - * - */ - min: number; -} - -/** - * @beta - * Contains additional options for how an animation is played. - */ -export interface PlayAnimationOptions { - /** - * @remarks - * Amount of time to fade out after an animation stops. - * - */ - blendOutTime?: number; - /** - * @remarks - * Specifies a controller to use that has been defined on the - * entity. - * - */ - controller?: string; - /** - * @remarks - * Specifies the state to transition to. - * - */ - nextState?: string; - /** - * @remarks - * Specifies a Molang expression for when this animation should - * complete. - * - */ - stopExpression?: string; -} - -/** - * @beta - * Additional options for how a sound plays for a player. - */ -export interface PlayerSoundOptions { - /** - * @remarks - * Location of the sound; if not specified, the sound is played - * near a player. - * - */ - location?: Vector3; - /** - * @remarks - * Optional pitch of the sound. - * - */ - pitch?: number; - /** - * @remarks - * Optional volume of the sound. - * - */ - volume?: number; -} - -/** - * @beta - * Defines a JSON structure that is used for more flexible. - */ -export interface RawMessage { - /** - * @remarks - * Provides a raw-text equivalent of the current message. - * - */ - rawtext?: RawMessage[]; - /** - * @remarks - * Provides a token that will get replaced with the value of a - * score. - * - */ - score?: RawMessageScore; - /** - * @remarks - * Provides a string literal value to use. - * - */ - text?: string; - /** - * @remarks - * Provides a translation token where, if the client has an - * available resource in the players' language which matches - * the token, will get translated on the client. - * - */ - translate?: string; - /** - * @remarks - * Arguments for the translation token. Can be either an array - * of strings or RawMessage containing an array of raw text - * objects. - * - */ - with?: string[] | RawMessage; -} - -/** - * @beta - * Provides a description of a score token to use within a raw - * message. - */ -export interface RawMessageScore { - /** - * @remarks - * Name of the score value to match. - * - */ - name?: string; - /** - * @remarks - * Name of the score value to match. - * - */ - objective?: string; -} - -/** - * @beta - * A `RawMessage` with only the `rawtext` property. When a - * `RawMessage` is serialized the contents are put into a - * rawtext property, so this is useful when reading saved - * RawMessages. See `BlockSignComponent.setText` and - * `BlockSignComponent.getRawText` for examples. - */ -export interface RawText { - /** - * @remarks - * A serialization of the current value of an associated sign. - * - */ - rawtext?: RawMessage[]; -} - -/** - * @beta - * Represents a fully customizable color within Minecraft. - */ -export interface RGB { - /** - * @remarks - * Determines a color's blue component. Valid values are - * between 0 and 1.0. - * - */ - blue: number; - /** - * @remarks - * Determines a color's green component. Valid values are - * between 0 and 1.0. - * - */ - green: number; - /** - * @remarks - * Determines a color's red component. Valid values are between - * 0 and 1.0. - * - */ - red: number; -} - -/** - * @beta - * Represents a fully customizable color within Minecraft. - */ -export interface RGBA { - /** - * @remarks - * Determines a color's alpha (opacity) component. Valid values - * are between 0 (transparent) and 1.0 (opaque). - * - */ - alpha: number; - /** - * @remarks - * Determines a color's blue component. Valid values are - * between 0 and 1.0. - * - */ - blue: number; - /** - * @remarks - * Determines a color's green component. Valid values are - * between 0 and 1.0. - * - */ - green: number; - /** - * @remarks - * Determines a color's red component. Valid values are between - * 0 and 1.0. - * - */ - red: number; -} - -/** - * @beta - * Contains additional options for how a scoreboard should be - * displayed within its display slot. - */ -export interface ScoreboardObjectiveDisplayOptions { - /** - * @remarks - * Objective to be displayed. - * - */ - objective: ScoreboardObjective; - /** - * @remarks - * The sort order to display the objective items within. - * - */ - sortOrder?: ObjectiveSortOrder; -} - -/** - * @beta - */ -export interface ScriptCameraDefaultOptions { - easeOptions: CameraEaseOptions; -} - -/** - * @beta - */ -export interface ScriptCameraSetFacingOptions { - easeOptions?: CameraEaseOptions; - facingEntity: Entity; - location?: Vector3; -} - -/** - * @beta - */ -export interface ScriptCameraSetLocationOptions { - easeOptions?: CameraEaseOptions; - location: Vector3; -} - -/** - * @beta - */ -export interface ScriptCameraSetPosOptions { - easeOptions?: CameraEaseOptions; - facingLocation: Vector3; - location?: Vector3; -} - -/** - * @beta - */ -export interface ScriptCameraSetRotOptions { - easeOptions?: CameraEaseOptions; - location?: Vector3; - rotation: Vector2; -} - -/** - * @beta - * Contains additional options for registering a script event - * event callback. - */ -export interface ScriptEventMessageFilterOptions { - /** - * @remarks - * Optional list of namespaces to filter inbound script event - * messages. - * - */ - namespaces: string[]; -} - -/** - * @beta - * Contains additional options for teleporting an entity. - */ -export interface TeleportOptions { - /** - * @remarks - * Whether to check whether blocks will block the entity after - * teleport. - * - */ - checkForBlocks?: boolean; - /** - * @remarks - * Dimension to potentially move the entity to. If not - * specified, the entity is teleported within the dimension - * that they reside. - * - */ - dimension?: Dimension; - /** - * @remarks - * Location that the entity should be facing after teleport. - * - */ - facingLocation?: Vector3; - /** - * @remarks - * Whether to retain the entities velocity after teleport. - * - */ - keepVelocity?: boolean; - /** - * @remarks - * Rotation of the entity after teleport. - * - */ - rotation?: Vector2; -} - -/** - * @beta - * Contains additional options for displaying a title and - * optional subtitle. - */ -export interface TitleDisplayOptions { - /** - * @remarks - * Fade-in duration for the title and subtitle, in ticks. There - * are 20 ticks per second. Use {@link TicksPerSecond} constant - * to convert between ticks and seconds. - * - */ - fadeInDuration: number; - /** - * @remarks - * Fade-out time for the title and subtitle, in ticks. There - * are 20 ticks per second. Use {@link TicksPerSecond} constant - * to convert between ticks and seconds. - * - */ - fadeOutDuration: number; - /** - * @remarks - * Amount of time for the title and subtitle to stay in place, - * in ticks. There are 20 ticks per second. Use {@link - * TicksPerSecond} constant to convert between ticks and - * seconds. - * - */ - stayDuration: number; - /** - * @remarks - * Optional subtitle text. - * - */ - subtitle?: (RawMessage | string)[] | RawMessage | string; -} - -/** - * @beta - * Represents a two-directional vector. - */ -export interface Vector2 { - /** - * @remarks - * X component of the two-dimensional vector. - * - */ - x: number; - /** - * @remarks - * Y component of the two-dimensional vector. - * - */ - y: number; -} - -/** - * @beta - * Contains a description of a vector. - */ -export interface Vector3 { - /** - * @remarks - * X component of this vector. - * - */ - x: number; - /** - * @remarks - * Y component of this vector. - * - */ - y: number; - /** - * @remarks - * Z component of this vector. - * - */ - z: number; -} - -/** - * @beta - * Contains additional options for a world-level playSound - * occurrence. - */ -export interface WorldSoundOptions { - /** - * @remarks - * Pitch of the sound played at the world level. - * - */ - pitch?: number; - /** - * @remarks - * Relative volume and space by which this sound is heard. - * - */ - volume?: number; -} - -/** - * @beta - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class CommandError extends Error { - private constructor(); -} - -/** - * @beta - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class LocationInUnloadedChunkError extends Error { - private constructor(); -} - -/** - * @beta - */ -// @ts-ignore Class inheritance allowed for native defined classes -export class LocationOutOfWorldBoundariesError extends Error { - private constructor(); -} - -/** - * @beta - * @remarks - * Holds the number of MoonPhases - * - */ -export const MoonPhaseCount = 8; -/** - * @beta - */ -export const TicksPerDay = 24000; -/** - * @beta - * @remarks - * How many times the server ticks per second of real time. - * - */ -export const TicksPerSecond = 20; -/** - * @remarks - * A class that provides system-level events and functions. - * - */ -export const system: System; -/** - * @remarks - * A class that wraps the state of a world - a set of - * dimensions and the environment of Minecraft. - * - */ -export const world: World; diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/package.json b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/package.json deleted file mode 100644 index a3d6ae7..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "@minecraft/server", - "version": "1.6.0-beta.1.20.30-preview.25", - "description": "", - "contributors": [ - { - "name": "Jake Shirley", - "email": "jake@xbox.com" - }, - { - "name": "Mike Ammerlaan", - "email": "mikeam@microsoft.com" - } - ], - "license": "MIT" -} \ No newline at end of file diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/tests.ts b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/tests.ts deleted file mode 100644 index 08757c6..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/tests.ts +++ /dev/null @@ -1,292 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unused-vars */ -import * as mc from '@minecraft/server'; - -export function createExplosion(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) { - const overworld = mc.world.getDimension('overworld'); - - log('Creating an explosion of radius 10.'); - overworld.createExplosion(targetLocation, 10); -} - -export function createNoBlockExplosion(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) { - const overworld = mc.world.getDimension('overworld'); - - const explodeNoBlocksLoc = { - x: Math.floor(targetLocation.x + 1), - y: Math.floor(targetLocation.y + 2), - z: Math.floor(targetLocation.z + 1), - }; - - log('Creating an explosion of radius 15 that does not break blocks.'); - overworld.createExplosion(explodeNoBlocksLoc, 15, { breaksBlocks: false }); -} - -export function createFireAndWaterExplosions( - log: (message: string, status?: number) => void, - targetLocation: mc.Vector3, -) { - const overworld = mc.world.getDimension('overworld'); - - const explosionLoc: mc.Vector3 = { - x: targetLocation.x + 0.5, - y: targetLocation.y + 0.5, - z: targetLocation.z + 0.5, - }; - - log('Creating an explosion of radius 15 that causes fire.'); - overworld.createExplosion(explosionLoc, 15, { causesFire: true }); - - const belowWaterLoc: mc.Vector3 = { x: targetLocation.x + 3, y: targetLocation.y + 1, z: targetLocation.z + 3 }; - - log('Creating an explosion of radius 10 that can go underwater.'); - overworld.createExplosion(belowWaterLoc, 10, { allowUnderwater: true }); -} - -export function itemStacks(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) { - const overworld = mc.world.getDimension('overworld'); - - const oneItemLoc: mc.Vector3 = { x: targetLocation.x + targetLocation.y + 3, y: 2, z: targetLocation.z + 1 }; - const fiveItemsLoc: mc.Vector3 = { x: targetLocation.x + 1, y: targetLocation.y + 2, z: targetLocation.z + 1 }; - const diamondPickaxeLoc: mc.Vector3 = { x: targetLocation.x + 2, y: targetLocation.y + 2, z: targetLocation.z + 4 }; - - const oneEmerald = new mc.ItemStack(mc.MinecraftItemTypes.emerald, 1, 0); - const onePickaxe = new mc.ItemStack(mc.MinecraftItemTypes.diamondPickaxe, 1, 0); - const fiveEmeralds = new mc.ItemStack(mc.MinecraftItemTypes.emerald, 5, 0); - - log(`Spawning an emerald at (${oneItemLoc.x}, ${oneItemLoc.y}, ${oneItemLoc.z})`); - overworld.spawnItem(oneEmerald, oneItemLoc); - - log(`Spawning five emeralds at (${fiveItemsLoc.x}, ${fiveItemsLoc.y}, ${fiveItemsLoc.z})`); - overworld.spawnItem(fiveEmeralds, fiveItemsLoc); - - log(`Spawning a diamond pickaxe at (${diamondPickaxeLoc.x}, ${diamondPickaxeLoc.y}, ${diamondPickaxeLoc.z})`); - overworld.spawnItem(onePickaxe, diamondPickaxeLoc); -} - -export function quickFoxLazyDog(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) { - const overworld = mc.world.getDimension('overworld'); - - const fox = overworld.spawnEntity('minecraft:fox', { - x: targetLocation.x + 1, - y: targetLocation.y + 2, - z: targetLocation.z + 3, - }); - fox.addEffect(mc.MinecraftEffectTypes.speed, 10, 20); - log('Created a fox.'); - - const wolf = overworld.spawnEntity('minecraft:wolf', { - x: targetLocation.x + 4, - y: targetLocation.y + 2, - z: targetLocation.z + 3, - }); - wolf.addEffect(mc.MinecraftEffectTypes.slowness, 10, 20); - wolf.isSneaking = true; - log('Created a sneaking wolf.', 1); -} - -export function runEntityCreatedEvent(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) { - // register a new function that is called when a new entity is created. - mc.world.events.entityCreate.subscribe((entityEvent: mc.EntityCreateEvent) => { - if (entityEvent && entityEvent.entity) { - log(`New entity of type '${entityEvent.entity}' created!`, 1); - } else { - log(`The entity event didn't work as expected.`, -1); - } - }); -} - -export function createOldHorse(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) { - const overworld = mc.world.getDimension('overworld'); - - log("Create a horse and triggering the 'ageable_grow_up' event, ensuring the horse is created as an adult"); - overworld.spawnEntity('minecraft:horse', targetLocation); -} - -export function pistonEvent(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) { - const pistonLoc: mc.Vector3 = { - x: Math.floor(targetLocation.x) + 1, - y: Math.floor(targetLocation.y) + 2, - z: Math.floor(targetLocation.z) + 1, - }; - - mc.world.events.beforePistonActivate.subscribe((pistonEvent: mc.BeforePistonActivateEvent) => { - if (pistonEvent.piston.location.equals(pistonLoc)) { - log('Cancelling piston event'); - pistonEvent.cancel = true; - } - }); -} - -export function spawnItem(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) { - const featherItem = new mc.ItemStack(mc.MinecraftItemTypes.feather, 1, 0); - - overworld.spawnItem(featherItem, targetLocation); - log(`New feather created at ${targetLocation.x}, ${targetLocation.y}, ${targetLocation.z}!`); -} - -export function testThatEntityIsFeatherItem( - log: (message: string, status?: number) => void, - targetLocation: mc.Vector3, -) { - const overworld = mc.world.getDimension('overworld'); - - const items = overworld.getEntities({ - location: targetLocation, - maxDistance: 20, - }); - - for (const item of items) { - const itemComp = item.getComponent('item') as any; - - if (itemComp) { - if (itemComp.itemStack.id.endsWith('feather')) { - log('Success! Found a feather', 1); - } - } - } -} - -export function trapTick() { - const overworld = mc.world.getDimension('overworld'); - - try { - // Minecraft runs at 20 ticks per second - if (ticks % 1200 === 0) { - overworld.runCommandAsync('say Another minute passes...'); - } - - ticks++; - } catch (e) { - console.warn('Error: ' + e); - } - - mc.system.run(trapTick); -} - -export default class SampleManager { - tickCount = 0; - - _availableFuncs: { - [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>; - }; - - pendingFuncs: Array<{ - name: string; - func: (log: (message: string, status?: number) => void, location: mc.Vector3) => void; - location: mc.Vector3; - }> = []; - - gameplayLogger(message: string, status?: number) { - if (status !== undefined && status > 0) { - message = 'SUCCESS: ' + message; - } else if (status !== undefined && status < 0) { - message = 'FAIL: ' + message; - } - - this.say(message); - } - say(message: string) { - mc.world.getDimension('overworld').runCommand('say ' + message); - } - - newChatMessage(chatEvent: mc.ChatEvent) { - const message = chatEvent.message.toLowerCase(); - - if (message.startsWith('howto') && chatEvent.sender) { - const nearbyBlock = chatEvent.sender.getBlockFromViewVector(); - if (!nearbyBlock) { - this.gameplayLogger('Please look at the block where you want me to run this.'); - return; - } - - const nearbyBlockLoc = nearbyBlock.location; - const nearbyLoc: mc.Vector3 = { x: nearbyBlockLoc.x, y: nearbyBlockLoc.y + 1, z: nearbyBlockLoc.z }; - - const sampleId = message.substring(5).trim(); - - if (sampleId.length < 2) { - let availableFuncStr = 'Here is my list of available samples:'; - - for (const sampleFuncKey in this._availableFuncs) { - availableFuncStr += ' ' + sampleFuncKey; - } - - this.say(availableFuncStr); - } else { - for (const sampleFuncKey in this._availableFuncs) { - if (sampleFuncKey.toLowerCase() === sampleId) { - const sampleFunc = this._availableFuncs[sampleFuncKey]; - - this.runSample(sampleFuncKey + this.tickCount, sampleFunc, nearbyLoc); - - return; - } - } - - this.say(`I couldn't find the sample '${sampleId}"'`); - } - } - } - - runSample( - sampleId: string, - snippetFunctions: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>, - targetLocation: mc.Vector3, - ) { - for (let i = snippetFunctions.length - 1; i >= 0; i--) { - this.pendingFuncs.push({ name: sampleId, func: snippetFunctions[i], location: targetLocation }); - } - } - - worldTick() { - if (this.tickCount % 10 === 0) { - if (this.pendingFuncs.length > 0) { - const funcSet = this.pendingFuncs.pop(); - - if (funcSet) { - funcSet.func(this.gameplayLogger, funcSet.location); - } - } - } - - this.tickCount++; - } - - constructor() { - this._availableFuncs = {}; - - this.gameplayLogger = this.gameplayLogger.bind(this); - - mc.world.events.tick.subscribe(this.worldTick.bind(this)); - mc.world.events.chat.subscribe(this.newChatMessage.bind(this)); - } - - registerSamples(sampleSet: { - [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>; - }) { - for (const sampleKey in sampleSet) { - if (sampleKey.length > 1 && sampleSet[sampleKey]) { - this._availableFuncs[sampleKey] = sampleSet[sampleKey]; - } - } - } -} - -const mojangMinecraftFuncs: { - [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>; -} = { - runEntityCreatedEvent: [runEntityCreatedEvent, createOldHorse], - createOldHorse: [createOldHorse], - spawnItem: [spawnItem, testThatEntityIsFeatherItem], - createNoBlockExplosion: [createExplosion], - createFireAndWaterExplosions: [createFireAndWaterExplosions], - createExplosion: [createExplosion], - itemStacks: [itemStacks], - quickFoxLazyDog: [quickFoxLazyDog], - pistonEvent: [pistonEvent], - trapTick: [trapTick], -}; - -export function register(sampleManager: SampleManager) { - sampleManager.registerSamples(mojangMinecraftFuncs); -} diff --git a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/tsconfig.json b/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/tsconfig.json deleted file mode 100644 index 2f66b0c..0000000 --- a/development_behavior_packs/NIA_V4.0_BP/node_modules/@minecraft/server/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": ["es6"], - "target": "es6", - "forceConsistentCasingInFileNames": true, - "noEmit": true, - "noImplicitAny": true, - "noImplicitThis": true, - "strictFunctionTypes": true, - "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": ["../"], - "types": [] - }, - "files": [ - "index.d.ts", - "tests.ts" - ] -} \ No newline at end of file