From 79cd57bee4e4c4f90704935ea26174e7b67cfe7e Mon Sep 17 00:00:00 2001 From: Qianshanyao Date: Sat, 27 Apr 2024 16:45:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A51.20.80=E6=AD=A3=E5=BC=8F?= =?UTF-8?q?=E7=89=88beta=E8=84=9A=E6=9C=ACAPI=E6=96=87=E6=A1=A3=EF=BC=8C?= =?UTF-8?q?=E5=90=8C=E6=AD=A51.21.0.23=E9=A2=84=E8=A7=88=E7=89=88=E8=84=9A?= =?UTF-8?q?=E6=9C=ACAPI=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 + bat/SapiFetchPreview.ps1 | 4 +- bat/SapiFetchStable.ps1 | 4 +- docusaurus.config.js | 62 +- .../current.json | 16 + i18n/en/docusaurus-theme-classic/navbar.json | 12 +- sidebars.js | 4 +- static/typedoc/preview/common.d.ts | 100 + static/typedoc/preview/server-admin.d.ts | 66 +- static/typedoc/preview/server-editor.d.ts | 3633 +++ static/typedoc/preview/server-gametest.d.ts | 503 +- static/typedoc/preview/server-net.d.ts | 104 +- static/typedoc/preview/server-ui.d.ts | 228 +- static/typedoc/preview/server.d.ts | 24072 ++++++++------- static/typedoc/stable/common.d.ts | 97 + static/typedoc/stable/server-admin.d.ts | 83 +- static/typedoc/stable/server-editor.d.ts | 3216 ++ static/typedoc/stable/server-gametest.d.ts | 939 +- static/typedoc/stable/server-net.d.ts | 182 +- static/typedoc/stable/server-ui.d.ts | 321 +- static/typedoc/stable/server.d.ts | 24674 +++++++++------- 21 files changed, 34404 insertions(+), 23920 deletions(-) create mode 100644 static/typedoc/preview/common.d.ts create mode 100644 static/typedoc/preview/server-editor.d.ts create mode 100644 static/typedoc/stable/common.d.ts create mode 100644 static/typedoc/stable/server-editor.d.ts diff --git a/.gitignore b/.gitignore index e5e8ce906a..3673811f6d 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,7 @@ yarn-error.log* /docs/sapi/preview/server-gametest/ /docs/sapi/preview/server-net/ /docs/sapi/preview/server-ui/ +/docs/sapi/stable/server-editor/ +/docs/sapi/stable/common/ +/docs/sapi/preview/common/ +/docs/sapi/preview/server-editor/ diff --git a/bat/SapiFetchPreview.ps1 b/bat/SapiFetchPreview.ps1 index 9d0ea50560..7ea892bc01 100644 --- a/bat/SapiFetchPreview.ps1 +++ b/bat/SapiFetchPreview.ps1 @@ -1,6 +1,8 @@ -cmd.exe /c npm i @minecraft/server@beta @minecraft/server-ui@beta @minecraft/server-gametest@beta @minecraft/server-admin@beta @minecraft/server-net@beta --save-dev +cmd.exe /c npm i @minecraft/common@1.2.0-rc.1.20.80-preview.21 @minecraft/server@1.12.0-beta.1.21.0-preview.23 @minecraft/server-editor@0.1.0-beta.1.21.0-preview.23 @minecraft/server-ui@1.2.0-beta.1.21.0-preview.23 @minecraft/server-gametest@1.0.0-beta.1.21.0-preview.23 @minecraft/server-admin@1.0.0-beta.1.21.0-preview.23 @minecraft/server-net@1.0.0-beta.1.21.0-preview.23 --save-dev Set-Location ../ +Copy-Item -Path ./node_modules/@minecraft/common/index.d.ts -Destination ./static/typedoc/preview/common.d.ts -Force Copy-Item -Path ./node_modules/@minecraft/server/index.d.ts -Destination ./static/typedoc/preview/server.d.ts -Force +Copy-Item -Path ./node_modules/@minecraft/server-editor/index.d.ts -Destination ./static/typedoc/preview/server-editor.d.ts -Force Copy-Item -Path ./node_modules/@minecraft/server-gametest/index.d.ts -Destination ./static/typedoc/preview/server-gametest.d.ts -Force Copy-Item -Path ./node_modules/@minecraft/server-ui/index.d.ts -Destination ./static/typedoc/preview/server-ui.d.ts -Force Copy-Item -Path ./node_modules/@minecraft/server-net/index.d.ts -Destination ./static/typedoc/preview/server-net.d.ts -Force diff --git a/bat/SapiFetchStable.ps1 b/bat/SapiFetchStable.ps1 index b2c98027e5..894a4820b9 100644 --- a/bat/SapiFetchStable.ps1 +++ b/bat/SapiFetchStable.ps1 @@ -1,6 +1,8 @@ -cmd.exe /c npm i @minecraft/server@1.1.0-beta.1.19.70-stable @minecraft/server-ui@1.0.0-beta.1.19.70-stable @minecraft/server-gametest@1.0.0-beta.1.19.70-stable @minecraft/server-admin@1.0.0-beta.1.19.70-stable @minecraft/server-net@1.0.0-beta.1.19.70-stable --save-dev +cmd.exe /c npm i @minecraft/common@1.2.0 @minecraft/server@1.11.0-beta.1.20.80-stable @minecraft/server-ui@1.2.0-beta.1.20.80-stable @minecraft/server-editor@0.1.0-beta.1.20.80-stable @minecraft/server-gametest@1.0.0-beta.1.20.80-stable @minecraft/server-admin@1.0.0-beta.1.20.80-stable @minecraft/server-net@1.0.0-beta.1.20.80-stable --save-dev Set-Location ../ +Copy-Item -Path ./node_modules/@minecraft/common/index.d.ts -Destination ./static/typedoc/stable/common.d.ts -Force Copy-Item -Path ./node_modules/@minecraft/server/index.d.ts -Destination ./static/typedoc/stable/server.d.ts -Force +Copy-Item -Path ./node_modules/@minecraft/server-editor/index.d.ts -Destination ./static/typedoc/stable/server-editor.d.ts -Force Copy-Item -Path ./node_modules/@minecraft/server-gametest/index.d.ts -Destination ./static/typedoc/stable/server-gametest.d.ts -Force Copy-Item -Path ./node_modules/@minecraft/server-ui/index.d.ts -Destination ./static/typedoc/stable/server-ui.d.ts -Force Copy-Item -Path ./node_modules/@minecraft/server-net/index.d.ts -Destination ./static/typedoc/stable/server-net.d.ts -Force diff --git a/docusaurus.config.js b/docusaurus.config.js index c1e87b622a..2916b37b41 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -38,6 +38,22 @@ const config = { } }, plugins: [ + [ + 'docusaurus-plugin-typedoc', + // Plugin / TypeDoc options + { + id: 'preview-common', + entryPoints: ['./static/typedoc/preview/common.d.ts'], + tsconfig: './static/typedoc/preview/tsconfig.json', + out: 'sapi/preview/common', + sidebar: { + categoryLabel: 'sapiPreviewSidebar', + collapsed: false, + position: 0, + fullNames: true, + }, + }, + ], [ 'docusaurus-plugin-typedoc', // Plugin / TypeDoc options @@ -102,7 +118,37 @@ const config = { out: 'sapi/preview/server-gametest' }, ], + [ + 'docusaurus-plugin-typedoc', + // Plugin / TypeDoc options + { + id: 'preview-server-editor', + entryPoints: [ + './static/typedoc/preview/server-editor.d.ts', + ], + tsconfig: './static/typedoc/preview/tsconfig.json', + out: 'sapi/preview/server-editor' + }, + ], // ----------------------------------------------------- + [ + 'docusaurus-plugin-typedoc', + // Plugin / TypeDoc options + { + id: 'stable-common', + entryPoints: [ + './static/typedoc/stable/common.d.ts' + ], + tsconfig: './static/typedoc/stable/tsconfig.json', + out: 'sapi/stable/common', + sidebar: { + categoryLabel: 'sapiStableSidebar', + collapsed: false, + position: 0, + fullNames: true, + } + }, + ], [ 'docusaurus-plugin-typedoc', // Plugin / TypeDoc options @@ -169,6 +215,18 @@ const config = { out: 'sapi/stable/server-gametest' } ], + [ + 'docusaurus-plugin-typedoc', + // Plugin / TypeDoc options + { + id: 'stable-server-editor', + entryPoints: [ + './static/typedoc/stable/server-editor.d.ts', + ], + tsconfig: './static/typedoc/stable/tsconfig.json', + out: 'sapi/stable/server-editor' + } + ], // -------------------------------------- [ 'docusaurus-plugin-typedoc', @@ -266,11 +324,11 @@ const config = { items: [ { to: '/docs/sapi/stable', - label: '稳定版 [1.19.70]', + label: '稳定版 [1.20.80]', }, { to: '/docs/sapi/preview', - label: '预览版 [1.19.80.24]', + label: '预览版 [1.21.0.23]', } ] }, diff --git a/i18n/en/docusaurus-plugin-content-docs/current.json b/i18n/en/docusaurus-plugin-content-docs/current.json index e063dd1518..8ff16fa5c9 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current.json +++ b/i18n/en/docusaurus-plugin-content-docs/current.json @@ -51,6 +51,10 @@ "message": "Script API Documentation", "description": "The label for the doc item 脚本API文档 in sidebar sapiStableSidebar, linking to the doc sapi/stable/README" }, + "sidebar.sapiPreviewSidebar.category.@minecraft/common": { + "message": "@minecraft/common", + "description": "The label for category @minecraft/common in sidebar sapiPreviewSidebar" + }, "sidebar.sapiPreviewSidebar.category.@minecraft/server": { "message": "@minecraft/server", "description": "The label for category @minecraft/server in sidebar sapiPreviewSidebar" @@ -71,6 +75,14 @@ "message": "@minecraft/server-gametest", "description": "The label for category @minecraft/server-gametest in sidebar sapiPreviewSidebar" }, + "sidebar.sapiPreviewSidebar.category.@minecraft/server-editor": { + "message": "@minecraft/server-editor", + "description": "The label for category @minecraft/server-editor in sidebar sapiPreviewSidebar" + }, + "sidebar.sapiStableSidebar.category.@minecraft/common": { + "message": "@minecraft/common", + "description": "The label for category @minecraft/common in sidebar sapiStableSidebar" + }, "sidebar.sapiStableSidebar.category.@minecraft/server": { "message": "@minecraft/server", "description": "The label for category @minecraft/server in sidebar sapiStableSidebar" @@ -90,5 +102,9 @@ "sidebar.sapiStableSidebar.category.@minecraft/server-gametest": { "message": "@minecraft/server-gametest", "description": "The label for category @minecraft/server-gametest in sidebar sapiStableSidebar" + }, + "sidebar.sapiStableSidebar.category.@minecraft/server-editor": { + "message": "@minecraft/server-editor", + "description": "The label for category @minecraft/server-editor in sidebar sapiStableSidebar" } } diff --git a/i18n/en/docusaurus-theme-classic/navbar.json b/i18n/en/docusaurus-theme-classic/navbar.json index 9524e2bd19..b34da66628 100644 --- a/i18n/en/docusaurus-theme-classic/navbar.json +++ b/i18n/en/docusaurus-theme-classic/navbar.json @@ -31,12 +31,12 @@ "message": "Preview", "description": "Navbar item with label 预览版" }, - "item.label.稳定版 [1.19.70]": { - "message": "Stable [1.19.70]", - "description": "Navbar item with label 稳定版 [1.19.70]" + "item.label.稳定版 [1.20.80]": { + "message": "Stable [1.20.80]", + "description": "Navbar item with label 稳定版 [1.20.80]" }, - "item.label.预览版 [1.19.80.24]": { - "message": "Preview [1.19.80.24]", - "description": "Navbar item with label 预览版 [1.19.80.24]" + "item.label.预览版 [1.21.0.23]": { + "message": "Preview [1.21.0.23]", + "description": "Navbar item with label 预览版 [1.21.0.23]" } } diff --git a/sidebars.js b/sidebars.js index 5222933b8c..cc0d562e22 100644 --- a/sidebars.js +++ b/sidebars.js @@ -10,11 +10,13 @@ */ const moduleNames = { + 'common': ['classes', 'interfaces'], 'server': ['classes', 'interfaces', 'enums'], 'server-ui': ['classes', 'enums'], 'server-admin': ['classes'], 'server-net': ['classes', 'enums'], - 'server-gametest': ['classes'] + 'server-gametest': ['classes'], + 'server-editor': ['classes', 'interfaces', 'enums'] }; const genSapiModuleSidebar = function (path, moduleName, moduleParseResultItemNameArr) { const ret = { diff --git a/static/typedoc/preview/common.d.ts b/static/typedoc/preview/common.d.ts new file mode 100644 index 0000000000..d0f57e789a --- /dev/null +++ b/static/typedoc/preview/common.d.ts @@ -0,0 +1,100 @@ +// 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 + * + * Manifest Details + * ```json + * { + * "module_name": "@minecraft/common", + * "version": "1.1.0" + * } + * ``` + * + */ +/** + * 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; +} + +/** + * This type of error is thrown when a parameter to a method or + * property is out of expected bounds. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class ArgumentOutOfBoundsError extends Error { + private constructor(); + /** + * @remarks + * Max expected value for the condition. + * + */ + maxValue: number; + /** + * @remarks + * Min expected value for the condition. + * + */ + minValue: number; + /** + * @remarks + * Passed-in value for the argument. + * + */ + value: number; +} + +/** + * Specifies an underlying error in the engine in processing a + * function. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class EngineError extends Error { + private constructor(); +} + +/** + * Specifies that a passed-in argument to a method is not + * correct or allowed. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class InvalidArgumentError extends Error { + private constructor(); + /** + * @remarks + * Index of the argument that is in error. + * + */ + index: number; +} + +/** + * @beta + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class PropertyOutOfBoundsError extends Error { + private constructor(); + maxValue: number; + minValue: number; + value: number; +} diff --git a/static/typedoc/preview/server-admin.d.ts b/static/typedoc/preview/server-admin.d.ts index cf05205e24..b725752edc 100644 --- a/static/typedoc/preview/server-admin.d.ts +++ b/static/typedoc/preview/server-admin.d.ts @@ -18,11 +18,12 @@ * ```json * { * "module_name": "@minecraft/server-admin", - * "version": "1.0.0-beta.1.20.0-preview.20" + * "version": "1.0.0-beta.1.21.0-preview.23" * } * ``` * */ +import * as minecraftcommon from '@minecraft/common'; /** * This represents a placeholder object that represents a * secret string. The contents of that string are not available @@ -31,12 +32,41 @@ export class SecretString { constructor(value: string); } + /** * A collection of server secrets defined in dedicated server * configuration. + * @example getPlayerProfile.ts + * ```typescript + * import { variables, secrets } from "@minecraft/server-admin"; + * import { http, HttpRequest, HttpRequestMethod, HttpHeader, HttpResponse } from "@minecraft/server-net"; + * + * const serverUrl = variables.get('serverEndpoint'); + * + * function getPlayerProfile(playerId: string): Promise { + * const req = new HttpRequest(serverUrl + 'getPlayerProfile'); + * + * req.body = JSON.stringify({ + * playerId, + * }); + * + * const authTokenSec = secrets.get('authtoken'); + * + * if (!authTokenSec) { + * throw new Error('authtoken secret not defined.'); + * } + * + * req.method = HttpRequestMethod.Post; + * req.headers = [new HttpHeader('Content-Type', 'application/json'), new HttpHeader('auth', authTokenSec)]; + * + * return http.request(req); + * } + * + * getPlayerProfile('dark navi'); + * ``` */ export class ServerSecrets { - protected constructor(); + private constructor(); /** * @remarks * A list of available, configured server secrets. @@ -55,12 +85,41 @@ export class ServerSecrets { */ get(name: string): SecretString | undefined; } + /** * A collection of server variables defined in dedicated server * configuration. + * @example getPlayerProfile.ts + * ```typescript + * import { variables, secrets } from "@minecraft/server-admin"; + * import { http, HttpRequest, HttpRequestMethod, HttpHeader, HttpResponse } from "@minecraft/server-net"; + * + * const serverUrl = variables.get('serverEndpoint'); + * + * function getPlayerProfile(playerId: string): Promise { + * const req = new HttpRequest(serverUrl + 'getPlayerProfile'); + * + * req.body = JSON.stringify({ + * playerId, + * }); + * + * const authTokenSec = secrets.get('authtoken'); + * + * if (!authTokenSec) { + * throw new Error('authtoken secret not defined.'); + * } + * + * req.method = HttpRequestMethod.Post; + * req.headers = [new HttpHeader('Content-Type', 'application/json'), new HttpHeader('auth', authTokenSec)]; + * + * return http.request(req); + * } + * + * getPlayerProfile('dark navi'); + * ``` */ export class ServerVariables { - protected constructor(); + private constructor(); /** * @remarks * A list of available, configured server variables. @@ -77,6 +136,7 @@ export class ServerVariables { */ get(name: string): any | undefined; } + /** * @remarks * A globally available object that returns a list of diff --git a/static/typedoc/preview/server-editor.d.ts b/static/typedoc/preview/server-editor.d.ts new file mode 100644 index 0000000000..662b79798d --- /dev/null +++ b/static/typedoc/preview/server-editor.d.ts @@ -0,0 +1,3633 @@ +// 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 + * + * Manifest Details + * ```json + * { + * "module_name": "@minecraft/server-editor", + * "version": "0.1.0-beta.1.21.0-preview.23" + * } + * ``` + * + */ +import * as minecraftcommon from '@minecraft/common'; +import * as minecraftserver from '@minecraft/server'; +/** + * The types of actions that are supported. This type + * corresponds to the expected arguments passed by the + * onExecute handler of an action. + */ +export declare enum ActionTypes { + MouseRayCastAction = 'MouseRayCastAction', + NoArgsAction = 'NoArgsAction', +} + +export enum BlockPaletteItemType { + Simple = 0, + Probability = 1, +} + +/** + * Predefined top level menus for core editor + */ +export declare enum CoreMenuType { + Edit = 'editor:menu:edit', + Experimental = 'editor:menu:experimental', + Extensions = 'editor:menu:extensions', + File = 'editor:menu:file', + Help = 'editor:menu:help', + View = 'editor:menu:view', + WorldOptions = 'editor:menu:worldOptions', +} + +/** + * An enumeration used by the 3D block cursor {@link Cursor} + */ +export enum CursorControlMode { + /** + * @remarks + * Using Keyboard mode will remove the dependence of the 3D + * block cursor on the player mouse position. The 3D block + * cursor can be positioned using the keyboard (or the Cursor + * move methods on the cursor object) and the position will not + * be reset if the mouse is moved + * + */ + Keyboard = 0, + /** + * @remarks + * The Mouse movement mode will disable keyboard or manual 3D + * block cursor movement and make the 3D block cursor only + * react to player mouse movement + * + */ + Mouse = 1, + /** + * @remarks + * This is generally the default move mode for the 3D block + * cursor. + * The 3D block cursor can be positioned using the keyboard (or + * the Cursor move methods on the cursor object) but the + * position will be reset to the block location under the + * players mouse position if any mouse movement is detected. + * + */ + KeyboardAndMouse = 2, + /** + * @remarks + * When in fixed mode, the 3D block cursor will remain in a + * fixed position directly in front of the players facing + * direction. It cannot be moved without moving the player (or + * adjusting the fixed block distance). + * This mode is useful for addressing block locations in the + * air (put the cursor into fixed mode, and fly the player + * until the desired air block is beneath the cursor, at which + * point it is selectable without being clickable) + * + */ + Fixed = 3, +} + +/** + * Describes how the cursor targets a point on the screen. + */ +export enum CursorTargetMode { + /** + * @remarks + * Target a nearest block. + * + */ + Block = 0, + /** + * @remarks + * Targets the face of a nearest block. + * + */ + Face = 1, +} + +/** + * Type of item that can be added to the property pane + */ +export declare enum EDITOR_PANE_PROPERTY_ITEM_TYPE { + Action = 'editorUI:Action', + BlockPicker = 'editorUI:BlockPicker', + Boolean = 'editorUI:Boolean', + Divider = 'editorUI:Divider', + Dropdown = 'editorUI:Dropdown', + Image = 'editorUI:Image', + Number = 'editorUI:Number', + String = 'editorUI:String', + SubPane = 'editorUI:SubPane', + Text = 'editorUI:Text', + Vec3 = 'editorUI:Vec3', +} + +/** + * Global editor input contexts + */ +export declare enum EditorInputContext { + GlobalEditor = 'global.editor', + GlobalToolMode = 'global.toolMode', + Viewport = 'local.toolMode.viewport', +} + +/** + * Enumeration representing the different modes Editor can be + * in. + */ +export enum EditorMode { + /** + * @remarks + * Mode for single-block editing. + * + */ + Crosshair = 'Crosshair', + /** + * @remarks + * Mode for multi-block editing UI and tools. + * + */ + Tool = 'Tool', +} + +export declare enum EditorStatusBarAlignment { + Right = 0, + Left = 1, +} + +export enum ExportResult { + ValidWorldExport = 0, + LevelFetchFailed = 1, + FileArchiverFetchFailed = 2, + ProjectConverterFetchFailed = 3, + PlayerNotFound = 4, + WorldExportFailed = 5, + WorldExportBusy = 6, + EditorSystemFailure = 7, +} + +/** + * Enumeration representing identifiers for graphics settings + * properties. + */ +export enum GraphicsSettingsProperty { + /** + * @remarks + * Manages rendering of invisible blocks (e.g., barrier, light, + * structure_void). + * + */ + ShowInvisibleBlocks = 'ShowInvisibleBlocks', +} + +/** + * Input modifier flags to create chorded bindings + */ +export declare enum InputModifier { + Unused = 0, + None = 1, + Alt = 2, + Control = 4, + Shift = 8, + Any = 15, +} + +/** + * Keyboard key + */ +export declare enum KeyboardKey { + BACKSPACE = 8, + TAB = 9, + ENTER = 13, + SHIFT = 16, + CTRL = 17, + ALT = 18, + CAPS_LOCK = 20, + ESCAPE = 27, + SPACE = 32, + PAGE_UP = 33, + PAGE_DOWN = 34, + END = 35, + HOME = 36, + LEFT = 37, + UP = 38, + RIGHT = 39, + DOWN = 40, + PRINT_SCREEN = 44, + INSERT = 45, + DELETE = 46, + KEY_0 = 48, + KEY_1 = 49, + KEY_2 = 50, + KEY_3 = 51, + KEY_4 = 52, + KEY_5 = 53, + KEY_6 = 54, + KEY_7 = 55, + KEY_8 = 56, + KEY_9 = 57, + KEY_A = 65, + KEY_B = 66, + KEY_C = 67, + KEY_D = 68, + KEY_E = 69, + KEY_F = 70, + KEY_G = 71, + KEY_H = 72, + KEY_I = 73, + KEY_J = 74, + KEY_K = 75, + KEY_L = 76, + KEY_M = 77, + KEY_N = 78, + KEY_O = 79, + KEY_P = 80, + KEY_Q = 81, + KEY_R = 82, + KEY_S = 83, + KEY_T = 84, + KEY_U = 85, + KEY_V = 86, + KEY_W = 87, + KEY_X = 88, + KEY_Y = 89, + KEY_Z = 90, + NUMPAD_0 = 96, + NUMPAD_1 = 97, + NUMPAD_2 = 98, + NUMPAD_3 = 99, + NUMPAD_4 = 100, + NUMPAD_5 = 101, + NUMPAD_6 = 102, + NUMPAD_7 = 103, + NUMPAD_8 = 104, + NUMPAD_9 = 105, + NUMPAD_MULTIPLY = 106, + NUMPAD_ADD = 107, + NUMPAD_SEPARATOR = 108, + NUMPAD_SUBTRACT = 109, + NUMPAD_DECIMAL = 110, + NUMPAD_DIVIDE = 111, + F1 = 112, + F2 = 113, + F3 = 114, + F4 = 115, + F5 = 116, + F6 = 117, + F7 = 118, + F8 = 119, + F9 = 120, + F10 = 121, + F11 = 122, + F12 = 123, + COMMA = 188, + PERIOD = 190, + SLASH = 191, + BACK_QUOTE = 192, + BRACKET_OPEN = 219, + BACK_SLASH = 220, + BRACKET_CLOSE = 221, + QUOTE = 222, +} + +/** + * Keyboard Key Actions + */ +export declare enum KeyInputType { + /** + * @remarks + * Button was pressed. + * + */ + Press = 1, + /** + * @remarks + * Button was released. + * + */ + Release = 2, +} + +/** + * Layout directions for property panes. + */ +export declare enum LayoutDirection { + Vertical = 0, + Horizontal = 1, +} + +/** + * Mouse device action categories + */ +export declare enum MouseActionCategory { + /** + * @remarks + * Mouse button was used. + * + */ + Button = 1, + /** + * @remarks + * Mouse wheel was used. + * + */ + Wheel = 2, + /** + * @remarks + * Mouse was dragged. + * + */ + Drag = 3, +} + +/** + * Detailed mouse device actions + */ +export declare enum MouseActionType { + LeftButton = 1, + MiddleButton = 2, + RightButton = 3, + Wheel = 4, +} + +/** + * Input event information about mouse actions + */ +export declare enum MouseInputType { + ButtonDown = 1, + ButtonUp = 2, + WheelIn = 3, + WheelOut = 4, + DragStart = 5, + Drag = 6, + DragEnd = 7, +} + +export enum PlaytestSessionResult { + OK = 0, + InvalidSessionHandle = 1, + SessionInfoNotFound = 2, + TooManyPlayers = 3, + WorldExportFailed = 4, + WorldExportBusy = 5, + UnsupportedScenario = 6, + EditorSystemFailure = 7, + InvalidLevelId = 8, + PlayerNotFound = 9, + ResponseTimeout = 10, + UnspecifiedError = 11, +} + +export enum ProjectExportType { + PlayableWorld = 0, + ProjectBackup = 1, + WorldTemplate = 2, +} + +/** + * Define the visibility of the status bar item If the tool + * does not have an `ISimpleToolPropertyPane` component, then + * this option is ignored + */ +export declare enum SimpleToolStatusBarVisibility { + AlwaysVisible = 0, + VisibleWhenActive = 1, +} + +export enum WidgetGroupSelectionMode { + Multiple = 'Multiple', + None = 'None', + Single = 'Single', +} + +/** + * Defines type information for graphics settings properties. + */ +export type GraphicsSettingsPropertyTypeMap = { + [GraphicsSettingsProperty.ShowInvisibleBlocks]?: boolean; +}; + +/** + * Full set of all possible raw actions + */ +export type Action = NoArgsAction | MouseRayCastAction; + +/** + * All actions have a unique identifier. Identifiers are + * globally unique and often GUIDs + */ +export type ActionID = { + id: string; +}; + +/** + * Callback type when an extension instance is activated for a + * given player. It is expected to return an array of + * disposables that will automatically be cleaned up on + * shutdown. + */ +export type ActivationFunctionType = ( + uiSession: IPlayerUISession, +) => IDisposable[]; + +/** + * The possible variants of a button. + */ +export declare type ButtonVariant = 'secondary' | 'primary' | 'destructive' | 'hero'; + +/** + * A generic handler for an event sink. + */ +export declare type EventHandler = (eventArg: T) => void; + +/** + * A property item which supports bound actions and replacing + * the bound action + */ +export type IActionPropertyItem = IPropertyItem & { + replaceBoundAction(action: RegisteredAction | undefined): void; +}; + +/** + * A property item which supports Dropdown properties + */ +export type IDropdownPropertyItem< + T extends Omit & { + [key in Prop]: number; + }, + Prop extends keyof T & string, +> = IPropertyItem & IDropdownPropertyItemMixIn; + +/** + * The IPlayerUISession represents the editor user interface + * for a given player and given extension. Extensions + * registered with Minecraft are instantiated for each player + * which joins a server, and this interface provides the set of + * functionality needed to create and modify the editor UI for + * that player. The associated Editor Context for this session + * object is also player specific. From a given + * IPlayerUISession object, there is no way to interact with + * the UI of another player, that must be done from global + * extension scope registration and/or data sharing independent + * of the UI object. + */ +export type IPlayerUISession> = { + createStatusBarItem(alignment: EditorStatusBarAlignment, size: number): IStatusBarItem; + createPropertyPane(options: IPropertyPaneOptions): IPropertyPane; + readonly actionManager: ActionManager; + readonly inputManager: IGlobalInputManager; + readonly menuBar: IMenuContainer; + readonly toolRail: IModalToolContainer; + readonly log: IPlayerLogger; + readonly extensionContext: ExtensionContext; + readonly builtInUIManager: BuiltInUIManager; + readonly eventSubscriptionCache: BedrockEventSubscriptionCache; + scratchStorage: PerPlayerStorage | undefined; +}; + +/** + * A property item which supports Vector3 properties + */ +export type IVector3PropertyItem = IPropertyItem & { + updateAxisLimits(limits: { + minX?: number; + maxX?: number; + minY?: number; + maxY?: number; + minZ?: number; + maxZ?: number; + }): void; +}; + +/** + * Modal tool lifecycle event payload + */ +export type ModalToolLifecycleEventPayload = { + isActiveTool: boolean; +}; + +/** + * Input modifier states for mouse actions + */ +export declare type MouseModifiers = { + alt: boolean; + ctrl: boolean; + shift: boolean; +}; + +/** + * Mouse properties that provide additional information from + * client event handling + */ +export declare type MouseProps = { + mouseAction: MouseActionType; + modifiers: MouseModifiers; + inputType: MouseInputType; +}; + +/** + * An action which returns the ray corresponding to a vector + * from the users mouse click in the viewport. + */ +export type MouseRayCastAction = { + actionType: ActionTypes.MouseRayCastAction; + readonly onExecute: (mouseRay: Ray, mouseProps: MouseProps) => void; +}; + +/** + * An action which needs no additional client side arguments on + * execute + */ +export type NoArgsAction = { + actionType: ActionTypes.NoArgsAction; + readonly onExecute: () => void; +}; + +/** + * Callback to execute when a value of a property item is + * updated. + */ +export type OnChangeCallback = ( + obj: T, + property: Prop, + oldValue: object, + newValue: object, +) => void; + +export type PropertyBag = Record; + +/** + * Callback to execute when a visibility of a property pane is + * updated. + */ +export type PropertyPaneVisibilityUpdate = { + isVisible: boolean; +}; + +/** + * Ray representing a direction from a set location. This + * location typically corresponds to the location of a mouse + * click performed on the client. + */ +export type Ray = { + location: minecraftserver.Vector3; + direction: minecraftserver.Vector3; + cursorBlockLocation: minecraftserver.Vector3; + rayHit: boolean; +}; + +/** + * A registered action is an action that has been registered + * with the action manager system and has a unique ID + * representing the action now. An action must be registered + * before it can be used in other systems. + */ +export type RegisteredAction = T & ActionID; + +/** + * Callback type when an extension instance is shutdown for a + * given player. Used for performing any final work or clean up + * that can't be handled automatically via Disposables. + */ +export type ShutdownFunctionType = (uiSession: IPlayerUISession) => void; + +/** + * Full set of all possible keyboard actions + */ +export type SupportedKeyboardActionTypes = RegisteredAction; + +/** + * Full set of all possible mouse actions + */ +export type SupportedMouseActionTypes = RegisteredAction; + +export type UnregisterInputBindingCallback = () => void; + +/** + * A cache for bedrock event subscriptions. Stores off a + * subscription by event key, and upon teardown unregisters all + * subscriptions. + */ +export declare class BedrockEventSubscriptionCache { + /** + * @remarks + * Constructs a new instance of the + * `BedrockEventSubscriptionCache` class + * + */ + constructor(mEvents: minecraftserver.WorldAfterEvents); + /** + * @remarks + * Subcribes to a bedrock event using the key of the desired + * event. When subscribed, the event handler is both returned, + * but also cached internally for unsubscription. This means + * the caller of the subscription does not need to worry about + * unsubscription since the cache will automatically + * unsubscribe handlers on overall teardown. + * + * @param event + * The event on the bedrock APIs to which to subscribe + * @param params + * The parameters to the subscription method for the event. + * Auto complete will display this for you + */ + subscribeToBedrockEvent( + event: T, + ...params: Parameters + ): ReturnType; + /** + * @remarks + * Cleans up the set of internal registrations and + * subscriptions. + * + */ + teardown(): void; +} + +export class BlockPalette { + /** + * @throws This function can throw errors. + * + * {@link minecraftcommon.ArgumentOutOfBoundsError} + */ + getItem(index: number): IBlockPaletteItem; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + * + * {@link minecraftcommon.ArgumentOutOfBoundsError} + */ + removeItemAt(index: number): void; + /** + * @remarks + * This function can't be called in read-only mode. + * + */ + removeItems(): void; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + * + * {@link minecraftcommon.ArgumentOutOfBoundsError} + */ + setItem(blockPaletteItem: IBlockPaletteItem, index: number): void; +} + +export class BlockPaletteManager { + private constructor(); + /** + * @throws This function can throw errors. + */ + getSelectedBlockType(): minecraftserver.BlockType; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + setSelectedBlockType(block: minecraftserver.BlockType): void; +} + +export class BrushShapeManager { + private constructor(); + readonly activeBrushShape?: BrushShape; + readonly activeBrushVolume?: minecraftserver.CompoundBlockVolume; + readonly brushShapeNames: string[]; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + activateBrushShape(name: string): minecraftserver.CompoundBlockVolume; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + getSettingsUIElements(brushName: string): SettingsUIElement[]; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + registerBrushShape( + name: string, + icon: string, + rebuild: () => minecraftserver.CompoundBlockVolume, + getSettingsUIElements: () => SettingsUIElement[], + ): void; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + uiSettingValueChanged(elementName: string, newValue: boolean | number | string | minecraftserver.Vector3): boolean; +} + +/** + * A ClipboardItem is a handle to an object which represents a + * set of blocks in a contained bounding area (most likely + * copied from the world) + */ +export class ClipboardItem { + private constructor(); + /** + * @remarks + * Return whether there is any block content in the item + * + * @throws This property can throw when used. + */ + readonly isEmpty: boolean; + /** + * @remarks + * Clear the contents of the item + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + clear(): void; + /** + * @remarks + * Create a {@link @minecraft/server.CompoundBlockVolume} + * container which represents the occupied block volumes within + * the ClipboardItem. + * This function does not perform any write operations, and + * instead returns only a prediction of the volume area which + * would be affected as part of a write operation with a given + * set of write options. + * + * This function can't be called in read-only mode. + * + * @param location + * A world location to which the ClipboardItem may potentially + * be written (nothing is actually written as part of this + * operation) + * @param options + * An optional set of write parameters which govern how the + * ClipboardItem should be potentially applied to the world + * @returns + * A {@link @minecraft/server.CompoundBlockVolume} which + * represents the occupied block volumes within the + * ClipboardItem as they would be written to the world with the + * specified {@link ClipboardWriteOptions} + * @throws This function can throw errors. + */ + getPredictedWriteAsCompoundBlockVolume( + location: minecraftserver.Vector3, + options?: ClipboardWriteOptions, + ): minecraftserver.CompoundBlockVolume; + /** + * @remarks + * Create a {@link Selection} container which represents the + * occupied block volumes within the ClipboardItem. + * This function does not perform any write operations, and + * instead returns only a prediction of the volume area which + * would be affected as part of a write operation with a given + * set of write options. + * + * This function can't be called in read-only mode. + * + * @param location + * A world location to which the ClipboardItem may potentially + * be written (nothing is actually written as part of this + * operation) + * @param options + * An optional set of write parameters which govern how the + * ClipboardItem should be potentially applied to the world + * @returns + * A {@link Selection} which represents the occupied block + * volumes within the ClipboardItem as they would be written to + * the world with the specified {@link ClipboardWriteOptions} + * @throws This function can throw errors. + */ + getPredictedWriteAsSelection(location: minecraftserver.Vector3, options?: ClipboardWriteOptions): Selection; + /** + * @remarks + * Get the bounding size of the ClipboardItem + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + getSize(): minecraftserver.Vector3; + /** + * @remarks + * Copy the contents of the area represented by a {@link + * Selection} volume into the ClipboardItem + * + * This function can't be called in read-only mode. + * + * @param selection + * A volume which represents the area to be copied + * @throws This function can throw errors. + */ + readFromSelection(selection: Selection): void; + /** + * @remarks + * Copy the contents of a rectangular volume into the Clipboard + * Item + * + * This function can't be called in read-only mode. + * + * @param from + * The world location of one corner of a bounding volume + * @param to + * The world location of the opposite corner of a bounding + * volume + * @throws This function can throw errors. + */ + readFromWorld(from: minecraftserver.Vector3, to: minecraftserver.Vector3): void; + /** + * @remarks + * Apply the contents of a ClipboardItem to the world at a + * given location using a set of write options + * + * This function can't be called in read-only mode. + * + * @param location + * The root point of the world location to which the + * ClipboardItem is written (this is modified by the various + * anchor, offset and rotation parameters of the {@link + * ClipboardWriteOptions} + * @param options + * An optional set of write parameters which modify the + * properties of the ClipboardItem as it is applied to the + * world + * @returns + * Success or Failure + * @throws This function can throw errors. + */ + writeToWorld(location: minecraftserver.Vector3, options?: ClipboardWriteOptions): boolean; +} + +/** + * The ClipboardManager (accessible from the {@link + * ExtensionContext}) is responsible for the management of all + * {@link ClipboardItem} objects, and provides the user the + * ability to create new {@link ClipboardItem} objects for use + * within an extension. + * + */ +export class ClipboardManager { + private constructor(); + /** + * @remarks + * The primary {@link ClipboardItem} object is always present + * (even if it's empty) and cannot be deleted. This object + * represents the main ClipboardItem object which is always + * accessible through the UI for cut/paste operations + * + * @throws This property can throw when used. + */ + readonly clipboard: ClipboardItem; + /** + * @remarks + * Create a new {@link ClipboardItem} object + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + create(): ClipboardItem; +} + +/** + * The 3D block cursor is controlled through this read only + * object and provides the Editor some control over the input + * methods, display properties and positioning of the 3D block + * cursor within the world. + * The 3D block cursor is a native object which is constantly + * calculating a screen/mouse -> world raycast, and recording + * the resultant block collision position and facing direction. + * Depending on the properties of the cursor state, this is not + * always true – the cursor can also be manually manipulated by + * keyboard input and moved around independently of mouse + * movement; when the mouse is moved, the block cursor will + * return to the mouse/world ray intersection point. + * The cursor can also be set to either block or face mode; + * block mode represents the block the mouse is pointing at, + * and face mode represents the adjacent block that the mouse + * is pointing at (i.e. the block attached to the face of the + * intersection point). + * In practical use, each tool when activated grabs the current + * cursor state object and stores it. The active tool then + * sets the current state to represent the functionality of the + * tool (color, input mode, etc). When the tool loses focus, + * it restores the cursor state using the stored state object + * that was grabbed during activation. + * The 3D block cursor can also be used to query the current + * block at which the mouse is pointing (or the current block + * to which the cursor has been manually moved by the user) + */ +export class Cursor { + private constructor(); + /** + * @remarks + * The face at of the block beneath the 3D block cursor which + * is intersected by the mouse raycast + * + * @throws This property can throw when used. + */ + readonly faceDirection: number; + /** + * @remarks + * Query whether or not the 3D block cursor is visible or + * hidden + * + * @throws This property can throw when used. + */ + readonly isVisible: boolean; + /** + * @remarks + * Get the world position of the 3D block cursor + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + getPosition(): minecraftserver.Vector3; + /** + * @remarks + * Get a property object which represents the current + * properties of the 3D block cursor. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + getProperties(): CursorProperties; + /** + * @remarks + * Hide the 3D block cursor from view until the corresponding + * {@link @minecraft-server-editor.Cursor.show} function is + * called + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + hide(): void; + /** + * @remarks + * Manually offset the 3D block cursor by given amount. + * Depending on the {@link + * @minecraft-server-editor.CursorProperties.CursorControlMode} + * - this function may have no effect + * + * This function can't be called in read-only mode. + * + * @param offset + * Amount by which the 3D block cursor should be moved + * @returns + * Return the newly modified position (or previous position if + * movement was restricted) + * @throws This function can throw errors. + */ + moveBy(offset: minecraftserver.Vector3): minecraftserver.Vector3; + /** + * @remarks + * Reset the 3D block cursor to the system default state + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + resetToDefaultState(): void; + /** + * @remarks + * Set the 3D block cursor properties to a given state + * + * This function can't be called in read-only mode. + * + * @param properties + * A set of optional parameters within a property state which + * represent the intended 3D block cursor state + * @throws This function can throw errors. + */ + setProperties(properties: CursorProperties): void; + /** + * @remarks + * Make the 3D block cursor visible on screen + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + show(): void; +} + +export class CursorPropertiesChangeAfterEvent { + private constructor(); + readonly properties: CursorProperties; +} + +export class CursorPropertyChangeAfterEventSignal { + private constructor(); + /** + * @remarks + * This function can't be called in read-only mode. + * + */ + subscribe( + callback: (arg: CursorPropertiesChangeAfterEvent) => void, + ): (arg: CursorPropertiesChangeAfterEvent) => void; + /** + * @remarks + * This function can't be called in read-only mode. + * + */ + unsubscribe(callback: (arg: CursorPropertiesChangeAfterEvent) => void): void; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export class CustomWidget extends Widget { + private constructor(); + readonly location: minecraftserver.Vector3; + readonly rotation: minecraftserver.Vector2; + readonly showTextOnlyWhenSelected: boolean; + getText(): string; + /** + * @remarks + * This function can't be called in read-only mode. + * + */ + moveBy(delta: minecraftserver.Vector3): void; + /** + * @remarks + * This function can't be called in read-only mode. + * + */ + setText(text: string): void; +} + +export class CustomWidgetMoveEventData { + private constructor(); + readonly group: WidgetGroup; + readonly location?: minecraftserver.Vector3; + readonly rotation?: minecraftserver.Vector2; + readonly widget: CustomWidget; +} + +export class ExportManager { + private constructor(); + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + beginExportProject(options: ProjectExportOptions): Promise; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + canExportProject(): boolean; +} + +/** + * Editor Extensions are the basis for all player specific, + * editor specific functionality within the game. Almost all + * editor functionality is exported and available within the + * context of an {@link ExtensionContext} + * When the script manager initializes during level loading, + * the scripts are loaded from the behavior packs and executed. + * As part of the global execution context, the scripts are + * free to register any number of extensions. + * An Editor Extension is defined a name, an activation + * function and a shutdown function. + * + * It is not recommended to directly use this function as the + * contract is not guaranteed to be stable, instead prefer + * {@link registerEditorExtension} as it provides additional + * functionality and a stable contract. + */ +export class Extension { + private constructor(); + /** + * @remarks + * Default identifier for tool rail grouping. All modal tools + * created from the extension will use this. + * + */ + readonly defaultToolGroupId: string; + /** + * @remarks + * Description specified during registration for the extension. + * + */ + readonly description: string; + /** + * @remarks + * Name of the extension. + * + */ + readonly name: string; + /** + * @remarks + * Notes specified during registration for the extension. + * + */ + readonly notes: string; +} + +/** + * The extension context is a native (C++) object created for + * each registered Editor Extension, when a player connection + * is established with the server. + * A registered extension activation or deactivation closure is + * accompanied by an [ExtensionContext] object, which provides + * a player specific, editor extension specific context. + * The Extension Context is the main interface to all the bound + * Editor Services. + * As more player services are added to the editor, they will + * be exposed through this object + */ +export class ExtensionContext { + private constructor(); + /** + * @remarks + * Contains a set of events that are applicable to the editor + * player. Event callbacks are called in a deferred manner. + * Event callbacks are executed in read-write mode. + * + */ + readonly afterEvents: ExtensionContextAfterEvents; + readonly blockPalette: BlockPaletteManager; + readonly brushShapeManager: BrushShapeManager; + /** + * @remarks + * This is used to access the players Clipboard Manager and the + * main interface through which the player can create, modify + * and apply clipboard items + * + */ + readonly clipboardManager: ClipboardManager; + /** + * @remarks + * This is used to access the players 3D block cursor and it's + * properties + * + */ + readonly cursor: Cursor; + readonly exportManager: ExportManager; + /** + * @remarks + * Contains information about the registered extension + * instance. + * + */ + readonly extensionInfo: Extension; + /** + * @remarks + * The current player which is the subject of the extension + * invocation + * + */ + readonly player: minecraftserver.Player; + readonly playtest: PlaytestManager; + /** + * @remarks + * The instance of the players Selection Manager and the main + * interface through which the player can create/modify + * selections + * + */ + readonly selectionManager: SelectionManager; + /** + * @remarks + * The instance of the players Settings Manager and the + * contract through which the settings for the player can be + * modified. + * + */ + readonly settings: SettingsManager; + /** + * @remarks + * The instance of the players Transaction Manager and the main + * interface through which the creator can create transaction + * records, and undo/redo previous transactions + * + */ + readonly transactionManager: TransactionManager; + readonly widgetManager: WidgetManager; +} + +/** + * Contains a set of events that are available across the scope + * of the ExtensionContext. + */ +export class ExtensionContextAfterEvents { + private constructor(); + readonly cursorPropertyChange: CursorPropertyChangeAfterEventSignal; + /** + * @remarks + * This event triggers when the editor mode changes for the + * player. + * + */ + readonly modeChange: ModeChangeAfterEventSignal; + readonly primarySelectionChange: PrimarySelectionChangeAfterEventSignal; +} + +/** + * Settings category that manages {@link + * GraphicsSettingsProperty} configurations. + */ +export class GraphicsSettings { + private constructor(); + /** + * @remarks + * Retrieves a graphics settings property value. + * + * @param property + * Property identifier. + * @returns + * Returns the property value if it is found. If the property + * is not available, it returns undefined. + */ + get(property: T): GraphicsSettingsPropertyTypeMap[T] | undefined; + /** + * @remarks + * Retrieves all graphics settings properties and their values. + * + * @returns + * Returns a property value map for all available properties. + */ + getAll(): GraphicsSettingsPropertyTypeMap; + /** + * @remarks + * Modifies a graphics settings property value. + * + * @param property + * Property identifier. + * @param value + * New property value. + * @throws This function can throw errors. + */ + set(property: T, value: GraphicsSettingsPropertyTypeMap[T]): void; + /** + * @remarks + * Modify multiple graphics settings properties. + * + * @param properties + * Property map to set available property values. If the + * property is not defined in the map, it will not be modified. + * @throws This function can throw errors. + */ + setAll(properties: GraphicsSettingsPropertyTypeMap): void; +} + +export class IBlockPaletteItem { + private constructor(); + getBlock(): minecraftserver.BlockType | undefined; + getDisplayName(): string; + getType(): BlockPaletteItemType; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + * + * {@link Error} + */ + setBlock(block: minecraftserver.BlockPermutation | minecraftserver.BlockType | string): void; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export class LineWidget extends Widget { + private constructor(); +} + +/** + * The logger class is a utility class which allows editor + * extensions to communicate with the player from the server to + * the client log window. + * The logger class presents 4 different output channels which + * can be used to send information to the client/player, + * depending on the context of the information. + */ +export class Logger { + private constructor(); + /** + * @remarks + * A `debug` output channel generally used during the + * development process of editor extensions. This channel + * defaults to `hidden` in the log window (unless explicitly + * enabled). + * Once your editor extension development process is complete, + * and you're ready to ship/share your extension - we generally + * recommend that you remove any references to this log channel + * to avoid a noisy experience for other users + * + * This function can't be called in read-only mode. + * + * @param message + * The message string to send to the log window + * @throws This function can throw errors. + */ + debug(message: string, properties?: LogProperties): void; + /** + * @remarks + * The error channel is generally used when the editor + * extension experiences an error (either a program error in + * executing logic unexpectedly, or an error in the input or + * output to/from a player). Use this channel sparingly - it's + * meant to communicate important problems to the player + * + * This function can't be called in read-only mode. + * + * @param message + * The message string to send to the log window + * @throws This function can throw errors. + */ + error(message: string, properties?: LogProperties): void; + /** + * @remarks + * The info channel is intended to communicate general, + * non-fatal or non-erroneous information to the player that + * can generally be safely ignored if they choose to do so. + * + * This function can't be called in read-only mode. + * + * @param message + * The message string to send to the log window + * @throws This function can throw errors. + */ + info(message: string, properties?: LogProperties): void; + /** + * @remarks + * The warning channel is intended to inform the user of + * "potential" issues (missing inputs, values out of range, + * things that cannot be found) but are not fatal and execution + * can still be completed. + * + * This function can't be called in read-only mode. + * + * @param message + * The message string to send to the log window + * @throws This function can throw errors. + */ + warning(message: string, properties?: LogProperties): void; +} + +/** + * The MinecraftEditor class is a namespace container for + * Editor functionality which does not have any player context. + */ +export class MinecraftEditor { + private constructor(); + /** + * @remarks + * A global instance of the log output class object. This is + * not contextualized to any particular player, and any + * messages sent to this instance will be broadcast to all + * connected editor client sessions + * + * @throws This property can throw when used. + */ + readonly log: Logger; + /** + * @remarks + * Allows querying and modifying some properties of the + * simulation. + * + */ + readonly simulation: SimulationState; +} + +/** + * Contains information related to changes in player editor + * mode. + */ +export class ModeChangeAfterEvent { + private constructor(); + /** + * @remarks + * The editor mode that the player is changed to. + * + */ + readonly mode: EditorMode; +} + +/** + * Manages callbacks that are connected to when a player editor + * mode changes. + */ +export class ModeChangeAfterEventSignal { + private constructor(); + /** + * @remarks + * Subscribes the specified callback to an editor mode change + * after event. + * + * This function can't be called in read-only mode. + * + */ + subscribe(callback: (arg: ModeChangeAfterEvent) => void): (arg: ModeChangeAfterEvent) => void; + /** + * @remarks + * Removes the specified callback from an editor mode change + * after event. + * + * This function can't be called in read-only mode. + * + */ + unsubscribe(callback: (arg: ModeChangeAfterEvent) => void): void; +} + +export class PlaytestManager { + private constructor(); + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + beginPlaytest(options: PlaytestGameOptions): Promise; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + getPlaytestSessionAvailability(): PlaytestSessionResult; +} + +export class PrimarySelectionChangeAfterEventSignal { + private constructor(); + /** + * @remarks + * This function can't be called in read-only mode. + * + */ + subscribe(callback: (arg: SelectionEventAfterEvent) => void): (arg: SelectionEventAfterEvent) => void; + /** + * @remarks + * This function can't be called in read-only mode. + * + */ + unsubscribe(callback: (arg: SelectionEventAfterEvent) => void): void; +} + +export class PrimarySelectionChangedEvent { + private constructor(); + readonly volume?: minecraftserver.CompoundBlockVolume; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export class ProbabilityBlockPaletteItem extends IBlockPaletteItem { + constructor(displayName?: string); + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + * + * {@link Error} + */ + addBlock(block: minecraftserver.BlockPermutation | minecraftserver.BlockType | string, weight: number): void; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + * + * {@link minecraftcommon.ArgumentOutOfBoundsError} + * + * {@link Error} + */ + removeBlockAt(index: number): void; +} + +/** + * The Selection represents a volume in space, which may + * potentially be made up of one or more block locations. + * These block locations do not need to be contiguous, and a + * Selection represent an irregular shape. + * It's important to note that a Selection is only a + * representation of the volume shape space - and does NOT + * represent the actual contents of the space. + */ +export class Selection { + private constructor(); + /** + * @remarks + * Returns a boolean representing whether or not there are any + * volumes pushed to the selection stack + * + * @throws This property can throw when used. + */ + readonly isEmpty: boolean; + /** + * @remarks + * Set whether or not the selection volume is visible to the + * client user. + * NOTE: Use this option carefully - Selection volumes are + * generally server-only, but marking a volume as visible + * causes the volume (and all volume operations) to be + * synchronized with the client game which can potentially + * generate excessive network traffic. + * + * + * This property can't be edited in read-only mode. + * + */ + visible: boolean; + /** + * @remarks + * Clear the contents of the Selection + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + clear(): void; + /** + * @remarks + * Fetch a block iterator which can be used to step across the + * Selection shape. Each call to the iterator will return the + * next block location within the Selection bounds which is + * actually selected. + * Block iteration is not guaranteed to be contiguous - it is + * possible to create irregular selection shapes by adding + * volumes to a selection which may or may not be contiguous or + * adjacent to other volumes within the selection. + * The Block iterator will return only selected volume + * locations + * + * This function can't be called in read-only mode. + * + */ + getBlockLocationIterator(): minecraftserver.BlockLocationIterator; + /** + * @remarks + * Return a bounding rectangle that contains all of the volumes + * within the selection (the bounding rectangle does NOT + * represent the shape of the selection, only the largest + * rectangle that will fit all of the volumes) + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + getBoundingBox(): minecraftserver.BoundingBox; + /** + * @remarks + * Return the color of the on-screen selection container hull + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + getFillColor(): minecraftserver.RGBA; + /** + * @remarks + * Return the color of the on-screen selection container + * outline + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + getOutlineColor(): minecraftserver.RGBA; + /** + * @remarks + * Get the origin of the CompoundBlockVolume that makes up the + * block component part of selection + * + * This function can't be called in read-only mode. + * + */ + getVolumeOrigin(): minecraftserver.Vector3; + /** + * @remarks + * Translate a selection by a given amount (this causes all of + * the volumes within the selection to be moved by the + * specified offset) + * + * This function can't be called in read-only mode. + * + * @param delta + * The amount by which to move + * @returns + * Return the newly moved position + * @throws This function can throw errors. + */ + moveBy(delta: minecraftserver.Vector3): minecraftserver.Vector3; + /** + * @remarks + * Move the selection to an absolute world location (causing + * all of the volumes within the selection to be moved to a + * location relative to the world location) + * + * This function can't be called in read-only mode. + * + * @param location + * The world location to which to relocate the selection + * @returns + * Return the newly moved position + * @throws This function can throw errors. + */ + moveTo(location: minecraftserver.Vector3): minecraftserver.Vector3; + /** + * @remarks + * Fetch the volume information of the last compound volume + * that was pushed to the volume stack without affecting the + * stack itself + * + * This function can't be called in read-only mode. + * + * @param forceRelativity + * See the description for {@link + * @minecraft-server/CompoundBlockVolume.peekLastVolume} + * @returns + * Returns undefined if the stack is empty + */ + peekLastVolume( + forceRelativity?: minecraftserver.CompoundBlockVolumePositionRelativity, + ): minecraftserver.CompoundBlockVolumeItem | undefined; + /** + * @remarks + * Remove the volume information that was last pushed to the + * volume stack. This will reduce the stack item length by 1 + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + popVolume(): void; + /** + * @remarks + * Push a compound volume item (a volume and action pair) to + * the volume stack. + * + * This function can't be called in read-only mode. + * + * @param item + * Item to push to the stack + * @throws This function can throw errors. + */ + pushVolume(item: minecraftserver.CompoundBlockVolumeItem): void; + /** + * @remarks + * Replace the contents of the current selection with a new + * specified selection. This operation will delete the current + * contents and copy the contents of the new selection to the + * target selection - it does this by content, not by + * reference. + * + * This function can't be called in read-only mode. + * + * @param other + * {@link @minecraft-server/CompoundBlockVolume} - set the + * block component part of this selection to the specified + * compound block volume. This will completely replace all + * block volume definitions in the selection. + * {@link @Selection} - replace the selection with the + * specified selection + * @throws This function can throw errors. + */ + set(other: minecraftserver.CompoundBlockVolume | Selection): void; + /** + * @remarks + * Set the color of the hull of the selection object if it is + * visible. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + setFillColor(color: minecraftserver.RGBA): void; + /** + * @remarks + * Set the color of the outline around the selection object if + * it is visible + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + setOutlineColor(color: minecraftserver.RGBA): void; +} + +export class SelectionEventAfterEvent { + private constructor(); + readonly selectionEvent: PrimarySelectionChangedEvent; +} + +/** + * The SelectionManager (accessible from the {@link + * ExtensionContext}) is responsible for the management of all + * {@link Selection} objects, and provides the user the ability + * to create new {@link Selection} objects for use within an + * extension. + */ +export class SelectionManager { + private constructor(); + /** + * @remarks + * The primary {@link Selection} object is always present (even + * if it's empty) and cannot be deleted. This object + * represents the main selection object which is always + * accessible through the UI, and by default is synchronized + * between the client and server. + * + * @throws This property can throw when used. + */ + readonly selection: Selection; + /** + * @remarks + * Create a new, empty {@link Selection} object + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + create(): Selection; +} + +/** + * The SettingsManager (accessible from the {@link + * ExtensionContext}) is responsible for the management all + * player settings. + */ +export class SettingsManager { + private constructor(); + /** + * @remarks + * Manages graphics settings properties. + * + */ + readonly graphics: GraphicsSettings; +} + +export class SettingsUIElement { + readonly initialValue: boolean | number | string | minecraftserver.Vector3; + readonly max?: number; + readonly min?: number; + readonly name: string; + readonly onChange: (arg: boolean | number | string | minecraftserver.Vector3) => boolean; + readonly options?: string[]; + constructor( + name: string, + initialValue: boolean | number | string | minecraftserver.Vector3, + onChange: (arg: boolean | number | string | minecraftserver.Vector3) => boolean, + min?: number, + max?: number, + options?: string[], + ); +} + +// @ts-ignore Class inheritance allowed for native defined classes +export class SimpleBlockPaletteItem extends IBlockPaletteItem { + constructor(displayName?: string); +} + +/** + * A simple class wrapper to inherit in your tool which + * contains the initialization and storage of the simple tool + * component utility. See one of the `Simple` samples to see + * how to use this class and the wrapper framework + */ +export declare class SimpleToolWrapper implements IDisposable { + get session(): IPlayerUISession; + get simpleTool(): ISimpleTool; + setupSimpleTool(session: IPlayerUISession, options: ISimpleToolOptions): void; + teardown(): void; +} + +/** + * Responsible for querying and modifying various properties of + * the simulation. + */ +export class SimulationState { + private constructor(); + /** + * @remarks + * Returns `true` if mob simulation is paused. + * + */ + isPaused(): boolean; + /** + * @remarks + * Sets the state of mob simulation. If set to `true`, mobs + * are paused. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + setPaused(isPaused: boolean): void; +} + +/** + * The Transaction Manager is responsible for tracking and + * managing all of the registered transaction operations which + * represent creator changes in the world. + * Transaction Manager is the basis of the UNDO and REDO + * operations, and allows a creator to store the changes made + * to the world and the state of the world BEFORE those changes + * were applied, making it possible to UNDO those changes and + * restore the world state. + * The transactions are stored as a stack, and can be undone in + * stack order to restore the world to it's original state + */ +export class TransactionManager { + private constructor(); + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + addUserDefinedOperation( + transactionHandlerId: UserDefinedTransactionHandlerId, + operationData: string, + operationName?: string, + ): void; + /** + * @remarks + * Commit all of the transaction operations currently attached + * to the open transaction record to the manager. These will + * be added as a single transaction manager entry. + * The open record will be closed and all tracking operations + * will cease. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + commitOpenTransaction(): boolean; + /** + * @remarks + * This function will commit the pending changes caused by any + * of the track changes variants. The changes will be + * committed to the currently open transaction, but the + * transaction will remain open for further records. + * Pending block changes from tracking operations will be added + * to the transaction record before submission to the + * transaction manager + * + * This function can't be called in read-only mode. + * + * @returns + * Returns the number of change requests that were being + * tracked + * @throws This function can throw errors. + */ + commitTrackedChanges(): number; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + createUserDefinedTransactionHandler( + undoClosure: (arg: string) => void, + redoClosure: (arg: string) => void, + ): UserDefinedTransactionHandlerId; + /** + * @remarks + * Discard the currently open transaction without committing it + * to the transaction manager stack. + * All records within the transaction will be discarded, and + * any tracking requests currently active will be stopped + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + discardOpenTransaction(): boolean; + /** + * @remarks + * Discard any pending tracked changes. This does not affect + * the current open transaction contents, only the pending + * tracked block operations + * + * This function can't be called in read-only mode. + * + * @returns + * Returns the number of change requests that were discarded + * @throws This function can throw errors. + */ + discardTrackedChanges(): number; + /** + * @remarks + * Open a transaction record which will be a container for any + * number of transaction operations. + * All transaction operations within a record are grouped and + * treated as a single atomic unit + * + * This function can't be called in read-only mode. + * + * @param name + * Give the transaction record a name + * @throws This function can throw errors. + */ + openTransaction(name: string): boolean; + /** + * @remarks + * Perform an redo operation. This will take the last + * transaction record on the redo stack and store the current + * world state and then apply the changes in the record. This + * will reduce the redo record stack by one. + * + * The transaction record affected by this operation will be + * transferred to the undo stack in case the creator decides to + * undo it + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + redo(): void; + /** + * @remarks + * Return the number of transaction records on the redo stack. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + redoSize(): number; + /** + * @remarks + * Begin tracking block changes in a specified area. These + * will be added to a pending changes list. + * The pending list will be added to the open transaction + * record when a commit has been issued. + * + * This function can't be called in read-only mode. + * + * @param from + * Min block location of a bounding area + * @param to + * Max block location of a bounding area + * @throws This function can throw errors. + */ + trackBlockChangeArea(from: minecraftserver.Vector3, to: minecraftserver.Vector3): boolean; + /** + * @remarks + * Begin tracking block changes in an area defined by a {@link + * @minecraft-server/CompoundBlockVolume}. These will be added + * to a pending changes list. + * The pending list will be added to the open transaction + * record when a commit has been issued. + * + * This function can't be called in read-only mode. + * + * @param compoundBlockVolume + * {@link @minecraft-server/CompoundBlockVolume} to track. + * Only non-void block locations will be tracked -- any changes + * falling into a void/negative space will not be tracked + * @throws This function can throw errors. + */ + trackBlockChangeCompoundBlockVolume(compoundBlockVolume: minecraftserver.CompoundBlockVolume): boolean; + /** + * @remarks + * Begin tracking block changes in a list of specified block + * locations. + * + * This function can't be called in read-only mode. + * + * @param locations + * An array of block locations to monitor for changes + * @throws This function can throw errors. + */ + trackBlockChangeList(locations: minecraftserver.Vector3[]): boolean; + /** + * @remarks + * Begin tracking block changes that may happen in a selection + * volume. + * The volume is copied, so tracking will not move if the + * selection volume is translated after this instruction is + * issued. + * Selection Volumes can also represent irregular shapes with + * non-contiguous blocks and this tracking call will honor the + * actual selected areas in the volume (and not the negative + * space) (see {@link @minecraft-server/CompoundBlockVolume} + * for more details + * + * This function can't be called in read-only mode. + * + * @param selection + * A collection of block location volumes represented by a + * Selection volume to monitor for changes. + * The Selection Volume is copied, so further changes to the + * volume after this call will not be reflected in the tracking + * list. + * @throws This function can throw errors. + */ + trackBlockChangeSelection(selection: Selection): boolean; + /** + * @remarks + * Perform an undo operation. This will take the last + * transaction record on the stack and apply the stored world + * state from before the changes were made. This will reduce + * the record stack by one. + * + * The transaction record affected by this operation will be + * transferred to the redo stack in case the creator decides to + * reapply it + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + undo(): void; + /** + * @remarks + * Return how many transactions records currently exist on the + * stack + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + undoSize(): number; +} + +/** + * A strongly typed transaction handle to enforce type safety + * when adding user defined transactions.
This transaction + * handle becomes the context for adding the transaction to the + * transaction manager.
You can obtain one of these handles + * by calling {@link registerUserDefinedTransactionHandler} + */ +export declare class UserDefinedTransactionHandle { + /** + * @remarks + * Constructs a new instance of the + * `UserDefinedTransactionHandle` class + * + */ + constructor(nativeHandle: UserDefinedTransactionHandlerId, transactionManager: TransactionManager); + /** + * @remarks + * Add a user defined transaction operation to the transaction + * manager with a payload of the specified type. This allows + * the extension to open a transaction, and insert custom data + * objects into the transaction log which are stored until an + * undo or redo event occurs. The payload data added here is + * stored and then passed to the undo/redo handlers (registered + * with {@link registerUserDefinedTransactionHandler}) when an + * undo/redo event is requested. NOTE:
Transactions can + * contain multiple operations - you can open a transaction and + * add any (reasonable) number of operations to it (of the same + * or differing types) before committing to the transaction + * log. NOTE/WARNING:
The payload data is serialized to + * JSON before being inserted into the transaction log and the + * underlying implementation uses the JSON.stringify() function + * to serialize the data. Any non-primitive data, such as + * classes or minecraft native objects will not serialize to + * JSON properly, so you should avoid using them as payload + * data. + * + * @param payload + * The data object to be inserted into the transaction log. + * @param transactionName + * A string name that will be associated with this operation + */ + addUserDefinedOperation(payload: T, transactionName: string): void; +} + +export class UserDefinedTransactionHandlerId { + private constructor(); +} + +export class Widget { + private constructor(); + readonly valid: boolean; + /** + * @remarks + * This function can't be called in read-only mode. + * + */ + deleteWidget(): void; + getIsSelected(): boolean; + getIsVisible(): boolean; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + setIsSelected(isSelected: boolean): void; + /** + * @remarks + * This function can't be called in read-only mode. + * + */ + setIsVisible(isVisible: boolean): void; +} + +export class WidgetGroup { + private constructor(); + readonly valid: boolean; + /** + * @remarks + * This function can't be called in read-only mode. + * + */ + areAnySelected(): boolean; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + createCustomWidget( + customEntityName: string, + location: minecraftserver.Vector3, + rotation?: minecraftserver.Vector2, + options?: CustomWidgetCreateOptions, + ): CustomWidget; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + deleteWidget(widgetToDelete: Widget): void; + /** + * @remarks + * This function can't be called in read-only mode. + * + */ + deselectAllWidgets(): void; + /** + * @remarks + * This function can't be called in read-only mode. + * + */ + getIsVisible(): boolean; + /** + * @remarks + * This function can't be called in read-only mode. + * + */ + moveSelectedWidgets(delta: minecraftserver.Vector3): void; + /** + * @remarks + * This function can't be called in read-only mode. + * + */ + selectAllWidgets(): void; + /** + * @remarks + * This function can't be called in read-only mode. + * + */ + setIsVisible(isVisible: boolean): void; +} + +export class WidgetManager { + private constructor(); + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + createGroup(options?: WidgetGroupCreateOptions): WidgetGroup; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + deleteGroup(groupToDelete: WidgetGroup): void; +} + +export class WidgetStateChangeEventData { + private constructor(); + readonly group: WidgetGroup; + readonly isSelected?: boolean; + readonly isVisible?: boolean; + readonly widget: Widget; +} + +export interface BrushShape { + icon: string; + name: string; +} + +/** + * Interface used to specify the options when a clipboard item + * is being written to the world + */ +export interface ClipboardWriteOptions { + /** + * @remarks + * The anchor is a unit vector representation of the side or + * corner of the Clipboard Item to be written to the world. + * `{0, 0, 0}` represents the center of the Clipboard item, + * `{0, 1, 0}` represents the top, `{-1, -1, -1}` represents + * the bottom/back/left corner, etc + * The anchor is used in conjunction with the item size to + * determine the object relative anchor point where the object + * will be applied in the world. + * Values for the X/Y/Z components should be within the range + * `(-1 <= X/Y/Z <=1)` + * + */ + anchor?: minecraftserver.Vector3; + /** + * @remarks + * An enum which represents the axis (or combination of axis') + * along which the item should be mirrored + * - X + * - Z + * - XZ + * + */ + mirror?: minecraftserver.StructureMirrorAxis; + /** + * @remarks + * A position offset which should be applied to the paste + * location while the clipboard item is being written + * + */ + offset?: minecraftserver.Vector3; + /** + * @remarks + * An enum representing the rotation around the Y-Axis which + * should be applied while the clipboard item is being written + * + */ + rotation?: minecraftserver.StructureRotation; +} + +/** + * The CursorProperties interface is used to describe the + * properties of the Editor 3D block cursor construct. + * The 3D block cursor can be queried to retrieve the current + * properties, and the same property class can be used to set + * the current properties of the cursor. + * This interface is generally used at the activation stage of + * the active tool to set up the color, visibility and input + * properties of the 3D block cursor + */ +export interface CursorProperties { + /** + * @remarks + * Enum representing the cursor control mode + * - Fixed Mode locks the cursor to a position which is \ + * blocks offset from the current player position. The cursor + * is camera relative, so it will always appear \ blocks + * ahead of the players feet + * - Keyboard Mode puts the cursor under direct control of the + * API, and ignores any mouse input. The cursor can only be + * moved around using the moveBy method + * - KeyboardAndMouse mode puts the cursor under a shared + * control of onMouseMove and keyboard input. Any mouse + * movement events will set the cursor to the position of the + * mouse/world raycast. This can be modified using the moveBy + * method, but any subsequent mouse events will reset the + * position back to where the raycast intersection occurs + * - Mouse mode puts the cursor under control of mouse move + * events, and moveBy method will be ignored + * + * + */ + controlMode?: CursorControlMode; + /** + * @remarks + * The fixed distance from the players feet at which the cursor + * is attached, relative to camera direction. + * This is only used when [controlMode] is set to `Fixed` + * + */ + fixedModeDistance?: number; + /** + * @remarks + * A [Color] Property representing the color of the block + * cursor object outline + * + */ + outlineColor?: minecraftserver.RGBA; + projectThroughLiquid?: boolean; + /** + * @remarks + * An enum representing the cursor target mode + * - Block Mode records the block position of the mouse/world + * raycast intersection + * - Face Mode records the block position of the block adjacent + * to the mouse/world raycast intersection, according to the + * face of the collision point of the selected block + * + */ + targetMode?: CursorTargetMode; + /** + * @remarks + * Boolean flag controlling the visibility of the 3D block + * cursor + * + */ + visible?: boolean; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export interface CustomWidgetCreateOptions extends WidgetCreateOptions { + moveEvent?: (arg: CustomWidgetMoveEventData) => void; + showTextOnlyWhenSelected?: boolean; + text?: string; + visualOffset?: minecraftserver.Vector3; +} + +/** + * An interface which defines the set of optional parameters + * which can be used when calling the `registerEditorExtension` + * function + */ +export interface ExtensionOptionalParameters { + /** + * @remarks + * An optional text description of the extension being + * registered. + * This can be a straight textual description or a string + * identifier key for a localized string in the extension's + * resource pack text files. + * The description is meant to be a very short snappy one-liner + * which quickly and uniquely identifies the extension + * The length of the string is capped to 256 characters + * + */ + description?: string; + /** + * @remarks + * Optional notes for the extension being registered. + * This can be a straight textual description or a string + * identifier key for a localized string in the extension's + * resource pack text files. + * The notes section is meant to convey more detailed + * information and notes (e.g. a link to the author's website) + * The length of this string is capped to 1024 characters + * + */ + notes?: string; + /** + * @remarks + * An optional custom identifier that will be used for all + * Modal Tools created from the registered extension. + * The length of the string is capped to 256 characters + * + */ + toolGroupId?: string; +} + +/** + * A properties class for the global instance of the logger + * object. + * While the logger object is available through the {@link + * ExtensionContext} - using the global instance allows the + * creator to use this properties class to perform direct + * server->client messaging and broadcasts. + */ +export interface LogProperties { + /** + * @remarks + * Direct a log message to a specific player. If no player is + * specified, then all players will receive the message + * + */ + player?: minecraftserver.Player; + /** + * @remarks + * Add additional tags to the log message which can be used by + * the client session to filter/search in the log window + * + */ + tags?: string[]; +} + +export interface PlaytestGameOptions { + alwaysDay?: boolean; + difficulty?: minecraftserver.Difficulty; + dimensionId?: string; + disableWeather?: boolean; + gameMode?: minecraftserver.GameMode; + showCoordinates?: boolean; + spawnPosition?: minecraftserver.Vector3; + timeOfDay?: number; + weather?: number; +} + +export interface ProjectExportOptions { + alwaysDay?: boolean; + difficulty?: minecraftserver.Difficulty; + disableWeather?: boolean; + exportName?: string; + exportType: ProjectExportType; + gameMode?: minecraftserver.GameMode; + initialTimOfDay?: number; +} + +export interface WidgetCreateOptions { + initialVisibility?: boolean; + isSelectable?: boolean; + stateChangeEvent?: (arg: WidgetStateChangeEventData) => void; +} + +export interface WidgetGroupCreateOptions { + groupSelectionMode?: WidgetGroupSelectionMode; +} + +/** + * Binds actions to the client and manages their lifetime. + * Action managers are managed on a per player basis since + * client side UI is per player. + */ +export interface ActionManager { + /** + * @remarks + * The active tool ID + * + */ + activeToolId: string | undefined; + /** + * @remarks + * Creates an action and registers it on the client + * + * @param rawAction + * The raw action to create. See ActionTypes for supported + * parameters + */ + createAction(rawAction: T): RegisteredAction; +} + +/** + * Represents a UI session for a given player + */ +export interface BuiltInUIManager { + /** + * @remarks + * Navigates to the documentation site. + * + */ + navigateToDocumentation(): void; + /** + * @remarks + * Navigates to the feedback site + * + */ + navigateToFeedback(): void; + /** + * @remarks + * Navigates to the pause screen + * + */ + navigateToPauseScreen(): void; + /** + * @remarks + * Updates the visibility of the log panel + * + */ + updateLogPanelVisibility(visibility: boolean): void; + /** + * @remarks + * Updates the visibility of the control demo + * + */ + updateUISettingsPanelVisibility(visibility: boolean): void; + /** + * @remarks + * Updates the visibility of the welcome panel + * + */ + updateWelcomePanelVisibility(visibility: boolean): void; +} + +/** + * An event that can be subscribed to. You can use the token, + * returned from the subscribe method, to clean up handlers. + */ +export declare interface EventSink { + /** + * @remarks + * Subscribes an event handler to a particular subscription. + * + * @param handler + * Handler function to subscribe with. + * @returns + * An event handler subscription token that can be used to + * unsubscribe and clean-up handlers. + */ + subscribe(handler: EventHandler): IEventToken; +} + +/** + * Simple abstraction for disposable objects. + */ +export interface IDisposable { + /** + * @remarks + * Initiates the teardown and cleanup of this disposable item. + * + */ + teardown(): void; +} + +export interface IDropdownItem { + /** + * @remarks + * Fallback display text if no loc ID + * + */ + readonly displayAltText: string; + /** + * @remarks + * Loc ID (resolved on client) + * + */ + readonly displayStringId: string; + /** + * @remarks + * The selectable value of the DropDown item. + * + */ + readonly value: number; +} + +/** + * Dropdown property item specific functionality + */ +export interface IDropdownPropertyItemMixIn { + /** + * @remarks + * Used to update the Dropdown options in the control. Will + * trigger onChange with -1 as the old value due to the list + * changing entries. + * + */ + updateDropdownItems(dropdownItems: IDropdownItem[], newValue: number): void; +} + +/** + * Returned from an event subscription. Provides functionality + * for cleaning up listeners + */ +export declare interface IEventToken { + /** + * @remarks + * Removes registered listener from an event + * + */ + unsubscribe(): void; +} + +export interface IGlobalInputManager { + registerKeyBinding( + inputContextId: EditorInputContext, + action: SupportedKeyboardActionTypes, + button: KeyboardKey, + modifier?: InputModifier, + ): void; +} + +export interface IMenu { + /** + * @remarks + * If defined, the menu will show a checked or unchecked + * checkbox. + * + */ + checked?: boolean; + /** + * @remarks + * Unique ID for the menu + * + */ + readonly id: string; + /** + * @remarks + * Sub menus of this menu + * + */ + readonly submenu: IMenu[]; + addItem(params: IMenuCreationParams, action?: RegisteredAction): IMenu; + dispose(): void; + hide(): void; + replaceAction(action: RegisteredAction): void; + show(): void; +} + +/** + * Manager and container for IMenu objects + */ +export interface IMenuContainer { + /** + * @remarks + * Create a top level item in the container. + * + * @param props + * Configuration for the menu to create + */ + createMenu(props: IMenuCreationParams): IMenu; + /** + * @remarks + * Search for a menu item, if it's not found defer it to next + * tick. + * + * @param id + * Menu identifier + */ + getMenu(id: string): Promise; +} + +/** + * Properties required to create a Menu + */ +export interface IMenuCreationParams { + /** + * @remarks + * Whether the menu should show a checkmark + * + */ + checked?: boolean; + /** + * @remarks + * Loc ID (resolved on client) + * + */ + displayStringId?: string; + /** + * @remarks + * The name of the menu + * + */ + name: string; + /** + * @remarks + * Custom unique identifier that will replace random id + * + */ + uniqueId?: string; +} + +export interface IModalTool { + /** + * @remarks + * Unique ID for the tool + * + */ + readonly id: string; + /** + * @remarks + * Provides lifecycle activation events for a modal tool + * + */ + onModalToolActivation: EventSink; + bindPropertyPane(pane: IPropertyPane): void; + dispose(): void; + hide(): void; + registerKeyBinding(action: SupportedKeyboardActionTypes, button: KeyboardKey, modifier?: InputModifier): void; + registerMouseButtonBinding(action: SupportedMouseActionTypes): void; + registerMouseDragBinding(action: SupportedMouseActionTypes): void; + registerMouseWheelBinding(action: SupportedMouseActionTypes): void; + show(): void; + unregisterInputBindings(): void; +} + +export interface IModalToolContainer { + /** + * @remarks + * Tools within this container. + * + */ + readonly currentTools: IModalTool[]; + /** + * @remarks + * The id of the selected tool in container. + * + */ + readonly selectedOptionId?: string; + addTool(params: ModalToolCreationParameters, action?: RegisteredAction): IModalTool; + dispose(): void; + hide(): void; + removeTool(id: string): void; + setSelectedOptionId(value: string | undefined, update?: boolean): void; + show(): void; +} + +/** + * Log helper interface for Player. + */ +export interface IPlayerLogger { + /** + * @remarks + * Dispatch a player log message with Debug log level + * + * @param message + * Message content + */ + debug(message: string): void; + /** + * @remarks + * Dispatch a player log message with Error log level + * + * @param message + * Message content + */ + error(message: string): void; + /** + * @remarks + * Dispatch a player log message with Info log level + * + * @param message + * Message content + */ + info(message: string): void; + /** + * @remarks + * Dispatch a player log message with Warning log level + * + * @param message + * Message content + */ + warning(message: string): void; +} + +export interface IPropertyItem { + /** + * @remarks + * If the item is enabled in the UI. + * + */ + enable: boolean; + /** + * @remarks + * Unique ID for the property item. + * + */ + readonly id: string; + /** + * @remarks + * The object associated. + * + */ + readonly obj: T; + /** + * @remarks + * The parent pane id. + * + */ + readonly paneId: string; + /** + * @remarks + * The target property of the object associated. + * + */ + readonly property: Prop; + /** + * @remarks + * The type name of the target property. + * + */ + readonly typeName: EDITOR_PANE_PROPERTY_ITEM_TYPE; + /** + * @remarks + * The value of the property. + * + */ + readonly value: T[Prop]; + /** + * @remarks + * If the item should be visible in the UI. + * + */ + visible: boolean; + dispose(): void; +} + +export interface IPropertyItemOptions { + /** + * @remarks + * If the item is enabled in the UI. + * + */ + enable?: boolean; + /** + * @remarks + * Callback to execute when the value is updated. + * + */ + onChange?: OnChangeCallback; + /** + * @remarks + * Fallback display text if no loc ID + * + */ + titleAltText?: string; + /** + * @remarks + * Loc ID (resolved on client) + * + */ + titleStringId?: string; + /** + * @remarks + * If the item should be visible in the UI. + * + */ + visible?: boolean; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export interface IPropertyItemOptionsBool extends IPropertyItemOptions { + /** + * @remarks + * controls appearance of the boolean. checkbox or toggleswitch + * + */ + displayAsToggleSwitch?: boolean; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export interface IPropertyItemOptionsButton extends IPropertyItemOptions { + icon?: string; + /** + * @remarks + * The variant for the button. By default it is "primary" + * + */ + variant?: ButtonVariant; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export interface IPropertyItemOptionsDataPicker extends IPropertyItemOptions { + /** + * @remarks + * Used to hold the entries allowed in the block/entity picker + * + */ + allowedEntries?: string[]; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export interface IPropertyItemOptionsDropdown extends IPropertyItemOptions { + /** + * @remarks + * The possible options for the drop down control. + * + */ + dropdownItems: IDropdownItem[]; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export interface IPropertyItemOptionsImage extends IPropertyItemOptions { + imageHeight: number; + imageWidth: number; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export interface IPropertyItemOptionsNumber extends IPropertyItemOptions { + /** + * @remarks + * The min possible value for the number. + * + */ + max?: number; + /** + * @remarks + * The max possible value for the number. + * + */ + min?: number; + /** + * @remarks + * If UI should show slider control. + * + */ + showSlider?: boolean; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export interface IPropertyItemOptionsSubPane extends IPropertyItemOptions { + /** + * @remarks + * The sub pane to render in UI. + * + */ + pane: IPropertyPane; +} + +/** + * Localization string id and border enable boolean for + * multiline text component. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export interface IPropertyItemOptionsText extends IPropertyItemOptions { + border: boolean; + valueStringId: string; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export interface IPropertyItemOptionsVector3 extends IPropertyItemOptions { + /** + * @remarks + * The max possible value for the X axis. By default + * Number.MAX_SAFE_INTEGER + * + */ + maxX?: number; + /** + * @remarks + * The max possible value for the Y axis. By default + * Number.MAX_SAFE_INTEGER + * + */ + maxY?: number; + /** + * @remarks + * The max possible value for the z axis. By default + * Number.MAX_SAFE_INTEGER + * + */ + maxZ?: number; + /** + * @remarks + * The min possible value for the X axis. By default + * Number.MIN_SAFE_INTEGER + * + */ + minX?: number; + /** + * @remarks + * The min possible value for the Y axis. By default + * Number.MIN_SAFE_INTEGER + * + */ + minY?: number; + /** + * @remarks + * The min possible value for the Z axis. By default + * Number.MIN_SAFE_INTEGER + * + */ + minZ?: number; +} + +/** + * Property pane present dynamic content. It can be associated + * with an object and presented with different kind of + * controls. + */ +export interface IPropertyPane { + /** + * @remarks + * Pane state for being expanded or collapsed. + * + */ + collapsed: boolean; + /** + * @remarks + * Unique ID for the property pane. + * + */ + readonly id: string; + /** + * @remarks + * Provides visibility change events + * + */ + onPropertyPaneVisibilityUpdated: EventSink; + /** + * @remarks + * In case of sub pane this is the id of the parent pane. + * + */ + readonly parentPaneId?: string; + /** + * @remarks + * Fallback display text if no loc ID + * + */ + titleAltText: string; + /** + * @remarks + * Loc ID (resolved on client) + * + */ + titleStringId: string; + /** + * @remarks + * Check visibility of the pane + * + */ + visible: boolean; + /** + * @remarks + * Width of the panel in rem. + * + */ + width?: number; + /** + * @remarks + * Adds a BlockPicker item to the pane. + * + */ + addBlockPicker( + obj: T, + property: Prop, + options?: IPropertyItemOptionsDataPicker, + ): IPropertyItem; + /** + * @remarks + * Adds a boolean item to the pane. + * + */ + addBool( + obj: T, + property: Prop, + options?: IPropertyItemOptionsBool, + ): IPropertyItem; + /** + * @remarks + * Adds a button to the pane and binds the specified action to + * the button activate. + * + */ + addButton( + action: RegisteredAction, + options?: IPropertyItemOptionsButton, + ): IActionPropertyItem< + { + EMPTY: undefined; + }, + 'EMPTY' + >; + /** + * @remarks + * Adds an divider item to the pane. + * + */ + addDivider(): IPropertyItem; + /** + * @remarks + * Adds an DropDown item to the pane. + * + */ + addDropdown< + T extends Omit & { + [key in Prop]: number; + }, + Prop extends keyof T & string, + >( + obj: T, + property: Prop, + options?: IPropertyItemOptionsDropdown, + ): IDropdownPropertyItem; + /** + * @remarks + * Adds an EntityPicker item to the pane. + * + */ + addEntityPicker( + obj: T, + property: Prop, + options?: IPropertyItemOptionsDataPicker, + ): IPropertyItem; + /** + * @remarks + */ + addImage( + obj: T, + property: Prop, + options?: IPropertyItemOptionsImage, + ): IPropertyItem; + /** + * @remarks + * Adds a number item to the pane. + * + */ + addNumber( + obj: T, + property: Prop, + options?: IPropertyItemOptionsNumber, + ): IPropertyItem; + /** + * @remarks + * Adds a string item to the pane + * + */ + addString( + obj: T, + property: Prop, + options?: IPropertyItemOptions, + ): IPropertyItem; + /** + * @remarks + * Adds a multiline Text item to the pane. + * + */ + addText( + obj: T, + property: Prop, + options?: IPropertyItemOptionsText, + ): IPropertyItem; + /** + * @remarks + * Adds a Vec3 item to the pane. + * + */ + addVector3( + obj: T, + property: Prop, + options?: IPropertyItemOptionsVector3, + ): IVector3PropertyItem; + /** + * @remarks + * Collapse the pane. + * + */ + collapse(): void; + /** + * @remarks + * Creates an internal sub panel that is presented inside a + * extender control. + * + */ + createPropertyPane(options: IPropertyPaneOptions): IPropertyPane; + /** + * @remarks + * Expand the pane. + * + */ + expand(): void; + /** + * @remarks + * Hide the pane. + * + */ + hide(): void; + /** + * @remarks + * Removes a child property pane from the parent pane. + * + */ + removePropertyPane(paneToRemove: IPropertyPane): boolean; + /** + * @remarks + * Show the pane and all of its property items. + * + */ + show(): void; +} + +/** + * The options to create a pane. + */ +export interface IPropertyPaneOptions { + /** + * @remarks + * Layout direction for sub panes + * + */ + direction?: LayoutDirection; + /** + * @remarks + * Fallback display text if no loc ID + * + */ + titleAltText: string; + /** + * @remarks + * Loc ID (resolved on client) + * + */ + titleStringId: string; + /** + * @remarks + * Width of the panel in rem. This property is ignored in case + * of sub panes + * + */ + width?: number; +} + +/** + * Optional parameter definition for RegisterEditorExtension + * function Allows the extension registrar to specify optional + * textual description and notes which would be visible through + * the extension manager + */ +export interface IRegisterExtensionOptionalParameters { + /** + * @remarks + * Description of the extension. + * + */ + description?: string; + /** + * @remarks + * Additional notes and description of the extension. + * + */ + notes?: string; + /** + * @remarks + * An optional custom group identifier that will be used for + * all Modal Tools created from the registered extension. + * + */ + toolGroupId?: string; +} + +/** + * The simple tool wrapper will create, bind and manage the + * lifecycle of all the desired components. The wrapper is + * designed to obfuscate and simplify the process of creating a + * simple editor tool so that a creator can get on with the job + * of just creating the tool functionality without getting + * mired in the irrelevant details of component lifecycle and + * visibility management. The wrapper will also attempt to + * codify particular implementation patterns and requirements + * that are common to all editor tools, and enforce them in a + * consistent way. It should also go some way to insulating the + * creator from underlying system and implementation changes as + * the editor evolves. + */ +export interface ISimpleTool { + get menu(): IMenu | undefined; + get name(): string; + get pane(): ISimpleToolPaneComponent; + get session(): IPlayerUISession; + get statusBar(): ISimpleToolStatusBarComponent; + get toolRail(): ISimpleToolRailComponent; + /** + * @remarks + */ + findPane(idString: string): ISimpleToolPaneComponent | undefined; + /** + * @remarks + */ + hidePane(idString?: string): void; + /** + * @remarks + */ + logDebug(message: string): void; + /** + * @remarks + */ + logError(message: string): void; + /** + * @remarks + */ + logInfo(message: string): void; + /** + * @remarks + */ + logWarn(message: string): void; + /** + * @remarks + */ + showPane(idString?: string): void; + /** + * @remarks + */ + showPaneExclusively(idString: string): void; + /** + * @remarks + */ + teardown(): void; +} + +/** + * Define a (key & modifier) pair for the simple tool + * activation key binding + */ +export interface ISimpleToolKeyPair { + button: KeyboardKey; + buttonModifier: InputModifier; +} + +/** + * A set of options which define the basic properties of a + * simple tool, and the optional components that are desired. + */ +export interface ISimpleToolOptions { + activationKeyBinding?: ISimpleToolKeyPair; + name: string; + onFinalize?: (tool: ISimpleTool) => void; + onTeardown?: (tool: ISimpleTool) => void; + propertyPaneOptions?: ISimpleToolPaneOptions; + statusBarOptions?: ISimpleToolStatusBarOptions; + toolRailOptions?: ISimpleToolRailOptions; +} + +/** + * The Simple Tool pane component represents the main window + * (or sub-window) for an editor tool. The pane components are + * stored as a hierarchy (see the `ISimpleToolPaneOptions` + * interface for more details) and are the main containers for + * all of the UI controls used by the editor tool. Panes are + * optional (a tool doesn't necessarily need to have a pane), + * but if a pane is present, then it is one of two type - Modal + * Pane (appears on the left side of the display; visibility is + * tied to the `ISimpleToolRail` component) (Note that there + * can be only one modal pane visible at a time) - Global Pane + * (appears on the right side of the display; visibility is up + * to the creator/user) + */ +export interface ISimpleToolPaneComponent { + get childPaneList(): string[]; + get id(): string; + get isVisible(): boolean; + get pane(): IPropertyPane; + get session(): IPlayerUISession; + get simpleTool(): ISimpleTool; + /** + * @remarks + */ + findPane(idString: string): ISimpleToolPaneComponent | undefined; + /** + * @remarks + */ + hidePane(): void; + /** + * @remarks + */ + reconstructPane(): void; + /** + * @remarks + */ + showPane(): void; +} + +/** + * A set of options which define the basic properties of a + * window pane (or sub-pane) for a simple tool. This pane can + * be a top level pane, or a child pane of the top level pane, + * and is the content container for all of the UI controls used + * by the editor tool. Each pane is uniquely identified by the + * `id` property, and has a number of optional function + * closures which are called at various points in the pane's + * lifecycle. Note that instead of having a single `onFinalize` + * function, panes implement a pair of `onBeginFinalize` and + * `onEndFinalize` functions. This is to allow for the pane to + * be partially constructed BEFORE any child panes are + * constructed. Once all child panes have been fully finalized, + * then the `onEndFinalize` function is called to allow the + * pane to finalize itself. + */ +export interface ISimpleToolPaneOptions { + childPaneInitiallyVisible?: string; + childPanes?: ISimpleToolPaneOptions[]; + childPanesMutuallyExclusive?: boolean; + id: string; + onBeginFinalize?: (pane: ISimpleToolPaneComponent) => void; + onEndFinalize?: (pane: ISimpleToolPaneComponent) => void; + onHide?: (pane: ISimpleToolPaneComponent) => void; + onShow?: (pane: ISimpleToolPaneComponent) => void; + onTeardown?: (pane: ISimpleToolPaneComponent) => void; + titleAltText: string; + titleStringId?: string; +} + +export interface ISimpleToolRailComponent { + get session(): IPlayerUISession; + get simpleTool(): ISimpleTool; + get toolRail(): IModalTool; +} + +/** + * The tool rail component allows the tool to register an icon + * and button (and dynamic tooltip) in the tool rail on the + * left side of the display. Adding a tool rail component to a + * tool will cause the tool to be considered a `modal tool`, + * and only one single modal tool can be active at any one + * time. Modal tools are generally tools which take focus and + * control of the cursor (e.g. selection, clipboards, entity + * selection, etc) Global tools (tools which do not have a tool + * rail) are generally things like property pages, settings, + * etc - things that do not require an active cursor or + * gameplay interaction + */ +export interface ISimpleToolRailOptions { + displayAltText: string; + displayStringId?: string; + icon: string; + onActivate?: (component: ISimpleToolRailComponent) => void; + onDeactivate?: (component: ISimpleToolRailComponent) => void; + onFinalize?: (component: ISimpleToolRailComponent) => void; + onTeardown?: (component: ISimpleToolRailComponent) => void; + tooltipAltText: string; + tooltipStringId?: string; +} + +export interface ISimpleToolStatusBarComponent { + get session(): IPlayerUISession; + get simpleTool(): ISimpleTool; + get statusBarItem(): IStatusBarItem; + hide(): void; + show(): void; +} + +/** + * A set of options which define the basic properties of a + * status bar item for a simple tool. + */ +export interface ISimpleToolStatusBarOptions { + alignment: EditorStatusBarAlignment; + displayAltText: string; + onFinalize?: (statusBar: ISimpleToolStatusBarComponent) => void; + onHide?: (statusBar: ISimpleToolStatusBarComponent) => void; + onShow?: (statusBar: ISimpleToolStatusBarComponent) => void; + onTeardown?: (statusBar: ISimpleToolStatusBarComponent) => void; + size: number; + visibility?: SimpleToolStatusBarVisibility; +} + +export interface IStatusBarItem { + /** + * @remarks + * Unique ID for the item. + * + */ + readonly id: string; + /** + * @remarks + * Text to display. + * + */ + text: string; + hide(): void; + show(): void; +} + +/** + * Parameters for creating a modal tool in the tool container + */ +export interface ModalToolCreationParameters { + /** + * @remarks + * The displayed string for the tool + * + */ + displayAltText: string; + /** + * @remarks + * Loc ID (resolved on client) + * + */ + displayStringId?: string; + /** + * @remarks + * Icon, if any (from resource pack on client) + * + */ + icon?: string; + /** + * @remarks + * tooltipAltText alt text, if any + * + */ + tooltipAltText?: string; + /** + * @remarks + * Tooltip localization string ID + * + */ + tooltipStringId?: string; +} + +/** + * @remarks + * Takes the input object (a property bag of values) and bind + * it to the pane as a data source. UI child elements of the + * pane will be updated when the values in the object change, + * and vice versa. + * + * @param propertyPane + * The property pane to bind the property bag to. + * @param target + * The property bag to bind to the pane. + */ +export declare function bindDataSource( + propertyPane: IPropertyPane, + target: T, +): T; +/** + * @remarks + * Executes an operation over a selection via chunks to allow + * splitting operation over multiple game ticks + * + * @param selection + * the selection to iterator over + * @param operation + * the operation to apply over each block location + */ +export declare function executeLargeOperation( + selection: Selection, + operation: (blockLocation: minecraftserver.Vector3) => void, +): Promise; +/** + * @remarks + * Returns a string array of the default block types for the + * Block picker control. Can be used to further filter blocks + * from the Block picker. + * + * @returns + * Default allowed block list + */ +export declare function getBlockPickerDefaultAllowBlockList(): string[]; +/** + * @remarks + * Adds the resource pack editor prefix and returns the full + * localization ID + * + */ +export declare function getLocalizationId(locId: string): string; +/** + * @remarks + * Registers an editor extension into Minecraft. This function + * calls underlying functionality to register an extension but + * provides helpful and contextual wrappers for individual + * client lifetimes. The onActivation function is called + * whenever a client joins a session, while the shutdown is + * called when a client leaves. There may be other + * circumstances in which these are called as well based on + * client state that is an implementation detail of the system. + * + */ +export declare function registerEditorExtension>( + extensionName: string, + activationFunction: ActivationFunctionType, + shutdownFunction: ShutdownFunctionType, + options?: IRegisterExtensionOptionalParameters, +): Extension; +/** + * @remarks + * Creates a strongly typed transaction handle to enforce type + * safety when adding user defined transactions. This function + * is a wrapper around the more generalized transaction manager + * API for script based transactions. Any Editor Extension that + * needs to insert data into the transaction log for undo/redo + * should use this function to create a handler for the + * specific type of data that needs to be inserted. When a + * transaction is undone/redone, the associated handler + * function will be invoked with a copy of the payload data + * that was inserted into the log. As a general rule, + * transaction data should contain 2 things:
1. The data + * that will be used to perform the operation we're trying to + * record
2. The data that will be used to restore the + * state of the program to what it was before the + * operation.
NOTE/WARNING:
The payload data is + * serialized to JSON before being inserted into the + * transaction log and the underlying implementation uses the + * JSON.stringify() function to serialize the data. Any + * non-primitive data, such as classes or minecraft native + * objects will not serialize to JSON properly, so you should + * avoid using them as payload data. + * + * @param transactionManager + * A reference to the TransactionManager (from the extension + * context for your extension) + * @param undoHandler + * A function that will be invoked when the transaction is + * undone. The function will be passed a copy of the payload + * data that was inserted into the transaction log. + * @param redoHandler + * A function that will be invoked when the transaction is + * redone. The function will be passed a copy of the payload + * data that was inserted into the transaction log. + * @returns + * - {@link UserDefinedTransactionHandle} - A strongly typed + * transaction handle that can be used to add transactions to + * the transaction manager. + */ +export declare function registerUserDefinedTransactionHandler( + transactionManager: TransactionManager, + undoHandler: (payload: T) => void, + redoHandler: (payload: T) => void, +): UserDefinedTransactionHandle; +/** + * @remarks + * Small utility for getting a string from an unknown exception + * type + * + */ +export declare function stringFromException(e: unknown): string; +export const editor: MinecraftEditor; diff --git a/static/typedoc/preview/server-gametest.d.ts b/static/typedoc/preview/server-gametest.d.ts index edc6986eec..3413c5a3e6 100644 --- a/static/typedoc/preview/server-gametest.d.ts +++ b/static/typedoc/preview/server-gametest.d.ts @@ -17,11 +17,12 @@ * ```json * { * "module_name": "@minecraft/server-gametest", - * "version": "1.0.0-internal.1.20.0-preview.20" + * "version": "1.0.0-internal.1.21.0-preview.23" * } * ``` * */ +import * as minecraftcommon from '@minecraft/common'; import * as minecraftserver from '@minecraft/server'; export enum GameTestErrorType { Assert = 'Assert', @@ -35,12 +36,19 @@ export enum GameTestErrorType { Unknown = 'Unknown', Waiting = 'Waiting', } + +export enum LookDuration { + Continuous = 'Continuous', + Instant = 'Instant', + UntilMove = 'UntilMove', +} + /** * Returns information about whether this fence is connected to * other fences in several directions. */ export class FenceConnectivity { - protected constructor(); + private constructor(); /** * @remarks * Represents whether this fence block is connected to another @@ -70,13 +78,14 @@ export class FenceConnectivity { */ readonly west: boolean; } + /** * Executes a set of steps defined via chained .thenXyz * methods, sequentially. This facilitates a 'script' of * GameTest setup methods and assertions over time. */ export class GameTestSequence { - protected constructor(); + private constructor(); /** * @remarks * Runs the given callback as a step within a GameTest @@ -193,12 +202,19 @@ export class GameTestSequence { */ thenWaitAfter(delayTicks: number, callback: () => void): GameTestSequence; } + +export class NavigationResult { + private constructor(); + readonly isFullPath: boolean; + getPath(): minecraftserver.Vector3[]; +} + /** * A utility class to set GameTest parameters for a test. * Methods can be chained together to set multiple properties. */ export class RegistrationBuilder { - protected constructor(); + private constructor(); /** * @remarks * Sets the batch for the test to run in. @@ -325,13 +341,14 @@ export class RegistrationBuilder { */ tag(tag: string): RegistrationBuilder; } + /** * Implements a class that can be used for testing sculk * spreading behaviors. This sculk spreader class can drive the * growth of sculk around a particular block. */ export class SculkSpreader { - protected constructor(); + private constructor(); /** * @remarks * Gets the maximum charge of a sculk spreader. @@ -376,15 +393,20 @@ export class SculkSpreader { */ getTotalCharge(): number; } + /** * A simulated player can be used within GameTests to represent * how a player moves throughout the world and to support * testing of how entities and the environment will react to a * player. This type derives much of its structure and methods - * from the {@link @minecraft/server.Player} type. + * from the {@link @minecraft/server.Player} type. Note that + * many types of events that may be available for entities more + * broadly, such as item use events, may not fire in the same + * capacity for simulated players. */ +// @ts-ignore Class inheritance allowed for native defined classes export class SimulatedPlayer extends minecraftserver.Player { - protected constructor(); + private constructor(); /** * @remarks * Rotation of the head across pitch and yaw angles. @@ -394,6 +416,8 @@ export class SimulatedPlayer extends minecraftserver.Player { readonly headRotation: minecraftserver.Vector2; /** * @remarks + * Returns whether the simulated player is sprinting. + * * This property can't be edited in read-only mode. * */ @@ -439,6 +463,13 @@ export class SimulatedPlayer extends minecraftserver.Player { * @throws This function can throw errors. */ breakBlock(blockLocation: minecraftserver.Vector3, direction?: minecraftserver.Direction): boolean; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + chat(message: string): void; /** * @remarks * Simulates and performs a disconnection of the simulated @@ -449,6 +480,26 @@ export class SimulatedPlayer extends minecraftserver.Player { * @throws This function can throw errors. */ disconnect(): void; + /** + * @remarks + * Drops the simulated player's selected item + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + dropSelectedItem(): boolean; + /** + * @remarks + * Causes the simulated player to start flying as though they + * were flying in creative mode. For flying with Elytra, see + * function glide. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + fly(): void; /** * @remarks * Gives the simulated player a particular item stack. @@ -462,6 +513,21 @@ export class SimulatedPlayer extends minecraftserver.Player { * @throws This function can throw errors. */ giveItem(itemStack: minecraftserver.ItemStack, selectSlot?: boolean): boolean; + /** + * @remarks + * Causes the simulated player to start gliding. Elytra must be + * equipped and the player must be in the air. + * + * This function can't be called in read-only mode. + * + * @returns + * Returns true if the simulated player begins to glide. + * Returns false if the player is already gliding, or the + * player does not have Elytra equipped, is in water or is on + * the ground. + * @throws This function can throw errors. + */ + glide(): boolean; /** * @remarks * Performs a raycast from the player’s head and interacts with @@ -520,7 +586,7 @@ export class SimulatedPlayer extends minecraftserver.Player { * * @throws This function can throw errors. */ - lookAtBlock(blockLocation: minecraftserver.Vector3): void; + lookAtBlock(blockLocation: minecraftserver.Vector3, duration?: LookDuration): void; /** * @remarks * Rotates the simulated player's head/body to look at the @@ -530,7 +596,7 @@ export class SimulatedPlayer extends minecraftserver.Player { * * @throws This function can throw errors. */ - lookAtEntity(entity: minecraftserver.Entity): void; + lookAtEntity(entity: minecraftserver.Entity, duration?: LookDuration): void; /** * @remarks * Rotates the simulated player's head/body to look at the @@ -540,7 +606,7 @@ export class SimulatedPlayer extends minecraftserver.Player { * * @throws This function can throw errors. */ - lookAtLocation(location: minecraftserver.Vector3): void; + lookAtLocation(location: minecraftserver.Vector3, duration?: LookDuration): void; /** * @remarks * Orders the simulated player to walk in the given direction @@ -572,7 +638,7 @@ export class SimulatedPlayer extends minecraftserver.Player { * * @throws This function can throw errors. */ - moveToBlock(blockLocation: minecraftserver.Vector3, speed?: number): void; + moveToBlock(blockLocation: minecraftserver.Vector3, options?: MoveToOptions): void; /** * @remarks * Orders the simulated player to move to the given location in @@ -583,7 +649,7 @@ export class SimulatedPlayer extends minecraftserver.Player { * * @throws This function can throw errors. */ - moveToLocation(location: minecraftserver.Vector3, speed?: number): void; + moveToLocation(location: minecraftserver.Vector3, options?: MoveToOptions): void; /** * @remarks * Orders the simulated player to move to a specific block @@ -597,7 +663,7 @@ export class SimulatedPlayer extends minecraftserver.Player { * * @throws This function can throw errors. */ - navigateToBlock(blockLocation: minecraftserver.Vector3, speed?: number): minecraftserver.NavigationResult; + navigateToBlock(blockLocation: minecraftserver.Vector3, speed?: number): NavigationResult; /** * @remarks * Will use navigation to follow the selected entity to within @@ -608,7 +674,7 @@ export class SimulatedPlayer extends minecraftserver.Player { * * @throws This function can throw errors. */ - navigateToEntity(entity: minecraftserver.Entity, speed?: number): minecraftserver.NavigationResult; + navigateToEntity(entity: minecraftserver.Entity, speed?: number): NavigationResult; /** * @remarks * Orders the simulated player to move to a specific location @@ -622,7 +688,7 @@ export class SimulatedPlayer extends minecraftserver.Player { * * @throws This function can throw errors. */ - navigateToLocation(location: minecraftserver.Vector3, speed?: number): minecraftserver.NavigationResult; + navigateToLocation(location: minecraftserver.Vector3, speed?: number): NavigationResult; /** * @remarks * Use navigation to follow the route provided via the @@ -667,18 +733,6 @@ export class SimulatedPlayer extends minecraftserver.Player { * @throws This function can throw errors. */ setBodyRotation(angleInDegrees: number): void; - /** - * @remarks - * Sets the game mode that the simulated player is operating - * under. - * - * This function can't be called in read-only mode. - * - * @param gameMode - * Game mode to set. - * @throws This function can throw errors. - */ - setGameMode(gameMode: minecraftserver.GameMode): void; /** * @remarks * Sets a particular item for the simulated player. @@ -694,6 +748,13 @@ export class SimulatedPlayer extends minecraftserver.Player { * @throws This function can throw errors. */ setItem(itemStack: minecraftserver.ItemStack, slot: number, selectSlot?: boolean): boolean; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + startBuild(slot?: number): void; /** * @remarks * Stops destroying the block that is currently being hit. @@ -703,6 +764,31 @@ export class SimulatedPlayer extends minecraftserver.Player { * @throws This function can throw errors. */ stopBreakingBlock(): void; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + stopBuild(): void; + /** + * @remarks + * Causes the simulated player to stop flying. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + stopFlying(): void; + /** + * @remarks + * Causes the simulated player to stop gliding. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + stopGliding(): void; /** * @remarks * Stops interacting with entities or blocks. @@ -722,15 +808,36 @@ export class SimulatedPlayer extends minecraftserver.Player { * @throws This function can throw errors. */ stopMoving(): void; + /** + * @remarks + * Causes the simulated player to stop swimming. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + stopSwimming(): void; /** * @remarks * Stops using the currently active item. * * This function can't be called in read-only mode. * + * @returns + * Returns the item that was in use. Undefined if no item was + * in use. + * @throws This function can throw errors. + */ + stopUsingItem(): minecraftserver.ItemStack | undefined; + /** + * @remarks + * Causes the simulated player to start swimming. + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ - stopUsingItem(): void; + swim(): void; /** * @remarks * Causes the simulated player to use an item. Does not consume @@ -806,12 +913,13 @@ export class SimulatedPlayer extends minecraftserver.Player { faceLocation?: minecraftserver.Vector3, ): boolean; } + /** * These well-known tags can be used to classify different * tests into suites to run. */ export class Tags { - protected constructor(); + private constructor(); /** * @remarks * Indicates that the tagged test should be a part of all @@ -840,7 +948,9 @@ export class Tags { * */ static readonly suiteDisabled = 'suite:disabled'; + static readonly suiteNextUpdate = 'suite:nextupdate'; } + /** * Main class for GameTest functions, with helpers and data for * manipulating the respective test. Note that all methods of @@ -848,7 +958,7 @@ export class Tags { * the GameTest structure block. */ export class Test { - protected constructor(); + private constructor(); /** * @remarks * Tests that the condition specified in _condition_ is true. @@ -860,6 +970,8 @@ export class Test { * Message that is passed if the _condition_ does not evaluate * to true. * @throws This function can throw errors. + * + * {@link GameTestError} */ assert(condition: boolean, message: string): void; /** @@ -876,9 +988,11 @@ export class Test { * specified type is at the location. If false, tests that a * block of the specified type is not present. * @throws This function can throw errors. + * + * {@link GameTestError} */ assertBlockPresent( - blockType: minecraftserver.BlockType, + blockType: minecraftserver.BlockType | string, blockLocation: minecraftserver.Vector3, isPresent?: boolean, ): void; @@ -894,12 +1008,13 @@ export class Test { * Callback function that contains additional tests based on * the block at the specified location. * @throws This function can throw errors. + * + * {@link GameTestError} * @example testIfButtonNotPressed.js * ```typescript - * test.assertBlockState(buttonPos, (block) => { - * return block.permutation.getProperty("button_pressed_bit") == 0; - * }); - * + * test.assertBlockState(buttonPos, (block) => { + * return block.permutation.getProperty("button_pressed_bit") == 0; + * }); * ``` */ assertBlockState(blockLocation: minecraftserver.Vector3, callback: (arg: minecraftserver.Block) => boolean): void; @@ -919,6 +1034,8 @@ export class Test { * false, tests whether the mob is not able to reach the * location. * @throws This function can throw errors. + * + * {@link GameTestError} */ assertCanReachLocation( mob: minecraftserver.Entity, @@ -939,6 +1056,8 @@ export class Test { * Location of the block with a container (for example, a * chest) to test the contents of. * @throws This function can throw errors. + * + * {@link GameTestError} */ assertContainerContains(itemStack: minecraftserver.ItemStack, blockLocation: minecraftserver.Vector3): void; /** @@ -950,6 +1069,8 @@ export class Test { * Location of the block with a container (for example, a * chest) to test is empty of contents. * @throws This function can throw errors. + * + * {@link GameTestError} */ assertContainerEmpty(blockLocation: minecraftserver.Vector3): void; /** @@ -972,10 +1093,11 @@ export class Test { * Whether or not the entity is expected to have the specified * armor equipped. * @throws This function can throw errors. + * + * {@link GameTestError} * @example horseArmorTest.js * ```typescript - * test.assertEntityHasArmor("minecraft:horse", armorSlotTorso, "diamond_horse_armor", 0, horseLocation, true); - * + * test.assertEntityHasArmor("minecraft:horse", armorSlotTorso, "diamond_horse_armor", 0, horseLocation, true); * ``` */ assertEntityHasArmor( @@ -1005,10 +1127,11 @@ export class Test { * Determines whether to test that the component exists, or * does not. * @throws This function can throw errors. + * + * {@link GameTestError} * @example sheepShearedTest.js * ```typescript - * test.assertEntityHasComponent("minecraft:sheep", "minecraft:is_sheared", entityLoc, false); - * + * test.assertEntityHasComponent("minecraft:sheep", "minecraft:is_sheared", entityLoc, false); * ``` */ assertEntityHasComponent( @@ -1032,6 +1155,8 @@ export class Test { * Whether to test that an entity is present or not present at * the specified location. * @throws This function can throw errors. + * + * {@link GameTestError} */ assertEntityInstancePresent( entity: minecraftserver.Entity, @@ -1050,25 +1175,28 @@ export class Test { * present in the GameTest area. If false, tests that the * specified entity is not present. * @throws This function can throw errors. + * + * {@link GameTestError} * @example simpleMobTest.ts * ```typescript - * gt.register("StarterTests", "simpleMobTest", (test: gt.Test) => { - * const attackerId = "fox"; - * const victimId = "chicken"; - * - * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); - * let victim = test.spawn(victimId, { x: 2, y: 2, z: 2 }); + * import * as gameTest from '@minecraft/server-gametest'; * - * test.assertEntityInstancePresentInArea(victim, true); + * gameTest + * .register('StarterTests', 'simpleMobTest', (test: gameTest.Test) => { + * const attackerId = 'fox'; + * const victimId = 'chicken'; * - * test.succeedWhen(() => { - * test.assertEntityInstancePresentInArea(victim, false); - * }); - * }) - * .maxTicks(400) - * .structureName("gametests:mediumglass"); + * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); + * const victim = test.spawn(victimId, { x: 2, y: 2, z: 2 }); * + * test.assertEntityInstancePresentInArea(victim, true); * + * test.succeedWhen(() => { + * test.assertEntityInstancePresentInArea(victim, false); + * }); + * }) + * .maxTicks(400) + * .structureName('gametests:mediumglass'); * ``` */ assertEntityInstancePresentInArea(entity: minecraftserver.Entity, isPresent?: boolean): void; @@ -1093,6 +1221,8 @@ export class Test { * specified type is present. If false, tests that an entity of * the specified type is not present. * @throws This function can throw errors. + * + * {@link GameTestError} */ assertEntityPresent( entityTypeIdentifier: string, @@ -1114,25 +1244,28 @@ export class Test { * specified type is present in the GameTest area. If false, * tests that an entity of the specified type is not present. * @throws This function can throw errors. + * + * {@link GameTestError} * @example simpleMobTest.ts * ```typescript - * gt.register("StarterTests", "simpleMobTest", (test: gt.Test) => { - * const attackerId = "fox"; - * const victimId = "chicken"; + * import * as gameTest from '@minecraft/server-gametest'; * - * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); - * test.spawn(victimId, { x: 2, y: 2, z: 2 }); + * gameTest + * .register('StarterTests', 'simpleMobTest', (test: gameTest.Test) => { + * const attackerId = 'fox'; + * const victimId = 'chicken'; * - * test.assertEntityPresentInArea(victimId, true); - * - * test.succeedWhen(() => { - * test.assertEntityPresentInArea(victimId, false); - * }); - * }) - * .maxTicks(400) - * .structureName("gametests:mediumglass"); + * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); + * test.spawn(victimId, { x: 2, y: 2, z: 2 }); * + * test.assertEntityPresentInArea(victimId, true); * + * test.succeedWhen(() => { + * test.assertEntityPresentInArea(victimId, false); + * }); + * }) + * .maxTicks(400) + * .structureName('gametests:mediumglass'); * ``` */ assertEntityPresentInArea(entityTypeIdentifier: string, isPresent?: boolean): void; @@ -1154,14 +1287,15 @@ export class Test { * entity with the specified identifier is found, an exception * is thrown. * @throws This function can throw errors. + * + * {@link GameTestError} * @example villagerEffectTest.js * ```typescript - * test.assertEntityState( - * villagerPos, - * "minecraft:villager_v2", - * (entity) => entity.getEffect(MinecraftEffectTypes.regeneration).duration > 120 - * ); // At least 6 seconds remaining in the villagers' effect - * + * test.assertEntityState( + * villagerPos, + * "minecraft:villager_v2", + * (entity) => entity.getEffect(MinecraftEffectTypes.Regeneration).duration > 120 + * ); // At least 6 seconds remaining in the villagers' effect * ``` */ assertEntityState( @@ -1186,6 +1320,8 @@ export class Test { * the specified location. If false, tests that an entity is * not testing the specified location. * @throws This function can throw errors. + * + * {@link GameTestError} */ assertEntityTouching(entityTypeIdentifier: string, location: minecraftserver.Vector3, isTouching?: boolean): void; /** @@ -1201,6 +1337,8 @@ export class Test { * Whether to test that the block at _position_ is expected to * be waterlogged. * @throws This function can throw errors. + * + * {@link GameTestError} */ assertIsWaterlogged(blockLocation: minecraftserver.Vector3, isWaterlogged?: boolean): void; /** @@ -1218,14 +1356,15 @@ export class Test { * @param count * Number of items, at minimum, to look and test for. * @throws This function can throw errors. + * + * {@link GameTestError} * @example findFeathers.js * ```typescript - * test.assertItemEntityCountIs(Items.feather, expectedFeatherLoc, 0, 1); - * + * test.assertItemEntityCountIs(Items.feather, expectedFeatherLoc, 0, 1); * ``` */ assertItemEntityCountIs( - itemType: minecraftserver.ItemType, + itemType: minecraftserver.ItemType | string, blockLocation: minecraftserver.Vector3, searchDistance: number, count: number, @@ -1248,9 +1387,11 @@ export class Test { * specified type is present. If false, tests that an item * entity of the specified type is not present. * @throws This function can throw errors. + * + * {@link GameTestError} */ assertItemEntityPresent( - itemType: minecraftserver.ItemType, + itemType: minecraftserver.ItemType | string, blockLocation: minecraftserver.Vector3, searchDistance?: number, isPresent?: boolean, @@ -1265,6 +1406,8 @@ export class Test { * @param power * Expected power level. * @throws This function can throw errors. + * + * {@link GameTestError} */ assertRedstonePower(blockLocation: minecraftserver.Vector3, power: number): void; /** @@ -1278,6 +1421,8 @@ export class Test { * @param dropResources * Whether to add resources exposed with a particular drop. * @throws This function can throw errors. + * + * {@link GameTestError} */ destroyBlock(blockLocation: minecraftserver.Vector3, dropResources?: boolean): void; /** @@ -1310,6 +1455,8 @@ export class Test { * @param blockLocation * Location of the block to retrieve. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} */ getBlock(blockLocation: minecraftserver.Vector3): minecraftserver.Block; /** @@ -1317,6 +1464,8 @@ export class Test { * Gets the dimension of this test. * * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} */ getDimension(): minecraftserver.Dimension; /** @@ -1330,6 +1479,8 @@ export class Test { * @param blockLocation * Location of the block to retrieve. * @throws This function can throw errors. + * + * {@link GameTestError} */ getFenceConnectivity(blockLocation: minecraftserver.Vector3): FenceConnectivity; /** @@ -1341,9 +1492,14 @@ export class Test { * * @param blockLocation * Location of the block to retrieve a sculk spreader from. + * @returns + * Returns the SculkSpreader or undefined if no SculkSpreader + * is present on the block. * @throws This function can throw errors. + * + * {@link GameTestError} */ - getSculkSpreader(blockLocation: minecraftserver.Vector3): SculkSpreader; + getSculkSpreader(blockLocation: minecraftserver.Vector3): SculkSpreader | undefined; /** * @remarks * Returns the direction of the current test - see the {@link @@ -1370,6 +1526,8 @@ export class Test { * This function can't be called in read-only mode. * * @throws This function can throw errors. + * + * {@link GameTestError} */ killAllEntities(): void; /** @@ -1377,6 +1535,8 @@ export class Test { * This function can't be called in read-only mode. * * @throws This function can throw errors. + * + * {@link GameTestError} */ onPlayerJump(mob: minecraftserver.Entity, jumpAmount: number): void; /** @@ -1390,6 +1550,8 @@ export class Test { * @throws * Will throw an error if a button is not present at the * specified position. + * + * {@link GameTestError} */ pressButton(blockLocation: minecraftserver.Vector3): void; /** @@ -1401,6 +1563,8 @@ export class Test { * @param text * Message to display. * @throws This function can throw errors. + * + * {@link GameTestError} */ print(text: string): void; /** @@ -1414,6 +1578,8 @@ export class Test { * @throws * Will throw an error if a lever is not present at the * specified position. + * + * {@link GameTestError} */ pullLever(blockLocation: minecraftserver.Vector3): void; /** @@ -1428,6 +1594,8 @@ export class Test { * @param duration * Number of ticks to pulse Redstone. * @throws This function can throw errors. + * + * {@link GameTestError} */ pulseRedstone(blockLocation: minecraftserver.Vector3, duration: number): void; /** @@ -1444,6 +1612,8 @@ export class Test { * @returns * A location relative to the GameTest command block. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} */ relativeBlockLocation(worldBlockLocation: minecraftserver.Vector3): minecraftserver.Vector3; /** @@ -1462,6 +1632,8 @@ export class Test { * @returns * A location relative to the GameTest command block. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} */ relativeLocation(worldLocation: minecraftserver.Vector3): minecraftserver.Vector3; /** @@ -1489,6 +1661,8 @@ export class Test { * test direction; Passing in Direction.north will return the * opposite of the test direction, and so on. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} */ rotateDirection(direction: minecraftserver.Direction): minecraftserver.Direction; /** @@ -1496,6 +1670,8 @@ export class Test { * This function can't be called in read-only mode. * * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} */ rotateVector(vector: minecraftserver.Vector3): minecraftserver.Vector3; /** @@ -1540,6 +1716,8 @@ export class Test { * @param blockLocation * Location of the block to set. * @throws This function can throw errors. + * + * {@link GameTestError} */ setBlockPermutation(blockData: minecraftserver.BlockPermutation, blockLocation: minecraftserver.Vector3): void; /** @@ -1554,8 +1732,10 @@ export class Test { * @param blockLocation * Location of the block to set. * @throws This function can throw errors. + * + * {@link GameTestError} */ - setBlockType(blockType: minecraftserver.BlockType, blockLocation: minecraftserver.Vector3): void; + setBlockType(blockType: minecraftserver.BlockType | string, blockLocation: minecraftserver.Vector3): void; /** * @remarks * For blocks that are fluid containers - like a cauldron - @@ -1569,6 +1749,8 @@ export class Test { * Type of fluid to set. See {@link * @minecraft/server-gametest.FluidType} for a list of values. * @throws This function can throw errors. + * + * {@link GameTestError} */ setFluidContainer(location: minecraftserver.Vector3, type: minecraftserver.FluidType): void; /** @@ -1582,6 +1764,8 @@ export class Test { * @param fuseLength * Length of time, in ticks, before the entity explodes. * @throws This function can throw errors. + * + * {@link GameTestError} */ setTntFuse(entity: minecraftserver.Entity, fuseLength: number): void; /** @@ -1599,29 +1783,32 @@ export class Test { * The spawned entity. If the entity cannot be spawned, returns * undefined. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} * @example simpleMobTest.ts * ```typescript - * gt.register("StarterTests", "simpleMobTest", (test: gt.Test) => { - * const attackerId = "fox"; - * const victimId = "chicken"; + * import * as gameTest from '@minecraft/server-gametest'; * - * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); - * test.spawn(victimId, { x: 2, y: 2, z: 2 }); + * gameTest + * .register('StarterTests', 'simpleMobTest', (test: gameTest.Test) => { + * const attackerId = 'fox'; + * const victimId = 'chicken'; * - * test.assertEntityPresentInArea(victimId, true); + * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); + * test.spawn(victimId, { x: 2, y: 2, z: 2 }); * - * test.succeedWhen(() => { - * test.assertEntityPresentInArea(victimId, false); - * }); - * }) - * .maxTicks(400) - * .structureName("gametests:mediumglass"); + * test.assertEntityPresentInArea(victimId, true); * + * test.succeedWhen(() => { + * test.assertEntityPresentInArea(victimId, false); + * }); + * }) + * .maxTicks(400) + * .structureName('gametests:mediumglass'); * ``` * @example spawnAdultPig.js * ```typescript - * test.spawn("minecraft:pig", { x: 1, y: 2, z: 1 }); - * + * test.spawn("minecraft:pig", { x: 1, y: 2, z: 1 }); * * ``` */ @@ -1641,10 +1828,11 @@ export class Test { * The spawned entity. If the entity cannot be spawned, returns * undefined. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} * @example spawnAdultPig.js * ```typescript - * test.spawn("minecraft:pig", { x: 1.5, y: 2, z: 1.5 }); - * + * test.spawn("minecraft:pig", { x: 1.5, y: 2, z: 1.5 }); * ``` */ spawnAtLocation(entityTypeIdentifier: string, location: minecraftserver.Vector3): minecraftserver.Entity; @@ -1659,15 +1847,15 @@ export class Test { * @param location * Location to create the item entity at. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} * @example spawnEmeralds.js * ```typescript - * const oneEmerald = new ItemStack(MinecraftItemTypes.emerald, 1, 0); - * const fiveEmeralds = new ItemStack(MinecraftItemTypes.emerald, 5, 0); - * - * test.spawnItem(oneEmerald, { x: 3.5, y: 3, z: 1.5 }); - * test.spawnItem(fiveEmeralds, { x: 1.5, y: 3, z: 1.5 }); - * + * const oneEmerald = new ItemStack(MinecraftItemTypes.Emerald, 1, 0); + * const fiveEmeralds = new ItemStack(MinecraftItemTypes.Emerald, 5, 0); * + * test.spawnItem(oneEmerald, { x: 3.5, y: 3, z: 1.5 }); + * test.spawnItem(fiveEmeralds, { x: 1.5, y: 3, z: 1.5 }); * ``` */ spawnItem(itemStack: minecraftserver.ItemStack, location: minecraftserver.Vector3): minecraftserver.Entity; @@ -1682,6 +1870,8 @@ export class Test { * @param name * Name to give the new simulated player. * @throws This function can throw errors. + * + * {@link GameTestError} */ spawnSimulatedPlayer( blockLocation: minecraftserver.Vector3, @@ -1699,6 +1889,8 @@ export class Test { * @param blockLocation * Location where the entity should be spawned. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} */ spawnWithoutBehaviors(entityTypeIdentifier: string, blockLocation: minecraftserver.Vector3): minecraftserver.Entity; /** @@ -1712,6 +1904,8 @@ export class Test { * @param location * Location where the entity should be spawned. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} */ spawnWithoutBehaviorsAtLocation( entityTypeIdentifier: string, @@ -1732,10 +1926,11 @@ export class Test { * Direction to spread. Use the Minecraft.Direction enum to * specify a direction. * @throws This function can throw errors. + * + * {@link GameTestError} * @example spreadFromFaceTowardDirection.js * ```typescript - * test.spreadFromFaceTowardDirection({ x: 1, y: 2, z: 1 }, Direction.south, Direction.down); - * + * test.spreadFromFaceTowardDirection({ x: 1, y: 2, z: 1 }, Direction.south, Direction.down); * ``` */ spreadFromFaceTowardDirection( @@ -1822,23 +2017,24 @@ export class Test { * @throws This function can throw errors. * @example simpleMobTest.ts * ```typescript - * gt.register("StarterTests", "simpleMobTest", (test: gt.Test) => { - * const attackerId = "fox"; - * const victimId = "chicken"; - * - * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); - * test.spawn(victimId, { x: 2, y: 2, z: 2 }); + * import * as gameTest from '@minecraft/server-gametest'; * - * test.assertEntityPresentInArea(victimId, true); + * gameTest + * .register('StarterTests', 'simpleMobTest', (test: gameTest.Test) => { + * const attackerId = 'fox'; + * const victimId = 'chicken'; * - * test.succeedWhen(() => { - * test.assertEntityPresentInArea(victimId, false); - * }); - * }) - * .maxTicks(400) - * .structureName("gametests:mediumglass"); + * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); + * test.spawn(victimId, { x: 2, y: 2, z: 2 }); * + * test.assertEntityPresentInArea(victimId, true); * + * test.succeedWhen(() => { + * test.assertEntityPresentInArea(victimId, false); + * }); + * }) + * .maxTicks(400) + * .structureName('gametests:mediumglass'); * ``` */ succeedWhen(callback: () => void): void; @@ -1860,9 +2056,11 @@ export class Test { * specified type is present. If false, tests that a block of * the specified type is not present. * @throws This function can throw errors. + * + * {@link GameTestError} */ succeedWhenBlockPresent( - blockType: minecraftserver.BlockType, + blockType: minecraftserver.BlockType | string, blockLocation: minecraftserver.Vector3, isPresent?: boolean, ): void; @@ -1933,6 +2131,8 @@ export class Test { * minecraft:grow_up, minecraft:grow_down and * minecraft:grow_sideways. * @throws This function can throw errors. + * + * {@link GameTestError} */ triggerInternalBlockEvent(blockLocation: minecraftserver.Vector3, event: string, eventParameters?: number[]): void; /** @@ -1964,6 +2164,8 @@ export class Test { * @param speedModifier * Adjustable modifier to the mob's walking speed. * @throws This function can throw errors. + * + * {@link GameTestError} */ walkTo(mob: minecraftserver.Entity, blockLocation: minecraftserver.Vector3, speedModifier?: number): void; /** @@ -1982,6 +2184,8 @@ export class Test { * @param speedModifier * Adjustable modifier to the mob's walking speed. * @throws This function can throw errors. + * + * {@link GameTestError} */ walkToLocation(mob: minecraftserver.Entity, location: minecraftserver.Vector3, speedModifier?: number): void; /** @@ -1996,6 +2200,8 @@ export class Test { * @returns * An absolute location relative to the GameTest command block. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} */ worldBlockLocation(relativeBlockLocation: minecraftserver.Vector3): minecraftserver.Vector3; /** @@ -2010,20 +2216,31 @@ export class Test { * @returns * An absolute location relative to the GameTest command block. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} */ worldLocation(relativeLocation: minecraftserver.Vector3): minecraftserver.Vector3; } + export interface GameTestErrorContext { absolutePosition: minecraftserver.Vector3; relativePosition: minecraftserver.Vector3; tickCount: number; } + +export interface MoveToOptions { + faceTarget?: boolean; + speed?: number; +} + +// @ts-ignore Class inheritance allowed for native defined classes export class GameTestError extends Error { - protected constructor(); + private constructor(); context?: GameTestErrorContext; messageParameters: string[]; type: GameTestErrorType; } + /** * @remarks * Registers a new GameTest function. This GameTest will become @@ -2042,31 +2259,26 @@ export class GameTestError extends Error { * Returns a {@link RegistrationBuilder} object where * additional options for this test can be specified via * builder methods. - * @example example1.js - * ```typescript - * GameTest.register("ExampleTests", "alwaysFail", (test) => { - * test.fail("This test, runnable via '/gametest run ExampleTests:alwaysFail', will always fail"); - * }); - * - * ``` * @example simpleMobTest.ts * ```typescript - * gt.register("StarterTests", "simpleMobTest", (test: gt.Test) => { - * const attackerId = "fox"; - * const victimId = "chicken"; + * import * as gameTest from '@minecraft/server-gametest'; * - * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); - * test.spawn(victimId, { x: 2, y: 2, z: 2 }); + * gameTest + * .register('StarterTests', 'simpleMobTest', (test: gameTest.Test) => { + * const attackerId = 'fox'; + * const victimId = 'chicken'; * - * test.assertEntityPresentInArea(victimId, true); + * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); + * test.spawn(victimId, { x: 2, y: 2, z: 2 }); * - * test.succeedWhen(() => { - * test.assertEntityPresentInArea(victimId, false); - * }); - * }) - * .maxTicks(400) - * .structureName("gametests:mediumglass"); + * test.assertEntityPresentInArea(victimId, true); * + * test.succeedWhen(() => { + * test.assertEntityPresentInArea(victimId, false); + * }); + * }) + * .maxTicks(400) + * .structureName('gametests:mediumglass'); * ``` */ export function register( @@ -2092,6 +2304,27 @@ export function register( * Returns a {@link RegistrationBuilder} object where * additional options for this test can be specified via * builder methods. + * @example simpleMobAsyncTest.ts + * ```typescript + * import * as gameTest from '@minecraft/server-gametest'; + * + * gameTest + * .registerAsync('StarterTests', 'simpleMobTest', async (test: gameTest.Test) => { + * const attackerId = 'fox'; + * const victimId = 'chicken'; + * + * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); + * test.spawn(victimId, { x: 2, y: 2, z: 2 }); + * + * test.assertEntityPresentInArea(victimId, true); + * + * test.succeedWhen(() => { + * test.assertEntityPresentInArea(victimId, false); + * }); + * }) + * .maxTicks(400) + * .structureName('gametests:mediumglass'); + * ``` */ export function registerAsync( testClassName: string, diff --git a/static/typedoc/preview/server-net.d.ts b/static/typedoc/preview/server-net.d.ts index c0f6ace22e..7a68035123 100644 --- a/static/typedoc/preview/server-net.d.ts +++ b/static/typedoc/preview/server-net.d.ts @@ -17,11 +17,12 @@ * ```json * { * "module_name": "@minecraft/server-net", - * "version": "1.0.0-beta.1.20.0-preview.20" + * "version": "1.0.0-beta.1.21.0-preview.23" * } * ``` * */ +import * as minecraftcommon from '@minecraft/common'; import * as minecraftserveradmin from '@minecraft/server-admin'; export enum HttpRequestMethod { /** @@ -32,7 +33,7 @@ export enum HttpRequestMethod { * specified URI, and not the body contents. * */ - DELETE = 'DELETE', + Delete = 'Delete', /** * @remarks * Represents the method for an HTTP PUT request. POST requests @@ -40,7 +41,7 @@ export enum HttpRequestMethod { * subordinate of the specified URI. * */ - GET = 'GET', + Get = 'Get', /** * @remarks * Represents the method for an HTTP PUT request. GET requests @@ -48,7 +49,7 @@ export enum HttpRequestMethod { * at the specified URI. * */ - HEAD = 'HEAD', + Head = 'Head', /** * @remarks * Represents the method for an HTTP PUT request. GET requests @@ -56,7 +57,7 @@ export enum HttpRequestMethod { * at the specified URI. * */ - POST = 'POST', + Post = 'Post', /** * @remarks * Represents the method for an HTTP PUT request. PUT requests @@ -64,10 +65,33 @@ export enum HttpRequestMethod { * exists in a resource collection. * */ - PUT = 'PUT', + Put = 'Put', } + +/** + * @example simpleHttpRequest.ts + * ```typescript + * import { HttpRequest, HttpHeader, HttpRequestMethod, http } from '@minecraft/server-net'; + * + * async function updateScore() { + * const req = new HttpRequest('http://localhost:3000/updateScore'); + * + * req.body = JSON.stringify({ + * score: 22, + * }); + * + * req.method = HttpRequestMethod.Post; + * req.headers = [ + * new HttpHeader('Content-Type', 'application/json'), + * new HttpHeader('auth', 'my-auth-token'), + * ]; + * + * await http.request(req); + * } + * ``` + */ export class HttpClient { - protected constructor(); + private constructor(); /** * @remarks * Cancels all pending requests. @@ -99,12 +123,53 @@ export class HttpClient { * the HTTP request. * @returns * An awaitable promise that contains the HTTP response. + * @example simpleHttpRequest.ts + * ```typescript + * import { HttpRequest, HttpHeader, HttpRequestMethod, http } from '@minecraft/server-net'; + * + * async function updateScore() { + * const req = new HttpRequest('http://localhost:3000/updateScore'); + * + * req.body = JSON.stringify({ + * score: 22, + * }); + * + * req.method = HttpRequestMethod.Post; + * req.headers = [ + * new HttpHeader('Content-Type', 'application/json'), + * new HttpHeader('auth', 'my-auth-token'), + * ]; + * + * await http.request(req); + * } + * ``` */ request(config: HttpRequest): Promise; } + /** * Represents an HTTP header - a key/value pair of * meta-information about a request. + * @example simpleHttpRequest.ts + * ```typescript + * import { HttpRequest, HttpHeader, HttpRequestMethod, http } from '@minecraft/server-net'; + * + * async function updateScore() { + * const req = new HttpRequest('http://localhost:3000/updateScore'); + * + * req.body = JSON.stringify({ + * score: 22, + * }); + * + * req.method = HttpRequestMethod.Post; + * req.headers = [ + * new HttpHeader('Content-Type', 'application/json'), + * new HttpHeader('auth', 'my-auth-token'), + * ]; + * + * await http.request(req); + * } + * ``` */ export class HttpHeader { /** @@ -125,8 +190,29 @@ export class HttpHeader { value: minecraftserveradmin.SecretString | string; constructor(key: string, value: minecraftserveradmin.SecretString | string); } + /** * Main object for structuring a request. + * @example simpleHttpRequest.ts + * ```typescript + * import { HttpRequest, HttpHeader, HttpRequestMethod, http } from '@minecraft/server-net'; + * + * async function updateScore() { + * const req = new HttpRequest('http://localhost:3000/updateScore'); + * + * req.body = JSON.stringify({ + * score: 22, + * }); + * + * req.method = HttpRequestMethod.Post; + * req.headers = [ + * new HttpHeader('Content-Type', 'application/json'), + * new HttpHeader('auth', 'my-auth-token'), + * ]; + * + * await http.request(req); + * } + * ``` */ export class HttpRequest { /** @@ -213,11 +299,12 @@ export class HttpRequest { */ setTimeout(timeout: number): HttpRequest; } + /** * Main object that contains result information from a request. */ export class HttpResponse { - protected constructor(); + private constructor(); /** * @remarks * Body content of the HTTP response. @@ -247,4 +334,5 @@ export class HttpResponse { */ readonly status: number; } + export const http: HttpClient; diff --git a/static/typedoc/preview/server-ui.d.ts b/static/typedoc/preview/server-ui.d.ts index d8d0840123..25511c830b 100644 --- a/static/typedoc/preview/server-ui.d.ts +++ b/static/typedoc/preview/server-ui.d.ts @@ -7,7 +7,6 @@ Copyright (c) Microsoft Corporation. ***************************************************************************** */ /** - * @beta * @packageDocumentation * The `@minecraft/server-ui` module contains types for * expressing simple dialog-based user experiences. @@ -37,39 +36,63 @@ * dimension.runCommand("say I like April too!"); * } * }); - * * ``` * * Manifest Details * ```json * { * "module_name": "@minecraft/server-ui", - * "version": "1.0.0-internal.1.20.0-preview.20" + * "version": "1.1.0" * } * ``` * */ +import * as minecraftcommon from '@minecraft/common'; import * as minecraftserver from '@minecraft/server'; export enum FormCancelationReason { - userBusy = 'userBusy', - userClosed = 'userClosed', + 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. + * @example actionFormAskFavoriteMonth.ts + * ```typescript + * import { Player } from '@minecraft/server'; + * import { ActionFormData, ActionFormResponse } from '@minecraft/server-ui'; + * + * function askFavoriteMonth(player: Player) { + * const form = new ActionFormData() + * .title('Months') + * .body('Choose your favorite month!') + * .button('January') + * .button('February') + * .button('March') + * .button('April') + * .button('May'); + * + * form.show(player).then((response: ActionFormResponse) => { + * if (response.selection === 3) { + * player.sendMessage('I like April too!'); + * } else { + * player.sendMessage('Nah, April is the best.'); + * } + * }); + * } + * ``` */ 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; /** @@ -77,8 +100,6 @@ export class ActionFormData { * 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; /** @@ -98,17 +119,41 @@ export class ActionFormData { * @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. + * @example actionFormAskFavoriteMonth.ts + * ```typescript + * import { Player } from '@minecraft/server'; + * import { ActionFormData, ActionFormResponse } from '@minecraft/server-ui'; + * + * function askFavoriteMonth(player: Player) { + * const form = new ActionFormData() + * .title('Months') + * .body('Choose your favorite month!') + * .button('January') + * .button('February') + * .button('March') + * .button('April') + * .button('May'); + * + * form.show(player).then((response: ActionFormResponse) => { + * if (response.selection === 3) { + * player.sendMessage('I like April too!'); + * } else { + * player.sendMessage('Nah, April is the best.'); + * } + * }); + * } + * ``` */ +// @ts-ignore Class inheritance allowed for native defined classes export class ActionFormResponse extends FormResponse { - protected constructor(); + private constructor(); /** * @remarks * Returns the index of the button that was pushed. @@ -116,11 +161,12 @@ export class ActionFormResponse extends FormResponse { */ readonly selection?: number; } + /** * Base type for a form response. */ export class FormResponse { - protected constructor(); + private constructor(); /** * @remarks * Contains additional details as to why a form was canceled. @@ -135,16 +181,42 @@ export class FormResponse { */ readonly canceled: boolean; } + /** * Builds a simple two-button modal dialog. + * @example messageFormSimple.ts + * ```typescript + * import { Player } from '@minecraft/server'; + * import { MessageFormResponse, MessageFormData } from '@minecraft/server-ui'; + * + * function showMessage(player: Player) { + * const messageForm = new MessageFormData() + * .title({ translate: 'permissions.removeplayer' }) // "Remove player" + * .body({ translate: 'accessibility.list.or.two', with: ['Player 1', 'Player 2'] }) // "Player 1 or Player 2" + * .button1('Player 1') + * .button2('Player 2'); + * + * messageForm + * .show(player) + * .then((formData: MessageFormResponse) => { + * // player canceled the form, or another dialog was up and open. + * if (formData.canceled || formData.selection === undefined) { + * return; + * } + * + * player.sendMessage(`You selected ${formData.selection === 0 ? 'Player 1' : 'Player 2'}`); + * }) + * .catch((error: Error) => { + * player.sendMessage('Failed to show form: ' + error); + * }); + * } + * ``` */ 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; /** @@ -152,8 +224,6 @@ export class MessageFormData { * 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; /** @@ -161,8 +231,6 @@ export class MessageFormData { * 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; /** @@ -182,17 +250,44 @@ export class MessageFormData { * @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. + * @example messageFormSimple.ts + * ```typescript + * import { Player } from '@minecraft/server'; + * import { MessageFormResponse, MessageFormData } from '@minecraft/server-ui'; + * + * function showMessage(player: Player) { + * const messageForm = new MessageFormData() + * .title({ translate: 'permissions.removeplayer' }) // "Remove player" + * .body({ translate: 'accessibility.list.or.two', with: ['Player 1', 'Player 2'] }) // "Player 1 or Player 2" + * .button1('Player 1') + * .button2('Player 2'); + * + * messageForm + * .show(player) + * .then((formData: MessageFormResponse) => { + * // player canceled the form, or another dialog was up and open. + * if (formData.canceled || formData.selection === undefined) { + * return; + * } + * + * player.sendMessage(`You selected ${formData.selection === 0 ? 'Player 1' : 'Player 2'}`); + * }) + * .catch((error: Error) => { + * player.sendMessage('Failed to show form: ' + error); + * }); + * } + * ``` */ +// @ts-ignore Class inheritance allowed for native defined classes export class MessageFormResponse extends FormResponse { - protected constructor(); + private constructor(); /** * @remarks * Returns the index of the button that was pushed. @@ -200,17 +295,47 @@ export class MessageFormResponse extends FormResponse { */ readonly selection?: number; } + /** * Used to create a fully customizable pop-up form for a * player. + * @example modalFormSimple.ts + * ```typescript + * import { Player } from '@minecraft/server'; + * import { ModalFormData } from '@minecraft/server-ui'; + * + * function showExampleModal(player: Player) { + * const modalForm = new ModalFormData().title('Example Modal Controls for §o§7ModalFormData§r'); + * + * modalForm.toggle('Toggle w/o default'); + * modalForm.toggle('Toggle w/ default', true); + * + * modalForm.slider('Slider w/o default', 0, 50, 5); + * modalForm.slider('Slider w/ default', 0, 50, 5, 30); + * + * modalForm.dropdown('Dropdown w/o default', ['option 1', 'option 2', 'option 3']); + * modalForm.dropdown('Dropdown w/ default', ['option 1', 'option 2', 'option 3'], 2); + * + * modalForm.textField('Input w/o default', 'type text here'); + * modalForm.textField('Input w/ default', 'type text here', 'this is default'); + * + * modalForm + * .show(player) + * .then(formData => { + * player.sendMessage(`Modal form results: ${JSON.stringify(formData.formValues, undefined, 2)}`); + * }) + * .catch((error: Error) => { + * player.sendMessage('Failed to show form: ' + error); + * return -1; + * }); + * } + * ``` */ 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, @@ -234,8 +359,6 @@ export class ModalFormData { * @remarks * Adds a numeric slider to the form. * - * This function can't be called in read-only mode. - * */ slider( label: minecraftserver.RawMessage | string, @@ -244,49 +367,82 @@ export class ModalFormData { valueStep: number, defaultValue?: number, ): ModalFormData; + /** + * @beta + */ + submitButton(submitButtonText: minecraftserver.RawMessage | string): 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, + defaultValue?: minecraftserver.RawMessage | 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. + * @example modalFormSimple.ts + * ```typescript + * import { Player } from '@minecraft/server'; + * import { ModalFormData } from '@minecraft/server-ui'; + * + * function showExampleModal(player: Player) { + * const modalForm = new ModalFormData().title('Example Modal Controls for §o§7ModalFormData§r'); + * + * modalForm.toggle('Toggle w/o default'); + * modalForm.toggle('Toggle w/ default', true); + * + * modalForm.slider('Slider w/o default', 0, 50, 5); + * modalForm.slider('Slider w/ default', 0, 50, 5, 30); + * + * modalForm.dropdown('Dropdown w/o default', ['option 1', 'option 2', 'option 3']); + * modalForm.dropdown('Dropdown w/ default', ['option 1', 'option 2', 'option 3'], 2); + * + * modalForm.textField('Input w/o default', 'type text here'); + * modalForm.textField('Input w/ default', 'type text here', 'this is default'); + * + * modalForm + * .show(player) + * .then(formData => { + * player.sendMessage(`Modal form results: ${JSON.stringify(formData.formValues, undefined, 2)}`); + * }) + * .catch((error: Error) => { + * player.sendMessage('Failed to show form: ' + error); + * return -1; + * }); + * } + * ``` */ +// @ts-ignore Class inheritance allowed for native defined classes export class ModalFormResponse extends FormResponse { - protected constructor(); + private constructor(); /** * @remarks * An ordered set of values based on the order of controls * specified by ModalFormData. * */ - readonly formValues?: any[]; + readonly formValues?: (boolean | number | string)[]; } + +// @ts-ignore Class inheritance allowed for native defined classes export class FormRejectError extends Error { - protected constructor(); + private constructor(); reason: FormRejectReason; } diff --git a/static/typedoc/preview/server.d.ts b/static/typedoc/preview/server.d.ts index 98344cfefb..f58545b56d 100644 --- a/static/typedoc/preview/server.d.ts +++ b/static/typedoc/preview/server.d.ts @@ -7,7 +7,6 @@ Copyright (c) Microsoft Corporation. ***************************************************************************** */ /** - * @beta * @packageDocumentation * Contains many types related to manipulating a Minecraft * world, including entities, blocks, dimensions, and more. @@ -16,17752 +15,17353 @@ * ```json * { * "module_name": "@minecraft/server", - * "version": "1.2.0-internal.1.20.0-preview.20" + * "version": "1.10.0" * } * ``` * */ -/** - * @beta - */ -export enum BlockVolumeIntersection { - Disjoint = 0, - Contains = 1, - Intersects = 2, -} -/** - * @beta - */ -export enum CompoundBlockVolumeAction { - Add = 0, - Subtract = 1, +import * as minecraftcommon from '@minecraft/common'; +export enum BlockComponentTypes { + Inventory = 'minecraft:inventory', + LavaContainer = 'minecraft:lavaContainer', + Piston = 'minecraft:piston', + PotionContainer = 'minecraft:potionContainer', + RecordPlayer = 'minecraft:recordPlayer', + Sign = 'minecraft:sign', + SnowContainer = 'minecraft:snowContainer', + WaterContainer = 'minecraft:waterContainer', } + /** - * @beta - * Represents a direction for expressing relative position or - * facing. + * An enumeration describing the state of a block piston. */ -export enum Direction { +export enum BlockPistonState { /** - * @beta * @remarks - * Represents an object located or facing in the down (z - 1) - * direction. + * Whether the piston is fully expanded. * */ - down = 'down', + Expanded = 'Expanded', /** - * @beta * @remarks - * Represents an object located or facing in the east (x + 1) - * direction. + * Whether the piston is in the process of expanding. * */ - east = 'east', + Expanding = 'Expanding', + /** + * @remarks + * Whether the piston is fully retracted. + * + */ + Retracted = 'Retracted', /** - * @beta * @remarks - * Represents an object located or facing in the north (z - 1) - * direction. + * Whether the piston is in the process of retracting. * */ - north = 'north', + Retracting = 'Retracting', +} + +/** + * @beta + * Description of the resulting intersection test on two + * BlockVolume objects + */ +export enum BlockVolumeIntersection { /** * @beta * @remarks - * Represents an object located or facing in the south (z + 1) - * direction. + * Volume B has no intersection points with Volume A * */ - south = 'south', + Disjoint = 0, /** * @beta * @remarks - * Represents an object located or facing in the up (z + 1) - * direction. + * Volume B resides completely inside Volume A * */ - up = 'up', + Contains = 1, /** * @beta * @remarks - * Represents an object located or facing in the west (x - 1) - * direction. + * Volume B partially intersects Volume A * */ - west = 'west', + Intersects = 2, } + /** * @beta - * An enumeration for the locations where scoreboard objectives - * can be displayed. + * The Action enum determines how the CompoundBlockVolume + * considers the associated CompoundBlockVolumeItem when + * performing inside/outside calculations. */ -export enum DisplaySlotId { +export enum CompoundBlockVolumeAction { /** * @beta * @remarks - * Score for an objective is displayed below a player's - * nametag. + * The associated BlockVolume is considered a positive space, + * and any intersection tests are considered hits * */ - belowname = 'belowname', + Add = 0, /** * @beta * @remarks - * This objective and respective list of players is shown on - * the Pause menu. + * 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 * */ - list = 'list', + Subtract = 1, +} + +/** + * @beta + * An enum describing the relativity of the + * CompoundBlockVolumeItem, relative to the parent + * CompoundVolume. + */ +export enum CompoundBlockVolumePositionRelativity { /** * @beta * @remarks - * The objective is shown on the right-hand side of the screen. + * The locations within the associated BlockVolume are relative + * to the CompoundBlockVolume to which they were added * */ - sidebar = 'sidebar', -} -/** - * @beta - * All the dye types supported by scripting - */ -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 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 - */ -export enum EntityLifetimeState { - loaded = 'loaded', - unloaded = 'unloaded', -} -/** - * @beta - */ -export enum EquipmentSlot { - chest = 'chest', - feet = 'feet', - head = 'head', - legs = 'legs', - mainhand = 'mainhand', - offhand = 'offhand', + Relative = 0, + /** + * @beta + * @remarks + * The locations within the associated BlockVolume are in + * absolute world space + * + */ + Absolute = 1, } + /** * @beta - * Represents the type of fluid for use within a fluid - * containing block, like a cauldron. + * An enumeration for the various difficulty levels of + * Minecraft. */ -export enum FluidType { +export enum Difficulty { /** * @beta * @remarks - * Represents lava as a type of fluid. + * Peaceful difficulty level. * */ - lava = 'lava', + Peaceful = 0, /** * @beta * @remarks - * Represents a potion as a type of fluid. + * Easy difficulty level. * */ - potion = 'potion', + Easy = 1, /** * @beta * @remarks - * Represents powder snow as a type of fluid. + * Normal difficulty level. * */ - powderSnow = 'powderSnow', + Normal = 2, /** * @beta * @remarks - * Represents water as a type of fluida. + * Hard difficulty level. * */ - water = 'water', + Hard = 3, } + /** - * @beta - * Represents a game mode for the current world experience. + * A general purpose relative direction enumeration. */ -export enum GameMode { +export enum Direction { /** - * @beta * @remarks - * World is in a more locked-down experience, where blocks may - * not be manipulated. + * Returns the {@link Block} beneath (y - 1) of this item. * */ - adventure = 'adventure', + Down = 'Down', /** - * @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. + * Returns the {@link Block} to the east (x + 1) of this item. * */ - creative = 'creative', - spectator = 'spectator', + East = 'East', /** - * @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. + * Returns the {@link Block} to the east (z + 1) of this item. * */ - survival = 'survival', -} -/** - * @beta - */ -export enum ItemLockMode { - inventory = 'inventory', - none = 'none', - slot = 'slot', -} -/** - * @beta - */ -export enum MessageSourceType { - clientScript = 'clientScript', - commandBlock = 'commandBlock', - dialogueCommand = 'dialogueCommand', - entityCommand = 'entityCommand', - serverCommand = 'serverCommand', - serverScript = 'serverScript', -} -/** - * @beta - * Used for specifying a sort order for how to display an - * objective and its list of participants. - */ -export enum ObjectiveSortOrder { + North = 'North', /** - * @beta * @remarks - * Objective participant list is displayed in ascending (e.g., - * A-Z) order. + * Returns the {@link Block} to the south (z - 1) of this item. * */ - ascending = 0, + South = 'South', /** - * @beta * @remarks - * Objective participant list is displayed in descending (e.g., - * Z-A) order. + * Returns the {@link Block} above (y + 1) of this item. + * + */ + Up = 'Up', + /** + * @remarks + * Returns the {@link Block} to the west (x - 1) of this item. * */ - descending = 1, + West = 'West', } + /** - * @beta - * Contains objectives and participants for the scoreboard. + * Specifies a mechanism for displaying scores on a scoreboard. */ -export enum ScoreboardIdentityType { +export enum DisplaySlotId { /** - * @beta * @remarks - * This scoreboard participant is tied to an entity. + * Displays the score below the player's name. * */ - entity = 'entity', + BelowName = 'BelowName', /** - * @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. + * Displays the score as a list on the pause screen. * */ - fakePlayer = 'fakePlayer', + List = 'List', /** - * @beta * @remarks - * This scoreboard participant is tied to a player. + * Displays the score on the side of the player's screen. * */ - player = 'player', -} -/** - * @beta - */ -export enum TimeOfDay { - Day = 1000, - Noon = 6000, - Sunset = 12000, - Night = 13000, - Midnight = 18000, - Sunrise = 23000, + Sidebar = 'Sidebar', } + /** - * @beta - * An enumeration with the reason that a watchdog is deciding - * to terminate execution of a behavior packs' script. + * Specifies different colors for use as dye. */ -export enum WatchdogTerminateReason { +export enum DyeColor { /** - * @beta * @remarks - * Script runtime for a behavior pack is terminated due to - * non-responsiveness from script (a hang or infinite loop). + * Black dye color. * */ - hang = 'hang', + Black = 'Black', /** - * @beta * @remarks - * Script runtime for a behavior pack is terminated due to a - * stack overflow (a long, and potentially infinite) chain of - * function calls. + * Blue dye color. * */ - stackOverflow = 'stackOverflow', -} -/** - * @beta - */ -export class BeforeEvents { - protected constructor(); - readonly chatSend: ChatSendBeforeEventSignal; - readonly dataDrivenEntityTriggerEvent: DataDrivenEntityTriggerBeforeEventSignal; - readonly explosion: ExplosionBeforeEventSignal; - readonly itemDefinitionEvent: ItemDefinitionBeforeEventSignal; - readonly itemUse: ItemUseBeforeEventSignal; - readonly itemUseOn: ItemUseOnBeforeEventSignal; - readonly pistonActivate: PistonActivateBeforeEventSignal; -} -/** - * @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 { - protected constructor(); + Blue = 'Blue', /** * @remarks - * Returns the dimension that the block is within. + * Brown dye color. * */ - readonly dimension: Dimension; + Brown = 'Brown', /** - * @beta * @remarks - * Returns or sets whether this block has a liquid on it. + * Cyan dye color. * - * This property can't be edited in read-only mode. + */ + Cyan = 'Cyan', + /** + * @remarks + * Gray dye color. * */ - isWaterlogged: boolean; + Gray = 'Gray', /** * @remarks - * Coordinates of the specified block. + * Green dye color. * - * @throws This property can throw when used. */ - readonly location: Vector3; + Green = 'Green', /** * @remarks - * Additional block configuration data that describes the - * block. + * Light blue dye color. * - * @throws This property can throw when used. */ - readonly permutation: BlockPermutation; + LightBlue = 'LightBlue', /** - * @beta * @remarks - * Gets the type of block. + * Lime dye color. * - * @throws This property can throw when used. */ - readonly 'type': BlockType; + Lime = 'Lime', /** - * @beta * @remarks - * Identifier of the type of block for this block. + * Magenta dye color. * - * @throws This property can throw when used. */ - readonly typeId: string; + Magenta = 'Magenta', /** * @remarks - * X coordinate of the block. + * Orange dye color. * */ - readonly x: number; + Orange = 'Orange', /** * @remarks - * Y coordinate of the block. + * Pink dye color. * */ - readonly y: number; + Pink = 'Pink', /** * @remarks - * Z coordinate of the block. + * Purple dye color. * */ - readonly z: number; + Purple = 'Purple', /** - * @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 + * Red dye color. * - * @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, faceToPlaceOn?: Direction): boolean; + Red = 'Red', /** - * @beta * @remarks - * Gets additional configuration properties (a component) for - * specific capabilities of particular blocks - for example, an - * inventory component of a chest block. + * Silver dye color. * - * @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; + Silver = 'Silver', /** - * @beta * @remarks - * Creates a prototype item stack based on this block that can - * be used with Container/ContainerSlot APIs. + * White dye color. * - * @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. */ - getItemStack(amount?: number, withData?: boolean): ItemStack; + White = 'White', /** - * @beta * @remarks - * Returns the net redstone power of this block. + * Yellow dye color. * - * @returns - * Returns undefined if redstone power is not applicable to - * this block. - * @throws This function can throw errors. */ - getRedstonePower(): number | undefined; + Yellow = 'Yellow', +} + +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 EnchantmentSlot { + ArmorFeet = 'ArmorFeet', + ArmorHead = 'ArmorHead', + ArmorLegs = 'ArmorLegs', + ArmorTorso = 'ArmorTorso', + Axe = 'Axe', + Bow = 'Bow', + CarrotStick = 'CarrotStick', + CosmeticHead = 'CosmeticHead', + Crossbow = 'Crossbow', + Elytra = 'Elytra', + FishingRod = 'FishingRod', + Flintsteel = 'Flintsteel', + Hoe = 'Hoe', + Pickaxe = 'Pickaxe', + Shears = 'Shears', + Shield = 'Shield', + Shovel = 'Shovel', + Spear = 'Spear', + Sword = 'Sword', +} + +export enum EntityComponentTypes { + AddRider = 'minecraft:addrider', + Ageable = 'minecraft:ageable', + Breathable = 'minecraft:breathable', + CanClimb = 'minecraft:can_climb', + CanFly = 'minecraft:can_fly', + CanPowerJump = 'minecraft:can_power_jump', + Color = 'minecraft:color', + Color2 = 'minecraft:color2', + Equippable = 'minecraft:equippable', + FireImmune = 'minecraft:fire_immune', + FloatsInLiquid = 'minecraft:floats_in_liquid', + FlyingSpeed = 'minecraft:flying_speed', + FrictionModifier = 'minecraft:friction_modifier', + GroundOffset = 'minecraft:ground_offset', + Healable = 'minecraft:healable', + Health = 'minecraft:health', + Inventory = 'minecraft:inventory', + IsBaby = 'minecraft:is_baby', + IsCharged = 'minecraft:is_charged', + IsChested = 'minecraft:is_chested', + IsDyeable = 'minecraft:is_dyeable', + IsHiddenWhenInvisible = 'minecraft:is_hidden_when_invisible', + IsIgnited = 'minecraft:is_ignited', + IsIllagerCaptain = 'minecraft:is_illager_captain', + IsSaddled = 'minecraft:is_saddled', + IsShaking = 'minecraft:is_shaking', + IsSheared = 'minecraft:is_sheared', + IsStackable = 'minecraft:is_stackable', + IsStunned = 'minecraft:is_stunned', + IsTamed = 'minecraft:is_tamed', + Item = 'minecraft:item', + LavaMovement = 'minecraft:lava_movement', + Leashable = 'minecraft:leashable', + MarkVariant = 'minecraft:mark_variant', + Movement = 'minecraft:movement', + MovementAmphibious = 'minecraft:movement.amphibious', + MovementBasic = 'minecraft:movement.basic', + MovementFly = 'minecraft:movement.fly', + MovementGeneric = 'minecraft:movement.generic', + MovementGlide = 'minecraft:movement.glide', + MovementHover = 'minecraft:movement.hover', + MovementJump = 'minecraft:movement.jump', + MovementSkip = 'minecraft:movement.skip', + MovementSway = 'minecraft:movement.sway', + NavigationClimb = 'minecraft:navigation.climb', + NavigationFloat = 'minecraft:navigation.float', + NavigationFly = 'minecraft:navigation.fly', + NavigationGeneric = 'minecraft:navigation.generic', + NavigationHover = 'minecraft:navigation.hover', + NavigationWalk = 'minecraft:navigation.walk', + Npc = 'minecraft:npc', + OnFire = 'minecraft:onfire', + Projectile = 'minecraft:projectile', + PushThrough = 'minecraft:push_through', + Rideable = 'minecraft:rideable', + Riding = 'minecraft:riding', + Scale = 'minecraft:scale', + SkinId = 'minecraft:skin_id', + Strength = 'minecraft:strength', + Tameable = 'minecraft:tameable', + TameMount = 'minecraft:tamemount', + TypeFamily = 'minecraft:type_family', + UnderwaterMovement = 'minecraft:underwater_movement', + Variant = 'minecraft:variant', + WantsJockey = 'minecraft:wants_jockey', +} + +/** + * Describes the source of damage from an Entity. + */ +export enum EntityDamageCause { /** - * @beta * @remarks - * Returns a set of tags for a block. + * Damage caused by a falling anvil. * - * @returns - * The list of tags that the block has. - * @throws This function can throw errors. */ - getTags(): string[]; + anvil = 'anvil', /** - * @beta * @remarks - * Checks to see if the permutation of this block has a - * specific tag. + * Damage caused from a non-Entity explosion. For example, an + * exploding bed. * - * @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"; + */ + blockExplosion = 'blockExplosion', + campfire = 'campfire', + /** + * @remarks + * Unused. * - * // Fetch the block - * const block = world.getDimension("overworld").getBlock({ x: 1, y: 2, z: 3 }); + */ + charging = 'charging', + /** + * @remarks + * Damage caused by physically touching an Entity or Block. For + * example, touching a Sweet Berry bush or Pufferfish. * - * console.log(`Block is dirt: ${block.hasTag("dirt")}`); - * console.log(`Block is wood: ${block.hasTag("wood")}`); - * console.log(`Block is stone: ${block.hasTag("stone")}`); + */ + contact = 'contact', + /** + * @remarks + * Damage caused by an Entity being out of air and inside a + * liquid block. * - * ``` */ - hasTag(tag: string): boolean; + drowning = 'drowning', /** - * @beta * @remarks - * Returns true if this block is an air block (i.e., empty - * space). + * Damage caused by an Entity attack. * - * @throws This function can throw errors. */ - isAir(): boolean; + entityAttack = 'entityAttack', /** - * @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). + * Damage caused by an Entity explosion. For example, a Creeper + * or Wither. * - * @throws This function can throw errors. */ - isLiquid(): boolean; + entityExplosion = 'entityExplosion', /** - * @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). + * Damage caused by falling onto the ground. * - * @throws This function can throw errors. */ - isSolid(): boolean; + fall = 'fall', /** * @remarks - * Sets the block in the dimension to the state of the - * permutation. + * Damage caused by falling blocks. Note: Anvils and + * Stalactites have their own damage causes. * - * This function can't be called in read-only mode. + */ + fallingBlock = 'fallingBlock', + /** + * @remarks + * Damage caused by catching on fire. * - * @param permutation - * Permutation that contains a set of property states for the - * Block. - * @throws This function can throw errors. */ - setPermutation(permutation: BlockPermutation): void; + fire = 'fire', /** - * @beta * @remarks - * Sets the type of block. + * Damage caused by burning over time. * - * This function can't be called in read-only mode. + */ + fireTick = 'fireTick', + /** + * @remarks + * Damage caused by fireworks. * - * @param blockType - * Identifier of the type of block to apply - for example, - * minecraft:powered_repeater. - * @throws This function can throw errors. */ - setType(blockType: BlockType): void; + fireworks = 'fireworks', /** - * @beta * @remarks - * Tries to set the block in the dimension to the state of the - * permutation by first checking if the placement is valid. + * Damage caused by flying into a wall at high speed while + * gliding with Elytra. * - * This function can't be called in read-only mode. + */ + flyIntoWall = 'flyIntoWall', + /** + * @remarks + * Damage caused by staying inside a Powder Snow block. * - * @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 { + freezing = 'freezing', /** * @remarks - * X size (west to east) component of this block area. + * Damage caused by touching a Lava block. * */ - x: number; + lava = 'lava', /** * @remarks - * Y size (down to up) of this block area size. + * Damage caused by being struck by lightning. * */ - y: number; + lightning = 'lightning', /** * @remarks - * Z size (south to north) of this block area size. + * Damage caused by magical attacks. For example, Evoker Fang + * or Conduit Block. * */ - z: number; + magic = 'magic', /** * @remarks - * Creates a new BlockAreaSize object. + * Damage caused by touching a Magma block. * */ - constructor(x: number, y: number, z: number); + magma = 'magma', /** * @remarks - * Tests whether this block area size is equal to another - * BlockAreaSize object. + * Damage caused by no source. For example, from a command or + * script. * */ - equals(other: BlockAreaSize): boolean; -} -/** - * @beta - * Contains information regarding an event where a player - * breaks a block. - */ -export class BlockBreakAfterEvent extends BlockEvent { - protected constructor(); + none = 'none', /** * @remarks - * Returns permutation information about this block before it - * was broken. + * Damage caused by an indirect source. For example, setting a + * mob's health to 0 in a behavior pack. * */ - readonly brokenBlockPermutation: BlockPermutation; + override = 'override', /** * @remarks - * Player that broke the block for this event. + * Damage caused by a Piston. * */ - readonly player: Player; -} -/** - * @beta - * Manages callbacks that are connected to when a block is - * broken. - */ -export class BlockBreakAfterEventSignal_deprecated extends IBlockBreakAfterEventSignal { - protected constructor(); -} -/** - * @beta - * Base type for components associated with blocks. - */ -export class BlockComponent extends Component { - protected constructor(); + piston = 'piston', /** * @remarks - * Block instance that this component pertains to. + * Damage caused by a projectile. * */ - readonly block: Block; -} -/** - * @beta - * Contains information regarding an event that impacts a - * specific block. - */ -export class BlockEvent { - protected constructor(); + projectile = 'projectile', + ramAttack = 'ramAttack', + selfDestruct = 'selfDestruct', + sonicBoom = 'sonicBoom', + soulCampfire = 'soulCampfire', /** * @remarks - * Block impacted by this event. + * Damage caused by a falling Stalactite block. * */ - readonly block: Block; + stalactite = 'stalactite', /** * @remarks - * Dimension that contains the block that is the subject of - * this event. + * Damage caused by touching a Stalagmite block. * */ - readonly dimension: Dimension; -} -/** - * @beta - * Contains information regarding an explosion that has - * occurred for a specific block. - */ -export class BlockExplodeAfterEvent extends BlockEvent { - protected constructor(); + stalagmite = 'stalagmite', /** * @remarks - * Optional source of the explosion. + * Damage caused over time by having an empty hunger bar. * */ - readonly source: Entity; -} -/** - * @beta - * Manages callbacks that are connected to when an explosion - * occurs, as it impacts individual blocks. - */ -export class BlockExplodeAfterEventSignal_deprecated extends IBlockExplodeAfterEventSignal { - protected constructor(); -} -/** - * @beta - * Represents the inventory of a block in the world. Used with - * blocks like chests. - */ -export class BlockInventoryComponent extends BlockComponent { - protected constructor(); + starve = 'starve', /** * @remarks - * The container which holds an {@link ItemStack}. + * Damage caused by an Entity being out of air and inside a + * non-liquid block. * - * @throws This property can throw when used. */ - readonly container: Container; + suffocation = 'suffocation', /** * @remarks - * Identifier of this component. Should always be - * minecraft:inventory. + * Damage caused by an Entity killing itself. For example, from + * the /kill command. * */ - static readonly componentId = 'minecraft:inventory'; -} -/** - * @beta - * Represents a fluid container block that currently contains - * lava. - */ -export class BlockLavaContainerComponent extends BlockLiquidContainerComponent { - protected constructor(); + suicide = 'suicide', /** * @remarks - * Identifier of this component. Should always be - * minecraft:lavaContainer. + * Damage caused by an Entity being in an inhabitable climate. + * For example, a Snow Golem in a biome with a temperature + * greater than 1. * */ - static readonly componentId = 'minecraft:lavaContainer'; -} -/** - * @beta - */ -export class BlockLiquidContainerComponent extends BlockComponent { - protected constructor(); + temperature = 'temperature', /** * @remarks - * This property can't be edited in read-only mode. + * Damage caused by the Thorns armor enchantment and by the + * Guardian thorns effect. * */ - fillLevel: number; -} -/** - * @beta - */ -export class BlockLocationIterator implements Iterable { - protected constructor(); + thorns = 'thorns', /** * @remarks - * This function can't be called in read-only mode. + * Damage caused over time by falling into the void. * */ - [Symbol.iterator](): Iterator; + 'void' = 'void', /** * @remarks - * This function can't be called in read-only mode. + * Damage caused by the Wither effect. For example, from + * touching a Wither Rose. * */ - next(): IteratorResult; + wither = 'wither', } + /** - * @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}). This type was introduced as of version 1.17.10.21. + * An enumeration describing initialization cause of an entity. */ -export class BlockPermutation { - protected constructor(); +export enum EntityInitializationCause { /** - * @beta * @remarks - * The {@link BlockType} that the permutation has. + * 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. * */ - readonly 'type': BlockType; + Born = 'Born', /** - * @beta * @remarks - * Creates a copy of this permutation. + * Case when an entity is created by an event, e.g., a + * Wandering trader spawning llamas. * - * @returns - * A copy of the permutation. */ - clone(): BlockPermutation; + Event = 'Event', /** - * @beta + * @remarks + * Case when an entity is loaded into the world. + * */ - getAllProperties(): Record; + Loaded = 'Loaded', /** - * @beta * @remarks - * Retrieves a prototype item stack based on this block - * permutation that can be used with item - * Container/ContainerSlot APIs. + * Case when an entity is naturally spawned in the world. * - * @param amount - * Number of instances of this block to place in the prototype - * item stack. - */ - getItemStack(amount?: number): ItemStack; - /** - * @beta */ - getProperty(propertyName: string): boolean | number | string | undefined; + Spawned = 'Spawned', /** - * @beta * @remarks - * Creates a copy of the permutation. + * Case when an entity is transformed into another entity. * */ - getTags(): string[]; + 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 - * 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(); + * Corresponding object is loaded. * - * 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; + Loaded = 'Loaded', /** + * @beta * @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. + * 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. * - * @param blockName - * An optional set of states to compare against. */ - matches(blockName: string, properties?: Record): boolean; + Unloaded = 'Unloaded', +} + +/** + * The equipment slot of the mob. This includes armor, offhand + * and mainhand slots. + */ +export enum EquipmentSlot { /** - * @beta * @remarks - * Returns a derived BlockPermutation with a specific property - * set. + * The chest slot. This slot is used to hold items such as + * Chestplate or Elytra. * - * @param name - * Identifier of the block property. - * @param value - * Value of the block property. - * @throws This function can throw errors. */ - withProperty(name: string, value: boolean | number | string): BlockPermutation; + Chest = 'Chest', /** * @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) + * The feet slot. This slot is used to hold items such as + * Boots. * - * @param blockName - * Identifier of the block to check. - * @param properties - * Optional additional set of properties to check against. - * @throws This function can throw errors. */ - static resolve(blockName: string, properties?: Record): BlockPermutation; -} -/** - * @beta - * When present, this block has piston-like behavior. Contains - * additional properties for discovering block piston state. - */ -export class BlockPistonComponent extends BlockComponent { - protected constructor(); + Feet = 'Feet', /** * @remarks - * Whether the piston is fully expanded. + * The head slot. This slot is used to hold items such as + * Helmets or Carved Pumpkins. * - * @throws This property can throw when used. */ - readonly isExpanded: boolean; + Head = 'Head', /** * @remarks - * Whether the piston is in the process of expanding. + * The legs slot. This slot is used to hold items such as + * Leggings. * - * @throws This property can throw when used. */ - readonly isExpanding: boolean; + Legs = 'Legs', /** * @remarks - * Whether the piston is in the process of expanding or - * retracting. + * The mainhand slot. For players, the mainhand slot refers to + * the currently active hotbar slot. * - * @throws This property can throw when used. */ - readonly isMoving: boolean; + Mainhand = 'Mainhand', /** * @remarks - * Whether the piston is fully retracted. + * The offhand slot. This slot is used to hold items such as + * shields and maps. * - * @throws This property can throw when used. */ - readonly isRetracted: boolean; + Offhand = 'Offhand', +} + +/** + * Represents the type of fluid for use within a fluid + * containing block, like a cauldron. + */ +export enum FluidType { /** * @remarks - * Whether the piston is in the process of retracting. + * Represents lava as a type of fluid. * - * @throws This property can throw when used. */ - readonly isRetracting: boolean; + Lava = 'Lava', /** * @remarks - * Identifier of this component. + * Represents a potion as a type of fluid. * */ - static readonly componentId = 'minecraft:piston'; + Potion = 'Potion', /** * @remarks - * Retrieves a set of blocks that this piston is connected - * with. + * Represents powder snow as a type of fluid. * - * @throws This function can throw errors. */ - getAttachedBlocks(): Vector3[]; -} -/** - * @beta - * Contains information regarding an event where a player - * places a block. - */ -export class BlockPlaceAfterEvent extends BlockEvent { - protected constructor(); + PowderSnow = 'PowderSnow', /** * @remarks - * Player that placed the block for this event. + * Represents water as a type of fluida. * */ - readonly player: Player; -} -/** - * @beta - * Manages callbacks that are connected to when a block is - * placed. - */ -export class BlockPlaceAfterEventSignal_deprecated extends IBlockPlaceAfterEventSignal { - protected constructor(); + Water = 'Water', } + /** - * @beta - * Represents a fluid container block that currently contains a - * potion. + * Represents a game mode for the current world experience. */ -export class BlockPotionContainerComponent extends BlockLiquidContainerComponent { - protected constructor(); +export enum GameMode { /** * @remarks - * Identifier of this component. Should always be - * minecraft:potionContainer. + * World is in a more locked-down experience, where blocks may + * not be manipulated. * */ - static readonly componentId = 'minecraft:potionContainer'; + adventure = 'adventure', /** * @remarks - * Sets the potion type based on an item stack. - * - * This function can't be called in read-only mode. + * 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. * - * @throws This function can throw errors. */ - setPotionType(itemStack: ItemStack): void; -} -/** - * @beta - */ -export class BlockProperties { - protected constructor(); + creative = 'creative', /** * @remarks - * Retrieves a specific block property instance. + * 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. * */ - static get(propertyName: string): BlockPropertyType; + spectator = 'spectator', /** * @remarks - * Retrieves a set of all available block properties. + * 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. * */ - static getAll(): BlockPropertyType[]; -} -/** - * @beta - */ -export class BlockProperty { - protected constructor(); - readonly name: string; -} -/** - * @beta - */ -export class BlockPropertyType { - protected constructor(); - readonly id: string; - readonly validValues: (boolean | number | string)[]; + survival = 'survival', } + /** * @beta - * Represents a block that can play a record. */ -export class BlockRecordPlayerComponent extends BlockComponent { - protected constructor(); +export enum GameRule { /** + * @beta * @remarks - * Identifier of this component. Should always be - * minecraft:recordPlayer. + * Whether command blocks should notify admins when they + * perform commands. * */ - static readonly componentId = 'minecraft:recordPlayer'; + CommandBlockOutput = 'commandBlockOutput', /** + * @beta * @remarks - * Clears the currently playing record of this record-playing - * block. - * - * This function can't be called in read-only mode. + * Controls whether command blocks can execute commands. * - * @throws This function can throw errors. */ - clearRecord(): void; + CommandBlocksEnabled = 'commandBlocksEnabled', /** + * @beta * @remarks - * Returns true if the record-playing block is currently - * playing a record. + * Controls whether the day and night cycles progress. * - * @throws This function can throw errors. */ - isPlaying(): boolean; + DoDayLightCycle = 'doDayLightCycle', /** + * @beta * @remarks - * Sets and plays a record based on an item type. - * - * This function can't be called in read-only mode. + * Controls whether non-mob entities do drops. ie. Item Frame * - * @throws This function can throw errors. */ - setRecord(recordItemType: ItemType): void; -} -/** - * @beta - * Represents a block that can display text on it. - */ -export class BlockSignComponent extends BlockComponent { - protected constructor(); + DoEntityDrops = 'doEntityDrops', /** + * @beta * @remarks - * Identifier of this component. Should always be - * minecraft:sign. + * Controls whether fire spreads. * */ - static readonly componentId = 'minecraft:sign'; + DoFireTick = 'doFireTick', /** + * @beta * @remarks - * Returns the RawText of the sign if `setText` was called with - * a RawMessage or a RawText object + * Controls whether players immediately respawn or are shown + * the death screen. * - * @throws This function can throw errors. */ - getRawText(): RawText | undefined; + DoImmediateRespawn = 'doImmediateRespawn', /** + * @beta * @remarks - * Returns the text of the sign if `setText` was called with a - * string + * Controls whether players deal with the effects of not + * sleeping (such as Phantom spawning). * - * @throws This function can throw errors. */ - getText(): string | undefined; + DoInsomnia = 'doInsomnia', /** + * @beta * @remarks - * Gets the dye that is on the text or undefined if the sign - * has not been dyed + * Determines whether players should be able to craft only + * those recipes that they've unlocked first - when + * dolimitedcrafting is set to true. * - * @throws This function can throw errors. */ - getTextDyeColor(): DyeColor | undefined; + DoLimitedCrafting = 'doLimitedCrafting', /** + * @beta * @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. - * @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); + * Controls whether mobs drop loot. * - * // 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): void; + DoMobLoot = 'doMobLoot', /** + * @beta * @remarks - * Sets the dye color of the text - * - * This function can't be called in read-only mode. + * Controls whether mobs spawn naturally in the world. * - * @param color - * The dye color you want or undefined if you want to clear the - * dye on the sign - * @throws This function can throw errors. */ - setTextDyeColor(color?: DyeColor): void; -} -/** - * @beta - * Represents a fluid container block that currently contains - * snow. - */ -export class BlockSnowContainerComponent extends BlockLiquidContainerComponent { - protected constructor(); + DoMobSpawning = 'doMobSpawning', /** + * @beta * @remarks - * Identifier of this component. Should always be - * minecraft:snowContainer. + * Controls whether blocks drop items when destroyed. * */ - static readonly componentId = 'minecraft:snowContainer'; -} -/** - * @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 { - protected constructor(); + DoTileDrops = 'doTileDrops', /** + * @beta * @remarks - * Represents whether this type of block can be waterlogged. + * Controls whether the weather can change naturally. * */ - readonly canBeWaterlogged: boolean; + DoWeatherCycle = 'doWeatherCycle', /** + * @beta * @remarks - * Block type name - for example, `minecraft:acacia_stairs`. + * Controls whether entities take damage from drowning. * */ - readonly id: string; -} -/** - * @beta - */ -export class BlockVolumeUtils { - protected constructor(); + DrowningDamage = 'drowningDamage', /** + * @beta * @remarks - * This function can't be called in read-only mode. + * Controls whether entities take damage from falling. * */ - static doesLocationTouchFaces(volume: BlockVolume, pos: Vector3): boolean; + FallDamage = 'fallDamage', /** + * @beta * @remarks - * This function can't be called in read-only mode. + * Controls whether entities take damage from fire. * */ - static doesVolumeTouchFaces(volume: BlockVolume, other: BlockVolume): boolean; + FireDamage = 'fireDamage', /** + * @beta * @remarks - * This function can't be called in read-only mode. + * Controls whether there is damage from freezing. * */ - static equals(volume: BlockVolume, other: BlockVolume): boolean; + FreezeDamage = 'freezeDamage', /** + * @beta * @remarks - * This function can't be called in read-only mode. + * The maximum number of commands that can be executed + * simultaneously by the /function command. * */ - static getBlockLocationIterator(volume: BlockVolume): BlockLocationIterator; + FunctionCommandLimit = 'functionCommandLimit', /** + * @beta * @remarks - * This function can't be called in read-only mode. + * Controls whether players keep their inventories when they + * die. * */ - static getBoundingBox(volume: BlockVolume): BoundingBox; + KeepInventory = 'keepInventory', /** + * @beta * @remarks - * This function can't be called in read-only mode. + * The maximum number of chained commands that can execute per + * tick. * */ - static getCapacity(volume: BlockVolume): number; + MaxCommandChainLength = 'maxCommandChainLength', /** + * @beta * @remarks - * This function can't be called in read-only mode. + * Controls whether mob griefing can happen in the world. + * Example: A Creeper explosion destroying blocks. * */ - static getMax(volume: BlockVolume): Vector3; + MobGriefing = 'mobGriefing', /** + * @beta * @remarks - * This function can't be called in read-only mode. + * Controls whether players can regenerate health. * */ - static getMin(volume: BlockVolume): Vector3; + NaturalRegeneration = 'naturalRegeneration', /** + * @beta * @remarks - * This function can't be called in read-only mode. + * The percentage of players required to be sleeping in order + * to advance to the next day. * */ - static getSpan(volume: BlockVolume): Vector3; + PlayersSleepingPercentage = 'playersSleepingPercentage', /** + * @beta * @remarks - * This function can't be called in read-only mode. + * Controls whether projectiles (entities with a projectile + * component, like Arrows, thrown Tridents or Fireworks) can + * destroy certain blocks that support this interaction (such + * as Chorus Fruit, Dripstone or Decorated Pots). Restrictions + * on which projectiles can destroy certain blocks apply. * */ - static intersects(volume: BlockVolume, other: BlockVolume): BlockVolumeIntersection; + ProjectilesCanBreakBlocks = 'projectilesCanBreakBlocks', /** + * @beta * @remarks - * This function can't be called in read-only mode. + * Controls whether players can damage each other. * */ - static isInside(volume: BlockVolume, pos: Vector3): number; + Pvp = 'pvp', /** + * @beta * @remarks - * This function can't be called in read-only mode. + * Controls how frequently random ticks occur. A value of 0 or + * less will disable random ticks. The default value is 1. * */ - static translate(volume: BlockVolume, delta: Vector3): BlockVolume; -} -/** - * @beta - * Represents a fluid container block that currently contains - * water. - */ -export class BlockWaterContainerComponent extends BlockLiquidContainerComponent { - protected constructor(); + RandomTickSpeed = 'randomTickSpeed', /** + * @beta * @remarks - * Identifier of this component. Should always be - * minecraft:waterContainer. + * Controls whether built-in (vanilla) recipes automatically + * unlock as the player progresses through the game (one + * alternative to this is to use the /recipe command based on + * custom gameplay logic.) * */ - static readonly componentId = 'minecraft:waterContainer'; + RecipesUnlock = 'recipesUnlock', /** + * @beta * @remarks - * Adds an item and colors the water based on a dye item type. - * - * This function can't be called in read-only mode. + * Controls whether respawn blocks (e.g. Bed, Respawn Anchor) + * explode in other dimensions. * - * @throws This function can throw errors. */ - addDye(itemType: ItemType): void; + RespawnBlocksExplode = 'respawnBlocksExplode', /** + * @beta * @remarks - * Retrieves a custom base color used for the sign text. + * Controls whether command output is displayed to players. + * Also controls whether Command Block output is stored by + * default. * - * @returns - * Color that is used as the base color for sign text. - * @throws This function can throw errors. */ - getCustomColor(): Color; + SendCommandFeedback = 'sendCommandFeedback', /** + * @beta * @remarks - * Sets a custom base color used for the sign text. + * Controls whether Border Block effects are shown. * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. */ - setCustomColor(color: Color): void; -} -/** - * @beta - */ -export class BoundingBoxUtils { - protected constructor(); + ShowBorderEffect = 'showBorderEffect', /** + * @beta * @remarks - * This function can't be called in read-only mode. + * Controls whether player coordinates are displayed. * */ - static createValid(min: Vector3, max: Vector3): BoundingBox; + ShowCoordinates = 'showCoordinates', + ShowDaysPlayed = 'showDaysPlayed', /** + * @beta * @remarks - * This function can't be called in read-only mode. + * Controls whether death messages are displayed in chat. * */ - static dilate(box: BoundingBox, size: Vector3): BoundingBox; + ShowDeathMessages = 'showDeathMessages', /** + * @beta * @remarks - * This function can't be called in read-only mode. + * Controls whether standard player notifications for recipes + * will show. When set to false, 'player unlocked recipes' are + * no longer sent as player notifications. * */ - static equals(box: BoundingBox, other: BoundingBox): boolean; + ShowRecipeMessages = 'showRecipeMessages', /** + * @beta * @remarks - * This function can't be called in read-only mode. + * Controls whether item tags are shown. E.g. 'Can Place On', + * 'Can Destroy', item lock icons, etc. * */ - static expand(box: BoundingBox, other: BoundingBox): BoundingBox; + ShowTags = 'showTags', /** + * @beta * @remarks - * This function can't be called in read-only mode. + * The block radius from world spawn that a player is allowed + * to spawn in. Does not affect Adventure mode. The default + * value is 10 blocks. * */ - static getCenter(box: BoundingBox): Vector3; + SpawnRadius = 'spawnRadius', /** + * @beta * @remarks - * This function can't be called in read-only mode. + * Affects whether TNT blocks can be lit. * - * @throws This function can throw errors. */ - static getIntersection(box: BoundingBox, other: BoundingBox): BoundingBox; + TntExplodes = 'tntExplodes', + TntExplosionDropDecay = 'tntExplosionDropDecay', +} + +/** + * @beta + */ +export enum HudElement { + PaperDoll = 0, + Armor = 1, + ToolTips = 2, + TouchControls = 3, + Crosshair = 4, + Hotbar = 5, + Health = 6, + ProgressBar = 7, + Hunger = 8, + AirBubbles = 9, + HorseHealth = 10, + StatusEffects = 11, + ItemText = 12, +} + +/** + * @beta + */ +export enum HudVisibility { + Hide = 0, + Reset = 1, +} + +/** + * @beta + */ +export enum InputPermissionCategory { /** + * @beta * @remarks - * This function can't be called in read-only mode. + * Player input relating to camera movement. * */ - static getSpan(box: BoundingBox): Vector3; + Camera = 1, /** + * @beta * @remarks - * This function can't be called in read-only mode. + * Player input relating to movement. * */ - static intersects(box: BoundingBox, other: BoundingBox): boolean; + Movement = 2, +} + +/** + * The types of item components that are accessible via + * function ItemStack.getComponent. + */ +export enum ItemComponentTypes { /** * @remarks - * This function can't be called in read-only mode. + * The minecraft:cooldown component. * */ - static isInside(box: BoundingBox, pos: Vector3): boolean; + Cooldown = 'minecraft:cooldown', /** * @remarks - * This function can't be called in read-only mode. + * The minecraft:durability component. * */ - static isValid(box: BoundingBox): boolean; + Durability = 'minecraft:durability', /** * @remarks - * This function can't be called in read-only mode. + * The minecraft:enchantable component. * */ - static translate(box: BoundingBox, delta: Vector3): BoundingBox; -} -/** - * @beta - * Contains information related to changes to a button push. - */ -export class ButtonPushAfterEvent extends BlockEvent { - protected constructor(); + Enchantable = 'minecraft:enchantable', /** * @remarks - * Optional source that triggered the button push. + * The minecraft:food component. * */ - readonly source: Entity; -} -/** - * @beta - * Manages callbacks that are connected to when a button is - * pushed. - */ -export class ButtonPushAfterEventSignal_deprecated extends IButtonPushAfterEventSignal { - protected constructor(); + Food = 'minecraft:food', } + /** - * @beta - * An event that fires as players enter chat messages. + * Describes how an an item can be moved within a container. */ -export class ChatSendAfterEvent { - protected constructor(); +export enum ItemLockMode { /** * @remarks - * Message that is being broadcast. In a beforeChat event - * handler, _message_ can be updated with edits before the - * message is displayed to players. + * The item cannot be dropped or crafted with. * */ - message: string; + inventory = 'inventory', /** * @remarks - * Player that sent the chat message. + * The item has no container restrictions. * */ - sender: Player; + none = 'none', /** * @remarks - * If true, this message is directly targeted to one or more - * players (i.e., is not broadcast.) + * The item cannot be moved from its slot, dropped or crafted + * with. * */ - sendToTargets: boolean; - getTargets(): Player[]; -} -/** - * @beta - * Manages callbacks that are connected to chat messages being - * sent. - */ -export class ChatSendAfterEventSignal_deprecated extends IChatSendAfterEventSignal { - protected constructor(); + slot = 'slot', } + /** - * @beta - * An event that fires as players enter chat messages. + * Enum containing the different phases of the moon based on + * the current day.,Obtain the current MoonPhase using + * world.getMoonPhase. + * + * The fullness of the moon controls various mob behaviors such + * as the number of slimes that spawn in Swamp biomes, the + * chance skeletons and zombies have to spawn with armor, as + * well as the chance for spiders to spawn with certain status + * effects. */ -export class ChatSendBeforeEvent extends ChatSendAfterEvent { - protected constructor(); +export enum MoonPhase { /** * @remarks - * If set to true in a beforeChat event handler, this message - * is not broadcast out. + * The brightest moon phase. During this phase, cats have a 50% + * chance of spawning as black cats. * */ - cancel: boolean; - setTargets(players: Player[]): void; -} -/** - * @beta - * Manages callbacks that are connected to an event that fires - * before chat messages are sent. - */ -export class ChatSendBeforeEventSignal extends IChatSendBeforeEventSignal { - protected constructor(); -} -/** - * Contains return data on the result of a command execution. - */ -export class CommandResult { - protected constructor(); + FullMoon = 0, /** * @remarks - * If the command operates against a number of entities, - * blocks, or items, this returns the number of successful - * applications of this command. + * The phase following the Full Moon. * */ - readonly successCount: number; -} -/** - * @beta - */ -export class Component { - protected constructor(); - readonly typeId: string; -} -/** - * @beta - */ -export class CompoundBlockVolume { - readonly capacity: number; - readonly volumeCount: number; + WaningGibbous = 1, /** * @remarks - * This function can't be called in read-only mode. + * The phase following the Waxing Crescent. * */ - clear(): void; + FirstQuarter = 2, /** * @remarks - * This function can't be called in read-only mode. + * The phase following the Last Quarter. * */ - getBlockLocationIterator(): BlockLocationIterator; + WaningCrescent = 3, /** * @remarks - * This function can't be called in read-only mode. + * The darkest moon phase. * */ - getBoundingBox(): BoundingBox; + NewMoon = 4, /** * @remarks - * This function can't be called in read-only mode. + * The phase following the New Moon. * */ - getMax(): Vector3; + WaxingCrescent = 5, /** * @remarks - * This function can't be called in read-only mode. + * The phase following the Waning Gibbous. * */ - getMin(): Vector3; + LastQuarter = 6, /** * @remarks - * This function can't be called in read-only mode. + * The phase following the First Quarter. * */ - isInside(delta: Vector3): boolean; + WaxingGibbous = 7, +} + +/** + * Used for specifying a sort order for how to display an + * objective and its list of participants. + */ +export enum ObjectiveSortOrder { /** * @remarks - * This function can't be called in read-only mode. + * Objective participant list is displayed in ascending (e.g., + * A-Z) order. * */ - peekLastVolume(): CompoundBlockVolumeItem | undefined; + Ascending = 0, /** * @remarks - * This function can't be called in read-only mode. + * Objective participant list is displayed in descending (e.g., + * Z-A) order. * */ - popVolume(): boolean; + Descending = 1, +} + +/** + * @beta + */ +export enum PaletteColor { + White = 0, + Orange = 1, + Magenta = 2, + LightBlue = 3, + Yellow = 4, + Lime = 5, + Pink = 6, + Gray = 7, + Silver = 8, + Cyan = 9, + Purple = 10, + Blue = 11, + Brown = 12, + Green = 13, + Red = 14, + Black = 15, +} + +/** + * Contains objectives and participants for the scoreboard. + */ +export enum ScoreboardIdentityType { /** * @remarks - * This function can't be called in read-only mode. + * This scoreboard participant is tied to an entity. * */ - pushVolume(item: CompoundBlockVolumeItem): void; + Entity = 'Entity', /** * @remarks - * This function can't be called in read-only mode. + * This scoreboard participant is tied to a pseudo player + * entity - typically this is used to store scores as data or + * as abstract progress. * */ - replaceOrAddLastVolume(item: CompoundBlockVolumeItem): boolean; + FakePlayer = 'FakePlayer', /** * @remarks - * This function can't be called in read-only mode. + * This scoreboard participant is tied to a player. * */ - translate(delta: Vector3): void; + Player = 'Player', } + /** - * @beta - * Represents a container that can hold sets of items. Used - * with entities such as Players, Chest Minecarts, Llamas, and - * more. + * Describes where the script event originated from. */ -export class Container { - protected constructor(); +export enum ScriptEventSource { /** * @remarks - * Count of the slots in the container that are empty. + * The script event originated from a Block such as a Command + * Block. * - * @throws - * Throws if the container is invalid. */ - readonly emptySlotsCount: number; + Block = 'Block', /** * @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. + * The script event originated from an Entity such as a Player, + * Command Block Minecart or Animation Controller. * - * @throws - * Throws if the container is invalid. */ - readonly size: number; + Entity = 'Entity', /** * @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. + * The script event originated from an NPC dialogue. * - * 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; + NPCDialogue = 'NPCDialogue', /** * @remarks - * Clears all inventory items in the container. - * - * This function can't be called in read-only mode. + * The script event originated from the server, such as from a + * runCommand API call or a dedicated server console. * - * @throws - * Throws if the container is invalid. */ - clearAll(): void; + Server = 'Server', +} + +/** + * Represents a side of a sign. + */ +export enum SignSide { /** * @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}. + * The back of the sign. * - * @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; + Back = 'Back', /** * @remarks - * Returns a container slot. This acts as a reference to a slot - * at the given index for this container. + * The front of the sign. * - * @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; - /** - * @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; + Front = 'Front', +} + +export enum StructureAnimationMode { + Blocks = 'Blocks', + Layers = 'Layers', + None = 'None', +} + +export enum StructureMirrorAxis { + None = 'None', + X = 'X', + XZ = 'XZ', + Z = 'Z', +} + +export enum StructureRotation { + None = 'None', + Rotate180 = 'Rotate180', + Rotate270 = 'Rotate270', + Rotate90 = 'Rotate90', +} + +export enum StructureSaveMode { + Memory = 'Memory', + World = 'World', } + /** - * @beta - * Represents a slot within a broader container (e.g., entity - * inventory.) + * Provides numeric values for common periods in the Minecraft + * day. */ -export class ContainerSlot { - protected 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; - readonly isValid: 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; +export enum TimeOfDay { /** * @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. + * Sets the time to the start of the day, which is time of the + * day 1,000 (or the equivalent of 7am) in Minecraft. * - * @throws - * Throws if the slot's container is invalid. */ - readonly maxAmount: number; + Day = 1000, /** * @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. + * Sets the time to noon, which is time of the day 6,000 in + * Minecraft. * - * @throws - * Throws if the slot's container is invalid. Also throws if - * the length exceeds 255 characters. */ - nameTag?: string; + Noon = 6000, /** * @remarks - * The type of the item. + * Sets the time to sunset, which is time of the day 12,000 (or + * the equivalent of 6pm) in Minecraft. * - * @throws - * Throws if the slot's container is invalid. */ - readonly 'type': ItemType; + Sunset = 12000, /** * @remarks - * Identifier of the type of items for the stack. If a - * namespace is not specified, 'minecraft:' is assumed. - * Examples include 'wheat' or 'apple'. + * Sets the time to night, which is time of the day 13,000 (or + * the equivalent of 7:00pm) in Minecraft. * - * @throws - * Throws if the slot's container is invalid. */ - readonly typeId?: string; + Night = 13000, /** * @remarks - * Creates an exact copy of the item stack, including any - * custom data or properties. - * - * This function can't be called in read-only mode. + * Sets the time to midnight, which is time of the day 18,000 + * (or the equivalent of 12:00am) in Minecraft. * - * @throws - * Throws if the slot's container is invalid. */ - clone(): ItemStack; - getItem(): ItemStack | undefined; + Midnight = 18000, /** * @remarks - * Returns the lore value - a secondary display string - for an - * ItemStack. + * Sets the time to sunrise, which is time of the day 23,000 + * (or the equivalent of 5am) in Minecraft. * - * @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[]; - getTags(): string[]; - hasTag(tag: string): boolean; + 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 - * 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. + * Script runtime for a behavior pack is terminated due to + * non-responsiveness from script (a hang or infinite loop). * - * @throws - * Throws if the slot's container is invalid. */ - isStackableWith(itemStack: ItemStack): boolean; + Hang = 'Hang', /** + * @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. + * Script runtime for a behavior pack is terminated due to a + * stack overflow (a long, and potentially infinite) chain of + * function calls. * - * @throws - * Throws if the slot's container is invalid. Also throws if - * any of the provided block identifiers are invalid. */ - setCanDestroy(blockIdentifiers?: string[]): void; + StackOverflow = 'StackOverflow', +} + +/** + * Used to specify the type of weather condition within the + * world. + */ +export enum WeatherType { /** * @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. + * Specifies a clear weather condition. * - * @throws - * Throws if the slot's container is invalid. Also throws if - * any of the provided block identifiers are invalid. */ - setCanPlaceOn(blockIdentifiers?: string[]): void; + Clear = 'Clear', /** * @remarks - * This function can't be called in read-only mode. + * Specifies a rain weather condition. * - * @throws This function can throw errors. */ - setItem(itemStack?: ItemStack): void; + Rain = 'Rain', /** * @remarks - * Sets the lore value - a secondary display string - for an - * ItemStack. - * - * This function can't be called in read-only mode. + * Specifies a rain and thunder weather condition. * - * @throws - * Throws if the slot's container is invalid. */ - setLore(loreList?: string[]): void; + Thunder = 'Thunder', } + /** * @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 { - protected constructor(); - /** - * @remarks - * Entity that the event triggered on. - * - */ - readonly entity: Entity; - /** - * @remarks - * Name of the data driven event being triggered. - * - */ - readonly id: string; - /** - * @remarks - * 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_deprecated extends IDataDrivenEntityTriggerAfterEventSignal { - protected constructor(); -} +export type BlockComponentTypeMap = { + inventory: BlockInventoryComponent; + lavaContainer: BlockLavaContainerComponent; + 'minecraft:inventory': BlockInventoryComponent; + 'minecraft:lavaContainer': BlockLavaContainerComponent; + 'minecraft:piston': BlockPistonComponent; + 'minecraft:potionContainer': BlockPotionContainerComponent; + 'minecraft:recordPlayer': BlockRecordPlayerComponent; + 'minecraft:sign': BlockSignComponent; + 'minecraft:snowContainer': BlockSnowContainerComponent; + 'minecraft:waterContainer': BlockWaterContainerComponent; + piston: BlockPistonComponent; + potionContainer: BlockPotionContainerComponent; + recordPlayer: BlockRecordPlayerComponent; + sign: BlockSignComponent; + snowContainer: BlockSnowContainerComponent; + waterContainer: BlockWaterContainerComponent; +}; + /** * @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 { - protected 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; - getModifiers(): DefinitionModifier[]; - setModifiers(modifiers: DefinitionModifier[]): void; -} +export type EntityComponentTypeMap = { + addrider: EntityAddRiderComponent; + ageable: EntityAgeableComponent; + breathable: EntityBreathableComponent; + can_climb: EntityCanClimbComponent; + can_fly: EntityCanFlyComponent; + can_power_jump: EntityCanPowerJumpComponent; + color: EntityColorComponent; + color2: EntityColor2Component; + equippable: EntityEquippableComponent; + fire_immune: EntityFireImmuneComponent; + floats_in_liquid: EntityFloatsInLiquidComponent; + flying_speed: EntityFlyingSpeedComponent; + friction_modifier: EntityFrictionModifierComponent; + ground_offset: EntityGroundOffsetComponent; + healable: EntityHealableComponent; + health: EntityHealthComponent; + inventory: EntityInventoryComponent; + is_baby: EntityIsBabyComponent; + is_charged: EntityIsChargedComponent; + is_chested: EntityIsChestedComponent; + is_dyeable: EntityIsDyeableComponent; + is_hidden_when_invisible: EntityIsHiddenWhenInvisibleComponent; + is_ignited: EntityIsIgnitedComponent; + is_illager_captain: EntityIsIllagerCaptainComponent; + is_saddled: EntityIsSaddledComponent; + is_shaking: EntityIsShakingComponent; + is_sheared: EntityIsShearedComponent; + is_stackable: EntityIsStackableComponent; + is_stunned: EntityIsStunnedComponent; + is_tamed: EntityIsTamedComponent; + item: EntityItemComponent; + lava_movement: EntityLavaMovementComponent; + leashable: EntityLeashableComponent; + mark_variant: EntityMarkVariantComponent; + 'minecraft:addrider': EntityAddRiderComponent; + 'minecraft:ageable': EntityAgeableComponent; + 'minecraft:breathable': EntityBreathableComponent; + 'minecraft:can_climb': EntityCanClimbComponent; + 'minecraft:can_fly': EntityCanFlyComponent; + 'minecraft:can_power_jump': EntityCanPowerJumpComponent; + 'minecraft:color': EntityColorComponent; + 'minecraft:color2': EntityColor2Component; + 'minecraft:equippable': EntityEquippableComponent; + 'minecraft:fire_immune': EntityFireImmuneComponent; + 'minecraft:floats_in_liquid': EntityFloatsInLiquidComponent; + 'minecraft:flying_speed': EntityFlyingSpeedComponent; + 'minecraft:friction_modifier': EntityFrictionModifierComponent; + 'minecraft:ground_offset': EntityGroundOffsetComponent; + 'minecraft:healable': EntityHealableComponent; + 'minecraft:health': EntityHealthComponent; + 'minecraft:inventory': EntityInventoryComponent; + 'minecraft:is_baby': EntityIsBabyComponent; + 'minecraft:is_charged': EntityIsChargedComponent; + 'minecraft:is_chested': EntityIsChestedComponent; + 'minecraft:is_dyeable': EntityIsDyeableComponent; + 'minecraft:is_hidden_when_invisible': EntityIsHiddenWhenInvisibleComponent; + 'minecraft:is_ignited': EntityIsIgnitedComponent; + 'minecraft:is_illager_captain': EntityIsIllagerCaptainComponent; + 'minecraft:is_saddled': EntityIsSaddledComponent; + 'minecraft:is_shaking': EntityIsShakingComponent; + 'minecraft:is_sheared': EntityIsShearedComponent; + 'minecraft:is_stackable': EntityIsStackableComponent; + 'minecraft:is_stunned': EntityIsStunnedComponent; + 'minecraft:is_tamed': EntityIsTamedComponent; + 'minecraft:item': EntityItemComponent; + 'minecraft:lava_movement': EntityLavaMovementComponent; + 'minecraft:leashable': EntityLeashableComponent; + 'minecraft:mark_variant': EntityMarkVariantComponent; + 'minecraft:movement': EntityMovementComponent; + 'minecraft:movement.amphibious': EntityMovementAmphibiousComponent; + 'minecraft:movement.basic': EntityMovementBasicComponent; + 'minecraft:movement.fly': EntityMovementFlyComponent; + 'minecraft:movement.generic': EntityMovementGenericComponent; + 'minecraft:movement.glide': EntityMovementGlideComponent; + 'minecraft:movement.hover': EntityMovementHoverComponent; + 'minecraft:movement.jump': EntityMovementJumpComponent; + 'minecraft:movement.skip': EntityMovementSkipComponent; + 'minecraft:movement.sway': EntityMovementSwayComponent; + 'minecraft:navigation.climb': EntityNavigationClimbComponent; + 'minecraft:navigation.float': EntityNavigationFloatComponent; + 'minecraft:navigation.fly': EntityNavigationFlyComponent; + 'minecraft:navigation.generic': EntityNavigationGenericComponent; + 'minecraft:navigation.hover': EntityNavigationHoverComponent; + 'minecraft:navigation.walk': EntityNavigationWalkComponent; + 'minecraft:npc': EntityNpcComponent; + 'minecraft:onfire': EntityOnFireComponent; + 'minecraft:projectile': EntityProjectileComponent; + 'minecraft:push_through': EntityPushThroughComponent; + 'minecraft:rideable': EntityRideableComponent; + 'minecraft:riding': EntityRidingComponent; + 'minecraft:scale': EntityScaleComponent; + 'minecraft:skin_id': EntitySkinIdComponent; + 'minecraft:strength': EntityStrengthComponent; + 'minecraft:tameable': EntityTameableComponent; + 'minecraft:tamemount': EntityTameMountComponent; + 'minecraft:type_family': EntityTypeFamilyComponent; + 'minecraft:underwater_movement': EntityUnderwaterMovementComponent; + 'minecraft:variant': EntityVariantComponent; + 'minecraft:wants_jockey': EntityWantsJockeyComponent; + movement: EntityMovementComponent; + 'movement.amphibious': EntityMovementAmphibiousComponent; + 'movement.basic': EntityMovementBasicComponent; + 'movement.fly': EntityMovementFlyComponent; + 'movement.generic': EntityMovementGenericComponent; + 'movement.glide': EntityMovementGlideComponent; + 'movement.hover': EntityMovementHoverComponent; + 'movement.jump': EntityMovementJumpComponent; + 'movement.skip': EntityMovementSkipComponent; + 'movement.sway': EntityMovementSwayComponent; + 'navigation.climb': EntityNavigationClimbComponent; + 'navigation.float': EntityNavigationFloatComponent; + 'navigation.fly': EntityNavigationFlyComponent; + 'navigation.generic': EntityNavigationGenericComponent; + 'navigation.hover': EntityNavigationHoverComponent; + 'navigation.walk': EntityNavigationWalkComponent; + npc: EntityNpcComponent; + onfire: EntityOnFireComponent; + projectile: EntityProjectileComponent; + push_through: EntityPushThroughComponent; + rideable: EntityRideableComponent; + riding: EntityRidingComponent; + scale: EntityScaleComponent; + skin_id: EntitySkinIdComponent; + strength: EntityStrengthComponent; + tameable: EntityTameableComponent; + tamemount: EntityTameMountComponent; + type_family: EntityTypeFamilyComponent; + underwater_movement: EntityUnderwaterMovementComponent; + variant: EntityVariantComponent; + wants_jockey: EntityWantsJockeyComponent; +}; + /** * @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 extends IDataDrivenEntityTriggerBeforeEventSignal { - protected constructor(); -} +export type ItemComponentTypeMap = { + cooldown: ItemCooldownComponent; + durability: ItemDurabilityComponent; + enchantable: ItemEnchantableComponent; + food: ItemFoodComponent; + 'minecraft:cooldown': ItemCooldownComponent; + 'minecraft:durability': ItemDurabilityComponent; + 'minecraft:enchantable': ItemEnchantableComponent; + 'minecraft:food': ItemFoodComponent; +}; + /** * @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 { - protected constructor(); - /** - * @remarks - * Identifier of the dimension. - * - * @throws This property can throw when used. - */ - 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 - * overworld.createExplosion(targetLocation, 10, new mc.ExplosionOptions()); - * ``` - * @example createFireAndWaterExplosions.ts - * ```typescript - * const explosionLoc: mc.Vector3 = { x: targetLocation.x + 0.5, y: targetLocation.y + 0.5, z: targetLocation.z + 0.5 }; - * - * const fireExplosionOptions = new mc.ExplosionOptions(); - * - * // Explode with fire - * fireExplosionOptions.causesFire = true; - * - * overworld.createExplosion(explosionLoc, 15, fireExplosionOptions); - * const waterExplosionOptions = new mc.ExplosionOptions(); - * - * // Explode in water - * waterExplosionOptions.allowUnderwater = true; - * - * const belowWaterLoc: mc.Vector3 = { x: targetLocation.x + 3, y: targetLocation.y + 1, z: targetLocation.z + 3 }; - * - * overworld.createExplosion(belowWaterLoc, 10, waterExplosionOptions); - * - * ``` - * @example createNoBlockExplosion.ts - * ```typescript - * const explosionOptions = new mc.ExplosionOptions(); - * - * // Start by exploding without breaking blocks - * explosionOptions.breaksBlocks = false; - * - * const explodeNoBlocksLoc: mc.Vector3 = { - * x: Math.floor(targetLocation.x + 1), - * y: Math.floor(targetLocation.y + 2), - * z: Math.floor(targetLocation.z + 1), - * }; - * - * overworld.createExplosion(explodeNoBlocksLoc, 15, explosionOptions); - * - * ``` - */ - 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, options?: BlockFillOptions): number; - /** - * @beta - * @remarks - * Returns a block instance at the given location. This method - * was introduced as of version 1.17.10.21. - * - * @param location - * The location at which to return a block. - * @returns - * Block at the specified location. - * @throws This function can throw errors. - */ - getBlock(location: Vector3): Block; - /** - * @beta - * @remarks - * Gets the first block that intersects with a vector emanating - * from a location. - * - * @param options - * Additional options for processing this raycast query. - * @throws This function can throw errors. - */ - getBlockFromRay(location: Vector3, direction: Vector3, options?: BlockRaycastOptions): Block; - /** - * @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 testThatEntityIsFeatherItem.ts - * ```typescript - * const query = { - * type: "item", - * location: targetLocation, - * }; - * const items = overworld.getEntities(query); - * - * for (const item of items) { - * const itemComp = item.getComponent("item") as any; - * - * if (itemComp) { - * if (itemComp.itemStack.id.endsWith("feather")) { - * console.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. - * @throws This function can throw errors. - */ - getEntitiesFromRay(location: Vector3, direction: Vector3, options?: EntityRaycastOptions): Entity[]; - /** - * @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 - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - 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 This function can throw errors. - */ - runCommandAsync(commandString: string): Promise; - /** - * @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 - * // create a horse and trigger the 'ageable_grow_up' event, ensuring the horse is created as an adult - * overworld.spawnEntity("minecraft:horse", targetLocation); - * ``` - * @example quickFoxLazyDog.ts - * ```typescript - * 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); - * - * ``` - * @example trapTick.ts - * ```typescript - * let ticks = 0; - * - * mc.world.events.tick.subscribe((event: mc.TickEvent) => { - * ticks++; - * - * // Minecraft runs at 20 ticks per second - * if (ticks % 1200 === 0) { - * overworld.runCommand("say Another minute passes..."); - * } - * }); - * ``` - */ - 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 oneItemLoc: mc.Vector3 = { x: 3, y: 2, z: 1 }; - * const fiveItemsLoc: mc.Vector3 = { x: 1, y: 2, z: 1 }; - * const diamondPickaxeLoc: mc.Vector3 = { x: 2, y: 2, 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); - * - * overworld.spawnItem(oneEmerald, oneItemLoc); - * overworld.spawnItem(fiveEmeralds, fiveItemsLoc); - * overworld.spawnItem(onePickaxe, diamondPickaxeLoc); - * - * ``` - * @example spawnItem.ts - * ```typescript - * const featherItem = new mc.ItemStack(mc.MinecraftItemTypes.feather, 1, 0); - * - * overworld.spawnItem(featherItem, targetLocation); - * log("New feather created!"); - * ``` - */ - 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 additional, customizable variables that can be - * adjusted for this particle emitter. - * @returns - * Newly created entity at the specified location. - */ - spawnParticle(effectName: string, location: Vector3, molangVariables: MolangVariableMap): void; -} -/** - * @beta - * For block properties that take a direction, provides a - * structured way to specify the direction of a block property. - */ -export class DirectionBlockProperty extends BlockProperty { - protected constructor(); - /** - * @remarks - * Value of the block property. - * - * This property can't be edited in read-only mode. - * - */ - value: Direction; - /** - * @remarks - * Returns a set of acceptable potential values for the - * direction-based block property. - * - */ - getValidValues(): Direction[]; -} -/** - * @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): void; - /** - * @remarks - * Defines a number dynamic property. - * - * @throws This function can throw errors. - */ - defineNumber(identifier: string): void; - /** - * @remarks - * Defines a string dynamic property. - * - * @throws This function can throw errors. - */ - defineString(identifier: string, maxLength: number): void; -} -/** - * @beta - * Represents an effect - like poison - that has been added to - * an Entity. - */ -export class Effect { - protected 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. - * - * @throws This property can throw when used. - */ - readonly duration: number; -} -/** - * @beta - * Contains information related to changes to an effect - like - * poison - being added to an entity. - */ -export class EffectAddAfterEvent { - protected 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_deprecated extends IEffectAddAfterEventSignal { - protected constructor(); -} -/** - * @beta - * Represents a type of effect - like poison - that can be - * applied to an entity. - */ -export class EffectType { - protected constructor(); - /** - * @remarks - * Identifier name of this effect type. - * - * @returns - * Identifier of the effect type. - */ - getName(): string; -} -/** - * @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. - */ - constructor(enchantmentType: EnchantmentType, 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. - * - */ - getEnchantment(enchantmentType: EnchantmentType): Enchantment; - /** - * @remarks - * If this collection has an EnchantmentInstance with type, - * returns the level of the enchantment. Returns 0 if not - * present. - * - */ - hasEnchantment(enchantmentType: EnchantmentType): 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. - * - */ - removeEnchantment(enchantmentType: EnchantmentType): void; -} -/** - * @beta - * This enum represents the item slot or type that an - * enchantment can be applied to. - */ -export class EnchantmentSlot { - protected 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 { - protected constructor(); - /** - * @remarks - * The name of the enchantment type. - * - */ - readonly id: string; - /** - * @remarks - * The maximum level this type of enchantment can have. - * - */ - readonly maxLevel: number; -} -/** - * Represents the state of an entity (a mob, the player, or - * other moving objects like minecarts) in the world. - */ -export class Entity { - protected constructor(); - /** - * @beta - * @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. - * - * @throws This property can throw when used. - */ - readonly id: string; - /** - * @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 - */ - 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. - * - * @throws This property can throw when used. - */ - 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 - * Unique identifier of the type of the entity - for example, - * 'minecraft:skeleton'. - * - * @throws This property can throw when used. - */ - readonly typeId: string; - /** - * @beta - * @remarks - * Adds 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. - * @param amplifier - * Optional amplification of the effect to apply. - * @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(MinecraftEffectTypes.poison, duration, 1); - * - * - * ``` - * @example quickFoxLazyDog.ts - * ```typescript - * 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); - * - * - * ``` - */ - addEffect(effectType: EffectType, duration: number, amplifier?: number, showParticles?: boolean): 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. - * @throws This function can throw errors. - */ - 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. - * @throws This function can throw errors. - */ - 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. - * - * @throws This function can throw errors. - */ - 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. - * - * @throws This function can throw errors. - */ - 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. - */ - 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. - * @throws This function can throw errors. - */ - extinguishFire(useEffects?: boolean): boolean; - /** - * @beta - * @remarks - * Returns the first intersecting block from the direction that - * this entity is looking at. - * - * @throws This function can throw errors. - */ - getBlockFromViewDirection(options?: BlockRaycastOptions): Block; - /** - * @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. - */ - getComponent(componentId: string): EntityComponent; - /** - * @beta - * @remarks - * Returns all components that are both present on this entity - * and supported by the API. - * - */ - getComponents(): EntityComponent[]; - /** - * @beta - * @remarks - * Returns a property value. - * - * @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 | undefined; - /** - * @beta - * @remarks - * Returns the effect for the specified EffectType on the - * entity, or undefined if the effect is not present. - * - * @returns - * Effect object for the specified effect, or undefined if the - * effect is not present. - * @throws This function can throw errors. - */ - getEffect(effectType: EffectType): Effect; - /** - * @beta - * @remarks - * Returns a set of effects applied to this item. - * - * @returns - * List of effects. - * @throws This function can throw errors. - */ - getEffects(): Effect[]; - /** - * @beta - * @remarks - * Returns a potential set of entities from the direction that - * this entity is looking at. - * - * @throws This function can throw errors. - */ - getEntitiesFromViewDirection(options?: EntityRaycastOptions): Entity[]; - /** - * @beta - * @remarks - * Returns the current location of the head component of this - * entity. - * - * @throws This function can throw errors. - */ - getHeadLocation(): Vector3; - /** - * @beta - * @remarks - * Returns the current rotation component of this entity. - * - * @throws This function can throw errors. - */ - getRotation(): Vector2; - /** - * @beta - * @remarks - * Returns all tags associated with an entity. - * - * @throws This function can throw errors. - */ - getTags(): string[]; - /** - * @beta - * @remarks - * Returns the current velocity vector of the entity. - * - * @throws This function can throw errors. - */ - getVelocity(): Vector3; - /** - * @beta - * @remarks - * 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. - */ - hasComponent(componentId: string): boolean; - /** - * @beta - * @remarks - * Tests whether an entity has a particular tag. - * - * @param tag - * Identifier of the tag to test for. - * @throws This function can throw errors. - */ - hasTag(tag: string): 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. - */ - kill(): boolean; - /** - * @beta - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - playAnimation(animationName: string, options?: PlayAnimationOptions): void; - /** - * @beta - * @remarks - * Removes a specified property. - * - * @throws This function can throw errors. - */ - removeDynamicProperty(identifier: 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. - * @throws This function can throw errors. - */ - removeTag(tag: string): boolean; - /** - * @beta - * @remarks - * This function can't be called in read-only mode. - * - * @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 value - * Data value of the property to set. - * @throws This function can throw errors. - */ - setDynamicProperty(identifier: string, value: boolean | number | string): 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. - * @throws This function can throw errors. - */ - setOnFire(seconds: number, useEffects?: boolean): boolean; - /** - * @beta - * @remarks - * Sets the main rotation of the entity. - * - * This function can't be called in read-only mode. - * - * @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. - * @throws This function can throw errors. - */ - 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 This function can throw errors. - */ - triggerEvent(eventName: string): void; - /** - * @beta - * @remarks - * This function can't be called in read-only mode. - * - * @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. - */ -export class EntityAddRiderComponent extends EntityComponent { - protected 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; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:addrider. - * - */ - 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. - */ -export class EntityAgeableComponent extends EntityComponent { - protected 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; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:ageable. - * - */ - 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 - */ -export class EntityAttributeComponent extends EntityComponent { - protected constructor(); - readonly current: number; - readonly value: number; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - resetToDefaultValue(): void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - resetToMaxValue(): void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - resetToMinValue(): void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - setCurrent(value: number): boolean; -} -/** - * @beta - * Base class for a family of entity movement events. - */ -export class EntityBaseMovementComponent extends EntityComponent { - protected constructor(); - readonly maxTurn: number; -} -/** - * @beta - * Defines what blocks this entity can breathe in and gives - * them the ability to suffocate. - */ -export class EntityBreathableComponent extends EntityComponent { - protected 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; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:breathable. - * - */ - 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. - */ -export class EntityCanClimbComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:can_climb. - * - */ - 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. - */ -export class EntityCanFlyComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:can_fly. - * - */ - static readonly componentId = 'minecraft:can_fly'; -} -/** - * @beta - * When added, this component signifies that the entity can - * power jump like the horse does within Minecraft. - */ -export class EntityCanPowerJumpComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:can_power_jump. - * - */ - static readonly componentId = 'minecraft:can_power_jump'; -} -/** - * @beta - * Defines the entity's color. Only works on certain entities - * that have predefined color values (sheep, llama, shulker). - */ -export class EntityColorComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * The palette color value of the entity. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:color. - * - */ - static readonly componentId = 'minecraft:color'; -} -/** - * @beta - * Base class for downstream entity components. - */ -export class EntityComponent extends Component { - protected constructor(); -} -/** - * @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 { - protected 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 - */ -export class EntityDieAfterEvent { - protected constructor(); - readonly damageSource: EntityDamageSource; - readonly deadEntity: Entity; -} -/** - * @beta - */ -export class EntityDieAfterEventSignal_deprecated extends IEntityDieAfterEventSignal { - protected constructor(); -} -/** - * @beta - */ -export class EntityEquipmentInventoryComponent extends EntityComponent { - protected constructor(); - static readonly componentId = 'minecraft:equipment_inventory'; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - getEquipment(equipmentSlot: EquipmentSlot): ItemStack | undefined; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - getEquipmentSlot(equipmentSlot: EquipmentSlot): ContainerSlot; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - setEquipment(equipmentSlot: EquipmentSlot, itemStack?: ItemStack): void; -} -/** - * @beta - * When added, this component signifies that this entity - * doesn't take damage from fire. - */ -export class EntityFireImmuneComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:fire_immune. - * - */ - static readonly componentId = 'minecraft:fire_immune'; -} -/** - * @beta - * When added, this component signifies that this entity can - * float in liquid blocks. - */ -export class EntityFloatsInLiquidComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:floats_in_liquid. - * - */ - static readonly componentId = 'minecraft:floats_in_liquid'; -} -/** - * @beta - * Represents the flying speed of an entity. - */ -export class EntityFlyingSpeedComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Speed while flying value of the entity. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:flying_speed. - * - */ - static readonly componentId = 'minecraft:flying_speed'; -} -/** - * @beta - * Defines how much friction affects this entity. - */ -export class EntityFrictionModifierComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * The higher the number, the more the friction affects this - * entity. A value of 1.0 means regular friction, while 2.0 - * means twice as much. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:friction_modifier. - * - */ - static readonly componentId = 'minecraft:friction_modifier'; -} -/** - * @beta - * Sets the offset from the ground that the entity is actually - * at. - */ -export class EntityGroundOffsetComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * The value of the entity's offset from the terrain, in - * blocks. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:ground_offset. - * - */ - static readonly componentId = 'minecraft:ground_offset'; -} -/** - * @beta - * Defines the interactions with this entity for healing it. - */ -export class EntityHealableComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * A set of filters for when these Healable items would apply. - * - * @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; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:healable. - * - */ - static readonly componentId = 'minecraft:healable'; - /** - * @remarks - * A set of items that can specifically heal this entity. - * - * @throws This function can throw errors. - */ - getFeedItems(): FeedItem[]; -} -/** - * @beta - * Defines the health properties of an entity. - */ -export class EntityHealthComponent extends EntityAttributeComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:health. - * - */ - static readonly componentId = 'minecraft:health'; -} -/** - * @beta - * Contains information related to an entity hitting (melee - * attacking) another entity. - */ -export class EntityHitAfterEvent { - protected constructor(); - /** - * @remarks - * Entity that made a hit/melee attack. - * - */ - readonly entity: Entity; - /** - * @remarks - * Block that was hit by the attack, or undefined if the hit - * attack did not hit a block. If both hitEntity and hitBlock - * are undefined, then the entity basically swiped into the - * air. - * - */ - readonly hitBlock?: Block; - /** - * @remarks - * Entity that was hit by the attack, or undefined if the hit - * attack did not hit an entity. If both hitEntity and hitBlock - * are undefined, then the entity basically swiped into the - * air. - * - */ - readonly hitEntity?: Entity; -} -/** - * @beta - * Manages callbacks that are connected to when an entity makes - * a melee attack on another entity. - */ -export class EntityHitAfterEventSignal_deprecated extends IEntityHitAfterEventSignal { - protected constructor(); -} -/** - * @beta - * Contains information related to an entity getting hurt by - * another entity. - */ -export class EntityHurtAfterEvent { - protected 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_deprecated extends IEntityHurtAfterEventSignal { - protected constructor(); -} -/** - * @beta - * Defines this entity's inventory properties. - */ -export class EntityInventoryComponent extends EntityComponent { - protected 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; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:inventory. - * - */ - static readonly componentId = 'minecraft:inventory'; -} -/** - * @beta - * When added, this component signifies that this entity is a - * baby. - */ -export class EntityIsBabyComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:is_baby. - * - */ - static readonly componentId = 'minecraft:is_baby'; -} -/** - * @beta - * When added, this component signifies that this entity is - * charged. - */ -export class EntityIsChargedComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:is_charged. - * - */ - static readonly componentId = 'minecraft:is_charged'; -} -/** - * @beta - * When added, this component signifies that this entity is - * currently carrying a chest. - */ -export class EntityIsChestedComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:is_chested. - * - */ - static readonly componentId = 'minecraft:is_chested'; -} -/** - * @beta - * When added, this component signifies that dyes can be used - * on this entity to change its color. - */ -export class EntityIsDyableComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:is_dyeable. - * - */ - static readonly componentId = 'minecraft:is_dyeable'; -} -/** - * @beta - * When added, this component signifies that this entity can - * hide from hostile mobs while invisible. - */ -export class EntityIsHiddenWhenInvisibleComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:is_hidden_when_invisible. - * - */ - static readonly componentId = 'minecraft:is_hidden_when_invisible'; -} -/** - * @beta - * When added, this component signifies that this entity this - * currently on fire. - */ -export class EntityIsIgnitedComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:is_ignited. - * - */ - static readonly componentId = 'minecraft:is_ignited'; -} -/** - * @beta - * When added, this component signifies that this entity is an - * illager captain. - */ -export class EntityIsIllagerCaptainComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:is_illager_captain. - * - */ - static readonly componentId = 'minecraft:is_illager_captain'; -} -/** - * @beta - * When added, this component signifies that this entity is - * currently saddled. - */ -export class EntityIsSaddledComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:is_saddled. - * - */ - static readonly componentId = 'minecraft:is_saddled'; -} -/** - * @beta - * When added, this component signifies that this entity is - * currently shaking. - */ -export class EntityIsShakingComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:is_shaking. - * - */ - static readonly componentId = 'minecraft:is_shaking'; -} -/** - * @beta - * When added, this component signifies that this entity is - * currently sheared. - */ -export class EntityIsShearedComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:is_sheared. - * - */ - static readonly componentId = 'minecraft:is_sheared'; -} -/** - * @beta - * When added, this component signifies that this entity can be - * stacked. - */ -export class EntityIsStackableComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:is_stackable. - * - */ - static readonly componentId = 'minecraft:is_stackable'; -} -/** - * @beta - * When added, this component signifies that this entity is - * currently stunned. - */ -export class EntityIsStunnedComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:is_stunned. - * - */ - static readonly componentId = 'minecraft:is_stunned'; -} -/** - * @beta - * When added, this component signifies that this entity is - * currently tamed. - */ -export class EntityIsTamedComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:is_tamed. - * - */ - 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. - */ -export class EntityItemComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Item stack represented by this entity in the world. - * - * @throws This property can throw when used. - */ - readonly itemStack: ItemStack; - /** - * @remarks - * Identifier of this component. - * - */ - 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 { - protected 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. - */ -export class EntityLavaMovementComponent extends EntityAttributeComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:lava_movement. - * - */ - 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. - */ -export class EntityLeashableComponent extends EntityComponent { - protected 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; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:leashable. - * - */ - 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 - * Additional variant value. Can be used to further - * differentiate variants. - */ -export class EntityMarkVariantComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * The identifier of the variant. By convention, 0 is the - * identifier of the base entity. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:mark_variant. - * - */ - static readonly componentId = 'minecraft:mark_variant'; -} -/** - * @beta - * Contains options for taming a rideable entity based on the - * entity that mounts it. - */ -export class EntityMountTamingComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:mount_taming. - * - */ - 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. - */ -export class EntityMovementAmphibiousComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * The maximum number in degrees the mob can turn per tick. - * - * @throws This property can throw when used. - */ - readonly maxTurn: number; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:movement.amphibious. - * - */ - static readonly componentId = 'minecraft:movement.amphibious'; -} -/** - * @beta - * This component accents the movement of an entity. - */ -export class EntityMovementBasicComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * The maximum number in degrees the mob can turn per tick. - * - * @throws This property can throw when used. - */ - readonly maxTurn: number; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:movement.basic. - * - */ - static readonly componentId = 'minecraft:movement.basic'; -} -/** - * @beta - * Defines the general movement speed of this entity. - */ -export class EntityMovementComponent extends EntityAttributeComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:movement. - * - */ - static readonly componentId = 'minecraft:movement'; -} -/** - * @beta - * When added, this move control causes the mob to fly. - */ -export class EntityMovementFlyComponent extends EntityBaseMovementComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:movement.fly. - * - */ - static readonly componentId = 'minecraft:movement.fly'; -} -/** - * @beta - * When added, this move control allows a mob to fly, swim, - * climb, etc. - */ -export class EntityMovementGenericComponent extends EntityBaseMovementComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:movement.generic. - * - */ - static readonly componentId = 'minecraft:movement.generic'; -} -/** - * @beta - * When added, this movement control allows the mob to glide. - */ -export class EntityMovementGlideComponent extends EntityBaseMovementComponent { - protected 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; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:movement.glide. - * - */ - static readonly componentId = 'minecraft:movement.glide'; -} -/** - * @beta - * When added, this move control causes the mob to hover. - */ -export class EntityMovementHoverComponent extends EntityBaseMovementComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:movement.hover. - * - */ - static readonly componentId = 'minecraft:movement.hover'; -} -/** - * @beta - * Move control that causes the mob to jump as it moves with a - * specified delay between jumps. - */ -export class EntityMovementJumpComponent extends EntityBaseMovementComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:movement.jump. - * - */ - static readonly componentId = 'minecraft:movement.jump'; -} -/** - * @beta - * When added, this move control causes the mob to hop as it - * moves. - */ -export class EntityMovementSkipComponent extends EntityBaseMovementComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:movement.skip. - * - */ - 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. - */ -export class EntityMovementSwayComponent extends EntityBaseMovementComponent { - protected 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; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:movement.sway. - * - */ - static readonly componentId = 'minecraft:movement.sway'; -} -/** - * @beta - * Allows this entity to generate paths that include vertical - * walls (for example, like Minecraft spiders do.) - */ -export class EntityNavigationClimbComponent extends EntityNavigationComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:navigation.climb. - * - */ - static readonly componentId = 'minecraft:navigation.climb'; -} -/** - * @beta - * Allows this entity to generate paths that include vertical - * walls (for example, like Minecraft spiders do.) - */ -export class EntityNavigationComponent extends EntityComponent { - protected 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. - */ -export class EntityNavigationFloatComponent extends EntityNavigationComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:navigation.float. - * - */ - static readonly componentId = 'minecraft:navigation.float'; -} -/** - * @beta - * Allows this entity to generate paths in the air (for - * example, like Minecraft parrots do.) - */ -export class EntityNavigationFlyComponent extends EntityNavigationComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:navigation.fly. - * - */ - 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. - */ -export class EntityNavigationGenericComponent extends EntityNavigationComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:navigation.generic. - * - */ - 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. - */ -export class EntityNavigationHoverComponent extends EntityNavigationComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:navigation.hover. - * - */ - 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. - */ -export class EntityNavigationWalkComponent extends EntityNavigationComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:navigation.swim. - * - */ - static readonly componentId = 'minecraft:navigation.walk'; -} -/** - * @beta - * When present on an entity, this entity is on fire. - */ -export class EntityOnFireComponent extends EntityComponent { - protected 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. - */ -export class EntityPushThroughComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * The value of the entity's push-through, in blocks. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:push_through. - * - */ - static readonly componentId = 'minecraft:push_through'; -} -/** - * @beta - * When added, this component adds the capability that an - * entity can be ridden by another entity. - */ -export class EntityRideableComponent extends EntityComponent { - protected 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; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:rideable. - * - */ - 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. - */ -export class EntityRidingComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * The entity this entity is currently riding on. - * - * @throws This property can throw when used. - */ - readonly entityRidingOn: Entity; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:riding. - * - */ - static readonly componentId = 'minecraft:riding'; -} -/** - * @beta - * Sets the entity's visual size. - */ -export class EntityScaleComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * The value of the scale. 1.0 means the entity will appear at - * the scale they are defined in their model. Higher numbers - * make the entity bigger. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:scale. - * - */ - static readonly componentId = 'minecraft:scale'; -} -/** - * @beta - * Skin Id value. Can be used to differentiate skins, such as - * base skins for villagers. - */ -export class EntitySkinIdComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * The identifier of the skin. By convention, 0 is the - * identifier of the base skin. - * - * This property can't be edited in read-only mode. - * - */ - value: number; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:skin_id. - * - */ - static readonly componentId = 'minecraft:skin_id'; -} -/** - * @beta - * Contains data related to an entity spawning within the - * world. - */ -export class EntitySpawnAfterEvent { - protected constructor(); - /** - * @remarks - * Entity that was spawned. - * - * This property can't be edited in read-only mode. - * - */ - entity: Entity; -} -/** - * @beta - */ -export class EntitySpawnEventSignalAfterEventSignal_deprecated extends IEntitySpawnAfterEventSignal { - protected constructor(); -} -/** - * @beta - * Defines the entity's strength to carry items. - */ -export class EntityStrengthComponent extends EntityComponent { - protected 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 strength value of this entity, after any effects or - * component updates are applied. - * - * @throws This property can throw when used. - */ - readonly value: number; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:strength. - * - */ - static readonly componentId = 'minecraft:strength'; -} -/** - * @beta - * Defines the rules for an entity to be tamed by the player. - */ -export class EntityTameableComponent extends EntityComponent { - protected 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; - /** - * @remarks - * Event to run when this entity becomes tamed. - * - * @throws This property can throw when used. - */ - readonly tameEvent: Trigger; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:tameable. - * - */ - 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 { - protected 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 { - protected 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 { - protected 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. - */ -export class EntityUnderwaterMovementComponent extends EntityAttributeComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:underwater_movement. - * - */ - 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). - */ -export class EntityVariantComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * The identifier of the variant. By convention, 0 is the - * identifier of the base entity. - * - * @throws This property can throw when used. - */ - readonly value: number; - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:variant. - * - */ - static readonly componentId = 'minecraft:variant'; -} -/** - * @beta - * When added, this component signifies that this entity wants - * to become a jockey. - */ -export class EntityWantsJockeyComponent extends EntityComponent { - protected constructor(); - /** - * @remarks - * Identifier of this component. Should always be - * minecraft:wants_jockey. - * - */ - static readonly componentId = 'minecraft:wants_jockey'; -} -/** - * @beta - * Contains a set of events that are available across the scope - * of the World. - */ -export class Events { - protected constructor(); - /** - * @remarks - * This event fires for a block that is broken by a player. - * - */ - readonly blockBreak: BlockBreakAfterEventSignal_deprecated; - /** - * @remarks - * This event fires for each BlockLocation destroyed by an - * explosion. It is fired after the blocks have already been - * destroyed. - * - */ - readonly blockExplode: BlockExplodeAfterEventSignal_deprecated; - /** - * @remarks - * This event fires for a block that is placed by a player. - * - */ - readonly blockPlace: BlockPlaceAfterEventSignal_deprecated; - /** - * @remarks - * This event fires when a button is pushed. - * - */ - readonly buttonPush: ButtonPushAfterEventSignal_deprecated; - /** - * @remarks - * This event is triggered after a chat message has been - * broadcast or sent to players. - * - */ - readonly chatSend: ChatSendAfterEventSignal_deprecated; - /** - * @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_deprecated; - /** - * @remarks - * This event fires when an effect, like poisoning, is added to - * an entity. - * - */ - readonly effectAdd: EffectAddAfterEventSignal_deprecated; - /** - * @remarks - * This event fires when an entity dies. - * - */ - readonly entityDie: EntityDieAfterEventSignal_deprecated; - /** - * @remarks - * This event fires when an entity hits (makes a melee attack) - * and potentially impacts another entity or block. - * - */ - readonly entityHit: EntityHitAfterEventSignal_deprecated; - /** - * @remarks - * This event fires when an entity is hurt (takes damage). - * - */ - readonly entityHurt: EntityHurtAfterEventSignal_deprecated; - /** - * @remarks - * This event fires when an entity is spawned. - * - */ - readonly entitySpawn: EntitySpawnEventSignalAfterEventSignal_deprecated; - /** - * @remarks - * This event is fired after an explosion occurs. - * - */ - readonly explosion: ExplosionAfterEventSignal_deprecated; - /** - * @remarks - * This event fires when a chargeable item completes charging. - * - */ - readonly itemCompleteCharge: ItemCompleteChargeAfterEventSignal_deprecated; - /** - * @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_deprecated; - /** - * @remarks - * This event fires when a chargeable item is released from - * charging. - * - */ - readonly itemReleaseCharge: ItemReleaseChargeAfterEventSignal_deprecated; - /** - * @remarks - * This event fires when a chargeable item starts charging. - * - */ - readonly itemStartCharge: StartChargeAfterEventSignal_deprecated; - /** - * @remarks - * This event fires when any particular item is starting to be - * used by an entity or player. - * - */ - readonly itemStartUseOn: ItemStartUseOnAfterEventSignal_deprecated; - /** - * @remarks - * This event fires when a chargeable item stops charging. - * - */ - readonly itemStopCharge: ItemStopChargeAfterEventSignal_deprecated; - /** - * @remarks - * This event fires when any particular item is ending being - * used by an entity or player. - * - */ - readonly itemStopUseOn: ItemStopUseOnAfterEventSignal_deprecated; - /** - * @remarks - * This event fires when any particular item is used by an - * entity or player. - * - */ - readonly itemUse: ItemUseAfterEventSignal_deprecated; - /** - * @remarks - * This event fires when any particular item is used on a block - * by an entity or player. - * - */ - readonly itemUseOn: ItemUseOnAfterEventSignal_deprecated; - /** - * @remarks - * This event fires when a lever activates or is deactivated. - * - */ - readonly leverActivate: LeverActionAfterEventSignal_deprecated; - /** - * @remarks - * This event is an internal implementation detail, and is - * otherwise not currently functional. - * - */ - readonly messageReceive: ServerMessageAfterEventSignal_deprecated; - /** - * @remarks - * This event fires when a piston expands or retracts. - * - */ - readonly pistonActivate: PistonActivateAfterEventSignal_deprecated; - /** - * @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_deprecated; - /** - * @remarks - * This event fires when a player leaves a world. - * - */ - readonly playerLeave: PlayerLeaveAfterEventSignal_deprecated; - /** - * @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_deprecated; - /** - * @remarks - * This event fires when a projectile hits an entity or block. - * - */ - readonly projectileHit: ProjectileHitAfterEventSignal_deprecated; - /** - * @remarks - * This event will be triggered when the weather changes within - * Minecraft. - * - */ - readonly weatherChange: WeatherChangeAfterEventSignal_deprecated; - /** - * @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_deprecated; -} -/** - * @beta - * Contains information regarding an explosion that has - * happened. - */ -export class ExplosionAfterEvent { - protected constructor(); - /** - * @remarks - * Dimension where the explosion has occurred. - * - */ - readonly dimension: Dimension; - /** - * @remarks - * Optional source of the explosion. - * - */ - readonly source: Entity; - getImpactedBlocks(): Vector3[]; -} -/** - * @beta - * Manages callbacks that are connected to when an explosion - * occurs. - */ -export class ExplosionAfterEventSignal_deprecated extends IExplosionAfterEventSignal { - protected constructor(); -} -/** - * @beta - * Contains information regarding an explosion that has - * happened. - */ -export class ExplosionBeforeEvent extends ExplosionAfterEvent { - protected constructor(); - /** - * @remarks - * If set to true, cancels the explosion event. - * - */ - cancel: boolean; - setImpactedBlocks(blocks: Vector3[]): void; -} -/** - * @beta - * Manages callbacks that are connected to before an explosion - * occurs. - */ -export class ExplosionBeforeEventSignal extends IExplosionBeforeEventSignal { - protected constructor(); -} -/** - * @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 { - protected 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 { - protected 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 { - protected constructor(); -} -/** - * @beta - * Represents constants related to fluid containers. - */ -export class FluidContainer { - protected 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 - */ -export class IBlockBreakAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: BlockBreakAfterEvent) => void): (arg: BlockBreakAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: BlockBreakAfterEvent) => void): void; -} -/** - * @beta - */ -export class IBlockExplodeAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: BlockExplodeAfterEvent) => void): (arg: BlockExplodeAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: BlockExplodeAfterEvent) => void): void; -} -/** - * @beta - */ -export class IBlockPlaceAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: BlockPlaceAfterEvent) => void): (arg: BlockPlaceAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: BlockPlaceAfterEvent) => void): void; -} -/** - * @beta - */ -export class IButtonPushAfterEventSignal { - protected 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 - */ -export class IChatSendAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ChatSendAfterEvent) => void): (arg: ChatSendAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ChatSendAfterEvent) => void): void; -} -/** - * @beta - */ -export class IChatSendBeforeEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ChatSendBeforeEvent) => void): (arg: ChatSendBeforeEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ChatSendBeforeEvent) => void): void; -} -/** - * @beta - */ -export class IDataDrivenEntityTriggerAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: DataDrivenEntityTriggerAfterEvent) => void, - options?: EntityDataDrivenTriggerEventOptions, - ): (arg: DataDrivenEntityTriggerAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: DataDrivenEntityTriggerAfterEvent) => void): void; -} -/** - * @beta - */ -export class IDataDrivenEntityTriggerBeforeEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: DataDrivenEntityTriggerBeforeEvent) => void, - options?: EntityDataDrivenTriggerEventOptions, - ): (arg: DataDrivenEntityTriggerBeforeEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: DataDrivenEntityTriggerBeforeEvent) => void): void; -} -/** - * @beta - */ -export class IEffectAddAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: EffectAddAfterEvent) => void, - options?: EntityEventOptions, - ): (arg: EffectAddAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: EffectAddAfterEvent) => void): void; -} -/** - * @beta - */ -export class IEntityDieAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: EntityDieAfterEvent) => void, - options?: EntityEventOptions, - ): (arg: EntityDieAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: EntityDieAfterEvent) => void): void; -} -/** - * @beta - */ -export class IEntityHitAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: EntityHitAfterEvent) => void, - options?: EntityEventOptions, - ): (arg: EntityHitAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: EntityHitAfterEvent) => void): void; -} -/** - * @beta - */ -export class IEntityHurtAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: EntityHurtAfterEvent) => void, - options?: EntityEventOptions, - ): (arg: EntityHurtAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: EntityHurtAfterEvent) => void): void; -} -/** - * @beta - */ -export class IEntitySpawnAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: EntitySpawnAfterEvent) => void): (arg: EntitySpawnAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: EntitySpawnAfterEvent) => void): void; -} -/** - * @beta - */ -export class IExplosionAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ExplosionAfterEvent) => void): (arg: ExplosionAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ExplosionAfterEvent) => void): void; -} -/** - * @beta - */ -export class IExplosionBeforeEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ExplosionBeforeEvent) => void): (arg: ExplosionBeforeEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ExplosionBeforeEvent) => void): void; -} -/** - * @beta - */ -export class IItemCompleteChargeAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemCompleteChargeAfterEvent) => void): (arg: ItemCompleteChargeAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemCompleteChargeAfterEvent) => void): void; -} -/** - * @beta - */ -export class IItemDefinitionAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: ItemDefinitionTriggeredAfterEvent) => void, - ): (arg: ItemDefinitionTriggeredAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemDefinitionTriggeredAfterEvent) => void): void; -} -/** - * @beta - */ -export class IItemDefinitionBeforeEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: ItemDefinitionTriggeredBeforeEvent) => void, - ): (arg: ItemDefinitionTriggeredBeforeEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemDefinitionTriggeredBeforeEvent) => void): void; -} -/** - * @beta - */ -export class IItemReleaseChargeAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemReleaseChargeAfterEvent) => void): (arg: ItemReleaseChargeAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemReleaseChargeAfterEvent) => void): void; -} -/** - * @beta - */ -export class IItemStartChargeAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemStartChargeAfterEvent) => void): (arg: ItemStartChargeAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemStartChargeAfterEvent) => void): void; -} -/** - * @beta - */ -export class IItemStartUseOnAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemStartUseOnAfterEvent) => void): (arg: ItemStartUseOnAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemStartUseOnAfterEvent) => void): void; -} -/** - * @beta - */ -export class IItemStopChargeAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemStopChargeAfterEvent) => void): (arg: ItemStopChargeAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemStopChargeAfterEvent) => void): void; -} -/** - * @beta - */ -export class IItemStopUseOnAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemStopUseOnAfterEvent) => void): (arg: ItemStopUseOnAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemStopUseOnAfterEvent) => void): void; -} -/** - * @beta - */ -export class IItemUseAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemUseAfterEvent) => void): (arg: ItemUseAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemUseAfterEvent) => void): void; -} -/** - * @beta - */ -export class IItemUseBeforeEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemUseBeforeEvent) => void): (arg: ItemUseBeforeEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemUseBeforeEvent) => void): void; -} -/** - * @beta - */ -export class IItemUseOnAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemUseOnAfterEvent) => void): (arg: ItemUseOnAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemUseOnAfterEvent) => void): void; -} -/** - * @beta - */ -export class IItemUseOnBeforeEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ItemUseOnBeforeEvent) => void): (arg: ItemUseOnBeforeEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemUseOnBeforeEvent) => void): void; -} -/** - * @beta - */ -export class ILeverActionEventSignalAfterEventSignal { - protected 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 - */ -export class IPistonActivateAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: PistonActivateAfterEvent) => void): (arg: PistonActivateAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: PistonActivateAfterEvent) => void): void; -} -/** - * @beta - */ -export class IPistonActivateBeforeEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: PistonActivateBeforeEvent) => void): (arg: PistonActivateBeforeEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: PistonActivateBeforeEvent) => void): void; -} -/** - * @beta - */ -export class IPlayerJoinAfterEventSignal { - protected 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 - */ -export class IPlayerLeaveAfterEventSignal { - protected 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 - */ -export class IPlayerSpawnAfterEventSignal { - protected 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 - */ -export class IProjectileHitAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: ProjectileHitAfterEvent) => void): (arg: ProjectileHitAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ProjectileHitAfterEvent) => void): void; -} -/** - * @beta - */ -export class IScriptEventCommandMessageAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe( - callback: (arg: ScriptEventCommandMessageAfterEvent) => void, - options?: ScriptEventMessageFilterOptions, - ): (arg: ScriptEventCommandMessageAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ScriptEventCommandMessageAfterEvent) => void): void; -} -/** - * @beta - */ -export class IServerMessageAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: MessageReceiveAfterEvent) => void): (arg: MessageReceiveAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: MessageReceiveAfterEvent) => void): void; -} -/** - * @beta - * Contains information related to a chargeable item completing - * being charged. - */ -export class ItemCompleteChargeAfterEvent { - protected 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: Entity; - /** - * @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 ItemCompleteChargeAfterEventSignal_deprecated extends IItemCompleteChargeAfterEventSignal { - protected constructor(); -} -/** - * @beta - * Base class for item components. - */ -export class ItemComponent extends Component { - protected constructor(); -} -/** - * @beta - * When present on an item, this item has a cooldown effect - * when used by entities. - */ -export class ItemCooldownComponent extends ItemComponent { - protected 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; - /** - * @remarks - * Identifier of this component. Should always be - * 'minecraft:cooldown'. - * - */ - 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_deprecated extends IItemDefinitionAfterEventSignal { - protected constructor(); -} -/** - * @beta - * Manages callbacks that are connected to an item's definition - * and components changing. - */ -export class ItemDefinitionBeforeEventSignal extends IItemDefinitionBeforeEventSignal { - protected constructor(); -} -/** - * @beta - * Contains information related to a custom item having a data - * definition change being triggered. - */ -export class ItemDefinitionTriggeredAfterEvent { - protected constructor(); - /** - * @remarks - * Name of the data-driven item event that is triggering this - * change. - * - */ - readonly eventName: string; - itemStack: ItemStack; - /** - * @remarks - * Returns the source entity that triggered this item event. - * - */ - readonly source: Entity; -} -/** - * @beta - * Contains information related to a triggering of a custom - * item definition change. - */ -export class ItemDefinitionTriggeredBeforeEvent extends ItemDefinitionTriggeredAfterEvent { - protected 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. - */ -export class ItemDurabilityComponent extends ItemComponent { - protected 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; - /** - * @remarks - * Identifier of this component. Should always be - * 'minecraft:durability'. - * - */ - 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. - */ -export class ItemEnchantsComponent extends ItemComponent { - protected 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; - /** - * @remarks - * Identifier of this component. - * - */ - 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. - */ -export class ItemFoodComponent extends ItemComponent { - protected 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; - /** - * @remarks - * Identifier of this component. Should always be - * 'minecraft:food'. - * - */ - 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 ItemReleaseChargeAfterEvent { - protected 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: Entity; - /** - * @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 ItemReleaseChargeAfterEventSignal_deprecated extends IItemReleaseChargeAfterEventSignal { - protected constructor(); -} -/** - * @beta - * Represents a collection of all of the available item types - * in Minecraft. - */ -export class Items { - protected constructor(); - /** - * @remarks - * Returns an item type given an item type identifier. - * - * This function can't be called in read-only mode. - * - * @param itemId - * Type of the item to return. - */ - static get(itemId: string): ItemType; -} -/** - * @beta - * Defines a collection of items. - */ -export class ItemStack { - /** - * @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; - /** - * @remarks - * Gets or sets whether the item is kept on death. - * - * This property can't be edited in read-only mode. - * - */ - 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. - * - */ - 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; - /** - * @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 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 - * Creates an exact copy of the item stack, including any - * custom data or properties. - * - */ - clone(): ItemStack; - /** - * @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, 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 strings. If the item does not have lore, - * returns an empty array. - */ - getLore(): string[]; - 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; - 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. - * - */ - isStackableWith(itemStack: ItemStack): 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. - * - * @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; - /** - * @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. - * - * @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; - /** - * @remarks - * Sets the lore value - a secondary display string - for an - * ItemStack. - * - * This function can't be called in read-only mode. - * - * @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; - /** - * @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 ItemStartChargeAfterEvent { - protected 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: Entity; - /** - * @remarks - * Returns the time, in ticks, for the remaining duration left - * before the charge completes its cycle. - * - */ - readonly useDuration: number; -} -/** - * @beta - * Contains information related to an item being used on a - * block. - */ -export class ItemStartUseOnAfterEvent { - protected 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: Entity; -} -/** - * @beta - * Manages callbacks that are connected to an item starting - * being used on a block event. - */ -export class ItemStartUseOnAfterEventSignal_deprecated extends IItemStartUseOnAfterEventSignal { - protected constructor(); -} -/** - * @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 ItemStopChargeAfterEvent { - protected 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: Entity; - /** - * @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 ItemStopChargeAfterEventSignal_deprecated extends IItemStopChargeAfterEventSignal { - protected constructor(); -} -/** - * @beta - * Contains information related to an item that has stopped - * being used on a block. - */ -export class ItemStopUseOnAfterEvent { - protected 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: Entity; -} -/** - * @beta - * Manages callbacks that are connected to an item stops used - * on a block event. - */ -export class ItemStopUseOnAfterEventSignal_deprecated extends IItemStopUseOnAfterEventSignal { - protected constructor(); -} -/** - * @beta - * Represents the type of an item - for example, Wool. - */ -export class ItemType { - protected constructor(); - /** - * @remarks - * Returns the identifier of the item type - for example, - * 'minecraft:apple'. - * - */ - readonly id: string; -} -/** - * @beta - * An iterator over a set of available item types. - */ -export class ItemTypeIterator implements Iterable { - protected 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 - * Returns the set of item types registered within Minecraft. - */ -export class ItemTypes { - protected 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(): ItemTypeIterator; -} -/** - * @beta - * Contains information related to an item being used. - */ -export class ItemUseAfterEvent { - protected constructor(); - itemStack: ItemStack; - /** - * @remarks - * Returns the source entity that triggered this item event. - * - */ - readonly source: Entity; -} -/** - * @beta - * Manages callbacks that are connected to an item use event. - */ -export class ItemUseAfterEventSignal_deprecated extends IItemUseAfterEventSignal { - protected constructor(); -} -/** - * @beta - * Contains information related to an item being used. - */ -export class ItemUseBeforeEvent extends ItemUseAfterEvent { - protected 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 extends IItemUseBeforeEventSignal { - protected constructor(); -} -/** - * @beta - * Contains information related to an item being used on a - * block. - */ -export class ItemUseOnAfterEvent { - protected 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; - readonly itemStack: ItemStack; - /** - * @remarks - * Returns the source entity that triggered this item event. - * - */ - readonly source: Entity; -} -/** - * @beta - * Manages callbacks that are connected to an item being used - * on a block event. - */ -export class ItemUseOnAfterEventSignal_deprecated extends IItemUseOnAfterEventSignal { - protected constructor(); -} -/** - * @beta - * Contains information related to an item being used on a - * block. - */ -export class ItemUseOnBeforeEvent extends ItemUseOnAfterEvent { - protected 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 extends IItemUseOnBeforeEventSignal { - protected constructor(); -} -/** - * @beta - */ -export class IWatchdogTerminateBeforeEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: WatchdogTerminateBeforeEvent) => void): (arg: WatchdogTerminateBeforeEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: WatchdogTerminateBeforeEvent) => void): void; -} -/** - * @beta - */ -export class IWeatherChangeAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: WeatherChangeAfterEvent) => void): (arg: WeatherChangeAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: WeatherChangeAfterEvent) => void): void; -} -/** - * @beta - */ -export class IWorldInitializeAfterEventSignal { - protected constructor(); - /** - * @remarks - * This function can't be called in read-only mode. - * - */ - subscribe(callback: (arg: WorldInitializeAfterEvent) => void): (arg: WorldInitializeAfterEvent) => void; - /** - * @remarks - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: WorldInitializeAfterEvent) => void): void; -} -/** - * @beta - * Contains information related to changes to a lever - * activating or deactivating. - */ -export class LeverActionAfterEvent extends BlockEvent { - protected 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). - */ -export class LeverActionAfterEventSignal_deprecated extends ILeverActionEventSignalAfterEventSignal { - protected constructor(); -} -/** - * @beta - * A specific currently-internal event used for passing - * messages from client to server. - */ -export class MessageReceiveAfterEvent { - protected constructor(); - readonly id: string; - readonly message: string; - readonly player: Player; - readonly sourceType: MessageSourceType; -} -/** - * @beta - * Contains definitions of standard Minecraft and Minecraft - * Education Edition block types. - */ -export class MinecraftBlockTypes { - protected constructor(); - /** - * @remarks - * Represents an acacia button within Minecraft. - * - */ - static readonly acaciaButton: BlockType; - /** - * @remarks - * Represents an acacia door within Minecraft. - * - */ - static readonly acaciaDoor: BlockType; - static readonly acaciaFence: BlockType; - /** - * @remarks - * Represents an acacia fence gate within Minecraft. - * - */ - static readonly acaciaFenceGate: BlockType; - static readonly acaciaHangingSign: BlockType; - static readonly acaciaLog: BlockType; - /** - * @remarks - * Represents an acacia pressure plate within Minecraft. - * - */ - static readonly acaciaPressurePlate: BlockType; - /** - * @remarks - * Represents a set of acacia stairs within Minecraft. - * - */ - static readonly acaciaStairs: BlockType; - /** - * @remarks - * Represents an acacia standing sign within Minecraft. - * - */ - static readonly acaciaStandingSign: BlockType; - /** - * @remarks - * Represents an acacia trapdoor within Minecraft. - * - */ - static readonly acaciaTrapdoor: BlockType; - /** - * @remarks - * Represents an acacia wall sign within Minecraft. - * - */ - static readonly acaciaWallSign: BlockType; - /** - * @remarks - * Represents an activator rail within Minecraft. - * - */ - static readonly activatorRail: BlockType; - /** - * @remarks - * Represents an empty space (air) within Minecraft. - * - */ - static readonly air: BlockType; - /** - * @remarks - * Represents an allow block within Minecraft. - * - */ - static readonly allow: BlockType; - /** - * @remarks - * Represents an amethyst block within Minecraft. - * - */ - static readonly amethystBlock: BlockType; - /** - * @remarks - * Represents a cluster of amethyst within Minecraft. - * - */ - static readonly amethystCluster: BlockType; - /** - * @remarks - * Represents ancient debris within Minecraft. - * - */ - static readonly ancientDebris: BlockType; - /** - * @remarks - * Represents andesite stairs within Minecraft. - * - */ - static readonly andesiteStairs: BlockType; - /** - * @remarks - * Represents an anvil within Minecraft. - * - */ - static readonly anvil: BlockType; - /** - * @remarks - * Represents an azalea flowering plant within Minecraft. - * - */ - static readonly azalea: BlockType; - /** - * @remarks - * Represents azalea leaves within Minecraft. - * - */ - static readonly azaleaLeaves: BlockType; - /** - * @remarks - * Represents flowered azalea leaves within Minecraft. - * - */ - static readonly azaleaLeavesFlowered: BlockType; - /** - * @remarks - * Represents a bamboo tree within Minecraft. - * - */ - static readonly bamboo: BlockType; - static readonly bambooBlock: BlockType; - static readonly bambooButton: BlockType; - static readonly bambooDoor: BlockType; - static readonly bambooDoubleSlab: BlockType; - static readonly bambooFence: BlockType; - static readonly bambooFenceGate: BlockType; - static readonly bambooHangingSign: BlockType; - static readonly bambooMosaic: BlockType; - static readonly bambooMosaicDoubleSlab: BlockType; - static readonly bambooMosaicSlab: BlockType; - static readonly bambooMosaicStairs: BlockType; - static readonly bambooPlanks: BlockType; - static readonly bambooPressurePlate: BlockType; - /** - * @remarks - * Represents a bamboo sapling within Minecraft. - * - */ - static readonly bambooSapling: BlockType; - static readonly bambooSlab: BlockType; - static readonly bambooStairs: BlockType; - static readonly bambooStandingSign: BlockType; - static readonly bambooTrapdoor: BlockType; - static readonly bambooWallSign: BlockType; - /** - * @remarks - * Represents a barrel within Minecraft. - * - */ - static readonly barrel: BlockType; - /** - * @remarks - * Represents an invisible but logical barrier within - * Minecraft. - * - */ - static readonly barrier: BlockType; - /** - * @remarks - * Represents a basalt block within Minecraft. - * - */ - static readonly basalt: BlockType; - /** - * @remarks - * Represents a beacon within Minecraft. - * - */ - static readonly beacon: BlockType; - /** - * @remarks - * Represents a bed within Minecraft. - * - */ - static readonly bed: BlockType; - /** - * @remarks - * Represents a bedrock block within Minecraft. - * - */ - static readonly bedrock: BlockType; - /** - * @remarks - * Represents a beehive within Minecraft. - * - */ - static readonly beehive: BlockType; - /** - * @remarks - * Represents a bee nest within Minecraft. - * - */ - static readonly beeNest: BlockType; - /** - * @remarks - * Represents a beetroot vegetable within Minecraft. - * - */ - static readonly beetroot: BlockType; - /** - * @remarks - * Represents a bell within Minecraft. - * - */ - static readonly bell: BlockType; - /** - * @remarks - * Represents a big dripleaf plant within Minecraft. - * - */ - static readonly bigDripleaf: BlockType; - /** - * @remarks - * Represents a birch button within Minecraft. - * - */ - static readonly birchButton: BlockType; - /** - * @remarks - * Represents a birch door within Minecraft. - * - */ - static readonly birchDoor: BlockType; - static readonly birchFence: BlockType; - /** - * @remarks - * Represents a birch fence gate within Minecraft. - * - */ - static readonly birchFenceGate: BlockType; - static readonly birchHangingSign: BlockType; - static readonly birchLog: BlockType; - /** - * @remarks - * Represents a birch pressure plate within Minecraft. - * - */ - static readonly birchPressurePlate: BlockType; - /** - * @remarks - * Represents a birch stairs block within Minecraft. - * - */ - static readonly birchStairs: BlockType; - /** - * @remarks - * Represents a birch standing sign within Minecraft. - * - */ - static readonly birchStandingSign: BlockType; - /** - * @remarks - * Represents a birch trapdoor within Minecraft. - * - */ - static readonly birchTrapdoor: BlockType; - /** - * @remarks - * Represents a birch wall sign within Minecraft. - * - */ - static readonly birchWallSign: BlockType; - /** - * @remarks - * Represents a black candle within Minecraft. - * - */ - static readonly blackCandle: BlockType; - /** - * @remarks - * Represents a black candle cake within Minecraft. - * - */ - static readonly blackCandleCake: BlockType; - static readonly blackCarpet: BlockType; - /** - * @remarks - * Represents a black glazed terracotta block within Minecraft. - * - */ - static readonly blackGlazedTerracotta: BlockType; - /** - * @remarks - * Represents a blackstone block within Minecraft. - * - */ - static readonly blackstone: BlockType; - /** - * @remarks - * Represents a blackstone double slab within Minecraft. - * - */ - static readonly blackstoneDoubleSlab: BlockType; - /** - * @remarks - * Represents a blackstone slab within Minecraft. - * - */ - static readonly blackstoneSlab: BlockType; - /** - * @remarks - * Represents blackstone stairs within Minecraft. - * - */ - static readonly blackstoneStairs: BlockType; - /** - * @remarks - * Represents a blackstone wall within Minecraft. - * - */ - static readonly blackstoneWall: BlockType; - static readonly blackWool: BlockType; - /** - * @remarks - * Represents a blast furnace within Minecraft. - * - */ - static readonly blastFurnace: BlockType; - /** - * @remarks - * Represents a blue candle within Minecraft. - * - */ - static readonly blueCandle: BlockType; - /** - * @remarks - * Represents a blue candle cake within Minecraft. - * - */ - static readonly blueCandleCake: BlockType; - static readonly blueCarpet: BlockType; - /** - * @remarks - * Represents a blue glazed terracotta block within Minecraft. - * - */ - static readonly blueGlazedTerracotta: BlockType; - /** - * @remarks - * Represents a blue ice block within Minecraft. - * - */ - static readonly blueIce: BlockType; - static readonly blueWool: BlockType; - /** - * @remarks - * Represents a bone block within Minecraft. - * - */ - static readonly boneBlock: BlockType; - /** - * @remarks - * Represents an unbreakable border block within Minecraft. - * - */ - static readonly bookshelf: BlockType; - /** - * @remarks - * Represents a border block within Minecraft. - * - */ - static readonly borderBlock: BlockType; - static readonly brainCoral: BlockType; - /** - * @remarks - * Represents a brewing stand within Minecraft. - * - */ - static readonly brewingStand: BlockType; - /** - * @remarks - * Represents a block of brick within Minecraft. - * - */ - static readonly brickBlock: BlockType; - /** - * @remarks - * Represents brick stairs within Minecraft. - * - */ - static readonly brickStairs: BlockType; - /** - * @remarks - * Represents a brown candle within Minecraft. - * - */ - static readonly brownCandle: BlockType; - /** - * @remarks - * Represents a brown candle cake within Minecraft. - * - */ - static readonly brownCandleCake: BlockType; - static readonly brownCarpet: BlockType; - /** - * @remarks - * Represents a brown glazed terracotta block within Minecraft. - * - */ - static readonly brownGlazedTerracotta: BlockType; - /** - * @remarks - * Represents a brown mushroom within Minecraft. - * - */ - static readonly brownMushroom: BlockType; - /** - * @remarks - * Represents a block of brown mushroom within Minecraft. - * - */ - static readonly brownMushroomBlock: BlockType; - static readonly brownWool: BlockType; - /** - * @remarks - * Represents a column of bubbles within Minecraft. - * - */ - static readonly bubbleColumn: BlockType; - static readonly bubbleCoral: BlockType; - /** - * @remarks - * Represents a block of budding amethyst within Minecraft. - * - */ - static readonly buddingAmethyst: BlockType; - /** - * @remarks - * Represents a cactus within Minecraft. - * - */ - static readonly cactus: BlockType; - /** - * @remarks - * Represents a cake within Minecraft. - * - */ - static readonly cake: BlockType; - /** - * @remarks - * Represents a calcite block within Minecraft. - * - */ - static readonly calcite: BlockType; - static readonly calibratedSculkSensor: BlockType; - /** - * @remarks - * Represents a camera within Minecraft Education Edition. It - * is not available in Minecraft Bedrock Edition. - * - */ - static readonly camera: BlockType; - /** - * @remarks - * Represents a campfire within Minecraft. - * - */ - static readonly campfire: BlockType; - /** - * @remarks - * Represents a candle within Minecraft. - * - */ - static readonly candle: BlockType; - /** - * @remarks - * Represents a cake with candles within Minecraft. - * - */ - static readonly candleCake: BlockType; - /** - * @remarks - * Represents carrots within Minecraft. - * - */ - static readonly carrots: BlockType; - /** - * @remarks - * Represents a cartography table block within Minecraft. - * - */ - static readonly cartographyTable: BlockType; - /** - * @remarks - * Represents a carved pumpkin within Minecraft. - * - */ - static readonly carvedPumpkin: BlockType; - /** - * @remarks - * Represents a cauldron within Minecraft. - * - */ - static readonly cauldron: BlockType; - /** - * @remarks - * Represents a set of cave vines within Minecraft. - * - */ - static readonly caveVines: BlockType; - /** - * @remarks - * Represents the body of a set of cave vines with berries - * within Minecraft. - * - */ - static readonly caveVinesBodyWithBerries: BlockType; - /** - * @remarks - * Represents the head of a set of cave vines with berries - * within Minecraft. - * - */ - static readonly caveVinesHeadWithBerries: BlockType; - /** - * @remarks - * Represents a metallic chain within Minecraft. - * - */ - static readonly chain: BlockType; - /** - * @remarks - * Represents a block that gives off heat but not light, within - * Minecraft Education Edition or Bedrock Edition with - * Education features. - * - */ - static readonly chainCommandBlock: BlockType; - /** - * @remarks - * Represents a chemical heat block within Minecraft. - * - */ - static readonly chemicalHeat: BlockType; - /** - * @remarks - * Represents a chemistry table within Minecraft Education - * experiences. - * - */ - static readonly chemistryTable: BlockType; - static readonly cherryButton: BlockType; - static readonly cherryDoor: BlockType; - static readonly cherryDoubleSlab: BlockType; - static readonly cherryFence: BlockType; - static readonly cherryFenceGate: BlockType; - static readonly cherryHangingSign: BlockType; - static readonly cherryLeaves: BlockType; - static readonly cherryLog: BlockType; - static readonly cherryPlanks: BlockType; - static readonly cherryPressurePlate: BlockType; - static readonly cherrySapling: BlockType; - static readonly cherrySlab: BlockType; - static readonly cherryStairs: BlockType; - static readonly cherryStandingSign: BlockType; - static readonly cherryTrapdoor: BlockType; - static readonly cherryWallSign: BlockType; - static readonly cherryWood: BlockType; - /** - * @remarks - * Represents a chest within Minecraft. - * - */ - static readonly chest: BlockType; - static readonly chiseledBookshelf: BlockType; - /** - * @remarks - * Represents a set of chiseled deepslate within Minecraft. - * - */ - static readonly chiseledDeepslate: BlockType; - /** - * @remarks - * Represents a block of chiseled nether bricks within - * Minecraft. - * - */ - static readonly chiseledNetherBricks: BlockType; - /** - * @remarks - * Represents a block of chiseled polished blackstone within - * Minecraft. - * - */ - static readonly chiseledPolishedBlackstone: BlockType; - /** - * @remarks - * Represents a chorus flower within Minecraft. - * - */ - static readonly chorusFlower: BlockType; - /** - * @remarks - * Represents a chorus plant within Minecraft. - * - */ - static readonly chorusPlant: BlockType; - /** - * @remarks - * Represents a block of clay within Minecraft. - * - */ - static readonly clay: BlockType; - static readonly clientRequestPlaceholderBlock: BlockType; - /** - * @remarks - * Represents a block of solid coal within Minecraft. - * - */ - static readonly coalBlock: BlockType; - /** - * @remarks - * Represents a block with embedded coal ore within Minecraft. - * - */ - static readonly coalOre: BlockType; - /** - * @remarks - * Represents a block of cobbled deepslate within Minecraft. - * - */ - static readonly cobbledDeepslate: BlockType; - /** - * @remarks - * Represents a double slab of cobbled deepslate within - * Minecraft. - * - */ - static readonly cobbledDeepslateDoubleSlab: BlockType; - /** - * @remarks - * Represents a slab of deepslate within Minecraft. - * - */ - static readonly cobbledDeepslateSlab: BlockType; - /** - * @remarks - * Represents cobbled deepslate stairs within Minecraft. - * - */ - static readonly cobbledDeepslateStairs: BlockType; - /** - * @remarks - * Represents a cobbled deepslate wall within Minecraft. - * - */ - static readonly cobbledDeepslateWall: BlockType; - /** - * @remarks - * Represents a block of cobblestone within Minecraft. - * - */ - static readonly cobblestone: BlockType; - /** - * @remarks - * Represents a wall of cobblestone within Minecraft. - * - */ - static readonly cobblestoneWall: BlockType; - /** - * @remarks - * Represents a set of cocoa beans (typically on a tree) within - * Minecraft. - * - */ - static readonly cocoa: BlockType; - /** - * @remarks - * Represents blue/purple torches within Minecraft. - * - */ - static readonly coloredTorchBp: BlockType; - /** - * @remarks - * Represents red/green torches within Minecraft. - * - */ - static readonly coloredTorchRg: BlockType; - /** - * @remarks - * Represents a block that can run commands within Minecraft. - * - */ - static readonly commandBlock: BlockType; - /** - * @remarks - * Represents a composter block within Minecraft. - * - */ - static readonly composter: BlockType; - /** - * @remarks - * Represents a block of concrete powder within Minecraft. - * - */ - static readonly concrete: BlockType; - /** - * @remarks - * Represents a block of concrete powder within Minecraft. - * - */ - static readonly concretePowder: BlockType; - /** - * @remarks - * Represents a conduit block within Minecraft. - * - */ - static readonly conduit: BlockType; - /** - * @remarks - * Represents a solid block of copper within Minecraft. - * - */ - static readonly copperBlock: BlockType; - /** - * @remarks - * Represents a block with embedded copper ore within - * Minecraft. - * - */ - static readonly copperOre: BlockType; + * Describes a type of biome. + */ +export class BiomeType { + private constructor(); /** * @remarks - * Represents a solid block of coral within Minecraft. + * Identifier of the biome type. * */ - static readonly coralBlock: BlockType; + readonly id: string; +} + +/** + * @beta + * Supports a catalog of available biome types registered + * within Minecraft. + */ +export class BiomeTypes { + private constructor(); /** * @remarks - * Represents a fan formation of coral within Minecraft. + * Returns a specific biome type. * + * @param typeName + * Identifier of the biome. Generally, namespaced identifiers + * (e.g., minecraft:frozen_peaks) should be used. + * @returns + * If the biome exists, a BiomeType object is returned. If not, + * undefined is returned. */ - static readonly coralFan: BlockType; + static get(typeName: string): BiomeType | undefined; /** * @remarks - * Represents a fan formation of dead coral within Minecraft. + * Returns all registered biome types within Minecraft * */ - static readonly coralFanDead: BlockType; + static getAll(): BiomeType[]; +} + +/** + * 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 - * Represents a hanging fan formation of coral within - * Minecraft. + * Returns the dimension that the block is within. * */ - static readonly coralFanHang: BlockType; + readonly dimension: Dimension; /** * @remarks - * Represents an alternate hanging fan formation of coral (#2) - * within Minecraft. + * Returns true if this block is an air block (i.e., empty + * space). * - */ - static readonly coralFanHang2: BlockType; - /** - * @remarks - * Represents an alternate hanging fan formation of coral (#3) - * within Minecraft. + * @throws This property can throw when used. * - */ - static readonly coralFanHang3: BlockType; - /** - * @remarks - * Represents a block of cracked deepslate bricks within - * Minecraft. + * {@link LocationInUnloadedChunkError} * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly crackedDeepslateBricks: BlockType; + readonly isAir: boolean; /** * @remarks - * Represents tiles of cracked deepslate within Minecraft. + * Returns true if this block is a liquid block - (e.g., a + * water block and a lava block are liquid, while an air block + * and a stone block are not. Water logged blocks are not + * liquid blocks). * - */ - static readonly crackedDeepslateTiles: BlockType; - /** - * @remarks - * Represents a block of cracked nether bricks within - * Minecraft. + * @throws This property can throw when used. * - */ - static readonly crackedNetherBricks: BlockType; - /** - * @remarks - * Represents a block of cracked and polished blackstone bricks - * within Minecraft. + * {@link LocationInUnloadedChunkError} * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly crackedPolishedBlackstoneBricks: BlockType; + readonly isLiquid: boolean; /** + * @beta * @remarks - * Represents a crafting table within Minecraft. + * 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). * - */ - static readonly craftingTable: BlockType; - /** - * @remarks - * Represents a crimson button within Minecraft. + * @throws This property can throw when used. * - */ - static readonly crimsonButton: BlockType; - /** - * @remarks - * Represents a crimson door within Minecraft. + * {@link LocationInUnloadedChunkError} * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly crimsonDoor: BlockType; + readonly isSolid: boolean; /** + * @beta * @remarks - * Represents a crimson double slab within Minecraft. + * Returns or sets whether this block has a liquid on it. * + * @throws This property can throw when used. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly crimsonDoubleSlab: BlockType; + readonly isWaterlogged: boolean; /** * @remarks - * Represents a crimson fence within Minecraft. + * Coordinates of the specified block. * + * @throws This property can throw when used. */ - static readonly crimsonFence: BlockType; + readonly location: Vector3; /** * @remarks - * Represents a crimson fence gate within Minecraft. + * Additional block configuration data that describes the + * block. * + * @throws This property can throw when used. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly crimsonFenceGate: BlockType; + readonly permutation: BlockPermutation; /** + * @beta * @remarks - * Represents a crimson fungus within Minecraft. + * Gets the type of block. + * + * @throws This property can throw when used. * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly crimsonFungus: BlockType; - static readonly crimsonHangingSign: BlockType; + readonly 'type': BlockType; /** + * @beta * @remarks - * Represents crimson hyphae within Minecraft. + * Identifier of the type of block for this block. * + * @throws This property can throw when used. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly crimsonHyphae: BlockType; + readonly typeId: string; /** * @remarks - * Represents crimson nylium within Minecraft. + * X coordinate of the block. * */ - static readonly crimsonNylium: BlockType; + readonly x: number; /** * @remarks - * Represents a set of crimson planks within Minecraft. + * Y coordinate of the block. * */ - static readonly crimsonPlanks: BlockType; + readonly y: number; /** * @remarks - * Represents a crimson pressure plate within Minecraft. + * Z coordinate of the block. * */ - static readonly crimsonPressurePlate: BlockType; + readonly z: number; /** * @remarks - * Represents a set of crimson roots within Minecraft. + * Returns the {@link Block} above this block (positive in the + * Y direction). + * + * @param steps + * Number of steps above to step before returning. + * @throws This function can throw errors. * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly crimsonRoots: BlockType; + above(steps?: number): Block | undefined; /** * @remarks - * Represents a crimson slab within Minecraft. + * Returns the {@link Block} below this block (negative in the + * Y direction). + * + * @param steps + * Number of steps below to step before returning. + * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly crimsonSlab: BlockType; + below(steps?: number): Block | undefined; /** * @remarks - * Represents a set of crimson stairs within Minecraft. + * Returns the {@link @minecraft/server.Location} of the center + * of this block on the X and Z axis. * */ - static readonly crimsonStairs: BlockType; + bottomCenter(): Vector3; /** + * @beta * @remarks - * Represents a crimson standing sign within Minecraft. + * 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. + * + * {@link Error} + * + * {@link LocationInUnloadedChunkError} * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly crimsonStandingSign: BlockType; + canPlace(blockToPlace: BlockPermutation | BlockType | string, faceToPlaceOn?: Direction): boolean; /** * @remarks - * Represents a crimson stem within Minecraft. + * Returns the {@link @minecraft/server.Location} of the center + * of this block on the X, Y, and Z axis. * */ - static readonly crimsonStem: BlockType; + center(): Vector3; /** * @remarks - * Represents a crimson trapdoor within Minecraft. + * Returns the {@link Block} to the east of this block + * (positive in the X direction). * + * @param steps + * Number of steps to the east to step before returning. + * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly crimsonTrapdoor: BlockType; + east(steps?: number): Block | undefined; /** * @remarks - * Represents a crimson wall sign within Minecraft. + * Gets a component (that represents additional capabilities) + * for a block - for example, an inventory component of a chest + * block. + * + * @param componentId + * The identifier of the component (e.g., + * 'minecraft:inventory'). If no namespace prefix is specified, + * 'minecraft:' is assumed. Available component IDs can be + * found as part of the {@link BlockComponentTypes} enum. + * @returns + * Returns the component if it exists on the block, otherwise + * undefined. + * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly crimsonWallSign: BlockType; + getComponent(componentId: T): BlockComponentTypeMap[T] | undefined; /** * @remarks - * Represents crying obsidian within Minecraft. + * 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. + * @returns + * An itemStack with the specified amount of items and data. + * Returns undefined if block type is incompatible. + * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly cryingObsidian: BlockType; + getItemStack(amount?: number, withData?: boolean): ItemStack | undefined; /** + * @beta * @remarks - * Represents a cut copper block within Minecraft. + * 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. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly cutCopper: BlockType; + getRedstonePower(): number | undefined; /** * @remarks - * Represents a cut copper slab within Minecraft. + * Returns a set of tags for a block. * + * @returns + * The list of tags that the block has. + * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly cutCopperSlab: BlockType; + getTags(): string[]; /** * @remarks - * Represents a set of cut copper stairs within Minecraft. + * 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. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} + * @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")}`); + * ``` */ - static readonly cutCopperStairs: BlockType; + hasTag(tag: string): boolean; /** * @remarks - * Represents a cyan-colored candle within Minecraft. + * 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. */ - static readonly cyanCandle: BlockType; + isValid(): boolean; /** + * @beta * @remarks - * Represents a cake with a cyan-colored candle within - * Minecraft. + * Tests whether this block matches a specific criteria. + * + * @param blockName + * Block type identifier to match this API against. + * @param states + * Optional set of block states to test this block against. + * @returns + * Returns true if the block matches the specified criteria. + * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly cyanCandleCake: BlockType; - static readonly cyanCarpet: BlockType; + matches(blockName: string, states?: Record): boolean; /** * @remarks - * Represents a block of cyan-colored glazed terracotta within - * Minecraft. + * Returns the {@link Block} to the north of this block + * (negative in the Z direction). + * + * @param steps + * Number of steps to the north to step before returning. + * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly cyanGlazedTerracotta: BlockType; - static readonly cyanWool: BlockType; + north(steps?: number): Block | undefined; /** * @remarks - * Represents a dark oak button within Minecraft. + * Returns a block at an offset relative vector to this block. + * + * @param offset + * The offset vector. For example, an offset of 0, 1, 0 will + * return the block above the current block. + * @returns + * Block at the specified offset, or undefined if that block + * could not be retrieved (for example, the block and its + * relative chunk is not loaded yet.) + * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly darkOakButton: BlockType; + offset(offset: Vector3): Block | undefined; /** * @remarks - * Represents a dark oak door within Minecraft. + * 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} */ - static readonly darkOakDoor: BlockType; - static readonly darkOakFence: BlockType; + setPermutation(permutation: BlockPermutation): void; /** + * @beta * @remarks - * Represents a dark oak fence gate within Minecraft. + * 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. + * + * {@link Error} + * + * {@link LocationInUnloadedChunkError} * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly darkOakFenceGate: BlockType; - static readonly darkOakHangingSign: BlockType; - static readonly darkOakLog: BlockType; + setType(blockType: BlockType | string): void; /** + * @beta * @remarks - * Represents a dark oak pressure plate within Minecraft. + * Sets whether this block has a water logged state - for + * example, whether stairs are submerged within water. + * + * This function can't be called in read-only mode. + * + * @param isWaterlogged + * true if the block should have water within it. + * @throws This function can throw errors. + * + * {@link Error} * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly darkOakPressurePlate: BlockType; + setWaterlogged(isWaterlogged: boolean): void; /** * @remarks - * Represents a set of dark oak stairs within Minecraft. + * Returns the {@link Block} to the south of this block + * (positive in the Z direction). + * + * @param steps + * Number of steps to the south to step before returning. + * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly darkOakStairs: BlockType; + south(steps?: number): Block | undefined; /** + * @beta * @remarks - * Represents a dark oak standing sign within Minecraft. + * 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. + * + * {@link LocationInUnloadedChunkError} * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly darkoakStandingSign: BlockType; + trySetPermutation(permutation: BlockPermutation): boolean; /** * @remarks - * Represents a dark oak trapdoor within Minecraft. + * Returns the {@link Block} to the west of this block + * (negative in the X direction). + * + * @param steps + * Number of steps to the west to step before returning. + * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly darkOakTrapdoor: BlockType; + west(steps?: number): Block | undefined; +} + +/** + * Base type for components associated with blocks. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockComponent extends Component { + private constructor(); /** * @remarks - * Represents a dark oak wall sign within Minecraft. + * Block instance that this component pertains to. * */ - static readonly darkoakWallSign: BlockType; + readonly block: Block; +} + +/** + * @beta + * Contains information regarding an entity falling onto a + * specific block. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockComponentEntityFallOnEvent extends BlockEvent { + private constructor(); /** * @remarks - * Represents a set of dark prismarine stairs within Minecraft. + * The entity that fell onto the block. * */ - static readonly darkPrismarineStairs: BlockType; + readonly entity?: Entity; /** * @remarks - * Represents a daylight detector within Minecraft. + * The distance that the entity fell onto this block with. * */ - static readonly daylightDetector: BlockType; + readonly fallDistance: number; +} + +/** + * @beta + * Contains information regarding a specific block that was + * placed. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockComponentOnPlaceEvent extends BlockEvent { + private constructor(); /** * @remarks - * Represents an inverted daylight detector within Minecraft. + * Previous block at this location that was replaced. * */ - static readonly daylightDetectorInverted: BlockType; - static readonly deadBrainCoral: BlockType; - static readonly deadBubbleCoral: BlockType; + readonly previousBlock: BlockPermutation; +} + +/** + * @beta + * Contains information regarding a specific block being + * destroyed. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockComponentPlayerDestroyEvent extends BlockEvent { + private constructor(); /** * @remarks - * Represents a dead bush within Minecraft. + * Returns permutation information about this block before it + * was destroyed. * */ - static readonly deadbush: BlockType; - static readonly deadFireCoral: BlockType; - static readonly deadHornCoral: BlockType; - static readonly deadTubeCoral: BlockType; - static readonly decoratedPot: BlockType; + readonly destroyedBlockPermutation: BlockPermutation; /** * @remarks - * Represents a block of deepslate within Minecraft. + * The player that destroyed this block. * */ - static readonly deepslate: BlockType; + readonly player?: Player; +} + +/** + * @beta + * Contains information regarding a specific block being + * interacted with. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockComponentPlayerInteractEvent extends BlockEvent { + private constructor(); /** * @remarks - * Represents a double slab of deepslate brick within - * Minecraft. + * The block face that was interacted with. * */ - static readonly deepslateBrickDoubleSlab: BlockType; + readonly face: Direction; /** * @remarks - * Represents a block of deepslate bricks within Minecraft. + * Location relative to the bottom north-west corner of the + * block that the player interacted with. * */ - static readonly deepslateBricks: BlockType; + readonly faceLocation?: Vector3; /** * @remarks - * Represents a slab of deepslate brick within Minecraft. + * The player that interacted with this block. * */ - static readonly deepslateBrickSlab: BlockType; + readonly player?: Player; +} + +/** + * @beta + * Contains information regarding an event before a player + * places a block. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockComponentPlayerPlaceBeforeEvent extends BlockEvent { + private constructor(); /** * @remarks - * Represents a set of deepslate brick stairs within Minecraft. + * If set to true, cancels the block place event. * */ - static readonly deepslateBrickStairs: BlockType; + cancel: boolean; /** * @remarks - * Represents a deepslate brick wall within Minecraft. + * The block face that was placed onto. * */ - static readonly deepslateBrickWall: BlockType; + readonly face: Direction; /** * @remarks - * Represents a block of deepslate with embedded coal ore - * within Minecraft. + * The block permutation that will be placed if the event is + * not cancelled. If set to a different block permutation, that + * permutation will be placed instead. * */ - static readonly deepslateCoalOre: BlockType; + permutationToPlace: BlockPermutation; /** * @remarks - * Represents a block of deepslate with embedded copper ore - * within Minecraft. + * The player that is placing this block. * */ - static readonly deepslateCopperOre: BlockType; + readonly player?: Player; +} + +/** + * @beta + * Contains information regarding a specific block randomly + * ticking. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockComponentRandomTickEvent extends BlockEvent { + private constructor(); +} + +/** + * @beta + */ +export class BlockComponentRegistry { + private constructor(); /** - * @remarks - * Represents a block of deepslate with embedded diamond ore - * within Minecraft. + * @throws This function can throw errors. * + * {@link minecraftcommon.EngineError} + * + * {@link Error} */ - static readonly deepslateDiamondOre: BlockType; + registerCustomComponent(name: string, customComponent: BlockCustomComponent): void; +} + +/** + * @beta + * Contains information regarding an entity stepping off a + * specific block. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockComponentStepOffEvent extends BlockEvent { + private constructor(); /** * @remarks - * Represents a block of deepslate with embedded emerald ore - * within Minecraft. + * The entity that stepped off the block. * */ - static readonly deepslateEmeraldOre: BlockType; + readonly entity?: Entity; +} + +/** + * @beta + * Contains information regarding an entity stepping onto a + * specific block. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockComponentStepOnEvent extends BlockEvent { + private constructor(); /** * @remarks - * Represents a block of deepslate with embedded gold ore - * within Minecraft. + * The entity that stepped on the block. * */ - static readonly deepslateGoldOre: BlockType; + readonly entity?: Entity; +} + +/** + * @beta + * Contains information regarding a specific block ticking. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockComponentTickEvent extends BlockEvent { + private constructor(); +} + +/** + * Contains information regarding an event that impacts a + * specific block. + */ +export class BlockEvent { + private constructor(); /** * @remarks - * Represents a block of deepslate with embedded iron ore - * within Minecraft. + * Block impacted by this event. * */ - static readonly deepslateIronOre: BlockType; + readonly block: Block; /** * @remarks - * Represents a block of deepslate with embedded lapis lazuli - * ore within Minecraft. + * Dimension that contains the block that is the subject of + * this event. * */ - static readonly deepslateLapisOre: BlockType; + 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 - * Represents a block of deepslate with embedded redstone ore - * within Minecraft. + * Description of the block that has exploded. * */ - static readonly deepslateRedstoneOre: BlockType; + readonly explodedBlockPermutation: BlockPermutation; /** * @remarks - * Represents a double slab of tiled deepslate within - * Minecraft. + * Optional source of the explosion. * */ - static readonly deepslateTileDoubleSlab: BlockType; + 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 - * Represents a set of deepslate tiles within Minecraft. + * 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. * */ - static readonly deepslateTiles: BlockType; + subscribe(callback: (arg: BlockExplodeAfterEvent) => void): (arg: BlockExplodeAfterEvent) => void; /** * @remarks - * Represents a slab of deepslate tiles within Minecraft. + * 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. * */ - static readonly deepslateTileSlab: BlockType; + unsubscribe(callback: (arg: BlockExplodeAfterEvent) => void): void; +} + +/** + * Represents the inventory of a block in the world. Used with + * blocks like chests. + * @example place_items_in_chest.js + * ```typescript + * import { world, MinecraftBlockTypes, Items, ItemStack } from "@minecraft/server"; + * + * // Fetch block + * const block = world.getDimension("overworld").getBlock({ x: 1, y: 2, z: 3 }); + * + * // Make it a chest + * block.setType(MinecraftBlockTypes.chest); + * + * // Get the inventory + * const inventoryComponent = block.getComponent("inventory"); + * const inventoryContainer = inventoryComponent.container; + * + * // Set slot 0 to a stack of 10 apples + * inventoryContainer.setItem(0, new ItemStack(Items.apple, 10, 0)); + * + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockInventoryComponent extends BlockComponent { + private constructor(); /** * @remarks - * Represents a set of deepslate tile stairs within Minecraft. + * The container which holds an {@link ItemStack}. * + * @throws This property can throw when used. */ - static readonly deepslateTileStairs: BlockType; + 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 - * Represents a wall of deepslate tile within Minecraft. + * Relative fill level of the liquid container. + * + * This property can't be edited in read-only mode. * */ - static readonly deepslateTileWall: BlockType; + fillLevel: number; /** * @remarks - * Represents a logical but generally invisible Deny logic - * block within Minecraft. + * 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. */ - static readonly deny: BlockType; + 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 - * Represents a detector rail within Minecraft. + * This function can't be called in read-only mode. * */ - static readonly detectorRail: BlockType; + [Symbol.iterator](): Iterator; /** * @remarks - * Represents a block of diamond within Minecraft. + * This function can't be called in read-only mode. * */ - static readonly diamondBlock: BlockType; + next(): IteratorResult; +} + +/** + * 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}). + * @example createTranslatedSign.ts + * ```typescript + * // A function the creates a sign at the specified location with the specified text + * import { DimensionLocation, BlockPermutation, BlockComponentTypes } from '@minecraft/server'; + * import { MinecraftBlockTypes } from '@minecraft/vanilla-data'; + * + * function createSignAt(location: DimensionLocation) { + * const signBlock = location.dimension.getBlock(location); + * + * if (!signBlock) { + * console.warn('Could not find a block at specified location.'); + * return; + * } + * + * const signPerm = BlockPermutation.resolve(MinecraftBlockTypes.StandingSign, { ground_sign_direction: 8 }); + * signBlock.setPermutation(signPerm); // Update block to be a sign + * + * // Update the sign block's text + * // with "Steve's Head" + * const signComponent = signBlock.getComponent(BlockComponentTypes.Sign); + * if (signComponent) { + * signComponent.setText({ translate: 'item.skull.player.name', with: ['Steve'] }); + * } + * } + * ``` + */ +export class BlockPermutation { + private constructor(); /** + * @beta * @remarks - * Represents a block with embedded diamond ore within - * Minecraft. + * The {@link BlockType} that the permutation has. * */ - static readonly diamondOre: BlockType; + readonly 'type': BlockType; /** * @remarks - * Represents a set of diorite stairs within Minecraft. + * Returns all available block states associated with this + * block. * + * @returns + * Returns the list of all of the block states that the + * permutation has. */ - static readonly dioriteStairs: BlockType; + getAllStates(): Record; /** * @remarks - * Represents a block of dirt within Minecraft. + * 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. */ - static readonly dirt: BlockType; + getItemStack(amount?: number): ItemStack | undefined; /** * @remarks - * Represents a block of dirt with roots within Minecraft. + * 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`. */ - static readonly dirtWithRoots: BlockType; + getState(stateName: string): boolean | number | string | undefined; /** + * @beta * @remarks - * Represents a dispenser within Minecraft. + * Creates a copy of the permutation. * */ - static readonly dispenser: BlockType; + getTags(): string[]; /** + * @beta * @remarks - * Represents a slab of double cut copper within Minecraft. + * 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")}`); + * ``` */ - static readonly doubleCutCopperSlab: BlockType; + hasTag(tag: string): boolean; /** * @remarks - * Represents a double plant within Minecraft. + * 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. */ - static readonly doublePlant: BlockType; - static readonly doubleStoneBlockSlab: BlockType; - static readonly doubleStoneBlockSlab2: BlockType; - static readonly doubleStoneBlockSlab3: BlockType; - static readonly doubleStoneBlockSlab4: BlockType; + matches(blockName: string, states?: Record): boolean; /** * @remarks - * Represents a double slab of stone within Minecraft. + * 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. */ - static readonly doubleStoneSlab: BlockType; + withState(name: string, value: boolean | number | string): BlockPermutation; /** * @remarks - * Represents an alternate double slab of stone (#2) within - * Minecraft. + * 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 + * import { DimensionLocation, BlockPermutation } from '@minecraft/server'; + * import { MinecraftBlockTypes } from '@minecraft/vanilla-data'; + * + * const allWoolBlocks: string[] = [ + * MinecraftBlockTypes.WhiteWool, + * MinecraftBlockTypes.OrangeWool, + * MinecraftBlockTypes.MagentaWool, + * MinecraftBlockTypes.LightBlueWool, + * MinecraftBlockTypes.YellowWool, + * MinecraftBlockTypes.LimeWool, + * MinecraftBlockTypes.PinkWool, + * MinecraftBlockTypes.GrayWool, + * MinecraftBlockTypes.LightGrayWool, + * MinecraftBlockTypes.CyanWool, + * MinecraftBlockTypes.PurpleWool, + * MinecraftBlockTypes.BlueWool, + * MinecraftBlockTypes.BrownWool, + * MinecraftBlockTypes.GreenWool, + * MinecraftBlockTypes.RedWool, + * MinecraftBlockTypes.BlackWool, + * ]; + * + * const cubeDim = 7; + * + * function placeRainbowCube(location: DimensionLocation) { + * 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++; + * location.dimension + * .getBlock({ x: location.x + x, y: location.y + y, z: location.z + z }) + * ?.setPermutation(BlockPermutation.resolve(allWoolBlocks[colorIndex % allWoolBlocks.length])); + * } + * } + * } + * } + * ``` */ - static readonly doubleStoneSlab2: BlockType; + static resolve(blockName: string, states?: Record): BlockPermutation; +} + +/** + * 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 - * Represents an alternate double slab of stone (#3) within - * Minecraft. + * Whether the piston is in the process of expanding or + * retracting. * + * @throws This property can throw when used. */ - static readonly doubleStoneSlab3: BlockType; + readonly isMoving: boolean; /** * @remarks - * Represents an alternate double slab of stone (#4) within - * Minecraft. + * The current state of the piston. * + * @throws This property can throw when used. */ - static readonly doubleStoneSlab4: BlockType; + readonly state: BlockPistonState; + static readonly componentId = 'minecraft:piston'; /** * @remarks - * Represents a double slab of wood within Minecraft. + * Retrieves a set of blocks that this piston is connected + * with. * + * @throws This function can throw errors. */ - static readonly doubleWoodenSlab: BlockType; + getAttachedBlocks(): Block[]; /** * @remarks - * Represents a dragon egg within Minecraft. + * Retrieves a set of block locations that this piston is + * connected with. * + * @throws This function can throw errors. */ - static readonly dragonEgg: BlockType; + getAttachedBlocksLocations(): 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 - * Represents a block of dried kelp within Minecraft. + * 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. */ - static readonly driedKelpBlock: BlockType; + 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 - * Represents a block of dripstone within Minecraft. + * 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. */ - static readonly dripstoneBlock: BlockType; + clearRecord(): void; /** * @remarks - * Represents a dropper within Minecraft. + * Returns true if the record-playing block is currently + * playing a record. * + * @throws This function can throw errors. */ - static readonly dropper: BlockType; + isPlaying(): boolean; /** * @remarks - * Represents an element in Minecraft Education experiences. + * 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. */ - static readonly element0: BlockType; + setRecord(recordItemType: ItemType | string): void; +} + +/** + * Represents a block that can display text on it. + * @example addTwoSidedSign.ts + * ```typescript + * // A function the creates a sign at the specified location with text on both sides and dye colors + * import { + * DimensionLocation, + * BlockPermutation, + * BlockSignComponent, + * BlockComponentTypes, + * DyeColor, + * SignSide, + * } from '@minecraft/server'; + * import { MinecraftBlockTypes } from '@minecraft/vanilla-data'; + * + * function createSignAt(location: DimensionLocation) { + * const block = location.dimension.getBlock(location); + * if (!block) { + * console.warn('Could not find a block at specified location.'); + * return; + * } + * const signPerm = BlockPermutation.resolve(MinecraftBlockTypes.StandingSign, { + * ground_sign_direction: 8, + * }); + * block.setPermutation(signPerm); + * const sign = block.getComponent(BlockComponentTypes.Sign); + * + * if (sign !== undefined) { + * sign.setText(`Party Sign!\nThis is green on the front.`); + * sign.setText(`Party Sign!\nThis is red on the back.`, SignSide.Back); + * sign.setTextDyeColor(DyeColor.Green); + * sign.setTextDyeColor(DyeColor.Red, SignSide.Back); + * + * // players cannot edit sign! + * sign.setWaxed(true); + * } else { + * console.warn('Could not find a sign component on the block.'); + * } + * } + * ``` + * @example setSignText.ts + * ```typescript + * import { + * BlockComponentTypes, + * DimensionLocation, + * RawMessage, + * RawText, + * } from '@minecraft/server'; + * + * // Function which updates a sign blocks text to raw text + * function updateSignText(signLocation: DimensionLocation) { + * const block = signLocation.dimension.getBlock(signLocation); + * if (!block) { + * console.warn('Could not find a block at specified location.'); + * return; + * } + * + * const sign = block.getComponent(BlockComponentTypes.Sign); + * if (sign) { + * // RawMessage + * const helloWorldMessage: RawMessage = { text: 'Hello World' }; + * sign.setText(helloWorldMessage); + * + * // RawText + * const helloWorldText: RawText = { rawtext: [{ text: 'Hello World' }] }; + * sign.setText(helloWorldText); + * + * // Regular string + * sign.setText('Hello World'); + * } else { + * console.warn('Could not find a sign component on the block.'); + * } + * } + * ``` + * @example createTranslatedSign.ts + * ```typescript + * // A function the creates a sign at the specified location with the specified text + * import { DimensionLocation, BlockPermutation, BlockComponentTypes } from '@minecraft/server'; + * import { MinecraftBlockTypes } from '@minecraft/vanilla-data'; + * + * function createSignAt(location: DimensionLocation) { + * const signBlock = location.dimension.getBlock(location); + * + * if (!signBlock) { + * console.warn('Could not find a block at specified location.'); + * return; + * } + * + * const signPerm = BlockPermutation.resolve(MinecraftBlockTypes.StandingSign, { ground_sign_direction: 8 }); + * signBlock.setPermutation(signPerm); // Update block to be a sign + * + * // Update the sign block's text + * // with "Steve's Head" + * const signComponent = signBlock.getComponent(BlockComponentTypes.Sign); + * if (signComponent) { + * signComponent.setText({ translate: 'item.skull.player.name', with: ['Steve'] }); + * } + * } + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockSignComponent extends BlockComponent { + private constructor(); /** * @remarks - * Represents the hydrogen element in Minecraft Education - * experiences. + * 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. */ - static readonly element1: BlockType; + readonly isWaxed: boolean; + static readonly componentId = 'minecraft:sign'; /** * @remarks - * Represents the neon element in Minecraft Education - * experiences. + * 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. */ - static readonly element10: BlockType; + getRawText(side?: SignSide): RawText | undefined; /** * @remarks - * Represents the fermium element in Minecraft Education - * experiences. + * 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. */ - static readonly element100: BlockType; + getText(side?: SignSide): string | undefined; /** * @remarks - * Represents the mendelevium element in Minecraft Education - * experiences. + * 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. */ - static readonly element101: BlockType; + getTextDyeColor(side?: SignSide): DyeColor | undefined; /** * @remarks - * Represents the nobelium element in Minecraft Education - * experiences. + * Sets the text of the sign component. * - */ - static readonly element102: BlockType; - /** - * @remarks - * Represents the lawrencium element in Minecraft Education - * experiences. + * 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 + * Throws if the provided message is greater than 512 + * characters in length. + * @example setSignText.ts + * ```typescript + * import { + * BlockComponentTypes, + * DimensionLocation, + * RawMessage, + * RawText, + * } from '@minecraft/server'; + * + * // Function which updates a sign blocks text to raw text + * function updateSignText(signLocation: DimensionLocation) { + * const block = signLocation.dimension.getBlock(signLocation); + * if (!block) { + * console.warn('Could not find a block at specified location.'); + * return; + * } + * + * const sign = block.getComponent(BlockComponentTypes.Sign); + * if (sign) { + * // RawMessage + * const helloWorldMessage: RawMessage = { text: 'Hello World' }; + * sign.setText(helloWorldMessage); + * + * // RawText + * const helloWorldText: RawText = { rawtext: [{ text: 'Hello World' }] }; + * sign.setText(helloWorldText); + * + * // Regular string + * sign.setText('Hello World'); + * } else { + * console.warn('Could not find a sign component on the block.'); + * } + * } + * ``` */ - static readonly element103: BlockType; + setText(message: RawMessage | RawText | string, side?: SignSide): void; /** * @remarks - * Represents the rutherfordium element in Minecraft Education - * experiences. + * Sets the dye color of the text. * - */ - static readonly element104: BlockType; - /** - * @remarks - * Represents the dubnium element in Minecraft Education - * experiences. + * 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. */ - static readonly element105: BlockType; + setTextDyeColor(color?: DyeColor, side?: SignSide): void; /** * @remarks - * Represents the seaborgium element in Minecraft Education - * experiences. + * Makes it so players cannot edit this sign. * - */ - static readonly element106: BlockType; - /** - * @remarks - * Represents the bohrium element in Minecraft Education - * experiences. + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly element107: BlockType; + setWaxed(waxed: boolean): 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'; +} + +/** + * Enumerates all {@link BlockStateType}s. + */ +export class BlockStates { + private constructor(); /** * @remarks - * Represents the hassium element in Minecraft Education - * experiences. + * Retrieves a specific block state instance. * + * @returns + * Returns the {@link Block} state instance if it is found. If + * the block state instance is not found returns undefined. */ - static readonly element108: BlockType; + static get(stateName: string): BlockStateType | undefined; /** * @remarks - * Represents the meitnerium element in Minecraft Education - * experiences. + * Retrieves a set of all available block states. * */ - static readonly element109: BlockType; + static getAll(): BlockStateType[]; +} + +/** + * 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 - * Represents the sodium element in Minecraft Education - * experiences. + * Identifier of the block property. * */ - static readonly element11: BlockType; + readonly id: string; /** * @remarks - * Represents the darmstadtium element in Minecraft Education - * experiences. + * A set of valid values for the block property. * */ - static readonly element110: BlockType; + readonly validValues: (boolean | number | string)[]; +} + +/** + * 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(); /** + * @beta * @remarks - * Represents the roentgenium element in Minecraft Education - * experiences. + * Represents whether this type of block can be waterlogged. * */ - static readonly element111: BlockType; + readonly canBeWaterlogged: boolean; /** + * @beta * @remarks - * Represents the copernicium element in Minecraft Education - * experiences. + * Block type name - for example, `minecraft:acacia_stairs`. * */ - static readonly element112: BlockType; + readonly id: string; +} + +/** + * @beta + * Contains a catalog of Minecraft Block Types that are + * available in this world. + */ +export class BlockTypes { + private constructor(); /** * @remarks - * Represents the nihonium element in Minecraft Education - * experiences. + * Returns a BlockType object for the specified identifier. * + * @param typeName + * Identifier of the block type. Should follow a namespace:id + * pattern, such as minecraft:dirt. + * @returns + * BlockType object, or undefined if the block type is not + * available within this world. */ - static readonly element113: BlockType; + static get(typeName: string): BlockType | undefined; /** * @remarks - * Represents the flerovium element in Minecraft Education - * experiences. + * Returns a collection of all available block types. * */ - static readonly element114: BlockType; + static getAll(): BlockType[]; +} + +/** + * @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) + * + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockVolume extends BlockVolumeBase { /** * @remarks - * Represents the moscovium element in Minecraft Education - * experiences. + * A world block location that represents a corner in a 3D + * rectangle * - */ - static readonly element115: BlockType; - /** - * @remarks - * Represents the livermorium element in Minecraft Education - * experiences. + * This property can't be edited in read-only mode. * */ - static readonly element116: BlockType; + 'from': Vector3; /** * @remarks - * Represents the tennessine element in Minecraft Education - * experiences. + * A world block location that represents the opposite corner + * in a 3D rectangle * - */ - static readonly element117: BlockType; - /** - * @remarks - * Represents the oganesson element in Minecraft Education - * experiences. + * This property can't be edited in read-only mode. * */ - static readonly element118: BlockType; + to: Vector3; + constructor(from: Vector3, to: Vector3); /** * @remarks - * Represents the magnesium element in Minecraft Education - * experiences. + * Check to see if the given location is directly adjacent to + * the outer surface of a BlockVolume. * - */ - static readonly element12: BlockType; - /** - * @remarks - * Represents the aluminum element in Minecraft Education - * experiences. * - */ - static readonly element13: BlockType; - /** - * @remarks - * Represents the silicon element in Minecraft Education - * experiences. + * This function can't be called in read-only mode. * + * @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 readonly element14: BlockType; + doesLocationTouchFaces(pos: Vector3): boolean; /** * @remarks - * Represents the phosphorus element in Minecraft Education - * experiences. + * 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 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 readonly element15: BlockType; + doesVolumeTouchFaces(other: BlockVolume): boolean; /** * @remarks - * Represents the sulfur element in Minecraft Education - * experiences. + * Return an enumeration which represents the intersection + * between two BlockVolume objects + * + * This function can't be called in read-only mode. * */ - static readonly element16: BlockType; + intersects(other: BlockVolume): BlockVolumeIntersection; +} + +/** + * @beta + * Base type for BlockVolumes. + */ +export class BlockVolumeBase { + private constructor(); /** * @remarks - * Represents the chlorine element in Minecraft Education - * experiences. + * 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 readonly element17: BlockType; + getBlockLocationIterator(): BlockLocationIterator; /** + * @beta * @remarks - * Represents the argon element in Minecraft Education - * experiences. + * 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. * + * @throws This function can throw errors. */ - static readonly element18: BlockType; + getBoundingBox(): BoundingBox; /** * @remarks - * Represents the potassium element in Minecraft Education - * experiences. + * Return the capacity (volume) of the BlockVolume (W*D*H) + * + * This function can't be called in read-only mode. * */ - static readonly element19: BlockType; + getCapacity(): number; /** * @remarks - * Represents the helium element in Minecraft Education - * experiences. + * Get the largest corner position of the volume (guaranteed to + * be >= min) * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly element2: BlockType; + getMax(): Vector3; /** * @remarks - * Represents the calcium element in Minecraft Education - * experiences. + * Get the smallest corner position of the volume (guaranteed + * to be <= max) * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly element20: BlockType; + getMin(): Vector3; /** * @remarks - * Represents the scandium element in Minecraft Education - * experiences. + * 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 readonly element21: BlockType; + getSpan(): Vector3; /** * @remarks - * Represents the titanium element in Minecraft Education - * experiences. + * Check to see if a given world block location is inside a + * BlockVolume + * + * This function can't be called in read-only mode. * */ - static readonly element22: BlockType; + isInside(location: Vector3): boolean; /** * @remarks - * Represents the vanadium element in Minecraft Education - * experiences. + * 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 */ - static readonly element23: BlockType; + translate(delta: Vector3): void; +} + +/** + * @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 - * Represents the chromium element in Minecraft Education - * experiences. + * 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. */ - static readonly element24: BlockType; + addDye(itemType: ItemType): void; /** * @remarks - * Represents the manganese element in Minecraft Education - * experiences. + * 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. */ - static readonly element25: BlockType; + getCustomColor(): RGBA; /** * @remarks - * Represents the iron element in Minecraft Education - * experiences. + * 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. */ - static readonly element26: BlockType; + 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 - * Represents the cobalt element in Minecraft Education - * experiences. + * 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 readonly element27: BlockType; + static createValid(min: Vector3, max: Vector3): BoundingBox; /** * @remarks - * Represents the nickel element in Minecraft Education - * experiences. + * 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 readonly element28: BlockType; + static dilate(box: BoundingBox, size: Vector3): BoundingBox; /** * @remarks - * Represents the copper element in Minecraft Education - * experiences. + * Check if two {@link @minecraft-server.BoundingBox} objects + * are identical + * + * This function can't be called in read-only mode. * */ - static readonly element29: BlockType; + static equals(box: BoundingBox, other: BoundingBox): boolean; /** * @remarks - * Represents a lithium element in Minecraft Education - * experiences. + * 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 readonly element3: BlockType; + static expand(box: BoundingBox, other: BoundingBox): BoundingBox; /** * @remarks - * Represents the zinc element in Minecraft Education - * experiences. + * 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 readonly element30: BlockType; + static getCenter(box: BoundingBox): Vector3; /** * @remarks - * Represents the gallium element in Minecraft Education - * experiences. + * Calculate the BoundingBox which represents the union area of + * two intersecting BoundingBoxes + * + * This function can't be called in read-only mode. * */ - static readonly element31: BlockType; + static getIntersection(box: BoundingBox, other: BoundingBox): BoundingBox | undefined; /** * @remarks - * Represents a germanium element in Minecraft Education - * experiences. + * Get the Span of each of the BoundingBox Axis components + * + * This function can't be called in read-only mode. * */ - static readonly element32: BlockType; + static getSpan(box: BoundingBox): Vector3; /** * @remarks - * Represents the arsenic element in Minecraft Education - * experiences. + * Check to see if two BoundingBox objects intersect + * + * This function can't be called in read-only mode. * */ - static readonly element33: BlockType; + static intersects(box: BoundingBox, other: BoundingBox): boolean; /** * @remarks - * Represents the selenium element in Minecraft Education - * experiences. + * Check to see if a given coordinate is inside a BoundingBox + * + * This function can't be called in read-only mode. * */ - static readonly element34: BlockType; + static isInside(box: BoundingBox, pos: Vector3): boolean; /** * @remarks - * Represents the bromine element in Minecraft Education - * experiences. + * Check to see if a BoundingBox is valid (i.e. (min <= max)) + * + * This function can't be called in read-only mode. * */ - static readonly element35: BlockType; + static isValid(box: BoundingBox): boolean; /** * @remarks - * Represents the krypton element in Minecraft Education - * experiences. + * 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 readonly element36: BlockType; + static translate(box: BoundingBox, delta: Vector3): BoundingBox; +} + +/** + * Contains information related to changes to a button push. + * @example buttonPushEvent.ts + * ```typescript + * import { world, ButtonPushAfterEvent, system } from '@minecraft/server'; + * + * world.afterEvents.buttonPush.subscribe((buttonPushEvent: ButtonPushAfterEvent) => { + * const eventLoc = buttonPushEvent.block.location; + * + * world.sendMessage( + * `Button push event at tick ${system.currentTick} Power:${buttonPushEvent.block.getRedstonePower()}`, + * ); + * }); + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class ButtonPushAfterEvent extends BlockEvent { + private constructor(); /** * @remarks - * Represents the rubidium element in Minecraft Education - * experiences. + * Optional source that triggered the button push. * */ - static readonly element37: BlockType; + readonly source: Entity; +} + +/** + * Manages callbacks that are connected to when a button is + * pushed. + * @example buttonPushEvent.ts + * ```typescript + * import { world, ButtonPushAfterEvent, system } from '@minecraft/server'; + * + * world.afterEvents.buttonPush.subscribe((buttonPushEvent: ButtonPushAfterEvent) => { + * const eventLoc = buttonPushEvent.block.location; + * + * world.sendMessage( + * `Button push event at tick ${system.currentTick} Power:${buttonPushEvent.block.getRedstonePower()}`, + * ); + * }); + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class ButtonPushAfterEventSignal extends IButtonPushAfterEventSignal { + private constructor(); +} + +/** + * Contains methods relating to the active camera for the + * specified player. + */ +export class Camera { + private constructor(); /** * @remarks - * Represents the strontium element in Minecraft Education - * experiences. + * Clears the active camera for the specified player. Causes + * the specified players to end any in-progress camera + * perspectives, including any eased camera motions, and return + * to their normal perspective. + * + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly element38: BlockType; + clear(): void; /** * @remarks - * Represents the yttrium element in Minecraft Education - * experiences. + * Begins a camera fade transition. A fade transition is a + * full-screen color that fades-in, holds, and then fades-out. + * + * This function can't be called in read-only mode. * + * @param fadeCameraOptions + * Additional options around camera fade operations. + * @throws This function can throw errors. */ - static readonly element39: BlockType; + fade(fadeCameraOptions?: CameraFadeOptions): void; /** * @remarks - * Represents a beryllium element in Minecraft Education - * experiences. + * Sets the current active camera for the specified player. + * + * This function can't be called in read-only mode. * + * @param cameraPreset + * Identifier of a camera preset file defined within JSON. + * @param setOptions + * Additional options for the camera. + * @throws This function can throw errors. */ - static readonly element4: BlockType; + setCamera( + cameraPreset: string, + setOptions?: + | CameraDefaultOptions + | CameraSetFacingOptions + | CameraSetLocationOptions + | CameraSetPosOptions + | CameraSetRotOptions, + ): void; +} + +/** + * @beta + * An event that fires as players enter chat messages. + */ +export class ChatSendAfterEvent { + private constructor(); /** * @remarks - * Represents the zirconium element in Minecraft Education - * experiences. + * Message that is being broadcast. * */ - static readonly element40: BlockType; + readonly message: string; /** * @remarks - * Represents the niobium element in Minecraft Education - * experiences. + * Player that sent the chat message. * */ - static readonly element41: BlockType; + readonly sender: Player; /** * @remarks - * Represents the molybdenum element in Minecraft Education - * experiences. + * Optional list of players that will receive this message. If + * defined, this message is directly targeted to one or more + * players (i.e., is not broadcast.) * */ - static readonly element42: BlockType; + readonly targets?: Player[]; +} + +/** + * @beta + * Manages callbacks that are connected to chat messages being + * sent. + */ +export class ChatSendAfterEventSignal { + private constructor(); /** * @remarks - * Represents the technetium element in Minecraft Education - * experiences. + * 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}'`; + * } + * }); + * ``` */ - static readonly element43: BlockType; + subscribe(callback: (arg: ChatSendAfterEvent) => void): (arg: ChatSendAfterEvent) => void; /** * @remarks - * Represents the ruthenium element in Minecraft Education - * experiences. + * Removes a callback from being called when new chat messages + * are sent. + * + * This function can't be called in read-only mode. * */ - static readonly element44: BlockType; + unsubscribe(callback: (arg: ChatSendAfterEvent) => void): void; +} + +/** + * @beta + * An event that fires as players enter chat messages. + */ +export class ChatSendBeforeEvent { + private constructor(); /** * @remarks - * Represents the rhodium element in Minecraft Education - * experiences. + * If set to true in a beforeChat event handler, this message + * is not broadcast out. * */ - static readonly element45: BlockType; + cancel: boolean; /** * @remarks - * Represents the palladium element in Minecraft Education - * experiences. + * Message that is being broadcast. * */ - static readonly element46: BlockType; + readonly message: string; /** * @remarks - * Represents the silver element in Minecraft Education - * experiences. + * Player that sent the chat message. * */ - static readonly element47: BlockType; + readonly sender: Player; /** * @remarks - * Represents the cadmium element in Minecraft Education - * experiences. + * Optional list of players that will receive this message. If + * defined, this message is directly targeted to one or more + * players (i.e., is not broadcast.) * */ - static readonly element48: BlockType; + readonly targets?: Player[]; +} + +/** + * @beta + * Manages callbacks that are connected to an event that fires + * before chat messages are sent. + */ +export class ChatSendBeforeEventSignal { + private constructor(); /** * @remarks - * Represents the indium element in Minecraft Education - * experiences. + * Adds a callback that will be called before new chat messages + * are sent. + * + * This function can't be called in read-only mode. * */ - static readonly element49: BlockType; + subscribe(callback: (arg: ChatSendBeforeEvent) => void): (arg: ChatSendBeforeEvent) => void; /** * @remarks - * Represents the boron element in Minecraft Education - * experiences. + * Removes a callback from being called before new chat + * messages are sent. + * + * This function can't be called in read-only mode. * */ - static readonly element5: BlockType; + unsubscribe(callback: (arg: ChatSendBeforeEvent) => void): void; +} + +/** + * Contains return data on the result of a command execution. + */ +export class CommandResult { + private constructor(); /** * @remarks - * Represents the tin element in Minecraft Education - * experiences. + * If the command operates against a number of entities, + * blocks, or items, this returns the number of successful + * applications of this command. * */ - static readonly element50: BlockType; + readonly successCount: number; +} + +/** + * Base class for downstream Component implementations. + */ +export class Component { + private constructor(); /** * @remarks - * Represents the antimony element in Minecraft Education - * experiences. + * Identifier of the component. * */ - static readonly element51: BlockType; + readonly typeId: string; /** * @remarks - * Represents the tellurium element in Minecraft Education - * experiences. + * 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. */ - static readonly element52: BlockType; + 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 - * Represents the iodine element in Minecraft Education - * experiences. + * Return the 'capacity' of the bounding rectangle which + * represents the collection of volumes in the stack * */ - static readonly element53: BlockType; + readonly capacity: number; + readonly items: CompoundBlockVolumeItem[]; + readonly itemsAbsolute: CompoundBlockVolumeItem[]; /** * @remarks - * Represents the xenon element in Minecraft Education - * experiences. + * Return the number of volumes (positive and negative) in the + * volume stack * */ - static readonly element54: BlockType; + readonly volumeCount: number; /** * @remarks - * Represents the cesium element in Minecraft Education - * experiences. + * 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) */ - static readonly element55: BlockType; + constructor(origin?: Vector3); /** * @remarks - * Represents the barium element in Minecraft Education - * experiences. + * Clear the contents of the volume stack + * + * This function can't be called in read-only mode. * */ - static readonly element56: BlockType; + clear(): void; /** * @remarks - * Represents the lanthanum element in Minecraft Education - * experiences. + * 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. * */ - static readonly element57: BlockType; + getBlockLocationIterator(): BlockLocationIterator; /** * @remarks - * Represents the cerium element in Minecraft Education - * experiences. + * 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. * */ - static readonly element58: BlockType; + getBoundingBox(): BoundingBox; /** * @remarks - * Represents the praseodymium element in Minecraft Education - * experiences. + * 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. * */ - static readonly element59: BlockType; + getMax(): Vector3; /** * @remarks - * Represents the carbon element in Minecraft Education - * experiences. + * 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. * */ - static readonly element6: BlockType; + getMin(): Vector3; /** * @remarks - * Represents the neodymium element in Minecraft Education - * experiences. + * Fetch the origin in world space of the compound volume + * + * This function can't be called in read-only mode. * */ - static readonly element60: BlockType; + getOrigin(): Vector3; /** * @remarks - * Represents the promethium element in Minecraft Education - * experiences. + * 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. * */ - static readonly element61: BlockType; + isEmpty(): boolean; /** * @remarks - * Represents the samarium element in Minecraft Education - * experiences. + * 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. * */ - static readonly element62: BlockType; + isInside(worldLocation: Vector3): boolean; /** * @remarks - * Represents the europium element in Minecraft Education - * experiences. + * 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 */ - static readonly element63: BlockType; + peekLastVolume(forceRelativity?: CompoundBlockVolumePositionRelativity): CompoundBlockVolumeItem | undefined; /** * @remarks - * Represents the gadolinium element in Minecraft Education - * experiences. + * 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. * */ - static readonly element64: BlockType; + popVolume(): boolean; /** * @remarks - * Represents a terbium element in Minecraft Education - * experiences. + * 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 */ - static readonly element65: BlockType; + pushVolume(item: CompoundBlockVolumeItem): void; /** * @remarks - * Represents the dysprosium element in Minecraft Education - * experiences. + * 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 */ - static readonly element66: BlockType; + replaceOrAddLastVolume(item: CompoundBlockVolumeItem): boolean; /** * @remarks - * Represents the holmium element in Minecraft Education - * experiences. + * 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} */ - static readonly element67: BlockType; + translateOrigin(delta: Vector3, preserveExistingVolumes?: boolean): void; +} + +/** + * Represents a container that can hold sets of items. Used + * with entities such as Players, Chest Minecarts, Llamas, and + * more. + * @example containers.js + * ```typescript + * let leftLocation = test.worldLocation({ x: 2, y: 2, z: 2 }); // left chest location + * let rightLocation = test.worldLocation({ x: 4, y: 2, z: 2 }); // right chest location + * + * const chestCart = test.spawn("chest_minecart", { x: 6, y: 2, z: 2 }); + * + * let leftChestBlock = defaultDimension.getBlock(leftLocation); + * let rightChestBlock = defaultDimension.getBlock(rightLocation); + * + * leftChestBlock.setType(MinecraftBlockTypes.chest); + * rightChestBlock.setType(MinecraftBlockTypes.chest); + * + * const rightChestInventoryComp = rightChestBlock.getComponent("inventory"); + * const leftChestInventoryComp = leftChestBlock.getComponent("inventory"); + * const chestCartInventoryComp = chestCart.getComponent("inventory"); + * + * const rightChestContainer = rightChestInventoryComp.container; + * const leftChestContainer = leftChestInventoryComp.container; + * const chestCartContainer = chestCartInventoryComp.container; + * + * rightChestContainer.setItem(0, new ItemStack(Items.apple, 10, 0)); + * test.assert(rightChestContainer.getItem(0).id === "apple", "Expected apple in right container slot index 0"); + * + * rightChestContainer.setItem(1, new ItemStack(Items.emerald, 10, 0)); + * test.assert(rightChestContainer.getItem(1).id === "emerald", "Expected emerald in right container slot index 1"); + * + * test.assert(rightChestContainer.size === 27, "Unexpected size: " + rightChestContainer.size); + * test.assert( + * rightChestContainer.emptySlotsCount === 25, + * "Unexpected emptySlotsCount: " + rightChestContainer.emptySlotsCount + * ); + * + * const itemStack = rightChestContainer.getItem(0); + * test.assert(itemStack.id === "apple", "Expected apple"); + * test.assert(itemStack.amount === 10, "Expected 10 apples"); + * test.assert(itemStack.data === 0, "Expected 0 data"); + * + * leftChestContainer.setItem(0, new ItemStack(Items.cake, 10, 0)); + * + * rightChestContainer.transferItem(0, 4, chestCartContainer); // transfer the apple from the right chest to a chest cart + * rightChestContainer.swapItems(1, 0, leftChestContainer); // swap the cake and emerald + * + * test.assert(chestCartContainer.getItem(4).id === "apple", "Expected apple in left container slot index 4"); + * test.assert(leftChestContainer.getItem(0).id === "emerald", "Expected emerald in left container slot index 0"); + * test.assert(rightChestContainer.getItem(1).id === "cake", "Expected cake in right container slot index 1"); + * + * ``` + */ +export class Container { + private constructor(); /** * @remarks - * Represents the erbium element in Minecraft Education - * experiences. + * Count of the slots in the container that are empty. * + * @throws + * Throws if the container is invalid. */ - static readonly element68: BlockType; + readonly emptySlotsCount: number; /** * @remarks - * Represents the thulium element in Minecraft Education - * experiences. + * 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. */ - static readonly element69: BlockType; + readonly size: number; /** * @remarks - * Represents the nitrogen element in Minecraft Education - * experiences. + * 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. */ - static readonly element7: BlockType; + addItem(itemStack: ItemStack): ItemStack | undefined; /** * @remarks - * Represents the ytterbium element in Minecraft Education - * experiences. + * Clears all inventory items in the container. + * + * This function can't be called in read-only mode. * + * @throws + * Throws if the container is invalid. */ - static readonly element70: BlockType; + clearAll(): void; /** * @remarks - * Represents the lutetium element in Minecraft Education - * experiences. + * 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 + * // A function that gets a copy of the first item in the player's hotbar + * import { Player, EntityInventoryComponent, ItemStack } from '@minecraft/server'; + * + * function getFirstHotbarItem(player: Player): ItemStack | undefined { + * const inventory = player.getComponent(EntityInventoryComponent.componentId); + * if (inventory && inventory.container) { + * return inventory.container.getItem(0); + * } + * return undefined; + * } + * ``` */ - static readonly element71: BlockType; + getItem(slot: number): ItemStack | undefined; /** * @remarks - * Represents a hafnium element in Minecraft Education - * experiences. + * 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. */ - static readonly element72: BlockType; + getSlot(slot: number): ContainerSlot; /** * @remarks - * Represents the tantalum element in Minecraft Education - * experiences. + * Returns whether a container object (or the entity or block + * that this container is associated with) is still available + * for use in this context. * */ - static readonly element73: BlockType; + isValid(): boolean; /** * @remarks - * Represents the tungsten element in Minecraft Education - * experiences. + * 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 + * // A function that moves an item from one slot of the player's inventory to another player's inventory + * import { Player, EntityComponentTypes } from '@minecraft/server'; * + * function moveBetweenPlayers(slotId: number, fromPlayer: Player, toPlayer: Player) { + * const fromInventory = fromPlayer.getComponent(EntityComponentTypes.Inventory); + * const toInventory = toPlayer.getComponent(EntityComponentTypes.Inventory); + * + * if (fromInventory && toInventory && fromInventory.container && toInventory.container) { + * fromInventory.container.moveItem(slotId, slotId, toInventory.container); + * } + * } + * ``` */ - static readonly element74: BlockType; + moveItem(fromSlot: number, toSlot: number, toContainer: Container): void; /** * @remarks - * Represents the rhenium element in Minecraft Education - * experiences. + * 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. */ - static readonly element75: BlockType; + setItem(slot: number, itemStack?: ItemStack): void; /** * @remarks - * Represents the osmium element in Minecraft Education - * experiences. + * 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 + * // A function that swaps an item from one slot of the player's inventory to another player's inventory + * import { Player, EntityComponentTypes } from '@minecraft/server'; + * + * function swapBetweenPlayers(slotId: number, fromPlayer: Player, toPlayer: Player) { + * const fromInventory = fromPlayer.getComponent(EntityComponentTypes.Inventory); + * const toInventory = toPlayer.getComponent(EntityComponentTypes.Inventory); * + * if (fromInventory && toInventory && fromInventory.container && toInventory.container) { + * fromInventory.container.swapItems(slotId, slotId, toInventory.container); + * } + * } + * ``` */ - static readonly element76: BlockType; + swapItems(slot: number, otherSlot: number, otherContainer: Container): void; /** * @remarks - * Represents the iridium element in Minecraft Education - * experiences. + * 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. + * @returns + * An itemStack with the items that couldn't be transferred. + * Returns undefined if all items were transferred. + * @throws + * Throws if either this container or `toContainer` are invalid + * or if the `fromSlot` or `toSlot` indices out of bounds. + * @example transferItem.ts + * ```typescript + * // A function that moves an item from one slot of the player's inventory to another player's inventory + * import { Player, EntityComponentTypes } from '@minecraft/server'; + * + * function moveBetweenPlayers(slotId: number, fromPlayer: Player, toPlayer: Player) { + * const fromInventory = fromPlayer.getComponent(EntityComponentTypes.Inventory); + * const toInventory = toPlayer.getComponent(EntityComponentTypes.Inventory); * + * if (fromInventory && toInventory && fromInventory.container && toInventory.container) { + * fromInventory.container.transferItem(slotId, toInventory.container); + * } + * } + * ``` */ - static readonly element77: BlockType; + transferItem(fromSlot: number, toContainer: Container): ItemStack | undefined; +} + +/** + * Represents a slot within a broader container (e.g., entity + * inventory.) + */ +export class ContainerSlot { + private constructor(); /** * @remarks - * Represents the platinum element in Minecraft Education - * experiences. + * 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. */ - static readonly element78: BlockType; + amount: number; /** * @remarks - * Represents the gold element in Minecraft Education - * experiences. + * 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. * + * {@link InvalidContainerSlotError} */ - static readonly element79: BlockType; + readonly isStackable: boolean; /** * @remarks - * Represents the oxygen element in Minecraft Education - * experiences. + * Gets or sets whether the item is kept on death. * - */ - static readonly element8: BlockType; - /** - * @remarks - * Represents the mercury element in Minecraft Education - * experiences. + * This property can't be edited in read-only mode. * + * @throws + * Throws if the slot's container is invalid. */ - static readonly element80: BlockType; + keepOnDeath: boolean; /** * @remarks - * Represents the thallium element in Minecraft Education - * experiences. + * Gets or sets the item's lock mode. The default value is + * `ItemLockMode.none`. * - */ - static readonly element81: BlockType; - /** - * @remarks - * Represents the lead element in Minecraft Education - * experiences. + * This property can't be edited in read-only mode. * + * @throws + * Throws if the slot's container is invalid. */ - static readonly element82: BlockType; + lockMode: ItemLockMode; /** * @remarks - * Represents the bismuth element in Minecraft Education - * experiences. + * 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. * - */ - static readonly element83: BlockType; - /** - * @remarks - * Represents the polonium element in Minecraft Education - * experiences. + * @throws + * Throws if the slot's container is invalid. * + * {@link InvalidContainerSlotError} */ - static readonly element84: BlockType; + readonly maxAmount: number; /** * @remarks - * Represents the astatine element in Minecraft Education - * experiences. + * 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. * - */ - static readonly element85: BlockType; - /** - * @remarks - * Represents the radon element in Minecraft Education - * experiences. + * 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. */ - static readonly element86: BlockType; + nameTag?: string; /** * @remarks - * Represents the francium element in Minecraft Education - * experiences. + * The type of the item. * - */ - static readonly element87: BlockType; - /** - * @remarks - * Represents the radium element in Minecraft Education - * experiences. + * @throws + * Throws if the slot's container is invalid. * - */ - static readonly element88: BlockType; - /** - * @remarks - * Represents the actinium element in Minecraft Education - * experiences. + * {@link minecraftcommon.EngineError} * + * {@link InvalidContainerSlotError} */ - static readonly element89: BlockType; + readonly 'type': ItemType; /** * @remarks - * Represents the fluorine element in Minecraft Education - * experiences. + * Identifier of the type of items for the stack. If a + * namespace is not specified, 'minecraft:' is assumed. + * Examples include 'wheat' or 'apple'. * - */ - static readonly element9: BlockType; - /** - * @remarks - * Represents the thorium element in Minecraft Education - * experiences. + * @throws + * Throws if the slot's container is invalid. * + * {@link InvalidContainerSlotError} */ - static readonly element90: BlockType; + readonly typeId: string; /** * @remarks - * Represents the protactinium element in Minecraft Education - * experiences. + * Clears all dynamic properties that have been set on this + * item stack. * - */ - static readonly element91: BlockType; - /** - * @remarks - * Represents the uranium element in Minecraft Education - * experiences. + * @throws + * Throws if the slot's container is invalid. * + * {@link InvalidContainerSlotError} */ - static readonly element92: BlockType; + clearDynamicProperties(): void; /** - * @remarks - * Represents the neptunium element in Minecraft Education - * experiences. + * @throws This function can throw errors. * + * {@link InvalidContainerSlotError} */ - static readonly element93: BlockType; + getCanDestroy(): string[]; /** - * @remarks - * Represents the plutonium element in Minecraft Education - * experiences. + * @throws This function can throw errors. * + * {@link InvalidContainerSlotError} */ - static readonly element94: BlockType; + getCanPlaceOn(): string[]; /** * @remarks - * Represents the americium element in Minecraft Education - * experiences. + * Returns a property value. * - */ - static readonly element95: BlockType; - /** - * @remarks - * Represents the curium element in Minecraft Education - * experiences. + * @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 slot's container is invalid. * + * {@link InvalidContainerSlotError} */ - static readonly element96: BlockType; + getDynamicProperty(identifier: string): boolean | number | string | Vector3 | undefined; /** * @remarks - * Represents the berkelium element in Minecraft Education - * experiences. + * Returns the available set of dynamic property identifiers + * that have been used on this item stack. * - */ - static readonly element97: BlockType; - /** - * @remarks - * Represents the californium element in Minecraft Education - * experiences. + * @returns + * A string array of the dynamic properties set on this entity. + * @throws + * Throws if the slot's container is invalid. * + * {@link InvalidContainerSlotError} */ - static readonly element98: BlockType; + getDynamicPropertyIds(): string[]; /** * @remarks - * Represents the einsteinium element in Minecraft Education - * experiences. + * Returns the total size, in bytes, of all the dynamic + * properties that are currently stored for this entity. This + * includes the size of both the key and the value. This can + * be useful for diagnosing performance warning signs - if, for + * example, an entity has many megabytes of associated dynamic + * properties, it may be slow to load on various devices. * - */ - static readonly element99: BlockType; - /** - * @remarks - * Represents a block of emerald within Minecraft. + * @throws + * Throws if the slot's container is invalid. * + * {@link InvalidContainerSlotError} */ - static readonly emeraldBlock: BlockType; + getDynamicPropertyTotalByteCount(): number; /** * @remarks - * Represents a block with embedded emerald ore within - * Minecraft. + * Creates an exact copy of the item stack, including any + * custom data or properties. * - */ - static readonly emeraldOre: BlockType; - /** - * @remarks - * Represents an enchanting table within Minecraft. + * @returns + * Returns a copy of the item in the slot. Returns undefined if + * the slot is empty. + * @throws + * Throws if the slot's container is invalid. * + * {@link InvalidContainerSlotError} */ - static readonly enchantingTable: BlockType; + getItem(): ItemStack | undefined; /** * @remarks - * Represents an end bricks block within Minecraft. + * 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. * + * {@link InvalidContainerSlotError} */ - static readonly endBricks: BlockType; + getLore(): string[]; /** * @remarks - * Represents a set of end brick stairs within Minecraft. + * 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 + * Throws if the slot's container is invalid. * + * {@link InvalidContainerSlotError} */ - static readonly endBrickStairs: BlockType; + getTags(): string[]; /** - * @remarks - * Represents an ender chest within Minecraft. + * @throws This function can throw errors. * + * {@link InvalidContainerSlotError} */ - static readonly enderChest: BlockType; + hasItem(): boolean; /** * @remarks - * Represents an end gateway within Minecraft. + * 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 + * Throws if the slot's container is invalid. * + * {@link InvalidContainerSlotError} */ - static readonly endGateway: BlockType; + hasTag(tag: string): boolean; /** * @remarks - * Represents an end portal block within Minecraft. + * 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. * + * {@link InvalidContainerSlotError} */ - static readonly endPortal: BlockType; + isStackableWith(itemStack: ItemStack): boolean; /** * @remarks - * Represents an end portal frame within Minecraft. + * Returns whether the ContainerSlot is valid. The container + * slot is valid if the container exists and is loaded, and the + * slot index is valid. * */ - static readonly endPortalFrame: BlockType; + isValid(): boolean; /** * @remarks - * Represents an end rod within Minecraft. + * 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. + * + * {@link Error} * + * {@link InvalidContainerSlotError} */ - static readonly endRod: BlockType; + setCanDestroy(blockIdentifiers?: string[]): void; /** * @remarks - * Represents an end stone block within Minecraft. + * 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. + * + * {@link Error} * + * {@link InvalidContainerSlotError} */ - static readonly endStone: BlockType; + setCanPlaceOn(blockIdentifiers?: string[]): void; /** * @remarks - * Represents a block of exposed copper within Minecraft. + * Sets a specified property to a value. + * + * @param identifier + * The property identifier. + * @param value + * Data value of the property to set. + * @throws + * Throws if the slot's container is invalid. * + * {@link Error} + * + * {@link InvalidContainerSlotError} */ - static readonly exposedCopper: BlockType; + setDynamicProperty(identifier: string, value?: boolean | number | string | Vector3): void; /** * @remarks - * Represents a block of exposed cut copper within Minecraft. + * 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 + * Throws if the slot's container is invalid. * + * {@link InvalidContainerSlotError} */ - static readonly exposedCutCopper: BlockType; + setItem(itemStack?: ItemStack): void; /** * @remarks - * Represents a slab of exposed cut copper within Minecraft. + * 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. + * + * {@link Error} * + * {@link InvalidContainerSlotError} */ - static readonly exposedCutCopperSlab: BlockType; + setLore(loreList?: string[]): void; +} + +/** + * 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 - * Represents a set of exposed cut copper stairs within - * Minecraft. + * Entity that the event triggered on. * */ - static readonly exposedCutCopperStairs: BlockType; + readonly entity: Entity; /** * @remarks - * Represents a double slab of exposed cut copper within - * Minecraft. + * Name of the data driven event being triggered. * */ - static readonly exposedDoubleCutCopperSlab: BlockType; + readonly eventId: string; /** * @remarks - * Represents a farmland block within Minecraft. + * An updateable list of modifications to component state that + * are the effect of this triggered event. * */ - static readonly farmland: BlockType; + getModifiers(): DefinitionModifier[]; +} + +/** + * 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 - * Represents a fence gate within Minecraft. + * 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. * */ - static readonly fenceGate: BlockType; + subscribe( + callback: (arg: DataDrivenEntityTriggerAfterEvent) => void, + options?: EntityDataDrivenTriggerEventOptions, + ): (arg: DataDrivenEntityTriggerAfterEvent) => void; /** * @remarks - * Represents a fire within Minecraft. + * 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. */ - static readonly fire: BlockType; - static readonly fireCoral: BlockType; + unsubscribe(callback: (arg: DataDrivenEntityTriggerAfterEvent) => void): void; +} + +/** + * A class that represents a particular dimension (e.g., The + * End) within a world. + */ +export class Dimension { + private constructor(); /** * @remarks - * Represents a fletching table within Minecraft. + * Height range of the dimension. * + * @throws This property can throw when used. */ - static readonly fletchingTable: BlockType; + readonly heightRange: minecraftcommon.NumberRange; /** * @remarks - * Represents a flowering azalea plant within Minecraft. + * Identifier of the dimension. * */ - static readonly floweringAzalea: BlockType; + readonly id: string; /** - * @remarks - * Represents a flower pot within Minecraft. + * @beta + * @throws This function can throw errors. + * + * {@link Error} * + * {@link UnloadedChunksError} */ - static readonly flowerPot: BlockType; + containsBlock(volume: BlockVolumeBase, filter: BlockFilter, allowUnloadedChunks?: boolean): boolean; /** * @remarks - * Represents flowing lava within Minecraft. + * 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. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} + * @example createExplosions.ts + * ```typescript + * // Creates an explosion of radius 15 that does not break blocks + * import { DimensionLocation } from '@minecraft/server'; + * + * function createExplosions(location: DimensionLocation) { + * // Creates an explosion of radius 15 that does not break blocks + * location.dimension.createExplosion(location, 15, { breaksBlocks: false }); + * + * // Creates an explosion of radius 15 that does not cause fire + * location.dimension.createExplosion(location, 15, { causesFire: true }); * + * // Creates an explosion of radius 10 that can go underwater + * location.dimension.createExplosion(location, 10, { allowUnderwater: true }); + * } + * ``` */ - static readonly flowingLava: BlockType; + createExplosion(location: Vector3, radius: number, explosionOptions?: ExplosionOptions): boolean; /** + * @beta * @remarks - * Represents flowing water within Minecraft. + * Fills an area between begin and end with block of type + * block. + * + * This function can't be called in read-only mode. + * + * @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. + * + * {@link minecraftcommon.EngineError} * - */ - static readonly flowingWater: BlockType; - /** - * @remarks - * Represents a frame within Minecraft. + * {@link Error} * + * {@link UnloadedChunksError} */ - static readonly frame: BlockType; - static readonly frogSpawn: BlockType; + fillBlocks( + volume: BlockVolumeBase | CompoundBlockVolume, + block: BlockPermutation | BlockType | string, + options?: BlockFillOptions, + ): ListBlockVolume; /** + * @beta * @remarks - * Represents a frosted ice block within Minecraft. + * Finds the location of the closest biome of a particular + * type. Note that the findClosestBiome operation can take some + * time to complete, so avoid using many of these calls within + * a particular tick. * - */ - static readonly frostedIce: BlockType; - /** - * @remarks - * Represents a furnace within Minecraft. + * This function can't be called in read-only mode. * - */ - static readonly furnace: BlockType; - /** - * @remarks - * Represents a block of gilded blackstone within Minecraft. + * @param pos + * Starting location to look for a biome to find. + * @param biomeToFind + * Identifier of the biome to look for. + * @param options + * Additional selection criteria for a biome search. + * @returns + * Returns a location of the biome, or undefined if a biome + * could not be found. + * @throws This function can throw errors. * - */ - static readonly gildedBlackstone: BlockType; - /** - * @remarks - * Represents a glass block within Minecraft. + * {@link minecraftcommon.EngineError} * + * {@link Error} */ - static readonly glass: BlockType; + findClosestBiome(pos: Vector3, biomeToFind: BiomeType | string, options?: BiomeSearchOptions): Vector3 | undefined; /** * @remarks - * Represents a pane of glass within Minecraft. + * Returns a block instance at the given location. * - */ - static readonly glassPane: BlockType; - /** - * @remarks - * Represents a glowing frame within Minecraft. + * @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 * - */ - static readonly glowFrame: BlockType; - /** - * @remarks - * Represents a glowing obsidian block within Minecraft. + * PositionOutOfWorldBoundariesError: Exception thrown when + * trying to interact with a position outside of dimension + * height range * - */ - static readonly glowingobsidian: BlockType; - /** - * @remarks - * Represents glow lichen within Minecraft. * - */ - static readonly glowLichen: BlockType; - /** - * @remarks - * Represents a block of glowstone within Minecraft. + * {@link LocationInUnloadedChunkError} * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly glowstone: BlockType; + getBlock(location: Vector3): Block | undefined; /** * @remarks - * Represents a gold block within Minecraft. + * 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. + * @throws This function can throw errors. */ - static readonly goldBlock: BlockType; + getBlockFromRay(location: Vector3, direction: Vector3, options?: BlockRaycastOptions): BlockRaycastHit | undefined; /** - * @remarks - * Represents a golden rail element within Minecraft. + * @beta + * @throws This function can throw errors. * - */ - static readonly goldenRail: BlockType; - /** - * @remarks - * Represents a block with embedded gold ore within Minecraft. + * {@link Error} * + * {@link UnloadedChunksError} */ - static readonly goldOre: BlockType; + getBlocks(volume: BlockVolumeBase, filter: BlockFilter, allowUnloadedChunks?: boolean): ListBlockVolume; /** * @remarks - * Represents a set of granite stairs within Minecraft. + * 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 checkFeatherNearby.ts + * ```typescript + * import { DimensionLocation, EntityComponentTypes } from "@minecraft/server"; + * + * // Returns true if a feather item entity is within 'distance' blocks of 'location'. + * function isFeatherNear(location: DimensionLocation, distance: number): boolean { + * const items = location.dimension.getEntities({ + * location: location, + * maxDistance: 20, + * }); + * + * for (const item of items) { + * const itemComp = item.getComponent(EntityComponentTypes.Item); + * + * if (itemComp) { + * if (itemComp.itemStack.typeId.endsWith('feather')) { + * return true; + * } + * } + * } + * + * return false; + * } + * ``` + * @example tagsQuery.ts + * ```typescript + * import { EntityQueryOptions, DimensionLocation } from '@minecraft/server'; + * + * function mobParty(targetLocation: DimensionLocation) { + * const mobs = ['creeper', 'skeleton', 'sheep']; + * + * // create some sample mob data + * for (let i = 0; i < 10; i++) { + * const mobTypeId = mobs[i % mobs.length]; + * const entity = targetLocation.dimension.spawnEntity(mobTypeId, targetLocation); + * entity.addTag('mobparty.' + mobTypeId); + * } + * + * const eqo: EntityQueryOptions = { + * tags: ['mobparty.skeleton'], + * }; + * + * for (const entity of targetLocation.dimension.getEntities(eqo)) { + * entity.kill(); + * } + * } + * ``` */ - static readonly graniteStairs: BlockType; + getEntities(options?: EntityQueryOptions): Entity[]; /** * @remarks - * Represents a block of dirt and grass within Minecraft. + * 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. */ - static readonly grass: BlockType; + getEntitiesAtBlockLocation(location: Vector3): Entity[]; /** * @remarks - * Represents a block of dirt and grass with a path within - * Minecraft. + * Gets entities that intersect with a specified vector + * emanating from a location. * + * @param options + * Additional options for processing this raycast query. + * @throws This function can throw errors. */ - static readonly grassPath: BlockType; + getEntitiesFromRay(location: Vector3, direction: Vector3, options?: EntityRaycastOptions): EntityRaycastHit[]; /** * @remarks - * Represents a block of gravel within Minecraft. + * 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. */ - static readonly gravel: BlockType; + getPlayers(options?: EntityQueryOptions): Player[]; /** + * @beta * @remarks - * Represents a gray-colored candle within Minecraft. + * Returns the current weather. * - */ - static readonly grayCandle: BlockType; - /** - * @remarks - * Represents a cake with gray-colored candle within Minecraft. + * This function can't be called in read-only mode. * + * @returns + * Returns a WeatherType that explains the broad category of + * weather that is currently going on. */ - static readonly grayCandleCake: BlockType; - static readonly grayCarpet: BlockType; + getWeather(): WeatherType; /** + * @beta * @remarks - * Represents a gray-colored block of glazed terracotta within - * Minecraft. + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly grayGlazedTerracotta: BlockType; - static readonly grayWool: BlockType; + playSound(soundId: string, location: Vector3, soundOptions?: WorldSoundOptions): void; /** * @remarks - * Represents a green-colored candle within Minecraft. + * Runs a command synchronously using the context of the + * broader dimenion. * - */ - static readonly greenCandle: BlockType; - /** - * @remarks - * Represents a green-colored candle cake within Minecraft. + * This function can't be called in read-only mode. * - */ - static readonly greenCandleCake: BlockType; - static readonly greenCarpet: BlockType; - /** - * @remarks - * Represents a green block of glazed terracotta within - * Minecraft. + * @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} */ - static readonly greenGlazedTerracotta: BlockType; - static readonly greenWool: BlockType; + runCommand(commandString: string): CommandResult; /** * @remarks - * Represents a grindstone within Minecraft. + * 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. */ - static readonly grindstone: BlockType; + runCommandAsync(commandString: string): Promise; /** + * @beta * @remarks - * Represents a set of hanging roots within Minecraft. + * This function can't be called in read-only mode. * - */ - static readonly hangingRoots: BlockType; - /** - * @remarks - * Represents a block of hardened clay within Minecraft. + * @throws This function can throw errors. * - */ - static readonly hardenedClay: BlockType; - /** - * @remarks - * Represents a block of hard glass within Minecraft. + * {@link LocationInUnloadedChunkError} * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly hardGlass: BlockType; + setBlockPermutation(location: Vector3, permutation: BlockPermutation): void; /** + * @beta * @remarks - * Represents a pane of hard glass within Minecraft. + * This function can't be called in read-only mode. * - */ - static readonly hardGlassPane: BlockType; - /** - * @remarks - * Represents a stained hard glass block within Minecraft. + * @throws This function can throw errors. + * + * {@link Error} + * + * {@link LocationInUnloadedChunkError} * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly hardStainedGlass: BlockType; + setBlockType(location: Vector3, blockType: BlockType | string): void; /** * @remarks - * Represents a stained pane of hard glass within Minecraft. + * 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. */ - static readonly hardStainedGlassPane: BlockType; + setWeather(weatherType: WeatherType, duration?: number): void; /** * @remarks - * Represents a block of hay within Minecraft. + * 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 + * // Spawns an adult horse + * import { DimensionLocation } from '@minecraft/server'; * + * function spawnAdultHorse(location: DimensionLocation) { + * // Create a horse and triggering the 'ageable_grow_up' event, ensuring the horse is created as an adult + * location.dimension.spawnEntity('minecraft:horse', location); + * } + * ``` + * @example quickFoxLazyDog.ts + * ```typescript + * // Spawns a fox over a dog + * import { DimensionLocation } from '@minecraft/server'; + * import { MinecraftEntityTypes } from '@minecraft/vanilla-data'; + * + * function spawnAdultHorse(location: DimensionLocation) { + * // Create fox (our quick brown fox) + * const fox = location.dimension.spawnEntity(MinecraftEntityTypes.Fox, { + * x: location.x, + * y: location.y + 2, + * z: location.z, + * }); + * + * fox.addEffect('speed', 10, { + * amplifier: 2, + * }); + * + * // Create wolf (our lazy dog) + * const wolf = location.dimension.spawnEntity(MinecraftEntityTypes.Wolf, location); + * wolf.addEffect('slowness', 10, { + * amplifier: 2, + * }); + * wolf.isSneaking = true; + * } + * ``` */ - static readonly hayBlock: BlockType; + spawnEntity(identifier: string, location: Vector3, options?: SpawnEntityOptions): Entity; /** * @remarks - * Represents a heavy weighted pressure plate within Minecraft. + * 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 spawnFeatherItem.ts + * ```typescript + * // Spawns a feather at a location + * import { ItemStack, DimensionLocation } from '@minecraft/server'; + * import { MinecraftItemTypes } from '@minecraft/vanilla-data'; + * + * function spawnFeather(location: DimensionLocation) { + * const featherItem = new ItemStack(MinecraftItemTypes.Feather, 1); + * location.dimension.spawnItem(featherItem, location); + * } + * ``` */ - static readonly heavyWeightedPressurePlate: BlockType; + spawnItem(itemStack: ItemStack, location: Vector3): Entity; /** * @remarks - * Represents a block of honey within Minecraft. + * 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 + * // A function that spawns a particle at a random location near the target location for all players in the server + * import { world, MolangVariableMap, DimensionLocation, Vector3 } from '@minecraft/server'; + * + * function spawnConfetti(location: DimensionLocation) { + * for (let i = 0; i < 100; i++) { + * const molang = new MolangVariableMap(); + * + * molang.setColorRGB('variable.color', { + * red: Math.random(), + * green: Math.random(), + * blue: Math.random() + * }); + * + * const newLocation: Vector3 = { + * x: location.x + Math.floor(Math.random() * 8) - 4, + * y: location.y + Math.floor(Math.random() * 8) - 4, + * z: location.z + Math.floor(Math.random() * 8) - 4, + * }; + * location.dimension.spawnParticle('minecraft:colored_flame_particle', newLocation, molang); + * } + * } + * ``` */ - static readonly honeyBlock: BlockType; + spawnParticle(effectName: string, location: Vector3, molangVariables?: MolangVariableMap): void; +} + +/** + * Represents a type of dimension. + */ +export class DimensionType { + private constructor(); /** * @remarks - * Represents a honeycomb block within Minecraft. + * Identifier of the dimension type. * */ - static readonly honeycombBlock: BlockType; + readonly typeId: string; +} + +/** + * Used for accessing all available dimension types. + */ +export class DimensionTypes { + private constructor(); /** * @remarks - * Represents a hopper within Minecraft. + * Retrieves a dimension type using a string-based identifier. * */ - static readonly hopper: BlockType; - static readonly hornCoral: BlockType; + static get(dimensionTypeId: string): DimensionType | undefined; /** * @remarks - * Represents a block of ice within Minecraft. + * Retrieves an array of all dimension types. * */ - static readonly ice: BlockType; + static getAll(): DimensionType[]; +} + +/** + * Represents an effect - like poison - that has been added to + * an Entity. + */ +export class Effect { + private constructor(); /** * @remarks - * Represents an infested block of deepslate within Minecraft. + * 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. */ - static readonly infestedDeepslate: BlockType; + readonly amplifier: number; /** * @remarks - * Represents an information update block within Minecraft. + * Gets the player-friendly name of this effect. * + * @throws This property can throw when used. */ - static readonly infoUpdate: BlockType; + readonly displayName: string; /** * @remarks - * Represents an information update block within Minecraft. + * 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. */ - static readonly infoUpdate2: BlockType; + readonly duration: number; /** * @remarks - * Represents an invisible boundary bedrock block within - * Minecraft. + * Gets the type id of this effect. * + * @throws This property can throw when used. */ - static readonly invisibleBedrock: BlockType; + readonly typeId: string; /** * @remarks - * Represents iron bars within Minecraft. + * Returns whether an effect instance is available for use in + * this context. * */ - static readonly ironBars: BlockType; + isValid(): boolean; +} + +/** + * Contains information related to changes to an effect - like + * poison - being added to an entity. + */ +export class EffectAddAfterEvent { + private constructor(); /** * @remarks - * Represents a block of iron within Minecraft. + * Additional properties and details of the effect. * */ - static readonly ironBlock: BlockType; + readonly effect: Effect; /** * @remarks - * Represents an iron door within Minecraft. + * Entity that the effect is being added to. * */ - static readonly ironDoor: BlockType; + readonly entity: Entity; +} + +/** + * Manages callbacks that are connected to when an effect is + * added to an entity. + */ +export class EffectAddAfterEventSignal { + private constructor(); /** * @remarks - * Represents a block with embedded iron ore within Minecraft. + * 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. * */ - static readonly ironOre: BlockType; + subscribe( + callback: (arg: EffectAddAfterEvent) => void, + options?: EntityEventOptions, + ): (arg: EffectAddAfterEvent) => void; /** * @remarks - * Represents an iron trapdoor within Minecraft. + * 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. */ - static readonly ironTrapdoor: BlockType; + unsubscribe(callback: (arg: EffectAddAfterEvent) => void): void; +} + +/** + * Contains information related to changes to an effect - like + * poison - being added to an entity. + */ +export class EffectAddBeforeEvent { + private constructor(); /** * @remarks - * Represents a jigsaw within Minecraft. + * When set to true will cancel the event. * */ - static readonly jigsaw: BlockType; + cancel: boolean; /** * @remarks - * Represents a jukebox within Minecraft. + * Effect duration. * */ - static readonly jukebox: BlockType; + duration: number; /** * @remarks - * Represents jungle wood button within Minecraft. + * The type of the effect that is being added. * */ - static readonly jungleButton: BlockType; + readonly effectType: string; /** * @remarks - * Represents a jungle wood door within Minecraft. + * Entity that the effect is being added to. * */ - static readonly jungleDoor: BlockType; - static readonly jungleFence: BlockType; + readonly entity: Entity; +} + +/** + * Manages callbacks that are connected to when an effect is + * added to an entity. + */ +export class EffectAddBeforeEventSignal { + private constructor(); /** * @remarks - * Represents a jungle wood fence gate within Minecraft. + * Adds a callback that will be called when an effect is added + * to an entity. * - */ - static readonly jungleFenceGate: BlockType; - static readonly jungleHangingSign: BlockType; - static readonly jungleLog: BlockType; - /** - * @remarks - * Represents a jungle wood pressure plate within Minecraft. + * This function can't be called in read-only mode. * */ - static readonly junglePressurePlate: BlockType; + subscribe(callback: (arg: EffectAddBeforeEvent) => void): (arg: EffectAddBeforeEvent) => void; /** * @remarks - * Represents a set of jungle wood stairs within Minecraft. + * Removes a callback from being called when an effect is added + * to an entity. * - */ - static readonly jungleStairs: BlockType; - /** - * @remarks - * Represents a jungle wood standing sign within Minecraft. + * This function can't be called in read-only mode. * */ - static readonly jungleStandingSign: BlockType; + unsubscribe(callback: (arg: EffectAddBeforeEvent) => void): void; +} + +/** + * Represents a type of effect - like poison - that can be + * applied to an entity. + */ +export class EffectType { + private constructor(); /** * @remarks - * Represents a jungle wood trapdoor within Minecraft. + * Identifier name of this effect type. * + * @returns + * Identifier of the effect type. */ - static readonly jungleTrapdoor: BlockType; + getName(): string; +} + +/** + * Represents a type of effect - like poison - that can be + * applied to an entity. + */ +export class EffectTypes { + private constructor(); /** * @remarks - * Represents a jungle wood wall sign within Minecraft. + * 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 readonly jungleWallSign: BlockType; + static get(identifier: string): EffectType | undefined; /** * @remarks - * Represents a set of kelp within Minecraft. + * Gets all effects. * + * This function can't be called in read-only mode. + * + * @returns + * A list of all effects. */ - static readonly kelp: BlockType; + static getAll(): EffectType[]; +} + +/** + * @beta + * Contains information on a type of enchantment. + */ +export class EnchantmentType { /** * @remarks - * Represents a ladder within Minecraft. + * The name of the enchantment type. * */ - static readonly ladder: BlockType; + readonly id: string; /** * @remarks - * Represents a lantern within Minecraft. + * The maximum level this type of enchantment can have. * */ - static readonly lantern: BlockType; + readonly maxLevel: number; /** - * @remarks - * Represents a block of lapis lazuli within Minecraft. - * + * @throws This function can throw errors. */ - static readonly lapisBlock: BlockType; + constructor(enchantmentType: string); +} + +/** + * @beta + * Contains a catalog of Minecraft Enchantment Types that are + * available in this world. + */ +export class EnchantmentTypes { + private constructor(); /** * @remarks - * Represents a block with embedded lapis lazuli within - * Minecraft. + * 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 readonly lapisOre: BlockType; + static get(enchantmentId: string): EnchantmentType | undefined; /** + * @beta * @remarks - * Represents a bud of large amethyst within Minecraft. + * Returns a collection of all available enchantment types. * */ - static readonly largeAmethystBud: BlockType; + static getAll(): EnchantmentType[]; +} + +/** + * 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 - * Represents lava within Minecraft. + * Dimension that the entity is currently within. * + * @throws This property can throw when used. */ - static readonly lava: BlockType; + readonly dimension: Dimension; /** + * @beta * @remarks - * Represents a set of leaves within Minecraft. + * 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. */ - static readonly leaves: BlockType; + readonly fallDistance: number; /** * @remarks - * Represents an updated set of leaves within Minecraft. + * 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. * */ - static readonly leaves2: BlockType; + readonly id: string; /** * @remarks - * Represents a lectern within Minecraft. + * 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. */ - static readonly lectern: BlockType; + readonly isClimbing: boolean; /** * @remarks - * Represents a lever within Minecraft. + * Whether the entity has a fall distance greater than 0, or + * greater than 1 while gliding. * + * @throws This property can throw when used. */ - static readonly lever: BlockType; + readonly isFalling: boolean; /** * @remarks - * Represents a block of light within Minecraft. + * Whether any part of the entity is inside a water block. * + * @throws This property can throw when used. */ - static readonly lightBlock: BlockType; + readonly isInWater: boolean; /** * @remarks - * Represents a light blue candle within Minecraft. + * Whether the entity is on top of a solid block. This property + * may behave in unexpected ways. This property will always be + * true when an Entity is first spawned, and if the Entity has + * no gravity this property may be incorrect. * + * @throws This property can throw when used. */ - static readonly lightBlueCandle: BlockType; + readonly isOnGround: boolean; /** * @remarks - * Represents a light blue candle cake within Minecraft. + * If true, the entity is currently sleeping. * + * @throws This property can throw when used. */ - static readonly lightBlueCandleCake: BlockType; - static readonly lightBlueCarpet: BlockType; + readonly isSleeping: boolean; /** * @remarks - * Represents a light blue block of glazed terracotta within - * Minecraft. + * Whether the entity is sneaking - that is, moving more slowly + * and more quietly. + * + * This property can't be edited in read-only mode. * */ - static readonly lightBlueGlazedTerracotta: BlockType; - static readonly lightBlueWool: BlockType; + isSneaking: boolean; /** * @remarks - * Represents a light gray candle within Minecraft. + * 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. */ - static readonly lightGrayCandle: BlockType; + readonly isSprinting: boolean; /** * @remarks - * Represents a light gray candle cake within Minecraft. + * 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. */ - static readonly lightGrayCandleCake: BlockType; - static readonly lightGrayCarpet: BlockType; - static readonly lightGrayWool: BlockType; + readonly isSwimming: boolean; /** + * @beta * @remarks - * Represents a lightning rod within Minecraft. + * 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. * */ - static readonly lightningRod: BlockType; + readonly lifetimeState: EntityLifetimeState; /** * @remarks - * Represents a light weighted pressure plate within Minecraft. + * Current location of the entity. * + * @throws This property can throw when used. */ - static readonly lightWeightedPressurePlate: BlockType; + readonly location: Vector3; /** * @remarks - * Represents a lime candle within Minecraft. + * Given name of the entity. + * + * This property can't be edited in read-only mode. * */ - static readonly limeCandle: BlockType; + nameTag: string; /** * @remarks - * Represents a lime-colored candle cake within Minecraft. + * Returns a scoreboard identity that represents this entity. + * Will remain valid when the entity is killed. * */ - static readonly limeCandleCake: BlockType; - static readonly limeCarpet: BlockType; + readonly scoreboardIdentity?: ScoreboardIdentity; /** + * @beta * @remarks - * Represents a lime-colored block of glazed terracotta within - * Minecraft. + * Retrieves or sets an entity that is used as the target of + * AI-related behaviors, like attacking. If the entity + * currently has no target returns undefined. * + * @throws This property can throw when used. */ - static readonly limeGlazedTerracotta: BlockType; - static readonly limeWool: BlockType; + readonly target?: Entity; /** * @remarks - * Represents a lit blast furnace within Minecraft. + * Identifier of the type of the entity - for example, + * 'minecraft:skeleton'. This property is accessible even if + * {@link Entity.isValid} is false. * */ - static readonly litBlastFurnace: BlockType; + readonly typeId: string; /** * @remarks - * Represents lit deepslate redstone ore within Minecraft. + * 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 poisonVillager.ts + * ```typescript + * // Spawns a villager and gives it the poison effect + * import { + * DimensionLocation, + * } from '@minecraft/server'; + * import { MinecraftEffectTypes } from '@minecraft/vanilla-data'; * + * function spawnPoisonedVillager(location: DimensionLocation) { + * const villagerType = 'minecraft:villager_v2'; + * const villager = location.dimension.spawnEntity(villagerType, location); + * const duration = 20; + * + * villager.addEffect(MinecraftEffectTypes.Poison, duration, { amplifier: 1 }); + * } + * + * ``` + * @example quickFoxLazyDog.ts + * ```typescript + * // Spawns a fox over a dog + * import { DimensionLocation } from '@minecraft/server'; + * import { MinecraftEntityTypes } from '@minecraft/vanilla-data'; + * + * function spawnAdultHorse(location: DimensionLocation) { + * // Create fox (our quick brown fox) + * const fox = location.dimension.spawnEntity(MinecraftEntityTypes.Fox, { + * x: location.x, + * y: location.y + 2, + * z: location.z, + * }); + * + * fox.addEffect('speed', 10, { + * amplifier: 2, + * }); + * + * // Create wolf (our lazy dog) + * const wolf = location.dimension.spawnEntity(MinecraftEntityTypes.Wolf, location); + * wolf.addEffect('slowness', 10, { + * amplifier: 2, + * }); + * wolf.isSneaking = true; + * } + * ``` */ - static readonly litDeepslateRedstoneOre: BlockType; + addEffect(effectType: EffectType | string, duration: number, options?: EntityEffectOptions): Effect | undefined; /** * @remarks - * Represents a lit furnace within Minecraft. + * 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. */ - static readonly litFurnace: BlockType; + addTag(tag: string): boolean; /** * @remarks - * Represents a lit pumpkin within Minecraft. + * 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 + * // A function that applies damage and then heals the entity + * import { Entity, EntityComponentTypes, system, world } from '@minecraft/server'; + * + * function applyDamageAndHeal(entity: Entity) { + * entity.applyDamage(19); // Many mobs have max damage of 20 so this is a near-death mob + * + * system.runTimeout(() => { + * const health = entity.getComponent(EntityComponentTypes.Health); + * if (health) { + * world.sendMessage(`Entity health before heal: ${health.currentValue}`); * + * health.resetToMaxValue(); + * + * world.sendMessage(`Entity after before heal: ${health.currentValue}`); + * } else { + * console.warn('Entity does not have health component'); + * } + * }, 40); // Run in a few seconds (40 ticks) + * } + * ``` */ - static readonly litPumpkin: BlockType; + applyDamage(amount: number, options?: EntityApplyDamageByProjectileOptions | EntityApplyDamageOptions): boolean; /** * @remarks - * Represents a lit redstone lamp within Minecraft. + * 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 yeetEntity.ts + * ```typescript + * // A function that throws entities up in the air + * import { Entity } from '@minecraft/server'; + * + * function yeetEntity(entity: Entity) { + * + * // Zero out the entity's velocity before applying impulse + * entity.clearVelocity(); * + * // throw the zombie up in the air + * entity.applyImpulse({ x: 0, y: 15, z: 0 }); + * } + * ``` */ - static readonly litRedstoneLamp: BlockType; + applyImpulse(vector: Vector3): void; /** * @remarks - * Represents lit redstone ore within Minecraft. + * 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 + * import { EntityQueryOptions, DimensionLocation } from '@minecraft/server'; + * + * function mobParty(targetLocation: DimensionLocation) { + * const mobs = ['creeper', 'skeleton', 'sheep']; + * + * // create some sample mob data + * for (let i = 0; i < 10; i++) { + * targetLocation.dimension.spawnEntity(mobs[i % mobs.length], targetLocation); + * } + * + * const eqo: EntityQueryOptions = { + * type: 'skeleton', + * }; * + * for (const entity of targetLocation.dimension.getEntities(eqo)) { + * entity.applyKnockback(0, 0, 0, 1); + * } + * } + * ``` */ - static readonly litRedstoneOre: BlockType; + applyKnockback(directionX: number, directionZ: number, horizontalStrength: number, verticalStrength: number): void; /** * @remarks - * Represents a lit smoker within Minecraft. + * Clears all dynamic properties that have been set on this + * entity. * + * @throws This function can throw errors. */ - static readonly litSmoker: BlockType; + clearDynamicProperties(): void; /** * @remarks - * Represents a lodestone within Minecraft. + * 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 yeetEntity.ts + * ```typescript + * // A function that throws entities up in the air + * import { Entity } from '@minecraft/server'; + * + * function yeetEntity(entity: Entity) { + * + * // Zero out the entity's velocity before applying impulse + * entity.clearVelocity(); + * + * // throw the zombie up in the air + * entity.applyImpulse({ x: 0, y: 15, z: 0 }); + * } + * ``` */ - static readonly lodestone: BlockType; + clearVelocity(): void; /** * @remarks - * Represents a loom within Minecraft. + * 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 setEntityOnFire.ts + * ```typescript + * import { world, Entity, EntityComponentTypes, system } from "@minecraft/server"; + * + * function setAblaze(entity: Entity) { + * entity.setOnFire(20, true); * + * system.runTimeout(() => { + * const onfire = entity.getComponent(EntityComponentTypes.OnFire); + * if (onfire) { + * world.sendMessage(`${onfire.onFireTicksRemaining} fire ticks remaining, extinguishing the entity.`); + * } + * // This will extinguish the entity + * entity.extinguishFire(true); + * }, 30); // Run in 30 ticks or ~1.5 seconds + * + * } + * ``` */ - static readonly loom: BlockType; + extinguishFire(useEffects?: boolean): boolean; /** * @remarks - * Represents a magenta candle within Minecraft. + * 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. */ - static readonly magentaCandle: BlockType; + getBlockFromViewDirection(options?: BlockRaycastOptions): BlockRaycastHit | undefined; /** * @remarks - * Represents a magenta candle cake within Minecraft. + * Gets a component (that represents additional capabilities) + * for an entity. * + * @param componentId + * The identifier of the component (e.g., 'minecraft:health'). + * If no namespace prefix is specified, 'minecraft:' is + * assumed. Available component IDs can be found as part of the + * {@link EntityComponentTypes} enum. + * @returns + * Returns the component if it exists on the entity, otherwise + * undefined. */ - static readonly magentaCandleCake: BlockType; - static readonly magentaCarpet: BlockType; + getComponent(componentId: T): EntityComponentTypeMap[T] | undefined; /** * @remarks - * Represents a block of magenta-colored glazed terracotta - * within Minecraft. + * 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. */ - static readonly magentaGlazedTerracotta: BlockType; - static readonly magentaWool: BlockType; + getComponents(): EntityComponent[]; /** * @remarks - * Represents magma within Minecraft. + * 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. */ - static readonly magma: BlockType; - static readonly mangroveButton: BlockType; - static readonly mangroveDoor: BlockType; - static readonly mangroveDoubleSlab: BlockType; - static readonly mangroveFence: BlockType; - static readonly mangroveFenceGate: BlockType; - static readonly mangroveHangingSign: BlockType; - static readonly mangroveLeaves: BlockType; - static readonly mangroveLog: BlockType; - static readonly mangrovePlanks: BlockType; - static readonly mangrovePressurePlate: BlockType; - static readonly mangrovePropagule: BlockType; - static readonly mangroveRoots: BlockType; - static readonly mangroveSlab: BlockType; - static readonly mangroveStairs: BlockType; - static readonly mangroveStandingSign: BlockType; - static readonly mangroveTrapdoor: BlockType; - static readonly mangroveWallSign: BlockType; - static readonly mangroveWood: BlockType; + getDynamicProperty(identifier: string): boolean | number | string | Vector3 | undefined; /** * @remarks - * Represents a medium-sized bud of amethyst within Minecraft. + * Returns the available set of dynamic property identifiers + * that have been used on this entity. * + * @returns + * A string array of the dynamic properties set on this entity. + * @throws This function can throw errors. */ - static readonly mediumAmethystBud: BlockType; + getDynamicPropertyIds(): string[]; /** * @remarks - * Represents a block of melon within Minecraft. + * Returns the total size, in bytes, of all the dynamic + * properties that are currently stored for this entity. This + * includes the size of both the key and the value. This can + * be useful for diagnosing performance warning signs - if, for + * example, an entity has many megabytes of associated dynamic + * properties, it may be slow to load on various devices. * + * @throws This function can throw errors. */ - static readonly melonBlock: BlockType; + getDynamicPropertyTotalByteCount(): number; /** * @remarks - * Represents a stem of melon within Minecraft. + * 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. */ - static readonly melonStem: BlockType; + getEffect(effectType: EffectType | string): Effect | undefined; /** * @remarks - * Represents a mob spawner within Minecraft. + * Returns a set of effects applied to this entity. * + * @returns + * List of effects. + * @throws This function can throw errors. */ - static readonly mobSpawner: BlockType; + getEffects(): Effect[]; /** * @remarks - * Represents a monster egg within Minecraft. + * 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. */ - static readonly monsterEgg: BlockType; + getEntitiesFromViewDirection(options?: EntityRaycastOptions): EntityRaycastHit[]; /** * @remarks - * Represents a block of moss within Minecraft. + * 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. */ - static readonly mossBlock: BlockType; + getHeadLocation(): Vector3; /** * @remarks - * Represents a carpet of moss within Minecraft. + * 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. */ - static readonly mossCarpet: BlockType; + getProperty(identifier: string): boolean | number | string | undefined; /** * @remarks - * Represents a block of cobblestone with moss within - * Minecraft. + * 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. */ - static readonly mossyCobblestone: BlockType; + getRotation(): Vector2; /** * @remarks - * Represents a set of mossy cobblestone stairs within - * Minecraft. + * Returns all tags associated with the entity. * + * @returns + * An array containing all tags as strings. + * @throws This function can throw errors. */ - static readonly mossyCobblestoneStairs: BlockType; + getTags(): string[]; /** * @remarks - * Represents a set of mossy stone brick stairs within - * Minecraft. + * 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 + * // A function that spawns fireworks and logs their velocity after 5 ticks + * import { DimensionLocation, system, world } from '@minecraft/server'; + * import { MinecraftEntityTypes } from '@minecraft/vanilla-data'; + * + * function spawnFireworks(location: DimensionLocation) { + * const fireworkRocket = location.dimension.spawnEntity(MinecraftEntityTypes.FireworksRocket, location); * + * system.runTimeout(() => { + * const velocity = fireworkRocket.getVelocity(); + * + * world.sendMessage(`Velocity of firework is: ${velocity.x}, ${velocity.y}, ${velocity.z}`); + * }, 5); + * } + * ``` */ - static readonly mossyStoneBrickStairs: BlockType; - static readonly movingBlock: BlockType; - static readonly mud: BlockType; - static readonly mudBrickDoubleSlab: BlockType; - static readonly mudBricks: BlockType; - static readonly mudBrickSlab: BlockType; - static readonly mudBrickStairs: BlockType; - static readonly mudBrickWall: BlockType; - static readonly muddyMangroveRoots: BlockType; + getVelocity(): Vector3; /** * @remarks - * Represents a mycelium plant within Minecraft. + * Returns the current view direction of the entity. * + * @returns + * Returns the current view direction of the entity. + * @throws This function can throw errors. */ - static readonly mycelium: BlockType; + getViewDirection(): Vector3; /** * @remarks - * Represents a nether brick block within Minecraft. + * 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. */ - static readonly netherBrick: BlockType; + hasComponent(componentId: string): boolean; /** * @remarks - * Represents a nether brick fence within Minecraft. + * 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. */ - static readonly netherBrickFence: BlockType; + hasTag(tag: string): boolean; /** * @remarks - * Represents a set of nether brick stairs within Minecraft. + * 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. */ - static readonly netherBrickStairs: BlockType; + isValid(): boolean; /** * @remarks - * Represents a block of nether with embedded gold ore within - * Minecraft. + * 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 + * import { EntityQueryOptions, DimensionLocation } from '@minecraft/server'; + * + * function mobParty(targetLocation: DimensionLocation) { + * const mobs = ['creeper', 'skeleton', 'sheep']; + * + * // create some sample mob data + * for (let i = 0; i < 10; i++) { + * const mobTypeId = mobs[i % mobs.length]; + * const entity = targetLocation.dimension.spawnEntity(mobTypeId, targetLocation); + * entity.addTag('mobparty.' + mobTypeId); + * } + * + * const eqo: EntityQueryOptions = { + * tags: ['mobparty.skeleton'], + * }; + * + * for (const entity of targetLocation.dimension.getEntities(eqo)) { + * entity.kill(); + * } + * } + * ``` */ - static readonly netherGoldOre: BlockType; + kill(): boolean; /** * @remarks - * Represents a block of netherite within Minecraft. + * Matches the entity against the passed in options. Uses the + * location of the entity for matching if the location is not + * specified in the passed in EntityQueryOptions. * + * @param options + * The query to perform the match against. + * @returns + * Returns true if the entity matches the criteria in the + * passed in EntityQueryOptions, otherwise it returns false. + * @throws + * Throws if the query options are misconfigured. */ - static readonly netheriteBlock: BlockType; + matches(options: EntityQueryOptions): boolean; /** * @remarks - * Represents a block of netherrack within Minecraft. + * 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. */ - static readonly netherrack: BlockType; + playAnimation(animationName: string, options?: PlayAnimationOptions): void; /** * @remarks - * Represents a nether rock within Minecraft. + * 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. */ - static readonly netherreactor: BlockType; + remove(): void; /** * @remarks - * Represents nether sprouts within Minecraft. + * 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. */ - static readonly netherSprouts: BlockType; + removeEffect(effectType: EffectType | string): boolean; /** * @remarks - * Represents nether wart within Minecraft. + * 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. */ - static readonly netherWart: BlockType; + removeTag(tag: string): boolean; /** * @remarks - * Represents a block of nether wart within Minecraft. + * 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. * + * {@link minecraftcommon.EngineError} + * + * {@link Error} */ - static readonly netherWartBlock: BlockType; + resetProperty(identifier: string): boolean | number | string; /** * @remarks - * Represents a standard set of stone stairs within Minecraft. + * 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} */ - static readonly normalStoneStairs: BlockType; + runCommand(commandString: string): CommandResult; /** * @remarks - * Represents a note block within Minecraft. + * 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. */ - static readonly noteblock: BlockType; - static readonly oakFence: BlockType; - static readonly oakHangingSign: BlockType; - static readonly oakLog: BlockType; + runCommandAsync(commandString: string): Promise; /** * @remarks - * Represents a set of oak stairs within Minecraft. + * 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. */ - static readonly oakStairs: BlockType; + setDynamicProperty(identifier: string, value?: boolean | number | string | Vector3): void; /** * @remarks - * Represents an observer within Minecraft. + * 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 setEntityOnFire.ts + * ```typescript + * import { world, Entity, EntityComponentTypes, system } from "@minecraft/server"; + * + * function setAblaze(entity: Entity) { + * entity.setOnFire(20, true); + * + * system.runTimeout(() => { + * const onfire = entity.getComponent(EntityComponentTypes.OnFire); + * if (onfire) { + * world.sendMessage(`${onfire.onFireTicksRemaining} fire ticks remaining, extinguishing the entity.`); + * } + * // This will extinguish the entity + * entity.extinguishFire(true); + * }, 30); // Run in 30 ticks or ~1.5 seconds + * + * } + * ``` */ - static readonly observer: BlockType; + setOnFire(seconds: number, useEffects?: boolean): boolean; /** * @remarks - * Represents an obsidian block within Minecraft. + * 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 */ - static readonly obsidian: BlockType; - static readonly ochreFroglight: BlockType; + setProperty(identifier: string, value: boolean | number | string): void; /** * @remarks - * Represents an orange candle within Minecraft. + * 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. */ - static readonly orangeCandle: BlockType; + setRotation(rotation: Vector2): void; /** * @remarks - * Represents an orange candle cake within Minecraft. + * 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 + * import { world, system } from '@minecraft/server'; + * + * const overworld = world.getDimension('overworld'); + * const targetLocation = { x: 0, y: 0, z: 0 }; + * + * const pig = overworld.spawnEntity('minecraft:pig', targetLocation); + * + * let inc = 1; + * const runId = system.runInterval(() => { + * pig.teleport( + * { x: targetLocation.x + inc / 4, y: targetLocation.y + inc / 4, z: targetLocation.z + inc / 4 }, + * { + * facingLocation: targetLocation, + * }, + * ); + * + * if (inc > 100) { + * system.clearRun(runId); + * } + * inc++; + * }, 4); + * ``` */ - static readonly orangeCandleCake: BlockType; - static readonly orangeCarpet: BlockType; + teleport(location: Vector3, teleportOptions?: TeleportOptions): void; /** * @remarks - * Represents a block of orange-colored glazed terracotta - * within Minecraft. + * 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 + * // A function that spawns a creeper and triggers it to explode immediately + * import { DimensionLocation } from '@minecraft/server'; + * import { MinecraftEntityTypes } from '@minecraft/vanilla-data'; * + * function spawnExplodingCreeper(location: DimensionLocation) { + * const creeper = location.dimension.spawnEntity(MinecraftEntityTypes.Creeper, location); + * + * creeper.triggerEvent('minecraft:start_exploding_forced'); + * } + * ``` */ - static readonly orangeGlazedTerracotta: BlockType; - static readonly orangeWool: BlockType; + triggerEvent(eventName: string): void; /** * @remarks - * Represents a block of oxidized copper within Minecraft. + * 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. */ - static readonly oxidizedCopper: BlockType; + 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 - * Represents a block of oxidized cut copper within Minecraft. + * 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. */ - static readonly oxidizedCutCopper: BlockType; + readonly entityType: string; /** * @remarks - * Represents a slab of oxidized cut copper within Minecraft. + * Optional spawn event to trigger on the rider when that rider + * is spawned for this entity. * + * @throws This property can throw when used. */ - static readonly oxidizedCutCopperSlab: BlockType; + 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 - * Represents a set of oxidized cut copper stairs within - * Minecraft. + * Amount of time before the entity grows up, -1 for always a + * baby. * + * @throws This property can throw when used. */ - static readonly oxidizedCutCopperStairs: BlockType; + readonly duration: number; /** * @remarks - * Represents a double slab of oxidized cut copper within - * Minecraft. + * Event that runs when this entity grows up. * + * @throws This property can throw when used. */ - static readonly oxidizedDoubleCutCopperSlab: BlockType; + readonly growUp: Trigger; /** * @remarks - * Represents a block of packed ice within Minecraft. + * The feed item used will transform into this item upon + * successful interaction. * + * @throws This property can throw when used. */ - static readonly packedIce: BlockType; - static readonly packedMud: BlockType; - static readonly pearlescentFroglight: BlockType; + readonly transformToItem: string; + static readonly componentId = 'minecraft:ageable'; /** * @remarks - * Represents a pink candle within Minecraft. + * List of items that the entity drops when it grows up. * + * @throws This function can throw errors. */ - static readonly pinkCandle: BlockType; + getDropItems(): string[]; /** * @remarks - * Represents a pink candle cake within Minecraft. + * 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. */ - static readonly pinkCandleCake: BlockType; - static readonly pinkCarpet: BlockType; + getFeedItems(): EntityDefinitionFeedItem[]; +} + +/** + * 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 - * Represents a pink-colored block of glazed terracotta within - * Minecraft. + * Current value of this attribute for this instance. * + * @throws This property can throw when used. */ - static readonly pinkGlazedTerracotta: BlockType; - static readonly pinkPetals: BlockType; - static readonly pinkWool: BlockType; + readonly currentValue: number; /** * @remarks - * Represents a piston within Minecraft. + * Returns the default defined value for this attribute. * + * @throws This property can throw when used. */ - static readonly piston: BlockType; - static readonly pistonArmCollision: BlockType; - static readonly pitcherCrop: BlockType; - static readonly pitcherPlant: BlockType; + readonly defaultValue: number; /** * @remarks - * Represents a set of planks within Minecraft. + * Returns the effective max of this attribute given any other + * ambient components or factors. * + * @throws This property can throw when used. */ - static readonly planks: BlockType; + readonly effectiveMax: number; /** * @remarks - * Represents podzol within Minecraft. + * Returns the effective min of this attribute given any other + * ambient components or factors. * + * @throws This property can throw when used. */ - static readonly podzol: BlockType; + readonly effectiveMin: number; /** * @remarks - * Represents pointed dripstone within Minecraft. + * 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. */ - static readonly pointedDripstone: BlockType; + resetToDefaultValue(): void; /** * @remarks - * Represents a set of polished andesite stairs within - * Minecraft. + * 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. */ - static readonly polishedAndesiteStairs: BlockType; + resetToMaxValue(): void; /** * @remarks - * Represents a block of polished basalt within Minecraft. + * 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. */ - static readonly polishedBasalt: BlockType; + resetToMinValue(): void; /** * @remarks - * Represents a block of polished blackstone within Minecraft. + * Sets the current value of this attribute. + * + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly polishedBlackstone: BlockType; + 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 - * Represents a double slab of polished blackstone brick within - * Minecraft. + * Maximum turn rate for this movement modality of the mob. * + * @throws This property can throw when used. */ - static readonly polishedBlackstoneBrickDoubleSlab: BlockType; + 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 - * Represents a block of polished blackstone bricks within - * Minecraft. + * If true, this entity can breathe in air. * + * @throws This property can throw when used. */ - static readonly polishedBlackstoneBricks: BlockType; + readonly breathesAir: boolean; /** * @remarks - * Represents a slab of polished blackstone within Minecraft. + * If true, this entity can breathe in lava. * + * @throws This property can throw when used. */ - static readonly polishedBlackstoneBrickSlab: BlockType; + readonly breathesLava: boolean; /** * @remarks - * Represents a set of polished blackstone brick stairs within - * Minecraft. + * If true, this entity can breathe in solid blocks. * + * @throws This property can throw when used. */ - static readonly polishedBlackstoneBrickStairs: BlockType; + readonly breathesSolids: boolean; /** * @remarks - * Represents a polished blackstone brick wall within - * Minecraft. + * If true, this entity can breathe in water. * + * @throws This property can throw when used. */ - static readonly polishedBlackstoneBrickWall: BlockType; + readonly breathesWater: boolean; /** * @remarks - * Represents a polished blackstone button within Minecraft. + * If true, this entity will have visible bubbles while in + * water. * + * @throws This property can throw when used. */ - static readonly polishedBlackstoneButton: BlockType; + readonly generatesBubbles: boolean; /** * @remarks - * Represents a double slab of polished blackstone within - * Minecraft. + * Time in seconds to recover breath to maximum. * + * @throws This property can throw when used. */ - static readonly polishedBlackstoneDoubleSlab: BlockType; + readonly inhaleTime: number; /** * @remarks - * Represents a polished blackstone pressure plate within - * Minecraft. + * Time in seconds between suffocation damage. * + * @throws This property can throw when used. */ - static readonly polishedBlackstonePressurePlate: BlockType; + readonly suffocateTime: number; /** * @remarks - * Represents a slab of polished blackstone within Minecraft. + * Time in seconds the entity can hold its breath. * + * @throws This property can throw when used. */ - static readonly polishedBlackstoneSlab: BlockType; + readonly totalSupply: number; + static readonly componentId = 'minecraft:breathable'; /** * @remarks - * Represents a set of polished blackstone stairs within - * Minecraft. + * List of blocks this entity can breathe in, in addition to + * the separate properties for classes of blocks. * + * @throws This function can throw errors. */ - static readonly polishedBlackstoneStairs: BlockType; + getBreatheBlocks(): BlockPermutation[]; /** * @remarks - * Represents a polished blackstone wall within Minecraft. + * List of blocks this entity can't breathe in. * + * @throws This function can throw errors. */ - static readonly polishedBlackstoneWall: BlockType; + getNonBreatheBlocks(): BlockPermutation[]; /** * @remarks - * Represents a block of polished deepslate within Minecraft. + * Sets the current air supply of the entity. * + * @param value + * New air supply for the entity. + * @throws This function can throw errors. */ - static readonly polishedDeepslate: BlockType; + setAirSupply(value: number): void; +} + +/** + * 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'; +} + +/** + * @beta + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityColor2Component extends EntityComponent { + private constructor(); /** - * @remarks - * Represents a double slab of polished deepslate within - * Minecraft. - * + * @throws This property can throw when used. */ - static readonly polishedDeepslateDoubleSlab: BlockType; + readonly value: PaletteColor; + static readonly componentId = 'minecraft:color2'; +} + +/** + * 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 - * Represents a slab of polished deepslate within Minecraft. + * Value of this particular color. + * + * This property can't be edited in read-only mode. * */ - static readonly polishedDeepslateSlab: BlockType; + 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(); /** + * @beta * @remarks - * Represents a set of polished deepslate stairs within - * Minecraft. + * The entity that owns this component. The entity will be + * undefined if it has been removed. * */ - static readonly polishedDeepslateStairs: BlockType; + 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 - * Represents a wall of polished deepslate within Minecraft. + * The amount by which an entity's age will increase when fed + * this item. Values usually range between 0 and 1. * */ - static readonly polishedDeepslateWall: BlockType; + readonly growth: number; /** * @remarks - * Represents a block of polished diorite within Minecraft. + * 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'. * */ - static readonly polishedDioriteStairs: BlockType; + readonly item: string; +} + +/** + * Contains data related to the death of an entity in the game. + */ +export class EntityDieAfterEvent { + private constructor(); /** * @remarks - * Represents a set of polished granite stairs within - * Minecraft. + * If specified, provides more information on the source of + * damage that caused the death of this entity. * */ - static readonly polishedGraniteStairs: BlockType; + readonly damageSource: EntityDamageSource; /** * @remarks - * Represents a portal within Minecraft. + * Now-dead entity object. * */ - static readonly portal: BlockType; + readonly deadEntity: Entity; +} + +/** + * Supports registering for an event that fires after an entity + * has died. + */ +export class EntityDieAfterEventSignal { + private constructor(); /** * @remarks - * Represents a set of potatoes within Minecraft. + * 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. */ - static readonly potatoes: BlockType; + subscribe( + callback: (arg: EntityDieAfterEvent) => void, + options?: EntityEventOptions, + ): (arg: EntityDieAfterEvent) => void; /** * @remarks - * Represents a block of powder snow within Minecraft. + * 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. */ - static readonly powderSnow: BlockType; + unsubscribe(callback: (arg: EntityDieAfterEvent) => void): void; +} + +/** + * Provides access to a mob's equipment slots. This component + * exists for all mob entities. + * @example givePlayerElytra.ts + * ```typescript + * // Gives the player Elytra + * import { EquipmentSlot, ItemStack, Player, EntityComponentTypes } from '@minecraft/server'; + * import { MinecraftItemTypes } from '@minecraft/vanilla-data'; + * + * function giveEquipment(player: Player) { + * const equipmentCompPlayer = player.getComponent(EntityComponentTypes.Equippable); + * if (equipmentCompPlayer) { + * equipmentCompPlayer.setEquipment(EquipmentSlot.Chest, new ItemStack(MinecraftItemTypes.Elytra)); + * } + * } + * ``` + * @example givePlayerEquipment.ts + * ```typescript + * // Gives the player some equipment + * import { EquipmentSlot, ItemStack, Player, EntityComponentTypes } from '@minecraft/server'; + * import { MinecraftItemTypes } from '@minecraft/vanilla-data'; + * + * function giveEquipment(player: Player) { + * const equipmentCompPlayer = player.getComponent(EntityComponentTypes.Equippable); + * if (equipmentCompPlayer) { + * equipmentCompPlayer.setEquipment(EquipmentSlot.Head, new ItemStack(MinecraftItemTypes.GoldenHelmet)); + * equipmentCompPlayer.setEquipment(EquipmentSlot.Chest, new ItemStack(MinecraftItemTypes.IronChestplate)); + * equipmentCompPlayer.setEquipment(EquipmentSlot.Legs, new ItemStack(MinecraftItemTypes.DiamondLeggings)); + * equipmentCompPlayer.setEquipment(EquipmentSlot.Feet, new ItemStack(MinecraftItemTypes.NetheriteBoots)); + * equipmentCompPlayer.setEquipment(EquipmentSlot.Mainhand, new ItemStack(MinecraftItemTypes.WoodenSword)); + * equipmentCompPlayer.setEquipment(EquipmentSlot.Offhand, new ItemStack(MinecraftItemTypes.Shield)); + * } else { + * console.warn('No equipment component found on player'); + * } + * } + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityEquippableComponent extends EntityComponent { + private constructor(); + static readonly componentId = 'minecraft:equippable'; /** * @remarks - * Represents a powered comparator within Minecraft. + * Gets the equipped item for the given EquipmentSlot. * + * @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. */ - static readonly poweredComparator: BlockType; + getEquipment(equipmentSlot: EquipmentSlot): ItemStack | undefined; /** * @remarks - * Represents a powered repeater within Minecraft. + * Gets the ContainerSlot corresponding to the given + * EquipmentSlot. * + * @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. */ - static readonly poweredRepeater: BlockType; + getEquipmentSlot(equipmentSlot: EquipmentSlot): ContainerSlot; /** * @remarks - * Represents a block of prismarine within Minecraft. + * 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. */ - static readonly prismarine: BlockType; + 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 - * Represents a set of prismarine brick stairs within - * Minecraft. + * Current value of the flying speed of the associated entity. + * + * This property can't be edited in read-only mode. * */ - static readonly prismarineBricksStairs: BlockType; + 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 - * Represents a set of prismarine stairs within Minecraft. + * Current value of the friction modifier of the associated + * entity. + * + * This property can't be edited in read-only mode. * */ - static readonly prismarineStairs: BlockType; + 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 - * Represents a pumpkin within Minecraft. + * 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. * */ - static readonly pumpkin: BlockType; + 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 - * Represents a pumpkin stem within Minecraft. + * Determines if an item can be used regardless of the entity + * being at full health. * + * @throws This property can throw when used. */ - static readonly pumpkinStem: BlockType; + readonly forceUse: boolean; + static readonly componentId = 'minecraft:healable'; /** * @remarks - * Represents a purple candle within Minecraft. + * A set of items that can specifically heal this entity. * + * @returns + * Entity that this component is associated with. + * @throws This function can throw errors. */ - static readonly purpleCandle: BlockType; + 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 - * Represents a purple colored candle cake within Minecraft. + * Entity whose health changed. * */ - static readonly purpleCandleCake: BlockType; - static readonly purpleCarpet: BlockType; + readonly entity: Entity; /** * @remarks - * Represents a purple-colored block of glazed terracotta - * within Minecraft. + * New health value of the entity. * */ - static readonly purpleGlazedTerracotta: BlockType; - static readonly purpleWool: BlockType; + readonly newValue: number; /** * @remarks - * Represents a purpur block within Minecraft. + * Old health value of the entity. * */ - static readonly purpurBlock: BlockType; + readonly oldValue: number; +} + +/** + * Manages callbacks that are connected to when the health of + * an entity changes. + */ +export class EntityHealthChangedAfterEventSignal { + private constructor(); /** * @remarks - * Represents a set of purpur stairs within Minecraft. + * Adds a callback that will be called when the health of an + * entity changes. + * + * This function can't be called in read-only mode. * */ - static readonly purpurStairs: BlockType; + subscribe( + callback: (arg: EntityHealthChangedAfterEvent) => void, + options?: EntityEventOptions, + ): (arg: EntityHealthChangedAfterEvent) => void; /** * @remarks - * Represents a block of solid quartz within Minecraft. + * 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. */ - static readonly quartzBlock: BlockType; + unsubscribe(callback: (arg: EntityHealthChangedAfterEvent) => void): void; +} + +/** + * Defines the health properties of an entity. + * @example applyDamageThenHeal.ts + * ```typescript + * // A function that applies damage and then heals the entity + * import { Entity, EntityComponentTypes, system, world } from '@minecraft/server'; + * + * function applyDamageAndHeal(entity: Entity) { + * entity.applyDamage(19); // Many mobs have max damage of 20 so this is a near-death mob + * + * system.runTimeout(() => { + * const health = entity.getComponent(EntityComponentTypes.Health); + * if (health) { + * world.sendMessage(`Entity health before heal: ${health.currentValue}`); + * + * health.resetToMaxValue(); + * + * world.sendMessage(`Entity after before heal: ${health.currentValue}`); + * } else { + * console.warn('Entity does not have health component'); + * } + * }, 40); // Run in a few seconds (40 ticks) + * } + * ``` + */ +// @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 - * Represents a block of solid quartz bricks within Minecraft. + * Face of the block that was hit. * */ - static readonly quartzBricks: BlockType; + readonly blockFace: Direction; /** * @remarks - * Represents a block with embedded quartz ore within - * Minecraft. + * Entity that made the attack. * */ - static readonly quartzOre: BlockType; + readonly damagingEntity: Entity; /** * @remarks - * Represents a set of quartz stairs within Minecraft. + * Block that was hit by the attack. * */ - static readonly quartzStairs: BlockType; + readonly hitBlock: Block; /** + * @beta * @remarks - * Represents a set of rails within Minecraft. + * Block permutation that was hit by the attack. * */ - static readonly rail: BlockType; + readonly hitBlockPermutation: BlockPermutation; +} + +/** + * Manages callbacks that are connected to when an entity hits + * a block. + */ +export class EntityHitBlockAfterEventSignal { + private constructor(); /** * @remarks - * Represents a block of raw copper within Minecraft. + * Adds a callback that will be called when an entity hits a + * block. + * + * This function can't be called in read-only mode. * */ - static readonly rawCopperBlock: BlockType; + subscribe( + callback: (arg: EntityHitBlockAfterEvent) => void, + options?: EntityEventOptions, + ): (arg: EntityHitBlockAfterEvent) => void; /** * @remarks - * Represents a block of raw gold within Minecraft. + * 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. */ - static readonly rawGoldBlock: BlockType; + unsubscribe(callback: (arg: EntityHitBlockAfterEvent) => void): void; +} + +/** + * Contains information related to an entity hitting (melee + * attacking) another entity. + */ +export class EntityHitEntityAfterEvent { + private constructor(); /** * @remarks - * Represents a block of raw iron within Minecraft. + * Entity that made a hit/melee attack. * */ - static readonly rawIronBlock: BlockType; + readonly damagingEntity: Entity; /** * @remarks - * Represents a red candle within Minecraft. + * Entity that was hit by the attack. * */ - static readonly redCandle: BlockType; + 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 - * Represents a red candle cake within Minecraft. + * Adds a callback that will be called when an entity hits + * another entity. * - */ - static readonly redCandleCake: BlockType; - static readonly redCarpet: BlockType; - /** - * @remarks - * Represents a red flower within Minecraft. + * This function can't be called in read-only mode. * */ - static readonly redFlower: BlockType; + subscribe( + callback: (arg: EntityHitEntityAfterEvent) => void, + options?: EntityEventOptions, + ): (arg: EntityHitEntityAfterEvent) => void; /** * @remarks - * Represents a red-colored block of glazed terracotta within - * Minecraft. + * Removes a callback from being called when an entity makes a + * melee attack on another entity. * - */ - static readonly redGlazedTerracotta: BlockType; - /** - * @remarks - * Represents a red mushroom within Minecraft. + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly redMushroom: BlockType; + unsubscribe(callback: (arg: EntityHitEntityAfterEvent) => void): void; +} + +/** + * Contains information related to an entity getting hurt. + */ +export class EntityHurtAfterEvent { + private constructor(); /** * @remarks - * Represents a block of red mushroom within Minecraft. + * Describes the amount of damage caused. * */ - static readonly redMushroomBlock: BlockType; + readonly damage: number; /** * @remarks - * Represents a block of red nether brick within Minecraft. + * Source information on the entity that may have applied this + * damage. * */ - static readonly redNetherBrick: BlockType; + readonly damageSource: EntityDamageSource; /** * @remarks - * Represents a set of red nether brick stairs within - * Minecraft. + * Entity that was hurt. * */ - static readonly redNetherBrickStairs: BlockType; + readonly hurtEntity: Entity; +} + +/** + * Manages callbacks that are connected to when an entity is + * hurt. + */ +export class EntityHurtAfterEventSignal { + private constructor(); /** * @remarks - * Represents a block of red sandstone within Minecraft. + * Adds a callback that will be called when an entity is hurt. * - */ - static readonly redSandstone: BlockType; - /** - * @remarks - * Represents a set of red sandstone stairs within Minecraft. + * This function can't be called in read-only mode. * */ - static readonly redSandstoneStairs: BlockType; + subscribe( + callback: (arg: EntityHurtAfterEvent) => void, + options?: EntityEventOptions, + ): (arg: EntityHurtAfterEvent) => void; /** * @remarks - * Represents a block of redstone within Minecraft. + * 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. */ - static readonly redstoneBlock: BlockType; + 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 - * Represents a redstone lamp within Minecraft. + * Number of slots that this entity can gain per extra + * strength. * + * @throws This property can throw when used. */ - static readonly redstoneLamp: BlockType; + readonly additionalSlotsPerStrength: number; /** * @remarks - * Represents a block with embedded redstone ore within - * Minecraft. + * If true, the contents of this inventory can be removed by a + * hopper. * + * @throws This property can throw when used. */ - static readonly redstoneOre: BlockType; + readonly canBeSiphonedFrom: boolean; /** * @remarks - * Represents a redstone torch within Minecraft. + * Defines the container for this entity. The container will be + * undefined if the entity has been removed. * + * @throws This property can throw when used. */ - static readonly redstoneTorch: BlockType; + readonly container?: Container; /** * @remarks - * Represents a redstone wire within Minecraft. + * Type of container this entity has. * + * @throws This property can throw when used. */ - static readonly redstoneWire: BlockType; - static readonly redWool: BlockType; + readonly containerType: string; /** * @remarks - * Represents reeds within Minecraft. + * Number of slots the container has. * + * @throws This property can throw when used. */ - static readonly reeds: BlockType; - static readonly reinforcedDeepslate: BlockType; + readonly inventorySize: number; /** * @remarks - * Represents a repeating command block within Minecraft. + * If true, the entity will not drop it's inventory on death. * + * @throws This property can throw when used. */ - static readonly repeatingCommandBlock: BlockType; + readonly 'private': boolean; /** * @remarks - * Represents a reserved block within Minecraft. + * If true, the entity's inventory can only be accessed by its + * owner or itself. * + * @throws This property can throw when used. */ - static readonly reserved6: BlockType; + 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. + * @example checkFeatherNearby.ts + * ```typescript + * import { DimensionLocation, EntityComponentTypes } from "@minecraft/server"; + * + * // Returns true if a feather item entity is within 'distance' blocks of 'location'. + * function isFeatherNear(location: DimensionLocation, distance: number): boolean { + * const items = location.dimension.getEntities({ + * location: location, + * maxDistance: 20, + * }); + * + * for (const item of items) { + * const itemComp = item.getComponent(EntityComponentTypes.Item); + * + * if (itemComp) { + * if (itemComp.itemStack.typeId.endsWith('feather')) { + * return true; + * } + * } + * } + * + * return false; + * } + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityItemComponent extends EntityComponent { + private constructor(); /** * @remarks - * Represents a respawn anchor within Minecraft. + * Item stack represented by this entity in the world. * + * @throws This property can throw when used. */ - static readonly respawnAnchor: BlockType; + 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 - * Represents a block of sand within Minecraft. + * This function can't be called in read-only mode. * */ - static readonly sand: BlockType; + [Symbol.iterator](): Iterator; /** * @remarks - * Represents a block of sandstone within Minecraft. + * 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. * */ - static readonly sandstone: BlockType; + 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 - * Represents a set of sandstone stairs within Minecraft. + * 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. */ - static readonly sandstoneStairs: BlockType; + readonly softDistance: number; + static readonly componentId = 'minecraft:leashable'; /** * @remarks - * Represents a sapling within Minecraft. + * 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. */ - static readonly sapling: BlockType; + leash(leashHolder: Entity): void; /** * @remarks - * Represents a set of scaffolding within Minecraft. + * 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. */ - static readonly scaffolding: BlockType; - static readonly sculk: BlockType; - static readonly sculkCatalyst: BlockType; + unleash(): void; +} + +/** + * 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 - * Represents a sculk sensor within Minecraft. + * Entity that was loaded. * - */ - static readonly sculkSensor: BlockType; - static readonly sculkShrieker: BlockType; - static readonly sculkVein: BlockType; - /** - * @remarks - * Represents seagrass within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly seagrass: BlockType; + entity: Entity; +} + +/** + * Registers a script-based event handler for handling what + * happens when an entity loads. + */ +export class EntityLoadAfterEventSignal { + private constructor(); /** * @remarks - * Represents a sealantern within Minecraft. + * 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. */ - static readonly seaLantern: BlockType; + subscribe(callback: (arg: EntityLoadAfterEvent) => void): (arg: EntityLoadAfterEvent) => void; /** * @remarks - * Represents a seapickle within Minecraft. + * 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. */ - static readonly seaPickle: BlockType; + unsubscribe(callback: (arg: EntityLoadAfterEvent) => void): void; +} + +/** + * 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 - * Represents a shroom light within Minecraft. + * Value of the mark variant value for this entity. + * + * This property can't be edited in read-only mode. * */ - static readonly shroomlight: BlockType; + 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'; +} + +/** + * @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'; +} + +/** + * 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'; +} + +/** + * @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 - * Represents a shulker box within Minecraft. + * Speed in effect when the entity is turning. * + * @throws This property can throw when used. */ - static readonly shulkerBox: BlockType; + readonly speedWhenTurning: number; /** * @remarks - * Represents a silver-colored block of glazed terracotta - * within Minecraft. + * Start speed during a glide. * + * @throws This property can throw when used. */ - static readonly silverGlazedTerracotta: BlockType; + readonly startSpeed: number; + static readonly componentId = 'minecraft:movement.glide'; +} + +/** + * 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'; +} + +/** + * @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 - * Represents a skull within Minecraft. + * Amplitude of the sway motion. * + * @throws This property can throw when used. */ - static readonly skull: BlockType; + readonly swayAmplitude: number; /** * @remarks - * Represents slime within Minecraft. + * Amount of sway frequency. * + * @throws This property can throw when used. */ - static readonly slime: BlockType; + 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 - * Represents a small bud of amethyst within Minecraft. + * Tells the pathfinder to avoid blocks that cause damage when + * finding a path. * + * @throws This property can throw when used. */ - static readonly smallAmethystBud: BlockType; + readonly avoidDamageBlocks: boolean; /** * @remarks - * Represents a small dripleaf block within Minecraft. + * Tells the pathfinder to avoid portals (like nether portals) + * when finding a path. * + * @throws This property can throw when used. */ - static readonly smallDripleafBlock: BlockType; + readonly avoidPortals: boolean; /** * @remarks - * Represents a smithing table within Minecraft. + * Whether or not the pathfinder should avoid tiles that are + * exposed to the sun when creating paths. * + * @throws This property can throw when used. */ - static readonly smithingTable: BlockType; + readonly avoidSun: boolean; /** * @remarks - * Represents a smoker within Minecraft. + * Tells the pathfinder to avoid water when creating a path. * + * @throws This property can throw when used. */ - static readonly smoker: BlockType; + readonly avoidWater: boolean; /** * @remarks - * Represents a block of smooth basalt within Minecraft. + * Tells the pathfinder whether or not it can jump out of water + * (like a dolphin). * + * @throws This property can throw when used. */ - static readonly smoothBasalt: BlockType; + readonly canBreach: boolean; /** * @remarks - * Represents a set of smooth quartz stairs within Minecraft. + * Tells the pathfinder that it can path through a closed door + * and break it. * + * @throws This property can throw when used. */ - static readonly smoothQuartzStairs: BlockType; + readonly canBreakDoors: boolean; /** * @remarks - * Represents a set of smooth red sandstone stairs within - * Minecraft. + * Tells the pathfinder whether or not it can float. * + * @throws This property can throw when used. */ - static readonly smoothRedSandstoneStairs: BlockType; + readonly canFloat: boolean; /** * @remarks - * Represents a set of smooth redstone stairs within Minecraft. + * Tells the pathfinder whether or not it can jump up blocks. * + * @throws This property can throw when used. */ - static readonly smoothSandstoneStairs: BlockType; + readonly canJump: boolean; /** * @remarks - * Represents a smooth stone block within Minecraft. + * 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. */ - static readonly smoothStone: BlockType; - static readonly snifferEgg: BlockType; + readonly canOpenDoors: boolean; /** * @remarks - * Represents snow within Minecraft. + * 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. */ - static readonly snow: BlockType; + readonly canOpenIronDoors: boolean; /** * @remarks - * Represents a layer of snow within Minecraft. + * Whether a path can be created through a door. * + * @throws This property can throw when used. */ - static readonly snowLayer: BlockType; + readonly canPassDoors: boolean; /** * @remarks - * Represents a soul campfire within Minecraft. + * Tells the pathfinder that it can start pathing when in the + * air. * + * @throws This property can throw when used. */ - static readonly soulCampfire: BlockType; + readonly canPathFromAir: boolean; /** * @remarks - * Represents soul fire within Minecraft. + * Tells the pathfinder whether or not it can travel on the + * surface of the lava. * + * @throws This property can throw when used. */ - static readonly soulFire: BlockType; + readonly canPathOverLava: boolean; /** * @remarks - * Represents a soul lantern within Minecraft. + * Tells the pathfinder whether or not it can travel on the + * surface of the water. * + * @throws This property can throw when used. */ - static readonly soulLantern: BlockType; + readonly canPathOverWater: boolean; /** * @remarks - * Represents a block of soul sand within Minecraft. + * Tells the pathfinder whether or not it will be pulled down + * by gravity while in water. * + * @throws This property can throw when used. */ - static readonly soulSand: BlockType; + readonly canSink: boolean; /** * @remarks - * Represents soul soil within Minecraft. + * 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. */ - static readonly soulSoil: BlockType; + readonly canSwim: boolean; /** * @remarks - * Represents a soul torch within Minecraft. + * Tells the pathfinder whether or not it can walk on the + * ground outside water. * + * @throws This property can throw when used. */ - static readonly soulTorch: BlockType; + readonly canWalk: boolean; /** * @remarks - * Represents a sponge within Minecraft. + * Tells the pathfinder whether or not it can travel in lava + * like walking on ground. * + * @throws This property can throw when used. */ - static readonly sponge: BlockType; + readonly canWalkInLava: boolean; /** * @remarks - * Represents a spore blossom within Minecraft. + * Tells the pathfinder whether or not it can walk on the + * ground or go underwater. * + * @throws This property can throw when used. */ - static readonly sporeBlossom: BlockType; + 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 + * Adds NPC capabilities to an entity such as custom skin, + * name, and dialogue interactions. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityNpcComponent extends EntityComponent { + private constructor(); /** * @remarks - * Represents a spruce wood button within Minecraft. + * The DialogueScene that is opened when players first interact + * with the NPC. * - */ - static readonly spruceButton: BlockType; - /** - * @remarks - * Represents a spruce wood door within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly spruceDoor: BlockType; - static readonly spruceFence: BlockType; + defaultScene: string; /** * @remarks - * Represents a spruce wood fence gate within Minecraft. + * The name of the NPC as it is displayed to players. * - */ - static readonly spruceFenceGate: BlockType; - static readonly spruceHangingSign: BlockType; - static readonly spruceLog: BlockType; - /** - * @remarks - * Represents a spruce wood pressure plate within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly sprucePressurePlate: BlockType; + name: string; /** * @remarks - * Represents a set of spruce wood stairs within Minecraft. + * The index of the skin the NPC will use. * - */ - static readonly spruceStairs: BlockType; - /** - * @remarks - * Represents a spruce wood standing sign within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly spruceStandingSign: BlockType; + skinIndex: number; + static readonly componentId = 'minecraft:npc'; +} + +/** + * When present on an entity, this entity is on fire. + * @example setEntityOnFire.ts + * ```typescript + * import { world, Entity, EntityComponentTypes, system } from "@minecraft/server"; + * + * function setAblaze(entity: Entity) { + * entity.setOnFire(20, true); + * + * system.runTimeout(() => { + * const onfire = entity.getComponent(EntityComponentTypes.OnFire); + * if (onfire) { + * world.sendMessage(`${onfire.onFireTicksRemaining} fire ticks remaining, extinguishing the entity.`); + * } + * // This will extinguish the entity + * entity.extinguishFire(true); + * }, 30); // Run in 30 ticks or ~1.5 seconds + * + * } + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityOnFireComponent extends EntityComponent { + private constructor(); /** * @remarks - * Represents a spruce wood trapdoor within Minecraft. + * The number of ticks remaining before the fire goes out. * */ - static readonly spruceTrapdoor: BlockType; + readonly onFireTicksRemaining: number; + static readonly componentId = 'minecraft:onfire'; +} + +/** + * The projectile component controls the properties of a + * projectile entity and allows it to be shot in a given + * direction. + * This component is present when the entity has the + * minecraft:projectile component. + * @example shootArrow.ts + * ```typescript + * import { world, Vector3 } from '@minecraft/server'; + * + * const location: Vector3 = { x: 0, y: -59, z: 0 }; // Replace with the coordinates of where you want to spawn the arrow + * const velocity: Vector3 = { x: 0, y: 0, z: 5 }; + * const arrow = world.getDimension('overworld').spawnEntity('minecraft:arrow', location); + * const projectileComp = arrow.getComponent('minecraft:projectile'); + * projectileComp?.shoot(velocity); + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityProjectileComponent extends EntityComponent { + private constructor(); /** * @remarks - * Represents a spruce wood wall sign within Minecraft. + * The fraction of the projectile's speed maintained every tick + * while traveling through air. * - */ - static readonly spruceWallSign: BlockType; - /** - * @remarks - * Represents stained glass within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly stainedGlass: BlockType; + airInertia: number; /** * @remarks - * Represents a pane of stained glass within Minecraft. + * If true, the entity will be set on fire when hurt. The + * default burn duration is 5 seconds. This duration can be + * modified via the onFireTime property. The entity will not + * catch fire if immune or if the entity is wet. * - */ - static readonly stainedGlassPane: BlockType; - /** - * @remarks - * Represents a block of stained hardened clay within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly stainedHardenedClay: BlockType; + catchFireOnHurt: boolean; /** * @remarks - * Represents a standing banner within Minecraft. + * If true, the projectile will spawn crit particles when hit + * by a player. E.g. Player attacking a Shulker bullet. * - */ - static readonly standingBanner: BlockType; - /** - * @remarks - * Represents a standing sign within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly standingSign: BlockType; + critParticlesOnProjectileHurt: boolean; /** * @remarks - * Represents a piston block with a sticky arm within - * Minecraft. + * If true, the projectile will be destroyed when it takes + * damage. E.g. Player attacking a Shulker bullet. * - */ - static readonly stickyPiston: BlockType; - static readonly stickyPistonArmCollision: BlockType; - /** - * @remarks - * Represents a block of stone within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly stone: BlockType; - static readonly stoneBlockSlab: BlockType; - static readonly stoneBlockSlab2: BlockType; - static readonly stoneBlockSlab3: BlockType; - static readonly stoneBlockSlab4: BlockType; + destroyOnProjectileHurt: boolean; /** * @remarks - * Represents a block of stone brick within Minecraft. + * The gravity applied to the projectile. When the entity is + * not on the ground, subtracts this amount from the + * projectile’s change in vertical position every tick. The + * higher the value, the faster the projectile falls. If + * negative, the entity will rise instead of fall. * - */ - static readonly stonebrick: BlockType; - /** - * @remarks - * Represents a set of stone brick stairs within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly stoneBrickStairs: BlockType; + gravity: number; /** * @remarks - * Represents a stone button within Minecraft. + * The sound that plays when the projectile hits an entity. * - */ - static readonly stoneButton: BlockType; - /** - * @remarks - * Represents a stonecutter within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly stonecutter: BlockType; + hitEntitySound?: string; /** * @remarks - * Represents a stonecutter block within Minecraft. + * The sound that plays when the projectile hits a block. * - */ - static readonly stonecutterBlock: BlockType; - /** - * @remarks - * Represents a stone pressure plate within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly stonePressurePlate: BlockType; + hitGroundSound?: string; /** * @remarks - * Represents a slab of stone within Minecraft. + * The particle that spawns when the projectile hits something. * - */ - static readonly stoneSlab: BlockType; - /** - * @remarks - * Represents a variant of a slab of stone (#2) within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly stoneSlab2: BlockType; + hitParticle?: string; /** * @remarks - * Represents a slab of stone (variant #3) within Minecraft. + * If true and the weather is thunder and the entity has line + * of sight to the sky, the entity will be struck by lightning + * when hit. E.g. A thrown Trident with the Channeling + * enchantment. * - */ - static readonly stoneSlab3: BlockType; - /** - * @remarks - * Represents a slab of stone (variant #4) within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly stoneSlab4: BlockType; + lightningStrikeOnHit: boolean; /** * @remarks - * Represents a set of stone stairs within Minecraft. + * The fraction of the projectile's speed maintained every tick + * while traveling through a liquid. * - */ - static readonly stoneStairs: BlockType; - /** - * @remarks - * Represents a stripped acacia log within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly strippedAcaciaLog: BlockType; - static readonly strippedBambooBlock: BlockType; + liquidInertia: number; /** * @remarks - * Represents a stripped birch log within Minecraft. + * Duration in seconds that the entity hit will be on fire for + * when catchFireOnHurt is set to true. * - */ - static readonly strippedBirchLog: BlockType; - static readonly strippedCherryLog: BlockType; - static readonly strippedCherryWood: BlockType; - /** - * @remarks - * Represents stripped crimson hyphae within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly strippedCrimsonHyphae: BlockType; + onFireTime: number; /** * @remarks - * Represents a stripped crimson stem within Minecraft. + * The owner of the projectile. This is used to determine what + * the projectile can collide with and damage. It also + * determines which entity is assigned as the attacker. * - */ - static readonly strippedCrimsonStem: BlockType; - /** - * @remarks - * Represents a stripped dark oak log within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly strippedDarkOakLog: BlockType; + owner?: Entity; /** * @remarks - * Represents a stripped jungle log within Minecraft. + * If true, the projectile will bounce off mobs when no damage + * is taken. E.g. A spawning wither. * - */ - static readonly strippedJungleLog: BlockType; - static readonly strippedMangroveLog: BlockType; - static readonly strippedMangroveWood: BlockType; - /** - * @remarks - * Represents a stripped oak log within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly strippedOakLog: BlockType; + shouldBounceOnHit: boolean; /** * @remarks - * Represents a stripped spruce log within Minecraft. + * If true, the projectile will stop moving when an entity is + * hit as thought it had been blocked. E.g. Thrown trident on + * hit behavior. * - */ - static readonly strippedSpruceLog: BlockType; - /** - * @remarks - * Represents stripped warped hyphae within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly strippedWarpedHyphae: BlockType; + stopOnHit: boolean; + static readonly componentId = 'minecraft:projectile'; /** * @remarks - * Represents stripped warped stem within Minecraft. + * Shoots the projectile with a given velocity. The projectile + * will be shot from its current location. * - */ - static readonly strippedWarpedStem: BlockType; - /** - * @remarks - * Represents a structure block, which provides for the saving - * and loading of block structures, within Minecraft. + * This function can't be called in read-only mode. * + * @param velocity + * The velocity to fire the projectile. This controls both the + * speed and direction which which the projectile will be shot. + * @param options + * Optional configuration for the shoot. + * @throws + * Throws if the component or entity no longer exist. */ - static readonly structureBlock: BlockType; + shoot(velocity: Vector3, options?: ProjectileShootOptions): void; +} + +/** + * 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 - * Represents a structure void within Minecraft. + * Value of the push through distances of this entity. * - */ - static readonly structureVoid: BlockType; - static readonly suspiciousGravel: BlockType; - static readonly suspiciousSand: BlockType; - /** - * @remarks - * Represents a sweet berry bush within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly sweetBerryBush: BlockType; + value: number; + static readonly componentId = 'minecraft:push_through'; +} + +/** + * 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 - * Represents tall grass within Minecraft. + * Id of the entity that was removed. * */ - static readonly tallgrass: BlockType; + readonly removedEntityId: string; /** * @remarks - * Represents a target within Minecraft. + * Identifier of the type of the entity removed - for example, + * 'minecraft:skeleton'. * */ - static readonly target: BlockType; + readonly typeId: string; +} + +/** + * 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 - * Represents tinted glass within Minecraft. + * Will call your function every time an entity is removed from + * the game. * - */ - static readonly tintedGlass: BlockType; - /** - * @remarks - * Represents a block of TnT within Minecraft. + * 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. */ - static readonly tnt: BlockType; + subscribe( + callback: (arg: EntityRemoveAfterEvent) => void, + options?: EntityEventOptions, + ): (arg: EntityRemoveAfterEvent) => void; /** * @remarks - * Represents a torch within Minecraft. + * Unsubscribes your function from subsequent calls when an + * entity is removed. * - */ - static readonly torch: BlockType; - static readonly torchflower: BlockType; - static readonly torchflowerCrop: BlockType; - /** - * @remarks - * Represents a trapdoor within Minecraft. + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly trapdoor: BlockType; + unsubscribe(callback: (arg: EntityRemoveAfterEvent) => void): void; +} + +/** + * 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 - * Represents a trapped chest within Minecraft. + * Reference to an entity that is being removed. * */ - static readonly trappedChest: BlockType; - static readonly tripWire: BlockType; + readonly removedEntity: Entity; +} + +/** + * 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 - * Represents a tripwire hook within Minecraft. + * Will call your function every time an entity is being + * removed from the game. * - */ - static readonly tripwireHook: BlockType; - static readonly tubeCoral: BlockType; - /** - * @remarks - * Represents a block of tuff within Minecraft. + * 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. */ - static readonly tuff: BlockType; + subscribe(callback: (arg: EntityRemoveBeforeEvent) => void): (arg: EntityRemoveBeforeEvent) => void; /** * @remarks - * Represents a turtle egg within Minecraft. + * Unsubscribes your function from subsequent calls when an + * entity is being removed. * - */ - static readonly turtleEgg: BlockType; - /** - * @remarks - * Represents a set of twisting vines within Minecraft. + * This function can't be called in read-only mode. * */ - static readonly twistingVines: BlockType; + 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 - * Represents an underwater torch within Minecraft. + * Zero-based index of the seat that can used to control this + * entity. * + * @throws This property can throw when used. */ - static readonly underwaterTorch: BlockType; + readonly controllingSeat: number; /** * @remarks - * Represents an undyed shulker box within Minecraft. + * Determines whether interactions are not supported if the + * entity is crouching. * + * @throws This property can throw when used. */ - static readonly undyedShulkerBox: BlockType; + readonly crouchingSkipInteract: boolean; /** * @remarks - * Represents an unknown block within Minecraft. + * 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. */ - static readonly unknown: BlockType; + readonly interactText: string; /** * @remarks - * Represents an unlit redstone torch within Minecraft. + * The max width a mob can be to be a passenger. * + * @throws This property can throw when used. */ - static readonly unlitRedstoneTorch: BlockType; + readonly passengerMaxWidth: number; /** * @remarks - * Represents an unpowered comparator within Minecraft. + * 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. */ - static readonly unpoweredComparator: BlockType; + readonly pullInEntities: boolean; /** * @remarks - * Represents an unpowered repeater within Minecraft. + * If true, this entity will be picked when looked at by the + * rider. * + * @throws This property can throw when used. */ - static readonly unpoweredRepeater: BlockType; - static readonly verdantFroglight: BlockType; + readonly riderCanInteract: boolean; /** * @remarks - * Represents a set of vines within Minecraft. + * Number of seats for riders defined for this entity. * + * @throws This property can throw when used. */ - static readonly vine: BlockType; + readonly seatCount: number; + static readonly componentId = 'minecraft:rideable'; /** * @remarks - * Represents a wall banner within Minecraft. + * Adds an entity to this entity as a rider. * - */ - static readonly wallBanner: BlockType; - /** - * @remarks - * Represents a wall sign within Minecraft. + * 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. */ - static readonly wallSign: BlockType; + addRider(rider: Entity): boolean; /** * @remarks - * Represents a warped button within Minecraft. + * Ejects the specified rider of this entity. * - */ - static readonly warpedButton: BlockType; - /** - * @remarks - * Represents a warped door within Minecraft. + * 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. */ - static readonly warpedDoor: BlockType; + ejectRider(rider: Entity): void; /** * @remarks - * Represents a double slab of warped within Minecraft. + * Ejects all riders of this entity. * - */ - static readonly warpedDoubleSlab: BlockType; - /** - * @remarks - * Represents a warped fence within Minecraft. + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly warpedFence: BlockType; + ejectRiders(): void; /** * @remarks - * Represents a warped fence gate within Minecraft. + * A string-list of entity types that this entity can support + * as riders. * + * @throws This function can throw errors. */ - static readonly warpedFenceGate: BlockType; + getFamilyTypes(): string[]; /** * @remarks - * Represents warped fungus within Minecraft. + * Gets a list of the all the entities currently riding this + * entity. * + * @throws This function can throw errors. */ - static readonly warpedFungus: BlockType; - static readonly warpedHangingSign: BlockType; + getRiders(): Entity[]; /** * @remarks - * Represents warped hyphae within Minecraft. + * Gets a list of positions and number of riders for each + * position for entities riding this entity. * + * @throws This function can throw errors. */ - static readonly warpedHyphae: BlockType; + 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 - * Represents warped nylium within Minecraft. + * The entity this entity is currently riding on. * + * @throws This property can throw when used. */ - static readonly warpedNylium: BlockType; + readonly entityRidingOn: Entity; + static readonly componentId = 'minecraft:riding'; +} + +/** + * Sets the entity's visual size. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityScaleComponent extends EntityComponent { + private constructor(); /** * @remarks - * Represents warped planks within Minecraft. + * Current value for the scale property set on entities. * - */ - static readonly warpedPlanks: BlockType; - /** - * @remarks - * Represents a warped pressure plate within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly warpedPressurePlate: BlockType; + 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 - * Represents a set of warped roots within Minecraft. + * Returns the value of the skin Id identifier of the entity. * - */ - static readonly warpedRoots: BlockType; - /** - * @remarks - * Represents a slab of warped material within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly warpedSlab: BlockType; + value: number; + static readonly componentId = 'minecraft:skin_id'; +} + +/** + * Contains data related to an entity spawning within the + * world. + * @example logEntitySpawnEvents.ts + * ```typescript + * // Register a new function that is called when a new entity is created. + * import { world, EntitySpawnAfterEvent } from '@minecraft/server'; + * + * world.afterEvents.entitySpawn.subscribe((entityEvent: EntitySpawnAfterEvent) => { + * const spawnLocation = entityEvent.entity.location; + * world.sendMessage( + * `New entity of type '${entityEvent.entity.typeId}' spawned at ${spawnLocation.x}, ${spawnLocation.y}, ${spawnLocation.z}!`, + * ); + * }); + * ``` + */ +export class EntitySpawnAfterEvent { + private constructor(); /** * @remarks - * Represents a set of warped stairs within Minecraft. + * Initialization cause (Spawned, Born ...). * */ - static readonly warpedStairs: BlockType; + readonly cause: EntityInitializationCause; /** * @remarks - * Represents a warped standing sign within Minecraft. + * Entity that was spawned. * - */ - static readonly warpedStandingSign: BlockType; - /** - * @remarks - * Represents a warped stem within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly warpedStem: BlockType; + entity: Entity; +} + +/** + * Registers a script-based event handler for handling what + * happens when an entity spawns. + * @example logEntitySpawnEvents.ts + * ```typescript + * // Register a new function that is called when a new entity is created. + * import { world, EntitySpawnAfterEvent } from '@minecraft/server'; + * + * world.afterEvents.entitySpawn.subscribe((entityEvent: EntitySpawnAfterEvent) => { + * const spawnLocation = entityEvent.entity.location; + * world.sendMessage( + * `New entity of type '${entityEvent.entity.typeId}' spawned at ${spawnLocation.x}, ${spawnLocation.y}, ${spawnLocation.z}!`, + * ); + * }); + * ``` + */ +export class EntitySpawnAfterEventSignal { + private constructor(); /** * @remarks - * Represents a warped trapdoor within Minecraft. + * Method to register an event handler for what happens when an + * entity spawns. * - */ - static readonly warpedTrapdoor: BlockType; - /** - * @remarks - * Represents a warped wall sign within Minecraft. + * This function can't be called in read-only mode. * + * @param callback + * Function that handles the spawn event. */ - static readonly warpedWallSign: BlockType; + subscribe(callback: (arg: EntitySpawnAfterEvent) => void): (arg: EntitySpawnAfterEvent) => void; /** * @remarks - * Represents a warped wart block within Minecraft. + * Unregisters a method that was previously subscribed to the + * subscription event. * - */ - static readonly warpedWartBlock: BlockType; - /** - * @remarks - * Represents water within Minecraft. + * 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. */ - static readonly water: BlockType; + 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 - * Represents a water lily within Minecraft. + * Maximum strength of this entity, as defined in the entity + * type definition. * + * @throws This property can throw when used. */ - static readonly waterlily: BlockType; + readonly max: number; /** * @remarks - * Represents a block of waxed copper within Minecraft. + * Current value of the strength component that has been set + * for entities. * + * @throws This property can throw when used. */ - static readonly waxedCopper: BlockType; + 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 - * Represents a block of waxed cut copper within Minecraft. + * Returns a set of items that can be used to tame this entity. * + * @throws This property can throw when used. */ - static readonly waxedCutCopper: BlockType; + readonly getTameItems: ItemStack[]; /** - * @remarks - * Represents a slab of waxed cut copper within Minecraft. - * + * @throws This property can throw when used. */ - static readonly waxedCutCopperSlab: BlockType; + readonly isTamed: boolean; /** * @remarks - * Represents a set of waxed cut copper stairs within - * Minecraft. + * 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. */ - static readonly waxedCutCopperStairs: BlockType; + readonly probability: number; /** - * @remarks - * Represents a double slab of waxed cut copper within - * Minecraft. - * + * @throws This property can throw when used. */ - static readonly waxedDoubleCutCopperSlab: BlockType; + readonly tamedToPlayer?: Player; /** - * @remarks - * Represents a block of waxed exposed copper within Minecraft. - * + * @throws This property can throw when used. */ - static readonly waxedExposedCopper: BlockType; + readonly tamedToPlayerId?: string; + static readonly componentId = 'minecraft:tameable'; /** * @remarks - * Represents a block of waxed exposed cut copper within - * Minecraft. + * Tames this entity. * - */ - static readonly waxedExposedCutCopper: BlockType; - /** - * @remarks - * Represents a slab of waxed exposed cut copper within - * Minecraft. + * This function can't be called in read-only mode. * + * @returns + * Returns true if the entity was tamed. + * @throws This function can throw errors. */ - static readonly waxedExposedCutCopperSlab: BlockType; + tame(player: Player): boolean; +} + +/** + * @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 EntityTameMountComponent extends EntityComponent { + private constructor(); /** - * @remarks - * Represents a set of waxed exposed cut copper stairs within - * Minecraft. - * + * @throws This property can throw when used. */ - static readonly waxedExposedCutCopperStairs: BlockType; + readonly isTamed: boolean; /** - * @remarks - * Represents a double slab of waxed exposed cut copper within - * Minecraft. - * + * @throws This property can throw when used. */ - static readonly waxedExposedDoubleCutCopperSlab: BlockType; + readonly isTamedToPlayer: boolean; /** - * @remarks - * Represents a block of waxed oxidized copper within - * Minecraft. - * + * @throws This property can throw when used. */ - static readonly waxedOxidizedCopper: BlockType; + readonly tamedToPlayer?: Player; /** - * @remarks - * Represents a block of waxed oxidized cut copper within - * Minecraft. - * + * @throws This property can throw when used. */ - static readonly waxedOxidizedCutCopper: BlockType; + readonly tamedToPlayerId?: string; + static readonly componentId = 'minecraft:tamemount'; /** * @remarks - * Represents a slab of waxed oxidized cut copper within - * Minecraft. + * Sets this rideable entity as tamed. * - */ - static readonly waxedOxidizedCutCopperSlab: BlockType; - /** - * @remarks - * Represents a set of waxed oxidized cut copper stairs within - * Minecraft. + * 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. */ - static readonly waxedOxidizedCutCopperStairs: BlockType; + tame(showParticles: boolean): void; /** * @remarks - * Represents a double slab of waxed oxidized cut copper within - * Minecraft. + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly waxedOxidizedDoubleCutCopperSlab: BlockType; + tameToPlayer(showParticles: boolean, player: Player): boolean; +} + +/** + * Represents information about a type of entity. + */ +export class EntityType { + private constructor(); /** * @remarks - * Represents a block of waxed weathered copper within - * Minecraft. + * Identifier of this entity type - for example, + * 'minecraft:skeleton'. * */ - static readonly waxedWeatheredCopper: BlockType; + readonly id: string; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityTypeFamilyComponent extends EntityComponent { + private constructor(); + static readonly componentId = 'minecraft:type_family'; /** - * @remarks - * Represents a block of waxed weathered cut copper within - * Minecraft. - * + * @throws This function can throw errors. */ - static readonly waxedWeatheredCutCopper: BlockType; + getTypeFamilies(): string[]; /** - * @remarks - * Represents a slab of waxed weathered cut copper within - * Minecraft. - * + * @throws This function can throw errors. */ - static readonly waxedWeatheredCutCopperSlab: BlockType; + hasTypeFamily(typeFamily: string): boolean; +} + +/** + * @beta + * An iterator that loops through available entity types. + */ +export class EntityTypeIterator implements Iterable { + private constructor(); /** * @remarks - * Represents a set of waxed weathered cut copper stairs within - * Minecraft. + * This function can't be called in read-only mode. * */ - static readonly waxedWeatheredCutCopperStairs: BlockType; + [Symbol.iterator](): Iterator; /** * @remarks - * Represents a double slab of waxed weathered cut copper - * within Minecraft. + * This function can't be called in read-only mode. * */ - static readonly waxedWeatheredDoubleCutCopperSlab: BlockType; + next(): IteratorResult; +} + +/** + * Used for accessing all entity types currently available for + * use within the world. + */ +export class EntityTypes { + private constructor(); /** * @remarks - * Represents a block of weathered copper within Minecraft. + * Retrieves an entity type using a string-based identifier. * */ - static readonly weatheredCopper: BlockType; + static get(identifier: string): EntityType | undefined; /** * @remarks - * Represents a block of weathered cut copper within Minecraft. + * Retrieves a set of all entity types within this world. * */ - static readonly weatheredCutCopper: BlockType; + static getAll(): EntityType[]; +} + +/** + * @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'; +} + +/** + * 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 - * Represents a slab of weathered cut copper within Minecraft. + * Current value for variant for this entity, as specified via + * components. * + * @throws This property can throw when used. */ - static readonly weatheredCutCopperSlab: BlockType; + 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'; +} + +/** + * Contains information regarding an explosion that has + * happened. + */ +export class ExplosionAfterEvent { + private constructor(); /** * @remarks - * Represents a set of weathered cut copper stairs within - * Minecraft. + * Dimension where the explosion has occurred. * */ - static readonly weatheredCutCopperStairs: BlockType; + readonly dimension: Dimension; /** * @remarks - * Represents a double slab of weathered cut copper within - * Minecraft. + * Optional source of the explosion. * */ - static readonly weatheredDoubleCutCopperSlab: BlockType; + readonly source?: Entity; /** * @remarks - * Represents a web within Minecraft. + * A collection of blocks impacted by this explosion event. * */ - static readonly web: BlockType; + getImpactedBlocks(): Block[]; +} + +/** + * Manages callbacks that are connected to when an explosion + * occurs. + */ +export class ExplosionAfterEventSignal { + private constructor(); /** * @remarks - * Represents a set of weeping vines within Minecraft. + * Adds a callback that will be called when an explosion + * occurs. + * + * This function can't be called in read-only mode. * */ - static readonly weepingVines: BlockType; + subscribe(callback: (arg: ExplosionAfterEvent) => void): (arg: ExplosionAfterEvent) => void; /** * @remarks - * Represents wheat within Minecraft. + * Removes a callback from being called when an explosion + * occurs. + * + * This function can't be called in read-only mode. * */ - static readonly wheat: BlockType; + unsubscribe(callback: (arg: ExplosionAfterEvent) => void): void; +} + +/** + * 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 - * Represents a white candle within Minecraft. + * If set to true, cancels the explosion event. * */ - static readonly whiteCandle: BlockType; + cancel: boolean; /** * @remarks - * Represents a white candle cake within Minecraft. + * Updates a collection of blocks impacted by this explosion + * event. * + * @param blocks + * New list of blocks that are impacted by this explosion. */ - static readonly whiteCandleCake: BlockType; - static readonly whiteCarpet: BlockType; + setImpactedBlocks(blocks: Block[]): void; +} + +/** + * Manages callbacks that are connected to before an explosion + * occurs. + */ +export class ExplosionBeforeEventSignal { + private constructor(); /** * @remarks - * Represents a block of white glazed terracotta within - * Minecraft. + * 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. * */ - static readonly whiteGlazedTerracotta: BlockType; - static readonly whiteWool: BlockType; + subscribe(callback: (arg: ExplosionBeforeEvent) => void): (arg: ExplosionBeforeEvent) => void; /** * @remarks - * Represents a wither rose within Minecraft. + * Removes a callback from being called from before when an + * explosion would occur. + * + * This function can't be called in read-only mode. * */ - static readonly witherRose: BlockType; + unsubscribe(callback: (arg: ExplosionBeforeEvent) => void): void; +} + +/** + * 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 - * Represents a block of wood within Minecraft. + * 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. * */ - static readonly wood: BlockType; + readonly healAmount: number; /** * @remarks - * Represents a wooden button within Minecraft. + * 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'. * */ - static readonly woodenButton: BlockType; + readonly item: string; /** * @remarks - * Represents a wooden door within Minecraft. + * As part of the Healable component, an optional collection of + * side effects that can occur from being fed an item. * */ - static readonly woodenDoor: BlockType; + 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 - * Represents a wooden pressure plate within Minecraft. + * 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. * */ - static readonly woodenPressurePlate: BlockType; + readonly amplifier: number; /** * @remarks - * Represents a wooden slab within Minecraft. + * Chance that this effect is applied as a result of the entity + * being fed this item. Valid values range between 0 and 1. * */ - static readonly woodenSlab: BlockType; + readonly chance: number; /** * @remarks - * Represents a yellow candle within Minecraft. + * Gets the duration, in ticks, of this effect. * */ - static readonly yellowCandle: BlockType; + readonly duration: number; /** * @remarks - * Represents a yellow candle cake within Minecraft. + * Gets the identifier of the effect to apply. Example values + * include 'fire_resistance' or 'regeneration'. * */ - static readonly yellowCandleCake: BlockType; - static readonly yellowCarpet: BlockType; + 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 - * Represents a yellow flower within Minecraft. + * Constant that represents the maximum fill level of a fluid + * container. * */ - static readonly yellowFlower: BlockType; + static readonly maxFillLevel = 6; /** * @remarks - * Represents a yellow block of glazed terracotta within - * Minecraft. + * Constant that represents the minimum fill level of a fluid + * container. * */ - static readonly yellowGlazedTerracotta: BlockType; - static readonly yellowWool: BlockType; + static readonly minFillLevel = 0; +} + +/** + * @beta + * Contains information regarding a changed world.gameRules + * property. + */ +export class GameRuleChangeAfterEvent { + private constructor(); /** * @remarks - * Returns a specific Minecraft block type given a type id. + * The rule identifier pertaining to the changed + * world.gameRules property. * */ - static get(typeName: string): BlockType; + readonly rule: GameRule; /** * @remarks - * Returns an array of all block types within Minecraft. + * The value of the world.gameRules property after being + * changed. * */ - static getAllBlockTypes(): BlockType[]; + readonly value: boolean | number; } + /** - * A collection of default Minecraft dimension types. + * @beta + * Manages callbacks that are connected to when a + * world.gameRules property has changed. */ -export class MinecraftDimensionTypes { - protected constructor(); +export class GameRuleChangeAfterEventSignal { + 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. + * Adds a callback that will be called when a world.gameRules + * property is changed. * - */ - 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. + * This function can't be called in read-only mode. * */ - static readonly overworld = 'minecraft:overworld'; + subscribe(callback: (arg: GameRuleChangeAfterEvent) => void): (arg: GameRuleChangeAfterEvent) => void; /** * @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. + * Removes a callback from being called when a world.gameRules + * property is changed. + * + * This function can't be called in read-only mode. * */ - static readonly theEnd = 'minecraft:the_end'; -} -/** - * @beta - * Returns available installed effect types within Minecraft. - */ -export class MinecraftEffectTypes { - protected constructor(); - static readonly absorption: EffectType; - static readonly badOmen: EffectType; - static readonly blindness: EffectType; - static readonly conduitPower: EffectType; - static readonly darkness: EffectType; - static readonly empty: EffectType; - static readonly fatalPoison: EffectType; - static readonly fireResistance: EffectType; - static readonly haste: EffectType; - static readonly healthBoost: EffectType; - static readonly hunger: EffectType; - static readonly instantDamage: EffectType; - static readonly instantHealth: EffectType; - static readonly invisibility: EffectType; - static readonly jumpBoost: EffectType; - static readonly levitation: EffectType; - static readonly miningFatigue: EffectType; - static readonly nausea: EffectType; - static readonly nightVision: EffectType; - static readonly poison: EffectType; - static readonly regeneration: EffectType; - static readonly resistance: EffectType; - static readonly saturation: EffectType; - static readonly slowFalling: EffectType; - static readonly slowness: EffectType; - static readonly speed: EffectType; - static readonly strength: EffectType; - static readonly villageHero: EffectType; - static readonly waterBreathing: EffectType; - static readonly weakness: EffectType; - static readonly wither: EffectType; -} -/** - * @beta - * Describes a set of enchantment types. - */ -export class MinecraftEnchantmentTypes { - protected constructor(); - static readonly aquaAffinity: EnchantmentType; - static readonly baneOfArthropods: EnchantmentType; - static readonly binding: EnchantmentType; - static readonly blastProtection: EnchantmentType; - static readonly channeling: EnchantmentType; - static readonly depthStrider: EnchantmentType; - static readonly efficiency: EnchantmentType; - static readonly featherFalling: EnchantmentType; - static readonly fireAspect: EnchantmentType; - static readonly fireProtection: EnchantmentType; - static readonly flame: EnchantmentType; - static readonly fortune: EnchantmentType; - static readonly frostWalker: EnchantmentType; - static readonly impaling: EnchantmentType; - static readonly infinity: EnchantmentType; - static readonly knockback: EnchantmentType; - static readonly looting: EnchantmentType; - static readonly loyalty: EnchantmentType; - static readonly luckOfTheSea: EnchantmentType; - static readonly lure: EnchantmentType; - static readonly mending: EnchantmentType; - static readonly multishot: EnchantmentType; - static readonly piercing: EnchantmentType; - static readonly power: EnchantmentType; - static readonly projectileProtection: EnchantmentType; - static readonly protection: EnchantmentType; - static readonly punch: EnchantmentType; - static readonly quickCharge: EnchantmentType; - static readonly respiration: EnchantmentType; - static readonly riptide: EnchantmentType; - static readonly sharpness: EnchantmentType; - static readonly silkTouch: EnchantmentType; - static readonly smite: EnchantmentType; - static readonly soulSpeed: EnchantmentType; - static readonly swiftSneak: EnchantmentType; - static readonly thorns: EnchantmentType; - static readonly unbreaking: EnchantmentType; - static readonly vanishing: EnchantmentType; -} -/** - * @beta - */ -export class MinecraftEntityTypes { - protected constructor(); - static readonly agent: EntityType; - static readonly allay: EntityType; - static readonly areaEffectCloud: EntityType; - static readonly armorStand: EntityType; - static readonly arrow: EntityType; - static readonly axolotl: EntityType; - static readonly bat: EntityType; - static readonly bee: EntityType; - static readonly blaze: EntityType; - static readonly boat: EntityType; - static readonly cat: EntityType; - static readonly caveSpider: EntityType; - static readonly chestBoat: EntityType; - static readonly chestMinecart: EntityType; - static readonly chicken: EntityType; - static readonly cod: EntityType; - static readonly commandBlockMinecart: EntityType; - static readonly cow: EntityType; - static readonly creeper: EntityType; - static readonly dolphin: EntityType; - static readonly donkey: EntityType; - static readonly dragonFireball: EntityType; - static readonly drowned: EntityType; - static readonly egg: EntityType; - static readonly elderGuardian: EntityType; - static readonly enderCrystal: EntityType; - static readonly enderDragon: EntityType; - static readonly enderman: EntityType; - static readonly endermite: EntityType; - static readonly enderPearl: EntityType; - static readonly evocationIllager: EntityType; - static readonly eyeOfEnderSignal: EntityType; - static readonly fireball: EntityType; - static readonly fireworksRocket: EntityType; - static readonly fishingHook: EntityType; - static readonly fox: EntityType; - static readonly frog: EntityType; - static readonly ghast: EntityType; - static readonly glowSquid: EntityType; - static readonly goat: EntityType; - static readonly guardian: EntityType; - static readonly hoglin: EntityType; - static readonly hopperMinecart: EntityType; - static readonly horse: EntityType; - static readonly husk: EntityType; - static readonly ironGolem: EntityType; - static readonly lightningBolt: EntityType; - static readonly lingeringPotion: EntityType; - static readonly llama: EntityType; - static readonly llamaSpit: EntityType; - static readonly magmaCube: EntityType; - static readonly minecart: EntityType; - static readonly mooshroom: EntityType; - static readonly mule: EntityType; - static readonly npc: EntityType; - static readonly ocelot: EntityType; - static readonly panda: EntityType; - static readonly parrot: EntityType; - static readonly phantom: EntityType; - static readonly pig: EntityType; - static readonly piglin: EntityType; - static readonly piglinBrute: EntityType; - static readonly pillager: EntityType; - static readonly player: EntityType; - static readonly polarBear: EntityType; - static readonly pufferfish: EntityType; - static readonly rabbit: EntityType; - static readonly ravager: EntityType; - static readonly salmon: EntityType; - static readonly sheep: EntityType; - static readonly shulker: EntityType; - static readonly shulkerBullet: EntityType; - static readonly silverfish: EntityType; - static readonly skeleton: EntityType; - static readonly skeletonHorse: EntityType; - static readonly slime: EntityType; - static readonly smallFireball: EntityType; - static readonly sniffer: EntityType; - static readonly snowball: EntityType; - static readonly snowGolem: EntityType; - static readonly spider: EntityType; - static readonly splashPotion: EntityType; - static readonly squid: EntityType; - static readonly stray: EntityType; - static readonly strider: EntityType; - static readonly tadpole: EntityType; - static readonly thrownTrident: EntityType; - static readonly tnt: EntityType; - static readonly tntMinecart: EntityType; - static readonly traderLlama: EntityType; - static readonly tripodCamera: EntityType; - static readonly tropicalfish: EntityType; - static readonly turtle: EntityType; - static readonly vex: EntityType; - static readonly villager: EntityType; - static readonly villagerV2: EntityType; - static readonly vindicator: EntityType; - static readonly wanderingTrader: EntityType; - static readonly warden: EntityType; - static readonly witch: EntityType; - static readonly wither: EntityType; - static readonly witherSkeleton: EntityType; - static readonly witherSkull: EntityType; - static readonly witherSkullDangerous: EntityType; - static readonly wolf: EntityType; - static readonly xpBottle: EntityType; - static readonly xpOrb: EntityType; - static readonly zoglin: EntityType; - static readonly zombie: EntityType; - static readonly zombieHorse: EntityType; - static readonly zombiePigman: EntityType; - static readonly zombieVillager: EntityType; - static readonly zombieVillagerV2: EntityType; + unsubscribe(callback: (arg: GameRuleChangeAfterEvent) => void): void; } + /** * @beta - * Contains definitions of standard Minecraft and Minecraft - * Education Edition block types. + * Represents the game rules for a world experience. */ -export class MinecraftItemTypes { - protected constructor(); - static readonly acaciaBoat: ItemType; +export class GameRules { + private constructor(); /** * @remarks - * Represents an item that can place an acacia button within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly acaciaButton: ItemType; - static readonly acaciaChestBoat: ItemType; + commandBlockOutput: boolean; /** * @remarks - * Represents an item that can place an acacia door within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly acaciaDoor: ItemType; - static readonly acaciaFence: ItemType; + commandBlocksEnabled: boolean; /** * @remarks - * Represents an item that can place an acacia fence gate - * within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly acaciaFenceGate: ItemType; - static readonly acaciaLog: ItemType; + doDayLightCycle: boolean; /** * @remarks - * Represents an item that can place an acacia pressure plate - * within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly acaciaPressurePlate: ItemType; + doEntityDrops: boolean; /** * @remarks - * Represents an item that can place an acacia sign within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly acaciaSign: ItemType; + doFireTick: boolean; /** * @remarks - * Represents an item that can place a set of acacia stairs - * within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly acaciaStairs: ItemType; + doImmediateRespawn: boolean; /** * @remarks - * Represents an item that can place an acacia trapdoor within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly acaciaTrapdoor: ItemType; + doInsomnia: boolean; /** * @remarks - * Represents an item that can place an activator rail within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly activatorRail: ItemType; - static readonly allaySpawnEgg: ItemType; + doLimitedCrafting: boolean; /** * @remarks - * Represents an item that can place an allow block within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly allow: ItemType; + doMobLoot: boolean; /** * @remarks - * Represents an item that can place an amethyst block within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly amethystBlock: ItemType; + doMobSpawning: boolean; /** * @remarks - * Represents an item that can place a cluster of amethyst - * within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly amethystCluster: ItemType; - static readonly amethystShard: ItemType; + doTileDrops: boolean; /** * @remarks - * Represents an item that can place ancient debris within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly ancientDebris: ItemType; + doWeatherCycle: boolean; /** * @remarks - * Represents an item that can place andesite stairs within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly andesiteStairs: ItemType; + drowningDamage: boolean; /** * @remarks - * Represents an item that can place an anvil within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly anvil: ItemType; - static readonly apple: ItemType; - static readonly armorStand: ItemType; - static readonly arrow: ItemType; - static readonly axolotlBucket: ItemType; - static readonly axolotlSpawnEgg: ItemType; + fallDamage: boolean; /** * @remarks - * Represents an item that can place an azalea flowering plant - * within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly azalea: ItemType; + fireDamage: boolean; /** * @remarks - * Represents an item that can place azalea leaves within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly azaleaLeaves: ItemType; + freezeDamage: boolean; /** * @remarks - * Represents flowered azalea leaves within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly azaleaLeavesFlowered: ItemType; - static readonly bakedPotato: ItemType; + functionCommandLimit: number; /** * @remarks - * Represents an item that can place a bamboo tree within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly bamboo: ItemType; - static readonly banner: ItemType; - static readonly bannerPattern: ItemType; + keepInventory: boolean; /** * @remarks - * Represents an item that can place a barrel within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly barrel: ItemType; + maxCommandChainLength: number; /** * @remarks - * Represents an item that can place an invisible but logical - * barrier within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly barrier: ItemType; + mobGriefing: boolean; /** * @remarks - * Represents an item that can place a basalt block within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly basalt: ItemType; - static readonly batSpawnEgg: ItemType; + naturalRegeneration: boolean; /** * @remarks - * Represents an item that can place a beacon within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly beacon: ItemType; + playersSleepingPercentage: number; /** * @remarks - * Represents an item that can place a bed within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly bed: ItemType; + projectilesCanBreakBlocks: boolean; /** * @remarks - * Represents an item that can place a bedrock block within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly bedrock: ItemType; - static readonly beef: ItemType; + pvp: boolean; /** * @remarks - * Represents an item that can place a beehive within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly beehive: ItemType; + randomTickSpeed: number; /** * @remarks - * Represents an item that can place a bee nest within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly beeNest: ItemType; - static readonly beeSpawnEgg: ItemType; + recipesUnlock: boolean; /** * @remarks - * Represents an item that can place a beetroot vegetable - * within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly beetroot: ItemType; - static readonly beetrootSeeds: ItemType; - static readonly beetrootSoup: ItemType; + respawnBlocksExplode: boolean; /** * @remarks - * Represents an item that can place a bell within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly bell: ItemType; + sendCommandFeedback: boolean; /** * @remarks - * Represents an item that can place a big dripleaf plant - * within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly bigDripleaf: ItemType; - static readonly birchBoat: ItemType; + showBorderEffect: boolean; /** * @remarks - * Represents an item that can place a birch button within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly birchButton: ItemType; - static readonly birchChestBoat: ItemType; + showCoordinates: boolean; /** + * @beta * @remarks - * Represents an item that can place a birch door within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly birchDoor: ItemType; - static readonly birchFence: ItemType; + showDaysPlayed: boolean; /** * @remarks - * Represents an item that can place a birch fence gate within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly birchFenceGate: ItemType; - static readonly birchLog: ItemType; + showDeathMessages: boolean; /** * @remarks - * Represents an item that can place a birch pressure plate - * within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly birchPressurePlate: ItemType; + showRecipeMessages: boolean; /** * @remarks - * Represents an item that can place a birch sign within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly birchSign: ItemType; + showTags: boolean; /** * @remarks - * Represents an item that can place a birch stairs block - * within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly birchStairs: ItemType; + spawnRadius: number; /** * @remarks - * Represents an item that can place a birch trapdoor within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly birchTrapdoor: ItemType; + tntExplodes: boolean; /** * @remarks - * Represents an item that can place a black candle within - * Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly blackCandle: ItemType; - static readonly blackCarpet: ItemType; - static readonly blackDye: ItemType; + tntExplosionDropDecay: boolean; +} + +/** + * Provides an adaptable interface for callers to subscribe to + * an event that fires when a button is pushed. + */ +export class IButtonPushAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a black glazed terracotta - * block within Minecraft. + * Subscribes to the event. + * + * This function can't be called in read-only mode. * */ - static readonly blackGlazedTerracotta: ItemType; + subscribe(callback: (arg: ButtonPushAfterEvent) => void): (arg: ButtonPushAfterEvent) => void; /** * @remarks - * Represents an item that can place a blackstone block within - * Minecraft. + * Unsubscribes from the event. + * + * This function can't be called in read-only mode. * */ - static readonly blackstone: ItemType; + 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 - * Represents an item that can place a blackstone slab within - * Minecraft. + * Subscribes to the event. + * + * This function can't be called in read-only mode. * */ - static readonly blackstoneSlab: ItemType; + subscribe(callback: (arg: LeverActionAfterEvent) => void): (arg: LeverActionAfterEvent) => void; /** * @remarks - * Represents blackstone stairs within Minecraft. + * Unsubscribes from the event. + * + * This function can't be called in read-only mode. * */ - static readonly blackstoneStairs: ItemType; + 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 - * Represents an item that can place a blackstone wall within - * Minecraft. + * Subscribes to the event. + * + * This function can't be called in read-only mode. * */ - static readonly blackstoneWall: ItemType; - static readonly blackWool: ItemType; + subscribe(callback: (arg: PlayerJoinAfterEvent) => void): (arg: PlayerJoinAfterEvent) => void; /** * @remarks - * Represents an item that can place a blast furnace within - * Minecraft. + * Unsubscribes from the event. + * + * This function can't be called in read-only mode. * */ - static readonly blastFurnace: ItemType; - static readonly blazePowder: ItemType; - static readonly blazeRod: ItemType; - static readonly blazeSpawnEgg: ItemType; + 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 - * Represents an item that can place a blue candle within - * Minecraft. + * Subscribes to the event. + * + * This function can't be called in read-only mode. * */ - static readonly blueCandle: ItemType; - static readonly blueCarpet: ItemType; - static readonly blueDye: ItemType; + subscribe(callback: (arg: PlayerLeaveAfterEvent) => void): (arg: PlayerLeaveAfterEvent) => void; /** * @remarks - * Represents an item that can place a blue glazed terracotta - * block within Minecraft. + * Unsubscribes from the event. + * + * This function can't be called in read-only mode. * */ - static readonly blueGlazedTerracotta: ItemType; + 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 - * Represents an item that can place a blue ice block within - * Minecraft. + * Subscribes to the event. + * + * This function can't be called in read-only mode. * */ - static readonly blueIce: ItemType; - static readonly blueWool: ItemType; - static readonly boat: ItemType; - static readonly bone: ItemType; + subscribe(callback: (arg: PlayerSpawnAfterEvent) => void): (arg: PlayerSpawnAfterEvent) => void; /** * @remarks - * Represents an item that can place a bone block within - * Minecraft. + * Unsubscribes from the event. + * + * This function can't be called in read-only mode. * */ - static readonly boneBlock: ItemType; - static readonly boneMeal: ItemType; - static readonly book: ItemType; + unsubscribe(callback: (arg: PlayerSpawnAfterEvent) => void): void; +} + +/** + * Contains information related to a chargeable item completing + * being charged. + */ +export class ItemCompleteUseAfterEvent { + private constructor(); /** * @remarks - * Represents an item that can place an unbreakable border - * block within Minecraft. + * Returns the item stack that has completed charging. * */ - static readonly bookshelf: ItemType; + readonly itemStack: ItemStack; /** * @remarks - * Represents an item that can place a border block within - * Minecraft. + * Returns the source entity that triggered this item event. * */ - static readonly borderBlock: ItemType; - static readonly bordureIndentedBannerPattern: ItemType; - static readonly bow: ItemType; - static readonly bowl: ItemType; - static readonly brainCoral: ItemType; - static readonly bread: ItemType; + readonly source: Player; /** * @remarks - * Represents an item that can place a brewing stand within - * Minecraft. + * 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. * */ - static readonly brewingStand: ItemType; - static readonly brick: ItemType; + subscribe(callback: (arg: ItemCompleteUseAfterEvent) => void): (arg: ItemCompleteUseAfterEvent) => void; /** * @remarks - * Represents an item that can place a block of brick within - * Minecraft. + * Removes a callback from being called when a chargeable item + * completes charging. + * + * This function can't be called in read-only mode. * */ - static readonly brickBlock: ItemType; + unsubscribe(callback: (arg: ItemCompleteUseAfterEvent) => void): void; +} + +/** + * @beta + */ +export class ItemCompleteUseEvent { + private constructor(); + readonly itemStack: ItemStack; + readonly source: Player; +} + +/** + * Base class for item components. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class ItemComponent extends Component { + private constructor(); +} + +/** + * @beta + * Contains information regarding an item before it is damaged + * from hitting an entity. + */ +export class ItemComponentBeforeDurabilityDamageEvent { + private constructor(); /** * @remarks - * Represents brick stairs within Minecraft. + * The attacking entity. * */ - static readonly brickStairs: ItemType; + readonly attackingEntity: Entity; /** * @remarks - * Represents an item that can place a brown candle within - * Minecraft. + * The damage applied to the item's durability when the event + * occurs. * */ - static readonly brownCandle: ItemType; - static readonly brownCarpet: ItemType; - static readonly brownDye: ItemType; + durabilityDamage: number; /** * @remarks - * Represents an item that can place a brown glazed terracotta - * block within Minecraft. + * The entity being hit. * */ - static readonly brownGlazedTerracotta: ItemType; + readonly hitEntity: Entity; /** * @remarks - * Represents an item that can place a brown mushroom within - * Minecraft. + * The item stack used to hit the entity. * */ - static readonly brownMushroom: ItemType; + itemStack?: ItemStack; +} + +/** + * @beta + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class ItemComponentCompleteUseEvent extends ItemCompleteUseEvent { + private constructor(); +} + +/** + * @beta + */ +export class ItemComponentConsumeEvent { + private constructor(); + readonly itemStack: ItemStack; + readonly source: Entity; +} + +/** + * @beta + * Contains information regarding when an item is used to hit + * an entity. + */ +export class ItemComponentHitEntityEvent { + private constructor(); /** * @remarks - * Represents an item that can place a block of brown mushroom - * within Minecraft. + * The attacking entity. * */ - static readonly brownMushroomBlock: ItemType; - static readonly brownWool: ItemType; - static readonly bubbleCoral: ItemType; - static readonly bucket: ItemType; + readonly attackingEntity: Entity; /** * @remarks - * Represents an item that can place a block of budding - * amethyst within Minecraft. + * Whether the hit landed or had any effect. * */ - static readonly buddingAmethyst: ItemType; + readonly hadEffect: boolean; /** * @remarks - * Represents an item that can place a cactus within Minecraft. + * The entity being hit. * */ - static readonly cactus: ItemType; + readonly hitEntity: Entity; /** * @remarks - * Represents an item that can place a cake within Minecraft. + * The item stack used to hit the entity. * */ - static readonly cake: ItemType; + readonly itemStack?: ItemStack; +} + +/** + * @beta + * Contains information regarding the mining of a block using + * an item. + */ +export class ItemComponentMineBlockEvent { + private constructor(); /** * @remarks - * Represents an item that can place a calcite block within - * Minecraft. + * The block impacted by this event. * */ - static readonly calcite: ItemType; + readonly block: Block; /** * @remarks - * Represents an item that can place a campfire within - * Minecraft. + * The item stack used to mine the block. * */ - static readonly campfire: ItemType; + readonly itemStack?: ItemStack; /** * @remarks - * Represents an item that can place a candle within Minecraft. + * The block permutation that was mined. * */ - static readonly candle: ItemType; + readonly minedBlockPermutation: BlockPermutation; /** * @remarks - * Represents an item that can place a carpet within Minecraft. + * The entity that mined the block. * */ - static readonly carpet: ItemType; - static readonly carrot: ItemType; - static readonly carrotOnAStick: ItemType; + readonly source: Entity; +} + +/** + * @beta + * Provides the functionality for registering custom components + * for items. + */ +export class ItemComponentRegistry { + private constructor(); /** * @remarks - * Represents an item that can place a cartography table block - * within Minecraft. + * Registers an item custom component that can be used in item + * JSON configuration. * - */ - static readonly cartographyTable: ItemType; - /** - * @remarks - * Represents an item that can place a carved pumpkin within - * Minecraft. + * @param name + * The id that represents this custom component. Must have a + * namespace. This id can be specified in a item's JSON + * configuration under the 'minecraft:custom_components' item + * component. + * @param itemCustomComponent + * The collection of event functions that will be called when + * the event occurs on an item using this custom component id. + * @throws This function can throw errors. * - */ - static readonly carvedPumpkin: ItemType; - static readonly catSpawnEgg: ItemType; - /** - * @remarks - * Represents an item that can place a cauldron within - * Minecraft. + * {@link ItemCustomComponentAlreadyRegisteredError} * - */ - static readonly cauldron: ItemType; - static readonly caveSpiderSpawnEgg: ItemType; - /** - * @remarks - * Represents an item that can place a metallic chain within - * Minecraft. + * {@link ItemCustomComponentNameError} * - */ - static readonly chain: ItemType; - /** - * @remarks - * Represents an item that can place a block that gives off - * heat but not light, within Minecraft Education Edition or - * Bedrock Edition with Education features. + * {@link ItemCustomComponentReloadNewComponentError} * + * {@link ItemCustomComponentReloadNewEventError} + * + * {@link ItemCustomComponentReloadVersionError} */ - static readonly chainCommandBlock: ItemType; - static readonly chainmailBoots: ItemType; - static readonly chainmailChestplate: ItemType; - static readonly chainmailHelmet: ItemType; - static readonly chainmailLeggings: ItemType; - static readonly charcoal: ItemType; + registerCustomComponent(name: string, itemCustomComponent: ItemCustomComponent): void; +} + +/** + * @beta + * Contains information regarding the use of an item. + */ +export class ItemComponentUseEvent { + private constructor(); /** * @remarks - * Represents an item that can place a chest within Minecraft. + * The item stack when the item was used. * */ - static readonly chest: ItemType; - static readonly chestBoat: ItemType; - static readonly chestMinecart: ItemType; - static readonly chicken: ItemType; - static readonly chickenSpawnEgg: ItemType; + readonly itemStack?: ItemStack; /** * @remarks - * Represents an item that can place a set of chiseled - * deepslate within Minecraft. + * The player who used the item. * */ - static readonly chiseledDeepslate: ItemType; + readonly source: Player; +} + +/** + * @beta + * Contains information regarding the use of an item on a block + * via a component. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class ItemComponentUseOnEvent extends ItemUseOnEvent { + private constructor(); /** * @remarks - * Represents an item that can place a block of chiseled nether - * bricks within Minecraft. + * The entity that used the item on the block. * */ - static readonly chiseledNetherBricks: ItemType; + readonly source: Entity; /** * @remarks - * Represents an item that can place a block of chiseled - * polished blackstone within Minecraft. + * The block permutation that the item was used on. * */ - static readonly chiseledPolishedBlackstone: ItemType; + readonly usedOnBlockPermutation: BlockPermutation; +} + +/** + * 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 an item that can place a chorus flower within - * Minecraft. + * Represents the cooldown category that this item is + * associated with. * + * @throws This property can throw when used. */ - static readonly chorusFlower: ItemType; - static readonly chorusFruit: ItemType; + readonly cooldownCategory: string; /** * @remarks - * Represents an item that can place a chorus plant within - * Minecraft. + * Amount of time, in ticks, it will take this item to + * cooldown. * + * @throws This property can throw when used. */ - static readonly chorusPlant: ItemType; + readonly cooldownTicks: number; + static readonly componentId = 'minecraft:cooldown'; /** * @remarks - * Represents an item that can place a block of clay within - * Minecraft. + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly clay: ItemType; - static readonly clayBall: ItemType; - static readonly clock: ItemType; - static readonly coal: ItemType; + getCooldownTicksRemaining(player: Player): number; /** * @remarks - * Represents an item that can place a block of solid coal - * within Minecraft. + * Will return true if the item is the cooldown category passed + * in and false otherwise. + * + * This function can't be called in read-only mode. * + * @param cooldownCategory + * The cooldown category that might be associated with this + * item. + * @returns + * True if the item is the given cooldown category. + * @throws This function can throw errors. */ - static readonly coalBlock: ItemType; + isCooldownCategory(cooldownCategory: string): boolean; /** * @remarks - * Represents an item that can place a block with embedded coal - * ore within Minecraft. + * Starts a new cooldown period for this item. + * + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly coalOre: ItemType; + startCooldown(player: Player): void; +} + +/** + * 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 - * Represents an item that can place a block of cobbled - * deepslate within Minecraft. + * Returns the current damage level of this particular item. + * + * This property can't be edited in read-only mode. * */ - static readonly cobbledDeepslate: ItemType; + damage: number; /** * @remarks - * Represents an item that can place a slab of deepslate within - * Minecraft. + * Represents the amount of damage that this item can take + * before breaking. * + * @throws This property can throw when used. */ - static readonly cobbledDeepslateSlab: ItemType; + readonly maxDurability: number; + static readonly componentId = 'minecraft:durability'; /** * @remarks - * Represents cobbled deepslate stairs within Minecraft. + * Returns the maximum chance that this item would be damaged + * using the damageRange property, given an unbreaking + * enchantment level. + * + * This function can't be called in read-only mode. * + * @param unbreakingEnchantmentLevel + * Unbreaking factor to consider in factoring the damage + * chance. Incoming unbreaking parameter must be within the + * range [0, 3]. + * @throws This function can throw errors. */ - static readonly cobbledDeepslateStairs: ItemType; + getDamageChance(unbreakingEnchantmentLevel?: number): number; /** * @remarks - * Represents an item that can place a cobbled deepslate wall - * within Minecraft. + * A range of numbers that is used to calculate the damage + * chance for an item. The damage chance will fall within this + * range. + * + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly cobbledDeepslateWall: ItemType; + getDamageChanceRange(): minecraftcommon.NumberRange; +} + +/** + * @beta + * When present on an item, this item can have enchantments + * applied to it. + * @example givePlayerIronFireSword.ts + * ```typescript + * // Spawns a bunch of item stacks + * import { EnchantmentType, ItemComponentTypes, ItemStack, Player } from '@minecraft/server'; + * import { MinecraftItemTypes, MinecraftEnchantmentTypes } from '@minecraft/vanilla-data'; + * + * function giveFireSword(player: Player) { + * const ironFireSword = new ItemStack(MinecraftItemTypes.DiamondSword, 1); + * + * const enchantments = ironFireSword?.getComponent(ItemComponentTypes.Enchantable); + * if (enchantments) { + * enchantments.addEnchantment({ type: new EnchantmentType(MinecraftEnchantmentTypes.FireAspect), level: 1 }); + * } + * + * const inventory = player.getComponent('minecraft:inventory'); + * if (inventory === undefined || inventory.container === undefined) { + * return; + * } + * inventory.container.setItem(0, ironFireSword); + * } + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class ItemEnchantableComponent extends ItemComponent { + private constructor(); /** - * @remarks - * Represents an item that can place a block of cobblestone - * within Minecraft. - * + * @throws This property can throw when used. */ - static readonly cobblestone: ItemType; + readonly slots: EnchantmentSlot[]; + static readonly componentId = 'minecraft:enchantable'; /** * @remarks - * Represents an item that can place a wall of cobblestone - * within Minecraft. + * Adds an enchantment to the item stack. + * + * This function can't be called in read-only mode. + * + * @param enchantment + * The enchantment interface to be added. + * @throws + * ScriptItemEnchantmentUnknownIdError: Exception thrown if the + * enchantment type does not exist. + * + * ScriptItemEnchantmentLevelOutOfBoundsError: Exception thrown + * if the enchantment level is outside the allowable range for + * the given enchantment type. + * + * ScriptItemEnchantmentTypeNotCompatibleError: Exception + * thrown if the enchantment is not compatible with the item + * stack. + * + * + * {@link EnchantmentLevelOutOfBoundsError} + * + * {@link EnchantmentTypeNotCompatibleError} + * + * {@link EnchantmentTypeUnknownIdError} * + * {@link Error} */ - static readonly cobblestoneWall: ItemType; - static readonly cocoaBeans: ItemType; - static readonly cod: ItemType; - static readonly codBucket: ItemType; - static readonly codSpawnEgg: ItemType; + addEnchantment(enchantment: Enchantment): void; /** * @remarks - * Represents an item that can place a block that can run - * commands within Minecraft. + * Adds a list of enchantments to the item stack. * + * This function can't be called in read-only mode. + * + * @param enchantments + * The list of enchantments to be added. + * @throws + * ScriptItemEnchantmentUnknownIdError: Exception thrown if any + * enchantment type does not exist. + * + * ScriptItemEnchantmentLevelOutOfBoundsError: Exception thrown + * if any enchantment level is outside the allowable range for + * the given enchantment type. + * + * ScriptItemEnchantmentTypeNotCompatibleError: Exception + * thrown if any enchantment is not compatible with the item + * stack. + * + * + * {@link EnchantmentLevelOutOfBoundsError} + * + * {@link EnchantmentTypeNotCompatibleError} + * + * {@link EnchantmentTypeUnknownIdError} + * + * {@link Error} */ - static readonly commandBlock: ItemType; - static readonly commandBlockMinecart: ItemType; - static readonly comparator: ItemType; - static readonly compass: ItemType; + addEnchantments(enchantments: Enchantment[]): void; /** * @remarks - * Represents an item that can place a composter block within - * Minecraft. + * Checks whether an enchantment can be added to the item + * stack. + * + * @param enchantment + * The enchantment interface to be added. + * @returns + * Returns true if the enchantment can be added to the item + * stack. + * @throws + * ScriptItemEnchantmentUnknownIdError: Exception thrown if the + * enchantment type does not exist. + * + * ScriptItemEnchantmentLevelOutOfBoundsError: Exception thrown + * if the enchantment level is outside the allowable range for + * the given enchantment type. + * + * + * {@link EnchantmentLevelOutOfBoundsError} * + * {@link EnchantmentTypeUnknownIdError} */ - static readonly composter: ItemType; + canAddEnchantment(enchantment: Enchantment): boolean; /** * @remarks - * Represents an item that can place a block of concrete powder - * within Minecraft. + * Gets the enchantment of a given type from the item stack. + * + * @param enchantmentType + * The enchantment type to get. + * @returns + * Returns the enchantment if it exists on the item stack. + * @throws + * ScriptItemEnchantmentUnknownIdError: Exception thrown if the + * enchantment type does not exist. + * * + * {@link EnchantmentTypeUnknownIdError} */ - static readonly concrete: ItemType; - static readonly concretePowder: ItemType; + getEnchantment(enchantmentType: EnchantmentType | string): Enchantment | undefined; /** * @remarks - * Represents an item that can place a conduit block within - * Minecraft. + * Gets all enchantments on the item stack. * + * @returns + * Returns a list of enchantments on the item stack. + * @throws This function can throw errors. */ - static readonly conduit: ItemType; - static readonly cookedBeef: ItemType; - static readonly cookedChicken: ItemType; - static readonly cookedCod: ItemType; - static readonly cookedMutton: ItemType; - static readonly cookedPorkchop: ItemType; - static readonly cookedRabbit: ItemType; - static readonly cookedSalmon: ItemType; - static readonly cookie: ItemType; + getEnchantments(): Enchantment[]; /** * @remarks - * Represents an item that can place a solid block of copper - * within Minecraft. + * Checks whether an item stack has a given enchantment type. + * + * @param enchantmentType + * The enchantment type to check for. + * @returns + * Returns true if the item stack has the enchantment type. + * @throws + * ScriptItemEnchantmentUnknownIdError: Exception thrown if the + * enchantment type does not exist. + * * + * {@link EnchantmentTypeUnknownIdError} */ - static readonly copperBlock: ItemType; - static readonly copperIngot: ItemType; + hasEnchantment(enchantmentType: EnchantmentType | string): boolean; /** * @remarks - * Represents an item that can place a block with embedded - * copper ore within Minecraft. + * Removes all enchantments applied to this item stack. + * + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly copperOre: ItemType; + removeAllEnchantments(): void; /** * @remarks - * Represents coral within Minecraft. + * Removes an enchantment of the given type. + * + * This function can't be called in read-only mode. + * + * @param enchantmentType + * The enchantment type to remove. + * @throws + * ScriptItemEnchantmentUnknownIdError: Exception thrown if the + * enchantment type does not exist. * + * + * {@link EnchantmentTypeUnknownIdError} + * + * {@link Error} */ - static readonly coral: ItemType; + removeEnchantment(enchantmentType: EnchantmentType | string): void; +} + +/** + * 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 - * Represents an item that can place a solid block of coral - * within Minecraft. + * If true, the player can always eat this item (even when not + * hungry). * + * @throws This property can throw when used. */ - static readonly coralBlock: ItemType; + readonly canAlwaysEat: boolean; /** * @remarks - * Represents an item that can place a fan formation of coral - * within Minecraft. + * Represents how much nutrition this food item will give an + * entity when eaten. * + * @throws This property can throw when used. */ - static readonly coralFan: ItemType; + readonly nutrition: number; /** * @remarks - * Represents an item that can place a fan formation of dead - * coral within Minecraft. + * 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. */ - static readonly coralFanDead: ItemType; - static readonly cowSpawnEgg: ItemType; + readonly saturationModifier: number; /** * @remarks - * Represents an item that can place a block of cracked - * deepslate bricks within Minecraft. + * When specified, converts the active item to the one + * specified by this property. * + * @throws This property can throw when used. */ - static readonly crackedDeepslateBricks: ItemType; + readonly usingConvertsTo: string; + static readonly componentId = 'minecraft:food'; +} + +/** + * 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 - * Represents tiles of cracked deepslate within Minecraft. + * Returns the item stack that triggered this item event. * */ - static readonly crackedDeepslateTiles: ItemType; + readonly itemStack?: ItemStack; /** * @remarks - * Represents an item that can place a block of cracked nether - * bricks within Minecraft. + * Returns the source entity that triggered this item event. * */ - static readonly crackedNetherBricks: ItemType; + readonly source: Player; /** * @remarks - * Represents an item that can place a block of cracked and - * polished blackstone bricks within Minecraft. + * Returns the time, in ticks, for the remaining duration left + * before the charge completes its cycle. * */ - static readonly crackedPolishedBlackstoneBricks: ItemType; + readonly useDuration: number; +} + +/** + * Manages callbacks that are connected to the releasing of + * charging for a chargeable item. + */ +export class ItemReleaseUseAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a crafting table within - * Minecraft. + * 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. * */ - static readonly craftingTable: ItemType; - static readonly creeperBannerPattern: ItemType; - static readonly creeperSpawnEgg: ItemType; + subscribe(callback: (arg: ItemReleaseUseAfterEvent) => void): (arg: ItemReleaseUseAfterEvent) => void; /** * @remarks - * Represents an item that can place a crimson button within - * Minecraft. + * Removes a callback from being called when a chargeable item + * is released from charging. + * + * This function can't be called in read-only mode. * */ - static readonly crimsonButton: ItemType; + unsubscribe(callback: (arg: ItemReleaseUseAfterEvent) => void): void; +} + +/** + * Defines a collection of items. + * @example givePlayerIronFireSword.ts + * ```typescript + * // Spawns a bunch of item stacks + * import { EnchantmentType, ItemComponentTypes, ItemStack, Player } from '@minecraft/server'; + * import { MinecraftItemTypes, MinecraftEnchantmentTypes } from '@minecraft/vanilla-data'; + * + * function giveFireSword(player: Player) { + * const ironFireSword = new ItemStack(MinecraftItemTypes.DiamondSword, 1); + * + * const enchantments = ironFireSword?.getComponent(ItemComponentTypes.Enchantable); + * if (enchantments) { + * enchantments.addEnchantment({ type: new EnchantmentType(MinecraftEnchantmentTypes.FireAspect), level: 1 }); + * } + * + * const inventory = player.getComponent('minecraft:inventory'); + * if (inventory === undefined || inventory.container === undefined) { + * return; + * } + * inventory.container.setItem(0, ironFireSword); + * } + * ``` + * @example givePlayerEquipment.ts + * ```typescript + * // Gives the player some equipment + * import { EquipmentSlot, ItemStack, Player, EntityComponentTypes } from '@minecraft/server'; + * import { MinecraftItemTypes } from '@minecraft/vanilla-data'; + * + * function giveEquipment(player: Player) { + * const equipmentCompPlayer = player.getComponent(EntityComponentTypes.Equippable); + * if (equipmentCompPlayer) { + * equipmentCompPlayer.setEquipment(EquipmentSlot.Head, new ItemStack(MinecraftItemTypes.GoldenHelmet)); + * equipmentCompPlayer.setEquipment(EquipmentSlot.Chest, new ItemStack(MinecraftItemTypes.IronChestplate)); + * equipmentCompPlayer.setEquipment(EquipmentSlot.Legs, new ItemStack(MinecraftItemTypes.DiamondLeggings)); + * equipmentCompPlayer.setEquipment(EquipmentSlot.Feet, new ItemStack(MinecraftItemTypes.NetheriteBoots)); + * equipmentCompPlayer.setEquipment(EquipmentSlot.Mainhand, new ItemStack(MinecraftItemTypes.WoodenSword)); + * equipmentCompPlayer.setEquipment(EquipmentSlot.Offhand, new ItemStack(MinecraftItemTypes.Shield)); + * } else { + * console.warn('No equipment component found on player'); + * } + * } + * ``` + * @example spawnFeatherItem.ts + * ```typescript + * // Spawns a feather at a location + * import { ItemStack, DimensionLocation } from '@minecraft/server'; + * import { MinecraftItemTypes } from '@minecraft/vanilla-data'; + * + * function spawnFeather(location: DimensionLocation) { + * const featherItem = new ItemStack(MinecraftItemTypes.Feather, 1); + * location.dimension.spawnItem(featherItem, location); + * } + * ``` + */ +export class ItemStack { /** * @remarks - * Represents an item that can place a crimson door within - * Minecraft. + * 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. * - */ - static readonly crimsonDoor: ItemType; - /** - * @remarks - * Represents an item that can place a crimson fence within - * Minecraft. + * This property can't be edited in read-only mode. * + * @throws + * Throws if the value is outside the range of 1-255. */ - static readonly crimsonFence: ItemType; + amount: number; /** * @remarks - * Represents an item that can place a crimson fence gate - * within Minecraft. + * 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. * */ - static readonly crimsonFenceGate: ItemType; + readonly isStackable: boolean; /** * @remarks - * Represents an item that can place a crimson fungus within - * Minecraft. + * Gets or sets whether the item is kept on death. * - */ - static readonly crimsonFungus: ItemType; - /** - * @remarks - * Represents crimson hyphae within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly crimsonHyphae: ItemType; + keepOnDeath: boolean; /** * @remarks - * Represents crimson nylium within Minecraft. + * Gets or sets the item's lock mode. The default value is + * `ItemLockMode.none`. * - */ - static readonly crimsonNylium: ItemType; - /** - * @remarks - * Represents an item that can place a set of crimson planks - * within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly crimsonPlanks: ItemType; + lockMode: ItemLockMode; /** * @remarks - * Represents an item that can place a crimson pressure plate - * within Minecraft. + * 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. * */ - static readonly crimsonPressurePlate: ItemType; + readonly maxAmount: number; /** * @remarks - * Represents an item that can place a set of crimson roots - * within Minecraft. + * 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. */ - static readonly crimsonRoots: ItemType; - static readonly crimsonSign: ItemType; + nameTag?: string; /** * @remarks - * Represents an item that can place a crimson slab within - * Minecraft. + * The type of the item. * */ - static readonly crimsonSlab: ItemType; + readonly 'type': ItemType; /** * @remarks - * Represents an item that can place a set of crimson stairs - * within Minecraft. + * Identifier of the type of items for the stack. If a + * namespace is not specified, 'minecraft:' is assumed. + * Examples include 'wheat' or 'apple'. * */ - static readonly crimsonStairs: ItemType; + readonly typeId: string; /** * @remarks - * Represents an item that can place a crimson stem within - * Minecraft. + * 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. */ - static readonly crimsonStem: ItemType; + constructor(itemType: ItemType | string, amount?: number); /** * @remarks - * Represents an item that can place a crimson trapdoor within - * Minecraft. + * Clears all dynamic properties that have been set on this + * item stack. * */ - static readonly crimsonTrapdoor: ItemType; - static readonly crossbow: ItemType; + clearDynamicProperties(): void; /** * @remarks - * Represents crying obsidian within Minecraft. + * Creates an exact copy of the item stack, including any + * custom data or properties. * + * @returns + * Returns a copy of this item stack. */ - static readonly cryingObsidian: ItemType; + clone(): ItemStack; /** * @remarks - * Represents an item that can place a cut copper block within - * Minecraft. + * Get the list of block types this item can break in Adventure + * mode. + * + * This function can't be called in read-only mode. * */ - static readonly cutCopper: ItemType; + getCanDestroy(): string[]; /** * @remarks - * Represents an item that can place a cut copper slab within - * Minecraft. + * 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. * */ - static readonly cutCopperSlab: ItemType; + getCanPlaceOn(): string[]; /** * @remarks - * Represents an item that can place a set of cut copper stairs - * within Minecraft. + * Gets a component (that represents additional capabilities) + * for an item stack. * + * @param componentId + * The identifier of the component (e.g., 'minecraft:food'). If + * no namespace prefix is specified, 'minecraft:' is assumed. + * Available component IDs can be found as part of the {@link + * ItemComponentTypes} enum. + * @returns + * Returns the component if it exists on the item stack, + * otherwise undefined. + * @example durability.ts + * ```typescript + * // Gives a player a half-damaged diamond sword + * import { ItemStack, Player, ItemComponentTypes, EntityComponentTypes } from '@minecraft/server'; + * import { MinecraftItemTypes } from '@minecraft/vanilla-data'; + * + * function giveHurtDiamondSword(player: Player) { + * const hurtDiamondSword = new ItemStack(MinecraftItemTypes.DiamondSword); + * const durabilityComponent = hurtDiamondSword.getComponent(ItemComponentTypes.Durability); + * if (durabilityComponent !== undefined) { + * durabilityComponent.damage = durabilityComponent.maxDurability / 2; + * } + * + * const inventory = player.getComponent(EntityComponentTypes.Inventory); + * if (inventory === undefined || inventory.container === undefined) { + * return; + * } + * + * inventory.container.addItem(hurtDiamondSword); + * } + * ``` */ - static readonly cutCopperStairs: ItemType; + getComponent(componentId: T): ItemComponentTypeMap[T] | undefined; /** * @remarks - * Represents an item that can place a cyan-colored candle - * within Minecraft. + * Returns all components that are both present on this item + * stack and supported by the API. * */ - static readonly cyanCandle: ItemType; - static readonly cyanCarpet: ItemType; - static readonly cyanDye: ItemType; + getComponents(): ItemComponent[]; /** * @remarks - * Represents an item that can place a block of cyan-colored - * glazed terracotta within Minecraft. + * 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. */ - static readonly cyanGlazedTerracotta: ItemType; - static readonly cyanWool: ItemType; - static readonly darkOakBoat: ItemType; + getDynamicProperty(identifier: string): boolean | number | string | Vector3 | undefined; /** * @remarks - * Represents an item that can place a dark oak button within - * Minecraft. + * Returns the available set of dynamic property identifiers + * that have been used on this entity. * + * @returns + * A string array of the dynamic properties set on this entity. */ - static readonly darkOakButton: ItemType; - static readonly darkOakChestBoat: ItemType; + getDynamicPropertyIds(): string[]; /** * @remarks - * Represents an item that can place a dark oak door within - * Minecraft. + * Returns the total size, in bytes, of all the dynamic + * properties that are currently stored for this entity. This + * includes the size of both the key and the value. This can + * be useful for diagnosing performance warning signs - if, for + * example, an entity has many megabytes of associated dynamic + * properties, it may be slow to load on various devices. * */ - static readonly darkOakDoor: ItemType; - static readonly darkOakFence: ItemType; + getDynamicPropertyTotalByteCount(): number; /** * @remarks - * Represents an item that can place a dark oak fence gate - * within Minecraft. + * 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. */ - static readonly darkOakFenceGate: ItemType; - static readonly darkOakLog: ItemType; + getLore(): string[]; /** * @remarks - * Represents an item that can place a dark oak pressure plate - * within Minecraft. + * Returns a set of tags associated with this item stack. * */ - static readonly darkOakPressurePlate: ItemType; + getTags(): string[]; /** * @remarks - * Represents an item that can place a dark oak sign within - * Minecraft. + * 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. */ - static readonly darkOakSign: ItemType; + hasComponent(componentId: string): boolean; /** * @remarks - * Represents an item that can place a set of dark oak stairs - * within Minecraft. + * 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. */ - static readonly darkOakStairs: ItemType; + hasTag(tag: string): boolean; /** * @remarks - * Represents an item that can place a dark oak trapdoor within - * Minecraft. + * 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. */ - static readonly darkOakTrapdoor: ItemType; + isStackableWith(itemStack: ItemStack): boolean; /** + * @beta * @remarks - * Represents an item that can place a set of dark prismarine - * stairs within Minecraft. + * Version safe way of checking if an item matches. * + * @param itemName + * Identifier of the item. + * @param states + * Applicable only for blocks. An optional set of states to + * compare against. If states is not specified, matches checks + * against the set of types more broadly. + * @returns + * Returns a boolean whether the specified item matches. */ - static readonly darkPrismarineStairs: ItemType; + matches(itemName: string, states?: Record): boolean; /** * @remarks - * Represents an item that can place a daylight detector within - * Minecraft. + * 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 + * const specialPickaxe = new ItemStack('minecraft:diamond_pickaxe'); + * specialPickaxe.setCanDestroy(['minecraft:cobblestone', 'minecraft:obsidian']); + * + * // Creates a diamond pickaxe that can destroy cobblestone and obsidian + * import { ItemStack, Player } from '@minecraft/server'; + * import { MinecraftItemTypes } from '@minecraft/vanilla-data'; + * + * function giveRestrictedPickaxe(player: Player) { + * const specialPickaxe = new ItemStack(MinecraftItemTypes.DiamondPickaxe); + * specialPickaxe.setCanPlaceOn([MinecraftItemTypes.Cobblestone, MinecraftItemTypes.Obsidian]); * + * const inventory = player.getComponent('inventory'); + * if (inventory === undefined || inventory.container === undefined) { + * return; + * } + * + * inventory.container.addItem(specialPickaxe); + * } + * ``` */ - static readonly daylightDetector: ItemType; - static readonly deadBrainCoral: ItemType; - static readonly deadBubbleCoral: ItemType; + setCanDestroy(blockIdentifiers?: string[]): void; /** * @remarks - * Represents an item that can place a dead bush within - * Minecraft. + * 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 + * import { ItemStack, Player, EntityComponentTypes } from '@minecraft/server'; + * import { MinecraftItemTypes } from '@minecraft/vanilla-data'; + * + * function giveRestrictedGoldBlock(player: Player) { + * const specialGoldBlock = new ItemStack(MinecraftItemTypes.GoldBlock); + * specialGoldBlock.setCanPlaceOn([MinecraftItemTypes.Grass, MinecraftItemTypes.Dirt]); + * + * const inventory = player.getComponent(EntityComponentTypes.Inventory); + * if (inventory === undefined || inventory.container === undefined) { + * return; + * } + * + * inventory.container.addItem(specialGoldBlock); + * } + * ``` */ - static readonly deadbush: ItemType; - static readonly deadFireCoral: ItemType; - static readonly deadHornCoral: ItemType; - static readonly deadTubeCoral: ItemType; + setCanPlaceOn(blockIdentifiers?: string[]): void; /** * @remarks - * Represents an item that can place a block of deepslate - * within Minecraft. + * Sets a specified property to a value. Note: This function + * only works with non-stackable items. * + * @param identifier + * The property identifier. + * @param value + * Data value of the property to set. + * @throws + * Throws if the item stack is stackable. */ - static readonly deepslate: ItemType; + setDynamicProperty(identifier: string, value?: boolean | number | string | Vector3): void; /** * @remarks - * Represents an item that can place a block of deepslate - * bricks within Minecraft. + * 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 + * import { EntityComponentTypes, ItemStack, Player } from '@minecraft/server'; + * import { MinecraftItemTypes } from '@minecraft/vanilla-data'; + * + * function giveAwesomeSword(player: Player) { + * const diamondAwesomeSword = new ItemStack(MinecraftItemTypes.DiamondSword, 1); + * 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 = player.getComponent(EntityComponentTypes.Inventory); + * if (inventory === undefined || inventory.container === undefined) { + * return; + * } + * + * inventory.container.setItem(0, diamondAwesomeSword); + * } + * ``` */ - static readonly deepslateBricks: ItemType; + setLore(loreList?: string[]): void; +} + +/** + * Contains information related to a chargeable item starting + * to be charged. + */ +export class ItemStartUseAfterEvent { + private constructor(); /** * @remarks - * Represents an item that can place a slab of deepslate brick - * within Minecraft. + * The impacted item stack that is starting to be charged. * */ - static readonly deepslateBrickSlab: ItemType; + readonly itemStack: ItemStack; /** * @remarks - * Represents an item that can place a set of deepslate brick - * stairs within Minecraft. + * Returns the source entity that triggered this item event. * */ - static readonly deepslateBrickStairs: ItemType; + readonly source: Player; /** * @remarks - * Represents an item that can place a deepslate brick wall - * within Minecraft. + * Returns the time, in ticks, for the remaining duration left + * before the charge completes its cycle. * */ - static readonly deepslateBrickWall: ItemType; + readonly useDuration: number; +} + +/** + * Manages callbacks that are connected to the start of + * charging for a chargeable item. + */ +export class ItemStartUseAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a block of deepslate with - * embedded coal ore within Minecraft. + * Adds a callback that will be called when a chargeable item + * starts charging. + * + * This function can't be called in read-only mode. * */ - static readonly deepslateCoalOre: ItemType; + subscribe(callback: (arg: ItemStartUseAfterEvent) => void): (arg: ItemStartUseAfterEvent) => void; /** * @remarks - * Represents an item that can place a block of deepslate with - * embedded copper ore within Minecraft. + * Removes a callback from being called when a chargeable item + * starts charging. + * + * This function can't be called in read-only mode. * */ - static readonly deepslateCopperOre: ItemType; + 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 - * Represents an item that can place a block of deepslate with - * embedded diamond ore within Minecraft. + * The block that the item is used on. * */ - static readonly deepslateDiamondOre: ItemType; + readonly block: Block; /** * @remarks - * Represents an item that can place a block of deepslate with - * embedded emerald ore within Minecraft. + * The face of the block that an item is being used on. * */ - static readonly deepslateEmeraldOre: ItemType; + readonly blockFace: Direction; /** * @remarks - * Represents an item that can place a block of deepslate with - * embedded gold ore within Minecraft. + * The impacted item stack that is starting to be used. Can be + * undefined in some gameplay scenarios like pushing a button + * with an empty hand. * */ - static readonly deepslateGoldOre: ItemType; + readonly itemStack?: ItemStack; /** * @remarks - * Represents an item that can place a block of deepslate with - * embedded iron ore within Minecraft. + * Returns the source entity that triggered this item event. * */ - static readonly deepslateIronOre: ItemType; + readonly source: Player; +} + +/** + * Manages callbacks that are connected to an item starting + * being used on a block event. + */ +export class ItemStartUseOnAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a block of deepslate with - * embedded lapis lazuli ore within Minecraft. + * 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. * */ - static readonly deepslateLapisOre: ItemType; + subscribe(callback: (arg: ItemStartUseOnAfterEvent) => void): (arg: ItemStartUseOnAfterEvent) => void; /** * @remarks - * Represents an item that can place a block of deepslate with - * embedded redstone ore within Minecraft. + * Removes a callback from being called when an item is used on + * a block. + * + * This function can't be called in read-only mode. * */ - static readonly deepslateRedstoneOre: ItemType; + 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 - * Represents an item that can place a set of deepslate tiles - * within Minecraft. + * The impacted item stack that is stopping being charged. + * ItemStopUseAfterEvent can be called when teleporting to a + * different dimension and this can be undefined. * */ - static readonly deepslateTiles: ItemType; + readonly itemStack?: ItemStack; /** * @remarks - * Represents an item that can place a slab of deepslate tiles - * within Minecraft. + * Returns the source entity that triggered this item event. * */ - static readonly deepslateTileSlab: ItemType; + readonly source: Player; /** * @remarks - * Represents an item that can place a set of deepslate tile - * stairs within Minecraft. + * Returns the time, in ticks, for the remaining duration left + * before the charge completes its cycle. * */ - static readonly deepslateTileStairs: ItemType; + 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 - * Represents an item that can place a wall of deepslate tile - * within Minecraft. + * Adds a callback that will be called when a chargeable item + * stops charging. + * + * This function can't be called in read-only mode. * */ - static readonly deepslateTileWall: ItemType; + subscribe(callback: (arg: ItemStopUseAfterEvent) => void): (arg: ItemStopUseAfterEvent) => void; /** * @remarks - * Represents an item that can place a logical but generally - * invisible Deny logic block within Minecraft. + * Removes a callback from being called when a chargeable item + * stops charging. + * + * This function can't be called in read-only mode. * */ - static readonly deny: ItemType; + 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 - * Represents an item that can place a detector rail within - * Minecraft. + * The block that the item is used on. * */ - static readonly detectorRail: ItemType; - static readonly diamond: ItemType; - static readonly diamondAxe: ItemType; + readonly block: Block; /** * @remarks - * Represents an item that can place a block of diamond within - * Minecraft. + * The impacted item stack that is being used on a block. * */ - static readonly diamondBlock: ItemType; - static readonly diamondBoots: ItemType; - static readonly diamondChestplate: ItemType; - static readonly diamondHelmet: ItemType; - static readonly diamondHoe: ItemType; - static readonly diamondHorseArmor: ItemType; - static readonly diamondLeggings: ItemType; + readonly itemStack?: ItemStack; /** * @remarks - * Represents an item that can place a block with embedded - * diamond ore within Minecraft. + * Returns the source entity that triggered this item event. * */ - static readonly diamondOre: ItemType; - static readonly diamondPickaxe: ItemType; - static readonly diamondShovel: ItemType; - static readonly diamondSword: ItemType; + readonly source: Player; +} + +/** + * Manages callbacks that are connected to an item stops used + * on a block event. + */ +export class ItemStopUseOnAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a set of diorite stairs - * within Minecraft. + * 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. * */ - static readonly dioriteStairs: ItemType; + subscribe(callback: (arg: ItemStopUseOnAfterEvent) => void): (arg: ItemStopUseOnAfterEvent) => void; /** * @remarks - * Represents an item that can place a block of dirt within - * Minecraft. + * Removes a callback from being called when an item is used on + * a block. + * + * This function can't be called in read-only mode. * */ - static readonly dirt: ItemType; + unsubscribe(callback: (arg: ItemStopUseOnAfterEvent) => void): void; +} + +/** + * Represents the type of an item - for example, Wool. + */ +export class ItemType { + private constructor(); /** * @remarks - * Represents an item that can place a block of dirt with roots - * within Minecraft. + * Returns the identifier of the item type - for example, + * 'minecraft:apple'. * */ - static readonly dirtWithRoots: ItemType; - static readonly discFragment5: ItemType; + readonly id: string; +} + +/** + * @beta + * Returns the set of item types registered within Minecraft. + */ +export class ItemTypes { + private constructor(); /** * @remarks - * Represents an item that can place a dispenser within - * Minecraft. + * Returns a specific item type, if available within Minecraft. * */ - static readonly dispenser: ItemType; - static readonly dolphinSpawnEgg: ItemType; - static readonly donkeySpawnEgg: ItemType; + static get(itemId: string): ItemType | undefined; /** * @remarks - * Represents an item that can place a double plant within + * Retrieves all available item types registered within * Minecraft. * */ - static readonly doublePlant: ItemType; - static readonly dragonBreath: ItemType; + static getAll(): ItemType[]; +} + +/** + * Contains information related to an item being used on a + * block. This event fires when an item used by a player + * successfully triggers an entity interaction. + */ +export class ItemUseAfterEvent { + private constructor(); /** * @remarks - * Represents an item that can place a dragon egg within - * Minecraft. + * The impacted item stack that is being used. * */ - static readonly dragonEgg: ItemType; - static readonly driedKelp: ItemType; + itemStack: ItemStack; /** * @remarks - * Represents an item that can place a block of dried kelp - * within Minecraft. + * Returns the source entity that triggered this item event. * */ - static readonly driedKelpBlock: ItemType; + readonly source: Player; +} + +/** + * Manages callbacks that are connected to an item use event. + */ +export class ItemUseAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a block of dripstone - * within Minecraft. + * Adds a callback that will be called when an item is used. + * + * This function can't be called in read-only mode. * */ - static readonly dripstoneBlock: ItemType; + subscribe(callback: (arg: ItemUseAfterEvent) => void): (arg: ItemUseAfterEvent) => void; /** * @remarks - * Represents an item that can place a dropper within - * Minecraft. + * Removes a callback from being called when an item is used. + * + * This function can't be called in read-only mode. * */ - static readonly dropper: ItemType; - static readonly drownedSpawnEgg: ItemType; - static readonly dye: ItemType; - static readonly echoShard: ItemType; - static readonly egg: ItemType; - static readonly elderGuardianSpawnEgg: ItemType; - static readonly elytra: ItemType; - static readonly emerald: ItemType; + 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 - * Represents an item that can place a block of emerald within - * Minecraft. + * If set to true, this will cancel the item use behavior. * */ - static readonly emeraldBlock: ItemType; + cancel: boolean; +} + +/** + * Manages callbacks that fire before an item is used. + */ +export class ItemUseBeforeEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a block with embedded - * emerald ore within Minecraft. + * Adds a callback that will be called before an item is used. + * + * This function can't be called in read-only mode. * */ - static readonly emeraldOre: ItemType; - static readonly emptyMap: ItemType; - static readonly enchantedBook: ItemType; - static readonly enchantedGoldenApple: ItemType; + subscribe(callback: (arg: ItemUseBeforeEvent) => void): (arg: ItemUseBeforeEvent) => void; /** * @remarks - * Represents an item that can place an enchanting table within - * Minecraft. + * Removes a callback from being called before an item is used. + * + * This function can't be called in read-only mode. * */ - static readonly enchantingTable: ItemType; + unsubscribe(callback: (arg: ItemUseBeforeEvent) => void): void; +} + +/** + * Contains information related to an item being used on a + * block. This event fires when an item used by a player + * successfully triggers a block interaction. + */ +export class ItemUseOnAfterEvent { + private constructor(); /** * @remarks - * Represents an item that can place an end bricks block within - * Minecraft. + * The block that the item is used on. * */ - static readonly endBricks: ItemType; + readonly block: Block; /** * @remarks - * Represents an item that can place a set of end brick stairs - * within Minecraft. + * The face of the block that an item is being used on. * */ - static readonly endBrickStairs: ItemType; - static readonly endCrystal: ItemType; + readonly blockFace: Direction; /** * @remarks - * Represents an item that can place an ender chest within - * Minecraft. + * Location relative to the bottom north-west corner of the + * block where the item is placed. * */ - static readonly enderChest: ItemType; - static readonly enderDragonSpawnEgg: ItemType; - static readonly enderEye: ItemType; - static readonly endermanSpawnEgg: ItemType; - static readonly endermiteSpawnEgg: ItemType; - static readonly enderPearl: ItemType; + readonly faceLocation: Vector3; /** * @remarks - * Represents an item that can place an end portal frame within - * Minecraft. + * The impacted item stack that is being used on a block. * */ - static readonly endPortalFrame: ItemType; + readonly itemStack: ItemStack; /** * @remarks - * Represents an item that can place an end rod within - * Minecraft. + * Returns the source entity that triggered this item event. * */ - static readonly endRod: ItemType; + readonly source: Player; +} + +/** + * Manages callbacks that are connected to an item being used + * on a block event. + */ +export class ItemUseOnAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place an end stone block within - * Minecraft. + * 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. * */ - static readonly endStone: ItemType; - static readonly evokerSpawnEgg: ItemType; - static readonly experienceBottle: ItemType; + subscribe(callback: (arg: ItemUseOnAfterEvent) => void): (arg: ItemUseOnAfterEvent) => void; /** * @remarks - * Represents an item that can place a block of exposed copper - * within Minecraft. + * Removes a callback from being called when an item is used on + * a block. + * + * This function can't be called in read-only mode. * */ - static readonly exposedCopper: ItemType; + 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 - * Represents an item that can place a block of exposed cut - * copper within Minecraft. + * If set to true, this will cancel the item use behavior. * */ - static readonly exposedCutCopper: ItemType; + cancel: boolean; +} + +/** + * Manages callbacks that fire before an item being used on a + * block event. + */ +export class ItemUseOnBeforeEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a slab of exposed cut - * copper within Minecraft. + * 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. * */ - static readonly exposedCutCopperSlab: ItemType; + subscribe(callback: (arg: ItemUseOnBeforeEvent) => void): (arg: ItemUseOnBeforeEvent) => void; /** * @remarks - * Represents an item that can place a set of exposed cut - * copper stairs within Minecraft. + * Removes a callback from being called before an item is used + * on a block. + * + * This function can't be called in read-only mode. * */ - static readonly exposedCutCopperStairs: ItemType; + unsubscribe(callback: (arg: ItemUseOnBeforeEvent) => void): void; +} + +/** + * @beta + * Contains information regarding the use of an item on a + * block. + */ +export class ItemUseOnEvent { + private constructor(); /** * @remarks - * Represents an item that can place a farmland block within - * Minecraft. + * The block impacted by this event. * */ - static readonly farmland: ItemType; - static readonly feather: ItemType; + readonly block: Block; /** * @remarks - * Represents an item that can place a fence within Minecraft. + * The face of the block that the item was used on. * */ - static readonly fence: ItemType; + readonly blockFace: Direction; /** * @remarks - * Represents an item that can place a fence gate within - * Minecraft. + * Location relative to the bottom north-west corner of the + * block that the item was used on. * */ - static readonly fenceGate: ItemType; - static readonly fermentedSpiderEye: ItemType; - static readonly fieldMasonedBannerPattern: ItemType; - static readonly filledMap: ItemType; - static readonly fireCharge: ItemType; - static readonly fireCoral: ItemType; - static readonly fireworkRocket: ItemType; - static readonly fireworkStar: ItemType; - static readonly fishingRod: ItemType; + readonly faceLocation: Vector3; /** * @remarks - * Represents an item that can place a fletching table within - * Minecraft. + * The item stack used on the block. * */ - static readonly fletchingTable: ItemType; - static readonly flint: ItemType; - static readonly flintAndSteel: ItemType; - static readonly flowerBannerPattern: ItemType; + readonly itemStack: ItemStack; +} + +/** + * Contains information related to changes to a lever + * activating or deactivating. + * @example leverActionEvent.ts + * ```typescript + * import { world, system, LeverActionAfterEvent } from '@minecraft/server'; + * + * world.afterEvents.leverAction.subscribe((leverActivateEvent: LeverActionAfterEvent) => { + * console.warn( + * `Lever event at ${system.currentTick} with power: ${leverActivateEvent.block.getRedstonePower()}`, + * ); + * }); + * + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class LeverActionAfterEvent extends BlockEvent { + private constructor(); /** * @remarks - * Represents an item that can place a flowering azalea plant - * within Minecraft. + * True if the lever is activated (that is, transmitting + * power). * */ - static readonly floweringAzalea: ItemType; + readonly isPowered: boolean; /** * @remarks - * Represents an item that can place a flower pot within - * Minecraft. + * Optional player that triggered the lever activation. * */ - static readonly flowerPot: ItemType; - static readonly foxSpawnEgg: ItemType; + readonly player: Player; +} + +/** + * Manages callbacks that are connected to lever moves + * (activates or deactivates). + * @example leverActionEvent.ts + * ```typescript + * import { world, system, LeverActionAfterEvent } from '@minecraft/server'; + * + * world.afterEvents.leverAction.subscribe((leverActivateEvent: LeverActionAfterEvent) => { + * console.warn( + * `Lever event at ${system.currentTick} with power: ${leverActivateEvent.block.getRedstonePower()}`, + * ); + * }); + * + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class LeverActionAfterEventSignal extends ILeverActionAfterEventSignal { + private constructor(); +} + +/** + * @beta + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class ListBlockVolume extends BlockVolumeBase { + constructor(locations: Vector3[]); /** * @remarks - * Represents an item that can place a frame within Minecraft. + * This function can't be called in read-only mode. * */ - static readonly frame: ItemType; - static readonly frogSpawn: ItemType; - static readonly frogSpawnEgg: ItemType; + add(locations: Vector3[]): void; /** * @remarks - * Represents an item that can place a frosted ice block within - * Minecraft. + * This function can't be called in read-only mode. * */ - static readonly frostedIce: ItemType; + remove(locations: Vector3[]): void; +} + +/** + * @beta + * A specific currently-internal event used for passing + * messages from client to server. + */ +export class MessageReceiveAfterEvent { + private constructor(); /** * @remarks - * Represents an item that can place a furnace within - * Minecraft. + * The message identifier. * */ - static readonly furnace: ItemType; - static readonly ghastSpawnEgg: ItemType; - static readonly ghastTear: ItemType; + readonly id: string; /** * @remarks - * Represents an item that can place a block of gilded - * blackstone within Minecraft. + * The message. * */ - static readonly gildedBlackstone: ItemType; + readonly message: string; /** * @remarks - * Represents an item that can place a glass block within - * Minecraft. + * The player who sent the message. * */ - static readonly glass: ItemType; - static readonly glassBottle: ItemType; + readonly player: Player; +} + +/** + * DEPRECATED + * Use @minecraft/vanilla-data.MinecraftDimensionTypes + * A collection of default Minecraft dimension types. + */ +export class MinecraftDimensionTypes { + private constructor(); /** * @remarks - * Represents an item that can place a pane of glass within - * Minecraft. + * 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 glassPane: ItemType; - static readonly glisteringMelonSlice: ItemType; - static readonly globeBannerPattern: ItemType; - static readonly glowBerries: ItemType; + static readonly nether = 'minecraft:nether'; /** * @remarks - * Represents an item that can place a glowing frame within - * Minecraft. + * 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 glowFrame: ItemType; - static readonly glowInkSac: ItemType; + static readonly overworld = 'minecraft:overworld'; /** * @remarks - * Represents glow lichen within Minecraft. + * 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 glowLichen: ItemType; - static readonly glowSquidSpawnEgg: ItemType; + 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 - * Represents an item that can place a block of glowstone - * within Minecraft. + * 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. */ - static readonly glowstone: ItemType; - static readonly glowstoneDust: ItemType; - static readonly goatHorn: ItemType; - static readonly goatSpawnEgg: ItemType; + setColorRGB(variableName: string, color: RGB): void; /** * @remarks - * Represents an item that can place a gold block within - * Minecraft. + * 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. */ - static readonly goldBlock: ItemType; - static readonly goldenApple: ItemType; - static readonly goldenAxe: ItemType; - static readonly goldenBoots: ItemType; - static readonly goldenCarrot: ItemType; - static readonly goldenChestplate: ItemType; - static readonly goldenHelmet: ItemType; - static readonly goldenHoe: ItemType; - static readonly goldenHorseArmor: ItemType; - static readonly goldenLeggings: ItemType; - static readonly goldenPickaxe: ItemType; + setColorRGBA(variableName: string, color: RGBA): void; /** * @remarks - * Represents an item that can place a golden rail element - * within Minecraft. + * 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. */ - static readonly goldenRail: ItemType; - static readonly goldenShovel: ItemType; - static readonly goldenSword: ItemType; - static readonly goldIngot: ItemType; - static readonly goldNugget: ItemType; + setFloat(variableName: string, number: number): void; /** * @remarks - * Represents an item that can place a block with embedded gold - * ore within Minecraft. + * 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. */ - static readonly goldOre: ItemType; + setSpeedAndDirection(variableName: string, speed: number, direction: Vector3): void; /** * @remarks - * Represents an item that can place a set of granite stairs - * within Minecraft. + * 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. */ - static readonly graniteStairs: ItemType; + setVector3(variableName: string, vector: Vector3): void; +} + +/** + * Contains information related to changes to a piston + * expanding or retracting. + * @example pistonAfterEvent.ts + * ```typescript + * import { world, system, PistonActivateAfterEvent } from '@minecraft/server'; + * + * world.afterEvents.pistonActivate.subscribe((pistonEvent: PistonActivateAfterEvent) => { + * console.warn( + * `Piston event at ${system.currentTick} ${(pistonEvent.piston.isMoving ? ' Moving' : 'Not moving')} with state: ${pistonEvent.piston.state}`, + * ); + * }); + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class PistonActivateAfterEvent extends BlockEvent { + private constructor(); /** * @remarks - * Represents an item that can place a block of dirt and grass - * within Minecraft. + * True if the piston is the process of expanding. * */ - static readonly grass: ItemType; + readonly isExpanding: boolean; /** * @remarks - * Represents an item that can place a block of dirt and grass - * with a path within Minecraft. + * Contains additional properties and details of the piston. * */ - static readonly grassPath: ItemType; + readonly piston: BlockPistonComponent; +} + +/** + * Manages callbacks that are connected to piston activations. + * @example pistonAfterEvent.ts + * ```typescript + * import { world, system, PistonActivateAfterEvent } from '@minecraft/server'; + * + * world.afterEvents.pistonActivate.subscribe((pistonEvent: PistonActivateAfterEvent) => { + * console.warn( + * `Piston event at ${system.currentTick} ${(pistonEvent.piston.isMoving ? ' Moving' : 'Not moving')} with state: ${pistonEvent.piston.state}`, + * ); + * }); + * ``` + */ +export class PistonActivateAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a block of gravel within - * Minecraft. + * This function can't be called in read-only mode. * */ - static readonly gravel: ItemType; + subscribe(callback: (arg: PistonActivateAfterEvent) => void): (arg: PistonActivateAfterEvent) => void; /** * @remarks - * Represents an item that can place a gray-colored candle - * within Minecraft. + * Removes a callback from being called when a piston expands + * or retracts. * - */ - static readonly grayCandle: ItemType; - static readonly grayCarpet: ItemType; - static readonly grayDye: ItemType; - /** - * @remarks - * Represents an item that can place a gray-colored block of - * glazed terracotta within Minecraft. + * This function can't be called in read-only mode. * */ - static readonly grayGlazedTerracotta: ItemType; - static readonly grayWool: ItemType; + unsubscribe(callback: (arg: PistonActivateAfterEvent) => void): void; +} + +/** + * Represents a player within the world. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class Player extends Entity { + private constructor(); /** * @remarks - * Represents an item that can place a green-colored candle - * within Minecraft. + * The player's Camera. * + * @throws This property can throw when used. */ - static readonly greenCandle: ItemType; - static readonly greenCarpet: ItemType; - static readonly greenDye: ItemType; + readonly camera: Camera; /** + * @beta * @remarks - * Represents an item that can place a green block of glazed - * terracotta within Minecraft. + * Input permissions of the player. * */ - static readonly greenGlazedTerracotta: ItemType; - static readonly greenWool: ItemType; + readonly inputPermissions: PlayerInputPermissions; /** * @remarks - * Represents an item that can place a grindstone within - * Minecraft. + * If true, the player is currently emoting. * + * @throws This property can throw when used. */ - static readonly grindstone: ItemType; - static readonly guardianSpawnEgg: ItemType; - static readonly gunpowder: ItemType; + readonly isEmoting: boolean; /** * @remarks - * Represents an item that can place a set of hanging roots - * within Minecraft. + * Whether the player is flying. For example, in Creative or + * Spectator mode. * + * @throws This property can throw when used. */ - static readonly hangingRoots: ItemType; + readonly isFlying: boolean; /** * @remarks - * Represents an item that can place a block of hardened clay - * within Minecraft. + * Whether the player is gliding with Elytra. * + * @throws This property can throw when used. */ - static readonly hardenedClay: ItemType; + readonly isGliding: boolean; /** * @remarks - * Represents an item that can place a block of hay within - * Minecraft. + * Whether the player is jumping. This will remain true while + * the player is holding the jump action. * + * @throws This property can throw when used. */ - static readonly hayBlock: ItemType; - static readonly heartOfTheSea: ItemType; + readonly isJumping: boolean; /** * @remarks - * Represents an item that can place a heavy weighted pressure - * plate within Minecraft. + * The current overall level for the player, based on their + * experience. * + * @throws This property can throw when used. */ - static readonly heavyWeightedPressurePlate: ItemType; - static readonly hoglinSpawnEgg: ItemType; + readonly level: number; /** * @remarks - * Represents an item that can place a block of honey within - * Minecraft. + * Name of the player. * + * @throws This property can throw when used. */ - static readonly honeyBlock: ItemType; - static readonly honeyBottle: ItemType; - static readonly honeycomb: ItemType; + readonly name: string; /** * @remarks - * Represents an item that can place a honeycomb block within - * Minecraft. + * Contains methods for manipulating the on-screen display of a + * Player. * + * @throws This property can throw when used. */ - static readonly honeycombBlock: ItemType; + readonly onScreenDisplay: ScreenDisplay; /** + * @beta * @remarks - * Represents an item that can place a hopper within Minecraft. + * This property can't be edited in read-only mode. * */ - static readonly hopper: ItemType; - static readonly hopperMinecart: ItemType; - static readonly hornCoral: ItemType; - static readonly horseSpawnEgg: ItemType; - static readonly huskSpawnEgg: ItemType; + selectedSlotIndex: number; /** * @remarks - * Represents an item that can place a block of ice within - * Minecraft. + * The overall total set of experience needed to achieve the + * next level for a player. * + * @throws This property can throw when used. */ - static readonly ice: ItemType; + readonly totalXpNeededForNextLevel: number; /** * @remarks - * Represents an item that can place an infested block of - * deepslate within Minecraft. + * The current set of experience achieved for the player. * + * @throws This property can throw when used. */ - static readonly infestedDeepslate: ItemType; - static readonly inkSac: ItemType; - static readonly ironAxe: ItemType; + readonly xpEarnedAtCurrentLevel: number; /** * @remarks - * Represents iron bars within Minecraft. + * Adds/removes experience to/from the Player and returns the + * current experience of the Player. * - */ - static readonly ironBars: ItemType; - /** - * @remarks - * Represents an item that can place a block of iron within - * Minecraft. + * 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. */ - static readonly ironBlock: ItemType; - static readonly ironBoots: ItemType; - static readonly ironChestplate: ItemType; + addExperience(amount: number): number; /** * @remarks - * Represents an item that can place an iron door within - * Minecraft. + * Adds/removes level to/from the Player and returns the + * current level of the Player. * - */ - static readonly ironDoor: ItemType; - static readonly ironGolemSpawnEgg: ItemType; - static readonly ironHelmet: ItemType; - static readonly ironHoe: ItemType; - static readonly ironHorseArmor: ItemType; - static readonly ironIngot: ItemType; - static readonly ironLeggings: ItemType; - static readonly ironNugget: ItemType; - /** - * @remarks - * Represents an item that can place a block with embedded iron - * ore within Minecraft. + * 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. */ - static readonly ironOre: ItemType; - static readonly ironPickaxe: ItemType; - static readonly ironShovel: ItemType; - static readonly ironSword: ItemType; + addLevels(amount: number): number; /** + * @beta * @remarks - * Represents an item that can place an iron trapdoor within - * Minecraft. + * Eats an item, providing the item's hunger and saturation + * effects to the player. Can only be used on food items. * - */ - static readonly ironTrapdoor: ItemType; - /** - * @remarks - * Represents an item that can place a jigsaw within Minecraft. + * This function can't be called in read-only mode. * + * @param itemStack + * The item to eat. + * @throws + * Throws if the item is not a food item. */ - static readonly jigsaw: ItemType; + eatItem(itemStack: ItemStack): void; /** - * @remarks - * Represents an item that can place a jukebox within - * Minecraft. - * + * @beta + * @throws This function can throw errors. */ - static readonly jukebox: ItemType; - static readonly jungleBoat: ItemType; + getGameMode(): GameMode; /** + * @beta * @remarks - * Represents jungle wood button within Minecraft. + * Gets the current item cooldown time for a particular + * cooldown category. * + * @param cooldownCategory + * Specifies the cooldown category to retrieve the current + * cooldown for. + * @throws This function can throw errors. */ - static readonly jungleButton: ItemType; - static readonly jungleChestBoat: ItemType; + getItemCooldown(cooldownCategory: string): number; /** * @remarks - * Represents an item that can place a jungle wood door within - * Minecraft. + * Gets the current spawn point of the player. * + * @throws This function can throw errors. */ - static readonly jungleDoor: ItemType; - static readonly jungleFence: ItemType; + getSpawnPoint(): DimensionLocation | undefined; /** * @remarks - * Represents an item that can place a jungle wood fence gate - * within Minecraft. + * Gets the total experience of the Player. * + * @throws This function can throw errors. */ - static readonly jungleFenceGate: ItemType; - static readonly jungleLog: ItemType; + getTotalXp(): number; /** + * @beta * @remarks - * Represents an item that can place a jungle wood pressure - * plate within Minecraft. + * Returns true if this player has operator-level permissions. * + * @throws This function can throw errors. */ - static readonly junglePressurePlate: ItemType; + isOp(): boolean; /** * @remarks - * Represents an item that can place a jungle sign within - * Minecraft. + * Plays a music track that only this particular player can + * hear. * - */ - static readonly jungleSign: ItemType; - /** - * @remarks - * Represents an item that can place a set of jungle wood - * stairs within Minecraft. + * This function can't be called in read-only mode. * + * @param trackId + * Identifier of the music track to play. + * @param musicOptions + * Additional options for the music track. + * @throws This function can throw errors. */ - static readonly jungleStairs: ItemType; + playMusic(trackId: string, musicOptions?: MusicOptions): void; /** * @remarks - * Represents an item that can place a jungle wood trapdoor - * within Minecraft. + * Plays a sound that only this particular player can hear. * - */ - static readonly jungleTrapdoor: ItemType; - /** - * @remarks - * Represents an item that can place a set of kelp within - * Minecraft. + * This function can't be called in read-only mode. * + * @param soundOptions + * Additional optional options for the sound. + * @throws This function can throw errors. */ - static readonly kelp: ItemType; + playSound(soundId: string, soundOptions?: PlayerSoundOptions): void; /** + * @beta * @remarks - * Represents an item that can place a ladder within Minecraft. + * This is an internal-facing method for posting a system + * message to downstream clients. * - */ - static readonly ladder: ItemType; - /** - * @remarks - * Represents an item that can place a lantern within - * Minecraft. + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly lantern: ItemType; + postClientMessage(id: string, value: string): void; /** * @remarks - * Represents an item that can place a block of lapis lazuli - * within Minecraft. + * Queues an additional music track that only this particular + * player can hear. If a track is not playing, a music track + * will play. * - */ - static readonly lapisBlock: ItemType; - static readonly lapisLazuli: ItemType; - /** - * @remarks - * Represents an item that can place a block with embedded - * lapis lazuli within Minecraft. + * This function can't be called in read-only mode. * - */ - static readonly lapisOre: ItemType; - /** - * @remarks - * Represents an item that can place a bud of large amethyst - * within Minecraft. + * @param trackId + * Identifier of the music track to play. + * @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. * */ - static readonly largeAmethystBud: ItemType; - static readonly lavaBucket: ItemType; - static readonly lead: ItemType; - static readonly leather: ItemType; - static readonly leatherBoots: ItemType; - static readonly leatherChestplate: ItemType; - static readonly leatherHelmet: ItemType; - static readonly leatherHorseArmor: ItemType; - static readonly leatherLeggings: ItemType; + queueMusic(trackId: string, musicOptions?: MusicOptions): void; /** * @remarks - * Represents an item that can place a set of leaves within - * Minecraft. + * Resets the level of the player. * - */ - static readonly leaves: ItemType; - /** - * @remarks - * Represents an item that can place an updated set of leaves - * within Minecraft. + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly leaves2: ItemType; + resetLevel(): void; /** * @remarks - * Represents an item that can place a lectern within - * Minecraft. + * 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 sendMessagesToPlayer.ts + * ```typescript + * import { Player } from "@minecraft/server"; + * + * function sendPlayerMessages(player: Player) { + * // Displays "First or Second" + * const rawMessage = { translate: 'accessibility.list.or.two', with: ['First', 'Second'] }; + * player.sendMessage(rawMessage); + * + * // Displays "Hello, world!" + * player.sendMessage('Hello, world!'); + * + * // Displays "Welcome, Amazing Player 1!" + * player.sendMessage({ translate: 'authentication.welcome', with: ['Amazing Player 1'] }); + * + * // Displays the player's score for objective "obj". Each player will see their own score. + * const rawMessageWithScore = { score: { name: '*', objective: 'obj' } }; + * player.sendMessage(rawMessageWithScore); + * + * // Displays "Apple or Coal" + * const rawMessageWithNestedTranslations = { + * translate: 'accessibility.list.or.two', + * with: { rawtext: [{ translate: 'item.apple.name' }, { translate: 'item.coal.name' }] }, + * }; + * player.sendMessage(rawMessageWithNestedTranslations); + * } + * ``` */ - static readonly lectern: ItemType; + sendMessage(message: (RawMessage | string)[] | RawMessage | string): void; /** + * @beta * @remarks - * Represents an item that can place a lever within Minecraft. + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly lever: ItemType; + setGameMode(gameMode?: GameMode): void; /** + * @beta * @remarks - * Represents an item that can place a block of light within - * Minecraft. + * Will change the specified players permissions, and whether + * they are operator or not. * - */ - static readonly lightBlock: ItemType; - /** - * @remarks - * Represents an item that can place a light blue candle within - * Minecraft. + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly lightBlueCandle: ItemType; - static readonly lightBlueCarpet: ItemType; - static readonly lightBlueDye: ItemType; + setOp(isOp: boolean): void; /** * @remarks - * Represents an item that can place a light blue block of - * glazed terracotta within Minecraft. + * Sets the current starting spawn point for this particular + * player. * - */ - static readonly lightBlueGlazedTerracotta: ItemType; - static readonly lightBlueWool: ItemType; - /** - * @remarks - * Represents an item that can place a light gray candle within - * Minecraft. + * This function can't be called in read-only mode. * + * @throws This function can throw errors. + * + * {@link Error} + * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly lightGrayCandle: ItemType; - static readonly lightGrayCarpet: ItemType; - static readonly lightGrayDye: ItemType; - static readonly lightGrayWool: ItemType; + setSpawnPoint(spawnPoint?: DimensionLocation): void; /** + * @beta * @remarks - * Represents an item that can place a lightning rod within - * Minecraft. + * Creates a new particle emitter at a specified location in + * the world. Only visible to the target player. + * + * 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 Error} * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} + * @example spawnParticle.ts + * ```typescript + * import { world, MolangVariableMap, Vector3 } from '@minecraft/server'; + * + * world.afterEvents.playerSpawn.subscribe(event => { + * const targetLocation = event.player.location; + * for (let i = 0; i < 100; i++) { + * const molang = new MolangVariableMap(); + * + * molang.setColorRGB('variable.color', { + * red: Math.random(), + * green: Math.random(), + * blue: Math.random() + * }); + * + * const newLocation: Vector3 = { + * 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, + * }; + * event.player.spawnParticle('minecraft:colored_flame_particle', newLocation, molang); + * } + * }); + * ``` */ - static readonly lightningRod: ItemType; + spawnParticle(effectName: string, location: Vector3, molangVariables?: MolangVariableMap): void; /** + * @beta * @remarks - * Represents an item that can place a light weighted pressure - * plate within Minecraft. + * Sets the item cooldown time for a particular cooldown + * category. + * + * This function can't be called in read-only mode. * + * @param cooldownCategory + * 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. */ - static readonly lightWeightedPressurePlate: ItemType; + startItemCooldown(cooldownCategory: string, tickDuration: number): void; /** * @remarks - * Represents an item that can place a lime candle within - * Minecraft. + * Stops any music tracks from playing for this particular + * player. + * + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly limeCandle: ItemType; - static readonly limeCarpet: ItemType; - static readonly limeDye: ItemType; + stopMusic(): void; +} + +/** + * 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 - * Represents an item that can place a lime-colored block of - * glazed terracotta within Minecraft. + * Returns permutation information about this block before it + * was broken. * */ - static readonly limeGlazedTerracotta: ItemType; - static readonly limeWool: ItemType; - static readonly lingeringPotion: ItemType; + readonly brokenBlockPermutation: BlockPermutation; /** * @remarks - * Represents an item that can place a lit pumpkin within - * Minecraft. + * The item stack that was used to break the block after the + * block was broken, or undefined if empty hand. * */ - static readonly litPumpkin: ItemType; - static readonly llamaSpawnEgg: ItemType; + readonly itemStackAfterBreak?: ItemStack; /** * @remarks - * Represents an item that can place a lodestone within - * Minecraft. + * The item stack that was used to break the block before the + * block was broken, or undefined if empty hand. * */ - static readonly lodestone: ItemType; - static readonly lodestoneCompass: ItemType; + readonly itemStackBeforeBreak?: ItemStack; /** * @remarks - * Represents an item that can place a log within Minecraft. + * Player that broke the block for this event. * */ - static readonly log: ItemType; + readonly player: Player; +} + +/** + * Manages callbacks that are connected to when a player breaks + * a block. + */ +export class PlayerBreakBlockAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a more updated, - * customizable log within Minecraft. + * 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. * */ - static readonly log2: ItemType; + subscribe( + callback: (arg: PlayerBreakBlockAfterEvent) => void, + options?: BlockEventOptions, + ): (arg: PlayerBreakBlockAfterEvent) => void; /** * @remarks - * Represents an item that can place a loom within Minecraft. + * Removes a callback from being called when a player breaks a + * block. + * + * This function can't be called in read-only mode. * */ - static readonly loom: ItemType; + unsubscribe(callback: (arg: PlayerBreakBlockAfterEvent) => void): void; +} + +/** + * 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 - * Represents an item that can place a magenta candle within - * Minecraft. + * If set to true, cancels the block break event. * */ - static readonly magentaCandle: ItemType; - static readonly magentaCarpet: ItemType; - static readonly magentaDye: ItemType; + cancel: boolean; /** * @remarks - * Represents an item that can place a block of magenta-colored - * glazed terracotta within Minecraft. + * The item stack that is being used to break the block, or + * undefined if empty hand. * */ - static readonly magentaGlazedTerracotta: ItemType; - static readonly magentaWool: ItemType; + itemStack?: ItemStack; /** * @remarks - * Represents magma within Minecraft. + * Player breaking the block for this event. * */ - static readonly magma: ItemType; - static readonly magmaCream: ItemType; - static readonly magmaCubeSpawnEgg: ItemType; - static readonly mangroveBoat: ItemType; - static readonly mangroveButton: ItemType; - static readonly mangroveChestBoat: ItemType; - static readonly mangroveDoor: ItemType; - static readonly mangroveFence: ItemType; - static readonly mangroveFenceGate: ItemType; - static readonly mangroveLeaves: ItemType; - static readonly mangroveLog: ItemType; - static readonly mangrovePlanks: ItemType; - static readonly mangrovePressurePlate: ItemType; - static readonly mangrovePropagule: ItemType; - static readonly mangroveRoots: ItemType; - static readonly mangroveSign: ItemType; - static readonly mangroveSlab: ItemType; - static readonly mangroveStairs: ItemType; - static readonly mangroveTrapdoor: ItemType; - static readonly mangroveWood: ItemType; + readonly player: Player; +} + +/** + * Manages callbacks that are connected to before a player + * breaks a block. + */ +export class PlayerBreakBlockBeforeEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a medium-sized bud of - * amethyst within Minecraft. + * 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. * */ - static readonly mediumAmethystBud: ItemType; + subscribe( + callback: (arg: PlayerBreakBlockBeforeEvent) => void, + options?: BlockEventOptions, + ): (arg: PlayerBreakBlockBeforeEvent) => void; /** * @remarks - * Represents an item that can place a block of melon within - * Minecraft. + * Removes a callback from being called before a player breaks + * a block. + * + * This function can't be called in read-only mode. * */ - static readonly melonBlock: ItemType; - static readonly melonSeeds: ItemType; - static readonly melonSlice: ItemType; - static readonly milkBucket: ItemType; - static readonly minecart: ItemType; + unsubscribe(callback: (arg: PlayerBreakBlockBeforeEvent) => void): void; +} + +/** + * Contains information related to changes to a player's + * dimension having been changed. + */ +export class PlayerDimensionChangeAfterEvent { + private constructor(); /** * @remarks - * Represents an item that can place a mob spawner within - * Minecraft. + * The dimension the player is changing from. * */ - static readonly mobSpawner: ItemType; - static readonly mojangBannerPattern: ItemType; + readonly fromDimension: Dimension; /** * @remarks - * Represents an item that can place a monster egg within - * Minecraft. + * The location the player was at before changing dimensions. * */ - static readonly monsterEgg: ItemType; - static readonly mooshroomSpawnEgg: ItemType; + readonly fromLocation: Vector3; /** * @remarks - * Represents an item that can place a block of moss within - * Minecraft. + * Handle to the player that is changing dimensions. * */ - static readonly mossBlock: ItemType; + readonly player: Player; /** * @remarks - * Represents an item that can place a carpet of moss within - * Minecraft. + * The dimension that the player is changing to. * */ - static readonly mossCarpet: ItemType; + readonly toDimension: Dimension; /** * @remarks - * Represents an item that can place a block of cobblestone - * with moss within Minecraft. + * The location the player will spawn to after changing + * dimensions. * */ - static readonly mossyCobblestone: ItemType; + readonly toLocation: Vector3; +} + +/** + * Manages callbacks that are connected to successful player + * dimension changes. + */ +export class PlayerDimensionChangeAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a set of mossy cobblestone - * stairs within Minecraft. + * Subscribes the specified callback to a player dimension + * change after event. + * + * This function can't be called in read-only mode. * */ - static readonly mossyCobblestoneStairs: ItemType; + subscribe(callback: (arg: PlayerDimensionChangeAfterEvent) => void): (arg: PlayerDimensionChangeAfterEvent) => void; /** * @remarks - * Represents an item that can place a set of mossy stone brick - * stairs within Minecraft. + * Removes the specified callback from a player dimension + * change after event. + * + * This function can't be called in read-only mode. * */ - static readonly mossyStoneBrickStairs: ItemType; - static readonly mud: ItemType; - static readonly mudBricks: ItemType; - static readonly mudBrickSlab: ItemType; - static readonly mudBrickStairs: ItemType; - static readonly mudBrickWall: ItemType; - static readonly muddyMangroveRoots: ItemType; - static readonly muleSpawnEgg: ItemType; - static readonly mushroomStew: ItemType; - static readonly musicDisc11: ItemType; - static readonly musicDisc13: ItemType; - static readonly musicDisc5: ItemType; - static readonly musicDiscBlocks: ItemType; - static readonly musicDiscCat: ItemType; - static readonly musicDiscChirp: ItemType; - static readonly musicDiscFar: ItemType; - static readonly musicDiscMall: ItemType; - static readonly musicDiscMellohi: ItemType; - static readonly musicDiscOtherside: ItemType; - static readonly musicDiscPigstep: ItemType; - static readonly musicDiscStal: ItemType; - static readonly musicDiscStrad: ItemType; - static readonly musicDiscWait: ItemType; - static readonly musicDiscWard: ItemType; - static readonly mutton: ItemType; + unsubscribe(callback: (arg: PlayerDimensionChangeAfterEvent) => void): void; +} + +/** + * @beta + */ +export class PlayerGameModeChangeAfterEvent { + private constructor(); + readonly fromGameMode: GameMode; + readonly player: Player; + readonly toGameMode: GameMode; +} + +/** + * @beta + */ +export class PlayerGameModeChangeAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a mycelium plant within - * Minecraft. + * This function can't be called in read-only mode. * */ - static readonly mycelium: ItemType; - static readonly nameTag: ItemType; - static readonly nautilusShell: ItemType; + subscribe(callback: (arg: PlayerGameModeChangeAfterEvent) => void): (arg: PlayerGameModeChangeAfterEvent) => void; /** * @remarks - * Represents an item that can place a nether brick block - * within Minecraft. + * This function can't be called in read-only mode. * */ - static readonly netherbrick: ItemType; + unsubscribe(callback: (arg: PlayerGameModeChangeAfterEvent) => void): void; +} + +/** + * @beta + */ +export class PlayerGameModeChangeBeforeEvent { + private constructor(); + cancel: boolean; + readonly fromGameMode: GameMode; + readonly player: Player; + toGameMode: GameMode; +} + +/** + * @beta + */ +export class PlayerGameModeChangeBeforeEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a nether brick block - * within Minecraft. + * This function can't be called in read-only mode. * */ - static readonly netherBrick: ItemType; + subscribe(callback: (arg: PlayerGameModeChangeBeforeEvent) => void): (arg: PlayerGameModeChangeBeforeEvent) => void; /** * @remarks - * Represents an item that can place a nether brick fence - * within Minecraft. + * This function can't be called in read-only mode. * */ - static readonly netherBrickFence: ItemType; + unsubscribe(callback: (arg: PlayerGameModeChangeBeforeEvent) => void): void; +} + +/** + * @beta + * Contains information regarding an event after a players + * input permissions change. + */ +export class PlayerInputPermissionCategoryChangeAfterEvent { + private constructor(); /** * @remarks - * Represents an item that can place a set of nether brick - * stairs within Minecraft. + * The category of input permissions that have changed. * */ - static readonly netherBrickStairs: ItemType; + readonly category: InputPermissionCategory; /** * @remarks - * Represents an item that can place a block of nether with - * embedded gold ore within Minecraft. + * The enabled/disabled state of the players input permissions. * */ - static readonly netherGoldOre: ItemType; - static readonly netheriteAxe: ItemType; + readonly enabled: boolean; /** * @remarks - * Represents an item that can place a block of netherite - * within Minecraft. + * The player that has had their input permissions changed. * */ - static readonly netheriteBlock: ItemType; - static readonly netheriteBoots: ItemType; - static readonly netheriteChestplate: ItemType; - static readonly netheriteHelmet: ItemType; - static readonly netheriteHoe: ItemType; - static readonly netheriteIngot: ItemType; - static readonly netheriteLeggings: ItemType; - static readonly netheritePickaxe: ItemType; - static readonly netheriteScrap: ItemType; - static readonly netheriteShovel: ItemType; - static readonly netheriteSword: ItemType; + readonly player: Player; +} + +/** + * @beta + * Manages callbacks that are connected to after a players + * input permissions change. + */ +export class PlayerInputPermissionCategoryChangeAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a block of netherrack - * within Minecraft. + * Adds a callback that will be called after a players input + * permissions change. + * + * This function can't be called in read-only mode. * */ - static readonly netherrack: ItemType; + subscribe( + callback: (arg: PlayerInputPermissionCategoryChangeAfterEvent) => void, + ): (arg: PlayerInputPermissionCategoryChangeAfterEvent) => void; /** * @remarks - * Represents nether sprouts within Minecraft. + * Removes a callback from being called after a players input + * permissions change. + * + * This function can't be called in read-only mode. * */ - static readonly netherSprouts: ItemType; - static readonly netherStar: ItemType; + unsubscribe(callback: (arg: PlayerInputPermissionCategoryChangeAfterEvent) => void): void; +} + +/** + * @beta + */ +export class PlayerInputPermissions { + private constructor(); + cameraEnabled: boolean; + movementEnabled: boolean; +} + +/** + * Contains information regarding an event after a player + * interacts with a block. + */ +export class PlayerInteractWithBlockAfterEvent { + private constructor(); /** * @remarks - * Represents nether wart within Minecraft. + * The block that will be interacted with. * */ - static readonly netherWart: ItemType; + readonly block: Block; /** * @remarks - * Represents an item that can place a block of nether wart - * within Minecraft. + * The face of the block that is being interacted with. * */ - static readonly netherWartBlock: ItemType; + readonly blockFace: Direction; /** * @remarks - * Represents an item that can place a standard set of stone - * stairs within Minecraft. + * Location relative to the bottom north-west corner of the + * block where the item is placed. * */ - static readonly normalStoneStairs: ItemType; + readonly faceLocation: Vector3; /** * @remarks - * Represents an item that can place a note block within - * Minecraft. + * The item stack that is being used in the interaction, or + * undefined if empty hand. * */ - static readonly noteblock: ItemType; - static readonly oakBoat: ItemType; - static readonly oakChestBoat: ItemType; - static readonly oakFence: ItemType; - static readonly oakLog: ItemType; - static readonly oakSign: ItemType; + readonly itemStack?: ItemStack; /** * @remarks - * Represents an item that can place a set of oak stairs within - * Minecraft. + * Source Player for this event. * */ - static readonly oakStairs: ItemType; + readonly player: Player; +} + +/** + * Manages callbacks that are connected to after a player + * interacts with a block. + */ +export class PlayerInteractWithBlockAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place an observer within - * Minecraft. + * Adds a callback that will be called after a player interacts + * with a block. + * + * This function can't be called in read-only mode. * */ - static readonly observer: ItemType; + subscribe( + callback: (arg: PlayerInteractWithBlockAfterEvent) => void, + ): (arg: PlayerInteractWithBlockAfterEvent) => void; /** * @remarks - * Represents an item that can place an obsidian block within - * Minecraft. + * Removes a callback from being called after a player + * interacts with a block. + * + * This function can't be called in read-only mode. * */ - static readonly obsidian: ItemType; - static readonly ocelotSpawnEgg: ItemType; - static readonly ochreFroglight: ItemType; + unsubscribe(callback: (arg: PlayerInteractWithBlockAfterEvent) => void): void; +} + +/** + * Contains information regarding an event before a player + * interacts with a block. + */ +export class PlayerInteractWithBlockBeforeEvent { + private constructor(); /** * @remarks - * Represents an item that can place an orange candle within - * Minecraft. + * The block that will be interacted with. * */ - static readonly orangeCandle: ItemType; - static readonly orangeCarpet: ItemType; - static readonly orangeDye: ItemType; + readonly block: Block; /** * @remarks - * Represents an item that can place a block of orange-colored - * glazed terracotta within Minecraft. + * The face of the block that is being interacted with. * */ - static readonly orangeGlazedTerracotta: ItemType; - static readonly orangeWool: ItemType; + readonly blockFace: Direction; /** * @remarks - * Represents an item that can place a block of oxidized copper - * within Minecraft. + * If set to true the interaction will be cancelled. * */ - static readonly oxidizedCopper: ItemType; + cancel: boolean; /** * @remarks - * Represents an item that can place a block of oxidized cut - * copper within Minecraft. + * Location relative to the bottom north-west corner of the + * block where the item is placed. * */ - static readonly oxidizedCutCopper: ItemType; + readonly faceLocation: Vector3; /** * @remarks - * Represents an item that can place a slab of oxidized cut - * copper within Minecraft. + * The item stack that is being used in the interaction, or + * undefined if empty hand. * */ - static readonly oxidizedCutCopperSlab: ItemType; + readonly itemStack?: ItemStack; /** * @remarks - * Represents an item that can place a set of oxidized cut - * copper stairs within Minecraft. + * Source Player for this event. * */ - static readonly oxidizedCutCopperStairs: ItemType; + readonly player: Player; +} + +/** + * Manages callbacks that are connected to before a player + * interacts with a block. + */ +export class PlayerInteractWithBlockBeforeEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a block of packed ice - * within Minecraft. + * Adds a callback that will be called before a player + * interacts with a block. + * + * This function can't be called in read-only mode. * */ - static readonly packedIce: ItemType; - static readonly packedMud: ItemType; - static readonly painting: ItemType; - static readonly pandaSpawnEgg: ItemType; - static readonly paper: ItemType; - static readonly parrotSpawnEgg: ItemType; - static readonly pearlescentFroglight: ItemType; - static readonly phantomMembrane: ItemType; - static readonly phantomSpawnEgg: ItemType; - static readonly piglinBannerPattern: ItemType; - static readonly piglinBruteSpawnEgg: ItemType; - static readonly piglinSpawnEgg: ItemType; - static readonly pigSpawnEgg: ItemType; - static readonly pillagerSpawnEgg: ItemType; + subscribe( + callback: (arg: PlayerInteractWithBlockBeforeEvent) => void, + ): (arg: PlayerInteractWithBlockBeforeEvent) => void; /** * @remarks - * Represents an item that can place a pink candle within - * Minecraft. + * Removes a callback from being called before a player + * interacts with a block. + * + * This function can't be called in read-only mode. * */ - static readonly pinkCandle: ItemType; - static readonly pinkCarpet: ItemType; - static readonly pinkDye: ItemType; + unsubscribe(callback: (arg: PlayerInteractWithBlockBeforeEvent) => void): void; +} + +/** + * Contains information regarding an event after a player + * interacts with an entity. + */ +export class PlayerInteractWithEntityAfterEvent { + private constructor(); /** * @remarks - * Represents an item that can place a pink-colored block of - * glazed terracotta within Minecraft. + * The item stack that is being used in the interaction, or + * undefined if empty hand. * */ - static readonly pinkGlazedTerracotta: ItemType; - static readonly pinkWool: ItemType; + readonly itemStack?: ItemStack; /** * @remarks - * Represents an item that can place a piston within Minecraft. + * Source Player for this event. * */ - static readonly piston: ItemType; - static readonly pitcherPlant: ItemType; - static readonly pitcherPod: ItemType; + readonly player: Player; /** * @remarks - * Represents an item that can place a set of planks within - * Minecraft. + * The entity that will be interacted with. * */ - static readonly planks: ItemType; + readonly target: Entity; +} + +/** + * Manages callbacks that are connected to after a player + * interacts with an entity. + */ +export class PlayerInteractWithEntityAfterEventSignal { + private constructor(); /** * @remarks - * Represents podzol within Minecraft. + * Adds a callback that will be called after a player interacts + * with an entity. + * + * This function can't be called in read-only mode. * */ - static readonly podzol: ItemType; + subscribe( + callback: (arg: PlayerInteractWithEntityAfterEvent) => void, + ): (arg: PlayerInteractWithEntityAfterEvent) => void; /** * @remarks - * Represents pointed dripstone within Minecraft. + * Removes a callback from being called after a player + * interacts with an entity. + * + * This function can't be called in read-only mode. * */ - static readonly pointedDripstone: ItemType; - static readonly poisonousPotato: ItemType; - static readonly polarBearSpawnEgg: ItemType; + unsubscribe(callback: (arg: PlayerInteractWithEntityAfterEvent) => void): void; +} + +/** + * Contains information regarding an event before a player + * interacts with an entity. + */ +export class PlayerInteractWithEntityBeforeEvent { + private constructor(); /** * @remarks - * Represents an item that can place a set of polished andesite - * stairs within Minecraft. + * If set to true the interaction will be cancelled. * */ - static readonly polishedAndesiteStairs: ItemType; + cancel: boolean; /** * @remarks - * Represents an item that can place a block of polished basalt - * within Minecraft. + * The item stack that is being used in the interaction, or + * undefined if empty hand. * */ - static readonly polishedBasalt: ItemType; + readonly itemStack?: ItemStack; /** * @remarks - * Represents an item that can place a block of polished - * blackstone within Minecraft. + * Source Player for this event. * */ - static readonly polishedBlackstone: ItemType; + readonly player: Player; /** * @remarks - * Represents an item that can place a block of polished - * blackstone bricks within Minecraft. + * The entity that will be interacted with. * */ - static readonly polishedBlackstoneBricks: ItemType; + readonly target: Entity; +} + +/** + * Manages callbacks that are connected to before a player + * interacts with an entity. + */ +export class PlayerInteractWithEntityBeforeEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a slab of polished - * blackstone within Minecraft. + * Adds a callback that will be called before a player + * interacts with an entity. + * + * This function can't be called in read-only mode. * */ - static readonly polishedBlackstoneBrickSlab: ItemType; + subscribe( + callback: (arg: PlayerInteractWithEntityBeforeEvent) => void, + ): (arg: PlayerInteractWithEntityBeforeEvent) => void; /** * @remarks - * Represents an item that can place a set of polished - * blackstone brick stairs within Minecraft. + * Removes a callback from being called before a player + * interacts with an entity. + * + * This function can't be called in read-only mode. * */ - static readonly polishedBlackstoneBrickStairs: ItemType; + unsubscribe(callback: (arg: PlayerInteractWithEntityBeforeEvent) => 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 - * Represents an item that can place a polished blackstone - * brick wall within Minecraft. + * This function can't be called in read-only mode. * */ - static readonly polishedBlackstoneBrickWall: ItemType; + [Symbol.iterator](): Iterator; /** * @remarks - * Represents an item that can place a polished blackstone - * button within Minecraft. + * 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. * */ - static readonly polishedBlackstoneButton: ItemType; + next(): IteratorResult; +} + +/** + * 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 - * Represents an item that can place a polished blackstone - * pressure plate within Minecraft. + * Opaque string identifier of the player that joined the game. * */ - static readonly polishedBlackstonePressurePlate: ItemType; + readonly playerId: string; /** * @remarks - * Represents an item that can place a slab of polished - * blackstone within Minecraft. + * Name of the player that has joined. * */ - static readonly polishedBlackstoneSlab: ItemType; + 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 - * Represents an item that can place a set of polished - * blackstone stairs within Minecraft. + * Opaque string identifier of the player that has left the + * event. * */ - static readonly polishedBlackstoneStairs: ItemType; + readonly playerId: string; /** * @remarks - * Represents an item that can place a polished blackstone wall - * within Minecraft. + * Player that has left the world. * */ - static readonly polishedBlackstoneWall: ItemType; + 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(); +} + +/** + * Contains information regarding a player that is leaving the + * world. + */ +export class PlayerLeaveBeforeEvent { + private constructor(); /** * @remarks - * Represents an item that can place a block of polished - * deepslate within Minecraft. + * The leaving player. * */ - static readonly polishedDeepslate: ItemType; + readonly player: Player; +} + +/** + * Manages callbacks that are connected to a player leaving the + * world. + */ +export class PlayerLeaveBeforeEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a slab of polished - * deepslate within Minecraft. + * Adds a callback that will be called when a player leaves the + * world. + * + * This function can't be called in read-only mode. * */ - static readonly polishedDeepslateSlab: ItemType; + subscribe(callback: (arg: PlayerLeaveBeforeEvent) => void): (arg: PlayerLeaveBeforeEvent) => void; /** * @remarks - * Represents an item that can place a set of polished - * deepslate stairs within Minecraft. + * Removes a callback that will be called when a player leaves + * the world. + * + * This function can't be called in read-only mode. * */ - static readonly polishedDeepslateStairs: ItemType; + unsubscribe(callback: (arg: PlayerLeaveBeforeEvent) => void): void; +} + +/** + * 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 - * Represents an item that can place a wall of polished - * deepslate within Minecraft. + * Player that placed the block for this event. * */ - static readonly polishedDeepslateWall: ItemType; + readonly player: Player; +} + +/** + * Manages callbacks that are connected to when a block is + * placed by a player. + */ +export class PlayerPlaceBlockAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a block of polished - * diorite within Minecraft. + * 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. * */ - static readonly polishedDioriteStairs: ItemType; + subscribe( + callback: (arg: PlayerPlaceBlockAfterEvent) => void, + options?: BlockEventOptions, + ): (arg: PlayerPlaceBlockAfterEvent) => void; /** * @remarks - * Represents an item that can place a set of polished granite - * stairs within Minecraft. + * Removes a callback from being called when an block is placed + * by a player. + * + * This function can't be called in read-only mode. * */ - static readonly polishedGraniteStairs: ItemType; - static readonly poppedChorusFruit: ItemType; - static readonly porkchop: ItemType; - static readonly potato: ItemType; - static readonly potion: ItemType; - static readonly powderSnowBucket: ItemType; + 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 - * Represents an item that can place a block of prismarine - * within Minecraft. + * If set to true, cancels the block place event. * */ - static readonly prismarine: ItemType; + cancel: boolean; /** * @remarks - * Represents an item that can place a set of prismarine brick - * stairs within Minecraft. + * The face of the block that the new block is being placed on. * */ - static readonly prismarineBricksStairs: ItemType; - static readonly prismarineCrystals: ItemType; - static readonly prismarineShard: ItemType; + readonly face: Direction; /** * @remarks - * Represents an item that can place a set of prismarine stairs - * within Minecraft. + * Location relative to the bottom north-west corner of the + * block where the new block is being placed onto. * */ - static readonly prismarineStairs: ItemType; - static readonly pufferfish: ItemType; - static readonly pufferfishBucket: ItemType; - static readonly pufferfishSpawnEgg: ItemType; + readonly faceLocation: Vector3; /** * @remarks - * Represents an item that can place a pumpkin within - * Minecraft. + * The block permutation that is being placed. * */ - static readonly pumpkin: ItemType; - static readonly pumpkinPie: ItemType; - static readonly pumpkinSeeds: ItemType; + readonly permutationBeingPlaced: BlockPermutation; /** * @remarks - * Represents an item that can place a purple candle within - * Minecraft. + * Player that is placing the block for this event. * */ - static readonly purpleCandle: ItemType; - static readonly purpleCarpet: ItemType; - static readonly purpleDye: ItemType; + readonly player: Player; +} + +/** + * @beta + * Manages callbacks that are connected to before a block is + * placed by a player. + */ +export class PlayerPlaceBlockBeforeEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a purple-colored block of - * glazed terracotta within Minecraft. + * 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. * */ - static readonly purpleGlazedTerracotta: ItemType; - static readonly purpleWool: ItemType; + subscribe( + callback: (arg: PlayerPlaceBlockBeforeEvent) => void, + options?: BlockEventOptions, + ): (arg: PlayerPlaceBlockBeforeEvent) => void; /** * @remarks - * Represents an item that can place a purpur block within - * Minecraft. + * Removes a callback from being called before an block is + * placed by a player. + * + * This function can't be called in read-only mode. * */ - static readonly purpurBlock: ItemType; + unsubscribe(callback: (arg: PlayerPlaceBlockBeforeEvent) => void): void; +} + +/** + * An event that contains more information about a player + * spawning. + */ +export class PlayerSpawnAfterEvent { + private constructor(); /** * @remarks - * Represents an item that can place a set of purpur stairs - * within Minecraft. + * If true, this is the initial spawn of a player after joining + * the game. + * + * This property can't be edited in read-only mode. * */ - static readonly purpurStairs: ItemType; - static readonly quartz: ItemType; + initialSpawn: boolean; /** * @remarks - * Represents an item that can place a block of solid quartz - * within Minecraft. + * Object that represents the player that joined the game. + * + * This property can't be edited in read-only mode. * */ - static readonly quartzBlock: ItemType; + 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 - * Represents an item that can place a block of solid quartz - * bricks within Minecraft. + * The redstone power of the pressure plate before it was + * popped. * */ - static readonly quartzBricks: ItemType; + readonly previousRedstonePower: number; /** * @remarks - * Represents an item that can place a block with embedded - * quartz ore within Minecraft. + * The redstone power of the pressure plate at the time of the + * pop. * */ - static readonly quartzOre: ItemType; + readonly redstonePower: number; +} + +/** + * Manages callbacks that are connected to when a pressure + * plate is popped. + */ +export class PressurePlatePopAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a set of quartz stairs - * within Minecraft. + * Adds a callback that will be called when a pressure plate is + * popped. + * + * This function can't be called in read-only mode. * */ - static readonly quartzStairs: ItemType; - static readonly rabbit: ItemType; - static readonly rabbitFoot: ItemType; - static readonly rabbitHide: ItemType; - static readonly rabbitSpawnEgg: ItemType; - static readonly rabbitStew: ItemType; + subscribe(callback: (arg: PressurePlatePopAfterEvent) => void): (arg: PressurePlatePopAfterEvent) => void; /** * @remarks - * Represents an item that can place a set of rails within - * Minecraft. + * Removes a callback from being called when a pressure plate + * is popped. + * + * This function can't be called in read-only mode. * */ - static readonly rail: ItemType; - static readonly ravagerSpawnEgg: ItemType; - static readonly rawCopper: ItemType; + 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 - * Represents an item that can place a block of raw copper - * within Minecraft. + * The redstone power of the pressure plate before it was + * pushed. * */ - static readonly rawCopperBlock: ItemType; - static readonly rawGold: ItemType; + readonly previousRedstonePower: number; /** * @remarks - * Represents an item that can place a block of raw gold within - * Minecraft. + * The redstone power of the pressure plate at the time of the + * push. * */ - static readonly rawGoldBlock: ItemType; - static readonly rawIron: ItemType; + readonly redstonePower: number; /** * @remarks - * Represents an item that can place a block of raw iron within - * Minecraft. + * Source that triggered the pressure plate push. * */ - static readonly rawIronBlock: ItemType; - static readonly recoveryCompass: ItemType; + readonly source: Entity; +} + +/** + * Manages callbacks that are connected to when a pressure + * plate is pushed. + */ +export class PressurePlatePushAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a red candle within - * Minecraft. + * Adds a callback that will be called when a pressure plate is + * pushed. + * + * This function can't be called in read-only mode. * */ - static readonly redCandle: ItemType; - static readonly redCarpet: ItemType; - static readonly redDye: ItemType; + subscribe(callback: (arg: PressurePlatePushAfterEvent) => void): (arg: PressurePlatePushAfterEvent) => void; /** * @remarks - * Represents an item that can place a red flower within - * Minecraft. + * Removes a callback from being called when a pressure plate + * is pushed. + * + * This function can't be called in read-only mode. * */ - static readonly redFlower: ItemType; + unsubscribe(callback: (arg: PressurePlatePushAfterEvent) => void): void; +} + +/** + * Contains information related to a projectile hitting a + * block. + */ +export class ProjectileHitBlockAfterEvent { + private constructor(); /** * @remarks - * Represents an item that can place a red-colored block of - * glazed terracotta within Minecraft. + * Dimension where this projectile hit took place. * */ - static readonly redGlazedTerracotta: ItemType; + readonly dimension: Dimension; /** * @remarks - * Represents an item that can place a red mushroom within - * Minecraft. + * Direction vector of the projectile as it hit a block. * */ - static readonly redMushroom: ItemType; + readonly hitVector: Vector3; /** * @remarks - * Represents an item that can place a block of red mushroom - * within Minecraft. + * Location where the projectile hit occurred. * */ - static readonly redMushroomBlock: ItemType; + readonly location: Vector3; /** * @remarks - * Represents an item that can place a block of red nether - * brick within Minecraft. + * Entity for the projectile that hit a block. * */ - static readonly redNetherBrick: ItemType; + readonly projectile: Entity; /** * @remarks - * Represents an item that can place a set of red nether brick - * stairs within Minecraft. + * Optional source entity that fired the projectile. * */ - static readonly redNetherBrickStairs: ItemType; + readonly source?: Entity; /** * @remarks - * Represents an item that can place a block of red sandstone - * within Minecraft. + * Contains additional information about the block that was hit + * by the projectile. + * + * This function can't be called in read-only mode. * */ - static readonly redSandstone: ItemType; + getBlockHit(): BlockHitInformation; +} + +/** + * Manages callbacks that are connected to when a projectile + * hits a block. + */ +export class ProjectileHitBlockAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a set of red sandstone - * stairs within Minecraft. + * Adds a callback that will be called when a projectile hits a + * block. + * + * This function can't be called in read-only mode. * */ - static readonly redSandstoneStairs: ItemType; - static readonly redstone: ItemType; + subscribe(callback: (arg: ProjectileHitBlockAfterEvent) => void): (arg: ProjectileHitBlockAfterEvent) => void; /** * @remarks - * Represents an item that can place a block of redstone within - * Minecraft. + * Removes a callback from being called when a projectile hits + * a block. + * + * This function can't be called in read-only mode. * */ - static readonly redstoneBlock: ItemType; + unsubscribe(callback: (arg: ProjectileHitBlockAfterEvent) => void): void; +} + +/** + * Contains information related to a projectile hitting an + * entity. + */ +export class ProjectileHitEntityAfterEvent { + private constructor(); /** * @remarks - * Represents an item that can place a redstone lamp within - * Minecraft. + * Dimension where this projectile hit took place. * */ - static readonly redstoneLamp: ItemType; + readonly dimension: Dimension; /** * @remarks - * Represents an item that can place a block with embedded - * redstone ore within Minecraft. + * Direction vector of the projectile as it hit an entity. * */ - static readonly redstoneOre: ItemType; + readonly hitVector: Vector3; /** * @remarks - * Represents an item that can place a redstone torch within - * Minecraft. + * Location where the projectile hit occurred. * */ - static readonly redstoneTorch: ItemType; - static readonly redWool: ItemType; - static readonly reinforcedDeepslate: ItemType; - static readonly repeater: ItemType; + readonly location: Vector3; /** * @remarks - * Represents an item that can place a repeating command block - * within Minecraft. + * Entity for the projectile that hit an entity. * */ - static readonly repeatingCommandBlock: ItemType; + readonly projectile: Entity; /** * @remarks - * Represents an item that can place a respawn anchor within - * Minecraft. + * Optional source entity that fired the projectile. * */ - static readonly respawnAnchor: ItemType; - static readonly rottenFlesh: ItemType; - static readonly saddle: ItemType; - static readonly salmon: ItemType; - static readonly salmonBucket: ItemType; - static readonly salmonSpawnEgg: ItemType; + readonly source?: Entity; /** * @remarks - * Represents an item that can place a block of sand within - * Minecraft. + * Contains additional information about an entity that was + * hit. + * + * This function can't be called in read-only mode. * */ - static readonly sand: ItemType; + getEntityHit(): EntityHitInformation; +} + +/** + * Manages callbacks that are connected to when a projectile + * hits an entity. + */ +export class ProjectileHitEntityAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a block of sandstone - * within Minecraft. + * Adds a callback that will be called when a projectile hits + * an entity. + * + * This function can't be called in read-only mode. * */ - static readonly sandstone: ItemType; + subscribe(callback: (arg: ProjectileHitEntityAfterEvent) => void): (arg: ProjectileHitEntityAfterEvent) => void; /** * @remarks - * Represents an item that can place a set of sandstone stairs - * within Minecraft. + * Removes a callback from being called when a projectile hits + * an entity. + * + * This function can't be called in read-only mode. * */ - static readonly sandstoneStairs: ItemType; + unsubscribe(callback: (arg: ProjectileHitEntityAfterEvent) => void): void; +} + +/** + * Contains objectives and participants for the scoreboard. + */ +export class Scoreboard { + private constructor(); /** * @remarks - * Represents an item that can place a sapling within - * Minecraft. + * Adds a new objective to the scoreboard. * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly sapling: ItemType; + addObjective(objectiveId: string, displayName?: string): ScoreboardObjective; /** * @remarks - * Represents an item that can place a set of scaffolding - * within Minecraft. + * Clears the objective that occupies a display slot. + * + * This function can't be called in read-only mode. * */ - static readonly scaffolding: ItemType; - static readonly sculk: ItemType; - static readonly sculkCatalyst: ItemType; + clearObjectiveAtDisplaySlot(displaySlotId: DisplaySlotId): ScoreboardObjective | undefined; /** * @remarks - * Represents an item that can place a sculk sensor within - * Minecraft. + * Returns a specific objective (by id). * + * @param objectiveId + * Identifier of the objective. */ - static readonly sculkSensor: ItemType; - static readonly sculkShrieker: ItemType; - static readonly sculkVein: ItemType; - static readonly scute: ItemType; + getObjective(objectiveId: string): ScoreboardObjective | undefined; /** * @remarks - * Represents seagrass within Minecraft. + * Returns an objective that occupies the specified display + * slot. * */ - static readonly seagrass: ItemType; - static readonly seaLantern: ItemType; + getObjectiveAtDisplaySlot(displaySlotId: DisplaySlotId): ScoreboardObjectiveDisplayOptions | undefined; /** * @remarks - * Represents an item that can place a seapickle within - * Minecraft. + * Returns all defined objectives. * */ - static readonly seaPickle: ItemType; - static readonly shears: ItemType; - static readonly sheepSpawnEgg: ItemType; - static readonly shield: ItemType; + getObjectives(): ScoreboardObjective[]; /** * @remarks - * Represents an item that can place a shroom light within - * Minecraft. + * Returns all defined scoreboard identities. * */ - static readonly shroomlight: ItemType; + getParticipants(): ScoreboardIdentity[]; /** * @remarks - * Represents an item that can place a shulker box within - * Minecraft. + * Removes an objective from the scoreboard. * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly shulkerBox: ItemType; - static readonly shulkerShell: ItemType; - static readonly shulkerSpawnEgg: ItemType; - static readonly silverfishSpawnEgg: ItemType; + removeObjective(objectiveId: ScoreboardObjective | string): boolean; /** * @remarks - * Represents an item that can place a silver-colored block of - * glazed terracotta within Minecraft. + * 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. */ - static readonly silverGlazedTerracotta: ItemType; - static readonly skeletonHorseSpawnEgg: ItemType; - static readonly skeletonSpawnEgg: ItemType; + setObjectiveAtDisplaySlot( + displaySlotId: DisplaySlotId, + objectiveDisplaySetting: ScoreboardObjectiveDisplayOptions, + ): ScoreboardObjective | undefined; +} + +/** + * Contains an identity of the scoreboard item. + */ +export class ScoreboardIdentity { + private constructor(); /** * @remarks - * Represents an item that can place a skull within Minecraft. + * Returns the player-visible name of this identity. * */ - static readonly skull: ItemType; - static readonly skullBannerPattern: ItemType; + readonly displayName: string; /** * @remarks - * Represents slime within Minecraft. + * Identifier of the scoreboard identity. * */ - static readonly slime: ItemType; - static readonly slimeBall: ItemType; - static readonly slimeSpawnEgg: ItemType; + readonly id: number; /** * @remarks - * Represents an item that can place a small bud of amethyst - * within Minecraft. + * Type of the scoreboard identity. * */ - static readonly smallAmethystBud: ItemType; + readonly 'type': ScoreboardIdentityType; /** * @remarks - * Represents an item that can place a small dripleaf block - * within Minecraft. + * If the scoreboard identity is an entity or player, returns + * the entity that this scoreboard item corresponds to. * + * @throws This function can throw errors. */ - static readonly smallDripleafBlock: ItemType; + getEntity(): Entity | undefined; /** * @remarks - * Represents an item that can place a smithing table within - * Minecraft. + * Returns true if the ScoreboardIdentity reference is still + * valid. * */ - static readonly smithingTable: ItemType; + isValid(): boolean; +} + +/** + * Contains objectives and participants for the scoreboard. + */ +export class ScoreboardObjective { + private constructor(); /** * @remarks - * Represents an item that can place a smoker within Minecraft. + * Returns the player-visible name of this scoreboard + * objective. * + * @throws This property can throw when used. */ - static readonly smoker: ItemType; + readonly displayName: string; /** * @remarks - * Represents an item that can place a block of smooth basalt - * within Minecraft. + * Identifier of the scoreboard objective. * + * @throws This property can throw when used. */ - static readonly smoothBasalt: ItemType; + readonly id: string; /** * @remarks - * Represents an item that can place a set of smooth quartz - * stairs within Minecraft. + * 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. */ - static readonly smoothQuartzStairs: ItemType; + addScore(participant: Entity | ScoreboardIdentity | string, scoreToAdd: number): number; /** * @remarks - * Represents an item that can place a set of smooth red - * sandstone stairs within Minecraft. + * Returns all objective participant identities. * + * @throws This function can throw errors. */ - static readonly smoothRedSandstoneStairs: ItemType; + getParticipants(): ScoreboardIdentity[]; /** * @remarks - * Represents an item that can place a set of smooth redstone - * stairs within Minecraft. + * Returns a specific score for a participant. * + * @param participant + * Identifier of the participant to retrieve a score for. + * @throws This function can throw errors. */ - static readonly smoothSandstoneStairs: ItemType; + getScore(participant: Entity | ScoreboardIdentity | string): number | undefined; /** * @remarks - * Represents an item that can place a smooth stone block - * within Minecraft. + * Returns specific scores for this objective for all + * participants. * + * @throws This function can throw errors. */ - static readonly smoothStone: ItemType; - static readonly snifferEgg: ItemType; - static readonly snifferSpawnEgg: ItemType; + getScores(): ScoreboardScoreInfo[]; /** * @remarks - * Represents snow within Minecraft. + * Returns if the specified identity is a participant of the + * scoreboard objective. * + * @throws This function can throw errors. */ - static readonly snow: ItemType; - static readonly snowball: ItemType; - static readonly snowGolemSpawnEgg: ItemType; + hasParticipant(participant: Entity | ScoreboardIdentity | string): boolean; /** * @remarks - * Represents an item that can place a layer of snow within - * Minecraft. + * Returns true if the ScoreboardObjective reference is still + * valid. * */ - static readonly snowLayer: ItemType; + isValid(): boolean; /** * @remarks - * Represents an item that can place a soul campfire within - * Minecraft. + * 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. */ - static readonly soulCampfire: ItemType; + removeParticipant(participant: Entity | ScoreboardIdentity | string): boolean; /** * @remarks - * Represents an item that can place a soul lantern within - * Minecraft. + * 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. */ - static readonly soulLantern: ItemType; + 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 - * Represents an item that can place a block of soul sand - * within Minecraft. + * This scoreboard participant for this score. * */ - static readonly soulSand: ItemType; + readonly participant: ScoreboardIdentity; /** * @remarks - * Represents soul soil within Minecraft. + * Score value of the identity for this objective. * */ - static readonly soulSoil: ItemType; + readonly score: number; +} + +/** + * Contains information about user interface elements that are + * showing up on the screen. + * @example setTitle.ts + * ```typescript + * import { world } from '@minecraft/server'; + * + * world.afterEvents.playerSpawn.subscribe((event) => { + * event.player.onScreenDisplay.setTitle('§o§6You respawned!§r'); + * }); + * ``` + * @example setTitleAndSubtitle.ts + * ```typescript + * import { world } from '@minecraft/server'; + * + * world.afterEvents.playerSpawn.subscribe((event) => { + * event.player.onScreenDisplay.setTitle('You respawned', { + * stayDuration: 100, + * fadeInDuration: 2, + * fadeOutDuration: 4, + * subtitle: 'Try not to die next time!', + * }); + * }); + * ``` + * @example titleCountdown.ts + * ```typescript + * import { world, system } from '@minecraft/server'; + * + * world.afterEvents.playerSpawn.subscribe(event => { + * event.player.onScreenDisplay.setTitle('Get ready!', { + * stayDuration: 220, + * fadeInDuration: 2, + * fadeOutDuration: 4, + * subtitle: '10', + * }); + * + * let countdown = 10; + * + * const intervalId = system.runInterval(() => { + * countdown--; + * event.player.onScreenDisplay.updateSubtitle(countdown.toString()); + * + * if (countdown == 0) { + * system.clearRun(intervalId); + * } + * }, 20); + * }); + * ``` + */ +export class ScreenDisplay { + private constructor(); /** + * @beta * @remarks - * Represents an item that can place a soul torch within - * Minecraft. + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly soulTorch: ItemType; - static readonly spawnEgg: ItemType; - static readonly spiderEye: ItemType; - static readonly spiderSpawnEgg: ItemType; - static readonly splashPotion: ItemType; + getHiddenHudElements(): HudElement[]; /** + * @beta * @remarks - * Represents an item that can place a sponge within Minecraft. + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly sponge: ItemType; + hideAllExcept(hudElements?: HudElement[]): void; /** + * @beta * @remarks - * Represents an item that can place a spore blossom within - * Minecraft. + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly sporeBlossom: ItemType; - static readonly spruceBoat: ItemType; + isForcedHidden(hudElement: HudElement): boolean; /** * @remarks - * Represents an item that can place a spruce wood button - * within Minecraft. + * Returns true if the current reference to this screen display + * manager object is valid and functional. * */ - static readonly spruceButton: ItemType; - static readonly spruceChestBoat: ItemType; + isValid(): boolean; /** + * @beta * @remarks - * Represents an item that can place a spruce wood door within - * Minecraft. + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly spruceDoor: ItemType; - static readonly spruceFence: ItemType; + resetHudElements(): void; /** * @remarks - * Represents an item that can place a spruce wood fence gate - * within Minecraft. + * 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. */ - static readonly spruceFenceGate: ItemType; - static readonly spruceLog: ItemType; + setActionBar(text: (RawMessage | string)[] | RawMessage | string): void; /** + * @beta * @remarks - * Represents an item that can place a spruce wood pressure - * plate within Minecraft. + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly sprucePressurePlate: ItemType; + setHudVisibility(visible: HudVisibility, hudElements?: HudElement[]): void; /** * @remarks - * Represents an item that can place a spruce sign within - * Minecraft. + * 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 setTitle.ts + * ```typescript + * import { world } from '@minecraft/server'; * + * world.afterEvents.playerSpawn.subscribe((event) => { + * event.player.onScreenDisplay.setTitle('§o§6You respawned!§r'); + * }); + * ``` + * @example setTitleAndSubtitle.ts + * ```typescript + * import { world } from '@minecraft/server'; + * + * world.afterEvents.playerSpawn.subscribe((event) => { + * event.player.onScreenDisplay.setTitle('You respawned', { + * stayDuration: 100, + * fadeInDuration: 2, + * fadeOutDuration: 4, + * subtitle: 'Try not to die next time!', + * }); + * }); + * ``` + * @example titleCountdown.ts + * ```typescript + * import { world, system } from '@minecraft/server'; + * + * world.afterEvents.playerSpawn.subscribe(event => { + * event.player.onScreenDisplay.setTitle('Get ready!', { + * stayDuration: 220, + * fadeInDuration: 2, + * fadeOutDuration: 4, + * subtitle: '10', + * }); + * + * let countdown = 10; + * + * const intervalId = system.runInterval(() => { + * countdown--; + * event.player.onScreenDisplay.updateSubtitle(countdown.toString()); + * + * if (countdown == 0) { + * system.clearRun(intervalId); + * } + * }, 20); + * }); + * ``` */ - static readonly spruceSign: ItemType; + setTitle(title: (RawMessage | string)[] | RawMessage | string, options?: TitleDisplayOptions): void; /** * @remarks - * Represents an item that can place a set of spruce wood - * stairs within Minecraft. + * 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. */ - static readonly spruceStairs: ItemType; + updateSubtitle(subtitle: (RawMessage | string)[] | RawMessage | string): void; +} + +/** + * Returns additional data about a /scriptevent command + * invocation. + */ +export class ScriptEventCommandMessageAfterEvent { + private constructor(); /** * @remarks - * Represents an item that can place a spruce wood trapdoor - * within Minecraft. + * Identifier of this ScriptEvent command message. * */ - static readonly spruceTrapdoor: ItemType; - static readonly spyglass: ItemType; - static readonly squidSpawnEgg: ItemType; + readonly id: string; /** * @remarks - * Represents stained glass within Minecraft. + * If this command was initiated via an NPC, returns the entity + * that initiated the NPC dialogue. * */ - static readonly stainedGlass: ItemType; + readonly initiator?: Entity; /** * @remarks - * Represents an item that can place a pane of stained glass - * within Minecraft. + * Optional additional data passed in with the script event + * command. * */ - static readonly stainedGlassPane: ItemType; + readonly message: string; /** * @remarks - * Represents an item that can place a block of stained - * hardened clay within Minecraft. + * Source block if this command was triggered via a block + * (e.g., a commandblock.) * */ - static readonly stainedHardenedClay: ItemType; - static readonly stick: ItemType; + readonly sourceBlock?: Block; /** * @remarks - * Represents an item that can place a piston block with a - * sticky arm within Minecraft. + * Source entity if this command was triggered by an entity + * (e.g., a NPC). * */ - static readonly stickyPiston: ItemType; + readonly sourceEntity?: Entity; /** * @remarks - * Represents an item that can place a block of stone within - * Minecraft. + * Returns the type of source that fired this command. * */ - static readonly stone: ItemType; - static readonly stoneAxe: ItemType; - static readonly stoneBlockSlab: ItemType; - static readonly stoneBlockSlab2: ItemType; - static readonly stoneBlockSlab3: ItemType; - static readonly stoneBlockSlab4: ItemType; + readonly sourceType: ScriptEventSource; +} + +/** + * Allows for registering an event handler that responds to + * inbound /scriptevent commands. + */ +export class ScriptEventCommandMessageAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a block of stone brick - * within Minecraft. + * Registers a new ScriptEvent handler. + * + * This function can't be called in read-only mode. * */ - static readonly stonebrick: ItemType; + subscribe( + callback: (arg: ScriptEventCommandMessageAfterEvent) => void, + options?: ScriptEventMessageFilterOptions, + ): (arg: ScriptEventCommandMessageAfterEvent) => void; /** * @remarks - * Represents an item that can place a set of stone brick - * stairs within Minecraft. + * Unsubscribes a particular handler for a ScriptEvent event. + * + * This function can't be called in read-only mode. * + * @throws This function can throw errors. */ - static readonly stoneBrickStairs: ItemType; + unsubscribe(callback: (arg: ScriptEventCommandMessageAfterEvent) => void): void; +} + +/** + * @beta + * Describes a particular seating position on this rideable + * entity. + */ +export class Seat { + private constructor(); /** * @remarks - * Represents an item that can place a stone button within - * Minecraft. + * Angle in degrees that a rider is allowed to rotate while + * riding this entity. * */ - static readonly stoneButton: ItemType; + readonly lockRiderRotation: number; /** * @remarks - * Represents an item that can place a stonecutter block within - * Minecraft. + * A maximum number of riders that this seat can support. * */ - static readonly stonecutterBlock: ItemType; - static readonly stoneHoe: ItemType; - static readonly stonePickaxe: ItemType; + readonly maxRiderCount: number; /** * @remarks - * Represents an item that can place a stone pressure plate - * within Minecraft. + * A minimum number of riders that can be placed in this seat + * position, if this seat is to be filled. * */ - static readonly stonePressurePlate: ItemType; - static readonly stoneShovel: ItemType; + readonly minRiderCount: number; /** * @remarks - * Represents an item that can place a set of stone stairs - * within Minecraft. + * Physical location of this seat, relative to the entity's + * location. * */ - static readonly stoneStairs: ItemType; - static readonly stoneSword: ItemType; - static readonly straySpawnEgg: ItemType; - static readonly striderSpawnEgg: ItemType; - static readonly 'string': ItemType; + readonly position: Vector3; /** * @remarks - * Represents an item that can place a stripped acacia log - * within Minecraft. + * Angle in degrees to rotate riders by. * */ - static readonly strippedAcaciaLog: ItemType; + readonly seatRotation: number; +} + +/** + * @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 - * Represents an item that can place a stripped birch log - * within Minecraft. + * Adds a callback that will be called when an internal message + * is passed. + * + * This function can't be called in read-only mode. * */ - static readonly strippedBirchLog: ItemType; + subscribe(callback: (arg: MessageReceiveAfterEvent) => void): (arg: MessageReceiveAfterEvent) => void; /** * @remarks - * Represents stripped crimson hyphae within Minecraft. + * Removes a callback from being called when an internal + * message is passed. + * + * This function can't be called in read-only mode. * */ - static readonly strippedCrimsonHyphae: ItemType; + unsubscribe(callback: (arg: MessageReceiveAfterEvent) => void): void; +} + +/** + * Represents a loaded structure template (.mcstructure file). + * Structures can be placed in a world using the /structure + * command or the {@link StructureManager} APIs. + */ +export class Structure { + private constructor(); /** * @remarks - * Represents an item that can place a stripped crimson stem - * within Minecraft. + * The name of the structure. The identifier must include a + * namespace. For structures created via the /structure command + * or structure blocks, this namespace defaults to + * "mystructure". * */ - static readonly strippedCrimsonStem: ItemType; + readonly id: string; /** * @remarks - * Represents an item that can place a stripped dark oak log - * within Minecraft. + * The dimensions of the structure. For example, a single block + * structure will have a size of {x:1, y:1, z:1} * + * @throws This property can throw when used. + * + * {@link InvalidStructureError} */ - static readonly strippedDarkOakLog: ItemType; + readonly size: Vector3; /** * @remarks - * Represents an item that can place a stripped jungle log - * within Minecraft. + * Returns a BlockPermutation representing the block contained + * within the Structure at the given location. + * + * @param location + * The block location relative to the Structure's origin. + * @returns + * Returns a BlockPermutation. Returns undefined if a block + * does not exist at the given location. + * @throws + * Throws if the location is outside the structure's bounds. + * Throws if the Structure has been deleted. * + * {@link minecraftcommon.InvalidArgumentError} + * + * {@link InvalidStructureError} */ - static readonly strippedJungleLog: ItemType; - static readonly strippedMangroveLog: ItemType; - static readonly strippedMangroveWood: ItemType; + getBlockPermutation(location: Vector3): BlockPermutation | undefined; /** * @remarks - * Represents an item that can place a stripped oak log within - * Minecraft. + * Returns whether the block at the given location is + * waterlogged. + * + * @param location + * The block location relative to the Structure's origin. + * @returns + * Returns whether the block at the given location is + * waterlogged. Returns false if a block does not exist at the + * given location. + * @throws + * Throws if the location is outside the structure's bounds. + * Throws if the Structure has been deleted. * + * {@link minecraftcommon.InvalidArgumentError} + * + * {@link InvalidStructureError} */ - static readonly strippedOakLog: ItemType; + getIsWaterlogged(location: Vector3): boolean; /** * @remarks - * Represents an item that can place a stripped spruce log - * within Minecraft. + * Returns whether the Structure is valid. The Structure may + * become invalid if it is deleted. * + * @returns + * Returns whether the Structure is valid. */ - static readonly strippedSpruceLog: ItemType; + isValid(): boolean; /** + * @beta * @remarks - * Represents stripped warped hyphae within Minecraft. + * Creates a copy of a Structure and saves it with a new name. + * + * This function can't be called in read-only mode. + * + * @param identifier + * The name of the newly created Structure. + * @param saveMode + * Determines how the Structure should be saved. Defaults to + * saving to the world. + * @returns + * Returns the newly created structure. + * @throws + * Throws if the identifier is invalid. A valid identifier must + * include a namespace and must be unique. + * Throws if the Structure has been deleted. + * + * {@link minecraftcommon.EngineError} * + * {@link minecraftcommon.InvalidArgumentError} + * + * {@link InvalidStructureError} */ - static readonly strippedWarpedHyphae: ItemType; + saveAs(identifier: string, saveMode?: StructureSaveMode): Structure; /** + * @beta * @remarks - * Represents stripped warped stem within Minecraft. + * Saves a modified Structure to the world file. + * + * This function can't be called in read-only mode. + * + * @throws + * Throws if the Structure has been deleted. * + * {@link InvalidStructureError} */ - static readonly strippedWarpedStem: ItemType; + saveToWorld(): void; /** + * @beta * @remarks - * Represents an item that can place a structure block, which - * provides for the saving and loading of block structures, - * within Minecraft. + * Sets a BlockPermutation within a Structure. + * + * This function can't be called in read-only mode. + * + * @param location + * The block location relative to the Structure's origin. + * @param blockPermutation + * The BlockPermutation to set. + * @throws + * Throws if the type of block is StructureVoid. + * Throws if the block is undefined and waterlogged is set to + * true. + * Throws if the block is air and waterlogged is set to true. + * Throws if the location is outside the structure's bounds. + * Throws if the Structure has been deleted. * + * {@link minecraftcommon.InvalidArgumentError} + * + * {@link InvalidStructureError} */ - static readonly structureBlock: ItemType; + setBlockPermutation(location: Vector3, blockPermutation?: BlockPermutation): void; +} + +/** + * Manager for Structure related APIs. Includes APIs for + * creating, getting, placing and deleting Structures. + */ +export class StructureManager { + private constructor(); /** * @remarks - * Represents an item that can place a structure void within - * Minecraft. + * Creates an empty Structure in memory. Use {@link + * Structure.setBlockPermutation} to populate the structure + * with blocks and save changes with {@link + * @minecraft/server.Structure.save}. + * + * This function can't be called in read-only mode. + * + * @param identifier + * The name of the structure. A valid identifier must include a + * namespace and must be unique. + * @param size + * The size of the structure. For example, to create a single + * block structure the size should be {x:1, y:1, z:1}. + * @param saveMode + * How the Structure should be saved upon creation. Defaults to + * StructureSaveMode.Memory. + * @returns + * Returns the newly created Structure. + * @throws + * Throws if the identifier is invalid. A valid identifier must + * include a namespace and must be unique. * + * {@link minecraftcommon.EngineError} + * + * {@link minecraftcommon.InvalidArgumentError} */ - static readonly structureVoid: ItemType; - static readonly sugar: ItemType; - static readonly sugarCane: ItemType; - static readonly suspiciousStew: ItemType; - static readonly sweetBerries: ItemType; - static readonly tadpoleBucket: ItemType; - static readonly tadpoleSpawnEgg: ItemType; + createEmpty(identifier: string, size: Vector3, saveMode?: StructureSaveMode): Structure; /** + * @beta * @remarks - * Represents tall grass within Minecraft. + * Creates a new Structure from blocks in the world. This is + * functionally equivalent to the /structure save command. + * + * This function can't be called in read-only mode. + * + * @param identifier + * The name of the structure. A valid identifier must include a + * namespace and must be unique. + * @param dimension + * The dimension where the blocks should be read from. + * @param options + * Additional options for creating a structure from the world. + * @returns + * Returns the newly created Structure. + * @throws + * Throws if the identifier is invalid. A valid identifier must + * include a namespace and must be unique. + * Throws if the structure bounds exceed the maximum size. + * Throws if the structure bounds contains blocks outside the + * world bounds. + * * + * {@link minecraftcommon.InvalidArgumentError} */ - static readonly tallgrass: ItemType; + createFromWorld( + identifier: string, + dimension: Dimension, + from: Vector3, + to: Vector3, + options?: StructureCreateOptions, + ): Structure; /** * @remarks - * Represents an item that can place a target within Minecraft. + * Deletes a structure from memory and from the world if it + * exists. + * + * This function can't be called in read-only mode. + * + * @param structure + * The structure identifier or Structure object that should be + * deleted. Note, a Structure object will become invalid after + * it is deleted. + * @returns + * Returns whether the structure was removed. + * @throws + * Throws if a structure cannot be removed. For example, a + * structure loaded from a Behavior Pack. * + * {@link minecraftcommon.InvalidArgumentError} */ - static readonly target: ItemType; + delete(structure: string | Structure): boolean; /** * @remarks - * Represents tinted glass within Minecraft. + * Gets a Structure that is saved to memory or the world. + * + * This function can't be called in read-only mode. * + * @param identifier + * The name of the structure to get. + * @returns + * Returns a Structure if it exists, otherwise undefined. */ - static readonly tintedGlass: ItemType; + get(identifier: string): Structure | undefined; /** + * @beta * @remarks - * Represents an item that can place a block of TnT within - * Minecraft. + * This function can't be called in read-only mode. * */ - static readonly tnt: ItemType; - static readonly tntMinecart: ItemType; + getWorldStructureIds(): string[]; /** * @remarks - * Represents an item that can place a torch within Minecraft. + * Places a structure in the world. Structures placed in + * unloaded chunks will be queued for loading. + * + * This function can't be called in read-only mode. + * + * @param structure + * The structure's identifier or a Structure object. + * @param dimension + * The dimension where the Structure should be placed. + * @param location + * The location within the dimension where the Structure should + * be placed. + * @param options + * Additional options for Structure placement. + * @throws + * Throws if the integrity value is outside of the range [0,1] + * Throws if the integrity seed is invalid. + * Throws if the placement location contains blocks that are + * outside the world bounds. + * + * {@link minecraftcommon.ArgumentOutOfBoundsError} + * + * {@link minecraftcommon.InvalidArgumentError} * + * {@link InvalidStructureError} */ - static readonly torch: ItemType; - static readonly torchflower: ItemType; - static readonly torchflowerSeeds: ItemType; - static readonly totemOfUndying: ItemType; - static readonly traderLlamaSpawnEgg: ItemType; + place( + structure: string | Structure, + dimension: Dimension, + location: Vector3, + options?: StructurePlaceOptions, + ): void; +} + +/** + * A class that provides system-level events and functions. + */ +export class System { + private constructor(); /** * @remarks - * Represents an item that can place a trapdoor within - * Minecraft. + * Returns a collection of after-events for system-level + * operations. * */ - static readonly trapdoor: ItemType; + readonly afterEvents: SystemAfterEvents; /** + * @beta * @remarks - * Represents an item that can place a trapped chest within - * Minecraft. + * Returns a collection of before-events for system-level + * operations. * */ - static readonly trappedChest: ItemType; - static readonly trident: ItemType; + readonly beforeEvents: SystemBeforeEvents; /** * @remarks - * Represents an item that can place a tripwire hook within - * Minecraft. + * Represents the current world tick of the server. * */ - static readonly tripwireHook: ItemType; - static readonly tropicalFish: ItemType; - static readonly tropicalFishBucket: ItemType; - static readonly tropicalFishSpawnEgg: ItemType; - static readonly tubeCoral: ItemType; + readonly currentTick: number; /** + * @beta * @remarks - * Represents an item that can place a block of tuff within - * Minecraft. + * Cancels the execution of a job queued via {@link + * System.runJob}. * + * @param jobId + * The job ID returned from {@link System.runJob}. */ - static readonly tuff: ItemType; + clearJob(jobId: number): void; /** * @remarks - * Represents an item that can place a turtle egg within - * Minecraft. + * Cancels the execution of a function run that was previously + * scheduled via {@link System.run}. * */ - static readonly turtleEgg: ItemType; - static readonly turtleHelmet: ItemType; - static readonly turtleSpawnEgg: ItemType; + clearRun(runId: number): void; /** * @remarks - * Represents an item that can place a set of twisting vines - * within Minecraft. + * 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 + * import { system, world } from '@minecraft/server'; + * + * function printEveryMinute() { + * try { + * // Minecraft runs at 20 ticks per second. + * if (system.currentTick % 1200 === 0) { + * world.sendMessage('Another minute passes...'); + * } + * } catch (e) { + * console.warn('Error: ' + e); + * } + * + * system.run(printEveryMinute); + * } + * + * printEveryMinute(); + * ``` */ - static readonly twistingVines: ItemType; + run(callback: () => void): number; /** * @remarks - * Represents an item that can place an undyed shulker box - * within Minecraft. + * 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 + * import { system, world } from '@minecraft/server'; + * + * const intervalRunIdentifier = Math.floor(Math.random() * 10000); + * + * system.runInterval(() => { + * world.sendMessage('This is an interval run ' + intervalRunIdentifier + ' sending a message every 30 seconds.'); + * }, 600); + * ``` */ - static readonly undyedShulkerBox: ItemType; - static readonly verdantFroglight: ItemType; - static readonly vexSpawnEgg: ItemType; - static readonly villagerSpawnEgg: ItemType; - static readonly vindicatorSpawnEgg: ItemType; + runInterval(callback: () => void, tickInterval?: number): number; /** + * @beta * @remarks - * Represents an item that can place a set of vines within - * Minecraft. + * Queues a generator to run until completion. The generator + * will be given a time slice each tick, and will be run until + * it yields or completes. * + * @param generator + * The instance of the generator to run. + * @returns + * An opaque handle that can be used with {@link + * System.clearJob} to stop the run of this generator. + * @example cubeGenerator.ts + * ```typescript + * import { BlockPermutation, DimensionLocation, world, ButtonPushAfterEvent, system } from '@minecraft/server'; + * + * // A simple generator that places blocks in a cube at a specific location + * // with a specific size, yielding after every block place. + * function* blockPlacingGenerator(blockPerm: BlockPermutation, startingLocation: DimensionLocation, size: number) { + * for (let x = startingLocation.x; x < startingLocation.x + size; x++) { + * for (let y = startingLocation.y; y < startingLocation.y + size; y++) { + * for (let z = startingLocation.z; z < startingLocation.z + size; z++) { + * const block = startingLocation.dimension.getBlock({ x: x, y: y, z: z }); + * if (block) { + * block.setPermutation(blockPerm); + * } + * yield; + * } + * } + * } + * } + * + * // When a button is pushed, we will place a 15x15x15 cube of cobblestone 10 blocks above it + * world.afterEvents.buttonPush.subscribe((buttonPushEvent: ButtonPushAfterEvent) => { + * const cubePos = buttonPushEvent.block.location; + * cubePos.y += 10; + * + * const blockPerm = BlockPermutation.resolve('minecraft:cobblestone'); + * + * system.runJob(blockPlacingGenerator(blockPerm, { dimension: buttonPushEvent.dimension, ...cubePos }, 15)); + * }); + * ``` */ - static readonly vine: ItemType; - static readonly wanderingTraderSpawnEgg: ItemType; - static readonly wardenSpawnEgg: ItemType; + runJob(generator: Generator): number; /** * @remarks - * Represents an item that can place a warped button within - * Minecraft. + * 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. */ - static readonly warpedButton: ItemType; + runTimeout(callback: () => void, tickDelay?: number): number; /** - * @remarks - * Represents an item that can place a warped door within - * Minecraft. + * @beta + * @throws This function can throw errors. * + * {@link minecraftcommon.EngineError} */ - static readonly warpedDoor: ItemType; + waitTicks(ticks: number): Promise; +} + +/** + * Provides a set of events that fire within the broader + * scripting system within Minecraft. + */ +export class SystemAfterEvents { + private constructor(); /** * @remarks - * Represents an item that can place a warped fence within - * Minecraft. + * An event that fires when a /scriptevent command is set. This + * provides a way for commands and other systems to trigger + * behavior within script. * */ - static readonly warpedFence: ItemType; + 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 - * Represents an item that can place a warped fence gate within - * Minecraft. + * 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. * */ - static readonly warpedFenceGate: ItemType; + readonly watchdogTerminate: WatchdogTerminateBeforeEventSignal; +} + +/** + * 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 - * Represents warped fungus within Minecraft. + * The position where the source hit the block. * */ - static readonly warpedFungus: ItemType; - static readonly warpedFungusOnAStick: ItemType; + readonly hitVector: Vector3; /** * @remarks - * Represents warped hyphae within Minecraft. + * The redstone power before the block is hit. * */ - static readonly warpedHyphae: ItemType; + readonly previousRedstonePower: number; /** * @remarks - * Represents warped nylium within Minecraft. + * The redstone power at the time the block is hit. * */ - static readonly warpedNylium: ItemType; + readonly redstonePower: number; /** * @remarks - * Represents warped planks within Minecraft. + * Optional source that hit the target block. * */ - static readonly warpedPlanks: ItemType; + readonly source: Entity; +} + +/** + * Manages callbacks that are connected to when a target block + * is hit. + */ +export class TargetBlockHitAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a warped pressure plate - * within Minecraft. + * Adds a callback that will be called when a target block is + * hit. + * + * This function can't be called in read-only mode. * */ - static readonly warpedPressurePlate: ItemType; + subscribe(callback: (arg: TargetBlockHitAfterEvent) => void): (arg: TargetBlockHitAfterEvent) => void; /** * @remarks - * Represents an item that can place a set of warped roots - * within Minecraft. + * Removes a callback from being called when a target block is + * hit. + * + * This function can't be called in read-only mode. * */ - static readonly warpedRoots: ItemType; - static readonly warpedSign: ItemType; + unsubscribe(callback: (arg: TargetBlockHitAfterEvent) => void): void; +} + +/** + * @beta + * Represents a trigger for firing an event. + */ +export class Trigger { /** * @remarks - * Represents an item that can place a slab of warped material - * within Minecraft. + * Event name of the trigger. * */ - static readonly warpedSlab: ItemType; + eventName: string; /** * @remarks - * Represents an item that can place a set of warped stairs - * within Minecraft. + * Creates a new trigger. * */ - static readonly warpedStairs: ItemType; + constructor(eventName: string); +} + +/** + * Contains information related to changes to a trip wire trip. + * @example tripWireTripEvent.ts + * ```typescript + * import { Vector3, world, BlockPermutation, TripWireTripAfterEvent, system } from '@minecraft/server'; + * + * const overworld = world.getDimension('overworld'); + * const targetLocation: Vector3 = { x: 0, y: 0, z: 0 }; + * + * // set up a tripwire + * const redstone = overworld.getBlock({ x: targetLocation.x, y: targetLocation.y - 1, z: targetLocation.z }); + * const tripwire = overworld.getBlock(targetLocation); + * + * if (redstone === undefined || tripwire === undefined) { + * console.warn('Could not find block at location.'); + * } else { + * + * redstone.setPermutation(BlockPermutation.resolve('redstone_block')); + * tripwire.setPermutation(BlockPermutation.resolve('tripwire')); + * + * world.afterEvents.tripWireTrip.subscribe((tripWireTripEvent: TripWireTripAfterEvent) => { + * const eventLoc = tripWireTripEvent.block.location; + * + * if (eventLoc.x === targetLocation.x && eventLoc.y === targetLocation.y && eventLoc.z === targetLocation.z) { + * console.warn( + * 'Tripwire trip event at tick ' + + * system.currentTick + + * (tripWireTripEvent.sources.length > 0 ? ' by entity ' + tripWireTripEvent.sources[0].id : ''), + * ); + * } + * }); + * } + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class TripWireTripAfterEvent extends BlockEvent { + private constructor(); /** * @remarks - * Represents an item that can place a warped stem within - * Minecraft. + * Whether or not the block has redstone power. * */ - static readonly warpedStem: ItemType; + readonly isPowered: boolean; /** * @remarks - * Represents an item that can place a warped trapdoor within - * Minecraft. + * The sources that triggered the trip wire to trip. * */ - static readonly warpedTrapdoor: ItemType; + readonly sources: Entity[]; +} + +/** + * Manages callbacks that are connected to when a trip wire is + * tripped. + * @example tripWireTripEvent.ts + * ```typescript + * import { Vector3, world, BlockPermutation, TripWireTripAfterEvent, system } from '@minecraft/server'; + * + * const overworld = world.getDimension('overworld'); + * const targetLocation: Vector3 = { x: 0, y: 0, z: 0 }; + * + * // set up a tripwire + * const redstone = overworld.getBlock({ x: targetLocation.x, y: targetLocation.y - 1, z: targetLocation.z }); + * const tripwire = overworld.getBlock(targetLocation); + * + * if (redstone === undefined || tripwire === undefined) { + * console.warn('Could not find block at location.'); + * } else { + * + * redstone.setPermutation(BlockPermutation.resolve('redstone_block')); + * tripwire.setPermutation(BlockPermutation.resolve('tripwire')); + * + * world.afterEvents.tripWireTrip.subscribe((tripWireTripEvent: TripWireTripAfterEvent) => { + * const eventLoc = tripWireTripEvent.block.location; + * + * if (eventLoc.x === targetLocation.x && eventLoc.y === targetLocation.y && eventLoc.z === targetLocation.z) { + * console.warn( + * 'Tripwire trip event at tick ' + + * system.currentTick + + * (tripWireTripEvent.sources.length > 0 ? ' by entity ' + tripWireTripEvent.sources[0].id : ''), + * ); + * } + * }); + * } + * ``` + */ +export class TripWireTripAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a warped wart block within - * Minecraft. + * Adds a callback that will be called when a trip wire is + * tripped. + * + * This function can't be called in read-only mode. * */ - static readonly warpedWartBlock: ItemType; - static readonly waterBucket: ItemType; + subscribe(callback: (arg: TripWireTripAfterEvent) => void): (arg: TripWireTripAfterEvent) => void; /** * @remarks - * Represents an item that can place a water lily within - * Minecraft. + * Removes a callback from being called when a trip wire is + * tripped. + * + * This function can't be called in read-only mode. * */ - static readonly waterlily: ItemType; + unsubscribe(callback: (arg: TripWireTripAfterEvent) => void): void; +} + +/** + * @beta + * Contains information related to a script watchdog + * termination. + */ +export class WatchdogTerminateBeforeEvent { + private constructor(); /** * @remarks - * Represents an item that can place a block of waxed copper - * within Minecraft. + * 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. * */ - static readonly waxedCopper: ItemType; + cancel: boolean; /** * @remarks - * Represents an item that can place a block of waxed cut - * copper within Minecraft. + * Contains the reason why a script runtime is to be + * terminated. * */ - static readonly waxedCutCopper: ItemType; + 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 - * Represents an item that can place a slab of waxed cut copper - * within Minecraft. + * 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. * */ - static readonly waxedCutCopperSlab: ItemType; + subscribe(callback: (arg: WatchdogTerminateBeforeEvent) => void): (arg: WatchdogTerminateBeforeEvent) => void; /** * @remarks - * Represents an item that can place a set of waxed cut copper - * stairs within Minecraft. + * 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. * */ - static readonly waxedCutCopperStairs: ItemType; + unsubscribe(callback: (arg: WatchdogTerminateBeforeEvent) => void): void; +} + +/** + * Contains information related to changes in weather in the + * environment. + */ +export class WeatherChangeAfterEvent { + private constructor(); /** * @remarks - * Represents an item that can place a block of waxed exposed - * copper within Minecraft. + * Dimension in which the weather has changed. * */ - static readonly waxedExposedCopper: ItemType; + readonly dimension: string; /** * @remarks - * Represents an item that can place a block of waxed exposed - * cut copper within Minecraft. + * The weather type after the weather was changed. * */ - static readonly waxedExposedCutCopper: ItemType; + readonly newWeather: WeatherType; /** * @remarks - * Represents an item that can place a slab of waxed exposed - * cut copper within Minecraft. + * The weather type before the weather was changed. * */ - static readonly waxedExposedCutCopperSlab: ItemType; + readonly previousWeather: WeatherType; +} + +/** + * Manages callbacks that are connected to weather changing. + */ +export class WeatherChangeAfterEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a set of waxed exposed cut - * copper stairs within Minecraft. + * Adds a callback that will be called when weather changes. + * + * This function can't be called in read-only mode. * */ - static readonly waxedExposedCutCopperStairs: ItemType; + subscribe(callback: (arg: WeatherChangeAfterEvent) => void): (arg: WeatherChangeAfterEvent) => void; /** * @remarks - * Represents an item that can place a block of waxed oxidized - * copper within Minecraft. + * Removes a callback from being called when weather changes. + * + * This function can't be called in read-only mode. * */ - static readonly waxedOxidizedCopper: ItemType; + unsubscribe(callback: (arg: WeatherChangeAfterEvent) => void): void; +} + +/** + * @beta + * Contains information related to changes in weather in the + * environment. + */ +export class WeatherChangeBeforeEvent { + private constructor(); /** * @remarks - * Represents an item that can place a block of waxed oxidized - * cut copper within Minecraft. + * If set to true the weather change will be cancelled. * */ - static readonly waxedOxidizedCutCopper: ItemType; + cancel: boolean; /** * @remarks - * Represents an item that can place a slab of waxed oxidized - * cut copper within Minecraft. + * Sets the duration of the new weather (in ticks). * */ - static readonly waxedOxidizedCutCopperSlab: ItemType; + duration: number; /** * @remarks - * Represents an item that can place a set of waxed oxidized - * cut copper stairs within Minecraft. + * The type of weather that will be applied. * */ - static readonly waxedOxidizedCutCopperStairs: ItemType; + newWeather: WeatherType; /** * @remarks - * Represents an item that can place a block of waxed weathered - * copper within Minecraft. + * The type of weather that it was prior to the event being + * fired. * */ - static readonly waxedWeatheredCopper: ItemType; + readonly previousWeather: WeatherType; +} + +/** + * @beta + * Manages callbacks that are connected to before weather + * changing. + */ +export class WeatherChangeBeforeEventSignal { + private constructor(); /** * @remarks - * Represents an item that can place a block of waxed weathered - * cut copper within Minecraft. + * Adds a callback that will be called before weather changes. + * + * This function can't be called in read-only mode. * */ - static readonly waxedWeatheredCutCopper: ItemType; + subscribe(callback: (arg: WeatherChangeBeforeEvent) => void): (arg: WeatherChangeBeforeEvent) => void; /** * @remarks - * Represents an item that can place a slab of waxed weathered - * cut copper within Minecraft. + * Removes a callback from being called before weather changes. + * + * This function can't be called in read-only mode. * */ - static readonly waxedWeatheredCutCopperSlab: ItemType; + unsubscribe(callback: (arg: WeatherChangeBeforeEvent) => 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 - * Represents an item that can place a set of waxed weathered - * cut copper stairs within Minecraft. + * 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. * */ - static readonly waxedWeatheredCutCopperStairs: ItemType; + readonly afterEvents: WorldAfterEvents; /** * @remarks - * Represents an item that can place a block of weathered - * copper within Minecraft. + * 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. * */ - static readonly weatheredCopper: ItemType; + readonly beforeEvents: WorldBeforeEvents; /** + * @beta * @remarks - * Represents an item that can place a block of weathered cut - * copper within Minecraft. + * The game rules that apply to the world. * */ - static readonly weatheredCutCopper: ItemType; + readonly gameRules: GameRules; /** * @remarks - * Represents an item that can place a slab of weathered cut - * copper within Minecraft. + * Returns the general global scoreboard that applies to the + * world. * */ - static readonly weatheredCutCopperSlab: ItemType; + readonly scoreboard: Scoreboard; /** * @remarks - * Represents an item that can place a set of weathered cut - * copper stairs within Minecraft. + * Returns the manager for {@link Structure} related APIs. * */ - static readonly weatheredCutCopperStairs: ItemType; + readonly structureManager: StructureManager; /** + * @beta * @remarks - * Represents an item that can place a web within Minecraft. + * 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. */ - static readonly web: ItemType; + broadcastClientMessage(id: string, value: string): void; /** * @remarks - * Represents an item that can place a set of weeping vines - * within Minecraft. + * Clears the set of dynamic properties declared for this + * behavior pack within the world. * */ - static readonly weepingVines: ItemType; + clearDynamicProperties(): void; /** * @remarks - * Represents wheat within Minecraft. + * Returns the absolute time since the start of the world. * */ - static readonly wheat: ItemType; - static readonly wheatSeeds: ItemType; + getAbsoluteTime(): number; /** * @remarks - * Represents an item that can place a white candle within - * Minecraft. + * Returns an array of all active players within the world. * + * @throws This function can throw errors. */ - static readonly whiteCandle: ItemType; - static readonly whiteCarpet: ItemType; - static readonly whiteDye: ItemType; + getAllPlayers(): Player[]; /** * @remarks - * Represents an item that can place a block of white glazed - * terracotta within Minecraft. + * 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. */ - static readonly whiteGlazedTerracotta: ItemType; - static readonly whiteWool: ItemType; - static readonly witchSpawnEgg: ItemType; + getDay(): number; /** * @remarks - * Represents an item that can place a wither rose within - * Minecraft. + * 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. */ - static readonly witherRose: ItemType; - static readonly witherSkeletonSpawnEgg: ItemType; - static readonly witherSpawnEgg: ItemType; - static readonly wolfSpawnEgg: ItemType; + getDefaultSpawnLocation(): Vector3; /** * @remarks - * Represents an item that can place a block of wood within - * Minecraft. + * 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 */ - static readonly wood: ItemType; - static readonly woodenAxe: ItemType; + getDimension(dimensionId: string): Dimension; /** * @remarks - * Represents an item that can place a wooden button within - * Minecraft. + * 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 incrementDynamicProperty.ts + * ```typescript + * import * as mc from '@minecraft/server'; + * + * function incrementProperty(propertyName: string): boolean { + * let number = mc.world.getDynamicProperty(propertyName); + * + * console.warn('Current value is: ' + number); + * + * if (number === undefined) { + * number = 0; + * } * + * if (typeof number !== 'number') { + * console.warn('Number is of an unexpected type.'); + * return false; + * } + * + * mc.world.setDynamicProperty(propertyName, number + 1); + * return true; + * } + * + * incrementProperty('samplelibrary:number'); + * ``` + * @example incrementDynamicPropertyInJsonBlob.ts + * ```typescript + * import * as mc from '@minecraft/server'; + * + * function updateWorldProperty(propertyName: string): boolean { + * let paintStr = mc.world.getDynamicProperty(propertyName); + * let paint: { color: string; intensity: number } | undefined = undefined; + * + * console.log('Current value is: ' + paintStr); + * + * if (paintStr === undefined) { + * paint = { + * color: 'purple', + * intensity: 0, + * }; + * } else { + * if (typeof paintStr !== 'string') { + * console.warn('Paint is of an unexpected type.'); + * return false; + * } + * + * try { + * paint = JSON.parse(paintStr); + * } catch (e) { + * console.warn('Error parsing serialized struct.'); + * return false; + * } + * } + * + * if (!paint) { + * console.warn('Error parsing serialized struct.'); + * return false; + * } + * + * paint.intensity++; + * paintStr = JSON.stringify(paint); // be very careful to ensure your serialized JSON str cannot exceed limits + * mc.world.setDynamicProperty(propertyName, paintStr); + * + * return true; + * } + * + * updateWorldProperty('samplelibrary:longerjson'); + * ``` */ - static readonly woodenButton: ItemType; + getDynamicProperty(identifier: string): boolean | number | string | Vector3 | undefined; /** * @remarks - * Represents an item that can place a wooden door within - * Minecraft. + * Gets a set of dynamic property identifiers that have been + * set in this world. * + * @returns + * A string array of active dynamic property identifiers. */ - static readonly woodenDoor: ItemType; - static readonly woodenHoe: ItemType; - static readonly woodenPickaxe: ItemType; + getDynamicPropertyIds(): string[]; /** * @remarks - * Represents an item that can place a wooden pressure plate - * within Minecraft. + * Gets the total byte count of dynamic properties. This could + * potentially be used for your own analytics to ensure you're + * not storing gigantic sets of dynamic properties. * */ - static readonly woodenPressurePlate: ItemType; - static readonly woodenShovel: ItemType; + getDynamicPropertyTotalByteCount(): number; /** * @remarks - * Represents an item that can place a wooden slab within - * Minecraft. + * 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. */ - static readonly woodenSlab: ItemType; - static readonly woodenSword: ItemType; + getEntity(id: string): Entity | undefined; /** * @remarks - * Represents wool within Minecraft. + * Returns the MoonPhase for the current time. * */ - static readonly wool: ItemType; - static readonly writableBook: ItemType; + getMoonPhase(): MoonPhase; /** * @remarks - * Represents an item that can place a yellow candle within - * Minecraft. + * 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. */ - static readonly yellowCandle: ItemType; - static readonly yellowCarpet: ItemType; - static readonly yellowDye: ItemType; + getPlayers(options?: EntityQueryOptions): Player[]; /** * @remarks - * Represents an item that can place a yellow flower within - * Minecraft. + * Returns the time of day. * + * @returns + * The time of day, in ticks, between 0 and 24000. */ - static readonly yellowFlower: ItemType; + getTimeOfDay(): number; /** * @remarks - * Represents an item that can place a yellow block of glazed - * terracotta within Minecraft. + * 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 + * import { world, MusicOptions, WorldSoundOptions, PlayerSoundOptions, Vector3 } from '@minecraft/server'; + * + * const players = world.getPlayers(); + * const targetLocation: Vector3 = { + * x: 0, + * y: 0, + * z: 0, + * }; + * + * const musicOptions: MusicOptions = { + * fade: 0.5, + * loop: true, + * volume: 1.0, + * }; + * world.playMusic('music.menu', musicOptions); + * + * const worldSoundOptions: WorldSoundOptions = { + * pitch: 0.5, + * volume: 4.0, + * }; + * world.playSound('ambient.weather.thunder', targetLocation, worldSoundOptions); + * + * const playerSoundOptions: PlayerSoundOptions = { + * pitch: 1.0, + * volume: 1.0, + * }; + * + * players[0].playSound('bucket.fill_water', playerSoundOptions); + * ``` */ - static readonly yellowGlazedTerracotta: ItemType; - static readonly yellowWool: ItemType; - static readonly zoglinSpawnEgg: ItemType; - static readonly zombieHorseSpawnEgg: ItemType; - static readonly zombiePigmanSpawnEgg: ItemType; - static readonly zombieSpawnEgg: ItemType; - static readonly zombieVillagerSpawnEgg: ItemType; -} -/** - * @beta - * Contains a set of additional variable values for further - * defining how rendering and animations function. - */ -export class MolangVariableMap { + playMusic(trackId: string, musicOptions?: MusicOptions): 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] + * 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 + * import { world, MusicOptions, WorldSoundOptions, PlayerSoundOptions, Vector3 } from '@minecraft/server'; + * + * const players = world.getPlayers(); + * const targetLocation: Vector3 = { + * x: 0, + * y: 0, + * z: 0, + * }; + * + * const musicOptions: MusicOptions = { + * fade: 0.5, + * loop: true, + * volume: 1.0, + * }; + * world.playMusic('music.menu', musicOptions); + * + * const worldSoundOptions: WorldSoundOptions = { + * pitch: 0.5, + * volume: 4.0, + * }; + * world.playSound('ambient.weather.thunder', targetLocation, worldSoundOptions); + * + * const playerSoundOptions: PlayerSoundOptions = { + * pitch: 1.0, + * volume: 1.0, + * }; + * + * players[0].playSound('bucket.fill_water', playerSoundOptions); + * ``` */ - setColorRGB(variableName: string, color: Color): MolangVariableMap; + playSound(soundId: string, location: Vector3, soundOptions?: WorldSoundOptions): 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] + * 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 trackId + * Identifier of the music track to play. + * @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. * */ - setColorRGBA(variableName: string, color: Color): MolangVariableMap; + queueMusic(trackId: string, musicOptions?: MusicOptions): 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 + * 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 + * import { world } from '@minecraft/server'; + * + * // Displays "Apple or Coal" + * const rawMessage = { + * translate: 'accessibility.list.or.two', + * with: { rawtext: [{ translate: 'item.apple.name' }, { translate: 'item.coal.name' }] }, + * }; + * world.sendMessage(rawMessage); + * ``` + * @example scoreWildcard.ts + * ```typescript + * import { world } from '@minecraft/server'; * + * // 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 + * import { world } from '@minecraft/server'; + * + * // Displays "Hello, world!" + * world.sendMessage('Hello, world!'); + * ``` + * @example translation.ts + * ```typescript + * import { world } from '@minecraft/server'; + * + * // Displays "First or Second" + * const rawMessage = { translate: 'accessibility.list.or.two', with: ['First', 'Second'] }; + * world.sendMessage(rawMessage); + * ``` */ - setSpeedAndDirection(variableName: string, speed: number, direction: Vector3): MolangVariableMap; + sendMessage(message: (RawMessage | string)[] | RawMessage | string): 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 + * Sets the world time. + * + * This function can't be called in read-only mode. * + * @param absoluteTime + * The world time, in ticks. */ - setVector3(variableName: string, vector: Vector3): MolangVariableMap; -} -/** - * @beta - * Contains data resulting from a navigation operation, - * including whether the navigation is possible and the path of - * navigation. - */ -export class NavigationResult { - protected constructor(); + setAbsoluteTime(absoluteTime: number): void; /** * @remarks - * Whether the navigation result contains a full path, - * including to the requested destination. + * 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} */ - readonly isFullPath: boolean; + setDefaultSpawnLocation(spawnLocation: Vector3): void; /** * @remarks - * A set of block locations that comprise the navigation route. + * Sets a specified property to a value. + * + * @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 incrementDynamicProperty.ts + * ```typescript + * import * as mc from '@minecraft/server'; + * + * function incrementProperty(propertyName: string): boolean { + * let number = mc.world.getDynamicProperty(propertyName); + * + * console.warn('Current value is: ' + number); + * + * if (number === undefined) { + * number = 0; + * } + * + * if (typeof number !== 'number') { + * console.warn('Number is of an unexpected type.'); + * return false; + * } + * + * mc.world.setDynamicProperty(propertyName, number + 1); + * return true; + * } * + * incrementProperty('samplelibrary:number'); + * ``` + * @example incrementDynamicPropertyInJsonBlob.ts + * ```typescript + * import * as mc from '@minecraft/server'; + * + * function updateWorldProperty(propertyName: string): boolean { + * let paintStr = mc.world.getDynamicProperty(propertyName); + * let paint: { color: string; intensity: number } | undefined = undefined; + * + * console.log('Current value is: ' + paintStr); + * + * if (paintStr === undefined) { + * paint = { + * color: 'purple', + * intensity: 0, + * }; + * } else { + * if (typeof paintStr !== 'string') { + * console.warn('Paint is of an unexpected type.'); + * return false; + * } + * + * try { + * paint = JSON.parse(paintStr); + * } catch (e) { + * console.warn('Error parsing serialized struct.'); + * return false; + * } + * } + * + * if (!paint) { + * console.warn('Error parsing serialized struct.'); + * return false; + * } + * + * paint.intensity++; + * paintStr = JSON.stringify(paint); // be very careful to ensure your serialized JSON str cannot exceed limits + * mc.world.setDynamicProperty(propertyName, paintStr); + * + * return true; + * } + * + * updateWorldProperty('samplelibrary:longerjson'); + * ``` */ - getPath(): Vector3[]; -} -/** - * @beta - * Contains information related to changes to a piston - * expanding or retracting. - */ -export class PistonActivateAfterEvent extends BlockEvent { - protected constructor(); + setDynamicProperty(identifier: string, value?: boolean | number | string | Vector3): void; /** * @remarks - * True if the piston is the process of expanding. + * 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. */ - readonly isExpanding: boolean; + setTimeOfDay(timeOfDay: number | TimeOfDay): void; /** * @remarks - * Contains additional properties and details of the piston. + * Stops any music tracks from playing. + * + * This function can't be called in read-only mode. * */ - readonly piston: BlockPistonComponent; -} -/** - * @beta - * Manages callbacks that are connected to piston activations. - */ -export class PistonActivateAfterEventSignal_deprecated extends IPistonActivateAfterEventSignal { - protected constructor(); + stopMusic(): void; } + /** - * @beta - * Contains information related to changes before a piston - * expands or retracts. + * Contains a set of events that are available across the scope + * of the World. */ -export class PistonActivateBeforeEvent extends BlockEvent { - protected constructor(); +export class WorldAfterEvents { + private constructor(); /** + * @beta * @remarks - * If this is set to true within an event handler, the piston - * activation is canceled. + * This event fires for each BlockLocation destroyed by an + * explosion. It is fired after the blocks have already been + * destroyed. * */ - cancel: boolean; + readonly blockExplode: BlockExplodeAfterEventSignal; /** * @remarks - * True if the piston is the process of expanding. + * This event fires when a button is pushed. * */ - readonly isExpanding: boolean; + readonly buttonPush: ButtonPushAfterEventSignal; /** + * @beta * @remarks - * Contains additional properties and details of the piston. + * This event is triggered after a chat message has been + * broadcast or sent to players. * */ - readonly piston: BlockPistonComponent; -} -/** - * @beta - * Manages callbacks that are connected to an event that fires - * before a piston is activated. - */ -export class PistonActivateBeforeEventSignal extends IPistonActivateBeforeEventSignal { - protected constructor(); -} -/** - * Represents a player within the world. - */ -export class Player extends Entity { - protected constructor(); + readonly chatSend: ChatSendAfterEventSignal; /** - * @beta * @remarks - * The current overall level for the player, based on their - * experience. + * This event is fired when an entity event has been triggered + * that will update the component definition state of an + * entity. * - * @throws This property can throw when used. */ - readonly level: number; + readonly dataDrivenEntityTrigger: DataDrivenEntityTriggerAfterEventSignal; /** * @remarks - * Name of the player. + * This event fires when an effect, like poisoning, is added to + * an entity. * - * @throws This property can throw when used. */ - readonly name: string; + readonly effectAdd: EffectAddAfterEventSignal; /** - * @beta * @remarks - * Contains methods for manipulating the on-screen display of a - * Player. + * This event fires when an entity dies. * */ - readonly onScreenDisplay: ScreenDisplay; + readonly entityDie: EntityDieAfterEventSignal; /** - * @beta * @remarks - * Manages the selected slot in the player's hotbar. - * - * This property can't be edited in read-only mode. + * This event fires when entity health changes in any degree. * */ - selectedSlot: number; + readonly entityHealthChanged: EntityHealthChangedAfterEventSignal; /** - * @beta * @remarks - * If this player has an individual spawn point set, returns - * the dimension that their spawn point is within. + * This event fires when an entity hits (that is, melee + * attacks) a block. * - * @throws This property can throw when used. */ - readonly spawnDimension?: Dimension; + readonly entityHitBlock: EntityHitBlockAfterEventSignal; /** - * @beta * @remarks - * The overall total set of experience needed to achieve the - * next level for a player. + * This event fires when an entity hits (that is, melee + * attacks) another entity. * - * @throws This property can throw when used. */ - readonly totalXpNeededForNextLevel: number; + readonly entityHitEntity: EntityHitEntityAfterEventSignal; /** - * @beta * @remarks - * The current set of experience achieved for the player. + * This event fires when an entity is hurt (takes damage). * - * @throws This property can throw when used. */ - readonly xpEarnedAtCurrentLevel: number; + readonly entityHurt: EntityHurtAfterEventSignal; /** - * @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. + * Fires when an entity is loaded. * - * @param amount - * Amount of experience to add. Note that this can be negative. - * @returns - * Returns the current experience of the Player. - * @throws This function can throw errors. */ - addExperience(amount: number): number; + readonly entityLoad: EntityLoadAfterEventSignal; /** - * @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. + * Fires when an entity is removed (for example, potentially + * unloaded, or removed after being killed). * - * @param amount - * Amount to add to the player. - * @returns - * Returns the current level of the Player. - * @throws This function can throw errors. */ - addLevels(amount: number): number; + readonly entityRemove: EntityRemoveAfterEventSignal; /** - * @beta * @remarks - * Clears the spawn point that has been individually set for a - * player. - * - * This function can't be called in read-only mode. + * This event fires when an entity is spawned. * - * @throws This function can throw errors. */ - clearSpawn(): void; + readonly entitySpawn: EntitySpawnAfterEventSignal; /** - * @beta * @remarks - * Gets the current item cooldown time for a particular - * cooldown category. + * This event is fired after an explosion occurs. * - * @param itemCategory - * Specifies the cooldown category to retrieve the current - * cooldown for. - * @throws This function can throw errors. */ - getItemCooldown(itemCategory: string): number; + readonly explosion: ExplosionAfterEventSignal; /** * @beta * @remarks - * Returns an individualized spawn position, if set, for a - * player. + * This event fires when a world.gameRules property has + * changed. * - * @returns - * The individual spawn position, or undefined if there is no - * specific spawn position set for a player. - * @throws This function can throw errors. */ - getSpawnPosition(): Vector3 | undefined; + readonly gameRuleChange: GameRuleChangeAfterEventSignal; /** - * @beta * @remarks - * Gets the total experience of the Player. + * This event fires when a chargeable item completes charging. * - * @throws This function can throw errors. */ - getTotalXp(): number; + readonly itemCompleteUse: ItemCompleteUseAfterEventSignal; /** - * @beta * @remarks - * Returns true if this player has operator-level permissions. + * This event fires when a chargeable item is released from + * charging. * - * @throws This function can throw errors. */ - isOp(): boolean; + readonly itemReleaseUse: ItemReleaseUseAfterEventSignal; /** - * @beta * @remarks - * Plays a sound that only this particular player can hear. - * - * This function can't be called in read-only mode. + * This event fires when a chargeable item starts charging. * - * @param soundID - * Identifier of the sound to play. - * @param soundOptions - * Additional optional options for the sound. - * @throws This function can throw errors. */ - playSound(soundID: string, soundOptions?: PlayerSoundOptions): void; + readonly itemStartUse: ItemStartUseAfterEventSignal; /** - * @beta * @remarks - * This is an internal-facing method for posting a system - * message to downstream clients. + * 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. * - * This function can't be called in read-only mode. - * - * @throws This function can throw errors. */ - postClientMessage(id: string, value: string): void; + readonly itemStartUseOn: ItemStartUseOnAfterEventSignal; /** - * @beta * @remarks - * Resets the level of the player. - * - * This function can't be called in read-only mode. + * This event fires when a chargeable item stops charging. * - * @throws This function can throw errors. */ - resetLevel(): void; + readonly itemStopUse: ItemStopUseAfterEventSignal; /** - * @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 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); + * 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. * - * ``` */ - sendMessage(message: (RawMessage | string)[] | RawMessage | string): void; + readonly itemStopUseOn: ItemStopUseOnAfterEventSignal; /** - * @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. + * This event fires when an item is successfully used by a + * player. * - * @throws This function can throw errors. */ - setOp(isOp: boolean): void; + readonly itemUse: ItemUseAfterEventSignal; /** - * @beta * @remarks - * Sets the individual spawn point of this player. + * This event fires when an item is used on a block by a + * player. * - * This function can't be called in read-only mode. + */ + readonly itemUseOn: ItemUseOnAfterEventSignal; + /** + * @remarks + * A lever has been pulled. * - * @param spawnPosition - * Location of the spawn point. - * @param spawnDimension - * Dimension to place the players' individualized spawn point - * within. - * @returns - * Returns undefined/void. - * @throws This function can throw errors. */ - setSpawn(spawnPosition: Vector3, spawnDimension: Dimension): void; + readonly leverAction: LeverActionAfterEventSignal; /** * @beta * @remarks - * Sets the item cooldown time for a particular cooldown - * category. - * - * This function can't be called in read-only mode. + * This event is an internal implementation detail, and is + * otherwise not currently functional. * - * @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 - * 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 { - protected constructor(); + */ + readonly messageReceive: ServerMessageAfterEventSignal; /** * @remarks - * This function can't be called in read-only mode. + * This event fires when a piston expands or retracts. * */ - [Symbol.iterator](): Iterator; + readonly pistonActivate: PistonActivateAfterEventSignal; /** * @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 event fires for a block that is broken by a player. * - * This function can't be called in read-only mode. + */ + readonly playerBreakBlock: PlayerBreakBlockAfterEventSignal; + /** + * @remarks + * Fires when a player moved to a different dimension. * */ - 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 { - protected constructor(); + readonly playerDimensionChange: PlayerDimensionChangeAfterEventSignal; + /** + * @beta + */ + readonly playerGameModeChange: PlayerGameModeChangeAfterEventSignal; /** + * @beta * @remarks - * Opaque string identifier of the player that joined the game. + * This event fires when a players input permissions change. * */ - readonly playerId: string; + readonly playerInputPermissionCategoryChange: PlayerInputPermissionCategoryChangeAfterEventSignal; /** + * @beta * @remarks - * Name of the player that has joined. + * An event for when a player interacts with a block. * */ - readonly playerName: string; -} -/** - * @beta - * Manages callbacks that are connected to a player joining the - * world. - */ -export class PlayerJoinAfterEventSignal_deprecated extends IPlayerJoinAfterEventSignal { - protected constructor(); -} -/** - * @beta - * Contains information regarding a player that has left the - * world. - */ -export class PlayerLeaveAfterEvent { - protected constructor(); + readonly playerInteractWithBlock: PlayerInteractWithBlockAfterEventSignal; /** + * @beta * @remarks - * Opaque string identifier of the player that has left the - * event. + * This event fires when a player interacts with an entity. * */ - readonly playerId: string; + readonly playerInteractWithEntity: PlayerInteractWithEntityAfterEventSignal; /** * @remarks - * Player that has left the world. + * 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 playerName: string; -} -/** - * @beta - * Manages callbacks that are connected to a player leaving the - * world. - */ -export class PlayerLeaveAfterEventSignal_deprecated extends IPlayerLeaveAfterEventSignal { - protected constructor(); -} -/** - * @beta - * An event that contains more information about a player - * spawning. - */ -export class PlayerSpawnAfterEvent { - protected constructor(); + readonly playerJoin: PlayerJoinAfterEventSignal; /** * @remarks - * If true, this is the initial spawn of a player after joining - * the game. + * This event fires when a player leaves a world. * - * This property can't be edited in read-only mode. + */ + readonly playerLeave: PlayerLeaveAfterEventSignal; + /** + * @remarks + * This event fires for a block that is placed by a player. * */ - initialSpawn: boolean; + readonly playerPlaceBlock: PlayerPlaceBlockAfterEventSignal; /** * @remarks - * Object that represents the player that joined the game. + * 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. * - * This property can't be edited in read-only mode. + */ + readonly playerSpawn: PlayerSpawnAfterEventSignal; + /** + * @remarks + * A pressure plate has popped back up (i.e., there are no + * entities on the pressure plate.) * */ - player: Player; -} -/** - * @beta - * Registers an event when a player is spawned (or re-spawned - * after death) and fully ready within the world. - */ -export class PlayerSpawnAfterEventSignal_deprecated extends IPlayerSpawnAfterEventSignal { - protected constructor(); -} -/** - * @beta - * Contains information related to a projectile hitting an - * entity or block. - */ -export class ProjectileHitAfterEvent { - protected constructor(); + readonly pressurePlatePop: PressurePlatePopAfterEventSignal; /** * @remarks - * Dimension where this projectile hit took place. + * A pressure plate has pushed (at least one entity has moved + * onto a pressure plate.) * */ - readonly dimension: Dimension; + readonly pressurePlatePush: PressurePlatePushAfterEventSignal; /** * @remarks - * Direction vector of the projectile as it hit a block/entity. + * This event fires when a projectile hits a block. * */ - readonly hitVector: Vector3; + readonly projectileHitBlock: ProjectileHitBlockAfterEventSignal; /** * @remarks - * Location where the projectile hit occurred. + * This event fires when a projectile hits an entity. * */ - readonly location: Vector3; + readonly projectileHitEntity: ProjectileHitEntityAfterEventSignal; /** * @remarks - * Entity for the projectile that hit a block/entity. + * A target block was hit. * */ - readonly projectile: Entity; + readonly targetBlockHit: TargetBlockHitAfterEventSignal; /** * @remarks - * Optional source entity that fired the projectile. + * A trip wire was tripped. * */ - readonly source: Entity; + readonly tripWireTrip: TripWireTripAfterEventSignal; /** * @remarks - * This function can't be called in read-only mode. + * This event will be triggered when the weather changes within + * Minecraft. * */ - getBlockHit(): BlockHitInformation | undefined; + readonly weatherChange: WeatherChangeAfterEventSignal; /** * @remarks - * This function can't be called in read-only mode. + * This event fires when the script environment is initialized + * on a World. * */ - getEntityHit(): EntityHitInformation | undefined; -} -/** - * @beta - * Manages callbacks that are connected to when a projectile - * hits an entity or block. - */ -export class ProjectileHitAfterEventSignal_deprecated extends IProjectileHitAfterEventSignal { - protected constructor(); + readonly worldInitialize: WorldInitializeAfterEventSignal; } + /** - * @beta - * Provides methods that should be used within the World - * Initialize event to register dynamic properties that can be - * used and stored within Minecraft. + * 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 PropertyRegistry { - protected constructor(); +export class WorldBeforeEvents { + private constructor(); /** + * @beta * @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. + * This event is triggered after a chat message has been + * broadcast or sent to players. * - * @throws This function can throw errors. */ - registerEntityTypeDynamicProperties( - propertiesDefinition: DynamicPropertiesDefinition, - entityType: EntityType, - ): void; + readonly chatSend: ChatSendBeforeEventSignal; /** * @remarks - * Registers a globally available dynamic property for a world. - * - * This function can't be called in read-only mode. + * This event is triggered after an event has been added to an + * entity. * - * @throws This function can throw errors. */ - registerWorldDynamicProperties(propertiesDefinition: DynamicPropertiesDefinition): void; -} -/** - * @beta - * Contains objectives and participants for the scoreboard. - */ -export class Scoreboard { - protected constructor(); + readonly effectAdd: EffectAddBeforeEventSignal; /** * @remarks - * Adds a new objective to the scoreboard. - * - * This function can't be called in read-only mode. + * Fires before an entity is removed from the world (for + * example, unloaded or removed after being killed.) * - * @throws This function can throw errors. */ - addObjective(objectiveId: string, displayName: string): ScoreboardObjective; + readonly entityRemove: EntityRemoveBeforeEventSignal; /** * @remarks - * Clears the objective that occupies a display slot. + * This event is fired after an explosion occurs. * - * This function can't be called in read-only mode. + */ + readonly explosion: ExplosionBeforeEventSignal; + /** + * @remarks + * This event fires when an item is successfully used by a + * player. * - * @throws This function can throw errors. */ - clearObjectiveAtDisplaySlot(displaySlotId: string): ScoreboardObjective; + readonly itemUse: ItemUseBeforeEventSignal; /** * @remarks - * Returns a specific objective (by id). + * This event fires when an item is used on a block by a + * player. * - * @param objectiveId - * Identifier of the objective. - * @throws This function can throw errors. */ - getObjective(objectiveId: string): ScoreboardObjective; + readonly itemUseOn: ItemUseOnBeforeEventSignal; /** * @remarks - * Returns an objective that occupies the specified display - * slot. + * This event fires before a block is broken by a player. * - * @throws This function can throw errors. */ - getObjectiveAtDisplaySlot(displaySlotId: string): ScoreboardObjectiveDisplayOptions; + readonly playerBreakBlock: PlayerBreakBlockBeforeEventSignal; /** + * @beta + */ + readonly playerGameModeChange: PlayerGameModeChangeBeforeEventSignal; + /** + * @beta * @remarks - * Returns all defined objectives. + * Fires before a player interacts with a block. * - * @throws This function can throw errors. */ - getObjectives(): ScoreboardObjective[]; + readonly playerInteractWithBlock: PlayerInteractWithBlockBeforeEventSignal; /** + * @beta * @remarks - * Returns all defined scoreboard identities. + * Fires before a player interacts with an entity. * - * @throws This function can throw errors. */ - getParticipants(): ScoreboardIdentity[]; + readonly playerInteractWithEntity: PlayerInteractWithEntityBeforeEventSignal; /** * @remarks - * Returns a score given an objective and participant. + * Fires when a player leaves the game. * - * @param objective - * Objective to retrieve the score for. - * @param participant - * Participant to retrieve the score for. - * @returns - * Score value. - * @throws This function can throw errors. */ - getScore(objective: ScoreboardObjective, participant: ScoreboardIdentity): number; + readonly playerLeave: PlayerLeaveBeforeEventSignal; /** + * @beta * @remarks - * Removes an objective from the scoreboard. + * This event fires before a block is placed by a player. * - * This function can't be called in read-only mode. + */ + readonly playerPlaceBlock: PlayerPlaceBlockBeforeEventSignal; + /** + * @beta + */ + readonly weatherChange: WeatherChangeBeforeEventSignal; + /** + * @beta + * @remarks + * This event fires immediately when the script environment is + * initialized on a World. Not all script functionality may be + * available. For guaranteed access to world state, use the + * world initialize after event. * - * @throws This function can throw errors. */ - removeObjective(objectiveId: ScoreboardObjective | string): boolean; + readonly worldInitialize: WorldInitializeBeforeEventSignal; +} + +/** + * Contains information and methods that can be used at the + * initialization of the scripting environment for a World. + */ +export class WorldInitializeAfterEvent { + private constructor(); +} + +/** + * Manages callbacks that are run on the first tick of the + * 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 - * Sets an objective into a display slot with specified - * additional display settings. + * 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. * - * @throws This function can throw errors. */ - setObjectiveAtDisplaySlot( - displaySlotId: string, - objectiveDisplaySetting: ScoreboardObjectiveDisplayOptions, - ): ScoreboardObjective; + subscribe(callback: (arg: WorldInitializeAfterEvent) => void): (arg: WorldInitializeAfterEvent) => void; /** * @remarks - * Sets the score given a participant and objective. + * Removes a callback from being called the scripting + * environment is initialized for a World. * * This function can't be called in read-only mode. * - * @param objective - * Objective to use for the scoreboard. - * @param participant - * Participant to apply the scoreboard value to. - * @throws This function can throw errors. */ - setScore(objective: ScoreboardObjective, participant: ScoreboardIdentity, score: number): boolean; + unsubscribe(callback: (arg: WorldInitializeAfterEvent) => void): void; } + /** * @beta - * Contains an identity of the scoreboard item. + * Contains information and methods that can be used at the + * initialization of the scripting environment for a World. + * Also, use the supplied blockRegistry object to register + * block custom components within the scope of the World + * Initialize execution. */ -export class ScoreboardIdentity { - protected constructor(); +export class WorldInitializeBeforeEvent { + private constructor(); + readonly blockTypeRegistry: BlockComponentRegistry; /** * @remarks - * Returns the player-visible name of this identity. + * Provides the functionality for registering custom components + * for items. * */ - readonly displayName: string; + readonly itemComponentRegistry: ItemComponentRegistry; +} + +/** + * @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 WorldInitializeBeforeEventSignal { + private constructor(); /** * @remarks - * Identifier of the scoreboard identity. + * Adds a callback that will be called when the scripting + * environment is initialized for a World. * - */ - readonly id: number; - /** - * @remarks - * Type of the scoreboard identity. + * This function can't be called in read-only mode. * */ - readonly 'type': ScoreboardIdentityType; + subscribe(callback: (arg: WorldInitializeBeforeEvent) => void): (arg: WorldInitializeBeforeEvent) => void; /** * @remarks - * If the scoreboard identity is an entity or player, returns - * the entity that this scoreboard item corresponds to. + * 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. */ - getEntity(): Entity; + unsubscribe(callback: (arg: WorldInitializeBeforeEvent) => void): void; +} + +/** + * @beta + * Contains additional options for searches for the + * dimension.findNearestBiome API. + */ +export interface BiomeSearchOptions { /** * @remarks - * Gets the current score for this participant based on an - * objective. + * Bounding volume size to look within. * - * @param objective - * The objective to retrieve the score for. - * @returns - * Score value. - * @throws This function can throw errors. */ - getScore(objective: ScoreboardObjective): number; + boundingSize?: Vector3; +} + +/** + * @beta + * Contains a set of events that will be raised for a block. + * This object must be bound using the BlockRegistry. + */ +export interface BlockCustomComponent { /** * @remarks - * Removes this participant from an objective. - * - * This function can't be called in read-only mode. + * This function will be called before a player places the + * block. * - * @param objective - * The objective to remove this participant from. - * @throws This function can throw errors. */ - removeFromObjective(objective: ScoreboardObjective): boolean; + beforeOnPlayerPlace?: (arg: BlockComponentPlayerPlaceBeforeEvent) => void; /** * @remarks - * Sets a score for this participant for a particular - * objective. - * - * This function can't be called in read-only mode. + * This function will be called when an entity falls onto the + * block that this custom component is bound to. * - * @param objective - * Objective to apply the score to. - * @param score - * Score value. - * @throws This function can throw errors. */ - setScore(objective: ScoreboardObjective, score: number): boolean; -} -/** - * @beta - * Contains objectives and participants for the scoreboard. - */ -export class ScoreboardObjective { - protected constructor(); + onEntityFallOn?: (arg: BlockComponentEntityFallOnEvent) => void; /** * @remarks - * Returns the player-visible name of this scoreboard - * objective. + * This function will be called when the block that this custom + * component is bound to is placed. * - * @throws This property can throw when used. */ - readonly displayName: string; + onPlace?: (arg: BlockComponentOnPlaceEvent) => void; /** * @remarks - * Identifier of the scoreboard objective. + * This function will be called when a player destroys a + * specific block. * - * @throws This property can throw when used. */ - readonly id: string; + onPlayerDestroy?: (arg: BlockComponentPlayerDestroyEvent) => void; /** * @remarks - * Returns all objective participant identities. + * This function will be called when a player sucessfully + * interacts with the block that this custom component is bound + * to. * - * @throws This function can throw errors. */ - getParticipants(): ScoreboardIdentity[]; + onPlayerInteract?: (arg: BlockComponentPlayerInteractEvent) => void; /** * @remarks - * Returns a specific score for a participant. + * This function will be called when a block randomly ticks. * - * @param participant - * Identifier of the participant to retrieve a score for. - * @throws This function can throw errors. */ - getScore(participant: ScoreboardIdentity): number; + onRandomTick?: (arg: BlockComponentRandomTickEvent) => void; /** * @remarks - * Returns specific scores for this objective for all - * participants. + * This function will be called when an entity steps off the + * block that this custom component is bound to. * - * @throws This function can throw errors. */ - getScores(): ScoreboardScoreInfo[]; + onStepOff?: (arg: BlockComponentStepOffEvent) => void; /** * @remarks - * Removes a participant from this scoreboard objective. - * - * This function can't be called in read-only mode. + * This function will be called when an entity steps onto the + * block that this custom component is bound to. * - * @param participant - * Participant to remove from being tracked with this - * objective. - * @throws This function can throw errors. */ - removeParticipant(participant: ScoreboardIdentity): boolean; + onStepOn?: (arg: BlockComponentStepOnEvent) => void; /** * @remarks - * Sets a score for a participant. - * - * This function can't be called in read-only mode. + * This function will be called when a block ticks. * - * @param participant - * Identity of the participant. - * @param score - * New value of the score. - * @throws This function can throw errors. */ - setScore(participant: ScoreboardIdentity, score: number): boolean; + onTick?: (arg: BlockComponentTickEvent) => void; } + /** - * @beta - * Contains a pair of a scoreboard participant and its - * respective score. + * Contains optional parameters for registering a block event. */ -export class ScoreboardScoreInfo { - protected constructor(); +export interface BlockEventOptions { /** * @remarks - * This scoreboard participant for this score. + * If this value is set, this event will only fire if the + * impacted block's type matches this parameter. * */ - readonly participant: ScoreboardIdentity; + blockTypes?: string[]; /** * @remarks - * Score value of the identity for this objective. + * If this value is set, this event will only fire if the + * impacted block's permutation matches this parameter. * */ - readonly score: number; + permutations?: BlockPermutation[]; } + /** * @beta - * Contains information about user interface elements that are - * showing up on the screen. + * Contains additional options for a block fill operation. */ -export class ScreenDisplay { - protected constructor(); +export interface BlockFillOptions { + blockFilter?: BlockFilter; + ignoreChunkBoundErrors?: boolean; +} + +export interface BlockFilter { + excludePermutations?: BlockPermutation[]; + excludeTags?: string[]; + excludeTypes?: string[]; + includePermutations?: BlockPermutation[]; + includeTags?: string[]; + includeTypes?: string[]; +} + +/** + * Contains more information for events where a block is hit. + */ +export interface BlockHitInformation { /** * @remarks - * Clears the title and subtitle, if currently displayed. - * - * This function can't be called in read-only mode. + * Block that was hit. * - * @throws This function can throw errors. */ - clearTitle(): void; + block: Block; /** * @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. + * Face of the block that was hit. * - * @throws This function can throw errors. */ - setActionBar(text: string): void; + face: Direction; /** * @remarks - * Will cause a title to show up on the player's on screen - * display. You can optionally specify an additional subtitle - * as well as fade in, stay and fade out times. + * Location relative to the bottom north-west corner of the + * block. * - * This function can't be called in read-only mode. + */ + faceLocation: Vector3; +} + +/** + * Contains information for block raycast hit results. + */ +export interface BlockRaycastHit { + /** + * @remarks + * Block that was hit. * - * @throws This function can throw errors. */ - setTitle(title: string, options?: TitleDisplayOptions): void; + block: Block; /** * @remarks - * Updates the subtitle if the subtitle was previously - * displayed via the setTitle method. + * Face of the block that was hit. * - * This function can't be called in read-only mode. + */ + face: Direction; + /** + * @remarks + * Hit location relative to the bottom north-west corner of the + * block. * - * @throws This function can throw errors. */ - updateSubtitle(subtitle: string): void; + faceLocation: Vector3; } + /** - * @beta - * Returns additional data about a /scriptevent command - * invocation. + * Contains additional options for configuring a block raycast + * query. */ -export class ScriptEventCommandMessageAfterEvent { - protected constructor(); +// @ts-ignore Class inheritance allowed for native defined classes +export interface BlockRaycastOptions extends BlockFilter { /** * @remarks - * Identifier of this ScriptEvent command message. + * If true, liquid blocks will be considered as blocks that + * 'stop' the raycast. * */ - readonly id: string; + includeLiquidBlocks?: boolean; /** * @remarks - * If this command was initiated via an NPC, returns the entity - * that initiated the NPC dialogue. + * If true, passable blocks like vines and flowers will be + * considered as blocks that 'stop' the raycast. * */ - readonly initiator: Entity; + includePassableBlocks?: boolean; /** * @remarks - * Optional additional data passed in with the script event - * command. + * Maximum distance, in blocks, to process the raycast. * */ - readonly message: string; + maxDistance?: number; +} + +/** + * @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 - * Source block if this command was triggered via a block - * (e.g., a commandblock.) + * A {@link @minecraft-server.Vector3} that represents the + * largest corner of the rectangle * */ - readonly sourceBlock: Block; + max: Vector3; /** * @remarks - * Source entity if this command was triggered by an entity - * (e.g., a NPC). + * A {@link @minecraft-server.Vector3} that represents the + * smallest corner of the rectangle * */ - readonly sourceEntity: Entity; + min: Vector3; +} + +export interface CameraDefaultOptions { /** * @remarks - * Returns the type of source that fired this command. + * Sets a set of easing options for the camera. * */ - readonly sourceType: MessageSourceType; + easeOptions: CameraEaseOptions; } + /** - * @beta - * Allows for registering an event handler that responds to - * inbound /scriptevent commands. + * Contains options associated with a camera ease operation. */ -export class ScriptEventCommandMessageAfterEventSignal extends IScriptEventCommandMessageAfterEventSignal { - protected constructor(); +export interface CameraEaseOptions { + /** + * @remarks + * Time for the ease operation. + * + */ + easeTime?: number; + /** + * @remarks + * Type of ease operation to use. + * + */ + easeType?: EasingType; } + /** - * @beta - * Describes a particular seating position on this rideable - * entity. + * Used to initiate a full-screen color fade. */ -export class Seat { - protected constructor(); +export interface CameraFadeOptions { /** * @remarks - * If specified, contains a forced rotation that the riders in - * this seat are facing. + * Fade color to use. * */ - readonly lockRiderRotation: number; + fadeColor?: RGB; /** * @remarks - * A maximum number of riders that this seat can support. + * Time in seconds for the fade-in, hold, and fade-out seconds. * */ - readonly maxRiderCount: number; + fadeTime?: CameraFadeTimeOptions; +} + +/** + * Contains timings for a fade transition. + */ +export interface CameraFadeTimeOptions { /** * @remarks - * A minimum number of riders that can be placed in this seat - * position, if this seat is to be filled. + * Time, in seconds, for a fade-in. * */ - readonly minRiderCount: number; + fadeInTime: number; /** * @remarks - * Physical location of this seat, relative to the entity's - * location. + * Time, in seconds, for a fade-out. * */ - readonly position: Vector3; + fadeOutTime: number; + /** + * @remarks + * Time, in seconds, to hold the full screen color. + * + */ + holdTime: number; } -/** - * @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_deprecated extends IServerMessageAfterEventSignal { - protected constructor(); + +export interface CameraSetFacingOptions { + easeOptions?: CameraEaseOptions; + facingEntity: Entity; + location?: Vector3; } + +export interface CameraSetLocationOptions { + easeOptions?: CameraEaseOptions; + location: Vector3; +} + +export interface CameraSetPosOptions { + easeOptions?: CameraEaseOptions; + facingLocation: Vector3; + location?: Vector3; +} + +export interface CameraSetRotOptions { + easeOptions?: CameraEaseOptions; + location?: Vector3; + rotation: Vector2; +} + /** * @beta + * This interface defines an entry into the {@link + * @minecraft-server/CompoundBlockVolume} which represents a + * volume of positive or negative space. + * */ -export class StartChargeAfterEventSignal_deprecated extends IItemStartChargeAfterEventSignal { - protected constructor(); +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; } + /** - * A class that provides system-level events and functions. + * Contains a set of updates to the component definition state + * of an entity. */ -export class System { - protected constructor(); +export interface DefinitionModifier { /** - * @beta * @remarks - * Represents the current world tick of the server. + * Retrieves the list of component groups that will be added + * via this definition modification. * */ - readonly currentTick: number; + addedComponentGroups: string[]; /** - * @beta * @remarks - * Contains a set of events that are applicable for the - * lifecycle of items in the Minecraft system. + * The list of component groups that will be removed via this + * definition modification. * */ - readonly events: SystemEvents; + removedComponentGroups: string[]; /** * @beta * @remarks - * Cancels the execution of a function run that was previously - * scheduled via the `run` function. + * The list of entity definition events that will be fired via + * this update. * */ - clearRun(runId: number): void; + triggers: Trigger[]; +} + +/** + * An exact coordinate within the world, including its + * dimension and location. + */ +export interface DimensionLocation { /** * @remarks - * Runs a specified function at a future time. This is - * frequently used to implement delayed behaviors and game - * loops. + * Dimension that this coordinate is associated with. * - * @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. */ - run(callback: () => void): number; + dimension: Dimension; /** - * @beta * @remarks - * Runs a set of code on an interval. + * X component of this dimension-location. * - * @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. */ - runInterval(callback: () => void, tickInterval?: number): number; + x: number; /** - * @beta * @remarks - * Runs a set of code at a future time specified by tickDelay. + * Y component of this dimension-location. * - * @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; + y: number; + /** + * @remarks + * Z component of this dimension-location. + * + */ + z: number; } + /** * @beta - * Contains a set of events that are available across the scope - * of the Minecraft add-on system. + * This interface represents a specific leveled enchantment + * that is applied to an item. */ -export class SystemEvents { - protected constructor(); +export interface Enchantment { /** * @remarks - * This event fires before a the performance watchdog - * terminates scripting execution due to exceeding a - * performance boundary. Depending on the configuration of the - * runtime environment, this event can be canceled. For - * example, on certain dedicated server environments the - * ability to override termination events may be disabled. + * The level of this enchantment instance. * */ - readonly beforeWatchdogTerminate: WatchdogTerminateBeforeEventSignal; + level: number; /** * @remarks - * This event fires if a /scriptevent command is invoked by a - * player, NPC, or block. + * The enchantment type of this instance. * */ - readonly scriptEventReceive: ScriptEventCommandMessageAfterEventSignal; + type: EnchantmentType; } + /** - * @beta - * Represents a trigger for firing an event. + * Additional options for when damage has been applied via a + * projectile. */ -export class Trigger { +export interface EntityApplyDamageByProjectileOptions { /** * @remarks - * Event name of the trigger. + * Optional entity that fired the projectile. * */ - eventName: string; + damagingEntity?: Entity; /** * @remarks - * Creates a new trigger. + * Projectile that caused damage. * */ - constructor(eventName: string); + damagingProjectile: Entity; } + /** - * @beta - * Contains a description of a vector. + * Additional descriptions and metadata for a damage event. */ -export class Vector { +export interface EntityApplyDamageOptions { /** * @remarks - * X component of this vector. + * Underlying cause of the damage. * */ - x: number; + cause: EntityDamageCause; /** * @remarks - * Y component of this vector. + * Optional entity that caused the damage. * */ - y: number; + damagingEntity?: Entity; +} + +/** + * Provides information about how damage has been applied to an + * entity. + */ +export interface EntityDamageSource { /** * @remarks - * Z component of this vector. + * Cause enumeration of damage. * */ - z: number; + cause: EntityDamageCause; /** * @remarks - * A constant vector that represents (0, 0, -1). + * Optional entity that caused the damage. * */ - static readonly back: Vector; + damagingEntity?: Entity; /** * @remarks - * A constant vector that represents (0, -1, 0). + * Optional projectile that may have caused damage. * */ - static readonly down: Vector; + damagingProjectile?: Entity; +} + +/** + * Specifies additional filters that are used in registering a + * data driven trigger event for entities. + */ +export interface EntityDataDrivenTriggerEventOptions { /** * @remarks - * A constant vector that represents (0, 0, 1). + * If this value is set, this event will only fire for entities + * that match the entities within this collection. * */ - static readonly forward: Vector; + entities?: Entity[]; /** * @remarks - * A constant vector that represents (-1, 0, 0). + * If this value is set, this event will only fire if the + * impacted entities' type matches this parameter. * */ - static readonly left: Vector; + entityTypes?: string[]; /** * @remarks - * A constant vector that represents (1, 1, 1). + * If this value is set, this event will only fire if the + * impacted triggered event matches one of the events listed in + * this parameter. * */ - static readonly one: Vector; + eventTypes?: string[]; +} + +/** + * Contains additional options for entity effects. + */ +export interface EntityEffectOptions { /** * @remarks - * A constant vector that represents (1, 0, 0). + * The strength of the effect. * */ - static readonly right: Vector; + amplifier?: number; /** * @remarks - * A constant vector that represents (0, 1, 0). + * If true, will show particles when effect is on the entity. * */ - static readonly up: Vector; + showParticles?: boolean; +} + +/** + * Contains optional parameters for registering an entity + * event. + */ +export interface EntityEventOptions { /** * @remarks - * A constant vector that represents (0, 0, 0). + * If this value is set, this event will only fire for entities + * that match the entities within this collection. * */ - static readonly zero: Vector; + entities?: Entity[]; /** * @remarks - * Creates a new instance of an abstract vector. + * If this value is set, this event will only fire if the + * impacted entities' type matches this parameter. * - * @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); + entityTypes?: string[]; +} + +/** + * Contains options for filtering entities. + */ +export interface EntityFilter { /** * @remarks - * Compares this vector and another vector to one another. + * Excludes entities that match one or more of the specified + * families. * - * @param other - * Other vector to compare this vector to. - * @returns - * True if the two vectors are equal. */ - equals(other: Vector): boolean; + excludeFamilies?: string[]; /** * @remarks - * Returns the length of this vector. + * Excludes entities if have a specific gamemode that matches + * the specified gamemode. * */ - length(): number; + excludeGameModes?: GameMode[]; /** * @remarks - * Returns the squared length of this vector. + * Excludes entities that have a name that match one of the + * specified values. * */ - lengthSquared(): number; + excludeNames?: string[]; /** * @remarks - * Returns this vector as a normalized vector. + * Excludes entities with a tag that matches one of the + * specified values. * */ - normalized(): Vector; + excludeTags?: string[]; /** * @remarks - * Returns the addition of these vectors. + * Excludes entities if they are one of the specified types. * */ - static add(a: Vector3, b: Vector3): Vector; + excludeTypes?: string[]; /** * @remarks - * Returns the cross product of these two vectors. + * If specified, includes entities that match all of the + * specified families. * */ - static cross(a: Vector3, b: Vector3): Vector; + families?: string[]; /** * @remarks - * Returns the distance between two vectors. + * If specified, includes entities with a gamemode that matches + * the specified gamemode. * */ - static distance(a: Vector3, b: Vector3): number; + gameMode?: GameMode; /** * @remarks - * Returns the component-wise division of these vectors. + * If specified, will only include entities that have at most + * this horizontal rotation. * */ - static divide(a: Vector3, b: number | Vector3): Vector; + maxHorizontalRotation?: number; /** * @remarks - * Returns the linear interpolation between a and b using t as - * the control. + * If defined, only players that have at most this level are + * returned. * */ - static lerp(a: Vector3, b: Vector3, t: number): Vector; + maxLevel?: number; /** * @remarks - * Returns a vector that is made from the largest components of - * two vectors. + * If specified, only entities that have at most this vertical + * rotation are returned. * */ - static max(a: Vector3, b: Vector3): Vector; + maxVerticalRotation?: number; /** * @remarks - * Returns a vector that is made from the smallest components - * of two vectors. + * If specified, will only include entities that have at a + * minimum this horizontal rotation. * */ - static min(a: Vector3, b: Vector3): Vector; + minHorizontalRotation?: number; /** * @remarks - * Returns the component-wise product of these vectors. + * If defined, only players that have at least this level are + * returned. * */ - static multiply(a: Vector3, b: number | Vector3): Vector; + minLevel?: number; /** * @remarks - * Returns the spherical linear interpolation between a and b - * using s as the control. + * If specified, will only include entities that have at least + * this vertical rotation. * */ - static slerp(a: Vector3, b: Vector3, s: number): Vector; + minVerticalRotation?: number; /** * @remarks - * Returns the subtraction of these vectors. + * Includes entities with the specified name. * */ - static subtract(a: Vector3, b: Vector3): Vector; -} -/** - * @beta - * Contains information related to a script watchdog - * termination. - */ -export class WatchdogTerminateBeforeEvent { - protected constructor(); + name?: string; /** - * @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. - * + * @beta */ - cancel: boolean; + propertyOptions?: EntityQueryPropertyOptions[]; /** * @remarks - * Contains the reason why a script runtime is to be - * terminated. + * Gets/sets a collection of EntityQueryScoreOptions objects + * with filters for specific scoreboard objectives. * */ - 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 extends IWatchdogTerminateBeforeEventSignal { - protected constructor(); -} -/** - * @beta - * Contains information related to changes in weather in the - * environment. - */ -export class WeatherChangeAfterEvent { - protected constructor(); + scoreOptions?: EntityQueryScoreOptions[]; /** * @remarks - * Dimension in which the weather has changed. + * Includes entities that match all of the specified tags. * */ - readonly dimension: string; + tags?: string[]; /** * @remarks - * Whether it is lightning after the change in weather. + * If defined, entities that match this type are included. * */ - readonly lightning: boolean; + type?: string; +} + +/** + * Contains additional information about an entity that was + * hit. + */ +export interface EntityHitInformation { /** * @remarks - * Whether it is raining after the change in weather. + * Entity that was hit. * */ - readonly raining: boolean; -} -/** - * @beta - * Manages callbacks that are connected to weather changing. - */ -export class WeatherChangeAfterEventSignal_deprecated extends IWeatherChangeAfterEventSignal { - protected constructor(); + entity?: Entity; } + /** - * A class that wraps the state of a world - a set of - * dimensions and the environment of Minecraft. + * Contains options for selecting entities within an area. + * @example testBlockConditional.ts + * ```typescript + * import { Dimension } from '@minecraft/server'; + * + * // Having this command: + * + * // execute as @e[type=fox] positioned as @s if block ^ ^-1 ^ stone run summon salmon + * + * // Equivalent scripting code would be: + * function spawnFish(dimension: Dimension) { + * dimension + * .getEntities({ + * type: 'fox', + * }) + * .filter(entity => { + * const block = dimension.getBlock({ + * x: entity.location.x, + * y: entity.location.y - 1, + * z: entity.location.z, + * }); + * + * return block !== undefined && block.matches('minecraft:stone'); + * }) + * .forEach(entity => { + * dimension.spawnEntity('salmon', entity.location); + * }); + * } + * ``` + * @example testPlaySoundChained.ts + * ```typescript + * import { Dimension } from '@minecraft/server'; + * + * // Having this command: + * + * // execute as @e[type=armor_stand,name=myArmorStand,tag=dummyTag1,tag=!dummyTag2] run playsound raid.horn @a + * + * // Equivalent scripting code would be: + * function playSounds(dimension: Dimension) { + * const targetPlayers = dimension.getPlayers(); + * const originEntities = dimension.getEntities({ + * type: 'armor_stand', + * name: 'myArmorStand', + * tags: ['dummyTag1'], + * excludeTags: ['dummyTag2'], + * }); + * + * originEntities.forEach(entity => { + * targetPlayers.forEach(player => { + * player.playSound('raid.horn'); + * }); + * }); + * } + * ``` + * @example testPropertyOptionsWithEqualsComparison.ts + * ```typescript + * import { world, EntityQueryOptions } from '@minecraft/server'; + * + * // Having this command: + * + * // execute as @e[has_property={propId=propValue}] + * + * // Equivalent scripting code would be: + * function findEntitiesHavingPropertyEqualsTo(propId: string, propValue: boolean | number | string) { + * const queryOption: EntityQueryOptions = { + * propertyOptions: [{ propertyId: propId, value: { equals: propValue } }] + * }; + * + * const overworld = world.getDimension('overworld'); + * const entities = overworld.getEntities(queryOption); + * } + * ``` + * @example testPropertyOptionsWithGreaterThanComparison.ts + * ```typescript + * import { world, EntityQueryOptions } from '@minecraft/server'; + * + * // No equivalent commands as `propValue..` is inclusive in commands + * + * function findEntitiesHavingPropertyGreaterThan(propId: string, propValue: number) { + * const queryOption: EntityQueryOptions = { + * propertyOptions: [{ propertyId: propId, value: { greaterThan: propValue } }] + * }; + * + * const overworld = world.getDimension('overworld'); + * const entities = overworld.getEntities(queryOption); + * } + * ``` + * @example testPropertyOptionsWithGreaterThanOrEqualsComparison.ts + * ```typescript + * import { world, EntityQueryOptions } from '@minecraft/server'; + * + * // Having this command: + * + * // execute as @e[has_property={propId=propValue..}] + * + * // Equivalent scripting code would be: + * function findEntitiesHavingPropertyGreaterThanOrEqualsTo(propId: string, propValue: number) { + * const queryOption: EntityQueryOptions = { + * propertyOptions: [{ propertyId: propId, value: { greaterThanOrEquals: propValue } }] + * }; + * + * const overworld = world.getDimension('overworld'); + * const entities = overworld.getEntities(queryOption); + * } + * ``` + * @example testPropertyOptionsWithHavingAProperty.ts + * ```typescript + * import { world, EntityQueryOptions } from '@minecraft/server'; + * + * // Having this command: + * + * // execute as @e[has_property={property=propId}] + * + * // Equivalent scripting code would be: + * function findEntitiesHavingAProperty(propId: string) { + * const queryOption: EntityQueryOptions = { + * propertyOptions: [{ propertyId: propId }] + * }; + * + * const overworld = world.getDimension('overworld'); + * const entities = overworld.getEntities(queryOption); + * } + * ``` + * @example testPropertyOptionsWithLessThanComparison.ts + * ```typescript + * import { world, EntityQueryOptions } from '@minecraft/server'; + * + * // No equivalent commands as `..propValue` is inclusive in commands + * + * function findEntitiesHavingPropertyLessThan(propId: string, propValue: number) { + * const queryOption: EntityQueryOptions = { + * propertyOptions: [{ propertyId: propId, value: { lessThan: propValue } }] + * }; + * + * const overworld = world.getDimension('overworld'); + * const entities = overworld.getEntities(queryOption); + * } + * ``` + * @example testPropertyOptionsWithLessThanOrEqualsComparison.ts + * ```typescript + * import { world, EntityQueryOptions } from '@minecraft/server'; + * + * // Having this command: + * + * // execute as @e[has_property={propId=..propValue}] + * + * // Equivalent scripting code would be: + * function findEntitiesHavingPropertyLessThanOrEqualsTo(propId: string, propValue: number) { + * const queryOption: EntityQueryOptions = { + * propertyOptions: [{ propertyId: propId, value: { lessThanOrEquals: propValue } }] + * }; + * + * const overworld = world.getDimension('overworld'); + * const entities = overworld.getEntities(queryOption); + * } + * ``` + * @example testPropertyOptionsWithNotEqualsComparison.ts + * ```typescript + * import { world, EntityQueryOptions } from '@minecraft/server'; + * + * // Having this command: + * + * // execute as @e[has_property={propId=!propValue}] + * + * // Equivalent scripting code would be: + * function findEntitiesHavingPropertyNotEqualsTo(propId: string, propValue: boolean | number | string) { + * const queryOption: EntityQueryOptions = { + * propertyOptions: [{ propertyId: propId, value: { notEquals: propValue } }] + * }; + * + * const overworld = world.getDimension('overworld'); + * const entities = overworld.getEntities(queryOption); + * } + * ``` + * @example testPropertyOptionsWithNotHavingAProperty.ts + * ```typescript + * import { world, EntityQueryOptions } from '@minecraft/server'; + * + * // Having this command: + * + * // execute as @e[has_property={property=!propId}] + * + * // Equivalent scripting code would be: + * function findEntitiesNotHavingAProperty(propId: string) { + * const queryOption: EntityQueryOptions = { + * propertyOptions: [{ propertyId: propId, exclude: true }] + * }; + * + * const overworld = world.getDimension('overworld'); + * const entities = overworld.getEntities(queryOption); + * } + * ``` + * @example testPropertyOptionsWithRangeComparison.ts + * ```typescript + * import { world, EntityQueryOptions } from '@minecraft/server'; + * + * // Having this command: + * + * // execute as @e[has_property={propId=lowerBoundValue..upperBoundValue}] + * + * // Equivalent scripting code would be: + * function findEntitiesHavingPropertyWithinRange(propId: string, lowerBoundValue: number, upperBoundValue: number) { + * const queryOption: EntityQueryOptions = { + * propertyOptions: [{ propertyId: propId, value: { lowerBound: lowerBoundValue, upperBound: upperBoundValue } }] + * }; + * + * const overworld = world.getDimension('overworld'); + * const entities = overworld.getEntities(queryOption); + * } + * ``` + * @example testSendMessageAllPlayers.ts + * ```typescript + * import { Dimension } from '@minecraft/server'; + * + * // Having this command: + * + * // execute as @e[type=armor_stand,name=myArmorStand,tag=dummyTag1,tag=!dummyTag2] run tellraw @a { "rawtext": [{"translate": "hello.world" }] } + * + * // Equivalent scripting code would be: + * function sendMessagesToPlayers(dimension: Dimension) { + * const targetPlayers = dimension.getPlayers(); + * const originEntities = dimension.getEntities({ + * type: 'armor_stand', + * name: 'myArmorStand', + * tags: ['dummyTag1'], + * excludeTags: ['dummyTag2'], + * }); + * + * originEntities.forEach(entity => { + * targetPlayers.forEach(player => { + * player.sendMessage({ rawtext: [{ translate: 'hello.world' }] }); + * }); + * }); + * } + * ``` + * @example testSetScoreBoardChained.ts + * ```typescript + * import { Dimension, world } from '@minecraft/server'; + * + * // Having these commands: + * + * // scoreboard objectives add scoreObjective1 dummy + * // scoreboard players set @e[type=armor_stand,name=myArmorStand] scoreObjective1 -1 + * + * // Equivalent scripting code would be: + * function setScores(dimension: Dimension) { + * const objective = world.scoreboard.addObjective('scoreObjective1', 'dummy'); + * dimension + * .getEntities({ + * type: 'armor_stand', + * name: 'myArmorStand', + * }) + * .forEach(entity => { + * if (entity.scoreboardIdentity !== undefined) { + * objective.setScore(entity.scoreboardIdentity, -1); + * } + * }); + * } + * ``` + * @example testSummonMobChained.ts + * ```typescript + * import { Dimension } from '@minecraft/server'; + * + * // Having this command: + * + * // execute as @e[type=armor_stand] run execute as @a[x=0,y=-60,z=0,c=4,r=15] run summon pig ~1 ~ ~ + * + * // Equivalent scripting code would be: + * function spawnPigs(dimension: Dimension) { + * const armorStandArray = dimension.getEntities({ + * type: 'armor_stand', + * }); + * const playerArray = dimension.getPlayers({ + * location: { x: 0, y: -60, z: 0 }, + * closest: 4, + * maxDistance: 15, + * }); + * armorStandArray.forEach(entity => { + * playerArray.forEach(player => { + * dimension.spawnEntity('pig', { + * x: player.location.x + 1, + * y: player.location.y, + * z: player.location.z, + * }); + * }); + * }); + * } + * ``` */ -export class World { - protected constructor(); +// @ts-ignore Class inheritance allowed for native defined classes +export interface EntityQueryOptions extends EntityFilter { /** - * @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. + * 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. * */ - readonly beforeEvents: BeforeEvents; + closest?: number; /** - * @beta * @remarks - * Contains a set of events that are applicable to the entirety - * of the world. + * 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. * */ - readonly events: Events; + farthest?: number; /** - * @beta * @remarks - * Returns the general global scoreboard that applies to the - * world. + * Adds a seed location to the query that is used in + * conjunction with closest, farthest, limit, volume, and + * distance properties. * */ - readonly scoreboard: Scoreboard; + location?: Vector3; /** - * @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. + * If specified, includes entities that are less than this + * distance away from the location specified in the location + * property. * */ - broadcastClientMessage(id: string, value: string): void; + maxDistance?: number; /** - * @beta * @remarks - * Returns the absolute time since the start of the world. + * If specified, includes entities that are least this distance + * away from the location specified in the location property. * */ - getAbsoluteTime(): number; + minDistance?: number; /** + * @beta * @remarks - * Returns an array of all active players within the world. + * In conjunction with location, specified a cuboid volume of + * entities to include. * - * @throws This function can throw errors. */ - getAllPlayers(): Player[]; + volume?: Vector3; +} + +/** + * @beta + */ +export interface EntityQueryPropertyOptions { + exclude?: boolean; + propertyId: string; + value?: + | boolean + | string + | EqualsComparison + | GreaterThanComparison + | GreaterThanOrEqualsComparison + | LessThanComparison + | LessThanOrEqualsComparison + | NotEqualsComparison + | RangeComparison; +} + +/** + * Contains additional options for filtering players based on + * their score for an objective. + */ +export interface EntityQueryScoreOptions { /** - * @beta * @remarks - * Returns the default spawn position within the world where - * players are spawned if they don't have a specific spawn - * position set. + * If set to true, entities and players within this score range + * are excluded from query results. * - * @returns - * Returns the default spawn position. */ - getDefaultSpawnPosition(): Vector3; + exclude?: boolean; /** * @remarks - * Returns a dimension object. + * If defined, only players that have a score equal to or under + * maxScore are included. * - * @returns - * The requested dimension - * @throws - * Throws if the given dimension name is invalid */ - getDimension(dimensionId: string): Dimension; + maxScore?: number; /** - * @beta * @remarks - * Returns a property value. + * If defined, only players that have a score equal to or over + * minScore are included. * - * @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 | undefined; + minScore?: number; /** - * @beta * @remarks - * Returns an entity based on the provided id. + * Identifier of the scoreboard objective to filter on. * - * @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; + objective?: string; +} + +/** + * Contains information for entity raycast hit results. + */ +export interface EntityRaycastHit { /** - * @beta * @remarks - * Returns a set of players based on a set of conditions - * defined via the EntityQueryOptions set of filter criteria. + * Distance from ray origin to entity bounds. * - * @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[]; + distance: number; /** - * @beta * @remarks - * Sets the current game time of the day. + * Entity that was hit. * */ - getTime(): number; + entity: Entity; +} + +/** + * Contains additional options for an entity raycast operation. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export interface EntityRaycastOptions extends EntityFilter { /** * @beta * @remarks - * Plays a particular music track for all players. - * - * This function can't be called in read-only mode. + * If true, blocks will not be considered as blocks that 'stop' + * the raycast. * - * @throws This function can throw errors. */ - playMusic(trackID: string, musicOptions?: MusicOptions): void; + ignoreBlockCollision?: boolean; /** * @beta * @remarks - * Plays a sound for all players. - * - * This function can't be called in read-only mode. + * If true, liquid blocks will be considered as blocks that + * 'stop' the raycast. * - * @throws This function can throw errors. */ - playSound(soundID: string, location: Vector3, soundOptions?: WorldSoundOptions): void; + includeLiquidBlocks?: boolean; /** * @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. + * If true, passable blocks like vines and flowers will be + * considered as blocks that 'stop' the raycast. * - * @throws This function can throw errors. */ - queueMusic(trackID: string, musicOptions?: MusicOptions): void; + includePassableBlocks?: boolean; /** - * @beta * @remarks - * Removes a specified property. - * - * This function can't be called in read-only mode. + * Maximum distance, in blocks, to process the raycast. * - * @throws This function can throw errors. */ - removeDynamicProperty(identifier: string): boolean; + maxDistance?: number; +} + +/** + * @beta + * Equal to operator. + */ +export interface EqualsComparison { /** - * @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); + * Threshold value compared against. * - * ``` */ - sendMessage(message: (RawMessage | string)[] | RawMessage | string): void; + equals: boolean | number | string; +} + +/** + * Additional configuration options for the {@link + * Dimension.createExplosion} method. + * @example createExplosions.ts + * ```typescript + * // Creates an explosion of radius 15 that does not break blocks + * import { DimensionLocation } from '@minecraft/server'; + * + * function createExplosions(location: DimensionLocation) { + * // Creates an explosion of radius 15 that does not break blocks + * location.dimension.createExplosion(location, 15, { breaksBlocks: false }); + * + * // Creates an explosion of radius 15 that does not cause fire + * location.dimension.createExplosion(location, 15, { causesFire: true }); + * + * // Creates an explosion of radius 10 that can go underwater + * location.dimension.createExplosion(location, 10, { allowUnderwater: true }); + * } + * ``` + */ +export interface ExplosionOptions { /** - * @beta * @remarks - * Sets the default spawn location for players within the - * world. Note that players can override this with their own - * spawn position. Note also that the default spawn position - * must be in the overworld dimension. - * - * This function can't be called in read-only mode. + * Whether parts of the explosion also impact underwater. * - * @param spawnPosition - * Location within the overworld where a player will spawn. - * @throws This function can throw errors. */ - setDefaultSpawn(spawnPosition: Vector3): void; + allowUnderwater?: boolean; /** - * @beta * @remarks - * Sets a specified property to a value. - * - * This function can't be called in read-only mode. + * Whether the explosion will break blocks within the blast + * radius. * - * @param value - * Data value of the property to set. - * @throws This function can throw errors. */ - setDynamicProperty(identifier: string, value: boolean | number | string): void; + breaksBlocks?: boolean; /** - * @beta * @remarks - * Returns the current game time of the day. - * - * This function can't be called in read-only mode. + * If true, the explosion is accompanied by fires within or + * near the blast radius. * */ - setTime(timeOfDay: number): void; + causesFire?: boolean; /** - * @beta * @remarks - * Stops any music tracks from playing. - * - * This function can't be called in read-only mode. + * Optional source of the explosion. * */ - stopMusic(): void; + source?: Entity; } + /** * @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. + * Greater than operator. */ -export class WorldInitializeAfterEvent { - protected constructor(); +export interface GreaterThanComparison { /** * @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, MinecraftEntityTypes, world } from "@minecraft/server"; - * - * world.events.worldInitialize.subscribe((e) => { - * let def = new DynamicPropertiesDefinition(); - * - * def.defineNumber("rpgStrength"); - * def.defineString("rpgRole", 16); - * def.defineBoolean("rpgIsHero"); - * - * e.propertyRegistry.registerEntityTypeDynamicProperties(def, MinecraftEntityTypes.skeleton); - * }); + * Threshold value compared against. * - * ``` */ - readonly propertyRegistry: PropertyRegistry; -} -/** - * @beta - */ -export class WorldInitializeAfterEventSignal_deprecated extends IWorldInitializeAfterEventSignal { - protected constructor(); + greaterThan: number; } + /** * @beta + * Greater than or equal to operator. */ -export interface BlockFillOptions { - matchingBlock?: BlockPermutation; +export interface GreaterThanOrEqualsComparison { + /** + * @remarks + * Threshold value compared against. + * + */ + greaterThanOrEquals: number; } + /** * @beta - * Contains more information for events where a block is hit. + * Contains a set of events that will be raised for an item. + * This object must be bound using the ItemComponentRegistry. */ -export interface BlockHitInformation { +export interface ItemCustomComponent { + onBeforeDurabilityDamage?: (arg: ItemComponentBeforeDurabilityDamageEvent) => void; + onCompleteUse?: (arg: ItemComponentCompleteUseEvent) => void; + onConsume?: (arg: ItemComponentConsumeEvent) => void; + onHitEntity?: (arg: ItemComponentHitEntityEvent) => void; /** * @remarks - * Block that was hit. + * This function will be called when an item containing this + * component is used to mine a block. * */ - block: Block; + onMineBlock?: (arg: ItemComponentMineBlockEvent) => void; /** * @remarks - * Face of the block that was hit. + * This function will be called when an item containing this + * component is used by a player. * */ - face: Direction; + onUse?: (arg: ItemComponentUseEvent) => void; + onUseOn?: (arg: ItemComponentUseOnEvent) => void; +} + +/** + * @beta + * Less than operator. + */ +export interface LessThanComparison { /** * @remarks - * Location relative to the bottom north-west corner of the - * block. + * Threshold value compared against. * */ - faceLocation: Vector3; + lessThan: number; } + /** * @beta - * Contains additional options for configuring a block raycast - * query. + * Less than or equal to operator. + */ +export interface LessThanOrEqualsComparison { + /** + * @remarks + * Threshold value compared against. + * + */ + lessThanOrEquals: number; +} + +/** + * Additional configuration options for {@link + * World.playMusic}/{@link World.queueMusic} methods. */ -export interface BlockRaycastOptions { +export interface MusicOptions { /** * @remarks - * If true, liquid blocks will be considered as blocks that - * 'stop' the raycast. + * Specifies a fade overlap for music at the end of play. * */ - includeLiquidBlocks?: boolean; + fade?: number; /** * @remarks - * If true, passable blocks like vines and flowers will be - * considered as blocks that 'stop' the raycast. + * If set to true, this music track will play repeatedly. * */ - includePassableBlocks?: boolean; + loop?: boolean; /** * @remarks - * Maximum distance, in blocks, to process the raycast. + * Relative volume level of the music. * */ - maxDistance?: number; -} -/** - * @beta - */ -export interface BlockVolume { - from: Vector3; - to: Vector3; + volume?: number; } + /** * @beta + * Not equal to operator. */ -export interface BoundingBox { - max: Vector3; - min: Vector3; +export interface NotEqualsComparison { + /** + * @remarks + * Threshold value compared against. + * + */ + notEquals: boolean | number | string; } + /** - * @beta - * Represents a fully customizable color within Minecraft. + * Contains additional options for how an animation is played. */ -export interface Color { +export interface PlayAnimationOptions { /** * @remarks - * Determines a color's alpha (opacity) component. Valid values - * are between 0 (transparent) and 1.0 (opaque). + * Amount of time to fade out after an animation stops. * */ - alpha: number; + blendOutTime?: number; /** * @remarks - * Determines a color's blue component. Valid values are - * between 0 and 1.0. + * Specifies a controller to use that has been defined on the + * entity. * */ - blue: number; + controller?: string; /** * @remarks - * Determines a color's green component. Valid values are - * between 0 and 1.0. + * Specifies the state to transition to. * */ - green: number; + nextState?: string; /** * @remarks - * Determines a color's red component. Valid values are between - * 0 and 1.0. + * A list of players the animation will be visible to. * */ - red: number; -} -/** - * @beta - */ -export interface CompoundBlockVolumeItem { - action: CompoundBlockVolumeAction; - volume: BlockVolume; -} -/** - * @beta - */ -export interface EntityApplyDamageByProjectileOptions { - damagingEntity?: Entity; - damagingProjectile: Entity; -} -/** - * @beta - */ -export interface EntityApplyDamageOptions { - cause: EntityDamageCause; - damagingEntity?: Entity; -} -/** - * @beta - */ -export interface EntityDamageSource { - cause: EntityDamageCause; - damagingEntity?: Entity; - damagingProjectile?: Entity; + players?: string[]; + /** + * @remarks + * Specifies a Molang expression for when this animation should + * complete. + * + */ + stopExpression?: string; } + /** - * @beta - * Specifies additional filters that are used in registering a - * data driven trigger event for entities. + * Additional options for how a sound plays for a player. */ -export interface EntityDataDrivenTriggerEventOptions { +export interface PlayerSoundOptions { /** * @remarks - * If this value is set, this event will only fire for entities - * that match the entities within this collection. + * Location of the sound; if not specified, the sound is played + * near a player. * */ - entities?: Entity[]; + location?: Vector3; /** * @remarks - * If this value is set, this event will only fire if the - * impacted entities' type matches this parameter. + * Optional pitch of the sound. * */ - entityTypes?: string[]; + pitch?: number; /** * @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. + * Optional volume of the sound. * */ - eventTypes?: string[]; + volume?: number; +} + +export interface ProjectileShootOptions { + uncertainty?: number; } + /** * @beta - * Contains optional parameters for registering an entity - * event. + * Operator represents a lower/upper bound structure for + * expressing a potential range of numbers. */ -export interface EntityEventOptions { +export interface RangeComparison { /** * @remarks - * If this value is set, this event will only fire for entities - * that match the entities within this collection. + * Lower bound within a range. * */ - entities?: Entity[]; + lowerBound: number; /** * @remarks - * If this value is set, this event will only fire if the - * impacted entities' type matches this parameter. + * Upper bound within a range. * */ - entityTypes?: string[]; + upperBound: number; } + /** - * @beta - * Contains additional information about an entity that was - * hit. + * Defines a JSON structure that is used for more flexible. + * @example addTranslatedSign.ts + * ```typescript + * import { DimensionLocation, world, BlockPermutation, BlockComponentTypes } from '@minecraft/server'; + * + * function placeTranslatedSign(location: DimensionLocation, text: string) { + * const signBlock = location.dimension.getBlock(location); + * + * if (!signBlock) { + * console.warn('Could not find a block at specified location.'); + * return; + * } + * const signPerm = BlockPermutation.resolve('minecraft:standing_sign', { ground_sign_direction: 8 }); + * signBlock.setPermutation(signPerm); + * + * const signComponent = signBlock.getComponent(BlockComponentTypes.Sign); + * if (signComponent) { + * signComponent.setText({ translate: 'item.skull.player.name', with: [text] }); + * } else { + * console.error('Could not find a sign component on the block.'); + * } + * } + * + * placeTranslatedSign( + * { + * dimension: world.getDimension('overworld'), + * x: 0, + * y: 0, + * z: 0, + * }, + * 'Steve', + * ); + * ``` + * @example showTranslatedMessageForm.ts + * ```typescript + * import { world, Player } from '@minecraft/server'; + * import { MessageFormData, MessageFormResponse } from '@minecraft/server-ui'; + * + * function showMessage(player: Player) { + * const messageForm = new MessageFormData() + * .title({ translate: 'permissions.removeplayer' }) + * .body({ translate: 'accessibility.list.or.two', with: ['Player 1', 'Player 2'] }) + * .button1('Player 1') + * .button2('Player 2'); + * + * messageForm + * .show(player) + * .then((formData: MessageFormResponse) => { + * // player canceled the form, or another dialog was up and open. + * if (formData.canceled || formData.selection === undefined) { + * return; + * } + * + * console.warn(`You selected ${formData.selection === 0 ? 'Player 1' : 'Player 2'}`); + * }) + * .catch((error: Error) => { + * console.warn('Failed to show form: ' + error); + * }); + * }; + * + * showMessage(world.getAllPlayers()[0]); + * ``` */ -export interface EntityHitInformation { +export interface RawMessage { /** * @remarks - * Entity that was hit. + * Provides a raw-text equivalent of the current message. * */ - entity: Entity; -} -/** - * @beta - * Contains options for selecting entities within an area. - */ -export interface EntityQueryOptions { + rawtext?: RawMessage[]; /** * @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. + * Provides a token that will get replaced with the value of a + * score. * */ - closest?: number; + score?: RawMessageScore; /** * @remarks - * Excludes entities that match one or more of the specified - * families. + * Provides a string literal value to use. * */ - excludeFamilies?: string[]; + text?: string; /** * @remarks - * Excludes entities if have a specific gamemode that matches - * the specified gamemode. + * 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. * */ - excludeGameModes?: GameMode[]; + translate?: string; /** * @remarks - * Excludes entities that have a name that match one of the - * specified values. + * Arguments for the translation token. Can be either an array + * of strings or RawMessage containing an array of raw text + * objects. * */ - excludeNames?: string[]; + with?: string[] | RawMessage; +} + +/** + * Provides a description of a score token to use within a raw + * message. + */ +export interface RawMessageScore { /** * @remarks - * Excludes entities with a tag that matches one of the - * specified values. + * Name of the score value to match. * */ - excludeTags?: string[]; + name?: string; /** * @remarks - * Excludes entities if they are one of the specified types. + * Name of the score value to match. * */ - excludeTypes?: string[]; + objective?: string; +} + +/** + * 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 - * If specified, includes entities that match all of the - * specified families. + * A serialization of the current value of an associated sign. * */ - families?: string[]; + rawtext?: RawMessage[]; +} + +/** + * Represents a fully customizable color within Minecraft. + */ +export interface RGB { /** * @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. + * Determines a color's blue component. Valid values are + * between 0 and 1.0. * */ - farthest?: number; + blue: number; /** * @remarks - * If specified, includes entities with a gamemode that matches - * the specified gamemode. + * Determines a color's green component. Valid values are + * between 0 and 1.0. * */ - gameMode?: GameMode; + green: number; /** * @remarks - * Adds a seed location to the query that is used in - * conjunction with closest, farthest, limit, volume, and - * distance properties. + * Determines a color's red component. Valid values are between + * 0 and 1.0. * */ - location?: Vector3; + red: number; +} + +/** + * Represents a fully customizable color within Minecraft. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export interface RGBA extends RGB { /** * @remarks - * If specified, includes entities that are less than this - * distance away from the location specified in the location - * property. + * Determines a color's alpha (opacity) component. Valid values + * are between 0 (transparent) and 1.0 (opaque). * */ - maxDistance?: number; + alpha: 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[]; +} + +/** + * @beta + */ +export interface SpawnEntityOptions { + initialPersistence?: boolean; +} + +/** + * Provides additional options for {@link + * StructureManager.createFromWorld} + */ +export interface StructureCreateOptions { /** * @remarks - * If specified, will only include entities that have at most - * this horizontal rotation. + * Whether blocks should be included in the structure. Defaults + * to true. * */ - maxHorizontalRotation?: number; + includeBlocks?: boolean; /** * @remarks - * If defined, only players that have at most this level are - * returned. + * Whether entities should be included in the structure. + * Defaults to true. * */ - maxLevel?: number; + includeEntities?: boolean; /** * @remarks - * If specified, only entities that have at most this vertical - * rotation are returned. + * How the Structure should be saved. Defaults to + * StructureSaveMode.World. * */ - maxVerticalRotation?: number; + saveMode?: StructureSaveMode; +} + +/** + * Provides additional options for {@link + * StructureManager.place} + */ +export interface StructurePlaceOptions { /** * @remarks - * If specified, includes entities that are least this distance - * away from the location specified in the location property. + * How the Structure should be animated when placed. * */ - minDistance?: number; + animationMode?: StructureAnimationMode; /** * @remarks - * If specified, will only include entities that have at a - * minimum this horizontal rotation. + * How many seconds the animation should take. * */ - minHorizontalRotation?: number; + animationSeconds?: number; /** * @remarks - * If defined, only players that have at least this level are - * returned. + * Whether blocks should be included in the structure. Defaults + * to true. * */ - minLevel?: number; + includeBlocks?: boolean; /** * @remarks - * If specified, will only include entities that have at least - * this vertical rotation. + * Whether entities should be included in the structure. + * Defaults to true. * */ - minVerticalRotation?: number; + includeEntities?: boolean; /** * @remarks - * Includes entities with the specified name. + * What percentage of blocks should be placed. A value of 1 + * will place 100% of the blocks while a value of 0 will place + * none. The blocks are chosen randomly based on the {@link + * StructurePlaceOptions.integritySeed}. * */ - name?: string; + integrity?: number; /** * @remarks - * Gets/sets a collection of EntityQueryScoreOptions objects - * with filters for specific scoreboard objectives. + * Seed that determines which blocks are randomly chosen to be + * placed. Defaults to a random seed. * */ - scoreOptions?: EntityQueryScoreOptions[]; + integritySeed?: string; /** * @remarks - * Includes entities that match all of the specified tags. + * Which axes the Structure should be mirrored on when placed. + * Defaults to StructureMirrorAxis.None. * */ - tags?: string[]; + mirror?: StructureMirrorAxis; /** * @remarks - * If defined, entities that match this type are included. + * How the Structure should be rotated when placed. Defaults to + * AxisAlignedRotation.None. * */ - type?: string; + rotation?: StructureRotation; /** - * @beta * @remarks - * In conjunction with location, specified a cuboid volume of - * entities to include. + * Whether the structure should be waterlogged when placed. + * Defaults to false. If true, blocks will become waterlogged + * when placed in water. * */ - volume?: BlockAreaSize; + waterlogged?: boolean; } + /** - * @beta - * Contains additional options for filtering players based on - * their score for an objective. + * Contains additional options for teleporting an entity. + * @example teleportMovement.ts + * ```typescript + * import { world, system } from '@minecraft/server'; + * + * const overworld = world.getDimension('overworld'); + * const targetLocation = { x: 0, y: 0, z: 0 }; + * + * const pig = overworld.spawnEntity('minecraft:pig', targetLocation); + * + * let inc = 1; + * const runId = system.runInterval(() => { + * pig.teleport( + * { x: targetLocation.x + inc / 4, y: targetLocation.y + inc / 4, z: targetLocation.z + inc / 4 }, + * { + * facingLocation: targetLocation, + * }, + * ); + * + * if (inc > 100) { + * system.clearRun(runId); + * } + * inc++; + * }, 4); + * ``` */ -export interface EntityQueryScoreOptions { +export interface TeleportOptions { /** * @remarks - * If set to true, entities and players within this score range - * are excluded from query results. + * Whether to check whether blocks will block the entity after + * teleport. * */ - exclude?: boolean; + checkForBlocks?: boolean; /** * @remarks - * If defined, only players that have a score equal to or under - * maxScore are included. + * Dimension to potentially move the entity to. If not + * specified, the entity is teleported within the dimension + * that they reside. * */ - maxScore?: number; + dimension?: Dimension; /** * @remarks - * If defined, only players that have a score equal to or over - * minScore are included. + * Location that the entity should be facing after teleport. * */ - minScore?: number; + facingLocation?: Vector3; /** * @remarks - * Identifier of the scoreboard objective to filter on. + * Whether to retain the entities velocity after teleport. * */ - objective?: string; -} -/** - * @beta - * Contains additional options for an entity raycast operation. - */ -export interface EntityRaycastOptions { + keepVelocity?: boolean; /** * @remarks - * Maximum distance, in blocks, to process the raycast. + * Rotation of the entity after teleport. * */ - maxDistance?: number; + rotation?: Vector2; } + /** - * @beta - * Additional configuration options for the {@link - * Dimension.createExplosion} method. + * Contains additional options for displaying a title and + * optional subtitle. */ -export interface ExplosionOptions { +export interface TitleDisplayOptions { /** * @remarks - * Whether parts of the explosion also impact underwater. + * 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. * */ - allowUnderwater?: boolean; + fadeInDuration: number; /** * @remarks - * Whether the explosion will break blocks within the blast - * radius. + * 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. * */ - breaksBlocks?: boolean; + fadeOutDuration: number; /** * @remarks - * If true, the explosion is accompanied by fires within or - * near the blast radius. + * 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. * */ - causesFire?: boolean; + stayDuration: number; /** * @remarks - * Optional source of the explosion. + * Optional subtitle text. * */ - source?: Entity; + subtitle?: (RawMessage | string)[] | RawMessage | string; } + /** - * @beta - * Additional configuration options for {@link - * World.playMusic}/{@link World.queueMusic} methods. + * Represents a two-directional vector. */ -export interface MusicOptions { +export interface Vector2 { /** * @remarks - * Specifies a fade overlap for music at the end of play. + * X component of the two-dimensional vector. * */ - fade?: number; + x: number; /** * @remarks - * If set to true, this music track will play repeatedly. + * Y component of the two-dimensional vector. * */ - loop?: boolean; + y: number; +} + +/** + * Contains a description of a vector. + */ +export interface Vector3 { /** * @remarks - * Relative volume level of the music. + * X component of this vector. * */ - volume?: number; + x: number; + /** + * @remarks + * Y component of this vector. + * + */ + y: number; + /** + * @remarks + * Z component of this vector. + * + */ + z: number; } + /** - * @beta - * Represents a min/max structure for expressing a potential - * range of numbers. + * Contains additional options for a world-level playSound + * occurrence. */ -export interface NumberRange { +export interface WorldSoundOptions { /** * @remarks - * Maximum value within a range. + * Pitch of the sound played at the world level. * */ - max: number; + pitch?: number; /** * @remarks - * Minimum value within a range. + * Relative volume and space by which this sound is heard. * */ - min: number; + volume?: number; } + +// @ts-ignore Class inheritance allowed for native defined classes +export class CommandError extends Error { + private constructor(); +} + /** * @beta */ -export interface PlayAnimationOptions { - blendOutTime?: number; - controller?: string; - nextState?: string; - stopExpression?: string; +// @ts-ignore Class inheritance allowed for native defined classes +export class EnchantmentLevelOutOfBoundsError extends Error { + private constructor(); } + /** * @beta */ -export interface PlayerSoundOptions { - location?: Vector3; - pitch?: number; - volume?: number; +// @ts-ignore Class inheritance allowed for native defined classes +export class EnchantmentTypeNotCompatibleError extends Error { + private constructor(); } + /** * @beta */ -export interface RawMessage { - rawtext?: RawMessage[]; - score?: RawMessageScore; - text?: string; - translate?: string; - with?: string[] | RawMessage; +// @ts-ignore Class inheritance allowed for native defined classes +export class EnchantmentTypeUnknownIdError extends Error { + private constructor(); } + +// @ts-ignore Class inheritance allowed for native defined classes +export class InvalidContainerSlotError extends Error { + private constructor(); +} + /** - * @beta + * Thrown when a Structure is invalid. A structure becomes + * invalid when it is deleted. */ -export interface RawMessageScore { - name?: string; - objective?: string; +// @ts-ignore Class inheritance allowed for native defined classes +export class InvalidStructureError extends Error { + private constructor(); } + /** * @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 + * Thrown when trying to register an item custom component with + * a name that has already been registered. */ -export interface RawText { - rawtext?: RawMessage[]; +// @ts-ignore Class inheritance allowed for native defined classes +export class ItemCustomComponentAlreadyRegisteredError extends Error { + private constructor(); } + /** * @beta - * Contains additional options for how a scoreboard should be - * displayed within its display slot. + * Thrown when trying to register an item custom component with + * an invalid namespace. */ -export interface ScoreboardObjectiveDisplayOptions { - /** - * @remarks - * Objective to be displayed. - * - */ - objective: ScoreboardObjective; - /** - * @remarks - * The sort order to display the objective items within. - * - */ - sortOrder?: ObjectiveSortOrder; +// @ts-ignore Class inheritance allowed for native defined classes +export class ItemCustomComponentNameError extends Error { + private constructor(); } + /** * @beta + * Thrown after using the /reload command when trying to + * register a previously unregistered item custom component. */ -export interface ScriptEventMessageFilterOptions { - namespaces: string[]; +// @ts-ignore Class inheritance allowed for native defined classes +export class ItemCustomComponentReloadNewComponentError extends Error { + private constructor(); } + /** * @beta + * Thrown after using the /reload command when trying to + * register a previously registered item custom component that + * handles a new event. */ -export interface TeleportOptions { - checkForBlocks?: boolean; - dimension?: Dimension; - facingLocation?: Vector3; - keepVelocity?: boolean; - rotation?: Vector2; +// @ts-ignore Class inheritance allowed for native defined classes +export class ItemCustomComponentReloadNewEventError extends Error { + private constructor(); } + /** * @beta - * Contains additional options for displaying a title and - * optional subtitle. + * Thrown after using the /reload command when trying to + * register a previously registered item custom component with + * a newer API version. */ -export interface TitleDisplayOptions { - /** - * @remarks - * Fade-in time for the title and subtitle, in seconds. - * - */ - fadeInSeconds: number; - /** - * @remarks - * Fade-out time for the title and subtitle, in seconds. - * - */ - fadeOutSeconds: number; - /** - * @remarks - * Amount of time for the title and subtitle to stay in place. - * - */ - staySeconds: number; - /** - * @remarks - * Optional subtitle text. - * - */ - subtitle?: string; +// @ts-ignore Class inheritance allowed for native defined classes +export class ItemCustomComponentReloadVersionError extends Error { + private constructor(); } + /** - * @beta + * Thrown when the chunk for provided location or bounding area + * is not loaded. */ -export interface Vector2 { - x: number; - y: number; +// @ts-ignore Class inheritance allowed for native defined classes +export class LocationInUnloadedChunkError extends Error { + private constructor(); } + /** - * @beta - * Contains a description of a vector. + * Thrown when a provided location or bounding area is outside + * the minimum or maximum dimension height. */ -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; +// @ts-ignore Class inheritance allowed for native defined classes +export class LocationOutOfWorldBoundariesError extends Error { + private constructor(); } + /** * @beta */ -export interface WorldSoundOptions { - pitch?: number; - volume?: number; +// @ts-ignore Class inheritance allowed for native defined classes +export class UnloadedChunksError extends Error { + private constructor(); } + /** * @beta */ -export const TicksPerDay = 24000; +export const HudElementsCount = 13; +/** + * @beta + */ +export const HudVisibilityCount = 2; +/** + * @remarks + * Holds the number of MoonPhases + * + */ +export const MoonPhaseCount = 8; /** * @beta + */ +export const TicksPerDay = 24000; +/** * @remarks * How many times the server ticks per second of real time. * diff --git a/static/typedoc/stable/common.d.ts b/static/typedoc/stable/common.d.ts new file mode 100644 index 0000000000..2dec9483a4 --- /dev/null +++ b/static/typedoc/stable/common.d.ts @@ -0,0 +1,97 @@ +// 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 + * + * Manifest Details + * ```json + * { + * "module_name": "@minecraft/common", + * "version": "1.2.0" + * } + * ``` + * + */ +/** + * 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; +} + +/** + * This type of error is thrown when a parameter to a method or + * property is out of expected bounds. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class ArgumentOutOfBoundsError extends Error { + private constructor(); + /** + * @remarks + * Max expected value for the condition. + * + */ + maxValue: number; + /** + * @remarks + * Min expected value for the condition. + * + */ + minValue: number; + /** + * @remarks + * Passed-in value for the argument. + * + */ + value: number; +} + +/** + * Specifies an underlying error in the engine in processing a + * function. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class EngineError extends Error { + private constructor(); +} + +/** + * Specifies that a passed-in argument to a method is not + * correct or allowed. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class InvalidArgumentError extends Error { + private constructor(); + /** + * @remarks + * Index of the argument that is in error. + * + */ + index: number; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export class PropertyOutOfBoundsError extends Error { + private constructor(); + maxValue: number; + minValue: number; + value: number; +} diff --git a/static/typedoc/stable/server-admin.d.ts b/static/typedoc/stable/server-admin.d.ts index c3298c640f..12e132fa91 100644 --- a/static/typedoc/stable/server-admin.d.ts +++ b/static/typedoc/stable/server-admin.d.ts @@ -18,28 +18,59 @@ * ```json * { * "module_name": "@minecraft/server-admin", - * "version": "1.0.0-beta.1.19.70-stable" + * "version": "1.0.0-beta.1.20.80-stable" * } * ``` * */ +import * as minecraftcommon from '@minecraft/common'; /** * 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. + * @example getPlayerProfile.ts + * ```typescript + * import { variables, secrets } from "@minecraft/server-admin"; + * import { http, HttpRequest, HttpRequestMethod, HttpHeader, HttpResponse } from "@minecraft/server-net"; + * + * const serverUrl = variables.get('serverEndpoint'); + * + * function getPlayerProfile(playerId: string): Promise { + * const req = new HttpRequest(serverUrl + 'getPlayerProfile'); + * + * req.body = JSON.stringify({ + * playerId, + * }); + * + * const authTokenSec = secrets.get('authtoken'); + * + * if (!authTokenSec) { + * throw new Error('authtoken secret not defined.'); + * } + * + * req.method = HttpRequestMethod.Post; + * req.headers = [new HttpHeader('Content-Type', 'application/json'), new HttpHeader('auth', authTokenSec)]; + * + * return http.request(req); + * } + * + * getPlayerProfile('dark navi'); + * ``` */ export class ServerSecrets { - protected constructor(); + private constructor(); /** + * @remarks * A list of available, configured server secrets. + * */ readonly names: string[]; /** @@ -48,35 +79,75 @@ export class ServerSecrets { * 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 + * + * This function can't be called in read-only mode. + * */ get(name: string): SecretString | undefined; } + /** * A collection of server variables defined in dedicated server * configuration. + * @example getPlayerProfile.ts + * ```typescript + * import { variables, secrets } from "@minecraft/server-admin"; + * import { http, HttpRequest, HttpRequestMethod, HttpHeader, HttpResponse } from "@minecraft/server-net"; + * + * const serverUrl = variables.get('serverEndpoint'); + * + * function getPlayerProfile(playerId: string): Promise { + * const req = new HttpRequest(serverUrl + 'getPlayerProfile'); + * + * req.body = JSON.stringify({ + * playerId, + * }); + * + * const authTokenSec = secrets.get('authtoken'); + * + * if (!authTokenSec) { + * throw new Error('authtoken secret not defined.'); + * } + * + * req.method = HttpRequestMethod.Post; + * req.headers = [new HttpHeader('Content-Type', 'application/json'), new HttpHeader('auth', authTokenSec)]; + * + * return http.request(req); + * } + * + * getPlayerProfile('dark navi'); + * ``` */ export class ServerVariables { - protected constructor(); + private constructor(); /** + * @remarks * 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 + * + * This function can't be called in read-only mode. + * */ get(name: string): any | undefined; } + /** + * @remarks * A globally available object that returns a list of * dedicated-server configured secrets. + * */ export const secrets: ServerSecrets; /** + * @remarks * A globally available object that returns a list of * dedicated-server configured variables. + * */ export const variables: ServerVariables; diff --git a/static/typedoc/stable/server-editor.d.ts b/static/typedoc/stable/server-editor.d.ts new file mode 100644 index 0000000000..814a941da8 --- /dev/null +++ b/static/typedoc/stable/server-editor.d.ts @@ -0,0 +1,3216 @@ +// 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 + * + * Manifest Details + * ```json + * { + * "module_name": "@minecraft/server-editor", + * "version": "0.1.0-beta.1.20.80-stable" + * } + * ``` + * + */ +import * as minecraftcommon from '@minecraft/common'; +import * as minecraftserver from '@minecraft/server'; +/** + * The types of actions that are supported. This type + * corresponds to the expected arguments passed by the + * onExecute handler of an action. + */ +export declare enum ActionTypes { + MouseRayCastAction = 'MouseRayCastAction', + NoArgsAction = 'NoArgsAction', +} + +export enum BlockPaletteItemType { + Simple = 0, + Probability = 1, +} + +/** + * Predefined top level menus for core editor + */ +export declare enum CoreMenuType { + Edit = 'editor:menu:edit', + Experimental = 'editor:menu:experimental', + Extensions = 'editor:menu:extensions', + File = 'editor:menu:file', + Help = 'editor:menu:help', + View = 'editor:menu:view', + WorldOptions = 'editor:menu:worldOptions', +} + +/** + * An enumeration used by the 3D block cursor {@link Cursor} + */ +export enum CursorControlMode { + /** + * @remarks + * Using Keyboard mode will remove the dependence of the 3D + * block cursor on the player mouse position. The 3D block + * cursor can be positioned using the keyboard (or the Cursor + * move methods on the cursor object) and the position will not + * be reset if the mouse is moved + * + */ + Keyboard = 0, + /** + * @remarks + * The Mouse movement mode will disable keyboard or manual 3D + * block cursor movement and make the 3D block cursor only + * react to player mouse movement + * + */ + Mouse = 1, + /** + * @remarks + * This is generally the default move mode for the 3D block + * cursor. + * The 3D block cursor can be positioned using the keyboard (or + * the Cursor move methods on the cursor object) but the + * position will be reset to the block location under the + * players mouse position if any mouse movement is detected. + * + */ + KeyboardAndMouse = 2, + /** + * @remarks + * When in fixed mode, the 3D block cursor will remain in a + * fixed position directly in front of the players facing + * direction. It cannot be moved without moving the player (or + * adjusting the fixed block distance). + * This mode is useful for addressing block locations in the + * air (put the cursor into fixed mode, and fly the player + * until the desired air block is beneath the cursor, at which + * point it is selectable without being clickable) + * + */ + Fixed = 3, +} + +/** + * Describes how the cursor targets a point on the screen. + */ +export enum CursorTargetMode { + /** + * @remarks + * Target a nearest block. + * + */ + Block = 0, + /** + * @remarks + * Targets the face of a nearest block. + * + */ + Face = 1, +} + +/** + * Type of item that can be added to the property pane + */ +export declare enum EDITOR_PANE_PROPERTY_ITEM_TYPE { + Action = 'editorUI:Action', + BlockPicker = 'editorUI:BlockPicker', + Boolean = 'editorUI:Boolean', + Divider = 'editorUI:Divider', + Dropdown = 'editorUI:Dropdown', + Image = 'editorUI:Image', + Number = 'editorUI:Number', + String = 'editorUI:String', + SubPane = 'editorUI:SubPane', + Text = 'editorUI:Text', + Vec3 = 'editorUI:Vec3', +} + +/** + * Global editor input contexts + */ +export declare enum EditorInputContext { + GlobalEditor = 'global.editor', + GlobalToolMode = 'global.toolMode', + Viewport = 'local.toolMode.viewport', +} + +/** + * Enumeration representing the different modes Editor can be + * in. + */ +export enum EditorMode { + /** + * @remarks + * Mode for single-block editing. + * + */ + Crosshair = 'Crosshair', + /** + * @remarks + * Mode for multi-block editing UI and tools. + * + */ + Tool = 'Tool', +} + +export declare enum EditorStatusBarAlignment { + Right = 0, + Left = 1, +} + +/** + * Enumeration representing identifiers for graphics settings + * properties. + */ +export enum GraphicsSettingsProperty { + /** + * @remarks + * Manages rendering of invisible blocks (e.g., barrier, light, + * structure_void). + * + */ + ShowInvisibleBlocks = 'ShowInvisibleBlocks', +} + +/** + * Input modifier flags to create chorded bindings + */ +export declare enum InputModifier { + Unused = 0, + None = 1, + Alt = 2, + Control = 4, + Shift = 8, + Any = 15, +} + +/** + * Keyboard key + */ +export declare enum KeyboardKey { + BACKSPACE = 8, + TAB = 9, + ENTER = 13, + SHIFT = 16, + CTRL = 17, + ALT = 18, + CAPS_LOCK = 20, + ESCAPE = 27, + SPACE = 32, + PAGE_UP = 33, + PAGE_DOWN = 34, + END = 35, + HOME = 36, + LEFT = 37, + UP = 38, + RIGHT = 39, + DOWN = 40, + PRINT_SCREEN = 44, + INSERT = 45, + DELETE = 46, + KEY_0 = 48, + KEY_1 = 49, + KEY_2 = 50, + KEY_3 = 51, + KEY_4 = 52, + KEY_5 = 53, + KEY_6 = 54, + KEY_7 = 55, + KEY_8 = 56, + KEY_9 = 57, + KEY_A = 65, + KEY_B = 66, + KEY_C = 67, + KEY_D = 68, + KEY_E = 69, + KEY_F = 70, + KEY_G = 71, + KEY_H = 72, + KEY_I = 73, + KEY_J = 74, + KEY_K = 75, + KEY_L = 76, + KEY_M = 77, + KEY_N = 78, + KEY_O = 79, + KEY_P = 80, + KEY_Q = 81, + KEY_R = 82, + KEY_S = 83, + KEY_T = 84, + KEY_U = 85, + KEY_V = 86, + KEY_W = 87, + KEY_X = 88, + KEY_Y = 89, + KEY_Z = 90, + NUMPAD_0 = 96, + NUMPAD_1 = 97, + NUMPAD_2 = 98, + NUMPAD_3 = 99, + NUMPAD_4 = 100, + NUMPAD_5 = 101, + NUMPAD_6 = 102, + NUMPAD_7 = 103, + NUMPAD_8 = 104, + NUMPAD_9 = 105, + NUMPAD_MULTIPLY = 106, + NUMPAD_ADD = 107, + NUMPAD_SEPARATOR = 108, + NUMPAD_SUBTRACT = 109, + NUMPAD_DECIMAL = 110, + NUMPAD_DIVIDE = 111, + F1 = 112, + F2 = 113, + F3 = 114, + F4 = 115, + F5 = 116, + F6 = 117, + F7 = 118, + F8 = 119, + F9 = 120, + F10 = 121, + F11 = 122, + F12 = 123, + COMMA = 188, + PERIOD = 190, + SLASH = 191, + BACK_QUOTE = 192, + BRACKET_OPEN = 219, + BACK_SLASH = 220, + BRACKET_CLOSE = 221, + QUOTE = 222, +} + +/** + * Keyboard Key Actions + */ +export declare enum KeyInputType { + /** + * @remarks + * Button was pressed. + * + */ + Press = 1, + /** + * @remarks + * Button was released. + * + */ + Release = 2, +} + +/** + * Layout directions for property panes. + */ +export declare enum LayoutDirection { + Vertical = 0, + Horizontal = 1, +} + +/** + * Mouse device action categories + */ +export declare enum MouseActionCategory { + /** + * @remarks + * Mouse button was used. + * + */ + Button = 1, + /** + * @remarks + * Mouse wheel was used. + * + */ + Wheel = 2, + /** + * @remarks + * Mouse was dragged. + * + */ + Drag = 3, +} + +/** + * Detailed mouse device actions + */ +export declare enum MouseActionType { + LeftButton = 1, + MiddleButton = 2, + RightButton = 3, + Wheel = 4, +} + +/** + * Input event information about mouse actions + */ +export declare enum MouseInputType { + ButtonDown = 1, + ButtonUp = 2, + WheelIn = 3, + WheelOut = 4, + DragStart = 5, + Drag = 6, + DragEnd = 7, +} + +export enum PlaytestSessionResult { + OK = 0, + InvalidSessionHandle = 1, + SessionInfoNotFound = 2, + TooManyPlayers = 3, + WorldExportFailed = 4, + WorldExportBusy = 5, + UnsupportedScenario = 6, + EditorSystemFailure = 7, + InvalidLevelId = 8, + PlayerNotFound = 9, + ResponseTimeout = 10, + UnspecifiedError = 11, +} + +export enum WidgetGroupSelectionMode { + Multiple = 'Multiple', + None = 'None', + Single = 'Single', +} + +/** + * Defines type information for graphics settings properties. + */ +export type GraphicsSettingsPropertyTypeMap = { + [GraphicsSettingsProperty.ShowInvisibleBlocks]?: boolean; +}; + +/** + * Full set of all possible raw actions + */ +export type Action = NoArgsAction | MouseRayCastAction; + +/** + * All actions have a unique identifier. Identifiers are + * globally unique and often GUIDs + */ +export type ActionID = { + id: string; +}; + +/** + * Callback type when an extension instance is activated for a + * given player. It is expected to return an array of + * disposables that will automatically be cleaned up on + * shutdown. + */ +export type ActivationFunctionType = ( + uiSession: IPlayerUISession, +) => IDisposable[]; + +/** + * The possible variants of a button. + */ +export declare type ButtonVariant = 'secondary' | 'primary' | 'destructive' | 'hero'; + +/** + * A generic handler for an event sink. + */ +export declare type EventHandler = (eventArg: T) => void; + +/** + * A property item which supports bound actions and replacing + * the bound action + */ +export type IActionPropertyItem = IPropertyItem & { + replaceBoundAction(action: RegisteredAction | undefined): void; +}; + +/** + * A property item which supports Dropdown properties + */ +export type IDropdownPropertyItem< + T extends Omit & { + [key in Prop]: number; + }, + Prop extends keyof T & string, +> = IPropertyItem & IDropdownPropertyItemMixIn; + +/** + * The IPlayerUISession represents the editor user interface + * for a given player and given extension. Extensions + * registered with Minecraft are instantiated for each player + * which joins a server, and this interface provides the set of + * functionality needed to create and modify the editor UI for + * that player. The associated Editor Context for this session + * object is also player specific. From a given + * IPlayerUISession object, there is no way to interact with + * the UI of another player, that must be done from global + * extension scope registration and/or data sharing independent + * of the UI object. + */ +export type IPlayerUISession> = { + createStatusBarItem(alignment: EditorStatusBarAlignment, size: number): IStatusBarItem; + createPropertyPane(options: IPropertyPaneOptions): IPropertyPane; + readonly actionManager: ActionManager; + readonly inputManager: IGlobalInputManager; + readonly menuBar: IMenuContainer; + readonly toolRail: IModalToolContainer; + readonly log: IPlayerLogger; + readonly extensionContext: ExtensionContext; + readonly builtInUIManager: BuiltInUIManager; + readonly eventSubscriptionCache: BedrockEventSubscriptionCache; + scratchStorage: PerPlayerStorage | undefined; +}; + +/** + * A property item which supports Vector3 properties + */ +export type IVector3PropertyItem = IPropertyItem & { + updateAxisLimits(limits: { + minX?: number; + maxX?: number; + minY?: number; + maxY?: number; + minZ?: number; + maxZ?: number; + }): void; +}; + +/** + * Modal tool lifecycle event payload + */ +export type ModalToolLifecycleEventPayload = { + isActiveTool: boolean; +}; + +/** + * Input modifier states for mouse actions + */ +export declare type MouseModifiers = { + alt: boolean; + ctrl: boolean; + shift: boolean; +}; + +/** + * Mouse properties that provide additional information from + * client event handling + */ +export declare type MouseProps = { + mouseAction: MouseActionType; + modifiers: MouseModifiers; + inputType: MouseInputType; +}; + +/** + * An action which returns the ray corresponding to a vector + * from the users mouse click in the viewport. + */ +export type MouseRayCastAction = { + actionType: ActionTypes.MouseRayCastAction; + readonly onExecute: (mouseRay: Ray, mouseProps: MouseProps) => void; +}; + +/** + * An action which needs no additional client side arguments on + * execute + */ +export type NoArgsAction = { + actionType: ActionTypes.NoArgsAction; + readonly onExecute: () => void; +}; + +/** + * Callback to execute when a value of a property item is + * updated. + */ +export type OnChangeCallback = ( + obj: T, + property: Prop, + oldValue: object, + newValue: object, +) => void; + +export type PropertyBag = Record; + +/** + * Callback to execute when a visibility of a property pane is + * updated. + */ +export type PropertyPaneVisibilityUpdate = { + isVisible: boolean; +}; + +/** + * Ray representing a direction from a set location. This + * location typically corresponds to the location of a mouse + * click performed on the client. + */ +export type Ray = { + location: minecraftserver.Vector3; + direction: minecraftserver.Vector3; + cursorBlockLocation: minecraftserver.Vector3; + rayHit: boolean; +}; + +/** + * A registered action is an action that has been registered + * with the action manager system and has a unique ID + * representing the action now. An action must be registered + * before it can be used in other systems. + */ +export type RegisteredAction = T & ActionID; + +/** + * Callback type when an extension instance is shutdown for a + * given player. Used for performing any final work or clean up + * that can't be handled automatically via Disposables. + */ +export type ShutdownFunctionType = (uiSession: IPlayerUISession) => void; + +/** + * Full set of all possible keyboard actions + */ +export type SupportedKeyboardActionTypes = RegisteredAction; + +/** + * Full set of all possible mouse actions + */ +export type SupportedMouseActionTypes = RegisteredAction; + +export type UnregisterInputBindingCallback = () => void; + +/** + * A cache for bedrock event subscriptions. Stores off a + * subscription by event key, and upon teardown unregisters all + * subscriptions. + */ +export declare class BedrockEventSubscriptionCache { + /** + * @remarks + * Constructs a new instance of the + * `BedrockEventSubscriptionCache` class + * + */ + constructor(mEvents: minecraftserver.WorldAfterEvents); + /** + * @remarks + * Subcribes to a bedrock event using the key of the desired + * event. When subscribed, the event handler is both returned, + * but also cached internally for unsubscription. This means + * the caller of the subscription does not need to worry about + * unsubscription since the cache will automatically + * unsubscribe handlers on overall teardown. + * + * @param event + * The event on the bedrock APIs to which to subscribe + * @param params + * The parameters to the subscription method for the event. + * Auto complete will display this for you + */ + subscribeToBedrockEvent( + event: T, + ...params: Parameters + ): ReturnType; + /** + * @remarks + * Cleans up the set of internal registrations and + * subscriptions. + * + */ + teardown(): void; +} + +export class BlockPaletteManager { + private constructor(); + /** + * @throws This function can throw errors. + */ + getSelectedBlockType(): minecraftserver.BlockType; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + setSelectedBlockType(block: minecraftserver.BlockType): void; +} + +/** + * A ClipboardItem is a handle to an object which represents a + * set of blocks in a contained bounding area (most likely + * copied from the world) + */ +export class ClipboardItem { + private constructor(); + /** + * @remarks + * Return whether there is any block content in the item + * + * @throws This property can throw when used. + */ + readonly isEmpty: boolean; + /** + * @remarks + * Clear the contents of the item + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + clear(): void; + /** + * @remarks + * Create a {@link @minecraft/server.CompoundBlockVolume} + * container which represents the occupied block volumes within + * the ClipboardItem. + * This function does not perform any write operations, and + * instead returns only a prediction of the volume area which + * would be affected as part of a write operation with a given + * set of write options. + * + * This function can't be called in read-only mode. + * + * @param location + * A world location to which the ClipboardItem may potentially + * be written (nothing is actually written as part of this + * operation) + * @param options + * An optional set of write parameters which govern how the + * ClipboardItem should be potentially applied to the world + * @returns + * A {@link @minecraft/server.CompoundBlockVolume} which + * represents the occupied block volumes within the + * ClipboardItem as they would be written to the world with the + * specified {@link ClipboardWriteOptions} + * @throws This function can throw errors. + */ + getPredictedWriteAsCompoundBlockVolume( + location: minecraftserver.Vector3, + options?: ClipboardWriteOptions, + ): minecraftserver.CompoundBlockVolume; + /** + * @remarks + * Create a {@link Selection} container which represents the + * occupied block volumes within the ClipboardItem. + * This function does not perform any write operations, and + * instead returns only a prediction of the volume area which + * would be affected as part of a write operation with a given + * set of write options. + * + * This function can't be called in read-only mode. + * + * @param location + * A world location to which the ClipboardItem may potentially + * be written (nothing is actually written as part of this + * operation) + * @param options + * An optional set of write parameters which govern how the + * ClipboardItem should be potentially applied to the world + * @returns + * A {@link Selection} which represents the occupied block + * volumes within the ClipboardItem as they would be written to + * the world with the specified {@link ClipboardWriteOptions} + * @throws This function can throw errors. + */ + getPredictedWriteAsSelection(location: minecraftserver.Vector3, options?: ClipboardWriteOptions): Selection; + /** + * @remarks + * Get the bounding size of the ClipboardItem + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + getSize(): minecraftserver.Vector3; + /** + * @remarks + * Copy the contents of the area represented by a {@link + * Selection} volume into the ClipboardItem + * + * This function can't be called in read-only mode. + * + * @param selection + * A volume which represents the area to be copied + * @throws This function can throw errors. + */ + readFromSelection(selection: Selection): void; + /** + * @remarks + * Copy the contents of a rectangular volume into the Clipboard + * Item + * + * This function can't be called in read-only mode. + * + * @param from + * The world location of one corner of a bounding volume + * @param to + * The world location of the opposite corner of a bounding + * volume + * @throws This function can throw errors. + */ + readFromWorld(from: minecraftserver.Vector3, to: minecraftserver.Vector3): void; + /** + * @remarks + * Apply the contents of a ClipboardItem to the world at a + * given location using a set of write options + * + * This function can't be called in read-only mode. + * + * @param location + * The root point of the world location to which the + * ClipboardItem is written (this is modified by the various + * anchor, offset and rotation parameters of the {@link + * ClipboardWriteOptions} + * @param options + * An optional set of write parameters which modify the + * properties of the ClipboardItem as it is applied to the + * world + * @returns + * Success or Failure + * @throws This function can throw errors. + */ + writeToWorld(location: minecraftserver.Vector3, options?: ClipboardWriteOptions): boolean; +} + +/** + * The ClipboardManager (accessible from the {@link + * ExtensionContext}) is responsible for the management of all + * {@link ClipboardItem} objects, and provides the user the + * ability to create new {@link ClipboardItem} objects for use + * within an extension. + * + */ +export class ClipboardManager { + private constructor(); + /** + * @remarks + * The primary {@link ClipboardItem} object is always present + * (even if it's empty) and cannot be deleted. This object + * represents the main ClipboardItem object which is always + * accessible through the UI for cut/paste operations + * + * @throws This property can throw when used. + */ + readonly clipboard: ClipboardItem; + /** + * @remarks + * Create a new {@link ClipboardItem} object + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + create(): ClipboardItem; +} + +/** + * The 3D block cursor is controlled through this read only + * object and provides the Editor some control over the input + * methods, display properties and positioning of the 3D block + * cursor within the world. + * The 3D block cursor is a native object which is constantly + * calculating a screen/mouse -> world raycast, and recording + * the resultant block collision position and facing direction. + * Depending on the properties of the cursor state, this is not + * always true – the cursor can also be manually manipulated by + * keyboard input and moved around independently of mouse + * movement; when the mouse is moved, the block cursor will + * return to the mouse/world ray intersection point. + * The cursor can also be set to either block or face mode; + * block mode represents the block the mouse is pointing at, + * and face mode represents the adjacent block that the mouse + * is pointing at (i.e. the block attached to the face of the + * intersection point). + * In practical use, each tool when activated grabs the current + * cursor state object and stores it. The active tool then + * sets the current state to represent the functionality of the + * tool (color, input mode, etc). When the tool loses focus, + * it restores the cursor state using the stored state object + * that was grabbed during activation. + * The 3D block cursor can also be used to query the current + * block at which the mouse is pointing (or the current block + * to which the cursor has been manually moved by the user) + */ +export class Cursor { + private constructor(); + /** + * @remarks + * The face at of the block beneath the 3D block cursor which + * is intersected by the mouse raycast + * + * @throws This property can throw when used. + */ + readonly faceDirection: number; + /** + * @remarks + * Query whether or not the 3D block cursor is visible or + * hidden + * + * @throws This property can throw when used. + */ + readonly isVisible: boolean; + /** + * @remarks + * Get the world position of the 3D block cursor + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + getPosition(): minecraftserver.Vector3; + /** + * @remarks + * Get a property object which represents the current + * properties of the 3D block cursor. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + getProperties(): CursorProperties; + /** + * @remarks + * Hide the 3D block cursor from view until the corresponding + * {@link @minecraft-server-editor.Cursor.show} function is + * called + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + hide(): void; + /** + * @remarks + * Manually offset the 3D block cursor by given amount. + * Depending on the {@link + * @minecraft-server-editor.CursorProperties.CursorControlMode} + * - this function may have no effect + * + * This function can't be called in read-only mode. + * + * @param offset + * Amount by which the 3D block cursor should be moved + * @returns + * Return the newly modified position (or previous position if + * movement was restricted) + * @throws This function can throw errors. + */ + moveBy(offset: minecraftserver.Vector3): minecraftserver.Vector3; + /** + * @remarks + * Reset the 3D block cursor to the system default state + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + resetToDefaultState(): void; + /** + * @remarks + * Set the 3D block cursor properties to a given state + * + * This function can't be called in read-only mode. + * + * @param properties + * A set of optional parameters within a property state which + * represent the intended 3D block cursor state + * @throws This function can throw errors. + */ + setProperties(properties: CursorProperties): void; + /** + * @remarks + * Make the 3D block cursor visible on screen + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + show(): void; +} + +export class CursorPropertiesChangeAfterEvent { + private constructor(); + readonly properties: CursorProperties; +} + +export class CursorPropertyChangeAfterEventSignal { + private constructor(); + /** + * @remarks + * This function can't be called in read-only mode. + * + */ + subscribe( + callback: (arg: CursorPropertiesChangeAfterEvent) => void, + ): (arg: CursorPropertiesChangeAfterEvent) => void; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + unsubscribe(callback: (arg: CursorPropertiesChangeAfterEvent) => void): void; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export class CustomWidget extends Widget { + private constructor(); + readonly location: minecraftserver.Vector3; + readonly rotation: minecraftserver.Vector2; + readonly showTextOnlyWhenSelected: boolean; + getText(): string; + /** + * @remarks + * This function can't be called in read-only mode. + * + */ + setText(text: string): void; +} + +export class CustomWidgetMoveEventData { + private constructor(); + readonly group: WidgetGroup; + readonly location?: minecraftserver.Vector3; + readonly rotation?: minecraftserver.Vector2; + readonly widget: CustomWidget; +} + +/** + * Editor Extensions are the basis for all player specific, + * editor specific functionality within the game. Almost all + * editor functionality is exported and available within the + * context of an {@link ExtensionContext} + * When the script manager initializes during level loading, + * the scripts are loaded from the behavior packs and executed. + * As part of the global execution context, the scripts are + * free to register any number of extensions. + * An Editor Extension is defined a name, an activation + * function and a shutdown function. + * + * It is not recommended to directly use this function as the + * contract is not guaranteed to be stable, instead prefer + * {@link registerEditorExtension} as it provides additional + * functionality and a stable contract. + */ +export class Extension { + private constructor(); + /** + * @remarks + * Default identifier for tool rail grouping. All modal tools + * created from the extension will use this. + * + */ + readonly defaultToolGroupId: string; + /** + * @remarks + * Description specified during registration for the extension. + * + */ + readonly description: string; + /** + * @remarks + * Name of the extension. + * + */ + readonly name: string; + /** + * @remarks + * Notes specified during registration for the extension. + * + */ + readonly notes: string; +} + +/** + * The extension context is a native (C++) object created for + * each registered Editor Extension, when a player connection + * is established with the server. + * A registered extension activation or deactivation closure is + * accompanied by an [ExtensionContext] object, which provides + * a player specific, editor extension specific context. + * The Extension Context is the main interface to all the bound + * Editor Services. + * As more player services are added to the editor, they will + * be exposed through this object + */ +export class ExtensionContext { + private constructor(); + /** + * @remarks + * Contains a set of events that are applicable to the editor + * player. Event callbacks are called in a deferred manner. + * Event callbacks are executed in read-write mode. + * + */ + readonly afterEvents: ExtensionContextAfterEvents; + readonly blockPalette: BlockPaletteManager; + /** + * @remarks + * This is used to access the players Clipboard Manager and the + * main interface through which the player can create, modify + * and apply clipboard items + * + */ + readonly clipboardManager: ClipboardManager; + /** + * @remarks + * This is used to access the players 3D block cursor and it's + * properties + * + */ + readonly cursor: Cursor; + /** + * @remarks + * Contains information about the registered extension + * instance. + * + */ + readonly extensionInfo: Extension; + /** + * @remarks + * The current player which is the subject of the extension + * invocation + * + */ + readonly player: minecraftserver.Player; + readonly playtest: PlaytestManager; + /** + * @remarks + * The instance of the players Selection Manager and the main + * interface through which the player can create/modify + * selections + * + */ + readonly selectionManager: SelectionManager; + /** + * @remarks + * The instance of the players Settings Manager and the + * contract through which the settings for the player can be + * modified. + * + */ + readonly settings: SettingsManager; + /** + * @remarks + * The instance of the players Transaction Manager and the main + * interface through which the creator can create transaction + * records, and undo/redo previous transactions + * + */ + readonly transactionManager: TransactionManager; + readonly widgetManager: WidgetManager; +} + +/** + * Contains a set of events that are available across the scope + * of the ExtensionContext. + */ +export class ExtensionContextAfterEvents { + private constructor(); + readonly cursorPropertyChange: CursorPropertyChangeAfterEventSignal; + /** + * @remarks + * This event triggers when the editor mode changes for the + * player. + * + */ + readonly modeChange: ModeChangeAfterEventSignal; + readonly primarySelectionChange: PrimarySelectionChangeAfterEventSignal; +} + +/** + * Settings category that manages {@link + * GraphicsSettingsProperty} configurations. + */ +export class GraphicsSettings { + private constructor(); + /** + * @remarks + * Retrieves a graphics settings property value. + * + * @param property + * Property identifier. + * @returns + * Returns the property value if it is found. If the property + * is not available, it returns undefined. + */ + get(property: T): GraphicsSettingsPropertyTypeMap[T] | undefined; + /** + * @remarks + * Retrieves all graphics settings properties and their values. + * + * @returns + * Returns a property value map for all available properties. + */ + getAll(): GraphicsSettingsPropertyTypeMap; + /** + * @remarks + * Modifies a graphics settings property value. + * + * @param property + * Property identifier. + * @param value + * New property value. + * @throws This function can throw errors. + */ + set(property: T, value: GraphicsSettingsPropertyTypeMap[T]): void; + /** + * @remarks + * Modify multiple graphics settings properties. + * + * @param properties + * Property map to set available property values. If the + * property is not defined in the map, it will not be modified. + * @throws This function can throw errors. + */ + setAll(properties: GraphicsSettingsPropertyTypeMap): void; +} + +export class IBlockPaletteItem { + private constructor(); + getBlock(): minecraftserver.BlockType | undefined; + getDisplayName(): string; + getType(): BlockPaletteItemType; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + * + * {@link Error} + */ + setBlock(block: minecraftserver.BlockPermutation | minecraftserver.BlockType | string): void; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export class LineWidget extends Widget { + private constructor(); +} + +/** + * The logger class is a utility class which allows editor + * extensions to communicate with the player from the server to + * the client log window. + * The logger class presents 4 different output channels which + * can be used to send information to the client/player, + * depending on the context of the information. + */ +export class Logger { + private constructor(); + /** + * @remarks + * A `debug` output channel generally used during the + * development process of editor extensions. This channel + * defaults to `hidden` in the log window (unless explicitly + * enabled). + * Once your editor extension development process is complete, + * and you're ready to ship/share your extension - we generally + * recommend that you remove any references to this log channel + * to avoid a noisy experience for other users + * + * This function can't be called in read-only mode. + * + * @param message + * The message string to send to the log window + * @throws This function can throw errors. + */ + debug(message: string, properties?: LogProperties): void; + /** + * @remarks + * The error channel is generally used when the editor + * extension experiences an error (either a program error in + * executing logic unexpectedly, or an error in the input or + * output to/from a player). Use this channel sparingly - it's + * meant to communicate important problems to the player + * + * This function can't be called in read-only mode. + * + * @param message + * The message string to send to the log window + * @throws This function can throw errors. + */ + error(message: string, properties?: LogProperties): void; + /** + * @remarks + * The info channel is intended to communicate general, + * non-fatal or non-erroneous information to the player that + * can generally be safely ignored if they choose to do so. + * + * This function can't be called in read-only mode. + * + * @param message + * The message string to send to the log window + * @throws This function can throw errors. + */ + info(message: string, properties?: LogProperties): void; + /** + * @remarks + * The warning channel is intended to inform the user of + * "potential" issues (missing inputs, values out of range, + * things that cannot be found) but are not fatal and execution + * can still be completed. + * + * This function can't be called in read-only mode. + * + * @param message + * The message string to send to the log window + * @throws This function can throw errors. + */ + warning(message: string, properties?: LogProperties): void; +} + +/** + * The MinecraftEditor class is a namespace container for + * Editor functionality which does not have any player context. + */ +export class MinecraftEditor { + private constructor(); + /** + * @remarks + * A global instance of the log output class object. This is + * not contextualized to any particular player, and any + * messages sent to this instance will be broadcast to all + * connected editor client sessions + * + * @throws This property can throw when used. + */ + readonly log: Logger; + /** + * @remarks + * Allows querying and modifying some properties of the + * simulation. + * + */ + readonly simulation: SimulationState; +} + +/** + * Contains information related to changes in player editor + * mode. + */ +export class ModeChangeAfterEvent { + private constructor(); + /** + * @remarks + * The editor mode that the player is changed to. + * + */ + readonly mode: EditorMode; +} + +/** + * Manages callbacks that are connected to when a player editor + * mode changes. + */ +export class ModeChangeAfterEventSignal { + private constructor(); + /** + * @remarks + * Subscribes the specified callback to an editor mode change + * after event. + * + * This function can't be called in read-only mode. + * + */ + subscribe(callback: (arg: ModeChangeAfterEvent) => void): (arg: ModeChangeAfterEvent) => void; + /** + * @remarks + * Removes the specified callback from an editor mode change + * after event. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + unsubscribe(callback: (arg: ModeChangeAfterEvent) => void): void; +} + +export class PlaytestManager { + private constructor(); + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + beginPlaytest(options: PlaytestGameOptions): Promise; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + getPlaytestSessionAvailability(): PlaytestSessionResult; +} + +export class PrimarySelectionChangeAfterEventSignal { + private constructor(); + /** + * @remarks + * This function can't be called in read-only mode. + * + */ + subscribe(callback: (arg: SelectionEventAfterEvent) => void): (arg: SelectionEventAfterEvent) => void; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + unsubscribe(callback: (arg: SelectionEventAfterEvent) => void): void; +} + +export class PrimarySelectionChangedEvent { + private constructor(); + readonly volume?: minecraftserver.CompoundBlockVolume; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export class ProbabilityBlockPaletteItem extends IBlockPaletteItem { + constructor(displayName?: string); + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + * + * {@link Error} + */ + addBlock(block: minecraftserver.BlockPermutation | minecraftserver.BlockType | string, weight: number): void; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + * + * {@link minecraftcommon.ArgumentOutOfBoundsError} + * + * {@link Error} + */ + removeBlockAt(index: number): void; +} + +/** + * The Selection represents a volume in space, which may + * potentially be made up of one or more block locations. + * These block locations do not need to be contiguous, and a + * Selection represent an irregular shape. + * It's important to note that a Selection is only a + * representation of the volume shape space - and does NOT + * represent the actual contents of the space. + */ +export class Selection { + private constructor(); + /** + * @remarks + * Returns a boolean representing whether or not there are any + * volumes pushed to the selection stack + * + * @throws This property can throw when used. + */ + readonly isEmpty: boolean; + /** + * @remarks + * Set whether or not the selection volume is visible to the + * client user. + * NOTE: Use this option carefully - Selection volumes are + * generally server-only, but marking a volume as visible + * causes the volume (and all volume operations) to be + * synchronized with the client game which can potentially + * generate excessive network traffic. + * + * + * This property can't be edited in read-only mode. + * + */ + visible: boolean; + /** + * @remarks + * Clear the contents of the Selection + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + clear(): void; + /** + * @remarks + * Fetch a block iterator which can be used to step across the + * Selection shape. Each call to the iterator will return the + * next block location within the Selection bounds which is + * actually selected. + * Block iteration is not guaranteed to be contiguous - it is + * possible to create irregular selection shapes by adding + * volumes to a selection which may or may not be contiguous or + * adjacent to other volumes within the selection. + * The Block iterator will return only selected volume + * locations + * + * This function can't be called in read-only mode. + * + */ + getBlockLocationIterator(): minecraftserver.BlockLocationIterator; + /** + * @remarks + * Return a bounding rectangle that contains all of the volumes + * within the selection (the bounding rectangle does NOT + * represent the shape of the selection, only the largest + * rectangle that will fit all of the volumes) + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + getBoundingBox(): minecraftserver.BoundingBox; + /** + * @remarks + * Return the color of the on-screen selection container hull + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + getFillColor(): minecraftserver.RGBA; + /** + * @remarks + * Return the color of the on-screen selection container + * outline + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + getOutlineColor(): minecraftserver.RGBA; + /** + * @remarks + * Get the origin of the CompoundBlockVolume that makes up the + * block component part of selection + * + * This function can't be called in read-only mode. + * + */ + getVolumeOrigin(): minecraftserver.Vector3; + /** + * @remarks + * Translate a selection by a given amount (this causes all of + * the volumes within the selection to be moved by the + * specified offset) + * + * This function can't be called in read-only mode. + * + * @param delta + * The amount by which to move + * @returns + * Return the newly moved position + * @throws This function can throw errors. + */ + moveBy(delta: minecraftserver.Vector3): minecraftserver.Vector3; + /** + * @remarks + * Move the selection to an absolute world location (causing + * all of the volumes within the selection to be moved to a + * location relative to the world location) + * + * This function can't be called in read-only mode. + * + * @param location + * The world location to which to relocate the selection + * @returns + * Return the newly moved position + * @throws This function can throw errors. + */ + moveTo(location: minecraftserver.Vector3): minecraftserver.Vector3; + /** + * @remarks + * Fetch the volume information of the last compound volume + * that was pushed to the volume stack without affecting the + * stack itself + * + * This function can't be called in read-only mode. + * + * @param forceRelativity + * See the description for {@link + * @minecraft-server/CompoundBlockVolume.peekLastVolume} + * @returns + * Returns undefined if the stack is empty + */ + peekLastVolume( + forceRelativity?: minecraftserver.CompoundBlockVolumePositionRelativity, + ): minecraftserver.CompoundBlockVolumeItem | undefined; + /** + * @remarks + * Remove the volume information that was last pushed to the + * volume stack. This will reduce the stack item length by 1 + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + popVolume(): void; + /** + * @remarks + * Push a compound volume item (a volume and action pair) to + * the volume stack. + * + * This function can't be called in read-only mode. + * + * @param item + * Item to push to the stack + * @throws This function can throw errors. + */ + pushVolume(item: minecraftserver.CompoundBlockVolumeItem): void; + /** + * @remarks + * Replace the contents of the current selection with a new + * specified selection. This operation will delete the current + * contents and copy the contents of the new selection to the + * target selection - it does this by content, not by + * reference. + * + * This function can't be called in read-only mode. + * + * @param other + * {@link @minecraft-server/CompoundBlockVolume} - set the + * block component part of this selection to the specified + * compound block volume. This will completely replace all + * block volume definitions in the selection. + * {@link @Selection} - replace the selection with the + * specified selection + * @throws This function can throw errors. + */ + set(other: minecraftserver.CompoundBlockVolume | Selection): void; + /** + * @remarks + * Set the color of the hull of the selection object if it is + * visible. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + setFillColor(color: minecraftserver.RGBA): void; + /** + * @remarks + * Set the color of the outline around the selection object if + * it is visible + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + setOutlineColor(color: minecraftserver.RGBA): void; +} + +export class SelectionEventAfterEvent { + private constructor(); + readonly selectionEvent: PrimarySelectionChangedEvent; +} + +/** + * The SelectionManager (accessible from the {@link + * ExtensionContext}) is responsible for the management of all + * {@link Selection} objects, and provides the user the ability + * to create new {@link Selection} objects for use within an + * extension. + */ +export class SelectionManager { + private constructor(); + /** + * @remarks + * The primary {@link Selection} object is always present (even + * if it's empty) and cannot be deleted. This object + * represents the main selection object which is always + * accessible through the UI, and by default is synchronized + * between the client and server. + * + * @throws This property can throw when used. + */ + readonly selection: Selection; + /** + * @remarks + * Create a new, empty {@link Selection} object + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + create(): Selection; +} + +/** + * The SettingsManager (accessible from the {@link + * ExtensionContext}) is responsible for the management all + * player settings. + */ +export class SettingsManager { + private constructor(); + /** + * @remarks + * Manages graphics settings properties. + * + */ + readonly graphics: GraphicsSettings; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export class SimpleBlockPaletteItem extends IBlockPaletteItem { + constructor(displayName?: string); +} + +/** + * Responsible for querying and modifying various properties of + * the simulation. + */ +export class SimulationState { + private constructor(); + /** + * @remarks + * Returns `true` if mob simulation is paused. + * + */ + isPaused(): boolean; + /** + * @remarks + * Sets the state of mob simulation. If set to `true`, mobs + * are paused. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + setPaused(isPaused: boolean): void; +} + +/** + * The Transaction Manager is responsible for tracking and + * managing all of the registered transaction operations which + * represent creator changes in the world. + * Transaction Manager is the basis of the UNDO and REDO + * operations, and allows a creator to store the changes made + * to the world and the state of the world BEFORE those changes + * were applied, making it possible to UNDO those changes and + * restore the world state. + * The transactions are stored as a stack, and can be undone in + * stack order to restore the world to it's original state + */ +export class TransactionManager { + private constructor(); + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + addUserDefinedOperation( + transactionHandlerId: UserDefinedTransactionHandlerId, + operationData: string, + operationName?: string, + ): void; + /** + * @remarks + * Commit all of the transaction operations currently attached + * to the open transaction record to the manager. These will + * be added as a single transaction manager entry. + * The open record will be closed and all tracking operations + * will cease. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + commitOpenTransaction(): boolean; + /** + * @remarks + * This function will commit the pending changes caused by any + * of the track changes variants. The changes will be + * committed to the currently open transaction, but the + * transaction will remain open for further records. + * Pending block changes from tracking operations will be added + * to the transaction record before submission to the + * transaction manager + * + * This function can't be called in read-only mode. + * + * @returns + * Returns the number of change requests that were being + * tracked + * @throws This function can throw errors. + */ + commitTrackedChanges(): number; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + createUserDefinedTransactionHandler( + undoClosure: (arg: string) => void, + redoClosure: (arg: string) => void, + ): UserDefinedTransactionHandlerId; + /** + * @remarks + * Discard the currently open transaction without committing it + * to the transaction manager stack. + * All records within the transaction will be discarded, and + * any tracking requests currently active will be stopped + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + discardOpenTransaction(): boolean; + /** + * @remarks + * Discard any pending tracked changes. This does not affect + * the current open transaction contents, only the pending + * tracked block operations + * + * This function can't be called in read-only mode. + * + * @returns + * Returns the number of change requests that were discarded + * @throws This function can throw errors. + */ + discardTrackedChanges(): number; + /** + * @remarks + * Open a transaction record which will be a container for any + * number of transaction operations. + * All transaction operations within a record are grouped and + * treated as a single atomic unit + * + * This function can't be called in read-only mode. + * + * @param name + * Give the transaction record a name + * @throws This function can throw errors. + */ + openTransaction(name: string): boolean; + /** + * @remarks + * Perform an redo operation. This will take the last + * transaction record on the redo stack and store the current + * world state and then apply the changes in the record. This + * will reduce the redo record stack by one. + * + * The transaction record affected by this operation will be + * transferred to the undo stack in case the creator decides to + * undo it + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + redo(): void; + /** + * @remarks + * Return the number of transaction records on the redo stack. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + redoSize(): number; + /** + * @remarks + * Begin tracking block changes in a specified area. These + * will be added to a pending changes list. + * The pending list will be added to the open transaction + * record when a commit has been issued. + * + * This function can't be called in read-only mode. + * + * @param from + * Min block location of a bounding area + * @param to + * Max block location of a bounding area + * @throws This function can throw errors. + */ + trackBlockChangeArea(from: minecraftserver.Vector3, to: minecraftserver.Vector3): boolean; + /** + * @remarks + * Begin tracking block changes in an area defined by a {@link + * @minecraft-server/CompoundBlockVolume}. These will be added + * to a pending changes list. + * The pending list will be added to the open transaction + * record when a commit has been issued. + * + * This function can't be called in read-only mode. + * + * @param compoundBlockVolume + * {@link @minecraft-server/CompoundBlockVolume} to track. + * Only non-void block locations will be tracked -- any changes + * falling into a void/negative space will not be tracked + * @throws This function can throw errors. + */ + trackBlockChangeCompoundBlockVolume(compoundBlockVolume: minecraftserver.CompoundBlockVolume): boolean; + /** + * @remarks + * Begin tracking block changes in a list of specified block + * locations. + * + * This function can't be called in read-only mode. + * + * @param locations + * An array of block locations to monitor for changes + * @throws This function can throw errors. + */ + trackBlockChangeList(locations: minecraftserver.Vector3[]): boolean; + /** + * @remarks + * Begin tracking block changes that may happen in a selection + * volume. + * The volume is copied, so tracking will not move if the + * selection volume is translated after this instruction is + * issued. + * Selection Volumes can also represent irregular shapes with + * non-contiguous blocks and this tracking call will honor the + * actual selected areas in the volume (and not the negative + * space) (see {@link @minecraft-server/CompoundBlockVolume} + * for more details + * + * This function can't be called in read-only mode. + * + * @param selection + * A collection of block location volumes represented by a + * Selection volume to monitor for changes. + * The Selection Volume is copied, so further changes to the + * volume after this call will not be reflected in the tracking + * list. + * @throws This function can throw errors. + */ + trackBlockChangeSelection(selection: Selection): boolean; + /** + * @remarks + * Perform an undo operation. This will take the last + * transaction record on the stack and apply the stored world + * state from before the changes were made. This will reduce + * the record stack by one. + * + * The transaction record affected by this operation will be + * transferred to the redo stack in case the creator decides to + * reapply it + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + undo(): void; + /** + * @remarks + * Return how many transactions records currently exist on the + * stack + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + undoSize(): number; +} + +/** + * A strongly typed transaction handle to enforce type safety + * when adding user defined transactions.
This transaction + * handle becomes the context for adding the transaction to the + * transaction manager.
You can obtain one of these handles + * by calling {@link registerUserDefinedTransactionHandler} + */ +export declare class UserDefinedTransactionHandle { + /** + * @remarks + * Constructs a new instance of the + * `UserDefinedTransactionHandle` class + * + */ + constructor(nativeHandle: UserDefinedTransactionHandlerId, transactionManager: TransactionManager); + /** + * @remarks + * Add a user defined transaction operation to the transaction + * manager with a payload of the specified type. This allows + * the extension to open a transaction, and insert custom data + * objects into the transaction log which are stored until an + * undo or redo event occurs. The payload data added here is + * stored and then passed to the undo/redo handlers (registered + * with {@link registerUserDefinedTransactionHandler}) when an + * undo/redo event is requested. NOTE:
Transactions can + * contain multiple operations - you can open a transaction and + * add any (reasonable) number of operations to it (of the same + * or differing types) before committing to the transaction + * log. NOTE/WARNING:
The payload data is serialized to + * JSON before being inserted into the transaction log and the + * underlying implementation uses the JSON.stringify() function + * to serialize the data. Any non-primitive data, such as + * classes or minecraft native objects will not serialize to + * JSON properly, so you should avoid using them as payload + * data. + * + * @param payload + * The data object to be inserted into the transaction log. + * @param transactionName + * A string name that will be associated with this operation + */ + addUserDefinedOperation(payload: T, transactionName: string): void; +} + +export class UserDefinedTransactionHandlerId { + private constructor(); +} + +export class Widget { + private constructor(); + readonly valid: boolean; + getIsSelected(): boolean; + getIsVisible(): boolean; + /** + * @remarks + * This function can't be called in read-only mode. + * + */ + setIsVisible(isVisible: boolean): void; +} + +export class WidgetGroup { + private constructor(); + readonly valid: boolean; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + createCustomWidget( + customEntityName: string, + location: minecraftserver.Vector3, + rotation?: minecraftserver.Vector2, + options?: CustomWidgetCreateOptions, + ): CustomWidget; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + deleteWidget(widgetToDelete: Widget): void; + /** + * @remarks + * This function can't be called in read-only mode. + * + */ + getIsVisible(): boolean; + /** + * @remarks + * This function can't be called in read-only mode. + * + */ + setIsVisible(isVisible: boolean): void; +} + +export class WidgetManager { + private constructor(); + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + createGroup(options?: WidgetGroupCreateOptions): WidgetGroup; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + deleteGroup(groupToDelete: WidgetGroup): void; +} + +export class WidgetStateChangeEventData { + private constructor(); + readonly group: WidgetGroup; + readonly isSelected?: boolean; + readonly isVisible?: boolean; + readonly widget: Widget; +} + +/** + * Interface used to specify the options when a clipboard item + * is being written to the world + */ +export interface ClipboardWriteOptions { + /** + * @remarks + * The anchor is a unit vector representation of the side or + * corner of the Clipboard Item to be written to the world. + * `{0, 0, 0}` represents the center of the Clipboard item, + * `{0, 1, 0}` represents the top, `{-1, -1, -1}` represents + * the bottom/back/left corner, etc + * The anchor is used in conjunction with the item size to + * determine the object relative anchor point where the object + * will be applied in the world. + * Values for the X/Y/Z components should be within the range + * `(-1 <= X/Y/Z <=1)` + * + */ + anchor?: minecraftserver.Vector3; + /** + * @remarks + * An enum which represents the axis (or combination of axis') + * along which the item should be mirrored + * - X + * - Z + * - XZ + * + */ + mirror?: minecraftserver.StructureMirrorAxis; + /** + * @remarks + * A position offset which should be applied to the paste + * location while the clipboard item is being written + * + */ + offset?: minecraftserver.Vector3; + /** + * @remarks + * An enum representing the rotation around the Y-Axis which + * should be applied while the clipboard item is being written + * + */ + rotation?: minecraftserver.StructureRotation; +} + +/** + * The CursorProperties interface is used to describe the + * properties of the Editor 3D block cursor construct. + * The 3D block cursor can be queried to retrieve the current + * properties, and the same property class can be used to set + * the current properties of the cursor. + * This interface is generally used at the activation stage of + * the active tool to set up the color, visibility and input + * properties of the 3D block cursor + */ +export interface CursorProperties { + /** + * @remarks + * Enum representing the cursor control mode + * - Fixed Mode locks the cursor to a position which is \ + * blocks offset from the current player position. The cursor + * is camera relative, so it will always appear \ blocks + * ahead of the players feet + * - Keyboard Mode puts the cursor under direct control of the + * API, and ignores any mouse input. The cursor can only be + * moved around using the moveBy method + * - KeyboardAndMouse mode puts the cursor under a shared + * control of onMouseMove and keyboard input. Any mouse + * movement events will set the cursor to the position of the + * mouse/world raycast. This can be modified using the moveBy + * method, but any subsequent mouse events will reset the + * position back to where the raycast intersection occurs + * - Mouse mode puts the cursor under control of mouse move + * events, and moveBy method will be ignored + * + * + */ + controlMode?: CursorControlMode; + /** + * @remarks + * The fixed distance from the players feet at which the cursor + * is attached, relative to camera direction. + * This is only used when [controlMode] is set to `Fixed` + * + */ + fixedModeDistance?: number; + /** + * @remarks + * A [Color] Property representing the color of the block + * cursor object outline + * + */ + outlineColor?: minecraftserver.RGBA; + projectThroughLiquid?: boolean; + /** + * @remarks + * An enum representing the cursor target mode + * - Block Mode records the block position of the mouse/world + * raycast intersection + * - Face Mode records the block position of the block adjacent + * to the mouse/world raycast intersection, according to the + * face of the collision point of the selected block + * + */ + targetMode?: CursorTargetMode; + /** + * @remarks + * Boolean flag controlling the visibility of the 3D block + * cursor + * + */ + visible?: boolean; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export interface CustomWidgetCreateOptions extends WidgetCreateOptions { + moveEvent?: (arg: CustomWidgetMoveEventData) => void; + showTextOnlyWhenSelected?: boolean; + text?: string; + visualOffset?: minecraftserver.Vector3; +} + +/** + * An interface which defines the set of optional parameters + * which can be used when calling the `registerEditorExtension` + * function + */ +export interface ExtensionOptionalParameters { + /** + * @remarks + * An optional text description of the extension being + * registered. + * This can be a straight textual description or a string + * identifier key for a localized string in the extension's + * resource pack text files. + * The description is meant to be a very short snappy one-liner + * which quickly and uniquely identifies the extension + * The length of the string is capped to 256 characters + * + */ + description?: string; + /** + * @remarks + * Optional notes for the extension being registered. + * This can be a straight textual description or a string + * identifier key for a localized string in the extension's + * resource pack text files. + * The notes section is meant to convey more detailed + * information and notes (e.g. a link to the author's website) + * The length of this string is capped to 1024 characters + * + */ + notes?: string; + /** + * @remarks + * An optional custom identifier that will be used for all + * Modal Tools created from the registered extension. + * The length of the string is capped to 256 characters + * + */ + toolGroupId?: string; +} + +/** + * A properties class for the global instance of the logger + * object. + * While the logger object is available through the {@link + * ExtensionContext} - using the global instance allows the + * creator to use this properties class to perform direct + * server->client messaging and broadcasts. + */ +export interface LogProperties { + /** + * @remarks + * Direct a log message to a specific player. If no player is + * specified, then all players will receive the message + * + */ + player?: minecraftserver.Player; + /** + * @remarks + * Add additional tags to the log message which can be used by + * the client session to filter/search in the log window + * + */ + tags?: string[]; +} + +export interface PlaytestGameOptions { + alwaysDay?: boolean; + difficulty?: minecraftserver.Difficulty; + disableWeather?: boolean; + gameMode?: minecraftserver.GameMode; + showCoordinates?: boolean; + spawnPosition?: minecraftserver.Vector3; + timeOfDay?: number; + weather?: number; +} + +export interface WidgetCreateOptions { + initialVisibility?: boolean; + isSelectable?: boolean; + stateChangeEvent?: (arg: WidgetStateChangeEventData) => void; +} + +export interface WidgetGroupCreateOptions { + groupSelectionMode?: WidgetGroupSelectionMode; +} + +/** + * Binds actions to the client and manages their lifetime. + * Action managers are managed on a per player basis since + * client side UI is per player. + */ +export interface ActionManager { + /** + * @remarks + * The active tool ID + * + */ + activeToolId: string | undefined; + /** + * @remarks + * Creates an action and registers it on the client + * + * @param rawAction + * The raw action to create. See ActionTypes for supported + * parameters + */ + createAction(rawAction: T): RegisteredAction; +} + +/** + * Represents a UI session for a given player + */ +export interface BuiltInUIManager { + /** + * @remarks + * Navigates to the documentation site. + * + */ + navigateToDocumentation(): void; + /** + * @remarks + * Navigates to the feedback site + * + */ + navigateToFeedback(): void; + /** + * @remarks + * Navigates to the pause screen + * + */ + navigateToPauseScreen(): void; + /** + * @remarks + * Updates the visibility of the log panel + * + */ + updateLogPanelVisibility(visibility: boolean): void; + /** + * @remarks + * Updates the visibility of the control demo + * + */ + updateUISettingsPanelVisibility(visibility: boolean): void; + /** + * @remarks + * Updates the visibility of the welcome panel + * + */ + updateWelcomePanelVisibility(visibility: boolean): void; +} + +/** + * An event that can be subscribed to. You can use the token, + * returned from the subscribe method, to clean up handlers. + */ +export declare interface EventSink { + /** + * @remarks + * Subscribes an event handler to a particular subscription. + * + * @param handler + * Handler function to subscribe with. + * @returns + * An event handler subscription token that can be used to + * unsubscribe and clean-up handlers. + */ + subscribe(handler: EventHandler): IEventToken; +} + +/** + * Simple abstraction for disposable objects. + */ +export interface IDisposable { + /** + * @remarks + * Initiates the teardown and cleanup of this disposable item. + * + */ + teardown(): void; +} + +export interface IDropdownItem { + /** + * @remarks + * Fallback display text if no loc ID + * + */ + readonly displayAltText: string; + /** + * @remarks + * Loc ID (resolved on client) + * + */ + readonly displayStringId: string; + /** + * @remarks + * The selectable value of the DropDown item. + * + */ + readonly value: number; +} + +/** + * Dropdown property item specific functionality + */ +export interface IDropdownPropertyItemMixIn { + /** + * @remarks + * Used to update the Dropdown options in the control. Will + * trigger onChange with -1 as the old value due to the list + * changing entries. + * + */ + updateDropdownItems(dropdownItems: IDropdownItem[], newValue: number): void; +} + +/** + * Returned from an event subscription. Provides functionality + * for cleaning up listeners + */ +export declare interface IEventToken { + /** + * @remarks + * Removes registered listener from an event + * + */ + unsubscribe(): void; +} + +export interface IGlobalInputManager { + registerKeyBinding( + inputContextId: EditorInputContext, + action: SupportedKeyboardActionTypes, + button: KeyboardKey, + modifier?: InputModifier, + ): void; +} + +export interface IMenu { + /** + * @remarks + * If defined, the menu will show a checked or unchecked + * checkbox. + * + */ + checked?: boolean; + /** + * @remarks + * Unique ID for the menu + * + */ + readonly id: string; + /** + * @remarks + * Sub menus of this menu + * + */ + readonly submenu: IMenu[]; + addItem(params: IMenuCreationParams, action?: RegisteredAction): IMenu; + dispose(): void; + hide(): void; + replaceAction(action: RegisteredAction): void; + show(): void; +} + +/** + * Manager and container for IMenu objects + */ +export interface IMenuContainer { + /** + * @remarks + * Create a top level item in the container. + * + * @param props + * Configuration for the menu to create + */ + createMenu(props: IMenuCreationParams): IMenu; + /** + * @remarks + * Search for a menu item, if it's not found defer it to next + * tick. + * + * @param id + * Menu identifier + */ + getMenu(id: string): Promise; +} + +/** + * Properties required to create a Menu + */ +export interface IMenuCreationParams { + /** + * @remarks + * Whether the menu should show a checkmark + * + */ + checked?: boolean; + /** + * @remarks + * Loc ID (resolved on client) + * + */ + displayStringId?: string; + /** + * @remarks + * The name of the menu + * + */ + name: string; + /** + * @remarks + * Custom unique identifier that will replace random id + * + */ + uniqueId?: string; +} + +export interface IModalTool { + /** + * @remarks + * Unique ID for the tool + * + */ + readonly id: string; + /** + * @remarks + * Provides lifecycle activation events for a modal tool + * + */ + onModalToolActivation: EventSink; + bindPropertyPane(pane: IPropertyPane): void; + dispose(): void; + hide(): void; + registerKeyBinding(action: SupportedKeyboardActionTypes, button: KeyboardKey, modifier?: InputModifier): void; + registerMouseButtonBinding(action: SupportedMouseActionTypes): void; + registerMouseDragBinding(action: SupportedMouseActionTypes): void; + registerMouseWheelBinding(action: SupportedMouseActionTypes): void; + show(): void; + unregisterInputBindings(): void; +} + +export interface IModalToolContainer { + /** + * @remarks + * Tools within this container. + * + */ + readonly currentTools: IModalTool[]; + /** + * @remarks + * The id of the selected tool in container. + * + */ + readonly selectedOptionId?: string; + addTool(params: ModalToolCreationParameters): IModalTool; + dispose(): void; + hide(): void; + removeTool(id: string): void; + setSelectedOptionId(value: string | undefined, update?: boolean): void; + show(): void; +} + +/** + * Log helper interface for Player. + */ +export interface IPlayerLogger { + /** + * @remarks + * Dispatch a player log message with Debug log level + * + * @param message + * Message content + */ + debug(message: string): void; + /** + * @remarks + * Dispatch a player log message with Error log level + * + * @param message + * Message content + */ + error(message: string): void; + /** + * @remarks + * Dispatch a player log message with Info log level + * + * @param message + * Message content + */ + info(message: string): void; + /** + * @remarks + * Dispatch a player log message with Warning log level + * + * @param message + * Message content + */ + warning(message: string): void; +} + +export interface IPropertyItem { + /** + * @remarks + * If the item is enabled in the UI. + * + */ + enable: boolean; + /** + * @remarks + * Unique ID for the property item. + * + */ + readonly id: string; + /** + * @remarks + * The object associated. + * + */ + readonly obj: T; + /** + * @remarks + * The parent pane id. + * + */ + readonly paneId: string; + /** + * @remarks + * The target property of the object associated. + * + */ + readonly property: Prop; + /** + * @remarks + * The type name of the target property. + * + */ + readonly typeName: EDITOR_PANE_PROPERTY_ITEM_TYPE; + /** + * @remarks + * The value of the property. + * + */ + readonly value: T[Prop]; + /** + * @remarks + * If the item should be visible in the UI. + * + */ + visible: boolean; + dispose(): void; +} + +export interface IPropertyItemOptions { + /** + * @remarks + * If the item is enabled in the UI. + * + */ + enable?: boolean; + /** + * @remarks + * Callback to execute when the value is updated. + * + */ + onChange?: OnChangeCallback; + /** + * @remarks + * Fallback display text if no loc ID + * + */ + titleAltText?: string; + /** + * @remarks + * Loc ID (resolved on client) + * + */ + titleStringId?: string; + /** + * @remarks + * If the item should be visible in the UI. + * + */ + visible?: boolean; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export interface IPropertyItemOptionsBool extends IPropertyItemOptions { + /** + * @remarks + * controls appearance of the boolean. checkbox or toggleswitch + * + */ + displayAsToggleSwitch?: boolean; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export interface IPropertyItemOptionsButton extends IPropertyItemOptions { + icon?: string; + /** + * @remarks + * The variant for the button. By default it is "primary" + * + */ + variant?: ButtonVariant; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export interface IPropertyItemOptionsDataPicker extends IPropertyItemOptions { + /** + * @remarks + * Used to hold the entries allowed in the block/entity picker + * + */ + allowedEntries?: string[]; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export interface IPropertyItemOptionsDropdown extends IPropertyItemOptions { + /** + * @remarks + * The possible options for the drop down control. + * + */ + dropdownItems: IDropdownItem[]; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export interface IPropertyItemOptionsImage extends IPropertyItemOptions { + imageHeight: number; + imageWidth: number; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export interface IPropertyItemOptionsNumber extends IPropertyItemOptions { + /** + * @remarks + * The min possible value for the number. + * + */ + max?: number; + /** + * @remarks + * The max possible value for the number. + * + */ + min?: number; + /** + * @remarks + * If UI should show slider control. + * + */ + showSlider?: boolean; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export interface IPropertyItemOptionsSubPane extends IPropertyItemOptions { + /** + * @remarks + * The sub pane to render in UI. + * + */ + pane: IPropertyPane; +} + +/** + * Localization string id and border enable boolean for + * multiline text component. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export interface IPropertyItemOptionsText extends IPropertyItemOptions { + border: boolean; + valueStringId: string; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export interface IPropertyItemOptionsVector3 extends IPropertyItemOptions { + /** + * @remarks + * The max possible value for the X axis. By default + * Number.MAX_SAFE_INTEGER + * + */ + maxX?: number; + /** + * @remarks + * The max possible value for the Y axis. By default + * Number.MAX_SAFE_INTEGER + * + */ + maxY?: number; + /** + * @remarks + * The max possible value for the z axis. By default + * Number.MAX_SAFE_INTEGER + * + */ + maxZ?: number; + /** + * @remarks + * The min possible value for the X axis. By default + * Number.MIN_SAFE_INTEGER + * + */ + minX?: number; + /** + * @remarks + * The min possible value for the Y axis. By default + * Number.MIN_SAFE_INTEGER + * + */ + minY?: number; + /** + * @remarks + * The min possible value for the Z axis. By default + * Number.MIN_SAFE_INTEGER + * + */ + minZ?: number; +} + +/** + * Property pane present dynamic content. It can be associated + * with an object and presented with different kind of + * controls. + */ +export interface IPropertyPane { + /** + * @remarks + * Pane state for being expanded or collapsed. + * + */ + collapsed: boolean; + /** + * @remarks + * Unique ID for the property pane. + * + */ + readonly id: string; + /** + * @remarks + * Provides visibility change events + * + */ + onPropertyPaneVisibilityUpdated: EventSink; + /** + * @remarks + * In case of sub pane this is the id of the parent pane. + * + */ + readonly parentPaneId?: string; + /** + * @remarks + * Fallback display text if no loc ID + * + */ + titleAltText: string; + /** + * @remarks + * Loc ID (resolved on client) + * + */ + titleStringId: string; + /** + * @remarks + * Width of the panel in rem. + * + */ + width?: number; + /** + * @remarks + * Adds a BlockPicker item to the pane. + * + */ + addBlockPicker( + obj: T, + property: Prop, + options?: IPropertyItemOptionsDataPicker, + ): IPropertyItem; + /** + * @remarks + * Adds a boolean item to the pane. + * + */ + addBool( + obj: T, + property: Prop, + options?: IPropertyItemOptionsBool, + ): IPropertyItem; + /** + * @remarks + * Adds a button to the pane and binds the specified action to + * the button activate. + * + */ + addButton( + action: RegisteredAction, + options?: IPropertyItemOptionsButton, + ): IActionPropertyItem< + { + EMPTY: undefined; + }, + 'EMPTY' + >; + /** + * @remarks + * Adds an divider item to the pane. + * + */ + addDivider(): IPropertyItem; + /** + * @remarks + * Adds an DropDown item to the pane. + * + */ + addDropdown< + T extends Omit & { + [key in Prop]: number; + }, + Prop extends keyof T & string, + >( + obj: T, + property: Prop, + options?: IPropertyItemOptionsDropdown, + ): IDropdownPropertyItem; + /** + * @remarks + * Adds an EntityPicker item to the pane. + * + */ + addEntityPicker( + obj: T, + property: Prop, + options?: IPropertyItemOptionsDataPicker, + ): IPropertyItem; + /** + * @remarks + */ + addImage( + obj: T, + property: Prop, + options?: IPropertyItemOptionsImage, + ): IPropertyItem; + /** + * @remarks + * Adds a number item to the pane. + * + */ + addNumber( + obj: T, + property: Prop, + options?: IPropertyItemOptionsNumber, + ): IPropertyItem; + /** + * @remarks + * Adds a string item to the pane + * + */ + addString( + obj: T, + property: Prop, + options?: IPropertyItemOptions, + ): IPropertyItem; + /** + * @remarks + * Adds a multiline Text item to the pane. + * + */ + addText( + obj: T, + property: Prop, + options?: IPropertyItemOptionsText, + ): IPropertyItem; + /** + * @remarks + * Adds a Vec3 item to the pane. + * + */ + addVector3( + obj: T, + property: Prop, + options?: IPropertyItemOptionsVector3, + ): IVector3PropertyItem; + /** + * @remarks + * Collapse the pane. + * + */ + collapse(): void; + /** + * @remarks + * Creates an internal sub panel that is presented inside a + * extender control. + * + */ + createPropertyPane(options: IPropertyPaneOptions): IPropertyPane; + /** + * @remarks + * Expand the pane. + * + */ + expand(): void; + /** + * @remarks + * Hide the pane. + * + */ + hide(): void; + /** + * @remarks + * Removes a child property pane from the parent pane. + * + */ + removePropertyPane(paneToRemove: IPropertyPane): boolean; + /** + * @remarks + * Show the pane and all of its property items. + * + */ + show(): void; +} + +/** + * The options to create a pane. + */ +export interface IPropertyPaneOptions { + /** + * @remarks + * Layout direction for sub panes + * + */ + direction?: LayoutDirection; + /** + * @remarks + * Fallback display text if no loc ID + * + */ + titleAltText: string; + /** + * @remarks + * Loc ID (resolved on client) + * + */ + titleStringId: string; + /** + * @remarks + * Width of the panel in rem. This property is ignored in case + * of sub panes + * + */ + width?: number; +} + +/** + * Optional parameter definition for RegisterEditorExtension + * function Allows the extension registrar to specify optional + * textual description and notes which would be visible through + * the extension manager + */ +export interface IRegisterExtensionOptionalParameters { + /** + * @remarks + * Description of the extension. + * + */ + description?: string; + /** + * @remarks + * Additional notes and description of the extension. + * + */ + notes?: string; + /** + * @remarks + * An optional custom group identifier that will be used for + * all Modal Tools created from the registered extension. + * + */ + toolGroupId?: string; +} + +export interface IStatusBarItem { + /** + * @remarks + * Unique ID for the item. + * + */ + readonly id: string; + /** + * @remarks + * Text to display. + * + */ + text: string; + hide(): void; + show(): void; +} + +/** + * Parameters for creating a modal tool in the tool container + */ +export interface ModalToolCreationParameters { + /** + * @remarks + * The displayed string for the tool + * + */ + displayAltText: string; + /** + * @remarks + * Loc ID (resolved on client) + * + */ + displayStringId?: string; + /** + * @remarks + * Icon, if any (from resource pack on client) + * + */ + icon?: string; + /** + * @remarks + * tooltipAltText alt text, if any + * + */ + tooltipAltText?: string; + /** + * @remarks + * Tooltip localization string ID + * + */ + tooltipStringId?: string; +} + +/** + * @remarks + * Takes the input object (a property bag of values) and bind + * it to the pane as a data source. UI child elements of the + * pane will be updated when the values in the object change, + * and vice versa. + * + * @param propertyPane + * The property pane to bind the property bag to. + * @param target + * The property bag to bind to the pane. + */ +export declare function bindDataSource( + propertyPane: IPropertyPane, + target: T, +): T; +/** + * @remarks + * Executes an operation over a selection via chunks to allow + * splitting operation over multiple game ticks + * + * @param selection + * the selection to iterator over + * @param operation + * the operation to apply over each block location + */ +export declare function executeLargeOperation( + selection: Selection, + operation: (blockLocation: minecraftserver.Vector3) => void, +): Promise; +/** + * @remarks + * Returns a string array of the default block types for the + * Block picker control. Can be used to further filter blocks + * from the Block picker. + * + * @returns + * Default allowed block list + */ +export declare function getBlockPickerDefaultAllowBlockList(): string[]; +/** + * @remarks + * Adds the resource pack editor prefix and returns the full + * localization ID + * + */ +export declare function getLocalizationId(locId: string): string; +/** + * @remarks + * Registers an editor extension into Minecraft. This function + * calls underlying functionality to register an extension but + * provides helpful and contextual wrappers for individual + * client lifetimes. The onActivation function is called + * whenever a client joins a session, while the shutdown is + * called when a client leaves. There may be other + * circumstances in which these are called as well based on + * client state that is an implementation detail of the system. + * + */ +export declare function registerEditorExtension>( + extensionName: string, + activationFunction: ActivationFunctionType, + shutdownFunction: ShutdownFunctionType, + options?: IRegisterExtensionOptionalParameters, +): Extension; +/** + * @remarks + * Creates a strongly typed transaction handle to enforce type + * safety when adding user defined transactions. This function + * is a wrapper around the more generalized transaction manager + * API for script based transactions. Any Editor Extension that + * needs to insert data into the transaction log for undo/redo + * should use this function to create a handler for the + * specific type of data that needs to be inserted. When a + * transaction is undone/redone, the associated handler + * function will be invoked with a copy of the payload data + * that was inserted into the log. As a general rule, + * transaction data should contain 2 things:
1. The data + * that will be used to perform the operation we're trying to + * record
2. The data that will be used to restore the + * state of the program to what it was before the + * operation.
NOTE/WARNING:
The payload data is + * serialized to JSON before being inserted into the + * transaction log and the underlying implementation uses the + * JSON.stringify() function to serialize the data. Any + * non-primitive data, such as classes or minecraft native + * objects will not serialize to JSON properly, so you should + * avoid using them as payload data. + * + * @param transactionManager + * A reference to the TransactionManager (from the extension + * context for your extension) + * @param undoHandler + * A function that will be invoked when the transaction is + * undone. The function will be passed a copy of the payload + * data that was inserted into the transaction log. + * @param redoHandler + * A function that will be invoked when the transaction is + * redone. The function will be passed a copy of the payload + * data that was inserted into the transaction log. + * @returns + * - {@link UserDefinedTransactionHandle} - A strongly typed + * transaction handle that can be used to add transactions to + * the transaction manager. + */ +export declare function registerUserDefinedTransactionHandler( + transactionManager: TransactionManager, + undoHandler: (payload: T) => void, + redoHandler: (payload: T) => void, +): UserDefinedTransactionHandle; +/** + * @remarks + * Small utility for getting a string from an unknown exception + * type + * + */ +export declare function stringFromException(e: unknown): string; +export const editor: MinecraftEditor; diff --git a/static/typedoc/stable/server-gametest.d.ts b/static/typedoc/stable/server-gametest.d.ts index a866eff327..1c191a904c 100644 --- a/static/typedoc/stable/server-gametest.d.ts +++ b/static/typedoc/stable/server-gametest.d.ts @@ -17,51 +17,83 @@ * ```json * { * "module_name": "@minecraft/server-gametest", - * "version": "1.0.0-internal.1.19.70-stable" + * "version": "1.0.0-internal.1.20.80-stable" * } * ``` * */ +import * as minecraftcommon from '@minecraft/common'; import * as minecraftserver from '@minecraft/server'; +export enum GameTestErrorType { + Assert = 'Assert', + AssertAtPosition = 'AssertAtPosition', + ExecutionTimeout = 'ExecutionTimeout', + ExhaustedAttempts = 'ExhaustedAttempts', + FailConditionsMet = 'FailConditionsMet', + LevelStateModificationFailed = 'LevelStateModificationFailed', + MethodNotImplemented = 'MethodNotImplemented', + SimulatedPlayerOutOfBounds = 'SimulatedPlayerOutOfBounds', + Unknown = 'Unknown', + Waiting = 'Waiting', +} + +export enum LookDuration { + Continuous = 'Continuous', + Instant = 'Instant', + UntilMove = 'UntilMove', +} + /** * Returns information about whether this fence is connected to * other fences in several directions. */ export class FenceConnectivity { - protected constructor(); + private constructor(); /** + * @remarks * Represents whether this fence block is connected to another * fence to the east (x + 1). + * */ readonly east: boolean; /** + * @remarks * Represents whether this fence block is connected to another * fence to the north (z - 1). + * */ readonly north: boolean; /** + * @remarks * Represents whether this fence block is connected to another * fence to the south (z + 1). + * */ readonly south: boolean; /** + * @remarks * Represents whether this fence block is connected to another * fence to the west (x - 1). + * */ readonly west: boolean; } + /** * Executes a set of steps defined via chained .thenXyz * methods, sequentially. This facilitates a 'script' of * GameTest setup methods and assertions over time. */ export class GameTestSequence { - protected constructor(); + private constructor(); /** * @remarks * Runs the given callback as a step within a GameTest * sequence. Exceptions thrown within the callback will end * sequence execution. + * + * This function can't be called in read-only mode. + * * @param callback * Callback function to execute. * @returns @@ -74,6 +106,9 @@ export class GameTestSequence { * After a delay, runs the given callback as a step within a * GameTest sequence. Exceptions thrown within the callback * will end sequence execution. + * + * This function can't be called in read-only mode. + * * @param delayTicks * Number of ticks to wait before executing the callback. * @param callback @@ -87,7 +122,9 @@ export class GameTestSequence { * @remarks * Runs the given callback every tick for the given number of * ticks. - * @param tickCount + * + * This function can't be called in read-only mode. + * * @param callback * Callback function to execute. * @returns @@ -99,6 +136,9 @@ export class GameTestSequence { * @remarks * Causes the test to fail if this step in the GameTest * sequence is reached. + * + * This function can't be called in read-only mode. + * * @param errorMessage * Error message summarizing the failure condition. */ @@ -106,6 +146,9 @@ export class GameTestSequence { /** * @remarks * Idles the GameTest sequence for the specified delayTicks. + * + * This function can't be called in read-only mode. + * * @param delayTicks * Number of ticks to delay for this step in the GameTest * sequence. @@ -118,6 +161,9 @@ export class GameTestSequence { * @remarks * Marks the GameTest a success if this step is reached in the * GameTest sequence. + * + * This function can't be called in read-only mode. + * */ thenSucceed(): void; /** @@ -125,6 +171,9 @@ export class GameTestSequence { * Executes the given callback every tick until it succeeds. * Exceptions thrown within the callback will end sequence * execution. + * + * This function can't be called in read-only mode. + * * @param callback * Testing callback function to execute. Typically, this * function will have .assertXyz functions within it. @@ -138,6 +187,9 @@ export class GameTestSequence { * After a delay from the previous step, executes the given * callback every tick until it succeeds. Exceptions thrown * within the callback will end sequence execution. + * + * This function can't be called in read-only mode. + * * @param delayTicks * Tick (after the previous step in the GameTest sequence) to * run the callback at. @@ -150,27 +202,39 @@ export class GameTestSequence { */ thenWaitAfter(delayTicks: number, callback: () => void): GameTestSequence; } + +export class NavigationResult { + private constructor(); + readonly isFullPath: boolean; + getPath(): minecraftserver.Vector3[]; +} + /** * A utility class to set GameTest parameters for a test. * Methods can be chained together to set multiple properties. */ export class RegistrationBuilder { - protected constructor(); + private constructor(); /** * @remarks * Sets the batch for the test to run in. + * + * This function can't be called in read-only mode. + * * @param batchName * Name of the batch for the test. * @returns * RegistrationBuilder object where additional configuration * methods can be called. */ - batch(batchName: 'night' | 'day'): RegistrationBuilder; + batch(batchName: string): RegistrationBuilder; /** * @remarks * Sets the maximum number of times a test will try to rerun if * it fails. - * @param attemptCount + * + * This function can't be called in read-only mode. + * * @returns * RegistrationBuilder object where additional configuration * methods can be called. @@ -180,7 +244,9 @@ export class RegistrationBuilder { * @remarks * Sets the maximum number of ticks a test will run for before * timing out and failing. - * @param tickCount + * + * This function can't be called in read-only mode. + * * @returns * RegistrationBuilder object where additional configuration * methods can be called. @@ -190,6 +256,9 @@ export class RegistrationBuilder { * @remarks * Size around the GameTest, in blocks, that should be reserved * for the test when running multiple tests together. + * + * This function can't be called in read-only mode. + * * @param paddingBlocks * Size, in blocks, around the GameTest where additional * GameTests should not be created. @@ -202,6 +271,9 @@ export class RegistrationBuilder { * @remarks * Whether this test is required to pass as part of its broader * set of tests. + * + * This function can't be called in read-only mode. + * * @param isRequired * If set to true, the test must pass in order for the entire * run of tests to pass. @@ -214,7 +286,9 @@ export class RegistrationBuilder { * @remarks * Sets the number of successful test runs to be considered * successful. - * @param attemptCount + * + * This function can't be called in read-only mode. + * * @returns * RegistrationBuilder object where additional configuration * methods can be called. @@ -224,14 +298,18 @@ export class RegistrationBuilder { * @remarks * If true, runs the test in all four rotations when run via * /gametest runset. - * @param rotate + * + * This function can't be called in read-only mode. + * */ rotateTest(rotate: boolean): RegistrationBuilder; /** * @remarks * Sets the number of ticks for a test to wait before executing * when the structure is spawned. - * @param tickCount + * + * This function can't be called in read-only mode. + * * @returns * RegistrationBuilder object where additional configuration * methods can be called. @@ -242,7 +320,9 @@ export class RegistrationBuilder { * Sets the name of the structure for a test to use. "xyz:bar" * will load `/structures/xyz/bar.mcstructure` from the * behavior pack stack. - * @param structureName + * + * This function can't be called in read-only mode. + * * @returns * RegistrationBuilder object where additional configuration * methods can be called. @@ -252,22 +332,27 @@ export class RegistrationBuilder { * @remarks * Adds a tag to a test. You can run all tests with a given tag * with `/gametest runset `. - * @param tag + * + * This function can't be called in read-only mode. + * * @returns * RegistrationBuilder object where additional configuration * methods can be called. */ tag(tag: string): RegistrationBuilder; } + /** * Implements a class that can be used for testing sculk * spreading behaviors. This sculk spreader class can drive the * growth of sculk around a particular block. */ export class SculkSpreader { - protected constructor(); + private constructor(); /** + * @remarks * Gets the maximum charge of a sculk spreader. + * * @throws This property can throw when used. */ readonly maxCharge: number; @@ -275,44 +360,67 @@ export class SculkSpreader { * @remarks * Adds a cursor - which is a notional waypoint that the sculk * will spread in the direction of. - * @param offset - * @param charge + * + * This function can't be called in read-only mode. + * */ addCursorsWithOffset(offset: minecraftserver.Vector3, charge: number): void; /** * @remarks * Retrieves the current position of the specified cursor. - * @param index + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ getCursorPosition(index: number): minecraftserver.Vector3; /** * @remarks * Returns a number of overall cursors for this sculk spreader. + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ getNumberOfCursors(): number; /** * @remarks * Gets the total current charge of the sculk spreader. + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ getTotalCharge(): number; } + /** * A simulated player can be used within GameTests to represent * how a player moves throughout the world and to support * testing of how entities and the environment will react to a * player. This type derives much of its structure and methods - * from the {@link @minecraft/server.Player} type. + * from the {@link @minecraft/server.Player} type. Note that + * many types of events that may be available for entities more + * broadly, such as item use events, may not fire in the same + * capacity for simulated players. */ -export class SimulatedPlayer { - protected constructor(); +// @ts-ignore Class inheritance allowed for native defined classes +export class SimulatedPlayer extends minecraftserver.Player { + private constructor(); /** + * @remarks * Rotation of the head across pitch and yaw angles. + * * @throws This property can throw when used. */ - readonly headRotation: minecraftserver.XYRotation; + readonly headRotation: minecraftserver.Vector2; + /** + * @remarks + * Returns whether the simulated player is sprinting. + * + * This property can't be edited in read-only mode. + * + */ isSprinting: boolean; /** * @remarks @@ -320,6 +428,9 @@ export class SimulatedPlayer { * Returns true if the attack was performed - for example, the * player was not on cooldown and had a valid target. Target * selection is performed by raycasting from the player's head. + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ attack(): boolean; @@ -330,7 +441,9 @@ export class SimulatedPlayer { * player was not on cooldown and had a valid target. The * attack can be performed at any distance and does not require * line of sight to the target entity. - * @param entity + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ attackEntity(entity: minecraftserver.Entity): boolean; @@ -340,6 +453,9 @@ export class SimulatedPlayer { * the server player's game mode. The block will be hit until * broken, an item is used or stopBreakingBlock is called. * Returns true if the block at blockLocation is solid. + * + * This function can't be called in read-only mode. + * * @param blockLocation * Location of the block to interact with. * @param direction @@ -347,16 +463,49 @@ export class SimulatedPlayer { * @throws This function can throw errors. */ breakBlock(blockLocation: minecraftserver.Vector3, direction?: minecraftserver.Direction): boolean; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + chat(message: string): void; /** * @remarks * Simulates and performs a disconnection of the simulated * player from the world. + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ disconnect(): void; + /** + * @remarks + * Drops the simulated player's selected item + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + dropSelectedItem(): boolean; + /** + * @remarks + * Causes the simulated player to start flying as though they + * were flying in creative mode. For flying with Elytra, see + * function glide. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + fly(): void; /** * @remarks * Gives the simulated player a particular item stack. + * + * This function can't be called in read-only mode. + * * @param itemStack * Item to give. * @param selectSlot @@ -364,11 +513,29 @@ export class SimulatedPlayer { * @throws This function can throw errors. */ giveItem(itemStack: minecraftserver.ItemStack, selectSlot?: boolean): boolean; + /** + * @remarks + * Causes the simulated player to start gliding. Elytra must be + * equipped and the player must be in the air. + * + * This function can't be called in read-only mode. + * + * @returns + * Returns true if the simulated player begins to glide. + * Returns false if the player is already gliding, or the + * player does not have Elytra equipped, is in water or is on + * the ground. + * @throws This function can throw errors. + */ + glide(): boolean; /** * @remarks * Performs a raycast from the player’s head and interacts with * the first intersected block or entity. Returns true if the * interaction was successful. Maximum range is 6 blocks. + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ interact(): boolean; @@ -377,6 +544,9 @@ export class SimulatedPlayer { * Causes the simulated player to interact with a block. The * block at the specified block location must be solid. Returns * true if the interaction was performed. + * + * This function can't be called in read-only mode. + * * @param blockLocation * Location of the block to interact with. * @param direction @@ -388,6 +558,9 @@ export class SimulatedPlayer { * @remarks * Causes the simulated player to interact with a mob. Returns * true if the interaction was performed. + * + * This function can't be called in read-only mode. + * * @param entity * Entity to interact with. * @throws This function can throw errors. @@ -396,6 +569,9 @@ export class SimulatedPlayer { /** * @remarks * Causes the simulated player to jump. + * + * This function can't be called in read-only mode. + * * @returns * True if a jump was performed. * @throws This function can throw errors. @@ -405,33 +581,39 @@ export class SimulatedPlayer { * @remarks * Rotates the simulated player's head/body to look at the * given block location. - * @param blockLocation + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ - lookAtBlock(blockLocation: minecraftserver.Vector3): void; + lookAtBlock(blockLocation: minecraftserver.Vector3, duration?: LookDuration): void; /** * @remarks * Rotates the simulated player's head/body to look at the * given entity. - * @param entity + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ - lookAtEntity(entity: minecraftserver.Entity): void; + lookAtEntity(entity: minecraftserver.Entity, duration?: LookDuration): void; /** * @remarks * Rotates the simulated player's head/body to look at the * given location. - * @param location + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ - lookAtLocation(location: minecraftserver.Vector3): void; + lookAtLocation(location: minecraftserver.Vector3, duration?: LookDuration): void; /** * @remarks * Orders the simulated player to walk in the given direction * relative to the GameTest. - * @param westEast - * @param northSouth - * @param speed + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ move(westEast: number, northSouth: number, speed?: number): void; @@ -439,9 +621,9 @@ export class SimulatedPlayer { * @remarks * Orders the simulated player to walk in the given direction * relative to the player's current rotation. - * @param leftRight - * @param backwardForward - * @param speed + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ moveRelative(leftRight: number, backwardForward: number, speed?: number): void; @@ -451,21 +633,23 @@ export class SimulatedPlayer { * location in a straight line. If a move or navigation is * already playing, this will override the last * move/navigation. - * @param blockLocation - * @param speed + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ - moveToBlock(blockLocation: minecraftserver.Vector3, speed?: number): void; + moveToBlock(blockLocation: minecraftserver.Vector3, options?: MoveToOptions): void; /** * @remarks * Orders the simulated player to move to the given location in * a straight line. If a move or navigation is already playing, * this will override the last move/navigation. - * @param location - * @param speed + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ - moveToLocation(location: minecraftserver.Vector3, speed?: number): void; + moveToLocation(location: minecraftserver.Vector3, options?: MoveToOptions): void; /** * @remarks * Orders the simulated player to move to a specific block @@ -474,21 +658,23 @@ export class SimulatedPlayer { * that if the simulated player gets stuck, that simulated * player will stop. The player must be touching the ground in * order to start navigation. - * @param blockLocation - * @param speed + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ - navigateToBlock(blockLocation: minecraftserver.Vector3, speed?: number): minecraftserver.NavigationResult; + navigateToBlock(blockLocation: minecraftserver.Vector3, speed?: number): NavigationResult; /** * @remarks * Will use navigation to follow the selected entity to within * a one block radius. If a move or navigation is already * playing, this will override the last move/navigation. - * @param entity - * @param speed + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ - navigateToEntity(entity: minecraftserver.Entity, speed?: number): minecraftserver.NavigationResult; + navigateToEntity(entity: minecraftserver.Entity, speed?: number): NavigationResult; /** * @remarks * Orders the simulated player to move to a specific location @@ -497,16 +683,20 @@ export class SimulatedPlayer { * the simulated player gets stuck, that simulated player will * stop. The player must be touching the ground in order to * start navigation. - * @param location - * @param speed + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ - navigateToLocation(location: minecraftserver.Vector3, speed?: number): minecraftserver.NavigationResult; + navigateToLocation(location: minecraftserver.Vector3, speed?: number): NavigationResult; /** * @remarks * Use navigation to follow the route provided via the * locations parameter. If a move or navigation is already * playing, this will override the last move/navigation. + * + * This function can't be called in read-only mode. + * * @param locations * A list of locations to use for routing. * @param speed @@ -517,6 +707,9 @@ export class SimulatedPlayer { /** * @remarks * Respawns the particular simulated player. + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ respawn(): boolean; @@ -524,7 +717,9 @@ export class SimulatedPlayer { * @remarks * Causes the simulated player to turn by the provided angle, * relative to the player's current rotation. - * @param angleInDegrees + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ rotateBody(angleInDegrees: number): void; @@ -532,22 +727,18 @@ export class SimulatedPlayer { * @remarks * Causes the simulated player to turn to face the provided * angle, relative to the GameTest. - * @param angleInDegrees + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ setBodyRotation(angleInDegrees: number): void; - /** - * @remarks - * Sets the game mode that the simulated player is operating - * under. - * @param gameMode - * Game mode to set. - * @throws This function can throw errors. - */ - setGameMode(gameMode: minecraftserver.GameMode): void; /** * @remarks * Sets a particular item for the simulated player. + * + * This function can't be called in read-only mode. + * * @param itemStack * Item to set. * @param slot @@ -557,15 +748,53 @@ export class SimulatedPlayer { * @throws This function can throw errors. */ setItem(itemStack: minecraftserver.ItemStack, slot: number, selectSlot?: boolean): boolean; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + startBuild(slot?: number): void; /** * @remarks * Stops destroying the block that is currently being hit. + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ stopBreakingBlock(): void; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + stopBuild(): void; + /** + * @remarks + * Causes the simulated player to stop flying. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + stopFlying(): void; + /** + * @remarks + * Causes the simulated player to stop gliding. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + stopGliding(): void; /** * @remarks * Stops interacting with entities or blocks. + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ stopInteracting(): void; @@ -573,19 +802,49 @@ export class SimulatedPlayer { * @remarks * Stops moving/walking/following if the simulated player is * moving. + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ stopMoving(): void; + /** + * @remarks + * Causes the simulated player to stop swimming. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + stopSwimming(): void; /** * @remarks * Stops using the currently active item. + * + * This function can't be called in read-only mode. + * + * @returns + * Returns the item that was in use. Undefined if no item was + * in use. + * @throws This function can throw errors. + */ + stopUsingItem(): minecraftserver.ItemStack | undefined; + /** + * @remarks + * Causes the simulated player to start swimming. + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ - stopUsingItem(): void; + swim(): void; /** * @remarks * Causes the simulated player to use an item. Does not consume * the item. Returns false if the item is on cooldown. + * + * This function can't be called in read-only mode. + * * @param itemStack * Item to use. * @throws This function can throw errors. @@ -595,6 +854,9 @@ export class SimulatedPlayer { * @remarks * Causes the simulated player to hold and use an item in their * inventory. + * + * This function can't be called in read-only mode. + * * @param slot * Index of the inventory slot. * @throws This function can throw errors. @@ -605,78 +867,90 @@ export class SimulatedPlayer { * Causes the simulated player to use an item in their * inventory on a block. The block at the specified block * location must be solid. Returns true if the item was used. + * + * This function can't be called in read-only mode. + * * @param slot * Index of the slot to use. * @param blockLocation * Location to use the item upon. * @param direction * Direction to place the specified item within. - * @param faceLocationX - * Block-face-relative X position where to place the item. - * @param faceLocationY - * Block-face-relative Y position where to place the item. + * @param faceLocation + * Location relative to the bottom north-west corner of the + * block where the item is placed. * @throws This function can throw errors. */ useItemInSlotOnBlock( slot: number, blockLocation: minecraftserver.Vector3, direction?: minecraftserver.Direction, - faceLocationX?: number, - faceLocationY?: number, + faceLocation?: minecraftserver.Vector3, ): boolean; /** * @remarks * Causes the simulated player to use an item on a block. The * block at the specified block location must be solid. Returns * true if the item was used. + * + * This function can't be called in read-only mode. + * * @param itemStack * Item to use. * @param blockLocation * Location to use the item upon. * @param direction * Direction to place the specified item within. - * @param faceLocationX - * Block-face-relative X position where to place the item. - * @param faceLocationY - * Block-face-relative Y position where to place the item. + * @param faceLocation + * Location relative to the bottom north-west corner of the + * block where the item is placed. * @throws This function can throw errors. */ useItemOnBlock( itemStack: minecraftserver.ItemStack, blockLocation: minecraftserver.Vector3, direction?: minecraftserver.Direction, - faceLocationX?: number, - faceLocationY?: number, + faceLocation?: minecraftserver.Vector3, ): boolean; } + /** * These well-known tags can be used to classify different * tests into suites to run. */ -// tslint:disable-next-line:no-unnecessary-class export class Tags { - protected constructor(); + private constructor(); /** + * @remarks * Indicates that the tagged test should be a part of all * suites. + * */ static readonly suiteAll = 'suite:all'; /** + * @remarks * Indicates that the tagged test should be a part of an * internal (debug) test suite. + * */ static readonly suiteDebug = 'suite:debug'; /** + * @remarks * Indicates that the tagged test should be a part of the * default test suite. + * */ static readonly suiteDefault = 'suite:default'; /** + * @remarks * Indicates that the tagged test should be a part of a suite * of disabled tests. + * */ static readonly suiteDisabled = 'suite:disabled'; + static readonly suiteNextUpdate = 'suite:nextupdate'; } + /** * Main class for GameTest functions, with helpers and data for * manipulating the respective test. Note that all methods of @@ -684,23 +958,27 @@ export class Tags { * the GameTest structure block. */ export class Test { - protected constructor(); + private constructor(); /** * @remarks * Tests that the condition specified in _condition_ is true. * If not, an error with the specified _message_ is thrown. + * * @param condition * Expression of the condition to evaluate. * @param message * Message that is passed if the _condition_ does not evaluate * to true. * @throws This function can throw errors. + * + * {@link GameTestError} */ assert(condition: boolean, message: string): void; /** * @remarks * Tests that a block of the specified type is present at the * specified location. If it is not, an exception is thrown. + * * @param blockType * Expected block type. * @param blockLocation @@ -710,9 +988,11 @@ export class Test { * specified type is at the location. If false, tests that a * block of the specified type is not present. * @throws This function can throw errors. + * + * {@link GameTestError} */ assertBlockPresent( - blockType: minecraftserver.BlockType, + blockType: minecraftserver.BlockType | string, blockLocation: minecraftserver.Vector3, isPresent?: boolean, ): void; @@ -721,18 +1001,20 @@ export class Test { * Tests that a block has a particular state value at the * specified location. If it does not have that state value, an * exception is thrown. + * * @param blockLocation * Location of the block to test at. * @param callback * Callback function that contains additional tests based on * the block at the specified location. * @throws This function can throw errors. + * + * {@link GameTestError} * @example testIfButtonNotPressed.js * ```typescript - * test.assertBlockState(buttonPos, (block) => { - * return block.permutation.getProperty("button_pressed_bit") == 0; - * }); - * + * test.assertBlockState(buttonPos, (block) => { + * return block.permutation.getProperty("button_pressed_bit") == 0; + * }); * ``` */ assertBlockState(blockLocation: minecraftserver.Vector3, callback: (arg: minecraftserver.Block) => boolean): void; @@ -741,6 +1023,7 @@ export class Test { * Tests that an entity can reach a particular location. * Depending on the value of canReach, throws an exception if * the condition is not met. + * * @param mob * Entity that you wish to test the location against. * @param blockLocation @@ -751,6 +1034,8 @@ export class Test { * false, tests whether the mob is not able to reach the * location. * @throws This function can throw errors. + * + * {@link GameTestError} */ assertCanReachLocation( mob: minecraftserver.Entity, @@ -762,6 +1047,7 @@ export class Test { * Tests that a container (e.g., a chest) at the specified * location contains a specified of item stack. If not, an * error is thrown. + * * @param itemStack * Represents the type of item to check for. The specified * container must contain at least 1 item matching the item @@ -770,22 +1056,28 @@ export class Test { * Location of the block with a container (for example, a * chest) to test the contents of. * @throws This function can throw errors. + * + * {@link GameTestError} */ assertContainerContains(itemStack: minecraftserver.ItemStack, blockLocation: minecraftserver.Vector3): void; /** * @remarks * Tests that a container (e.g., a chest) at the specified * location is empty. If not, an error is thrown. + * * @param blockLocation * Location of the block with a container (for example, a * chest) to test is empty of contents. * @throws This function can throw errors. + * + * {@link GameTestError} */ assertContainerEmpty(blockLocation: minecraftserver.Vector3): void; /** * @remarks * Tests that an entity has a specific piece of armor equipped. * If not, an error is thrown. + * * @param entityTypeIdentifier * Identifier of the entity to match (e.g., * 'minecraft:skeleton'). @@ -801,10 +1093,11 @@ export class Test { * Whether or not the entity is expected to have the specified * armor equipped. * @throws This function can throw errors. + * + * {@link GameTestError} * @example horseArmorTest.js * ```typescript - * test.assertEntityHasArmor("minecraft:horse", armorSlotTorso, "diamond_horse_armor", 0, horseLocation, true); - * + * test.assertEntityHasArmor("minecraft:horse", armorSlotTorso, "diamond_horse_armor", 0, horseLocation, true); * ``` */ assertEntityHasArmor( @@ -819,6 +1112,7 @@ export class Test { * @remarks * Tests that an entity has a particular component. If not, an * exception is thrown. + * * @param entityTypeIdentifier * Identifier of the specified entity (e.g., * 'minecraft:skeleton'). If the namespace is not specified, @@ -833,10 +1127,11 @@ export class Test { * Determines whether to test that the component exists, or * does not. * @throws This function can throw errors. + * + * {@link GameTestError} * @example sheepShearedTest.js * ```typescript - * test.assertEntityHasComponent("minecraft:sheep", "minecraft:is_sheared", entityLoc, false); - * + * test.assertEntityHasComponent("minecraft:sheep", "minecraft:is_sheared", entityLoc, false); * ``` */ assertEntityHasComponent( @@ -851,6 +1146,7 @@ export class Test { * particular entity is present or not present at the specified * location. Depending on the value of isPresent, if the entity * is found or not found, an error is thrown. + * * @param entity * Specific entity to test for. * @param blockLocation @@ -859,6 +1155,8 @@ export class Test { * Whether to test that an entity is present or not present at * the specified location. * @throws This function can throw errors. + * + * {@link GameTestError} */ assertEntityInstancePresent( entity: minecraftserver.Entity, @@ -869,6 +1167,7 @@ export class Test { * @remarks * Tests that an entity instance is present within the GameTest * area. If not, an exception is thrown. + * * @param entity * Entity instance to test for. * @param isPresent @@ -876,25 +1175,28 @@ export class Test { * present in the GameTest area. If false, tests that the * specified entity is not present. * @throws This function can throw errors. + * + * {@link GameTestError} * @example simpleMobTest.ts * ```typescript - * gt.register("StarterTests", "simpleMobTest", (test: gt.Test) => { - * const attackerId = "fox"; - * const victimId = "chicken"; - * - * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); - * let victim = test.spawn(victimId, { x: 2, y: 2, z: 2 }); + * import * as gameTest from '@minecraft/server-gametest'; * - * test.assertEntityInstancePresentInArea(victim, true); + * gameTest + * .register('StarterTests', 'simpleMobTest', (test: gameTest.Test) => { + * const attackerId = 'fox'; + * const victimId = 'chicken'; * - * test.succeedWhen(() => { - * test.assertEntityInstancePresentInArea(victim, false); - * }); - * }) - * .maxTicks(400) - * .structureName("gametests:mediumglass"); + * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); + * const victim = test.spawn(victimId, { x: 2, y: 2, z: 2 }); * + * test.assertEntityInstancePresentInArea(victim, true); * + * test.succeedWhen(() => { + * test.assertEntityInstancePresentInArea(victim, false); + * }); + * }) + * .maxTicks(400) + * .structureName('gametests:mediumglass'); * ``` */ assertEntityInstancePresentInArea(entity: minecraftserver.Entity, isPresent?: boolean): void; @@ -904,6 +1206,7 @@ export class Test { * or non-presence of entity of a specified type at a * particular location. If the condition is not met, an * exception is thrown. + * * @param entityTypeIdentifier * Type of entity to test for (e.g., 'minecraft:skeleton'). If * an entity namespace is not specified, 'minecraft:' is @@ -918,6 +1221,8 @@ export class Test { * specified type is present. If false, tests that an entity of * the specified type is not present. * @throws This function can throw errors. + * + * {@link GameTestError} */ assertEntityPresent( entityTypeIdentifier: string, @@ -929,6 +1234,7 @@ export class Test { * @remarks * Tests that an entity of a specified type is present within * the GameTest area. If not, an exception is thrown. + * * @param entityTypeIdentifier * Type of entity to test for (e.g., 'minecraft:skeleton'). If * an entity namespace is not specified, 'minecraft:' is @@ -938,25 +1244,28 @@ export class Test { * specified type is present in the GameTest area. If false, * tests that an entity of the specified type is not present. * @throws This function can throw errors. + * + * {@link GameTestError} * @example simpleMobTest.ts * ```typescript - * gt.register("StarterTests", "simpleMobTest", (test: gt.Test) => { - * const attackerId = "fox"; - * const victimId = "chicken"; + * import * as gameTest from '@minecraft/server-gametest'; * - * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); - * test.spawn(victimId, { x: 2, y: 2, z: 2 }); + * gameTest + * .register('StarterTests', 'simpleMobTest', (test: gameTest.Test) => { + * const attackerId = 'fox'; + * const victimId = 'chicken'; * - * test.assertEntityPresentInArea(victimId, true); - * - * test.succeedWhen(() => { - * test.assertEntityPresentInArea(victimId, false); - * }); - * }) - * .maxTicks(400) - * .structureName("gametests:mediumglass"); + * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); + * test.spawn(victimId, { x: 2, y: 2, z: 2 }); * + * test.assertEntityPresentInArea(victimId, true); * + * test.succeedWhen(() => { + * test.assertEntityPresentInArea(victimId, false); + * }); + * }) + * .maxTicks(400) + * .structureName('gametests:mediumglass'); * ``` */ assertEntityPresentInArea(entityTypeIdentifier: string, isPresent?: boolean): void; @@ -965,6 +1274,7 @@ export class Test { * Tests that an entity (e.g., a skeleton) at the specified * location has a particular piece of data. If not, an error is * thrown. + * * @param blockLocation * Location of the entity to look for. * @param entityTypeIdentifier @@ -977,14 +1287,15 @@ export class Test { * entity with the specified identifier is found, an exception * is thrown. * @throws This function can throw errors. + * + * {@link GameTestError} * @example villagerEffectTest.js * ```typescript - * test.assertEntityState( - * villagerPos, - * "minecraft:villager_v2", - * (entity) => entity.getEffect(MinecraftEffectTypes.regeneration).duration > 120 - * ); // At least 6 seconds remaining in the villagers' effect - * + * test.assertEntityState( + * villagerPos, + * "minecraft:villager_v2", + * (entity) => entity.getEffect(MinecraftEffectTypes.Regeneration).duration > 120 + * ); // At least 6 seconds remaining in the villagers' effect * ``` */ assertEntityState( @@ -997,6 +1308,7 @@ export class Test { * Depending on the value of isTouching, tests that an entity * of a specified type is touching or connected to another * entity. If the condition is not met, an exception is thrown. + * * @param entityTypeIdentifier * Type of entity to test for (e.g., 'minecraft:skeleton'). If * an entity namespace is not specified, 'minecraft:' is @@ -1008,6 +1320,8 @@ export class Test { * the specified location. If false, tests that an entity is * not testing the specified location. * @throws This function can throw errors. + * + * {@link GameTestError} */ assertEntityTouching(entityTypeIdentifier: string, location: minecraftserver.Vector3, isTouching?: boolean): void; /** @@ -1016,18 +1330,22 @@ export class Test { * at a location contains water. If the condition is not met, * an error is thrown. Pure water blocks are not considered to * be waterlogged. + * * @param blockLocation * Location of the block to test for. * @param isWaterlogged * Whether to test that the block at _position_ is expected to * be waterlogged. * @throws This function can throw errors. + * + * {@link GameTestError} */ assertIsWaterlogged(blockLocation: minecraftserver.Vector3, isWaterlogged?: boolean): void; /** * @remarks * Tests that items of a particular type and count are present * within an area. If not, an error is thrown. + * * @param itemType * Type of item to look for. * @param blockLocation @@ -1038,14 +1356,15 @@ export class Test { * @param count * Number of items, at minimum, to look and test for. * @throws This function can throw errors. + * + * {@link GameTestError} * @example findFeathers.js * ```typescript - * test.assertItemEntityCountIs(Items.feather, expectedFeatherLoc, 0, 1); - * + * test.assertItemEntityCountIs(Items.feather, expectedFeatherLoc, 0, 1); * ``` */ assertItemEntityCountIs( - itemType: minecraftserver.ItemType, + itemType: minecraftserver.ItemType | string, blockLocation: minecraftserver.Vector3, searchDistance: number, count: number, @@ -1056,6 +1375,7 @@ export class Test { * particular item entity is present or not at a particular * location. If the condition is not met, an exception is * thrown. + * * @param itemType * Type of item to test for. * @param blockLocation @@ -1067,9 +1387,11 @@ export class Test { * specified type is present. If false, tests that an item * entity of the specified type is not present. * @throws This function can throw errors. + * + * {@link GameTestError} */ assertItemEntityPresent( - itemType: minecraftserver.ItemType, + itemType: minecraftserver.ItemType | string, blockLocation: minecraftserver.Vector3, searchDistance?: number, isPresent?: boolean, @@ -1078,26 +1400,35 @@ export class Test { * @remarks * Tests that Redstone power at a particular location matches a * particular value. If not, an exception is thrown. + * * @param blockLocation * Location to test. * @param power * Expected power level. * @throws This function can throw errors. + * + * {@link GameTestError} */ assertRedstonePower(blockLocation: minecraftserver.Vector3, power: number): void; /** * @remarks * Destroys a block at a particular location. + * + * This function can't be called in read-only mode. + * * @param blockLocation * Location of the block to destroy. * @param dropResources * Whether to add resources exposed with a particular drop. * @throws This function can throw errors. + * + * {@link GameTestError} */ destroyBlock(blockLocation: minecraftserver.Vector3, dropResources?: boolean): void; /** * @remarks * Marks the current test as a failure case. + * * @param errorMessage * Error message summarizing the failure condition. * @throws This function can throw errors. @@ -1107,6 +1438,7 @@ export class Test { * @remarks * Runs the given callback. If the callback does not throw an * exception, the test is marked as a failure. + * * @param callback * Callback function that runs. If the function runs * successfully, the test is marked as a failure. Typically, @@ -1117,15 +1449,23 @@ export class Test { /** * @remarks * Gets a block at the specified block location. + * + * This function can't be called in read-only mode. + * * @param blockLocation * Location of the block to retrieve. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} */ getBlock(blockLocation: minecraftserver.Vector3): minecraftserver.Block; /** * @remarks * Gets the dimension of this test. + * * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} */ getDimension(): minecraftserver.Dimension; /** @@ -1133,31 +1473,48 @@ export class Test { * If the block at the specified block location is a fence, * this returns a helper object with details on how a fence is * connected. + * + * This function can't be called in read-only mode. + * * @param blockLocation * Location of the block to retrieve. * @throws This function can throw errors. + * + * {@link GameTestError} */ getFenceConnectivity(blockLocation: minecraftserver.Vector3): FenceConnectivity; /** * @remarks * Retrieves a sculk spreader object that can be used to * control and manage how sculk grows from a block. + * + * This function can't be called in read-only mode. + * * @param blockLocation * Location of the block to retrieve a sculk spreader from. + * @returns + * Returns the SculkSpreader or undefined if no SculkSpreader + * is present on the block. * @throws This function can throw errors. + * + * {@link GameTestError} */ - getSculkSpreader(blockLocation: minecraftserver.Vector3): SculkSpreader; + getSculkSpreader(blockLocation: minecraftserver.Vector3): SculkSpreader | undefined; /** * @remarks * Returns the direction of the current test - see the {@link * @minecraft/server.Direction} enum for more information on * potential values (north, east, south, west - values 2-5). + * */ getTestDirection(): minecraftserver.Direction; /** * @remarks * This asynchronous function will wait for the specified time * in ticks before continuing execution. + * + * This function can't be called in read-only mode. + * * @param tickDelay * Amount of time to wait, in ticks. */ @@ -1165,47 +1522,80 @@ export class Test { /** * @remarks * Kills all entities within the GameTest structure. + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. + * + * {@link GameTestError} */ killAllEntities(): void; + /** + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + * + * {@link GameTestError} + */ onPlayerJump(mob: minecraftserver.Entity, jumpAmount: number): void; /** * @remarks * Presses a button at a block location. + * + * This function can't be called in read-only mode. + * * @param blockLocation * Location to push the button at. * @throws * Will throw an error if a button is not present at the * specified position. + * + * {@link GameTestError} */ pressButton(blockLocation: minecraftserver.Vector3): void; /** * @remarks * Displays the specified message to all players. + * + * This function can't be called in read-only mode. + * * @param text * Message to display. * @throws This function can throw errors. + * + * {@link GameTestError} */ print(text: string): void; /** * @remarks * Pulls a lever at a block location. + * + * This function can't be called in read-only mode. + * * @param blockLocation * Location to pull the lever at. * @throws * Will throw an error if a lever is not present at the * specified position. + * + * {@link GameTestError} */ pullLever(blockLocation: minecraftserver.Vector3): void; /** * @remarks * Sends a Redstone pulse at a particular location by creating * a temporary Redstone block. + * + * This function can't be called in read-only mode. + * * @param blockLocation * Location to pulse Redstone at. * @param duration * Number of ticks to pulse Redstone. * @throws This function can throw errors. + * + * {@link GameTestError} */ pulseRedstone(blockLocation: minecraftserver.Vector3, duration: number): void; /** @@ -1215,12 +1605,15 @@ export class Test { * block. For example, the relative coordinates for the block * above the structure block are (0, 1, 0). Rotation of the * GameTest structure is also taken into account. + * * @param worldBlockLocation * Absolute location in the world to convert to a relative * location. * @returns * A location relative to the GameTest command block. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} */ relativeBlockLocation(worldBlockLocation: minecraftserver.Vector3): minecraftserver.Vector3; /** @@ -1230,17 +1623,25 @@ export class Test { * example, the relative coordinates for the block above the * structure block are (0, 1, 0). Rotation of the GameTest * structure is also taken into account. + * + * This function can't be called in read-only mode. + * * @param worldLocation * Absolute location in the world to convert to a relative * location. * @returns * A location relative to the GameTest command block. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} */ relativeLocation(worldLocation: minecraftserver.Vector3): minecraftserver.Vector3; /** * @remarks * Removes a simulated player from the world. + * + * This function can't be called in read-only mode. + * * @param simulatedPlayer * Simulated player to remove. */ @@ -1251,22 +1652,34 @@ export class Test { * the current test. Passing in Direction.south will return the * test direction; Passing in Direction.north will return the * opposite of the test direction, and so on. + * + * This function can't be called in read-only mode. + * * @param direction * Direction to translate into a direction relative to the * GameTest facing. Passing in Direction.south will return the * test direction; Passing in Direction.north will return the * opposite of the test direction, and so on. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} */ rotateDirection(direction: minecraftserver.Direction): minecraftserver.Direction; /** - * @param vector + * @remarks + * This function can't be called in read-only mode. + * * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} */ - rotateVector(vector: minecraftserver.Vector): minecraftserver.Vector; + rotateVector(vector: minecraftserver.Vector3): minecraftserver.Vector3; /** * @remarks * Runs a specific callback after a specified delay of ticks + * + * This function can't be called in read-only mode. + * * @param delayTicks * Number of ticks to delay before running the specified * callback. @@ -1279,6 +1692,9 @@ export class Test { * @remarks * Runs the given callback after a delay of _tick_ ticks from * the start of the GameTest. + * + * This function can't be called in read-only mode. + * * @param tick * Tick (after the start of the GameTest) to run the callback * at. @@ -1291,83 +1707,108 @@ export class Test { * @remarks * Sets a block to a particular configuration (a * BlockPermutation) at the specified block location. + * + * This function can't be called in read-only mode. + * * @param blockData * Permutation that contains the configuration data for a * block. * @param blockLocation * Location of the block to set. * @throws This function can throw errors. + * + * {@link GameTestError} */ setBlockPermutation(blockData: minecraftserver.BlockPermutation, blockLocation: minecraftserver.Vector3): void; /** * @remarks * Sets a block to a particular type at the specified block * location. + * + * This function can't be called in read-only mode. + * * @param blockType * Type of block to set. * @param blockLocation * Location of the block to set. * @throws This function can throw errors. + * + * {@link GameTestError} */ - setBlockType(blockType: minecraftserver.BlockType, blockLocation: minecraftserver.Vector3): void; + setBlockType(blockType: minecraftserver.BlockType | string, blockLocation: minecraftserver.Vector3): void; /** * @remarks * For blocks that are fluid containers - like a cauldron - * changes the type of fluid within that container. + * + * This function can't be called in read-only mode. + * * @param location * Location of the fluid container block. * @param type * Type of fluid to set. See {@link * @minecraft/server-gametest.FluidType} for a list of values. * @throws This function can throw errors. + * + * {@link GameTestError} */ setFluidContainer(location: minecraftserver.Vector3, type: minecraftserver.FluidType): void; /** * @remarks * Sets the fuse of an explodable entity. + * + * This function can't be called in read-only mode. + * * @param entity * Entity that is explodable. * @param fuseLength * Length of time, in ticks, before the entity explodes. * @throws This function can throw errors. + * + * {@link GameTestError} */ setTntFuse(entity: minecraftserver.Entity, fuseLength: number): void; /** * @remarks * Spawns an entity at a location. + * + * This function can't be called in read-only mode. + * * @param entityTypeIdentifier * Type of entity to create. If no namespace is provided, * 'minecraft:' is assumed. Note that an optional initial spawn * event can be specified between less than/greater than signs - * (e.g., namespace:entityType\). - * @param blockLocation + * (e.g., namespace:entityType\). * @returns * The spawned entity. If the entity cannot be spawned, returns * undefined. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} * @example simpleMobTest.ts * ```typescript - * gt.register("StarterTests", "simpleMobTest", (test: gt.Test) => { - * const attackerId = "fox"; - * const victimId = "chicken"; + * import * as gameTest from '@minecraft/server-gametest'; * - * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); - * test.spawn(victimId, { x: 2, y: 2, z: 2 }); + * gameTest + * .register('StarterTests', 'simpleMobTest', (test: gameTest.Test) => { + * const attackerId = 'fox'; + * const victimId = 'chicken'; * - * test.assertEntityPresentInArea(victimId, true); + * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); + * test.spawn(victimId, { x: 2, y: 2, z: 2 }); * - * test.succeedWhen(() => { - * test.assertEntityPresentInArea(victimId, false); - * }); - * }) - * .maxTicks(400) - * .structureName("gametests:mediumglass"); + * test.assertEntityPresentInArea(victimId, true); * + * test.succeedWhen(() => { + * test.assertEntityPresentInArea(victimId, false); + * }); + * }) + * .maxTicks(400) + * .structureName('gametests:mediumglass'); * ``` * @example spawnAdultPig.js * ```typescript - * test.spawn("minecraft:pig", { x: 1, y: 2, z: 1 }); - * + * test.spawn("minecraft:pig", { x: 1, y: 2, z: 1 }); * * ``` */ @@ -1375,52 +1816,62 @@ export class Test { /** * @remarks * Spawns an entity at a location. + * + * This function can't be called in read-only mode. + * * @param entityTypeIdentifier * Type of entity to create. If no namespace is provided, * 'minecraft:' is assumed. Note that an optional initial spawn * event can be specified between less than/greater than signs - * (e.g., namespace:entityType\). - * @param location + * (e.g., namespace:entityType\). * @returns * The spawned entity. If the entity cannot be spawned, returns * undefined. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} * @example spawnAdultPig.js * ```typescript - * test.spawn("minecraft:pig", { x: 1.5, y: 2, z: 1.5 }); - * + * test.spawn("minecraft:pig", { x: 1.5, y: 2, z: 1.5 }); * ``` */ spawnAtLocation(entityTypeIdentifier: string, location: minecraftserver.Vector3): minecraftserver.Entity; /** * @remarks * Spawns an item entity at a specified location. + * + * This function can't be called in read-only mode. + * * @param itemStack * ItemStack that describes the item entity to create. * @param location * Location to create the item entity at. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} * @example spawnEmeralds.js * ```typescript - * const oneEmerald = new ItemStack(MinecraftItemTypes.emerald, 1, 0); - * const fiveEmeralds = new ItemStack(MinecraftItemTypes.emerald, 5, 0); - * - * test.spawnItem(oneEmerald, { x: 3.5, y: 3, z: 1.5 }); - * test.spawnItem(fiveEmeralds, { x: 1.5, y: 3, z: 1.5 }); - * + * const oneEmerald = new ItemStack(MinecraftItemTypes.Emerald, 1, 0); + * const fiveEmeralds = new ItemStack(MinecraftItemTypes.Emerald, 5, 0); * + * test.spawnItem(oneEmerald, { x: 3.5, y: 3, z: 1.5 }); + * test.spawnItem(fiveEmeralds, { x: 1.5, y: 3, z: 1.5 }); * ``` */ spawnItem(itemStack: minecraftserver.ItemStack, location: minecraftserver.Vector3): minecraftserver.Entity; /** * @remarks * Creates a new simulated player within the world. + * + * This function can't be called in read-only mode. + * * @param blockLocation * Location where to spawn the simulated player. * @param name * Name to give the new simulated player. - * @param gameMode * @throws This function can throw errors. + * + * {@link GameTestError} */ spawnSimulatedPlayer( blockLocation: minecraftserver.Vector3, @@ -1432,10 +1883,14 @@ export class Test { * Spawns an entity at a location without any AI behaviors. * This method is frequently used in conjunction with methods * like .walkTo to create predictable mob actions. - * @param entityTypeIdentifier + * + * This function can't be called in read-only mode. + * * @param blockLocation * Location where the entity should be spawned. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} */ spawnWithoutBehaviors(entityTypeIdentifier: string, blockLocation: minecraftserver.Vector3): minecraftserver.Entity; /** @@ -1443,10 +1898,14 @@ export class Test { * Spawns an entity at a location without any AI behaviors. * This method is frequently used in conjunction with methods * like .walkTo to create predictable mob actions. - * @param entityTypeIdentifier + * + * This function can't be called in read-only mode. + * * @param location * Location where the entity should be spawned. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} */ spawnWithoutBehaviorsAtLocation( entityTypeIdentifier: string, @@ -1456,6 +1915,9 @@ export class Test { * @remarks * Tests that a particular item entity is present at a * particular location. If not, an exception is thrown. + * + * This function can't be called in read-only mode. + * * @param blockLocation * BlockLocation containing a multiface block. * @param fromFace @@ -1464,10 +1926,11 @@ export class Test { * Direction to spread. Use the Minecraft.Direction enum to * specify a direction. * @throws This function can throw errors. + * + * {@link GameTestError} * @example spreadFromFaceTowardDirection.js * ```typescript - * test.spreadFromFaceTowardDirection({ x: 1, y: 2, z: 1 }, Direction.south, Direction.down); - * + * test.spreadFromFaceTowardDirection({ x: 1, y: 2, z: 1 }, Direction.south, Direction.down); * ``` */ spreadFromFaceTowardDirection( @@ -1479,6 +1942,9 @@ export class Test { * @remarks * Creates a new GameTestSequence - A set of steps that play * out sequentially within a GameTest. + * + * This function can't be called in read-only mode. + * * @returns * A new GameTestSequence with chaining methods that facilitate * creating a set of steps. @@ -1487,6 +1953,9 @@ export class Test { /** * @remarks * Marks the current test as a success case. + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ succeed(): void; @@ -1494,6 +1963,9 @@ export class Test { * @remarks * Runs the given callback. If the callback does not throw an * exception, the test is marked as a success. + * + * This function can't be called in read-only mode. + * * @param callback * Callback function that runs. If the function runs * successfully, the test is marked as a success. Typically, @@ -1504,6 +1976,9 @@ export class Test { /** * @remarks * Marks the test as a success at the specified tick. + * + * This function can't be called in read-only mode. + * * @param tick * Tick after the start of the GameTest to mark the test as * successful. @@ -1515,6 +1990,9 @@ export class Test { * Runs the given callback at _tick_ ticks after the start of * the test. If the callback does not throw an exception, the * test is marked as a failure. + * + * This function can't be called in read-only mode. + * * @param tick * Tick after the start of the GameTest to run the testing * callback at. @@ -1530,29 +2008,33 @@ export class Test { * successfully executes, the test is marked as a success. * Specifically, the test will succeed when the callback does * not throw an exception. + * + * This function can't be called in read-only mode. + * * @param callback * Testing callback function that runs. If the function runs * successfully, the test is marked as a success. * @throws This function can throw errors. * @example simpleMobTest.ts * ```typescript - * gt.register("StarterTests", "simpleMobTest", (test: gt.Test) => { - * const attackerId = "fox"; - * const victimId = "chicken"; - * - * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); - * test.spawn(victimId, { x: 2, y: 2, z: 2 }); + * import * as gameTest from '@minecraft/server-gametest'; * - * test.assertEntityPresentInArea(victimId, true); + * gameTest + * .register('StarterTests', 'simpleMobTest', (test: gameTest.Test) => { + * const attackerId = 'fox'; + * const victimId = 'chicken'; * - * test.succeedWhen(() => { - * test.assertEntityPresentInArea(victimId, false); - * }); - * }) - * .maxTicks(400) - * .structureName("gametests:mediumglass"); + * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); + * test.spawn(victimId, { x: 2, y: 2, z: 2 }); * + * test.assertEntityPresentInArea(victimId, true); * + * test.succeedWhen(() => { + * test.assertEntityPresentInArea(victimId, false); + * }); + * }) + * .maxTicks(400) + * .structureName('gametests:mediumglass'); * ``` */ succeedWhen(callback: () => void): void; @@ -1562,6 +2044,9 @@ export class Test { * presence of a block of a particular type on every tick. When * the specified block of a type is found or not found * (depending on isPresent), the test is marked as a success. + * + * This function can't be called in read-only mode. + * * @param blockType * Type of block to test for. * @param blockLocation @@ -1571,9 +2056,11 @@ export class Test { * specified type is present. If false, tests that a block of * the specified type is not present. * @throws This function can throw errors. + * + * {@link GameTestError} */ succeedWhenBlockPresent( - blockType: minecraftserver.BlockType, + blockType: minecraftserver.BlockType | string, blockLocation: minecraftserver.Vector3, isPresent?: boolean, ): void; @@ -1582,6 +2069,9 @@ export class Test { * Tests for the presence of a component on every tick. * Depending on the value of hasComponent, when the specified * component is found, the test is marked as a success. + * + * This function can't be called in read-only mode. + * * @param entityTypeIdentifier * Type of entity to look for. If no namespace is specified, * 'minecraft:' is assumed. @@ -1608,6 +2098,9 @@ export class Test { * of an entity on every tick. When an entity of the specified * type is found or not found (depending on isPresent), the * test is marked as a success. + * + * This function can't be called in read-only mode. + * * @param entityTypeIdentifier * Type of entity to test for (e.g., 'minecraft:skeleton'). If * an entity namespace is not specified, 'minecraft:' is @@ -1629,14 +2122,17 @@ export class Test { * @remarks * Triggers a block event from a fixed list of available block * events. - * @param blockLocation + * + * This function can't be called in read-only mode. + * * @param event * Event to trigger. Valid values include minecraft:drip, * minecraft:grow_stalagtite, minecraft:grow_stalagmite, * minecraft:grow_up, minecraft:grow_down and * minecraft:grow_sideways. - * @param eventParameters * @throws This function can throw errors. + * + * {@link GameTestError} */ triggerInternalBlockEvent(blockLocation: minecraftserver.Vector3, event: string, eventParameters?: number[]): void; /** @@ -1645,6 +2141,9 @@ export class Test { * specified callback successfully completes. until can be used * in conjunction with .assert functions to evaluate that a * condition is true. + * + * This function can't be called in read-only mode. + * * @param callback * Function with code to evaluate. */ @@ -1655,6 +2154,9 @@ export class Test { * in conjunction with methods like .spawnWithoutBehaviors to * have more predictable mob behaviors. Mobs will stop * navigation as soon as they intersect the target location. + * + * This function can't be called in read-only mode. + * * @param mob * Mob entity to give orders to. * @param blockLocation @@ -1662,6 +2164,8 @@ export class Test { * @param speedModifier * Adjustable modifier to the mob's walking speed. * @throws This function can throw errors. + * + * {@link GameTestError} */ walkTo(mob: minecraftserver.Entity, blockLocation: minecraftserver.Vector3, speedModifier?: number): void; /** @@ -1670,6 +2174,9 @@ export class Test { * in conjunction with methods like .spawnWithoutBehaviors to * have more predictable mob behaviors. Mobs will stop * navigation as soon as they intersect the target location. + * + * This function can't be called in read-only mode. + * * @param mob * Mob entity to give orders to. * @param location @@ -1677,6 +2184,8 @@ export class Test { * @param speedModifier * Adjustable modifier to the mob's walking speed. * @throws This function can throw errors. + * + * {@link GameTestError} */ walkToLocation(mob: minecraftserver.Entity, location: minecraftserver.Vector3, speedModifier?: number): void; /** @@ -1685,11 +2194,14 @@ export class Test { * GameTest structure block, returns a new BlockLocation with * coordinates relative to world. Rotation of the GameTest * structure is also taken into account. + * * @param relativeBlockLocation * Location relative to the GameTest command block. * @returns * An absolute location relative to the GameTest command block. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} */ worldBlockLocation(relativeBlockLocation: minecraftserver.Vector3): minecraftserver.Vector3; /** @@ -1698,19 +2210,45 @@ export class Test { * structure block, returns a new location with coordinates * relative to world. Rotation of the GameTest structure is * also taken into account. + * * @param relativeLocation * Location relative to the GameTest command block. * @returns * An absolute location relative to the GameTest command block. * @throws This function can throw errors. + * + * {@link minecraftserver.GameTestError} */ worldLocation(relativeLocation: minecraftserver.Vector3): minecraftserver.Vector3; } + +export interface GameTestErrorContext { + absolutePosition: minecraftserver.Vector3; + relativePosition: minecraftserver.Vector3; + tickCount: number; +} + +export interface MoveToOptions { + faceTarget?: boolean; + speed?: number; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export class GameTestError extends Error { + private constructor(); + context?: GameTestErrorContext; + messageParameters: string[]; + type: GameTestErrorType; +} + /** * @remarks * Registers a new GameTest function. This GameTest will become * available in Minecraft via /gametest run * [testClassName]:[testName]. + * + * This function can't be called in read-only mode. + * * @param testClassName * Name of the class of tests this test should be a part of. * @param testName @@ -1721,31 +2259,26 @@ export class Test { * Returns a {@link RegistrationBuilder} object where * additional options for this test can be specified via * builder methods. - * @example example1.js - * ```typescript - * GameTest.register("ExampleTests", "alwaysFail", (test) => { - * test.fail("This test, runnable via '/gametest run ExampleTests:alwaysFail', will always fail"); - * }); - * - * ``` * @example simpleMobTest.ts * ```typescript - * gt.register("StarterTests", "simpleMobTest", (test: gt.Test) => { - * const attackerId = "fox"; - * const victimId = "chicken"; + * import * as gameTest from '@minecraft/server-gametest'; * - * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); - * test.spawn(victimId, { x: 2, y: 2, z: 2 }); + * gameTest + * .register('StarterTests', 'simpleMobTest', (test: gameTest.Test) => { + * const attackerId = 'fox'; + * const victimId = 'chicken'; * - * test.assertEntityPresentInArea(victimId, true); + * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); + * test.spawn(victimId, { x: 2, y: 2, z: 2 }); * - * test.succeedWhen(() => { - * test.assertEntityPresentInArea(victimId, false); - * }); - * }) - * .maxTicks(400) - * .structureName("gametests:mediumglass"); + * test.assertEntityPresentInArea(victimId, true); * + * test.succeedWhen(() => { + * test.assertEntityPresentInArea(victimId, false); + * }); + * }) + * .maxTicks(400) + * .structureName('gametests:mediumglass'); * ``` */ export function register( @@ -1758,6 +2291,9 @@ export function register( * Registers a new GameTest function that is designed for * asynchronous execution. This GameTest will become available * in Minecraft via /gametest run [testClassName]:[testName]. + * + * This function can't be called in read-only mode. + * * @param testClassName * Name of the class of tests this test should be a part of. * @param testName @@ -1768,6 +2304,27 @@ export function register( * Returns a {@link RegistrationBuilder} object where * additional options for this test can be specified via * builder methods. + * @example simpleMobAsyncTest.ts + * ```typescript + * import * as gameTest from '@minecraft/server-gametest'; + * + * gameTest + * .registerAsync('StarterTests', 'simpleMobTest', async (test: gameTest.Test) => { + * const attackerId = 'fox'; + * const victimId = 'chicken'; + * + * test.spawn(attackerId, { x: 5, y: 2, z: 5 }); + * test.spawn(victimId, { x: 2, y: 2, z: 2 }); + * + * test.assertEntityPresentInArea(victimId, true); + * + * test.succeedWhen(() => { + * test.assertEntityPresentInArea(victimId, false); + * }); + * }) + * .maxTicks(400) + * .structureName('gametests:mediumglass'); + * ``` */ export function registerAsync( testClassName: string, diff --git a/static/typedoc/stable/server-net.d.ts b/static/typedoc/stable/server-net.d.ts index 8ad6428678..14f0275991 100644 --- a/static/typedoc/stable/server-net.d.ts +++ b/static/typedoc/stable/server-net.d.ts @@ -17,56 +17,95 @@ * ```json * { * "module_name": "@minecraft/server-net", - * "version": "1.0.0-beta.1.19.70-stable" + * "version": "1.0.0-beta.1.20.80-stable" * } * ``` * */ +import * as minecraftcommon from '@minecraft/common'; 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', + 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', + 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', + 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', + 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', + Put = 'Put', } + +/** + * @example simpleHttpRequest.ts + * ```typescript + * import { HttpRequest, HttpHeader, HttpRequestMethod, http } from '@minecraft/server-net'; + * + * async function updateScore() { + * const req = new HttpRequest('http://localhost:3000/updateScore'); + * + * req.body = JSON.stringify({ + * score: 22, + * }); + * + * req.method = HttpRequestMethod.Post; + * req.headers = [ + * new HttpHeader('Content-Type', 'application/json'), + * new HttpHeader('auth', 'my-auth-token'), + * ]; + * + * await http.request(req); + * } + * ``` + */ export class HttpClient { - protected constructor(); + private constructor(); /** * @remarks * Cancels all pending requests. - * @param reason + * + * 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 @@ -76,53 +115,146 @@ export class HttpClient { /** * @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. + * @example simpleHttpRequest.ts + * ```typescript + * import { HttpRequest, HttpHeader, HttpRequestMethod, http } from '@minecraft/server-net'; + * + * async function updateScore() { + * const req = new HttpRequest('http://localhost:3000/updateScore'); + * + * req.body = JSON.stringify({ + * score: 22, + * }); + * + * req.method = HttpRequestMethod.Post; + * req.headers = [ + * new HttpHeader('Content-Type', 'application/json'), + * new HttpHeader('auth', 'my-auth-token'), + * ]; + * + * await http.request(req); + * } + * ``` */ request(config: HttpRequest): Promise; } + /** * Represents an HTTP header - a key/value pair of * meta-information about a request. + * @example simpleHttpRequest.ts + * ```typescript + * import { HttpRequest, HttpHeader, HttpRequestMethod, http } from '@minecraft/server-net'; + * + * async function updateScore() { + * const req = new HttpRequest('http://localhost:3000/updateScore'); + * + * req.body = JSON.stringify({ + * score: 22, + * }); + * + * req.method = HttpRequestMethod.Post; + * req.headers = [ + * new HttpHeader('Content-Type', 'application/json'), + * new HttpHeader('auth', 'my-auth-token'), + * ]; + * + * await http.request(req); + * } + * ``` */ 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. + * @example simpleHttpRequest.ts + * ```typescript + * import { HttpRequest, HttpHeader, HttpRequestMethod, http } from '@minecraft/server-net'; + * + * async function updateScore() { + * const req = new HttpRequest('http://localhost:3000/updateScore'); + * + * req.body = JSON.stringify({ + * score: 22, + * }); + * + * req.method = HttpRequestMethod.Post; + * req.headers = [ + * new HttpHeader('Content-Type', 'application/json'), + * new HttpHeader('auth', 'my-auth-token'), + * ]; + * + * await http.request(req); + * } + * ``` */ 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); @@ -130,55 +262,77 @@ export class HttpRequest { * @remarks * Adds an additional header to the overall list of headers * used in the corresponding HTTP request. - * @param key - * @param value + * + * 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. - * @param body + * + * 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. - * @param headers + * + * 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. - * @param method + * + * 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 { - protected constructor(); + 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/static/typedoc/stable/server-ui.d.ts b/static/typedoc/stable/server-ui.d.ts index 26ae5a0c92..25511c830b 100644 --- a/static/typedoc/stable/server-ui.d.ts +++ b/static/typedoc/stable/server-ui.d.ts @@ -7,7 +7,6 @@ Copyright (c) Microsoft Corporation. ***************************************************************************** */ /** - * @beta * @packageDocumentation * The `@minecraft/server-ui` module contains types for * expressing simple dialog-based user experiences. @@ -37,47 +36,80 @@ * dimension.runCommand("say I like April too!"); * } * }); - * * ``` * * Manifest Details * ```json * { * "module_name": "@minecraft/server-ui", - * "version": "0.1.0" + * "version": "1.1.0" * } * ``` * */ +import * as minecraftcommon from '@minecraft/common'; import * as minecraftserver from '@minecraft/server'; export enum FormCancelationReason { - userBusy = 'userBusy', - userClosed = 'userClosed', + 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. + * @example actionFormAskFavoriteMonth.ts + * ```typescript + * import { Player } from '@minecraft/server'; + * import { ActionFormData, ActionFormResponse } from '@minecraft/server-ui'; + * + * function askFavoriteMonth(player: Player) { + * const form = new ActionFormData() + * .title('Months') + * .body('Choose your favorite month!') + * .button('January') + * .button('February') + * .button('March') + * .button('April') + * .button('May'); + * + * form.show(player).then((response: ActionFormResponse) => { + * if (response.selection === 3) { + * player.sendMessage('I like April too!'); + * } else { + * player.sendMessage('Nah, April is the best.'); + * } + * }); + * } + * ``` */ export class ActionFormData { /** * @remarks * Method that sets the body text for the modal form. - * @param bodyText + * */ - body(bodyText: string): ActionFormData; + body(bodyText: minecraftserver.RawMessage | string): ActionFormData; /** * @remarks * Adds a button to this form with an icon from a resource * pack. - * @param text - * @param iconPath + * */ - button(text: string, iconPath?: string): ActionFormData; + 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. @@ -86,74 +118,129 @@ export class ActionFormData { /** * @remarks * This builder method sets the title for the modal dialog. - * @param titleText + * */ - title(titleText: string): ActionFormData; + title(titleText: minecraftserver.RawMessage | string): ActionFormData; } + /** * Returns data about the player results from a modal action * form. + * @example actionFormAskFavoriteMonth.ts + * ```typescript + * import { Player } from '@minecraft/server'; + * import { ActionFormData, ActionFormResponse } from '@minecraft/server-ui'; + * + * function askFavoriteMonth(player: Player) { + * const form = new ActionFormData() + * .title('Months') + * .body('Choose your favorite month!') + * .button('January') + * .button('February') + * .button('March') + * .button('April') + * .button('May'); + * + * form.show(player).then((response: ActionFormResponse) => { + * if (response.selection === 3) { + * player.sendMessage('I like April too!'); + * } else { + * player.sendMessage('Nah, April is the best.'); + * } + * }); + * } + * ``` */ +// @ts-ignore Class inheritance allowed for native defined classes export class ActionFormResponse extends FormResponse { - protected constructor(); - /** - * Contains additional details as to why a form was canceled. - */ - readonly cancelationReason?: FormCancelationReason; - /** - * If true, the form was canceled by the player (e.g., they - * selected the pop-up X close button). - */ - readonly canceled: boolean; + private constructor(); /** + * @remarks * Returns the index of the button that was pushed. + * */ readonly selection?: number; } + /** * Base type for a form response. */ export class FormResponse { - protected constructor(); + 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. + * @example messageFormSimple.ts + * ```typescript + * import { Player } from '@minecraft/server'; + * import { MessageFormResponse, MessageFormData } from '@minecraft/server-ui'; + * + * function showMessage(player: Player) { + * const messageForm = new MessageFormData() + * .title({ translate: 'permissions.removeplayer' }) // "Remove player" + * .body({ translate: 'accessibility.list.or.two', with: ['Player 1', 'Player 2'] }) // "Player 1 or Player 2" + * .button1('Player 1') + * .button2('Player 2'); + * + * messageForm + * .show(player) + * .then((formData: MessageFormResponse) => { + * // player canceled the form, or another dialog was up and open. + * if (formData.canceled || formData.selection === undefined) { + * return; + * } + * + * player.sendMessage(`You selected ${formData.selection === 0 ? 'Player 1' : 'Player 2'}`); + * }) + * .catch((error: Error) => { + * player.sendMessage('Failed to show form: ' + error); + * }); + * } + * ``` */ export class MessageFormData { /** * @remarks * Method that sets the body text for the modal form. - * @param bodyText + * */ - body(bodyText: string): MessageFormData; + body(bodyText: minecraftserver.RawMessage | string): MessageFormData; /** * @remarks * Method that sets the text for the first button of the * dialog. - * @param text + * */ - button1(text: string): MessageFormData; + button1(text: minecraftserver.RawMessage | string): MessageFormData; /** * @remarks * This method sets the text for the second button on the * dialog. - * @param text + * */ - button2(text: string): MessageFormData; + 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. @@ -162,48 +249,107 @@ export class MessageFormData { /** * @remarks * This builder method sets the title for the modal dialog. - * @param titleText + * */ - title(titleText: string): MessageFormData; + title(titleText: minecraftserver.RawMessage | string): MessageFormData; } + /** * Returns data about the player results from a modal message * form. + * @example messageFormSimple.ts + * ```typescript + * import { Player } from '@minecraft/server'; + * import { MessageFormResponse, MessageFormData } from '@minecraft/server-ui'; + * + * function showMessage(player: Player) { + * const messageForm = new MessageFormData() + * .title({ translate: 'permissions.removeplayer' }) // "Remove player" + * .body({ translate: 'accessibility.list.or.two', with: ['Player 1', 'Player 2'] }) // "Player 1 or Player 2" + * .button1('Player 1') + * .button2('Player 2'); + * + * messageForm + * .show(player) + * .then((formData: MessageFormResponse) => { + * // player canceled the form, or another dialog was up and open. + * if (formData.canceled || formData.selection === undefined) { + * return; + * } + * + * player.sendMessage(`You selected ${formData.selection === 0 ? 'Player 1' : 'Player 2'}`); + * }) + * .catch((error: Error) => { + * player.sendMessage('Failed to show form: ' + error); + * }); + * } + * ``` */ +// @ts-ignore Class inheritance allowed for native defined classes export class MessageFormResponse extends FormResponse { - protected constructor(); - /** - * Contains additional details as to why a form was canceled. - */ - readonly cancelationReason?: FormCancelationReason; - /** - * If true, the form was canceled by the player (e.g., they - * selected the pop-up X close button). - */ - readonly canceled: boolean; + 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. + * @example modalFormSimple.ts + * ```typescript + * import { Player } from '@minecraft/server'; + * import { ModalFormData } from '@minecraft/server-ui'; + * + * function showExampleModal(player: Player) { + * const modalForm = new ModalFormData().title('Example Modal Controls for §o§7ModalFormData§r'); + * + * modalForm.toggle('Toggle w/o default'); + * modalForm.toggle('Toggle w/ default', true); + * + * modalForm.slider('Slider w/o default', 0, 50, 5); + * modalForm.slider('Slider w/ default', 0, 50, 5, 30); + * + * modalForm.dropdown('Dropdown w/o default', ['option 1', 'option 2', 'option 3']); + * modalForm.dropdown('Dropdown w/ default', ['option 1', 'option 2', 'option 3'], 2); + * + * modalForm.textField('Input w/o default', 'type text here'); + * modalForm.textField('Input w/ default', 'type text here', 'this is default'); + * + * modalForm + * .show(player) + * .then(formData => { + * player.sendMessage(`Modal form results: ${JSON.stringify(formData.formValues, undefined, 2)}`); + * }) + * .catch((error: Error) => { + * player.sendMessage('Failed to show form: ' + error); + * return -1; + * }); + * } + * ``` */ export class ModalFormData { /** * @remarks * Adds a dropdown with choices to the form. - * @param label - * @param options - * @param defaultValueIndex + * */ - dropdown(label: string, options: string[], defaultValueIndex?: number): ModalFormData; + 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. @@ -212,58 +358,91 @@ export class ModalFormData { /** * @remarks * Adds a numeric slider to the form. - * @param label - * @param minimumValue - * @param maximumValue - * @param valueStep - * @param defaultValue + * */ slider( - label: string, + label: minecraftserver.RawMessage | string, minimumValue: number, maximumValue: number, valueStep: number, defaultValue?: number, ): ModalFormData; + /** + * @beta + */ + submitButton(submitButtonText: minecraftserver.RawMessage | string): ModalFormData; /** * @remarks * Adds a textbox to the form. - * @param label - * @param placeholderText - * @param defaultValue + * */ - textField(label: string, placeholderText: string, defaultValue?: string): ModalFormData; + textField( + label: minecraftserver.RawMessage | string, + placeholderText: minecraftserver.RawMessage | string, + defaultValue?: minecraftserver.RawMessage | string, + ): ModalFormData; /** * @remarks * This builder method sets the title for the modal dialog. - * @param titleText + * */ - title(titleText: string): ModalFormData; + title(titleText: minecraftserver.RawMessage | string): ModalFormData; /** * @remarks * Adds a toggle checkbox button to the form. - * @param label - * @param defaultValue + * */ - toggle(label: string, defaultValue?: boolean): ModalFormData; + toggle(label: minecraftserver.RawMessage | string, defaultValue?: boolean): ModalFormData; } + /** * Returns data about player responses to a modal form. + * @example modalFormSimple.ts + * ```typescript + * import { Player } from '@minecraft/server'; + * import { ModalFormData } from '@minecraft/server-ui'; + * + * function showExampleModal(player: Player) { + * const modalForm = new ModalFormData().title('Example Modal Controls for §o§7ModalFormData§r'); + * + * modalForm.toggle('Toggle w/o default'); + * modalForm.toggle('Toggle w/ default', true); + * + * modalForm.slider('Slider w/o default', 0, 50, 5); + * modalForm.slider('Slider w/ default', 0, 50, 5, 30); + * + * modalForm.dropdown('Dropdown w/o default', ['option 1', 'option 2', 'option 3']); + * modalForm.dropdown('Dropdown w/ default', ['option 1', 'option 2', 'option 3'], 2); + * + * modalForm.textField('Input w/o default', 'type text here'); + * modalForm.textField('Input w/ default', 'type text here', 'this is default'); + * + * modalForm + * .show(player) + * .then(formData => { + * player.sendMessage(`Modal form results: ${JSON.stringify(formData.formValues, undefined, 2)}`); + * }) + * .catch((error: Error) => { + * player.sendMessage('Failed to show form: ' + error); + * return -1; + * }); + * } + * ``` */ +// @ts-ignore Class inheritance allowed for native defined classes export class ModalFormResponse extends FormResponse { - protected constructor(); - /** - * Contains additional details as to why a form was canceled. - */ - readonly cancelationReason?: FormCancelationReason; - /** - * If true, the form was canceled by the player (e.g., they - * selected the pop-up X close button). - */ - readonly canceled: boolean; + private constructor(); /** + * @remarks * An ordered set of values based on the order of controls * specified by ModalFormData. + * */ - readonly formValues?: any[]; + 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/static/typedoc/stable/server.d.ts b/static/typedoc/stable/server.d.ts index 2458b4bd32..d60271c800 100644 --- a/static/typedoc/stable/server.d.ts +++ b/static/typedoc/stable/server.d.ts @@ -15,14615 +15,16871 @@ * ```json * { * "module_name": "@minecraft/server", - * "version": "1.0.0" + * "version": "1.10.0" * } * ``` * */ +import * as minecraftcommon from '@minecraft/common'; +export enum BlockComponentTypes { + Inventory = 'minecraft:inventory', + LavaContainer = 'minecraft:lavaContainer', + Piston = 'minecraft:piston', + PotionContainer = 'minecraft:potionContainer', + RecordPlayer = 'minecraft:recordPlayer', + Sign = 'minecraft:sign', + SnowContainer = 'minecraft:snowContainer', + WaterContainer = 'minecraft:waterContainer', +} + /** - * @beta - * Represents a direction for expressing relative position or - * facing. + * An enumeration describing the state of a block piston. */ -export enum Direction { - /** - * @beta - * Represents an object located or facing in the down (z - 1) - * direction. - */ - down = 'down', - /** - * @beta - * Represents an object located or facing in the east (x + 1) - * direction. - */ - east = 'east', +export enum BlockPistonState { /** - * @beta - * Represents an object located or facing in the north (z - 1) - * direction. + * @remarks + * Whether the piston is fully expanded. + * */ - north = 'north', + Expanded = 'Expanded', /** - * @beta - * Represents an object located or facing in the south (z + 1) - * direction. + * @remarks + * Whether the piston is in the process of expanding. + * */ - south = 'south', + Expanding = 'Expanding', /** - * @beta - * Represents an object located or facing in the up (z + 1) - * direction. + * @remarks + * Whether the piston is fully retracted. + * */ - up = 'up', + Retracted = 'Retracted', /** - * @beta - * Represents an object located or facing in the west (x - 1) - * direction. + * @remarks + * Whether the piston is in the process of retracting. + * */ - west = 'west', + Retracting = 'Retracting', } + /** * @beta - * An enumeration for the locations where scoreboard objectives - * can be displayed. + * Description of the resulting intersection test on two + * BlockVolume objects */ -export enum DisplaySlotId { +export enum BlockVolumeIntersection { /** * @beta - * Score for an objective is displayed below a player's - * nametag. + * @remarks + * Volume B has no intersection points with Volume A + * */ - belowname = 'belowname', + Disjoint = 0, /** * @beta - * This objective and respective list of players is shown on - * the Pause menu. + * @remarks + * Volume B resides completely inside Volume A + * */ - list = 'list', + Contains = 1, /** * @beta - * The objective is shown on the right-hand side of the screen. + * @remarks + * Volume B partially intersects Volume A + * */ - 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', + Intersects = 2, } + /** * @beta - * Represents the type of fluid for use within a fluid - * containing block, like a cauldron. + * The Action enum determines how the CompoundBlockVolume + * considers the associated CompoundBlockVolumeItem when + * performing inside/outside calculations. */ -export enum FluidType { - /** - * @beta - * Represents lava as a type of fluid. - */ - lava = 'lava', - /** - * @beta - * Represents a potion as a type of fluid. - */ - potion = 'potion', +export enum CompoundBlockVolumeAction { /** * @beta - * Represents powder snow as a type of fluid. + * @remarks + * The associated BlockVolume is considered a positive space, + * and any intersection tests are considered hits + * */ - powderSnow = 'powderSnow', + Add = 0, /** * @beta - * Represents water as a type of fluida. + * @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 + * */ - water = 'water', + Subtract = 1, } + /** * @beta - * Represents a game mode for the current world experience. + * An enum describing the relativity of the + * CompoundBlockVolumeItem, relative to the parent + * CompoundVolume. */ -export enum GameMode { - /** - * @beta - * World is in a more locked-down experience, where blocks may - * not be manipulated. - */ - adventure = 'adventure', +export enum CompoundBlockVolumePositionRelativity { /** * @beta - * 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. + * @remarks + * The locations within the associated BlockVolume are relative + * to the CompoundBlockVolume to which they were added + * */ - creative = 'creative', - spectator = 'spectator', + Relative = 0, /** * @beta - * 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. + * @remarks + * The locations within the associated BlockVolume are in + * absolute world space + * */ - survival = 'survival', -} -export enum ItemLockMode { - inventory = 'inventory', - none = 'none', - slot = 'slot', -} -export enum MessageSourceType { - clientScript = 'clientScript', - commandBlock = 'commandBlock', - dialogueCommand = 'dialogueCommand', - entityCommand = 'entityCommand', - serverCommand = 'serverCommand', - serverScript = 'serverScript', + Absolute = 1, } + /** * @beta - * Used for specifying a sort order for how to display an - * objective and its list of participants. + * An enumeration for the various difficulty levels of + * Minecraft. */ -export enum ObjectiveSortOrder { - /** - * @beta - * Objective participant list is displayed in ascending (e.g., - * A-Z) order. - */ - ascending = 0, +export enum Difficulty { /** * @beta - * Objective participant list is displayed in descending (e.g., - * Z-A) order. + * @remarks + * Peaceful difficulty level. + * */ - descending = 1, -} -/** - * @beta - * Contains objectives and participants for the scoreboard. - */ -export enum ScoreboardIdentityType { + Peaceful = 0, /** * @beta - * This scoreboard participant is tied to an entity. + * @remarks + * Easy difficulty level. + * */ - entity = 'entity', + Easy = 1, /** * @beta - * This scoreboard participant is tied to a pseudo player - * entity - typically this is used to store scores as data or - * as abstract progress. + * @remarks + * Normal difficulty level. + * */ - fakePlayer = 'fakePlayer', + Normal = 2, /** * @beta - * This scoreboard participant is tied to a player. + * @remarks + * Hard difficulty level. + * */ - player = 'player', -} -export enum TimeOfDay { - Day = 1000, - Noon = 6000, - Sunset = 12000, - Night = 13000, - Midnight = 18000, - Sunrise = 23000, + Hard = 3, } + /** - * @beta - * An enumeration with the reason that a watchdog is deciding - * to terminate execution of a behavior packs' script. + * A general purpose relative direction enumeration. */ -export enum WatchdogTerminateReason { +export enum Direction { /** - * @beta - * Script runtime for a behavior pack is terminated due to - * non-responsiveness from script (a hang or infinite loop). + * @remarks + * Returns the {@link Block} beneath (y - 1) of this item. + * */ - hang = 'hang', + Down = 'Down', /** - * @beta - * Script runtime for a behavior pack is terminated due to a - * stack overflow (a long, and potentially infinite) chain of - * function calls. + * @remarks + * Returns the {@link Block} to the east (x + 1) of this item. + * */ - stackOverflow = 'stackOverflow', -} -/** - * @beta - * An event that fires as players enter chat messages. - */ -export class BeforeChatEvent { - protected constructor(); + East = 'East', /** - * If set to true in a beforeChat event handler, this message - * is not broadcast out. + * @remarks + * Returns the {@link Block} to the east (z + 1) of this item. + * */ - cancel: boolean; + North = 'North', /** - * Message that is being broadcast. In a beforeChat event - * handler, _message_ can be updated with edits before the - * message is displayed to players. + * @remarks + * Returns the {@link Block} to the south (z - 1) of this item. + * */ - message: string; + South = 'South', /** - * Player that sent the chat message. + * @remarks + * Returns the {@link Block} above (y + 1) of this item. + * */ - sender: Player; + Up = 'Up', /** - * If true, this message is directly targeted to one or more - * players (i.e., is not broadcast.) + * @remarks + * Returns the {@link Block} to the west (x - 1) of this item. + * */ - sendToTargets: boolean; - getTargets(): Player[]; - setTargets(players: Player[]): void; + West = 'West', } + /** - * @beta - * Manages callbacks that are connected to an event that fires - * before chat messages are sent. + * Specifies a mechanism for displaying scores on a scoreboard. */ -export class BeforeChatEventSignal { - protected constructor(); +export enum DisplaySlotId { /** * @remarks - * Adds a callback that will be called before new chat messages - * are sent. - * @param callback + * Displays the score below the player's name. + * */ - subscribe(callback: (arg: BeforeChatEvent) => void): (arg: BeforeChatEvent) => void; + BelowName = 'BelowName', /** * @remarks - * Removes a callback from being called before new chat - * messages are sent. - * @param callback - * @throws This function can throw errors. + * Displays the score as a list on the pause screen. + * + */ + List = 'List', + /** + * @remarks + * Displays the score on the side of the player's screen. + * */ - unsubscribe(callback: (arg: BeforeChatEvent) => void): void; + Sidebar = 'Sidebar', } + /** - * @beta - * Contains information related to firing of a data driven - * entity event - for example, the minecraft:ageable_grow_up - * event on a chicken. + * Specifies different colors for use as dye. */ -export class BeforeDataDrivenEntityTriggerEvent { - protected constructor(); +export enum DyeColor { /** - * If set to true, this entity event is not triggered. + * @remarks + * Black dye color. + * */ - cancel: boolean; + Black = 'Black', /** - * Entity that the event triggered on. + * @remarks + * Blue dye color. + * */ - readonly entity: Entity; + Blue = 'Blue', /** - * Name of the data driven event being triggered. + * @remarks + * Brown dye color. + * */ - readonly id: string; - getModifiers(): DefinitionModifier[]; - 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 BeforeDataDrivenEntityTriggerEventSignal { - protected constructor(); + Brown = 'Brown', /** * @remarks - * Adds a callback that will be called before a data driven - * entity event is triggered. - * @param callback - * @param options + * Cyan dye color. + * */ - subscribe( - callback: (arg: BeforeDataDrivenEntityTriggerEvent) => void, - options?: EntityDataDrivenTriggerEventOptions, - ): (arg: BeforeDataDrivenEntityTriggerEvent) => void; + Cyan = 'Cyan', /** * @remarks - * Removes a callback that will be called before a data driven - * entity event is triggered. - * @param callback - * @throws This function can throw errors. + * Gray dye color. + * */ - unsubscribe(callback: (arg: BeforeDataDrivenEntityTriggerEvent) => void): void; -} -/** - * @beta - * Contains information regarding an explosion that has - * happened. - */ -export class BeforeExplosionEvent { - protected constructor(); + Gray = 'Gray', /** - * If set to true, cancels the explosion event. + * @remarks + * Green dye color. + * */ - cancel: boolean; + Green = 'Green', /** - * Dimension where the explosion has occurred. + * @remarks + * Light blue dye color. + * */ - readonly dimension: Dimension; + LightBlue = 'LightBlue', /** - * Optional source of the explosion. + * @remarks + * Lime dye color. + * */ - readonly source: Entity; - getImpactedBlocks(): Vector3[]; - setImpactedBlocks(blocks: Vector3[]): void; -} -/** - * @beta - * Manages callbacks that are connected to before an explosion - * occurs. - */ -export class BeforeExplosionEventSignal { - protected constructor(); + Lime = 'Lime', /** * @remarks - * Adds a callback that will be called when before an explosion - * occurs. The callback can optionally change or cancel - * explosion behavior. - * @param callback + * Magenta dye color. + * */ - subscribe(callback: (arg: BeforeExplosionEvent) => void): (arg: BeforeExplosionEvent) => void; + Magenta = 'Magenta', /** * @remarks - * Removes a callback from being called from before when an - * explosion would occur. - * @param callback - * @throws This function can throw errors. + * Orange dye color. + * */ - unsubscribe(callback: (arg: BeforeExplosionEvent) => void): void; -} -/** - * @beta - * Manages callbacks that are connected to an item's definition - * and components changing. - */ -export class BeforeItemDefinitionEventSignal { - protected constructor(); + Orange = 'Orange', /** * @remarks - * Adds a callback that will be called when an item's - * definition and components change. - * @param callback + * Pink dye color. + * */ - subscribe( - callback: (arg: BeforeItemDefinitionTriggeredEvent) => void, - ): (arg: BeforeItemDefinitionTriggeredEvent) => void; + Pink = 'Pink', /** * @remarks - * Removes a callback from being called when an item's - * definition and components change. - * @param callback - * @throws This function can throw errors. + * Purple dye color. + * */ - unsubscribe(callback: (arg: BeforeItemDefinitionTriggeredEvent) => void): void; -} -/** - * @beta - * Contains information related to a triggering of a custom - * item definition change. - */ -export class BeforeItemDefinitionTriggeredEvent { - protected constructor(); + Purple = 'Purple', /** - * If set to true, will cancel the application of this item - * definition change. + * @remarks + * Red dye color. + * */ - cancel: boolean; + Red = 'Red', /** - * Name of the data-driven item event that is triggering this - * change. + * @remarks + * Silver dye color. + * */ - readonly eventName: string; + Silver = 'Silver', /** - * The impacted item stack that is being used. + * @remarks + * White dye color. + * */ - item: ItemStack; + White = 'White', /** - * Returns the source entity that triggered this item event. + * @remarks + * Yellow dye color. + * */ - readonly source: Entity; + Yellow = 'Yellow', +} + +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 - * Contains information related to an item being used. */ -export class BeforeItemUseEvent { - protected constructor(); - /** - * If set to true, this will cancel the item use behavior. - */ - cancel: boolean; - /** - * The impacted item stack that is being used. - */ - item: ItemStack; - /** - * Returns the source entity that triggered this item event. - */ - readonly source: Entity; +export enum EnchantmentSlot { + ArmorFeet = 'ArmorFeet', + ArmorHead = 'ArmorHead', + ArmorLegs = 'ArmorLegs', + ArmorTorso = 'ArmorTorso', + Axe = 'Axe', + Bow = 'Bow', + CarrotStick = 'CarrotStick', + CosmeticHead = 'CosmeticHead', + Crossbow = 'Crossbow', + Elytra = 'Elytra', + FishingRod = 'FishingRod', + Flintsteel = 'Flintsteel', + Hoe = 'Hoe', + Pickaxe = 'Pickaxe', + Shears = 'Shears', + Shield = 'Shield', + Shovel = 'Shovel', + Spear = 'Spear', + Sword = 'Sword', } + +export enum EntityComponentTypes { + AddRider = 'minecraft:addrider', + Ageable = 'minecraft:ageable', + Breathable = 'minecraft:breathable', + CanClimb = 'minecraft:can_climb', + CanFly = 'minecraft:can_fly', + CanPowerJump = 'minecraft:can_power_jump', + Color = 'minecraft:color', + Color2 = 'minecraft:color2', + Equippable = 'minecraft:equippable', + FireImmune = 'minecraft:fire_immune', + FloatsInLiquid = 'minecraft:floats_in_liquid', + FlyingSpeed = 'minecraft:flying_speed', + FrictionModifier = 'minecraft:friction_modifier', + GroundOffset = 'minecraft:ground_offset', + Healable = 'minecraft:healable', + Health = 'minecraft:health', + Inventory = 'minecraft:inventory', + IsBaby = 'minecraft:is_baby', + IsCharged = 'minecraft:is_charged', + IsChested = 'minecraft:is_chested', + IsDyeable = 'minecraft:is_dyeable', + IsHiddenWhenInvisible = 'minecraft:is_hidden_when_invisible', + IsIgnited = 'minecraft:is_ignited', + IsIllagerCaptain = 'minecraft:is_illager_captain', + IsSaddled = 'minecraft:is_saddled', + IsShaking = 'minecraft:is_shaking', + IsSheared = 'minecraft:is_sheared', + IsStackable = 'minecraft:is_stackable', + IsStunned = 'minecraft:is_stunned', + IsTamed = 'minecraft:is_tamed', + Item = 'minecraft:item', + LavaMovement = 'minecraft:lava_movement', + Leashable = 'minecraft:leashable', + MarkVariant = 'minecraft:mark_variant', + Movement = 'minecraft:movement', + MovementAmphibious = 'minecraft:movement.amphibious', + MovementBasic = 'minecraft:movement.basic', + MovementFly = 'minecraft:movement.fly', + MovementGeneric = 'minecraft:movement.generic', + MovementGlide = 'minecraft:movement.glide', + MovementHover = 'minecraft:movement.hover', + MovementJump = 'minecraft:movement.jump', + MovementSkip = 'minecraft:movement.skip', + MovementSway = 'minecraft:movement.sway', + NavigationClimb = 'minecraft:navigation.climb', + NavigationFloat = 'minecraft:navigation.float', + NavigationFly = 'minecraft:navigation.fly', + NavigationGeneric = 'minecraft:navigation.generic', + NavigationHover = 'minecraft:navigation.hover', + NavigationWalk = 'minecraft:navigation.walk', + Npc = 'minecraft:npc', + OnFire = 'minecraft:onfire', + Projectile = 'minecraft:projectile', + PushThrough = 'minecraft:push_through', + Rideable = 'minecraft:rideable', + Riding = 'minecraft:riding', + Scale = 'minecraft:scale', + SkinId = 'minecraft:skin_id', + Strength = 'minecraft:strength', + Tameable = 'minecraft:tameable', + TameMount = 'minecraft:tamemount', + TypeFamily = 'minecraft:type_family', + UnderwaterMovement = 'minecraft:underwater_movement', + Variant = 'minecraft:variant', + WantsJockey = 'minecraft:wants_jockey', +} + /** - * @beta - * Manages callbacks that fire before an item is used. + * Describes the source of damage from an Entity. */ -export class BeforeItemUseEventSignal { - protected constructor(); +export enum EntityDamageCause { /** * @remarks - * Adds a callback that will be called before an item is used. - * @param callback + * Damage caused by a falling anvil. + * */ - subscribe(callback: (arg: BeforeItemUseEvent) => void): (arg: BeforeItemUseEvent) => void; + anvil = 'anvil', /** * @remarks - * Removes a callback from being called before an item is used. - * @param callback - * @throws This function can throw errors. + * Damage caused from a non-Entity explosion. For example, an + * exploding bed. + * */ - unsubscribe(callback: (arg: BeforeItemUseEvent) => void): void; -} -/** - * @beta - * Contains information related to an item being used on a - * block. - */ -export class BeforeItemUseOnEvent { - protected constructor(); + blockExplosion = 'blockExplosion', + campfire = 'campfire', /** - * The face of the block that an item is being used on. + * @remarks + * Unused. + * */ - readonly blockFace: Direction; + charging = 'charging', /** - * If set to true, this will cancel the item use behavior. + * @remarks + * Damage caused by physically touching an Entity or Block. For + * example, touching a Sweet Berry bush or Pufferfish. + * */ - cancel: boolean; + contact = 'contact', /** - * X coordinate of the item-use impact location on the face of - * the target block. + * @remarks + * Damage caused by an Entity being out of air and inside a + * liquid block. + * */ - readonly faceLocationX: number; + drowning = 'drowning', /** - * Y coordinate of the item-use impact location on the face of - * the target block. + * @remarks + * Damage caused by an Entity attack. + * */ - readonly faceLocationY: number; + entityAttack = 'entityAttack', /** - * The impacted item stack that is being used on a block. + * @remarks + * Damage caused by an Entity explosion. For example, a Creeper + * or Wither. + * */ - item: ItemStack; + entityExplosion = 'entityExplosion', /** - * Returns the source entity that triggered this item event. + * @remarks + * Damage caused by falling onto the ground. + * */ - readonly source: Entity; - getBlockLocation(): Vector3; -} -/** - * @beta - * Manages callbacks that fire before an item being used on a - * block event. - */ -export class BeforeItemUseOnEventSignal { - protected constructor(); + fall = 'fall', /** * @remarks - * Adds a callback that will be called before an item is used - * on a block. - * @param callback + * Damage caused by falling blocks. Note: Anvils and + * Stalactites have their own damage causes. + * */ - subscribe(callback: (arg: BeforeItemUseOnEvent) => void): (arg: BeforeItemUseOnEvent) => void; + fallingBlock = 'fallingBlock', /** * @remarks - * Removes a callback from being called before an item is used - * on a block. - * @param callback - * @throws This function can throw errors. + * Damage caused by catching on fire. + * */ - unsubscribe(callback: (arg: BeforeItemUseOnEvent) => void): void; -} -/** - * @beta - * Contains information related to changes before a piston - * expands or retracts. - */ -export class BeforePistonActivateEvent extends BlockEvent { - protected constructor(); + fire = 'fire', /** - * Block impacted by this event. + * @remarks + * Damage caused by burning over time. + * */ - readonly block: Block; + fireTick = 'fireTick', /** - * If this is set to true within an event handler, the piston - * activation is canceled. + * @remarks + * Damage caused by fireworks. + * */ - cancel: boolean; + fireworks = 'fireworks', /** - * Dimension that contains the block that is the subject of - * this event. + * @remarks + * Damage caused by flying into a wall at high speed while + * gliding with Elytra. + * */ - readonly dimension: Dimension; + flyIntoWall = 'flyIntoWall', /** - * True if the piston is the process of expanding. + * @remarks + * Damage caused by staying inside a Powder Snow block. + * */ - readonly isExpanding: boolean; + freezing = 'freezing', /** - * Contains additional properties and details of the piston. + * @remarks + * Damage caused by touching a Lava block. + * */ - readonly piston: BlockPistonComponent; -} -/** - * @beta - * Manages callbacks that are connected to an event that fires - * before a piston is activated. - */ -export class BeforePistonActivateEventSignal { - protected constructor(); + lava = 'lava', /** * @remarks - * Adds a callback that will be called before a piston expands - * or retracts. - * @param callback + * Damage caused by being struck by lightning. + * */ - subscribe(callback: (arg: BeforePistonActivateEvent) => void): (arg: BeforePistonActivateEvent) => void; + lightning = 'lightning', /** * @remarks - * Removes a callback from being called before a piston expands - * or retracts. - * @param callback - * @throws This function can throw errors. + * Damage caused by magical attacks. For example, Evoker Fang + * or Conduit Block. + * */ - unsubscribe(callback: (arg: BeforePistonActivateEvent) => void): void; -} -/** - * @beta - * Contains information related to a script watchdog - * termination. - */ -export class BeforeWatchdogTerminateEvent { - protected constructor(); + magic = 'magic', /** - * 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. + * @remarks + * Damage caused by touching a Magma block. + * */ - cancel: boolean; + magma = 'magma', /** - * Contains the reason why a script runtime is to be - * terminated. + * @remarks + * Damage caused by no source. For example, from a command or + * script. + * */ - 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 BeforeWatchdogTerminateEventSignal { - protected constructor(); + none = 'none', /** * @remarks - * Adds a callback that will be called when a script runtime is - * being terminated due to a violation of the performance - * watchdog system. - * @param callback + * Damage caused by an indirect source. For example, setting a + * mob's health to 0 in a behavior pack. + * */ - subscribe(callback: (arg: BeforeWatchdogTerminateEvent) => void): (arg: BeforeWatchdogTerminateEvent) => void; + override = 'override', /** * @remarks - * Removes a callback from being called when a script runtime - * is being terminated due to a violation of the performance - * watchdog system. - * @param callback - * @throws This function can throw errors. + * Damage caused by a Piston. + * */ - unsubscribe(callback: (arg: BeforeWatchdogTerminateEvent) => void): void; -} -/** - * @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 { - protected constructor(); + piston = 'piston', /** - * Returns the dimension that the block is within. + * @remarks + * Damage caused by a projectile. + * */ - readonly dimension: Dimension; + projectile = 'projectile', + ramAttack = 'ramAttack', + selfDestruct = 'selfDestruct', + sonicBoom = 'sonicBoom', + soulCampfire = 'soulCampfire', /** - * Returns or sets whether this block has a liquid on it. + * @remarks + * Damage caused by a falling Stalactite block. + * */ - isWaterlogged: boolean; + stalactite = 'stalactite', /** - * Coordinates of the specified block. - * @throws This property can throw when used. + * @remarks + * Damage caused by touching a Stalagmite block. + * */ - readonly location: Vector3; + stalagmite = 'stalagmite', /** - * Additional block configuration data that describes the - * block. - * @throws This property can throw when used. + * @remarks + * Damage caused over time by having an empty hunger bar. + * */ - readonly permutation: BlockPermutation; + starve = 'starve', /** - * Gets the type of block. - * @throws This property can throw when used. + * @remarks + * Damage caused by an Entity being out of air and inside a + * non-liquid block. + * */ - readonly 'type': BlockType; + suffocation = 'suffocation', /** - * Identifier of the type of block for this block. - * @throws This property can throw when used. + * @remarks + * Damage caused by an Entity killing itself. For example, from + * the /kill command. + * */ - readonly typeId: string; + suicide = 'suicide', /** - * X coordinate of the block. + * @remarks + * Damage caused by an Entity being in an inhabitable climate. + * For example, a Snow Golem in a biome with a temperature + * greater than 1. + * */ - readonly x: number; + temperature = 'temperature', /** - * Y coordinate of the block. + * @remarks + * Damage caused by the Thorns armor enchantment and by the + * Guardian thorns effect. + * */ - readonly y: number; + thorns = 'thorns', /** - * Z coordinate of the block. + * @remarks + * Damage caused over time by falling into the void. + * */ - readonly z: number; + 'void' = 'void', /** * @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. + * Damage caused by the Wither effect. For example, from + * touching a Wither Rose. + * */ - canPlace(blockToPlace: BlockPermutation | BlockType, faceToPlaceOn?: Direction): boolean; + wither = 'wither', +} + +/** + * An enumeration describing initialization cause of an entity. + */ +export enum EntityInitializationCause { /** * @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. + * 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. + * */ - getComponent(componentName: string): any; + Born = 'Born', /** * @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. + * Case when an entity is created by an event, e.g., a + * Wandering trader spawning llamas. + * */ - getRedstonePower(): number | undefined; + Event = 'Event', /** * @remarks - * Returns a set of tags for a block. - * @returns - * The list of tags that the block has. - * @throws This function can throw errors. + * Case when an entity is loaded into the world. + * */ - getTags(): string[]; + Loaded = 'Loaded', /** * @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"; + * Case when an entity is naturally spawned in the world. * - * // 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; - isAir(): boolean; - isLiquid(): boolean; - isSolid(): boolean; + Spawned = 'Spawned', /** * @remarks - * Sets the block in the dimension to the state of the - * permutation. - * @param permutation - * Permutation that contains a set of property states for the - * Block. - * @throws This function can throw errors. + * Case when an entity is transformed into another entity. + * */ - setPermutation(permutation: BlockPermutation): void; + 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 - * Sets the type of block. - * @param blockType - * Identifier of the type of block to apply - for example, - * minecraft:powered_repeater. - * @throws This function can throw errors. + * Corresponding object is loaded. + * */ - setType(blockType: BlockType): void; + Loaded = 'Loaded', /** + * @beta * @remarks - * Tries to set the block in the dimension to the state of the - * permutation by first checking if the placement is valid. - * @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. + * 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. + * */ - trySetPermutation(permutation: BlockPermutation): boolean; + Unloaded = 'Unloaded', } + /** - * @beta - * Holds information for expressing the net size of a volume of - * blocks. + * The equipment slot of the mob. This includes armor, offhand + * and mainhand slots. */ -export class BlockAreaSize { +export enum EquipmentSlot { + /** + * @remarks + * The chest slot. This slot is used to hold items such as + * Chestplate or Elytra. + * + */ + Chest = 'Chest', /** - * X size (west to east) component of this block area. + * @remarks + * The feet slot. This slot is used to hold items such as + * Boots. + * */ - x: number; + Feet = 'Feet', /** - * Y size (down to up) of this block area size. + * @remarks + * The head slot. This slot is used to hold items such as + * Helmets or Carved Pumpkins. + * */ - y: number; + Head = 'Head', /** - * Z size (south to north) of this block area size. + * @remarks + * The legs slot. This slot is used to hold items such as + * Leggings. + * */ - z: number; + Legs = 'Legs', /** * @remarks - * Creates a new BlockAreaSize object. - * @param x - * @param y - * @param z + * The mainhand slot. For players, the mainhand slot refers to + * the currently active hotbar slot. + * */ - constructor(x: number, y: number, z: number); + Mainhand = 'Mainhand', /** * @remarks - * Tests whether this block area size is equal to another - * BlockAreaSize object. - * @param other + * The offhand slot. This slot is used to hold items such as + * shields and maps. + * */ - equals(other: BlockAreaSize): boolean; + Offhand = 'Offhand', } + /** - * @beta - * Contains information regarding an event where a player - * breaks a block. + * Represents the type of fluid for use within a fluid + * containing block, like a cauldron. */ -export class BlockBreakEvent extends BlockEvent { - protected constructor(); +export enum FluidType { /** - * Block broken in this event. Note that because this event - * fires right after a block is broken, the block you will - * receive will likely be of type 'minecraft:air'. See the - * .brokenBlockPermutation property for information on this - * block before it was broken. + * @remarks + * Represents lava as a type of fluid. + * */ - readonly block: Block; + Lava = 'Lava', /** - * Returns permutation information about this block before it - * was broken. + * @remarks + * Represents a potion as a type of fluid. + * */ - readonly brokenBlockPermutation: BlockPermutation; + Potion = 'Potion', /** - * Dimension that contains the block that has been broken in - * this event. + * @remarks + * Represents powder snow as a type of fluid. + * */ - readonly dimension: Dimension; + PowderSnow = 'PowderSnow', /** - * Player that broke the block for this event. + * @remarks + * Represents water as a type of fluida. + * */ - readonly player: Player; + Water = 'Water', } + /** - * @beta - * Manages callbacks that are connected to when a block is - * broken. + * Represents a game mode for the current world experience. */ -export class BlockBreakEventSignal { - protected constructor(); +export enum GameMode { /** * @remarks - * Adds a callback that will be called when a block is broken - * by a player. - * @param callback + * World is in a more locked-down experience, where blocks may + * not be manipulated. + * */ - subscribe(callback: (arg: BlockBreakEvent) => void): (arg: BlockBreakEvent) => void; + adventure = 'adventure', /** * @remarks - * Removes a callback from being called when an block is - * broken. - * @param callback - * @throws This function can throw errors. + * 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. + * */ - unsubscribe(callback: (arg: BlockBreakEvent) => void): void; -} -/** - * @beta - * Base type for components associated with blocks. - */ -// tslint:disable-next-line:no-unnecessary-class -export class BlockComponent { - protected constructor(); -} -/** - * @beta - * Contains information regarding an event that impacts a - * specific block. - */ -export class BlockEvent { - protected constructor(); + creative = 'creative', /** - * Block impacted by this event. + * @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. + * */ - readonly block: Block; + spectator = 'spectator', /** - * Dimension that contains the block that is the subject of - * this event. + * @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. + * */ - readonly dimension: Dimension; + survival = 'survival', } + /** * @beta - * Contains information regarding an explosion that has - * occurred for a specific block. */ -export class BlockExplodeEvent extends BlockEvent { - protected constructor(); +export enum GameRule { /** - * Block impacted by this explosion event. + * @beta + * @remarks + * Whether command blocks should notify admins when they + * perform commands. + * */ - readonly block: Block; + CommandBlockOutput = 'commandBlockOutput', /** - * Dimension that contains the block that is the subject of - * this explosion event. + * @beta + * @remarks + * Controls whether command blocks can execute commands. + * */ - readonly dimension: Dimension; + CommandBlocksEnabled = 'commandBlocksEnabled', /** - * Optional source of the explosion. + * @beta + * @remarks + * Controls whether the day and night cycles progress. + * */ - readonly source: Entity; -} -/** - * @beta - * Manages callbacks that are connected to when an explosion - * occurs, as it impacts individual blocks. - */ -export class BlockExplodeEventSignal { - protected constructor(); + DoDayLightCycle = 'doDayLightCycle', /** + * @beta * @remarks - * Adds a callback that will be called when an explosion - * occurs, as it impacts individual blocks. - * @param callback + * Controls whether non-mob entities do drops. ie. Item Frame + * */ - subscribe(callback: (arg: BlockExplodeEvent) => void): (arg: BlockExplodeEvent) => void; + DoEntityDrops = 'doEntityDrops', /** + * @beta * @remarks - * Removes a callback from being called when an explosion - * occurs, as it impacts individual blocks. - * @param callback - * @throws This function can throw errors. + * Controls whether fire spreads. + * */ - unsubscribe(callback: (arg: BlockExplodeEvent) => void): void; -} -/** - * @beta - * Represents the inventory of a block in the world. Used with - * blocks like chests. - */ -export class BlockInventoryComponent extends BlockComponent { - protected constructor(); + DoFireTick = 'doFireTick', /** - * The container which holds an {@link ItemStack}. - * @throws This property can throw when used. + * @beta + * @remarks + * Controls whether players immediately respawn or are shown + * the death screen. + * */ - readonly container: BlockInventoryComponentContainer; + DoImmediateRespawn = 'doImmediateRespawn', /** - * Identifier of this component. Should always be - * minecraft:inventory. + * @beta + * @remarks + * Controls whether players deal with the effects of not + * sleeping (such as Phantom spawning). + * */ - readonly typeId: string; + DoInsomnia = 'doInsomnia', /** - * Identifier of this component. Should always be - * minecraft:inventory. + * @beta + * @remarks + * Determines whether players should be able to craft only + * those recipes that they've unlocked first - when + * dolimitedcrafting is set to true. + * */ - static readonly componentId = 'minecraft:inventory'; -} -export class BlockInventoryComponentContainer extends Container { - protected constructor(); - readonly emptySlotsCount: number; - readonly size: number; - addItem(itemStack: ItemStack): void; - clearAll(): void; - clearItem(slot: number): void; - getItem(slot: number): ItemStack; - getSlot(slot: number): ContainerSlot; - setItem(slot: number, itemStack?: ItemStack): void; - swapItems(slot: number, otherSlot: number, otherContainer: Container): boolean; - transferItem(fromSlot: number, toSlot: number, toContainer: Container): boolean; -} -/** - * @beta - * Represents a fluid container block that currently contains - * lava. - */ -export class BlockLavaContainerComponent extends BlockComponent { - protected constructor(); + DoLimitedCrafting = 'doLimitedCrafting', /** - * Relative level of lava within this block. Valid values are - * between FluidContainer.minFillLevel (0) and - * FluidContainer.maxFillLevel (6). - */ - fillLevel: number; + * @beta + * @remarks + * Controls whether mobs drop loot. + * + */ + DoMobLoot = 'doMobLoot', /** - * Identifier of this component. Should always be - * minecraft:lavaContainer. + * @beta + * @remarks + * Controls whether mobs spawn naturally in the world. + * */ - readonly typeId: string; + DoMobSpawning = 'doMobSpawning', /** - * Identifier of this component. Should always be - * minecraft:lavaContainer. + * @beta + * @remarks + * Controls whether blocks drop items when destroyed. + * */ - static readonly componentId = 'minecraft:lavaContainer'; -} -/** - * @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}). This type was introduced as of version 1.17.10.21. - */ -export class BlockPermutation { - protected constructor(); + DoTileDrops = 'doTileDrops', /** - * The {@link BlockType} that the permutation has. + * @beta + * @remarks + * Controls whether the weather can change naturally. + * */ - readonly 'type': BlockType; + DoWeatherCycle = 'doWeatherCycle', /** + * @beta * @remarks - * Creates a copy of this permutation. - * @returns - * A copy of the permutation. + * Controls whether entities take damage from drowning. + * */ - clone(): BlockPermutation; + DrowningDamage = 'drowningDamage', /** + * @beta * @remarks - * Returns all available properties associated with this block. - * @returns - * Returns the list of all of the properties that the - * permutation has. + * Controls whether entities take damage from falling. + * */ - getAllProperties(): Record; + FallDamage = 'fallDamage', /** + * @beta * @remarks - * Gets a property for the permutation. - * @param propertyName - * @returns - * Returns the property if the permutation has it, else `null`. + * Controls whether entities take damage from fire. + * */ - getProperty(propertyName: string): boolean | number | string | undefined; + FireDamage = 'fireDamage', /** + * @beta * @remarks - * Creates a copy of the permutation. + * Controls whether there is damage from freezing. + * */ - getTags(): string[]; + FreezeDamage = 'freezeDamage', /** + * @beta * @remarks - * Checks to see if the permutation has a specific tag. - * @param tag - * @returns - * Returns `true` if the permutation has the tag, else `false`. - * @example check_block_tags.js - * ```typescript - * import { world } from "@minecraft/server"; + * The maximum number of commands that can be executed + * simultaneously by the /function command. * - * // Fetch the block - * const block = world.getDimension("overworld").getBlock({ x: 1, y: 2, z: 3 }); - * const blockPerm = block.getPermutation(); + */ + FunctionCommandLimit = 'functionCommandLimit', + /** + * @beta + * @remarks + * Controls whether players keep their inventories when they + * die. * - * console.log(`Block is dirt: ${blockPerm.hasTag("dirt")}`); - * console.log(`Block is wood: ${blockPerm.hasTag("wood")}`); - * console.log(`Block is stone: ${blockPerm.hasTag("stone")}`); + */ + KeepInventory = 'keepInventory', + /** + * @beta + * @remarks + * The maximum number of chained commands that can execute per + * tick. * - * ``` */ - hasTag(tag: string): boolean; - matches(blockName: string, properties?: Record): boolean; - withProperty(name: string, value: boolean | number | string): BlockPermutation; - static resolve(blockName: string, properties?: Record): BlockPermutation; -} -/** - * @beta - * When present, this block has piston-like behavior. Contains - * additional properties for discovering block piston state. - */ -export class BlockPistonComponent extends BlockComponent { - protected constructor(); + MaxCommandChainLength = 'maxCommandChainLength', /** - * Whether the piston is fully expanded. - * @throws This property can throw when used. + * @beta + * @remarks + * Controls whether mob griefing can happen in the world. + * Example: A Creeper explosion destroying blocks. + * */ - readonly isExpanded: boolean; + MobGriefing = 'mobGriefing', /** - * Whether the piston is in the process of expanding. - * @throws This property can throw when used. + * @beta + * @remarks + * Controls whether players can regenerate health. + * */ - readonly isExpanding: boolean; + NaturalRegeneration = 'naturalRegeneration', /** - * Whether the piston is in the process of expanding or - * retracting. - * @throws This property can throw when used. + * @beta + * @remarks + * The percentage of players required to be sleeping in order + * to advance to the next day. + * */ - readonly isMoving: boolean; + PlayersSleepingPercentage = 'playersSleepingPercentage', /** - * Whether the piston is fully retracted. - * @throws This property can throw when used. + * @beta + * @remarks + * Controls whether projectiles (entities with a projectile + * component, like Arrows, thrown Tridents or Fireworks) can + * destroy certain blocks that support this interaction (such + * as Chorus Fruit, Dripstone or Decorated Pots). Restrictions + * on which projectiles can destroy certain blocks apply. + * */ - readonly isRetracted: boolean; + ProjectilesCanBreakBlocks = 'projectilesCanBreakBlocks', /** - * Whether the piston is in the process of retracting. - * @throws This property can throw when used. + * @beta + * @remarks + * Controls whether players can damage each other. + * */ - readonly isRetracting: boolean; + Pvp = 'pvp', /** - * Identifier of this component. + * @beta + * @remarks + * Controls how frequently random ticks occur. A value of 0 or + * less will disable random ticks. The default value is 1. + * */ - readonly typeId: string; + RandomTickSpeed = 'randomTickSpeed', /** - * Identifier of this component. + * @beta + * @remarks + * Controls whether built-in (vanilla) recipes automatically + * unlock as the player progresses through the game (one + * alternative to this is to use the /recipe command based on + * custom gameplay logic.) + * */ - static readonly componentId = 'minecraft:piston'; - getAttachedBlocks(): Vector3[]; -} -/** - * @beta - * Contains information regarding an event where a player - * places a block. - */ -export class BlockPlaceEvent extends BlockEvent { - protected constructor(); + RecipesUnlock = 'recipesUnlock', /** - * Block placed in this event. + * @beta + * @remarks + * Controls whether respawn blocks (e.g. Bed, Respawn Anchor) + * explode in other dimensions. + * */ - readonly block: Block; + RespawnBlocksExplode = 'respawnBlocksExplode', /** - * Dimension that contains the block that has been placed in - * this event. + * @beta + * @remarks + * Controls whether command output is displayed to players. + * Also controls whether Command Block output is stored by + * default. + * */ - readonly dimension: Dimension; + SendCommandFeedback = 'sendCommandFeedback', /** - * Player that placed the block for this event. + * @beta + * @remarks + * Controls whether Border Block effects are shown. + * */ - readonly player: Player; -} -/** - * @beta - * Manages callbacks that are connected to when a block is - * placed. - */ -export class BlockPlaceEventSignal { - protected constructor(); + ShowBorderEffect = 'showBorderEffect', /** + * @beta * @remarks - * Adds a callback that will be called when a block is placed - * by a player. - * @param callback + * Controls whether player coordinates are displayed. + * */ - subscribe(callback: (arg: BlockPlaceEvent) => void): (arg: BlockPlaceEvent) => void; + ShowCoordinates = 'showCoordinates', /** + * @beta * @remarks - * Removes a callback from being called when an block is - * placed. - * @param callback - * @throws This function can throw errors. + * Controls whether death messages are displayed in chat. + * */ - unsubscribe(callback: (arg: BlockPlaceEvent) => void): void; -} -/** - * @beta - * Represents a fluid container block that currently contains a - * potion. - */ -export class BlockPotionContainerComponent extends BlockComponent { - protected constructor(); + ShowDeathMessages = 'showDeathMessages', /** - * Relative level of potion liquid within this block. Valid - * values are between FluidContainer.minFillLevel (0) and - * FluidContainer.maxFillLevel (6). + * @beta + * @remarks + * Controls whether standard player notifications for recipes + * will show. When set to false, 'player unlocked recipes' are + * no longer sent as player notifications. + * */ - fillLevel: number; + ShowRecipeMessages = 'showRecipeMessages', /** - * Identifier of this component. Should always be - * minecraft:potionContainer. + * @beta + * @remarks + * Controls whether item tags are shown. E.g. 'Can Place On', + * 'Can Destroy', item lock icons, etc. + * */ - readonly typeId: string; + ShowTags = 'showTags', /** - * Identifier of this component. Should always be - * minecraft:potionContainer. + * @beta + * @remarks + * The block radius from world spawn that a player is allowed + * to spawn in. Does not affect Adventure mode. The default + * value is 10 blocks. + * */ - static readonly componentId = 'minecraft:potionContainer'; + SpawnRadius = 'spawnRadius', /** + * @beta * @remarks - * Sets the potion type based on an item stack. - * @param item - * Potion to use as the type of potion for this potion - * container. - * @throws This function can throw errors. + * Affects whether TNT blocks can be lit. + * */ - setPotionType(item: ItemStack): void; + TntExplodes = 'tntExplodes', } + /** * @beta - * Returns an enumeration of available block properties. */ -// tslint:disable-next-line:no-unnecessary-class -export class BlockProperties { - protected constructor(); - static get(propertyName: string): BlockPropertyType; - static getAll(): BlockPropertyType[]; -} -export class BlockPropertyType { - protected constructor(); - readonly id: string; - readonly validValues: (boolean | number | string)[]; +export enum HudElement { + PaperDoll = 0, + Armor = 1, + ToolTips = 2, + TouchControls = 3, + Crosshair = 4, + Hotbar = 5, + Health = 6, + ProgressBar = 7, + Hunger = 8, + AirBubbles = 9, + HorseHealth = 10, + StatusEffects = 11, + ItemText = 12, } + /** * @beta - * Represents a block that can play a record. */ -export class BlockRecordPlayerComponent extends BlockComponent { - protected constructor(); - /** - * Identifier of this component. Should always be - * minecraft:recordPlayer. - */ - readonly typeId: string; +export enum HudVisibility { + Hide = 0, + Reset = 1, +} + +/** + * The types of item components that are accessible via + * function ItemStack.getComponent. + */ +export enum ItemComponentTypes { /** - * Identifier of this component. Should always be - * minecraft:recordPlayer. + * @remarks + * The minecraft:cooldown component. + * */ - static readonly componentId = 'minecraft:recordPlayer'; + Cooldown = 'minecraft:cooldown', /** * @remarks - * Clears the currently playing record of this record-playing - * block. - * @throws This function can throw errors. + * The minecraft:durability component. + * */ - clearRecord(): void; + Durability = 'minecraft:durability', /** * @remarks - * Returns true if the record-playing block is currently - * playing a record. - * @throws This function can throw errors. + * The minecraft:enchantable component. + * */ - isPlaying(): boolean; + Enchantable = 'minecraft:enchantable', /** * @remarks - * Sets and plays a record based on an item type. - * @param recordItemType - * @throws This function can throw errors. + * The minecraft:food component. + * */ - setRecord(recordItemType: ItemType): void; + Food = 'minecraft:food', } + /** - * @beta - * Represents a block that can display text on it. + * Describes how an an item can be moved within a container. */ -export class BlockSignComponent extends BlockComponent { - protected constructor(); - readonly text: string; +export enum ItemLockMode { /** - * Identifier of this component. Should always be - * minecraft:sign. + * @remarks + * The item cannot be dropped or crafted with. + * */ - readonly typeId: string; + inventory = 'inventory', /** - * Identifier of this component. Should always be - * minecraft:sign. + * @remarks + * The item has no container restrictions. + * */ - static readonly componentId = 'minecraft:sign'; + none = 'none', + /** + * @remarks + * The item cannot be moved from its slot, dropped or crafted + * with. + * + */ + slot = 'slot', } + /** - * @beta - * Represents a fluid container block that currently contains - * snow. + * Enum containing the different phases of the moon based on + * the current day.,Obtain the current MoonPhase using + * world.getMoonPhase. + * + * The fullness of the moon controls various mob behaviors such + * as the number of slimes that spawn in Swamp biomes, the + * chance skeletons and zombies have to spawn with armor, as + * well as the chance for spiders to spawn with certain status + * effects. */ -export class BlockSnowContainerComponent extends BlockComponent { - protected constructor(); - /** - * Relative level of snow within this block. Valid values are - * between FluidContainer.minFillLevel (0) and - * FluidContainer.maxFillLevel (6). - */ - fillLevel: number; +export enum MoonPhase { /** - * Identifier of this component. Should always be - * minecraft:snowContainer. + * @remarks + * The brightest moon phase. During this phase, cats have a 50% + * chance of spawning as black cats. + * */ - readonly typeId: string; + FullMoon = 0, /** - * Identifier of this component. Should always be - * minecraft:snowContainer. + * @remarks + * The phase following the Full Moon. + * */ - static readonly componentId = 'minecraft:snowContainer'; -} -/** - * @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 { - protected constructor(); + WaningGibbous = 1, /** - * Represents whether this type of block can be waterlogged. + * @remarks + * The phase following the Waxing Crescent. + * */ - readonly canBeWaterlogged: boolean; + FirstQuarter = 2, /** - * Block type name - for example, `minecraft:acacia_stairs`. + * @remarks + * The phase following the Last Quarter. + * */ - readonly id: string; -} -/** - * @beta - * Represents a fluid container block that currently contains - * water. - */ -export class BlockWaterContainerComponent extends BlockComponent { - protected constructor(); + WaningCrescent = 3, /** - * Relative level of water within this block. Valid values are - * between FluidContainer.minFillLevel (0) and - * FluidContainer.maxFillLevel (6). + * @remarks + * The darkest moon phase. + * */ - fillLevel: number; + NewMoon = 4, /** - * Identifier of this component. Should always be - * minecraft:waterContainer. + * @remarks + * The phase following the New Moon. + * */ - readonly typeId: string; + WaxingCrescent = 5, /** - * Identifier of this component. Should always be - * minecraft:waterContainer. + * @remarks + * The phase following the Waning Gibbous. + * */ - static readonly componentId = 'minecraft:waterContainer'; + LastQuarter = 6, /** * @remarks - * Adds an item and colors the water based on a dye item type. - * @param itemType - * @throws This function can throw errors. + * The phase following the First Quarter. + * */ - addDye(itemType: ItemType): void; - getCustomColor(): Color; - setCustomColor(color: Color): void; + WaxingGibbous = 7, } + /** - * @beta - * Contains information related to changes to a button push. + * Used for specifying a sort order for how to display an + * objective and its list of participants. */ -export class ButtonPushEvent extends BlockEvent { - protected constructor(); - /** - * Block impacted by this event. - */ - readonly block: Block; +export enum ObjectiveSortOrder { /** - * Dimension that contains the block that is the subject of - * this event. + * @remarks + * Objective participant list is displayed in ascending (e.g., + * A-Z) order. + * */ - readonly dimension: Dimension; + Ascending = 0, /** - * Optional source that triggered the button push. + * @remarks + * Objective participant list is displayed in descending (e.g., + * Z-A) order. + * */ - readonly source: Entity; + Descending = 1, } + /** * @beta - * Manages callbacks that are connected to when a button is - * pushed. */ -export class ButtonPushEventSignal { - protected constructor(); +export enum PaletteColor { + White = 0, + Orange = 1, + Magenta = 2, + LightBlue = 3, + Yellow = 4, + Lime = 5, + Pink = 6, + Gray = 7, + Silver = 8, + Cyan = 9, + Purple = 10, + Blue = 11, + Brown = 12, + Green = 13, + Red = 14, + Black = 15, +} + +/** + * Contains objectives and participants for the scoreboard. + */ +export enum ScoreboardIdentityType { /** * @remarks - * Adds a callback that will be called when a button is pushed. - * @param callback + * This scoreboard participant is tied to an entity. + * */ - subscribe(callback: (arg: ButtonPushEvent) => void): (arg: ButtonPushEvent) => void; + Entity = 'Entity', /** * @remarks - * Removes a callback from being called when a button is - * pushed. - * @param callback - * @throws This function can throw errors. + * 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. + * */ - unsubscribe(callback: (arg: ButtonPushEvent) => void): void; + Player = 'Player', } + /** - * @beta - * An event that fires as players enter chat messages. + * Describes where the script event originated from. */ -export class ChatEvent { - protected constructor(); +export enum ScriptEventSource { /** - * Message that is being broadcast. In a beforeChat event - * handler, _message_ can be updated with edits before the - * message is displayed to players. + * @remarks + * The script event originated from a Block such as a Command + * Block. + * */ - message: string; + Block = 'Block', /** - * Player that sent the chat message. + * @remarks + * The script event originated from an Entity such as a Player, + * Command Block Minecart or Animation Controller. + * */ - sender: Player; + Entity = 'Entity', /** - * If true, this message is directly targeted to one or more - * players (i.e., is not broadcast.) + * @remarks + * The script event originated from an NPC dialogue. + * */ - sendToTargets: boolean; - getTargets(): Player[]; + NPCDialogue = 'NPCDialogue', + /** + * @remarks + * The script event originated from the server, such as from a + * runCommand API call or a dedicated server console. + * + */ + Server = 'Server', } + /** - * @beta - * Manages callbacks that are connected to chat messages being - * sent. + * Represents a side of a sign. */ -export class ChatEventSignal { - protected constructor(); +export enum SignSide { /** * @remarks - * Adds a callback that will be called when new chat messages - * are sent. - * @param callback - * @example custom_command.js - * ```typescript - * const chatCallback = World.events.beforeChat.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}'`; - * } - * }); + * The back of the sign. * - * ``` */ - subscribe(callback: (arg: ChatEvent) => void): (arg: ChatEvent) => void; + Back = 'Back', /** * @remarks - * Removes a callback from being called when new chat messages - * are sent. - * @param callback - * @throws This function can throw errors. + * The front of the sign. + * */ - unsubscribe(callback: (arg: ChatEvent) => void): void; + Front = 'Front', +} + +export enum StructureAnimationMode { + Blocks = 'Blocks', + Layers = 'Layers', + None = 'None', +} + +export enum StructureMirrorAxis { + None = 'None', + X = 'X', + XZ = 'XZ', + Z = 'Z', +} + +export enum StructureRotation { + None = 'None', + Rotate180 = 'Rotate180', + Rotate270 = 'Rotate270', + Rotate90 = 'Rotate90', +} + +export enum StructureSaveMode { + Memory = 'Memory', + World = 'World', } + /** - * Contains return data on the result of a command execution. + * Provides numeric values for common periods in the Minecraft + * day. */ -export class CommandResult { - protected constructor(); +export enum TimeOfDay { /** - * If the command operates against a number of entities, - * blocks, or items, this returns the number of successful - * applications of this command. + * @remarks + * Sets the time to the start of the day, which is time of the + * day 1,000 (or the equivalent of 7am) in Minecraft. + * */ - readonly successCount: number; -} -/** - * @beta - * Represents a container that can hold sets of items. Used - * with entities such as Players, Chest Minecarts, Llamas, and - * more. - */ -export class Container { - protected constructor(); + Day = 1000, /** - * Count of the slots in the container that are empty. - * @throws - * Throws if the container is invalid. + * @remarks + * Sets the time to noon, which is time of the day 6,000 in + * Minecraft. + * */ - readonly emptySlotsCount: number; + Noon = 6000, /** - * 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. + * @remarks + * Sets the time to sunset, which is time of the day 12,000 (or + * the equivalent of 6pm) in Minecraft. + * */ - readonly size: number; + Sunset = 12000, /** * @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. - * @param itemStack - * The stack of items to add. - * @throws This function can throw errors. + * Sets the time to night, which is time of the day 13,000 (or + * the equivalent of 7:00pm) in Minecraft. + * */ - addItem(itemStack: ItemStack): void; + Night = 13000, /** * @remarks - * Clears all inventory items in the container. - * @throws - * Throws if the container is invalid. + * Sets the time to midnight, which is time of the day 18,000 + * (or the equivalent of 12:00am) in Minecraft. + * */ - clearAll(): void; + Midnight = 18000, /** * @remarks - * Clears a specific item at a slot within the container. - * @param slot - * @throws - * Throws if the container is invalid. + * Sets the time to sunrise, which is time of the day 23,000 + * (or the equivalent of 5am) in Minecraft. + * */ - clearItem(slot: number): void; + 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 - * 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); + * Script runtime for a behavior pack is terminated due to + * non-responsiveness from script (a hang or infinite loop). * - * ``` */ - getItem(slot: number): ItemStack; + Hang = 'Hang', /** + * @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. + * Script runtime for a behavior pack is terminated due to a + * stack overflow (a long, and potentially infinite) chain of + * function calls. + * */ - getSlot(slot: number): ContainerSlot; + StackOverflow = 'StackOverflow', +} + +/** + * Used to specify the type of weather condition within the + * world. + */ +export enum WeatherType { /** * @remarks - * Sets an item stack within a particular slot. - * @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. + * Specifies a clear weather condition. + * */ - setItem(slot: number, itemStack?: ItemStack): void; + Clear = 'Clear', /** * @remarks - * Swaps items between two different slots within containers. - * @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); + * Specifies a rain weather condition. * - * ``` */ - swapItems(slot: number, otherSlot: number, otherContainer: Container): boolean; + Rain = 'Rain', /** * @remarks - * Moves an item from one slot to another container, or to the - * first available slot in the same container. - * @param fromSlot - * Zero-based index of the slot to transfer an item from, on - * this container. - * @param toSlot - * @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); + * Specifies a rain and thunder weather condition. * - * ``` */ - transferItem(fromSlot: number, toSlot: number, toContainer: Container): boolean; + Thunder = 'Thunder', } + /** * @beta - * Represents a slot within a broader container (e.g., entity - * inventory.) */ -export class ContainerSlot { - protected constructor(); +export type BlockComponentTypeMap = { + inventory: BlockInventoryComponent; + lavaContainer: BlockLavaContainerComponent; + 'minecraft:inventory': BlockInventoryComponent; + 'minecraft:lavaContainer': BlockLavaContainerComponent; + 'minecraft:piston': BlockPistonComponent; + 'minecraft:potionContainer': BlockPotionContainerComponent; + 'minecraft:recordPlayer': BlockRecordPlayerComponent; + 'minecraft:sign': BlockSignComponent; + 'minecraft:snowContainer': BlockSnowContainerComponent; + 'minecraft:waterContainer': BlockWaterContainerComponent; + piston: BlockPistonComponent; + potionContainer: BlockPotionContainerComponent; + recordPlayer: BlockRecordPlayerComponent; + sign: BlockSignComponent; + snowContainer: BlockSnowContainerComponent; + waterContainer: BlockWaterContainerComponent; +}; + +/** + * @beta + */ +export type EntityComponentTypeMap = { + addrider: EntityAddRiderComponent; + ageable: EntityAgeableComponent; + breathable: EntityBreathableComponent; + can_climb: EntityCanClimbComponent; + can_fly: EntityCanFlyComponent; + can_power_jump: EntityCanPowerJumpComponent; + color: EntityColorComponent; + color2: EntityColor2Component; + equippable: EntityEquippableComponent; + fire_immune: EntityFireImmuneComponent; + floats_in_liquid: EntityFloatsInLiquidComponent; + flying_speed: EntityFlyingSpeedComponent; + friction_modifier: EntityFrictionModifierComponent; + ground_offset: EntityGroundOffsetComponent; + healable: EntityHealableComponent; + health: EntityHealthComponent; + inventory: EntityInventoryComponent; + is_baby: EntityIsBabyComponent; + is_charged: EntityIsChargedComponent; + is_chested: EntityIsChestedComponent; + is_dyeable: EntityIsDyeableComponent; + is_hidden_when_invisible: EntityIsHiddenWhenInvisibleComponent; + is_ignited: EntityIsIgnitedComponent; + is_illager_captain: EntityIsIllagerCaptainComponent; + is_saddled: EntityIsSaddledComponent; + is_shaking: EntityIsShakingComponent; + is_sheared: EntityIsShearedComponent; + is_stackable: EntityIsStackableComponent; + is_stunned: EntityIsStunnedComponent; + is_tamed: EntityIsTamedComponent; + item: EntityItemComponent; + lava_movement: EntityLavaMovementComponent; + leashable: EntityLeashableComponent; + mark_variant: EntityMarkVariantComponent; + 'minecraft:addrider': EntityAddRiderComponent; + 'minecraft:ageable': EntityAgeableComponent; + 'minecraft:breathable': EntityBreathableComponent; + 'minecraft:can_climb': EntityCanClimbComponent; + 'minecraft:can_fly': EntityCanFlyComponent; + 'minecraft:can_power_jump': EntityCanPowerJumpComponent; + 'minecraft:color': EntityColorComponent; + 'minecraft:color2': EntityColor2Component; + 'minecraft:equippable': EntityEquippableComponent; + 'minecraft:fire_immune': EntityFireImmuneComponent; + 'minecraft:floats_in_liquid': EntityFloatsInLiquidComponent; + 'minecraft:flying_speed': EntityFlyingSpeedComponent; + 'minecraft:friction_modifier': EntityFrictionModifierComponent; + 'minecraft:ground_offset': EntityGroundOffsetComponent; + 'minecraft:healable': EntityHealableComponent; + 'minecraft:health': EntityHealthComponent; + 'minecraft:inventory': EntityInventoryComponent; + 'minecraft:is_baby': EntityIsBabyComponent; + 'minecraft:is_charged': EntityIsChargedComponent; + 'minecraft:is_chested': EntityIsChestedComponent; + 'minecraft:is_dyeable': EntityIsDyeableComponent; + 'minecraft:is_hidden_when_invisible': EntityIsHiddenWhenInvisibleComponent; + 'minecraft:is_ignited': EntityIsIgnitedComponent; + 'minecraft:is_illager_captain': EntityIsIllagerCaptainComponent; + 'minecraft:is_saddled': EntityIsSaddledComponent; + 'minecraft:is_shaking': EntityIsShakingComponent; + 'minecraft:is_sheared': EntityIsShearedComponent; + 'minecraft:is_stackable': EntityIsStackableComponent; + 'minecraft:is_stunned': EntityIsStunnedComponent; + 'minecraft:is_tamed': EntityIsTamedComponent; + 'minecraft:item': EntityItemComponent; + 'minecraft:lava_movement': EntityLavaMovementComponent; + 'minecraft:leashable': EntityLeashableComponent; + 'minecraft:mark_variant': EntityMarkVariantComponent; + 'minecraft:movement': EntityMovementComponent; + 'minecraft:movement.amphibious': EntityMovementAmphibiousComponent; + 'minecraft:movement.basic': EntityMovementBasicComponent; + 'minecraft:movement.fly': EntityMovementFlyComponent; + 'minecraft:movement.generic': EntityMovementGenericComponent; + 'minecraft:movement.glide': EntityMovementGlideComponent; + 'minecraft:movement.hover': EntityMovementHoverComponent; + 'minecraft:movement.jump': EntityMovementJumpComponent; + 'minecraft:movement.skip': EntityMovementSkipComponent; + 'minecraft:movement.sway': EntityMovementSwayComponent; + 'minecraft:navigation.climb': EntityNavigationClimbComponent; + 'minecraft:navigation.float': EntityNavigationFloatComponent; + 'minecraft:navigation.fly': EntityNavigationFlyComponent; + 'minecraft:navigation.generic': EntityNavigationGenericComponent; + 'minecraft:navigation.hover': EntityNavigationHoverComponent; + 'minecraft:navigation.walk': EntityNavigationWalkComponent; + 'minecraft:npc': EntityNpcComponent; + 'minecraft:onfire': EntityOnFireComponent; + 'minecraft:projectile': EntityProjectileComponent; + 'minecraft:push_through': EntityPushThroughComponent; + 'minecraft:rideable': EntityRideableComponent; + 'minecraft:riding': EntityRidingComponent; + 'minecraft:scale': EntityScaleComponent; + 'minecraft:skin_id': EntitySkinIdComponent; + 'minecraft:strength': EntityStrengthComponent; + 'minecraft:tameable': EntityTameableComponent; + 'minecraft:tamemount': EntityTameMountComponent; + 'minecraft:type_family': EntityTypeFamilyComponent; + 'minecraft:underwater_movement': EntityUnderwaterMovementComponent; + 'minecraft:variant': EntityVariantComponent; + 'minecraft:wants_jockey': EntityWantsJockeyComponent; + movement: EntityMovementComponent; + 'movement.amphibious': EntityMovementAmphibiousComponent; + 'movement.basic': EntityMovementBasicComponent; + 'movement.fly': EntityMovementFlyComponent; + 'movement.generic': EntityMovementGenericComponent; + 'movement.glide': EntityMovementGlideComponent; + 'movement.hover': EntityMovementHoverComponent; + 'movement.jump': EntityMovementJumpComponent; + 'movement.skip': EntityMovementSkipComponent; + 'movement.sway': EntityMovementSwayComponent; + 'navigation.climb': EntityNavigationClimbComponent; + 'navigation.float': EntityNavigationFloatComponent; + 'navigation.fly': EntityNavigationFlyComponent; + 'navigation.generic': EntityNavigationGenericComponent; + 'navigation.hover': EntityNavigationHoverComponent; + 'navigation.walk': EntityNavigationWalkComponent; + npc: EntityNpcComponent; + onfire: EntityOnFireComponent; + projectile: EntityProjectileComponent; + push_through: EntityPushThroughComponent; + rideable: EntityRideableComponent; + riding: EntityRidingComponent; + scale: EntityScaleComponent; + skin_id: EntitySkinIdComponent; + strength: EntityStrengthComponent; + tameable: EntityTameableComponent; + tamemount: EntityTameMountComponent; + type_family: EntityTypeFamilyComponent; + underwater_movement: EntityUnderwaterMovementComponent; + variant: EntityVariantComponent; + wants_jockey: EntityWantsJockeyComponent; +}; + +/** + * @beta + */ +export type ItemComponentTypeMap = { + cooldown: ItemCooldownComponent; + durability: ItemDurabilityComponent; + enchantable: ItemEnchantableComponent; + food: ItemFoodComponent; + 'minecraft:cooldown': ItemCooldownComponent; + 'minecraft:durability': ItemDurabilityComponent; + 'minecraft:enchantable': ItemEnchantableComponent; + 'minecraft:food': ItemFoodComponent; +}; + +/** + * @beta + * Describes a type of biome. + */ +export class BiomeType { + private constructor(); /** - * 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. - * @throws - * Throws if the value is outside the range of 1-255. + * @remarks + * Identifier of the biome type. + * */ - amount: number; - data: number; - /** - * 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; - readonly isValid: boolean; + readonly id: string; +} + +/** + * @beta + * Supports a catalog of available biome types registered + * within Minecraft. + */ +export class BiomeTypes { + private constructor(); /** - * Gets or sets whether the item is kept on death. - * @throws - * Throws if the slot's container is invalid. + * @remarks + * Returns a specific biome type. + * + * @param typeName + * Identifier of the biome. Generally, namespaced identifiers + * (e.g., minecraft:frozen_peaks) should be used. + * @returns + * If the biome exists, a BiomeType object is returned. If not, + * undefined is returned. */ - keepOnDeath: boolean; + static get(typeName: string): BiomeType | undefined; /** - * Gets or sets the item's lock mode. The default value is - * `ItemLockMode.none`. - * @throws - * Throws if the slot's container is invalid. + * @remarks + * Returns all registered biome types within Minecraft + * */ - lockMode: ItemLockMode; + static getAll(): BiomeType[]; +} + +/** + * 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(); /** - * 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. + * @remarks + * Returns the dimension that the block is within. + * */ - readonly maxAmount: number; + readonly dimension: Dimension; /** - * 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. - * @throws - * Throws if the slot's container is invalid. Also throws if - * the length exceeds 255 characters. + * @remarks + * Returns true if this block is an air block (i.e., empty + * space). + * + * @throws This property can throw when used. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - nameTag?: string; + readonly isAir: boolean; /** - * The type of the item. - * @throws - * Throws if the slot's container is invalid. + * @remarks + * Returns true if this block is a liquid block - (e.g., a + * water block and a lava block 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. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - readonly 'type': ItemType; + readonly isLiquid: boolean; /** - * 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. + * @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. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - readonly typeId?: string; + readonly isSolid: boolean; /** + * @beta * @remarks - * Creates an exact copy of the item stack, including any - * custom data or properties. - * @throws - * Throws if the slot's container is invalid. + * Returns or sets whether this block has a liquid on it. + * + * @throws This property can throw when used. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - clone(): ItemStack; - getItem(): ItemStack; + readonly isWaterlogged: boolean; /** * @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. + * Coordinates of the specified block. + * + * @throws This property can throw when used. */ - getLore(): string[]; + readonly location: Vector3; /** * @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 - * @throws - * Throws if the slot's container is invalid. + * Additional block configuration data that describes the + * block. + * + * @throws This property can throw when used. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - isStackableWith(itemStack: ItemStack): boolean; + readonly permutation: BlockPermutation; /** + * @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. - * @param blockIdentifiers - * @throws - * Throws if the slot's container is invalid. Also throws if - * any of the provided block identifiers are invalid. + * Gets the type of block. + * + * @throws This property can throw when used. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - setCanDestroy(blockIdentifiers?: string[]): void; + readonly 'type': BlockType; /** + * @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. - * @param blockIdentifiers - * @throws - * Throws if the slot's container is invalid. Also throws if - * any of the provided block identifiers are invalid. + * Identifier of the type of block for this block. + * + * @throws This property can throw when used. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - setCanPlaceOn(blockIdentifiers?: string[]): void; - setItem(itemStack?: ItemStack): void; + readonly typeId: string; /** * @remarks - * Sets the lore value - a secondary display string - for an - * ItemStack. - * @param loreList - * @throws - * Throws if the slot's container is invalid. + * X coordinate of the block. + * */ - 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 DataDrivenEntityTriggerEvent { - protected constructor(); + readonly x: number; /** - * Entity that the event triggered on. + * @remarks + * Y coordinate of the block. + * */ - readonly entity: Entity; + readonly y: number; /** - * Name of the data driven event being triggered. + * @remarks + * Z coordinate of the block. + * */ - readonly id: string; - 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 DataDrivenEntityTriggerEventSignal { - protected constructor(); + readonly z: number; /** * @remarks - * Adds a callback that will be called after a data driven - * entity event is triggered. - * @param callback - * @param options + * Returns the {@link Block} above this block (positive in the + * Y direction). + * + * @param steps + * Number of steps above to step before returning. + * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - subscribe( - callback: (arg: DataDrivenEntityTriggerEvent) => void, - options?: EntityDataDrivenTriggerEventOptions, - ): (arg: DataDrivenEntityTriggerEvent) => void; + above(steps?: number): Block | undefined; /** * @remarks - * Removes a callback that will be called after a data driven - * entity event is triggered. - * @param callback + * Returns the {@link Block} below this block (negative in the + * Y direction). + * + * @param steps + * Number of steps below to step before returning. * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - unsubscribe(callback: (arg: DataDrivenEntityTriggerEvent) => void): void; -} -/** - * @beta - * Contains a set of updates to the component definition state - * of an entity. - */ -export class DefinitionModifier { - getComponentGroupsToAdd(): string[]; - getComponentGroupsToRemove(): string[]; - getTriggers(): Trigger[]; - setComponentGroupsToAdd(newGroups: string[]): void; - setComponentGroupsToRemove(removedGroups: string[]): void; - setTriggers(newTriggers: Trigger[]): void; -} -/** - * A class that represents a particular dimension (e.g., The - * End) within a world. - */ -export class Dimension { - protected constructor(); + below(steps?: number): Block | undefined; /** - * Identifier of the dimension. - * @throws This property can throw when used. + * @remarks + * Returns the {@link @minecraft/server.Location} of the center + * of this block on the X and Z axis. + * */ - readonly id: string; + bottomCenter(): Vector3; /** * @beta * @remarks - * Creates an explosion at the specified location. - * @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 - * overworld.createExplosion(targetLocation, 10, new mc.ExplosionOptions()); - * ``` - * @example createFireAndWaterExplosions.ts - * ```typescript - * const explosionLoc: mc.Vector3 = { x: targetLocation.x + 0.5, y: targetLocation.y + 0.5, z: targetLocation.z + 0.5 }; - * - * const fireExplosionOptions = new mc.ExplosionOptions(); - * - * // Explode with fire - * fireExplosionOptions.causesFire = true; - * - * overworld.createExplosion(explosionLoc, 15, fireExplosionOptions); - * const waterExplosionOptions = new mc.ExplosionOptions(); + * Checks to see whether it is valid to place the specified + * block type or block permutation, on a specified face on this + * block * - * // Explode in water - * waterExplosionOptions.allowUnderwater = true; + * @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. * - * const belowWaterLoc: mc.Vector3 = { x: targetLocation.x + 3, y: targetLocation.y + 1, z: targetLocation.z + 3 }; + * {@link Error} * - * overworld.createExplosion(belowWaterLoc, 10, waterExplosionOptions); + * {@link LocationInUnloadedChunkError} * - * ``` - * @example createNoBlockExplosion.ts - * ```typescript - * const explosionOptions = new mc.ExplosionOptions(); + * {@link LocationOutOfWorldBoundariesError} + */ + canPlace(blockToPlace: BlockPermutation | BlockType | string, faceToPlaceOn?: Direction): boolean; + /** + * @remarks + * Returns the {@link @minecraft/server.Location} of the center + * of this block on the X, Y, and Z axis. * - * // Start by exploding without breaking blocks - * explosionOptions.breaksBlocks = false; + */ + center(): Vector3; + /** + * @remarks + * Returns the {@link Block} to the east of this block + * (positive in the X direction). * - * const explodeNoBlocksLoc: mc.Vector3 = { - * x: Math.floor(targetLocation.x + 1), - * y: Math.floor(targetLocation.y + 2), - * z: Math.floor(targetLocation.z + 1), - * }; + * @param steps + * Number of steps to the east to step before returning. + * @throws This function can throw errors. * - * overworld.createExplosion(explodeNoBlocksLoc, 15, explosionOptions); + * {@link LocationInUnloadedChunkError} * - * ``` + * {@link LocationOutOfWorldBoundariesError} */ - createExplosion(location: Vector3, radius: number, explosionOptions?: ExplosionOptions): void; + east(steps?: number): Block | undefined; /** - * @beta * @remarks - * Fills an area between begin and end with block of type + * Gets a component (that represents additional capabilities) + * for a block - for example, an inventory component of a chest * block. - * @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. + * + * @param componentId + * The identifier of the component (e.g., + * 'minecraft:inventory'). If no namespace prefix is specified, + * 'minecraft:' is assumed. Available component IDs can be + * found as part of the {@link BlockComponentTypes} enum. * @returns - * Returns number of blocks placed. + * Returns the component if it exists on the block, otherwise + * undefined. * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - fillBlocks(begin: Vector3, end: Vector3, block: BlockPermutation | BlockType, options?: BlockFillOptions): number; + getComponent(componentId: T): BlockComponentTypeMap[T] | undefined; /** - * @beta * @remarks - * Returns a block instance at the given location. This method - * was introduced as of version 1.17.10.21. - * @param location - * The location at which to return a block. + * 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. * @returns - * Block at the specified location. + * An itemStack with the specified amount of items and data. + * Returns undefined if block type is incompatible. * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - getBlock(location: Vector3): Block; + getItemStack(amount?: number, withData?: boolean): ItemStack | undefined; /** * @beta * @remarks - * Gets the first block that intersects with a vector emanating - * from a location. - * @param location - * @param direction - * @param options - * Additional options for processing this raycast query. + * 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. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - getBlockFromRay(location: Vector3, direction: Vector3, options?: BlockRaycastOptions): Block; + getRedstonePower(): number | undefined; /** - * @beta * @remarks - * Returns a set of entities based on a set of conditions - * defined via the EntityQueryOptions set of filter criteria. - * @param getEntities + * Returns a set of tags for a block. + * * @returns - * An entity array. + * The list of tags that the block has. + * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} + */ + getTags(): string[]; + /** + * @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 testThatEntityIsFeatherItem.ts + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} + * @example check_block_tags.js * ```typescript - * const query = { - * type: "item", - * location: targetLocation, - * }; - * const items = overworld.getEntities(query); - * - * for (const item of items) { - * const itemComp = item.getComponent("item") as any; - * - * if (itemComp) { - * if (itemComp.itemStack.id.endsWith("feather")) { - * console.log("Success! Found a feather", 1); - * } - * } - * } + * 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")}`); * ``` */ - getEntities(getEntities?: EntityQueryOptions): EntityIterator; + hasTag(tag: string): boolean; /** - * @beta * @remarks - * Returns a set of entities at a particular location. - * @param location - * The location at which to return entities. + * 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 - * Zero or more entities at the specified location. + * True if this block object is still working and valid. */ - getEntitiesAtBlockLocation(location: Vector3): Entity[]; + isValid(): boolean; /** * @beta * @remarks - * Gets entities that intersect with a specified vector - * emanating from a location. - * @param location - * @param direction - * @param options - * Additional options for processing this raycast query. + * Tests whether this block matches a specific criteria. + * + * @param blockName + * Block type identifier to match this API against. + * @param states + * Optional set of block states to test this block against. + * @returns + * Returns true if the block matches the specified criteria. * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - getEntitiesFromRay(location: Vector3, direction: Vector3, options?: EntityRaycastOptions): Entity[]; + matches(blockName: string, states?: Record): boolean; /** - * @beta * @remarks - * Returns a set of players based on a set of conditions - * defined via the EntityQueryOptions set of filter criteria. - * @param getPlayers - * @returns - * A player array. + * Returns the {@link Block} to the north of this block + * (negative in the Z direction). + * + * @param steps + * Number of steps to the north to step before returning. * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - getPlayers(getPlayers?: EntityQueryOptions): PlayerIterator; + north(steps?: number): Block | undefined; /** * @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 a block at an offset relative vector to this block. + * + * @param offset + * The offset vector. For example, an offset of 0, 1, 0 will + * return the block above the current block. * @returns - * For commands that return data, returns a CommandResult with - * an indicator of command results. + * Block at the specified offset, or undefined if that block + * could not be retrieved (for example, the block and its + * relative chunk is not loaded yet.) * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - runCommandAsync(commandString: string): Promise; + offset(offset: Vector3): Block | undefined; + /** + * @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; /** * @beta * @remarks - * Creates a new entity (e.g., a mob) at the specified - * location. - * @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. + * 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. - * @example createOldHorse.ts - * ```typescript - * // create a horse and trigger the 'ageable_grow_up' event, ensuring the horse is created as an adult - * overworld.spawnEntity("minecraft:horse", targetLocation); - * ``` - * @example quickFoxLazyDog.ts - * ```typescript - * 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); * - * ``` - * @example trapTick.ts - * ```typescript - * let ticks = 0; + * {@link Error} * - * mc.world.events.tick.subscribe((event: mc.TickEvent) => { - * ticks++; + * {@link LocationInUnloadedChunkError} * - * // Minecraft runs at 20 ticks per second - * if (ticks % 1200 === 0) { - * overworld.runCommand("say Another minute passes..."); - * } - * }); - * ``` + * {@link LocationOutOfWorldBoundariesError} */ - spawnEntity(identifier: string, location: Vector3): Entity; + setType(blockType: BlockType | string): void; /** * @beta * @remarks - * Creates a new item stack as an entity at the specified - * location. - * @param item - * @param location - * The location at which to create the item stack. - * @returns - * Newly created item stack entity at the specified location. + * Sets whether this block has a water logged state - for + * example, whether stairs are submerged within water. + * + * This function can't be called in read-only mode. + * + * @param isWaterlogged + * true if the block should have water within it. * @throws This function can throw errors. - * @example itemStacks.ts - * ```typescript - * const oneItemLoc: mc.Vector3 = { x: 3, y: 2, z: 1 }; - * const fiveItemsLoc: mc.Vector3 = { x: 1, y: 2, z: 1 }; - * const diamondPickaxeLoc: mc.Vector3 = { x: 2, y: 2, 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); + * {@link Error} * - * overworld.spawnItem(oneEmerald, oneItemLoc); - * overworld.spawnItem(fiveEmeralds, fiveItemsLoc); - * overworld.spawnItem(onePickaxe, diamondPickaxeLoc); + * {@link LocationInUnloadedChunkError} * - * ``` - * @example spawnItem.ts - * ```typescript - * const featherItem = new mc.ItemStack(mc.MinecraftItemTypes.feather, 1, 0); + * {@link LocationOutOfWorldBoundariesError} + */ + setWaterlogged(isWaterlogged: boolean): void; + /** + * @remarks + * Returns the {@link Block} to the south of this block + * (positive in the Z direction). * - * overworld.spawnItem(featherItem, targetLocation); - * log("New feather created!"); - * ``` + * @param steps + * Number of steps to the south to step before returning. + * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - spawnItem(item: ItemStack, location: Vector3): Entity; + south(steps?: number): Block | undefined; /** * @beta * @remarks - * Creates a new particle emitter at a specified location in - * the world. - * @param effectName - * Identifier of the particle to create. - * @param location - * The location at which to create the particle emitter. - * @param molangVariables - * A set of additional, customizable variables that can be - * adjusted for this particle emitter. + * 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 - * Newly created entity at the specified location. + * Returns `true` if the block permutation data was + * successfully set, else `false`. + * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} + */ + trySetPermutation(permutation: BlockPermutation): boolean; + /** + * @remarks + * Returns the {@link Block} to the west of this block + * (negative in the X direction). + * + * @param steps + * Number of steps to the west to step before returning. + * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - spawnParticle(effectName: string, location: Vector3, molangVariables: MolangVariableMap): void; + west(steps?: number): Block | undefined; } + /** - * @beta - * For block properties that take a direction, provides a - * structured way to specify the direction of a block property. + * Base type for components associated with blocks. */ -export class DirectionBlockProperty { - protected constructor(); - /** - * Name of the property. - */ - readonly name: string; +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockComponent extends Component { + private constructor(); /** - * Value of the block property. + * @remarks + * Block instance that this component pertains to. + * */ - value: Direction; - getValidValues(): Direction[]; + readonly block: Block; } + /** * @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. + * Contains information regarding an entity falling onto a + * specific block. */ -export class DynamicPropertiesDefinition { +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockComponentEntityFallOnEvent extends BlockEvent { + private constructor(); /** * @remarks - * Defines a boolean dynamic property. - * @param identifier - * @throws This function can throw errors. + * The entity that fell onto the block. + * */ - defineBoolean(identifier: string): void; + readonly entity?: Entity; /** * @remarks - * Defines a number dynamic property. - * @param identifier - * @throws This function can throw errors. + * The distance that the entity fell onto this block with. + * */ - defineNumber(identifier: string): void; + readonly fallDistance: number; +} + +/** + * @beta + * Contains information regarding a specific block that was + * placed. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockComponentOnPlaceEvent extends BlockEvent { + private constructor(); /** * @remarks - * Defines a string dynamic property. - * @param identifier - * @param maxLength - * @throws This function can throw errors. + * Previous block at this location that was replaced. + * */ - defineString(identifier: string, maxLength: number): void; + readonly previousBlock: BlockPermutation; } + /** * @beta - * Represents an effect - like poison - that has been added to - * an Entity. + * Contains information regarding a specific block being + * destroyed. */ -export class Effect { - protected constructor(); - /** - * 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; +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockComponentPlayerDestroyEvent extends BlockEvent { + private constructor(); /** - * Gets the player-friendly name of this effect. - * @throws This property can throw when used. + * @remarks + * Returns permutation information about this block before it + * was destroyed. + * */ - readonly displayName: string; + readonly destroyedBlockPermutation: BlockPermutation; /** - * Gets the entire specified duration, in ticks, of this - * effect. - * @throws This property can throw when used. + * @remarks + * The player that destroyed this block. + * */ - readonly duration: number; + readonly player?: Player; } + /** * @beta - * Contains information related to changes to an effect - like - * poison - being added to an entity. + * Contains information regarding a specific block being + * interacted with. */ -export class EffectAddEvent { - protected constructor(); +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockComponentPlayerInteractEvent extends BlockEvent { + private constructor(); /** - * Additional properties and details of the effect. + * @remarks + * The block face that was interacted with. + * */ - effect: Effect; + readonly face: Direction; /** - * Additional variant number for the effect. + * @remarks + * Location relative to the bottom north-west corner of the + * block that the player interacted with. + * */ - effectState: number; + readonly faceLocation?: Vector3; /** - * Entity that the effect is being added to. + * @remarks + * The player that interacted with this block. + * */ - entity: Entity; + readonly player?: Player; } + /** * @beta - * Manages callbacks that are connected to when an effect is - * added to an entity. + * Contains information regarding an event before a player + * places a block. */ -export class EffectAddEventSignal { - protected constructor(); +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockComponentPlayerPlaceBeforeEvent extends BlockEvent { + private constructor(); /** * @remarks - * Adds a callback that will be called when an effect is added - * to an entity. - * @param callback - * @param options + * If set to true, cancels the block place event. + * */ - subscribe(callback: (arg: EffectAddEvent) => void, options?: EntityEventOptions): (arg: EffectAddEvent) => void; + cancel: boolean; /** * @remarks - * Removes a callback from being called when an effect is added - * to an entity. - * @param callback + * The block face that was placed onto. + * + */ + readonly face: Direction; + /** + * @remarks + * The block permutation that will be placed if the event is + * not cancelled. If set to a different block permutation, that + * permutation will be placed instead. + * + */ + permutationToPlace: BlockPermutation; + /** + * @remarks + * The player that is placing this block. + * + */ + readonly player?: Player; +} + +/** + * @beta + * Contains information regarding a specific block randomly + * ticking. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockComponentRandomTickEvent extends BlockEvent { + private constructor(); +} + +/** + * @beta + */ +export class BlockComponentRegistry { + private constructor(); + /** * @throws This function can throw errors. + * + * {@link minecraftcommon.EngineError} + * + * {@link Error} */ - unsubscribe(callback: (arg: EffectAddEvent) => void): void; + registerCustomComponent(name: string, customComponent: BlockCustomComponent): void; } + /** * @beta - * Represents a type of effect - like poison - that can be - * applied to an entity. + * Contains information regarding an entity stepping off a + * specific block. */ -export class EffectType { - protected constructor(); +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockComponentStepOffEvent extends BlockEvent { + private constructor(); /** * @remarks - * Identifier name of this effect type. - * @returns - * Identifier of the effect type. + * The entity that stepped off the block. + * */ - getName(): string; + readonly entity?: Entity; } + /** * @beta - * This class represents a specific leveled enchantment that is - * applied to an item. + * Contains information regarding an entity stepping onto a + * specific block. */ -export class Enchantment { +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockComponentStepOnEvent extends BlockEvent { + private constructor(); /** - * The level of this enchantment instance. + * @remarks + * The entity that stepped on the block. + * */ - level: number; + readonly entity?: Entity; +} + +/** + * @beta + * Contains information regarding a specific block ticking. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockComponentTickEvent extends BlockEvent { + private constructor(); +} + +/** + * Contains information regarding an event that impacts a + * specific block. + */ +export class BlockEvent { + private constructor(); /** - * The enchantment type of this instance. + * @remarks + * Block impacted by this event. + * */ - readonly 'type': EnchantmentType; + readonly block: Block; /** * @remarks - * Creates a new particular type of enchantment configuration. - * @param enchantmentType - * Type of the enchantment. - * @param level - * Level of the enchantment. + * Dimension that contains the block that is the subject of + * this event. + * */ - constructor(enchantmentType: EnchantmentType, level?: number); + readonly dimension: Dimension; } + /** * @beta - * This class represents a collection of enchantments that can - * be applied to an item. + * Contains information regarding an explosion that has + * occurred for a specific block. */ -export class EnchantmentList implements Iterable { +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockExplodeAfterEvent extends BlockEvent { + private constructor(); /** - * The item slot/type that this collection is applied to. + * @remarks + * Description of the block that has exploded. + * */ - readonly slot: number; + readonly explodedBlockPermutation: BlockPermutation; /** * @remarks - * Creates a new EnchantmentList. - * @param enchantmentSlot + * Optional source of the explosion. + * */ - constructor(enchantmentSlot: number); - [Symbol.iterator](): Iterator; + 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 - * Attempts to add the enchantment to this collection. Returns - * true if successful. - * @param enchantment + * 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. + * */ - addEnchantment(enchantment: Enchantment): boolean; + subscribe(callback: (arg: BlockExplodeAfterEvent) => void): (arg: BlockExplodeAfterEvent) => void; /** * @remarks - * Returns whether or not the provided EnchantmentInstance can - * be added to this collection. - * @param enchantment + * 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. */ - canAddEnchantment(enchantment: Enchantment): boolean; + unsubscribe(callback: (arg: BlockExplodeAfterEvent) => void): void; +} + +/** + * Represents the inventory of a block in the world. Used with + * blocks like chests. + * @example place_items_in_chest.js + * ```typescript + * import { world, MinecraftBlockTypes, Items, ItemStack } from "@minecraft/server"; + * + * // Fetch block + * const block = world.getDimension("overworld").getBlock({ x: 1, y: 2, z: 3 }); + * + * // Make it a chest + * block.setType(MinecraftBlockTypes.chest); + * + * // Get the inventory + * const inventoryComponent = block.getComponent("inventory"); + * const inventoryContainer = inventoryComponent.container; + * + * // Set slot 0 to a stack of 10 apples + * inventoryContainer.setItem(0, new ItemStack(Items.apple, 10, 0)); + * + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockInventoryComponent extends BlockComponent { + private constructor(); /** * @remarks - * Returns an enchantment associated with a type. - * @param enchantmentType + * The container which holds an {@link ItemStack}. + * + * @throws This property can throw when used. */ - getEnchantment(enchantmentType: EnchantmentType): Enchantment; + 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 - * If this collection has an EnchantmentInstance with type, - * returns the level of the enchantment. Returns 0 if not - * present. - * @param enchantmentType + * Relative fill level of the liquid container. + * + * This property can't be edited in read-only mode. + * */ - hasEnchantment(enchantmentType: EnchantmentType): number; - next(): IteratorResult; + fillLevel: number; /** * @remarks - * Removes an EnchantmentInstance with type from this - * collection if present. - * @param enchantmentType + * 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. */ - removeEnchantment(enchantmentType: EnchantmentType): void; -} -/** - * @beta - * This enum represents the item slot or type that an - * enchantment can be applied to. - */ -// tslint:disable-next-line:no-unnecessary-class -export class EnchantmentSlot { - protected 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; + isValidLiquid(): boolean; } + /** * @beta - * Contains information on a type of enchantment. + * 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 EnchantmentType { - protected constructor(); +export class BlockLocationIterator implements Iterable { + private constructor(); /** - * The name of the enchantment type. + * @remarks + * This function can't be called in read-only mode. + * */ - readonly id: string; + [Symbol.iterator](): Iterator; /** - * The maximum level this type of enchantment can have. + * @remarks + * This function can't be called in read-only mode. + * */ - readonly maxLevel: number; + next(): IteratorResult; } + /** - * Represents the state of an entity (a mob, the player, or - * other moving objects like minecarts) in the world. + * 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}). + * @example createTranslatedSign.ts + * ```typescript + * // A function the creates a sign at the specified location with the specified text + * import { DimensionLocation, BlockPermutation, BlockComponentTypes } from '@minecraft/server'; + * import { MinecraftBlockTypes } from '@minecraft/vanilla-data'; + * + * function createSignAt(location: DimensionLocation) { + * const signBlock = location.dimension.getBlock(location); + * + * if (!signBlock) { + * console.warn('Could not find a block at specified location.'); + * return; + * } + * + * const signPerm = BlockPermutation.resolve(MinecraftBlockTypes.StandingSign, { ground_sign_direction: 8 }); + * signBlock.setPermutation(signPerm); // Update block to be a sign + * + * // Update the sign block's text + * // with "Steve's Head" + * const signComponent = signBlock.getComponent(BlockComponentTypes.Sign); + * if (signComponent) { + * signComponent.setText({ translate: 'item.skull.player.name', with: ['Steve'] }); + * } + * } + * ``` */ -export class Entity { - protected constructor(); +export class BlockPermutation { + private constructor(); /** * @beta - * Dimension that the entity is currently within. - * @throws This property can throw when used. - */ - readonly dimension: Dimension; - /** - * 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. - * @throws This property can throw when used. + * @remarks + * The {@link BlockType} that the permutation has. + * */ - readonly id: string; + readonly 'type': BlockType; /** * @beta - * Whether the entity is sneaking - that is, moving more slowly - * and more quietly. + * @remarks + * Creates a copy of this permutation. + * + * @returns + * A copy of the permutation. */ - isSneaking: boolean; + clone(): BlockPermutation; /** - * @beta - * Current location of the entity. - * @throws This property can throw when used. + * @remarks + * Returns all available block states associated with this + * block. + * + * @returns + * Returns the list of all of the block states that the + * permutation has. */ - readonly location: Vector3; + getAllStates(): Record; /** - * @beta - * Given name of the entity. + * @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. */ - nameTag: string; + getItemStack(amount?: number): ItemStack | undefined; /** - * @beta - * Returns a scoreboard identity that represents this entity. - * @throws This property can throw when used. + * @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`. */ - readonly scoreboard: ScoreboardIdentity; + getState(stateName: string): boolean | number | string | undefined; /** * @beta - * 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; - /** - * Unique identifier of the type of the entity - for example, - * 'minecraft:skeleton'. - * @throws This property can throw when used. + * @remarks + * Creates a copy of the permutation. + * */ - readonly typeId: string; + getTags(): string[]; /** * @beta * @remarks - * Adds an effect, like poison, to the entity. - * @param effectType - * Type of effect to add to the entity. - * @param duration - * Amount of time, in ticks, for the effect to apply. - * @param amplifier - * Optional amplification of the effect to apply. - * @param showParticles - * @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(MinecraftEffectTypes.poison, duration, 1); - * + * Checks to see if the permutation has a specific tag. * - * ``` - * @example quickFoxLazyDog.ts + * @returns + * Returns `true` if the permutation has the tag, else `false`. + * @example check_block_tags.js * ```typescript - * 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); + * 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")}`); * ``` */ - addEffect(effectType: EffectType, duration: number, amplifier?: number, showParticles?: boolean): void; + hasTag(tag: string): boolean; /** - * @beta * @remarks - * Adds a specified tag to an entity. - * @param tag - * Content of the tag to add. - * @throws This function can throw errors. + * 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. */ - addTag(tag: string): boolean; + matches(blockName: string, states?: Record): boolean; /** - * @beta * @remarks - * Applies a set of damage to an entity. - * @param amount - * Amount of damage to apply. - * @param source - * Additional option about the source of damage, which may add - * additional effects or spur additional behaviors on this - * entity. + * 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. */ - applyDamage(amount: number, source?: EntityDamageSource): boolean; - applyImpulse(vector: Vector3): void; - applyKnockback(directionX: number, directionZ: number, horizontalStrength: number, verticalStrength: number): void; - clearVelocity(): void; + withState(name: string, value: boolean | number | string): BlockPermutation; /** - * @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. - * @param useEffects - * Whether to show any visual effects connected to the - * extinguishing. + * 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. - */ - extinguishFire(useEffects?: boolean): boolean; + * @example addBlockColorCube.ts + * ```typescript + * import { DimensionLocation, BlockPermutation } from '@minecraft/server'; + * import { MinecraftBlockTypes } from '@minecraft/vanilla-data'; + * + * const allWoolBlocks: string[] = [ + * MinecraftBlockTypes.WhiteWool, + * MinecraftBlockTypes.OrangeWool, + * MinecraftBlockTypes.MagentaWool, + * MinecraftBlockTypes.LightBlueWool, + * MinecraftBlockTypes.YellowWool, + * MinecraftBlockTypes.LimeWool, + * MinecraftBlockTypes.PinkWool, + * MinecraftBlockTypes.GrayWool, + * MinecraftBlockTypes.LightGrayWool, + * MinecraftBlockTypes.CyanWool, + * MinecraftBlockTypes.PurpleWool, + * MinecraftBlockTypes.BlueWool, + * MinecraftBlockTypes.BrownWool, + * MinecraftBlockTypes.GreenWool, + * MinecraftBlockTypes.RedWool, + * MinecraftBlockTypes.BlackWool, + * ]; + * + * const cubeDim = 7; + * + * function placeRainbowCube(location: DimensionLocation) { + * 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++; + * location.dimension + * .getBlock({ x: location.x + x, y: location.y + y, z: location.z + z }) + * ?.setPermutation(BlockPermutation.resolve(allWoolBlocks[colorIndex % allWoolBlocks.length])); + * } + * } + * } + * } + * ``` + */ + static resolve(blockName: string, states?: Record): BlockPermutation; +} + +/** + * 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(); /** - * @beta * @remarks - * Returns the first intersecting block from the direction that - * this entity is looking at. - * @param options - * @throws This function can throw errors. + * Whether the piston is in the process of expanding or + * retracting. + * + * @throws This property can throw when used. */ - getBlockFromViewDirection(options?: BlockRaycastOptions): Block; + readonly isMoving: boolean; /** - * @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. + * The current state of the piston. + * + * @throws This property can throw when used. */ - getComponent(componentId: string): IEntityComponent; + readonly state: BlockPistonState; + static readonly componentId = 'minecraft:piston'; /** - * @beta * @remarks - * Returns all components that are both present on this entity - * and supported by the API. + * Retrieves a set of blocks that this piston is connected + * with. + * + * @throws This function can throw errors. */ - getComponents(): IEntityComponent[]; + getAttachedBlocks(): Block[]; /** - * @beta * @remarks - * Returns a property value. - * @param identifier - * @returns - * Returns the value for the property, or undefined if the - * property has not been set. + * Retrieves a set of block locations that this piston is + * connected with. + * * @throws This function can throw errors. */ - getDynamicProperty(identifier: string): boolean | number | string | undefined; + getAttachedBlocksLocations(): 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'; /** - * @beta * @remarks - * Returns the effect for the specified EffectType on the - * entity, or undefined if the effect is not present. - * @param effectType - * @returns - * Effect object for the specified effect, or undefined if the - * effect is not present. + * 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. */ - getEffect(effectType: EffectType): Effect; + 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'; /** - * @beta * @remarks - * Returns a set of effects applied to this item. - * @returns - * List of effects. + * 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. */ - getEffects(): Effect[]; + clearRecord(): void; /** - * @beta * @remarks - * Returns a potential set of entities from the direction that - * this entity is looking at. - * @param options + * Returns true if the record-playing block is currently + * playing a record. + * * @throws This function can throw errors. */ - getEntitiesFromViewDirection(options?: EntityRaycastOptions): Entity[]; - getHeadLocation(): Vector3; - getRotation(): XYRotation; + isPlaying(): boolean; /** - * @beta * @remarks - * Returns all tags associated with an entity. + * 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. */ - getTags(): string[]; - getVelocity(): Vector3; - getViewDirection(): Vector3; + setRecord(recordItemType: ItemType | string): void; +} + +/** + * Represents a block that can display text on it. + * @example addTwoSidedSign.ts + * ```typescript + * // A function the creates a sign at the specified location with text on both sides and dye colors + * import { + * DimensionLocation, + * BlockPermutation, + * BlockSignComponent, + * BlockComponentTypes, + * DyeColor, + * SignSide, + * } from '@minecraft/server'; + * import { MinecraftBlockTypes } from '@minecraft/vanilla-data'; + * + * function createSignAt(location: DimensionLocation) { + * const block = location.dimension.getBlock(location); + * if (!block) { + * console.warn('Could not find a block at specified location.'); + * return; + * } + * const signPerm = BlockPermutation.resolve(MinecraftBlockTypes.StandingSign, { + * ground_sign_direction: 8, + * }); + * block.setPermutation(signPerm); + * const sign = block.getComponent(BlockComponentTypes.Sign); + * + * if (sign !== undefined) { + * sign.setText(`Party Sign!\nThis is green on the front.`); + * sign.setText(`Party Sign!\nThis is red on the back.`, SignSide.Back); + * sign.setTextDyeColor(DyeColor.Green); + * sign.setTextDyeColor(DyeColor.Red, SignSide.Back); + * + * // players cannot edit sign! + * sign.setWaxed(true); + * } else { + * console.warn('Could not find a sign component on the block.'); + * } + * } + * ``` + * @example setSignText.ts + * ```typescript + * import { + * BlockComponentTypes, + * DimensionLocation, + * RawMessage, + * RawText, + * } from '@minecraft/server'; + * + * // Function which updates a sign blocks text to raw text + * function updateSignText(signLocation: DimensionLocation) { + * const block = signLocation.dimension.getBlock(signLocation); + * if (!block) { + * console.warn('Could not find a block at specified location.'); + * return; + * } + * + * const sign = block.getComponent(BlockComponentTypes.Sign); + * if (sign) { + * // RawMessage + * const helloWorldMessage: RawMessage = { text: 'Hello World' }; + * sign.setText(helloWorldMessage); + * + * // RawText + * const helloWorldText: RawText = { rawtext: [{ text: 'Hello World' }] }; + * sign.setText(helloWorldText); + * + * // Regular string + * sign.setText('Hello World'); + * } else { + * console.warn('Could not find a sign component on the block.'); + * } + * } + * ``` + * @example createTranslatedSign.ts + * ```typescript + * // A function the creates a sign at the specified location with the specified text + * import { DimensionLocation, BlockPermutation, BlockComponentTypes } from '@minecraft/server'; + * import { MinecraftBlockTypes } from '@minecraft/vanilla-data'; + * + * function createSignAt(location: DimensionLocation) { + * const signBlock = location.dimension.getBlock(location); + * + * if (!signBlock) { + * console.warn('Could not find a block at specified location.'); + * return; + * } + * + * const signPerm = BlockPermutation.resolve(MinecraftBlockTypes.StandingSign, { ground_sign_direction: 8 }); + * signBlock.setPermutation(signPerm); // Update block to be a sign + * + * // Update the sign block's text + * // with "Steve's Head" + * const signComponent = signBlock.getComponent(BlockComponentTypes.Sign); + * if (signComponent) { + * signComponent.setText({ translate: 'item.skull.player.name', with: ['Steve'] }); + * } + * } + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockSignComponent extends BlockComponent { + private constructor(); /** - * @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. + * 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. */ - hasComponent(componentId: string): boolean; + readonly isWaxed: boolean; + static readonly componentId = 'minecraft:sign'; /** - * @beta * @remarks - * Tests whether an entity has a particular tag. - * @param tag - * Identifier of the tag to test for. + * 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. */ - hasTag(tag: string): boolean; + getRawText(side?: SignSide): RawText | undefined; /** - * @beta * @remarks - * Kills this entity. The entity will drop loot as normal. + * 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. */ - kill(): void; - playAnimation(animationName: string, options?: PlayAnimationOptions): void; + getText(side?: SignSide): string | undefined; /** - * @beta * @remarks - * Removes a specified property. - * @param identifier + * 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. */ - removeDynamicProperty(identifier: string): boolean; + getTextDyeColor(side?: SignSide): DyeColor | undefined; /** - * @beta * @remarks - * Removes a specified tag from an entity. - * @param tag - * Content of the tag to remove. - * @throws This function can throw errors. + * 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 + * Throws if the provided message is greater than 512 + * characters in length. + * @example setSignText.ts + * ```typescript + * import { + * BlockComponentTypes, + * DimensionLocation, + * RawMessage, + * RawText, + * } from '@minecraft/server'; + * + * // Function which updates a sign blocks text to raw text + * function updateSignText(signLocation: DimensionLocation) { + * const block = signLocation.dimension.getBlock(signLocation); + * if (!block) { + * console.warn('Could not find a block at specified location.'); + * return; + * } + * + * const sign = block.getComponent(BlockComponentTypes.Sign); + * if (sign) { + * // RawMessage + * const helloWorldMessage: RawMessage = { text: 'Hello World' }; + * sign.setText(helloWorldMessage); + * + * // RawText + * const helloWorldText: RawText = { rawtext: [{ text: 'Hello World' }] }; + * sign.setText(helloWorldText); + * + * // Regular string + * sign.setText('Hello World'); + * } else { + * console.warn('Could not find a sign component on the block.'); + * } + * } + * ``` */ - removeTag(tag: string): boolean; + setText(message: RawMessage | RawText | string, side?: SignSide): void; /** * @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. + * 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. */ - runCommandAsync(commandString: string): Promise; + setTextDyeColor(color?: DyeColor, side?: SignSide): void; /** - * @beta * @remarks - * Sets a specified property to a value. - * @param identifier - * @param value - * Data value of the property to set. + * Makes it so players cannot edit this sign. + * + * This function can't be called in read-only mode. + * * @throws This function can throw errors. */ - setDynamicProperty(identifier: string, value: boolean | number | string): void; + setWaxed(waxed: boolean): 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'; +} + +/** + * Enumerates all {@link BlockStateType}s. + */ +export class BlockStates { + private constructor(); /** - * @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. - * @param seconds - * Length of time to set the entity on fire. - * @param useEffects - * @throws This function can throw errors. + * Retrieves a specific block state instance. + * + * @returns + * Returns the {@link Block} state instance if it is found. If + * the block state instance is not found returns undefined. */ - setOnFire(seconds: number, useEffects?: boolean): boolean; + static get(stateName: string): BlockStateType | undefined; /** - * @beta * @remarks - * Sets the main rotation of the entity. - * @param degreesX - * @param degreesY - * @throws This function can throw errors. + * Retrieves a set of all available block states. + * */ - setRotation(degreesX: number, degreesY: number): void; + static getAll(): BlockStateType[]; +} + +/** + * 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(); /** - * @beta * @remarks - * Teleports the selected entity to a new location - * @param location - * New location for the entity. - * @param dimension - * Dimension to move the selected entity to. - * @param xRotation - * X rotation of the entity after teleportation. - * @param yRotation - * Y rotation of the entity after teleportation. - * @param keepVelocity - * @throws This function can throw errors. + * Identifier of the block property. + * */ - teleport( - location: Vector3, - dimension: Dimension, - xRotation: number, - yRotation: number, - keepVelocity?: boolean, - ): void; + readonly id: string; + /** + * @remarks + * A set of valid values for the block property. + * + */ + readonly validValues: (boolean | number | string)[]; +} + +/** + * 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(); /** * @beta * @remarks - * Teleports the selected entity to a new location, and will - * have the entity facing a specified location. - * @param location - * New location for the entity. - * @param dimension - * Dimension to move the selected entity to. - * @param facingLocation - * Location that this entity will be facing. - * @param keepVelocity - * @throws This function can throw errors. + * Represents whether this type of block can be waterlogged. + * */ - teleportFacing(location: Vector3, dimension: Dimension, facingLocation: Vector3, keepVelocity?: boolean): void; + readonly canBeWaterlogged: boolean; /** * @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. - * @param eventName - * Name of the entity type event to trigger. If a namespace is - * not specified, minecraft: is assumed. - * @throws This function can throw errors. + * Block type name - for example, `minecraft:acacia_stairs`. + * */ - triggerEvent(eventName: string): void; + readonly id: string; } + /** * @beta - * When added, this component makes the entity spawn with a - * rider of the specified entityType. + * Contains a catalog of Minecraft Block Types that are + * available in this world. */ -export class EntityAddRiderComponent extends IEntityComponent { - protected constructor(); +export class BlockTypes { + private constructor(); /** - * 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; - /** - * 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; - /** - * Identifier of this component. Should always be - * minecraft:addrider. + * @remarks + * Returns a BlockType object for the specified identifier. + * + * @param typeName + * Identifier of the block type. Should follow a namespace:id + * pattern, such as minecraft:dirt. + * @returns + * BlockType object, or undefined if the block type is not + * available within this world. */ - readonly typeId: string; + static get(typeName: string): BlockType | undefined; /** - * Identifier of this component. Should always be - * minecraft:addrider. + * @remarks + * Returns a collection of all available block types. + * */ - static readonly componentId = 'minecraft:addrider'; + static getAll(): BlockType[]; } + /** * @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. + * 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 class EntityAgeableComponent extends IEntityComponent { - protected constructor(); +// @ts-ignore Class inheritance allowed for native defined classes +export class BlockVolume extends BlockVolumeBase { /** - * Amount of time before the entity grows up, -1 for always a - * baby. - * @throws This property can throw when used. + * @remarks + * A world block location that represents a corner in a 3D + * rectangle + * + * This property can't be edited in read-only mode. + * */ - readonly duration: number; + 'from': Vector3; /** - * Event to run when this entity grows up. - * @throws This property can throw when used. + * @remarks + * A world block location that represents the opposite corner + * in a 3D rectangle + * + * This property can't be edited in read-only mode. + * */ - readonly growUp: Trigger; + to: Vector3; + constructor(from: Vector3, to: Vector3); /** - * Identifier of this component. Should always be - * minecraft:ageable. + * @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 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. */ - readonly typeId: string; + doesLocationTouchFaces(pos: Vector3): boolean; /** - * Identifier of this component. Should always be - * minecraft:ageable. + * @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 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 readonly componentId = 'minecraft:ageable'; - getDropItems(): string[]; - getFeedItems(): EntityDefinitionFeedItem[]; + doesVolumeTouchFaces(other: BlockVolume): boolean; + /** + * @remarks + * Return an enumeration which represents the intersection + * between two BlockVolume objects + * + * This function can't be called in read-only mode. + * + */ + intersects(other: BlockVolume): BlockVolumeIntersection; } + /** * @beta - * Defines what blocks this entity can breathe in and gives - * them the ability to suffocate. + * Base type for BlockVolumes. */ -export class EntityBreathableComponent extends IEntityComponent { - protected constructor(); +export class BlockVolumeBase { + private constructor(); /** - * If true, this entity can breathe in air. - * @throws This property can throw when used. + * @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. + * */ - readonly breathesAir: boolean; + getBlockLocationIterator(): BlockLocationIterator; /** - * If true, this entity can breathe in lava. - * @throws This property can throw when used. + * @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. + * + * @throws This function can throw errors. */ - readonly breathesLava: boolean; + getBoundingBox(): BoundingBox; /** - * If true, this entity can breathe in solid blocks. - * @throws This property can throw when used. + * @remarks + * Return the capacity (volume) of the BlockVolume (W*D*H) + * + * This function can't be called in read-only mode. + * */ - readonly breathesSolids: boolean; + getCapacity(): number; /** - * If true, this entity can breathe in water. - * @throws This property can throw when used. + * @remarks + * Get the largest corner position of the volume (guaranteed to + * be >= min) + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - readonly breathesWater: boolean; + getMax(): Vector3; /** - * If true, this entity will have visible bubbles while in - * water. - * @throws This property can throw when used. + * @remarks + * Get the smallest corner position of the volume (guaranteed + * to be <= max) + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - readonly generatesBubbles: boolean; + getMin(): Vector3; /** - * Time in seconds to recover breath to maximum. - * @throws This property can throw when used. + * @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. + * */ - readonly inhaleTime: number; + getSpan(): Vector3; /** - * Time in seconds between suffocation damage. - * @throws This property can throw when used. + * @remarks + * Check to see if a given world block location is inside a + * BlockVolume + * + * This function can't be called in read-only mode. + * */ - readonly suffocateTime: number; + isInside(pos: Vector3): boolean; /** - * Time in seconds the entity can hold its breath. - * @throws This property can throw when used. + * @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 */ - readonly totalSupply: number; + translate(delta: Vector3): void; +} + +/** + * @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'; /** - * Identifier of this component. Should always be - * minecraft:breathable. + * @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. */ - readonly typeId: string; + addDye(itemType: ItemType): void; /** - * Identifier of this component. Should always be - * minecraft:breathable. + * @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. */ - static readonly componentId = 'minecraft:breathable'; - getBreatheBlocks(): BlockPermutation[]; - getNonBreatheBlocks(): BlockPermutation[]; + getCustomColor(): RGBA; /** * @remarks - * Sets the current air supply of the entity. - * @param value - * New air supply for the entity. + * 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. */ - setAirSupply(value: number): void; + setCustomColor(color: RGBA): void; } + /** * @beta - * When added, this component signifies that the entity can - * climb up ladders. + * 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 EntityCanClimbComponent extends IEntityComponent { - protected constructor(); +export class BoundingBoxUtils { + private constructor(); /** - * Identifier of this component. Should always be - * minecraft:can_climb. + * @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 */ - readonly typeId: string; + static createValid(min: Vector3, max: Vector3): BoundingBox; /** - * Identifier of this component. Should always be - * minecraft:can_climb. + * @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 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. - */ -export class EntityCanFlyComponent extends IEntityComponent { - protected constructor(); + static dilate(box: BoundingBox, size: Vector3): BoundingBox; /** - * Identifier of this component. Should always be - * minecraft:can_fly. + * @remarks + * Check if two {@link @minecraft-server.BoundingBox} objects + * are identical + * + * This function can't be called in read-only mode. + * */ - readonly typeId: string; + static equals(box: BoundingBox, other: BoundingBox): boolean; /** - * Identifier of this component. Should always be - * minecraft:can_fly. + * @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 readonly componentId = 'minecraft:can_fly'; -} -/** - * @beta - * When added, this component signifies that the entity can - * power jump like the horse does within Minecraft. - */ -export class EntityCanPowerJumpComponent extends IEntityComponent { - protected constructor(); + static expand(box: BoundingBox, other: BoundingBox): BoundingBox; /** - * Identifier of this component. Should always be - * minecraft:can_power_jump. + * @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) */ - readonly typeId: string; + static getCenter(box: BoundingBox): Vector3; /** - * Identifier of this component. Should always be - * minecraft:can_power_jump. + * @remarks + * Calculate the BoundingBox which represents the union area of + * two intersecting BoundingBoxes + * + * This function can't be called in read-only mode. + * */ - static readonly componentId = 'minecraft:can_power_jump'; -} -/** - * @beta - * Defines the entity's color. Only works on certain entities - * that have predefined color values (sheep, llama, shulker). - */ -export class EntityColorComponent extends IEntityComponent { - protected constructor(); + static getIntersection(box: BoundingBox, other: BoundingBox): BoundingBox | undefined; /** - * Identifier of this component. Should always be - * minecraft:color. + * @remarks + * Get the Span of each of the BoundingBox Axis components + * + * This function can't be called in read-only mode. + * */ - readonly typeId: string; + static getSpan(box: BoundingBox): Vector3; /** - * The palette color value of the entity. + * @remarks + * Check to see if two BoundingBox objects intersect + * + * This function can't be called in read-only mode. + * */ - value: number; + static intersects(box: BoundingBox, other: BoundingBox): boolean; /** - * Identifier of this component. Should always be - * minecraft:color. + * @remarks + * Check to see if a given coordinate is inside a BoundingBox + * + * This function can't be called in read-only mode. + * */ - static readonly componentId = 'minecraft:color'; -} -/** - * @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 { - protected constructor(); + static isInside(box: BoundingBox, pos: Vector3): boolean; /** - * The amount by which an entity's age will increase when fed - * this item. Values usually range between 0 and 1. + * @remarks + * Check to see if a BoundingBox is valid (i.e. (min <= max)) + * + * This function can't be called in read-only mode. + * */ - readonly growth: number; + static isValid(box: BoundingBox): boolean; /** - * 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'. + * @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 */ - readonly item: string; -} -export class EntityDieEvent { - protected constructor(); - readonly damageSource: EntityDamageSource; - readonly deadEntity: Entity; -} -export class EntityDieEventSignal { - protected constructor(); - subscribe(callback: (arg: EntityDieEvent) => void, options?: EntityEventOptions): (arg: EntityDieEvent) => void; - unsubscribe(callback: (arg: EntityDieEvent) => void): void; + static translate(box: BoundingBox, delta: Vector3): BoundingBox; } + /** - * @beta - * When added, this component signifies that this entity - * doesn't take damage from fire. + * Contains information related to changes to a button push. + * @example buttonPushEvent.ts + * ```typescript + * import { world, ButtonPushAfterEvent, system } from '@minecraft/server'; + * + * world.afterEvents.buttonPush.subscribe((buttonPushEvent: ButtonPushAfterEvent) => { + * const eventLoc = buttonPushEvent.block.location; + * + * world.sendMessage( + * `Button push event at tick ${system.currentTick} Power:${buttonPushEvent.block.getRedstonePower()}`, + * ); + * }); + * ``` */ -export class EntityFireImmuneComponent extends IEntityComponent { - protected constructor(); - /** - * Identifier of this component. Should always be - * minecraft:fire_immune. - */ - readonly typeId: string; +// @ts-ignore Class inheritance allowed for native defined classes +export class ButtonPushAfterEvent extends BlockEvent { + private constructor(); /** - * Identifier of this component. Should always be - * minecraft:fire_immune. + * @remarks + * Optional source that triggered the button push. + * */ - static readonly componentId = 'minecraft:fire_immune'; + readonly source: Entity; } + /** - * @beta - * When added, this component signifies that this entity can - * float in liquid blocks. + * Manages callbacks that are connected to when a button is + * pushed. + * @example buttonPushEvent.ts + * ```typescript + * import { world, ButtonPushAfterEvent, system } from '@minecraft/server'; + * + * world.afterEvents.buttonPush.subscribe((buttonPushEvent: ButtonPushAfterEvent) => { + * const eventLoc = buttonPushEvent.block.location; + * + * world.sendMessage( + * `Button push event at tick ${system.currentTick} Power:${buttonPushEvent.block.getRedstonePower()}`, + * ); + * }); + * ``` */ -export class EntityFloatsInLiquidComponent extends IEntityComponent { - protected constructor(); - /** - * Identifier of this component. Should always be - * minecraft:floats_in_liquid. - */ - readonly typeId: string; - /** - * Identifier of this component. Should always be - * minecraft:floats_in_liquid. - */ - static readonly componentId = 'minecraft:floats_in_liquid'; +// @ts-ignore Class inheritance allowed for native defined classes +export class ButtonPushAfterEventSignal extends IButtonPushAfterEventSignal { + private constructor(); } + /** - * @beta - * Represents the flying speed of an entity. + * Contains methods relating to the active camera for the + * specified player. */ -export class EntityFlyingSpeedComponent extends IEntityComponent { - protected constructor(); +export class Camera { + private constructor(); /** - * Identifier of this component. Should always be - * minecraft:flying_speed. - */ - readonly typeId: string; + * @remarks + * Clears the active camera for the specified player. Causes + * the specified players to end any in-progress camera + * perspectives, including any eased camera motions, and return + * to their normal perspective. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + */ + clear(): void; /** - * Speed while flying value of the entity. + * @remarks + * Begins a camera fade transition. A fade transition is a + * full-screen color that fades-in, holds, and then fades-out. + * + * This function can't be called in read-only mode. + * + * @param fadeCameraOptions + * Additional options around camera fade operations. + * @throws This function can throw errors. */ - value: number; + fade(fadeCameraOptions?: CameraFadeOptions): void; /** - * Identifier of this component. Should always be - * minecraft:flying_speed. + * @remarks + * Sets the current active camera for the specified player. + * + * This function can't be called in read-only mode. + * + * @param cameraPreset + * Identifier of a camera preset file defined within JSON. + * @param setOptions + * Additional options for the camera. + * @throws This function can throw errors. */ - static readonly componentId = 'minecraft:flying_speed'; + setCamera( + cameraPreset: string, + setOptions?: + | CameraDefaultOptions + | CameraSetFacingOptions + | CameraSetLocationOptions + | CameraSetPosOptions + | CameraSetRotOptions, + ): void; } + /** * @beta - * Defines how much friction affects this entity. + * An event that fires as players enter chat messages. */ -export class EntityFrictionModifierComponent extends IEntityComponent { - protected constructor(); +export class ChatSendAfterEvent { + private constructor(); /** - * Identifier of this component. Should always be - * minecraft:friction_modifier. + * @remarks + * Message that is being broadcast. + * */ - readonly typeId: string; + readonly message: string; /** - * The higher the number, the more the friction affects this - * entity. A value of 1.0 means regular friction, while 2.0 - * means twice as much. + * @remarks + * Player that sent the chat message. + * */ - value: number; + readonly sender: Player; /** - * Identifier of this component. Should always be - * minecraft:friction_modifier. + * @remarks + * Optional list of players that will receive this message. If + * defined, this message is directly targeted to one or more + * players (i.e., is not broadcast.) + * */ - static readonly componentId = 'minecraft:friction_modifier'; + readonly targets?: Player[]; } + /** * @beta - * Sets the offset from the ground that the entity is actually - * at. + * Manages callbacks that are connected to chat messages being + * sent. */ -export class EntityGroundOffsetComponent extends IEntityComponent { - protected constructor(); - /** - * Identifier of this component. Should always be - * minecraft:ground_offset. - */ - readonly typeId: string; +export class ChatSendAfterEventSignal { + private constructor(); /** - * The value of the entity's offset from the terrain, in - * blocks. + * @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}'`; + * } + * }); + * ``` */ - value: number; + subscribe(callback: (arg: ChatSendAfterEvent) => void): (arg: ChatSendAfterEvent) => void; /** - * Identifier of this component. Should always be - * minecraft:ground_offset. + * @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. */ - static readonly componentId = 'minecraft:ground_offset'; + unsubscribe(callback: (arg: ChatSendAfterEvent) => void): void; } + /** * @beta - * Defines the interactions with this entity for healing it. + * An event that fires as players enter chat messages. */ -export class EntityHealableComponent extends IEntityComponent { - protected constructor(); +export class ChatSendBeforeEvent { + private constructor(); /** - * A set of filters for when these Healable items would apply. - * @throws This property can throw when used. + * @remarks + * If set to true in a beforeChat event handler, this message + * is not broadcast out. + * */ - readonly filters: FilterGroup; + cancel: boolean; /** - * Determines if an item can be used regardless of the entity - * being at full health. - * @throws This property can throw when used. + * @remarks + * Message that is being broadcast. + * */ - readonly forceUse: boolean; + readonly message: string; /** - * Identifier of this component. Should always be - * minecraft:healable. + * @remarks + * Player that sent the chat message. + * */ - readonly typeId: string; + readonly sender: Player; /** - * Identifier of this component. Should always be - * minecraft:healable. + * @remarks + * Optional list of players that will receive this message. If + * defined, this message is directly targeted to one or more + * players (i.e., is not broadcast.) + * */ - static readonly componentId = 'minecraft:healable'; - getFeedItems(): FeedItem[]; + readonly targets?: Player[]; } + /** * @beta - * Defines the health properties of an entity. + * Manages callbacks that are connected to an event that fires + * before chat messages are sent. */ -export class EntityHealthComponent extends IEntityComponent { - protected constructor(); - /** - * Read-only. Returns the current value of health for the - * entity. - * @throws This property can throw when used. - */ - readonly current: number; - /** - * Identifier of this component. Should always be - * minecraft:health. - */ - readonly typeId: string; - /** - * Value for health as defined through entity components. - * @throws This property can throw when used. - */ - readonly value: number; - /** - * Identifier of this component. Should always be - * minecraft:health. - */ - static readonly componentId = 'minecraft:health'; - /** - * @remarks - * Resets the current health value of the entity to its default - * value. - * @throws This function can throw errors. - */ - resetToDefaultValue(): void; +export class ChatSendBeforeEventSignal { + private constructor(); /** * @remarks - * Resets the current health of the entity to its maximum - * value. - * @throws This function can throw errors. + * Adds a callback that will be called before new chat messages + * are sent. + * + * This function can't be called in read-only mode. + * */ - resetToMaxValue(): void; + subscribe(callback: (arg: ChatSendBeforeEvent) => void): (arg: ChatSendBeforeEvent) => void; /** * @remarks - * Resets the current health to the minimum value. + * 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. */ - resetToMinValue(): void; + unsubscribe(callback: (arg: ChatSendBeforeEvent) => void): void; +} + +/** + * Contains return data on the result of a command execution. + */ +export class CommandResult { + private constructor(); /** * @remarks - * Sets the current health of the entity. - * @param value - * @throws This function can throw errors. + * If the command operates against a number of entities, + * blocks, or items, this returns the number of successful + * applications of this command. + * */ - setCurrent(value: number): boolean; + readonly successCount: number; } + /** - * @beta - * Contains information related to an entity hitting (melee - * attacking) another entity. + * Base class for downstream Component implementations. */ -export class EntityHitEvent { - protected constructor(); - /** - * Entity that made a hit/melee attack. - */ - readonly entity: Entity; +export class Component { + private constructor(); /** - * Block that was hit by the attack, or undefined if the hit - * attack did not hit a block. If both hitEntity and hitBlock - * are undefined, then the entity basically swiped into the - * air. + * @remarks + * Identifier of the component. + * */ - readonly hitBlock?: Block; + readonly typeId: string; /** - * Entity that was hit by the attack, or undefined if the hit - * attack did not hit an entity. If both hitEntity and hitBlock - * are undefined, then the entity basically swiped into the - * air. + * @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. */ - readonly hitEntity?: Entity; + isValid(): boolean; } + /** * @beta - * Manages callbacks that are connected to when an entity makes - * a melee attack on another entity. + * 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 EntityHitEventSignal { - protected constructor(); +export class CompoundBlockVolume { /** * @remarks - * Adds a callback that will be called when an entity hits - * another entity. - * @param callback - * @param options + * Return the 'capacity' of the bounding rectangle which + * represents the collection of volumes in the stack + * */ - subscribe(callback: (arg: EntityHitEvent) => void, options?: EntityEventOptions): (arg: EntityHitEvent) => void; + readonly capacity: number; /** * @remarks - * Removes a callback from being called when an entity makes a - * melee attack on another entity. - * @param callback - * @throws This function can throw errors. + * Return the number of volumes (positive and negative) in the + * volume stack + * */ - unsubscribe(callback: (arg: EntityHitEvent) => void): void; -} -/** - * @beta - * Contains information related to an entity getting hurt by - * another entity. - */ -export class EntityHurtEvent { - protected constructor(); + readonly volumeCount: number; /** - * Describes the amount of damage caused. + * @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) */ - readonly damage: number; + constructor(origin?: Vector3); /** - * Source information on the entity that may have applied this - * damage. + * @remarks + * Clear the contents of the volume stack + * + * This function can't be called in read-only mode. + * */ - readonly damageSource: EntityDamageSource; - /** - * Entity that was hurt. + 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. + * */ - readonly hurtEntity: Entity; -} -/** - * @beta - * Manages callbacks that are connected to when an entity is - * hurt. - */ -export class EntityHurtEventSignal { - protected constructor(); + getBlockLocationIterator(): BlockLocationIterator; /** * @remarks - * Adds a callback that will be called when an entity is hurt. - * @param callback - * @param options + * 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. + * */ - subscribe(callback: (arg: EntityHurtEvent) => void, options?: EntityEventOptions): (arg: EntityHurtEvent) => void; + getBoundingBox(): BoundingBox; /** * @remarks - * Removes a callback from being called when an entity is hurt. - * @param callback - * @throws This function can throw errors. + * 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. + * */ - unsubscribe(callback: (arg: EntityHurtEvent) => void): void; -} -/** - * @beta - * Defines this entity's inventory properties. - */ -export class EntityInventoryComponent extends IEntityComponent { - protected constructor(); + getMax(): Vector3; /** - * Number of slots that this entity can gain per extra - * strength. - * @throws This property can throw when used. + * @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. + * */ - readonly additionalSlotsPerStrength: number; + getMin(): Vector3; /** - * If true, the contents of this inventory can be removed by a - * hopper. - * @throws This property can throw when used. + * @remarks + * Fetch the origin in world space of the compound volume + * + * This function can't be called in read-only mode. + * */ - readonly canBeSiphonedFrom: boolean; + getOrigin(): Vector3; /** - * Defines the container for this entity. - * @throws This property can throw when used. + * @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. + * */ - readonly container: InventoryComponentContainer; + isEmpty(): boolean; /** - * Type of container this entity has. - * @throws This property can throw when used. + * @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. + * */ - readonly containerType: string; + isInside(worldLocation: Vector3): boolean; /** - * Number of slots the container has. - * @throws This property can throw when used. + * @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 */ - readonly inventorySize: number; + peekLastVolume(forceRelativity?: CompoundBlockVolumePositionRelativity): CompoundBlockVolumeItem | undefined; /** - * If true, the entity will not drop it's inventory on death. - * @throws This property can throw when used. + * @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. + * */ - readonly 'private': boolean; + popVolume(): boolean; /** - * If true, the entity's inventory can only be accessed by its - * owner or itself. - * @throws This property can throw when used. + * @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 */ - readonly restrictToOwner: boolean; + pushVolume(item: CompoundBlockVolumeItem): void; /** - * Identifier of this component. Should always be - * minecraft:inventory. + * @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 */ - readonly typeId: string; + replaceOrAddLastVolume(item: CompoundBlockVolumeItem): boolean; /** - * Identifier of this component. Should always be - * minecraft:inventory. + * @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} */ - static readonly componentId = 'minecraft:inventory'; + translateOrigin(delta: Vector3, preserveExistingVolumes?: boolean): void; } + /** - * @beta - * When added, this component signifies that this entity is a - * baby. + * Represents a container that can hold sets of items. Used + * with entities such as Players, Chest Minecarts, Llamas, and + * more. + * @example containers.js + * ```typescript + * let leftLocation = test.worldLocation({ x: 2, y: 2, z: 2 }); // left chest location + * let rightLocation = test.worldLocation({ x: 4, y: 2, z: 2 }); // right chest location + * + * const chestCart = test.spawn("chest_minecart", { x: 6, y: 2, z: 2 }); + * + * let leftChestBlock = defaultDimension.getBlock(leftLocation); + * let rightChestBlock = defaultDimension.getBlock(rightLocation); + * + * leftChestBlock.setType(MinecraftBlockTypes.chest); + * rightChestBlock.setType(MinecraftBlockTypes.chest); + * + * const rightChestInventoryComp = rightChestBlock.getComponent("inventory"); + * const leftChestInventoryComp = leftChestBlock.getComponent("inventory"); + * const chestCartInventoryComp = chestCart.getComponent("inventory"); + * + * const rightChestContainer = rightChestInventoryComp.container; + * const leftChestContainer = leftChestInventoryComp.container; + * const chestCartContainer = chestCartInventoryComp.container; + * + * rightChestContainer.setItem(0, new ItemStack(Items.apple, 10, 0)); + * test.assert(rightChestContainer.getItem(0).id === "apple", "Expected apple in right container slot index 0"); + * + * rightChestContainer.setItem(1, new ItemStack(Items.emerald, 10, 0)); + * test.assert(rightChestContainer.getItem(1).id === "emerald", "Expected emerald in right container slot index 1"); + * + * test.assert(rightChestContainer.size === 27, "Unexpected size: " + rightChestContainer.size); + * test.assert( + * rightChestContainer.emptySlotsCount === 25, + * "Unexpected emptySlotsCount: " + rightChestContainer.emptySlotsCount + * ); + * + * const itemStack = rightChestContainer.getItem(0); + * test.assert(itemStack.id === "apple", "Expected apple"); + * test.assert(itemStack.amount === 10, "Expected 10 apples"); + * test.assert(itemStack.data === 0, "Expected 0 data"); + * + * leftChestContainer.setItem(0, new ItemStack(Items.cake, 10, 0)); + * + * rightChestContainer.transferItem(0, 4, chestCartContainer); // transfer the apple from the right chest to a chest cart + * rightChestContainer.swapItems(1, 0, leftChestContainer); // swap the cake and emerald + * + * test.assert(chestCartContainer.getItem(4).id === "apple", "Expected apple in left container slot index 4"); + * test.assert(leftChestContainer.getItem(0).id === "emerald", "Expected emerald in left container slot index 0"); + * test.assert(rightChestContainer.getItem(1).id === "cake", "Expected cake in right container slot index 1"); + * + * ``` */ -export class EntityIsBabyComponent extends IEntityComponent { - protected constructor(); - /** - * Identifier of this component. Should always be - * minecraft:is_baby. - */ - readonly typeId: string; +export class Container { + private constructor(); /** - * Identifier of this component. Should always be - * minecraft:is_baby. + * @remarks + * Count of the slots in the container that are empty. + * + * @throws + * Throws if the container is invalid. */ - static readonly componentId = 'minecraft:is_baby'; -} -/** - * @beta - * When added, this component signifies that this entity is - * charged. - */ -export class EntityIsChargedComponent extends IEntityComponent { - protected constructor(); + readonly emptySlotsCount: number; /** - * Identifier of this component. Should always be - * minecraft:is_charged. + * @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 typeId: string; + readonly size: number; /** - * Identifier of this component. Should always be - * minecraft:is_charged. + * @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. */ - static readonly componentId = 'minecraft:is_charged'; -} -/** - * @beta - * When added, this component signifies that this entity is - * currently carrying a chest. - */ -export class EntityIsChestedComponent extends IEntityComponent { - protected constructor(); + addItem(itemStack: ItemStack): ItemStack | undefined; /** - * Identifier of this component. Should always be - * minecraft:is_chested. + * @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. */ - readonly typeId: string; + clearAll(): void; /** - * Identifier of this component. Should always be - * minecraft:is_chested. + * @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 + * // A function that gets a copy of the first item in the player's hotbar + * import { Player, EntityInventoryComponent, ItemStack } from '@minecraft/server'; + * + * function getFirstHotbarItem(player: Player): ItemStack | undefined { + * const inventory = player.getComponent(EntityInventoryComponent.componentId); + * if (inventory && inventory.container) { + * return inventory.container.getItem(0); + * } + * return undefined; + * } + * ``` */ - static readonly componentId = 'minecraft:is_chested'; -} -/** - * @beta - * When added, this component signifies that dyes can be used - * on this entity to change its color. - */ -export class EntityIsDyableComponent extends IEntityComponent { - protected constructor(); + getItem(slot: number): ItemStack | undefined; /** - * Identifier of this component. Should always be - * minecraft:is_dyeable. + * @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. */ - readonly typeId: string; + getSlot(slot: number): ContainerSlot; /** - * Identifier of this component. Should always be - * minecraft:is_dyeable. + * @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. + * */ - static readonly componentId = 'minecraft:is_dyeable'; -} -/** - * @beta - * When added, this component signifies that this entity can - * hide from hostile mobs while invisible. - */ -export class EntityIsHiddenWhenInvisibleComponent extends IEntityComponent { - protected constructor(); + isValid(): boolean; /** - * Identifier of this component. Should always be - * minecraft:is_hidden_when_invisible. + * @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 + * // A function that moves an item from one slot of the player's inventory to another player's inventory + * import { Player, EntityComponentTypes } from '@minecraft/server'; + * + * function moveBetweenPlayers(slotId: number, fromPlayer: Player, toPlayer: Player) { + * const fromInventory = fromPlayer.getComponent(EntityComponentTypes.Inventory); + * const toInventory = toPlayer.getComponent(EntityComponentTypes.Inventory); + * + * if (fromInventory && toInventory && fromInventory.container && toInventory.container) { + * fromInventory.container.moveItem(slotId, slotId, toInventory.container); + * } + * } + * ``` */ - readonly typeId: string; + moveItem(fromSlot: number, toSlot: number, toContainer: Container): void; /** - * Identifier of this component. Should always be - * minecraft:is_hidden_when_invisible. + * @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. */ - static readonly componentId = 'minecraft:is_hidden_when_invisible'; -} -/** - * @beta - * When added, this component signifies that this entity this - * currently on fire. - */ -export class EntityIsIgnitedComponent extends IEntityComponent { - protected constructor(); + setItem(slot: number, itemStack?: ItemStack): void; /** - * Identifier of this component. Should always be - * minecraft:is_ignited. + * @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 + * // A function that swaps an item from one slot of the player's inventory to another player's inventory + * import { Player, EntityComponentTypes } from '@minecraft/server'; + * + * function swapBetweenPlayers(slotId: number, fromPlayer: Player, toPlayer: Player) { + * const fromInventory = fromPlayer.getComponent(EntityComponentTypes.Inventory); + * const toInventory = toPlayer.getComponent(EntityComponentTypes.Inventory); + * + * if (fromInventory && toInventory && fromInventory.container && toInventory.container) { + * fromInventory.container.swapItems(slotId, slotId, toInventory.container); + * } + * } + * ``` */ - readonly typeId: string; + swapItems(slot: number, otherSlot: number, otherContainer: Container): void; /** - * Identifier of this component. Should always be - * minecraft:is_ignited. + * @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. + * @returns + * An itemStack with the items that couldn't be transferred. + * Returns undefined if all items were transferred. + * @throws + * Throws if either this container or `toContainer` are invalid + * or if the `fromSlot` or `toSlot` indices out of bounds. + * @example transferItem.ts + * ```typescript + * // A function that moves an item from one slot of the player's inventory to another player's inventory + * import { Player, EntityComponentTypes } from '@minecraft/server'; + * + * function moveBetweenPlayers(slotId: number, fromPlayer: Player, toPlayer: Player) { + * const fromInventory = fromPlayer.getComponent(EntityComponentTypes.Inventory); + * const toInventory = toPlayer.getComponent(EntityComponentTypes.Inventory); + * + * if (fromInventory && toInventory && fromInventory.container && toInventory.container) { + * fromInventory.container.transferItem(slotId, toInventory.container); + * } + * } + * ``` */ - static readonly componentId = 'minecraft:is_ignited'; + transferItem(fromSlot: number, toContainer: Container): ItemStack | undefined; } + /** - * @beta - * When added, this component signifies that this entity is an - * illager captain. + * Represents a slot within a broader container (e.g., entity + * inventory.) */ -export class EntityIsIllagerCaptainComponent extends IEntityComponent { - protected constructor(); - /** - * Identifier of this component. Should always be - * minecraft:is_illager_captain. - */ - readonly typeId: string; +export class ContainerSlot { + private constructor(); /** - * Identifier of this component. Should always be - * minecraft:is_illager_captain. + * @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. */ - static readonly componentId = 'minecraft:is_illager_captain'; -} -/** - * @beta - * When added, this component signifies that this entity is - * currently saddled. - */ -export class EntityIsSaddledComponent extends IEntityComponent { - protected constructor(); + amount: number; /** - * Identifier of this component. Should always be - * minecraft:is_saddled. + * @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. + * + * {@link InvalidContainerSlotError} */ - readonly typeId: string; + readonly isStackable: boolean; /** - * Identifier of this component. Should always be - * minecraft:is_saddled. + * @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. */ - static readonly componentId = 'minecraft:is_saddled'; -} -/** - * @beta - * When added, this component signifies that this entity is - * currently shaking. - */ -export class EntityIsShakingComponent extends IEntityComponent { - protected constructor(); + keepOnDeath: boolean; /** - * Identifier of this component. Should always be - * minecraft:is_shaking. + * @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. */ - readonly typeId: string; + lockMode: ItemLockMode; /** - * Identifier of this component. Should always be - * minecraft:is_shaking. - */ - static readonly componentId = 'minecraft:is_shaking'; -} -/** - * @beta - * When added, this component signifies that this entity is - * currently sheared. - */ -export class EntityIsShearedComponent extends IEntityComponent { - protected constructor(); + * @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. + * + * {@link InvalidContainerSlotError} + */ + readonly maxAmount: number; /** - * Identifier of this component. Should always be - * minecraft:is_sheared. + * @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. */ - readonly typeId: string; + nameTag?: string; /** - * Identifier of this component. Should always be - * minecraft:is_sheared. + * @remarks + * The type of the item. + * + * @throws + * Throws if the slot's container is invalid. + * + * {@link minecraftcommon.EngineError} + * + * {@link InvalidContainerSlotError} */ - static readonly componentId = 'minecraft:is_sheared'; -} -/** - * @beta - * When added, this component signifies that this entity can be - * stacked. - */ -export class EntityIsStackableComponent extends IEntityComponent { - protected constructor(); + readonly 'type': ItemType; /** - * Identifier of this component. Should always be - * minecraft:is_stackable. + * @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. + * + * {@link InvalidContainerSlotError} */ readonly typeId: string; /** - * Identifier of this component. Should always be - * minecraft:is_stackable. + * @remarks + * Clears all dynamic properties that have been set on this + * item stack. + * + * @throws + * Throws if the slot's container is invalid. + * + * {@link InvalidContainerSlotError} */ - static readonly componentId = 'minecraft:is_stackable'; -} -/** - * @beta - * When added, this component signifies that this entity is - * currently stunned. - */ -export class EntityIsStunnedComponent extends IEntityComponent { - protected constructor(); + clearDynamicProperties(): void; /** - * Identifier of this component. Should always be - * minecraft:is_stunned. + * @throws This function can throw errors. + * + * {@link InvalidContainerSlotError} */ - readonly typeId: string; + getCanDestroy(): string[]; /** - * Identifier of this component. Should always be - * minecraft:is_stunned. + * @throws This function can throw errors. + * + * {@link InvalidContainerSlotError} */ - static readonly componentId = 'minecraft:is_stunned'; -} -/** - * @beta - * When added, this component signifies that this entity is - * currently tamed. - */ -export class EntityIsTamedComponent extends IEntityComponent { - protected constructor(); + getCanPlaceOn(): string[]; /** - * Identifier of this component. Should always be - * minecraft:is_tamed. + * @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 slot's container is invalid. + * + * {@link InvalidContainerSlotError} */ - readonly typeId: string; + getDynamicProperty(identifier: string): boolean | number | string | Vector3 | undefined; /** - * Identifier of this component. Should always be - * minecraft:is_tamed. + * @remarks + * Returns the available set of dynamic property identifiers + * that have been used on this item stack. + * + * @returns + * A string array of the dynamic properties set on this entity. + * @throws + * Throws if the slot's container is invalid. + * + * {@link InvalidContainerSlotError} */ - 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. - */ -export class EntityItemComponent extends IEntityComponent { - protected constructor(); + getDynamicPropertyIds(): string[]; /** - * Item stack represented by this entity in the world. - * @throws This property can throw when used. + * @remarks + * Returns the total size, in bytes, of all the dynamic + * properties that are currently stored for this entity. This + * includes the size of both the key and the value. This can + * be useful for diagnosing performance warning signs - if, for + * example, an entity has many megabytes of associated dynamic + * properties, it may be slow to load on various devices. + * + * @throws + * Throws if the slot's container is invalid. + * + * {@link InvalidContainerSlotError} */ - readonly itemStack: ItemStack; + getDynamicPropertyTotalByteCount(): number; /** - * Identifier of this component. + * @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 + * Throws if the slot's container is invalid. + * + * {@link InvalidContainerSlotError} */ - readonly typeId: string; + getItem(): ItemStack | undefined; /** - * Identifier of this component. + * @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. + * + * {@link InvalidContainerSlotError} */ - 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 { - protected constructor(); - [Symbol.iterator](): Iterator; + getLore(): string[]; /** * @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. + * 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 + * Throws if the slot's container is invalid. + * + * {@link InvalidContainerSlotError} */ - next(): IteratorResult; -} -/** - * @beta - * Defines the base movement speed in lava of this entity. - */ -export class EntityLavaMovementComponent extends IEntityComponent { - protected constructor(); + getTags(): string[]; /** - * Read-only. Returns the current value of movement speed on - * lava for the entity. - * @throws This property can throw when used. + * @throws This function can throw errors. + * + * {@link InvalidContainerSlotError} */ - readonly current: number; + hasItem(): boolean; /** - * Identifier of this component. Should always be - * minecraft:lava_movement. + * @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 + * Throws if the slot's container is invalid. + * + * {@link InvalidContainerSlotError} */ - readonly typeId: string; + hasTag(tag: string): boolean; /** - * Value for movement speed on lava as defined through entity - * components. - * @throws This property can throw when used. + * @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. + * + * {@link InvalidContainerSlotError} */ - readonly value: number; + isStackableWith(itemStack: ItemStack): boolean; /** - * Identifier of this component. Should always be - * minecraft:lava_movement. + * @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. + * */ - static readonly componentId = 'minecraft:lava_movement'; + isValid(): boolean; /** * @remarks - * Resets the current movement speed on lava for the entity to - * its default value. - * @throws This function can throw errors. + * 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. + * + * {@link Error} + * + * {@link InvalidContainerSlotError} */ - resetToDefaultValue(): void; + setCanDestroy(blockIdentifiers?: string[]): void; /** * @remarks - * Resets the movement speed on lava to the maximum value for - * the entity. - * @throws This function can throw errors. + * 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. + * + * {@link Error} + * + * {@link InvalidContainerSlotError} */ - resetToMaxValue(): void; + setCanPlaceOn(blockIdentifiers?: string[]): void; /** * @remarks - * Resets the movement speed on lava speed to the minimum - * value. - * @throws This function can throw errors. + * Sets a specified property to a value. + * + * @param identifier + * The property identifier. + * @param value + * Data value of the property to set. + * @throws + * Throws if the slot's container is invalid. + * + * {@link Error} + * + * {@link InvalidContainerSlotError} */ - resetToMinValue(): void; + setDynamicProperty(identifier: string, value?: boolean | number | string | Vector3): void; /** * @remarks - * Sets the current value of movement speed on lava for the - * entity. - * @param value - * @throws This function can throw errors. + * 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 + * Throws if the slot's container is invalid. + * + * {@link InvalidContainerSlotError} + */ + 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. + * + * {@link Error} + * + * {@link InvalidContainerSlotError} */ - setCurrent(value: number): boolean; + setLore(loreList?: string[]): void; } + /** - * @beta - * Allows this entity to be leashed and defines the conditions - * and events for this entity when is leashed. + * Contains information related to firing of a data driven + * entity event - for example, the minecraft:ageable_grow_up + * event on a chicken. */ -export class EntityLeashableComponent extends IEntityComponent { - protected constructor(); - /** - * 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; - /** - * Identifier of this component. Should always be - * minecraft:leashable. - */ - readonly typeId: string; - /** - * Identifier of this component. Should always be - * minecraft:leashable. - */ - static readonly componentId = 'minecraft:leashable'; +export class DataDrivenEntityTriggerAfterEvent { + private constructor(); /** * @remarks - * Leashes this entity to another entity. - * @param leashHolder - * The entity to leash this entity to. - * @throws This function can throw errors. + * Entity that the event triggered on. + * */ - leash(leashHolder: Entity): void; + readonly entity: Entity; /** * @remarks - * Unleashes this entity if it is leashed to another entity. - * @throws This function can throw errors. - */ - unleash(): void; -} -/** - * @beta - * Additional variant value. Can be used to further - * differentiate variants. - */ -export class EntityMarkVariantComponent extends IEntityComponent { - protected constructor(); - /** - * Identifier of this component. Should always be - * minecraft:mark_variant. - */ - readonly typeId: string; - /** - * The identifier of the variant. By convention, 0 is the - * identifier of the base entity. + * Name of the data driven event being triggered. + * */ - value: number; + readonly eventId: string; /** - * Identifier of this component. Should always be - * minecraft:mark_variant. + * @remarks + * An updateable list of modifications to component state that + * are the effect of this triggered event. + * */ - static readonly componentId = 'minecraft:mark_variant'; + getModifiers(): DefinitionModifier[]; } + /** - * @beta - * Contains options for taming a rideable entity based on the - * entity that mounts it. + * 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 EntityMountTamingComponent extends IEntityComponent { - protected constructor(); - /** - * Identifier of this component. Should always be - * minecraft:mount_taming. - */ - readonly typeId: string; +export class DataDrivenEntityTriggerAfterEventSignal { + private constructor(); /** - * Identifier of this component. Should always be - * minecraft:mount_taming. + * @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. + * */ - static readonly componentId = 'minecraft:tamemount'; + subscribe( + callback: (arg: DataDrivenEntityTriggerAfterEvent) => void, + options?: EntityDataDrivenTriggerEventOptions, + ): (arg: DataDrivenEntityTriggerAfterEvent) => void; /** * @remarks - * Sets this rideable entity as tamed. - * @param showParticles - * Whether to show effect particles when this entity is tamed. + * 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. */ - setTamed(showParticles: boolean): void; + unsubscribe(callback: (arg: DataDrivenEntityTriggerAfterEvent) => void): void; } + /** - * @beta - * When added, this movement control allows the mob to swim in - * water and walk on land. + * A class that represents a particular dimension (e.g., The + * End) within a world. */ -export class EntityMovementAmphibiousComponent extends IEntityComponent { - protected constructor(); +export class Dimension { + private constructor(); /** - * The maximum number in degrees the mob can turn per tick. + * @remarks + * Height range of the dimension. + * * @throws This property can throw when used. */ - readonly maxTurn: number; - /** - * Identifier of this component. Should always be - * minecraft:movement.amphibious. - */ - readonly typeId: string; + readonly heightRange: minecraftcommon.NumberRange; /** - * Identifier of this component. Should always be - * minecraft:movement.amphibious. + * @remarks + * Identifier of the dimension. + * */ - static readonly componentId = 'minecraft:movement.amphibious'; -} -/** - * @beta - * This component accents the movement of an entity. - */ -export class EntityMovementBasicComponent extends IEntityComponent { - protected constructor(); + readonly id: string; /** - * The maximum number in degrees the mob can turn per tick. - * @throws This property can throw when used. + * @beta + * @throws This function can throw errors. + * + * {@link Error} + * + * {@link UnloadedChunksError} */ - readonly maxTurn: number; + containsBlock(volume: BlockVolumeBase, filter: BlockFilter, allowUnloadedChunks?: boolean): boolean; /** - * Identifier of this component. Should always be - * minecraft:movement.basic. + * @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. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} + * @example createExplosions.ts + * ```typescript + * // Creates an explosion of radius 15 that does not break blocks + * import { DimensionLocation } from '@minecraft/server'; + * + * function createExplosions(location: DimensionLocation) { + * // Creates an explosion of radius 15 that does not break blocks + * location.dimension.createExplosion(location, 15, { breaksBlocks: false }); + * + * // Creates an explosion of radius 15 that does not cause fire + * location.dimension.createExplosion(location, 15, { causesFire: true }); + * + * // Creates an explosion of radius 10 that can go underwater + * location.dimension.createExplosion(location, 10, { allowUnderwater: true }); + * } + * ``` */ - readonly typeId: string; + createExplosion(location: Vector3, radius: number, explosionOptions?: ExplosionOptions): boolean; /** - * Identifier of this component. Should always be - * minecraft:movement.basic. + * @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. */ - static readonly componentId = 'minecraft:movement.basic'; -} -/** - * @beta - * Defines the general movement speed of this entity. - */ -export class EntityMovementComponent extends IEntityComponent { - protected constructor(); + fillBlocks( + begin: Vector3, + end: Vector3, + block: BlockPermutation | BlockType | string, + options?: BlockFillOptions, + ): number; /** - * Read-only. Returns the current value of default movement - * speed for the entity. - * @throws This property can throw when used. + * @beta + * @remarks + * Finds the location of the closest biome of a particular + * type. Note that the findClosestBiome operation can take some + * time to complete, so avoid using many of these calls within + * a particular tick. + * + * This function can't be called in read-only mode. + * + * @param pos + * Starting location to look for a biome to find. + * @param biomeToFind + * Identifier of the biome to look for. + * @param options + * Additional selection criteria for a biome search. + * @returns + * Returns a location of the biome, or undefined if a biome + * could not be found. + * @throws This function can throw errors. + * + * {@link minecraftcommon.EngineError} + * + * {@link Error} */ - readonly current: number; + findClosestBiome(pos: Vector3, biomeToFind: BiomeType | string, options?: BiomeSearchOptions): Vector3 | undefined; /** - * Identifier of this component. Should always be - * minecraft:movement. + * @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} */ - readonly typeId: string; + getBlock(location: Vector3): Block | undefined; /** - * Value for default movement speed as defined through entity - * components. - * @throws This property can throw when used. + * @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. + * @throws This function can throw errors. */ - readonly value: number; + getBlockFromRay(location: Vector3, direction: Vector3, options?: BlockRaycastOptions): BlockRaycastHit | undefined; /** - * Identifier of this component. Should always be - * minecraft:movement. + * @beta + * @throws This function can throw errors. + * + * {@link Error} + * + * {@link UnloadedChunksError} */ - static readonly componentId = 'minecraft:movement'; + getBlocks(volume: BlockVolumeBase, filter: BlockFilter, allowUnloadedChunks?: boolean): ListBlockVolume; /** * @remarks - * Resets the current default movement speed value for the - * entity to the default value. + * 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 checkFeatherNearby.ts + * ```typescript + * import { DimensionLocation, EntityComponentTypes } from "@minecraft/server"; + * + * // Returns true if a feather item entity is within 'distance' blocks of 'location'. + * function isFeatherNear(location: DimensionLocation, distance: number): boolean { + * const items = location.dimension.getEntities({ + * location: location, + * maxDistance: 20, + * }); + * + * for (const item of items) { + * const itemComp = item.getComponent(EntityComponentTypes.Item); + * + * if (itemComp) { + * if (itemComp.itemStack.typeId.endsWith('feather')) { + * return true; + * } + * } + * } + * + * return false; + * } + * ``` + * @example tagsQuery.ts + * ```typescript + * import { EntityQueryOptions, DimensionLocation } from '@minecraft/server'; + * + * function mobParty(targetLocation: DimensionLocation) { + * const mobs = ['creeper', 'skeleton', 'sheep']; + * + * // create some sample mob data + * for (let i = 0; i < 10; i++) { + * const mobTypeId = mobs[i % mobs.length]; + * const entity = targetLocation.dimension.spawnEntity(mobTypeId, targetLocation); + * entity.addTag('mobparty.' + mobTypeId); + * } + * + * const eqo: EntityQueryOptions = { + * tags: ['mobparty.skeleton'], + * }; + * + * for (const entity of targetLocation.dimension.getEntities(eqo)) { + * entity.kill(); + * } + * } + * ``` */ - resetToDefaultValue(): void; + getEntities(options?: EntityQueryOptions): Entity[]; /** * @remarks - * Resets the default movement speed to the maximum value for - * the entity. - * @throws This function can throw errors. + * 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. */ - resetToMaxValue(): void; + getEntitiesAtBlockLocation(location: Vector3): Entity[]; /** * @remarks - * Resets the default movement speed to the minimum value. - * @throws This function can throw errors. + * Gets entities that intersect with a specified vector + * emanating from a location. + * + * @param options + * Additional options for processing this raycast query. */ - resetToMinValue(): void; + getEntitiesFromRay(location: Vector3, direction: Vector3, options?: EntityRaycastOptions): EntityRaycastHit[]; /** * @remarks - * Sets the current value of default movement speed for the - * entity. - * @param value + * 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. */ - setCurrent(value: number): boolean; -} -/** - * @beta - * When added, this move control causes the mob to fly. - */ -export class EntityMovementFlyComponent extends IEntityComponent { - protected constructor(); + getPlayers(options?: EntityQueryOptions): Player[]; /** - * The maximum number in degrees the mob can turn per tick. - * @throws This property can throw when used. + * @beta + * @remarks + * Returns the current weather. + * + * This function can't be called in read-only mode. + * + * @returns + * Returns a WeatherType that explains the broad category of + * weather that is currently going on. */ - readonly maxTurn: number; + getWeather(): WeatherType; /** - * Identifier of this component. Should always be - * minecraft:movement.fly. + * @beta + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - readonly typeId: string; + playSound(soundId: string, location: Vector3, soundOptions?: WorldSoundOptions): void; /** - * Identifier of this component. Should always be - * minecraft:movement.fly. + * @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} */ - static readonly componentId = 'minecraft:movement.fly'; -} -/** - * @beta - * When added, this move control allows a mob to fly, swim, - * climb, etc. - */ -export class EntityMovementGenericComponent extends IEntityComponent { - protected constructor(); + runCommand(commandString: string): CommandResult; /** - * The maximum number in degrees the mob can turn per tick. - * @throws This property can throw when used. - */ - readonly maxTurn: number; - /** - * Identifier of this component. Should always be - * minecraft:movement.generic. + * @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. */ - readonly typeId: string; + runCommandAsync(commandString: string): Promise; /** - * Identifier of this component. Should always be - * minecraft:movement.generic. + * @beta + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - static readonly componentId = 'minecraft:movement.generic'; -} -/** - * @beta - * When added, this movement control allows the mob to glide. - */ -export class EntityMovementGlideComponent extends IEntityComponent { - protected constructor(); + setBlockPermutation(location: Vector3, permutation: BlockPermutation): void; /** - * The maximum number in degrees the mob can turn per tick. - * @throws This property can throw when used. + * @beta + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. + * + * {@link Error} + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} */ - readonly maxTurn: number; + setBlockType(location: Vector3, blockType: BlockType | string): void; /** - * Speed in effect when the entity is turning. - * @throws This property can throw when used. + * @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. */ - readonly speedWhenTurning: number; + setWeather(weatherType: WeatherType, duration?: number): void; /** - * Start speed during a glide. - * @throws This property can throw when used. + * @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 + * // Spawns an adult horse + * import { DimensionLocation } from '@minecraft/server'; + * + * function spawnAdultHorse(location: DimensionLocation) { + * // Create a horse and triggering the 'ageable_grow_up' event, ensuring the horse is created as an adult + * location.dimension.spawnEntity('minecraft:horse', location); + * } + * ``` + * @example quickFoxLazyDog.ts + * ```typescript + * // Spawns a fox over a dog + * import { DimensionLocation } from '@minecraft/server'; + * import { MinecraftEntityTypes } from '@minecraft/vanilla-data'; + * + * function spawnAdultHorse(location: DimensionLocation) { + * // Create fox (our quick brown fox) + * const fox = location.dimension.spawnEntity(MinecraftEntityTypes.Fox, { + * x: location.x, + * y: location.y + 2, + * z: location.z, + * }); + * + * fox.addEffect('speed', 10, { + * amplifier: 2, + * }); + * + * // Create wolf (our lazy dog) + * const wolf = location.dimension.spawnEntity(MinecraftEntityTypes.Wolf, location); + * wolf.addEffect('slowness', 10, { + * amplifier: 2, + * }); + * wolf.isSneaking = true; + * } + * ``` */ - readonly startSpeed: number; + spawnEntity(identifier: string, location: Vector3, options?: SpawnEntityOptions): Entity; /** - * Identifier of this component. Should always be - * minecraft:movement.glide. + * @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 spawnFeatherItem.ts + * ```typescript + * // Spawns a feather at a location + * import { ItemStack, DimensionLocation } from '@minecraft/server'; + * import { MinecraftItemTypes } from '@minecraft/vanilla-data'; + * + * function spawnFeather(location: DimensionLocation) { + * const featherItem = new ItemStack(MinecraftItemTypes.Feather, 1); + * location.dimension.spawnItem(featherItem, location); + * } + * ``` */ - readonly typeId: string; + spawnItem(itemStack: ItemStack, location: Vector3): Entity; /** - * Identifier of this component. Should always be - * minecraft:movement.glide. + * @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 + * // A function that spawns a particle at a random location near the target location for all players in the server + * import { world, MolangVariableMap, DimensionLocation, Vector3 } from '@minecraft/server'; + * + * function spawnConfetti(location: DimensionLocation) { + * for (let i = 0; i < 100; i++) { + * const molang = new MolangVariableMap(); + * + * molang.setColorRGB('variable.color', { + * red: Math.random(), + * green: Math.random(), + * blue: Math.random() + * }); + * + * const newLocation: Vector3 = { + * x: location.x + Math.floor(Math.random() * 8) - 4, + * y: location.y + Math.floor(Math.random() * 8) - 4, + * z: location.z + Math.floor(Math.random() * 8) - 4, + * }; + * location.dimension.spawnParticle('minecraft:colored_flame_particle', newLocation, molang); + * } + * } + * ``` */ - static readonly componentId = 'minecraft:movement.glide'; + spawnParticle(effectName: string, location: Vector3, molangVariables?: MolangVariableMap): void; } + /** - * @beta - * When added, this move control causes the mob to hover. + * Represents a type of dimension. */ -export class EntityMovementHoverComponent extends IEntityComponent { - protected constructor(); - /** - * The maximum number in degrees the mob can turn per tick. - * @throws This property can throw when used. - */ - readonly maxTurn: number; +export class DimensionType { + private constructor(); /** - * Identifier of this component. Should always be - * minecraft:movement.hover. + * @remarks + * Identifier of the dimension type. + * */ readonly typeId: string; - /** - * Identifier of this component. Should always be - * minecraft:movement.hover. - */ - static readonly componentId = 'minecraft:movement.hover'; } + /** - * @beta - * Move control that causes the mob to jump as it moves with a - * specified delay between jumps. + * Used for accessing all available dimension types. */ -export class EntityMovementJumpComponent extends IEntityComponent { - protected constructor(); - /** - * The maximum number in degrees the mob can turn per tick. - * @throws This property can throw when used. - */ - readonly maxTurn: number; +export class DimensionTypes { + private constructor(); /** - * Identifier of this component. Should always be - * minecraft:movement.jump. + * @remarks + * Retrieves a dimension type using a string-based identifier. + * */ - readonly typeId: string; + static get(dimensionTypeId: string): DimensionType | undefined; /** - * Identifier of this component. Should always be - * minecraft:movement.jump. + * @remarks + * Retrieves an array of all dimension types. + * */ - static readonly componentId = 'minecraft:movement.jump'; + static getAll(): DimensionType[]; } + /** - * @beta - * When added, this move control causes the mob to hop as it - * moves. + * Represents an effect - like poison - that has been added to + * an Entity. */ -export class EntityMovementSkipComponent extends IEntityComponent { - protected constructor(); +export class Effect { + private constructor(); /** - * The maximum number in degrees the mob can turn per tick. + * @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 maxTurn: number; - /** - * Identifier of this component. Should always be - * minecraft:movement.skip. - */ - readonly typeId: string; - /** - * Identifier of this component. Should always be - * minecraft:movement.skip. - */ - 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. - */ -export class EntityMovementSwayComponent extends IEntityComponent { - protected constructor(); + readonly amplifier: number; /** - * The maximum number in degrees the mob can turn per tick. + * @remarks + * Gets the player-friendly name of this effect. + * * @throws This property can throw when used. */ - readonly maxTurn: number; + readonly displayName: string; /** - * Amplitude of the sway motion. + * @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 swayAmplitude: number; + readonly duration: number; /** - * Amount of sway frequency. + * @remarks + * Gets the type id of this effect. + * * @throws This property can throw when used. */ - readonly swayFrequency: number; - /** - * Identifier of this component. Should always be - * minecraft:movement.sway. - */ readonly typeId: string; /** - * Identifier of this component. Should always be - * minecraft:movement.sway. + * @remarks + * Returns whether an effect instance is available for use in + * this context. + * */ - static readonly componentId = 'minecraft:movement.sway'; + isValid(): boolean; } + /** - * @beta - * Allows this entity to generate paths that include vertical - * walls (for example, like Minecraft spiders do.) + * Contains information related to changes to an effect - like + * poison - being added to an entity. */ -export class EntityNavigationClimbComponent extends IEntityComponent { - protected constructor(); +export class EffectAddAfterEvent { + private constructor(); /** - * Tells the pathfinder to avoid blocks that cause damage when - * finding a path. - * @throws This property can throw when used. + * @remarks + * Additional properties and details of the effect. + * */ - readonly avoidDamageBlocks: boolean; + readonly effect: Effect; /** - * Tells the pathfinder to avoid portals (like nether portals) - * when finding a path. - * @throws This property can throw when used. + * @remarks + * Entity that the effect is being added to. + * */ - readonly avoidPortals: boolean; + readonly entity: Entity; +} + +/** + * Manages callbacks that are connected to when an effect is + * added to an entity. + */ +export class EffectAddAfterEventSignal { + private constructor(); /** - * Whether or not the pathfinder should avoid tiles that are - * exposed to the sun when creating paths. - * @throws This property can throw when used. + * @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. + * */ - readonly avoidSun: boolean; + subscribe( + callback: (arg: EffectAddAfterEvent) => void, + options?: EntityEventOptions, + ): (arg: EffectAddAfterEvent) => void; /** - * Tells the pathfinder to avoid water when creating a path. - * @throws This property can throw when used. + * @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. */ - readonly avoidWater: boolean; + unsubscribe(callback: (arg: EffectAddAfterEvent) => void): void; +} + +/** + * Contains information related to changes to an effect - like + * poison - being added to an entity. + */ +export class EffectAddBeforeEvent { + private constructor(); /** - * Tells the pathfinder whether or not it can jump out of water - * (like a dolphin). - * @throws This property can throw when used. + * @remarks + * When set to true will cancel the event. + * */ - readonly canBreach: boolean; + cancel: boolean; /** - * Tells the pathfinder that it can path through a closed door - * and break it. - * @throws This property can throw when used. + * @remarks + * Effect duration. + * */ - readonly canBreakDoors: boolean; + duration: number; /** - * Tells the pathfinder whether or not it can float. - * @throws This property can throw when used. + * @remarks + * The type of the effect that is being added. + * */ - readonly canFloat: boolean; + readonly effectType: string; /** - * Tells the pathfinder whether or not it can jump up blocks. - * @throws This property can throw when used. - */ - readonly canJump: boolean; - /** - * 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; - /** - * 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; - /** - * Whether a path can be created through a door. - * @throws This property can throw when used. - */ - readonly canPassDoors: boolean; - /** - * Tells the pathfinder that it can start pathing when in the - * air. - * @throws This property can throw when used. - */ - readonly canPathFromAir: boolean; - /** - * Tells the pathfinder whether or not it can travel on the - * surface of the lava. - * @throws This property can throw when used. + * @remarks + * Entity that the effect is being added to. + * */ - readonly canPathOverLava: boolean; + readonly entity: Entity; +} + +/** + * Manages callbacks that are connected to when an effect is + * added to an entity. + */ +export class EffectAddBeforeEventSignal { + private constructor(); /** - * Tells the pathfinder whether or not it can travel on the - * surface of the water. - * @throws This property can throw when used. + * @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. + * */ - readonly canPathOverWater: boolean; + subscribe(callback: (arg: EffectAddBeforeEvent) => void): (arg: EffectAddBeforeEvent) => void; /** - * Tells the pathfinder whether or not it will be pulled down - * by gravity while in water. - * @throws This property can throw when used. + * @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. */ - readonly canSink: boolean; + unsubscribe(callback: (arg: EffectAddBeforeEvent) => void): void; +} + +/** + * Represents a type of effect - like poison - that can be + * applied to an entity. + */ +export class EffectType { + private constructor(); /** - * 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. + * @remarks + * Identifier name of this effect type. + * + * @returns + * Identifier of the effect type. */ - readonly canSwim: boolean; + getName(): string; +} + +/** + * Represents a type of effect - like poison - that can be + * applied to an entity. + */ +export class EffectTypes { + private constructor(); /** - * Tells the pathfinder whether or not it can walk on the - * ground outside water. - * @throws This property can throw when used. + * @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. */ - readonly canWalk: boolean; + static get(identifier: string): EffectType | undefined; /** - * Tells the pathfinder whether or not it can travel in lava - * like walking on ground. - * @throws This property can throw when used. + * @remarks + * Gets all effects. + * + * This function can't be called in read-only mode. + * + * @returns + * A list of all effects. */ - readonly canWalkInLava: boolean; + static getAll(): EffectType[]; +} + +/** + * @beta + * Contains information on a type of enchantment. + */ +export class EnchantmentType { /** - * Tells the pathfinder whether or not it can walk on the - * ground or go underwater. - * @throws This property can throw when used. + * @remarks + * The name of the enchantment type. + * */ - readonly isAmphibious: boolean; + readonly id: string; /** - * Identifier of this component. Should always be - * minecraft:navigation.climb. + * @remarks + * The maximum level this type of enchantment can have. + * */ - readonly typeId: string; + readonly maxLevel: number; /** - * Identifier of this component. Should always be - * minecraft:navigation.climb. + * @throws This function can throw errors. */ - static readonly componentId = 'minecraft:navigation.climb'; + constructor(enchantmentType: string); } + /** * @beta - * Allows this entity to generate paths by flying around the - * air like the regular Ghast. + * Contains a catalog of Minecraft Enchantment Types that are + * available in this world. */ -export class EntityNavigationFloatComponent extends IEntityComponent { - protected constructor(); - /** - * Tells the pathfinder to avoid blocks that cause damage when - * finding a path. - * @throws This property can throw when used. - */ - readonly avoidDamageBlocks: boolean; +export class EnchantmentTypes { + private constructor(); /** - * Tells the pathfinder to avoid portals (like nether portals) - * when finding a path. - * @throws This property can throw when used. - */ - readonly avoidPortals: boolean; - /** - * Whether or not the pathfinder should avoid tiles that are - * exposed to the sun when creating paths. - * @throws This property can throw when used. + * @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. */ - readonly avoidSun: boolean; + 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(); /** - * Tells the pathfinder to avoid water when creating a path. + * @remarks + * Dimension that the entity is currently within. + * * @throws This property can throw when used. */ - readonly avoidWater: boolean; + readonly dimension: Dimension; /** - * Tells the pathfinder whether or not it can jump out of water - * (like a dolphin). + * @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 canBreach: boolean; + readonly fallDistance: number; /** - * Tells the pathfinder that it can path through a closed door - * and break it. - * @throws This property can throw when used. + * @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 canBreakDoors: boolean; + readonly id: string; /** - * Tells the pathfinder whether or not it can float. + * @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 canFloat: boolean; + readonly isClimbing: boolean; /** - * Tells the pathfinder whether or not it can jump up blocks. + * @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 canJump: boolean; + readonly isFalling: boolean; /** - * Tells the pathfinder that it can path through a closed door - * assuming the AI will open the door. + * @remarks + * Whether any part of the entity is inside a water block. + * * @throws This property can throw when used. */ - readonly canOpenDoors: boolean; + readonly isInWater: boolean; /** - * Tells the pathfinder that it can path through a closed iron - * door assuming the AI will open the door. + * @remarks + * Whether the entity is on top of a solid block. This property + * may behave in unexpected ways. This property will always be + * true when an Entity is first spawned, and if the Entity has + * no gravity this property may be incorrect. + * * @throws This property can throw when used. */ - readonly canOpenIronDoors: boolean; + readonly isOnGround: boolean; /** - * Whether a path can be created through a door. + * @remarks + * If true, the entity is currently sleeping. + * * @throws This property can throw when used. */ - readonly canPassDoors: boolean; + readonly isSleeping: boolean; /** - * Tells the pathfinder that it can start pathing when in the - * air. - * @throws This property can throw when used. + * @remarks + * Whether the entity is sneaking - that is, moving more slowly + * and more quietly. + * + * This property can't be edited in read-only mode. + * */ - readonly canPathFromAir: boolean; + isSneaking: boolean; /** - * Tells the pathfinder whether or not it can travel on the - * surface of the lava. + * @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 canPathOverLava: boolean; + readonly isSprinting: boolean; /** - * Tells the pathfinder whether or not it can travel on the - * surface of the water. + * @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 canPathOverWater: boolean; + readonly isSwimming: boolean; /** - * Tells the pathfinder whether or not it will be pulled down - * by gravity while in water. - * @throws This property can throw when used. + * @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 canSink: boolean; + readonly lifetimeState: EntityLifetimeState; /** - * Tells the pathfinder whether or not it can path anywhere - * through water and plays swimming animation along that path. + * @remarks + * Current location of the entity. + * * @throws This property can throw when used. */ - readonly canSwim: boolean; + readonly location: Vector3; /** - * Tells the pathfinder whether or not it can walk on the - * ground outside water. - * @throws This property can throw when used. + * @remarks + * Given name of the entity. + * + * This property can't be edited in read-only mode. + * */ - readonly canWalk: boolean; + nameTag: string; /** - * Tells the pathfinder whether or not it can travel in lava - * like walking on ground. - * @throws This property can throw when used. + * @remarks + * Returns a scoreboard identity that represents this entity. + * Will remain valid when the entity is killed. + * */ - readonly canWalkInLava: boolean; + readonly scoreboardIdentity?: ScoreboardIdentity; /** - * Tells the pathfinder whether or not it can walk on the - * ground or go underwater. + * @beta + * @remarks + * Retrieves or sets an entity that is used as the target of + * AI-related behaviors, like attacking. If the entity + * currently has no target returns undefined. + * * @throws This property can throw when used. */ - readonly isAmphibious: boolean; + readonly target?: Entity; /** - * Identifier of this component. Should always be - * minecraft:navigation.float. + * @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; /** - * Identifier of this component. Should always be - * minecraft:navigation.float. - */ - static readonly componentId = 'minecraft:navigation.float'; -} -/** - * @beta - * Allows this entity to generate paths in the air (for - * example, like Minecraft parrots do.) - */ -export class EntityNavigationFlyComponent extends IEntityComponent { - protected constructor(); - /** - * Tells the pathfinder to avoid blocks that cause damage when - * finding a path. - * @throws This property can throw when used. + * @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 poisonVillager.ts + * ```typescript + * // Spawns a villager and gives it the poison effect + * import { + * DimensionLocation, + * } from '@minecraft/server'; + * import { MinecraftEffectTypes } from '@minecraft/vanilla-data'; + * + * function spawnPoisonedVillager(location: DimensionLocation) { + * const villagerType = 'minecraft:villager_v2'; + * const villager = location.dimension.spawnEntity(villagerType, location); + * const duration = 20; + * + * villager.addEffect(MinecraftEffectTypes.Poison, duration, { amplifier: 1 }); + * } + * + * ``` + * @example quickFoxLazyDog.ts + * ```typescript + * // Spawns a fox over a dog + * import { DimensionLocation } from '@minecraft/server'; + * import { MinecraftEntityTypes } from '@minecraft/vanilla-data'; + * + * function spawnAdultHorse(location: DimensionLocation) { + * // Create fox (our quick brown fox) + * const fox = location.dimension.spawnEntity(MinecraftEntityTypes.Fox, { + * x: location.x, + * y: location.y + 2, + * z: location.z, + * }); + * + * fox.addEffect('speed', 10, { + * amplifier: 2, + * }); + * + * // Create wolf (our lazy dog) + * const wolf = location.dimension.spawnEntity(MinecraftEntityTypes.Wolf, location); + * wolf.addEffect('slowness', 10, { + * amplifier: 2, + * }); + * wolf.isSneaking = true; + * } + * ``` */ - readonly avoidDamageBlocks: boolean; + addEffect(effectType: EffectType | string, duration: number, options?: EntityEffectOptions): Effect | undefined; /** - * Tells the pathfinder to avoid portals (like nether portals) - * when finding a path. - * @throws This property can throw when used. + * @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. */ - readonly avoidPortals: boolean; + addTag(tag: string): boolean; /** - * Whether or not the pathfinder should avoid tiles that are - * exposed to the sun when creating paths. - * @throws This property can throw when used. + * @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 + * // A function that applies damage and then heals the entity + * import { Entity, EntityComponentTypes, system, world } from '@minecraft/server'; + * + * function applyDamageAndHeal(entity: Entity) { + * entity.applyDamage(19); // Many mobs have max damage of 20 so this is a near-death mob + * + * system.runTimeout(() => { + * const health = entity.getComponent(EntityComponentTypes.Health); + * if (health) { + * world.sendMessage(`Entity health before heal: ${health.currentValue}`); + * + * health.resetToMaxValue(); + * + * world.sendMessage(`Entity after before heal: ${health.currentValue}`); + * } else { + * console.warn('Entity does not have health component'); + * } + * }, 40); // Run in a few seconds (40 ticks) + * } + * ``` */ - readonly avoidSun: boolean; + applyDamage(amount: number, options?: EntityApplyDamageByProjectileOptions | EntityApplyDamageOptions): boolean; /** - * Tells the pathfinder to avoid water when creating a path. - * @throws This property can throw when used. + * @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 yeetEntity.ts + * ```typescript + * // A function that throws entities up in the air + * import { Entity } from '@minecraft/server'; + * + * function yeetEntity(entity: Entity) { + * + * // Zero out the entity's velocity before applying impulse + * entity.clearVelocity(); + * + * // throw the zombie up in the air + * entity.applyImpulse({ x: 0, y: 15, z: 0 }); + * } + * ``` */ - readonly avoidWater: boolean; + applyImpulse(vector: Vector3): void; /** - * Tells the pathfinder whether or not it can jump out of water - * (like a dolphin). - * @throws This property can throw when used. + * @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 + * import { EntityQueryOptions, DimensionLocation } from '@minecraft/server'; + * + * function mobParty(targetLocation: DimensionLocation) { + * const mobs = ['creeper', 'skeleton', 'sheep']; + * + * // create some sample mob data + * for (let i = 0; i < 10; i++) { + * targetLocation.dimension.spawnEntity(mobs[i % mobs.length], targetLocation); + * } + * + * const eqo: EntityQueryOptions = { + * type: 'skeleton', + * }; + * + * for (const entity of targetLocation.dimension.getEntities(eqo)) { + * entity.applyKnockback(0, 0, 0, 1); + * } + * } + * ``` */ - readonly canBreach: boolean; + applyKnockback(directionX: number, directionZ: number, horizontalStrength: number, verticalStrength: number): void; /** - * Tells the pathfinder that it can path through a closed door - * and break it. - * @throws This property can throw when used. + * @remarks + * Clears all dynamic properties that have been set on this + * entity. + * + * @throws This function can throw errors. */ - readonly canBreakDoors: boolean; + clearDynamicProperties(): void; /** - * Tells the pathfinder whether or not it can float. - * @throws This property can throw when used. + * @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 yeetEntity.ts + * ```typescript + * // A function that throws entities up in the air + * import { Entity } from '@minecraft/server'; + * + * function yeetEntity(entity: Entity) { + * + * // Zero out the entity's velocity before applying impulse + * entity.clearVelocity(); + * + * // throw the zombie up in the air + * entity.applyImpulse({ x: 0, y: 15, z: 0 }); + * } + * ``` */ - readonly canFloat: boolean; + clearVelocity(): void; /** - * Tells the pathfinder whether or not it can jump up blocks. - * @throws This property can throw when used. + * @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 setEntityOnFire.ts + * ```typescript + * import { world, Entity, EntityComponentTypes, system } from "@minecraft/server"; + * + * function setAblaze(entity: Entity) { + * entity.setOnFire(20, true); + * + * system.runTimeout(() => { + * const onfire = entity.getComponent(EntityComponentTypes.OnFire); + * if (onfire) { + * world.sendMessage(`${onfire.onFireTicksRemaining} fire ticks remaining, extinguishing the entity.`); + * } + * // This will extinguish the entity + * entity.extinguishFire(true); + * }, 30); // Run in 30 ticks or ~1.5 seconds + * + * } + * ``` */ - readonly canJump: boolean; + extinguishFire(useEffects?: boolean): boolean; /** - * 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. + * @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. */ - readonly canOpenDoors: boolean; + getBlockFromViewDirection(options?: BlockRaycastOptions): BlockRaycastHit | undefined; /** - * 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. + * @remarks + * Gets a component (that represents additional capabilities) + * for an entity. + * + * @param componentId + * The identifier of the component (e.g., 'minecraft:health'). + * If no namespace prefix is specified, 'minecraft:' is + * assumed. Available component IDs can be found as part of the + * {@link EntityComponentTypes} enum. + * @returns + * Returns the component if it exists on the entity, otherwise + * undefined. */ - readonly canOpenIronDoors: boolean; + getComponent(componentId: T): EntityComponentTypeMap[T] | undefined; /** - * Whether a path can be created through a door. - * @throws This property can throw when used. + * @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. */ - readonly canPassDoors: boolean; + getComponents(): EntityComponent[]; /** - * Tells the pathfinder that it can start pathing when in the - * air. - * @throws This property can throw when used. + * @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. */ - readonly canPathFromAir: boolean; + getDynamicProperty(identifier: string): boolean | number | string | Vector3 | undefined; /** - * Tells the pathfinder whether or not it can travel on the - * surface of the lava. - * @throws This property can throw when used. + * @remarks + * Returns the available set of dynamic property identifiers + * that have been used on this entity. + * + * @returns + * A string array of the dynamic properties set on this entity. + * @throws This function can throw errors. */ - readonly canPathOverLava: boolean; + getDynamicPropertyIds(): string[]; /** - * Tells the pathfinder whether or not it can travel on the - * surface of the water. - * @throws This property can throw when used. + * @remarks + * Returns the total size, in bytes, of all the dynamic + * properties that are currently stored for this entity. This + * includes the size of both the key and the value. This can + * be useful for diagnosing performance warning signs - if, for + * example, an entity has many megabytes of associated dynamic + * properties, it may be slow to load on various devices. + * + * @throws This function can throw errors. */ - readonly canPathOverWater: boolean; + getDynamicPropertyTotalByteCount(): number; /** - * Tells the pathfinder whether or not it will be pulled down - * by gravity while in water. - * @throws This property can throw when used. + * @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. */ - readonly canSink: boolean; + getEffect(effectType: EffectType | string): Effect | undefined; /** - * 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. + * @remarks + * Returns a set of effects applied to this entity. + * + * @returns + * List of effects. + * @throws This function can throw errors. */ - readonly canSwim: boolean; + getEffects(): Effect[]; /** - * Tells the pathfinder whether or not it can walk on the - * ground outside water. - * @throws This property can throw when used. + * @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. */ - readonly canWalk: boolean; + getEntitiesFromViewDirection(options?: EntityRaycastOptions): EntityRaycastHit[]; /** - * Tells the pathfinder whether or not it can travel in lava - * like walking on ground. - * @throws This property can throw when used. + * @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. */ - readonly canWalkInLava: boolean; + getHeadLocation(): Vector3; /** - * Tells the pathfinder whether or not it can walk on the - * ground or go underwater. - * @throws This property can throw when used. + * @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. */ - readonly isAmphibious: boolean; + getProperty(identifier: string): boolean | number | string | undefined; /** - * Identifier of this component. Should always be - * minecraft:navigation.fly. + * @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. */ - readonly typeId: string; + getRotation(): Vector2; /** - * Identifier of this component. Should always be - * minecraft:navigation.fly. + * @remarks + * Returns all tags associated with the entity. + * + * @returns + * An array containing all tags as strings. + * @throws This function can throw errors. */ - 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. - */ -export class EntityNavigationGenericComponent extends IEntityComponent { - protected constructor(); + getTags(): string[]; /** - * Tells the pathfinder to avoid blocks that cause damage when - * finding a path. - * @throws This property can throw when used. + * @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 + * // A function that spawns fireworks and logs their velocity after 5 ticks + * import { DimensionLocation, system, world } from '@minecraft/server'; + * import { MinecraftEntityTypes } from '@minecraft/vanilla-data'; + * + * function spawnFireworks(location: DimensionLocation) { + * const fireworkRocket = location.dimension.spawnEntity(MinecraftEntityTypes.FireworksRocket, location); + * + * system.runTimeout(() => { + * const velocity = fireworkRocket.getVelocity(); + * + * world.sendMessage(`Velocity of firework is: ${velocity.x}, ${velocity.y}, ${velocity.z}`); + * }, 5); + * } + * ``` */ - readonly avoidDamageBlocks: boolean; + getVelocity(): Vector3; /** - * Tells the pathfinder to avoid portals (like nether portals) - * when finding a path. - * @throws This property can throw when used. + * @remarks + * Returns the current view direction of the entity. + * + * @returns + * Returns the current view direction of the entity. + * @throws This function can throw errors. */ - readonly avoidPortals: boolean; + getViewDirection(): Vector3; /** - * Whether or not the pathfinder should avoid tiles that are - * exposed to the sun when creating paths. - * @throws This property can throw when used. + * @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. */ - readonly avoidSun: boolean; + hasComponent(componentId: string): boolean; /** - * Tells the pathfinder to avoid water when creating a path. - * @throws This property can throw when used. + * @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. */ - readonly avoidWater: boolean; + hasTag(tag: string): boolean; /** - * Tells the pathfinder whether or not it can jump out of water - * (like a dolphin). - * @throws This property can throw when used. + * @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. */ - readonly canBreach: boolean; + isValid(): boolean; /** - * Tells the pathfinder that it can path through a closed door - * and break it. - * @throws This property can throw when used. + * @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 + * import { EntityQueryOptions, DimensionLocation } from '@minecraft/server'; + * + * function mobParty(targetLocation: DimensionLocation) { + * const mobs = ['creeper', 'skeleton', 'sheep']; + * + * // create some sample mob data + * for (let i = 0; i < 10; i++) { + * const mobTypeId = mobs[i % mobs.length]; + * const entity = targetLocation.dimension.spawnEntity(mobTypeId, targetLocation); + * entity.addTag('mobparty.' + mobTypeId); + * } + * + * const eqo: EntityQueryOptions = { + * tags: ['mobparty.skeleton'], + * }; + * + * for (const entity of targetLocation.dimension.getEntities(eqo)) { + * entity.kill(); + * } + * } + * ``` */ - readonly canBreakDoors: boolean; + kill(): boolean; /** - * Tells the pathfinder whether or not it can float. - * @throws This property can throw when used. + * @remarks + * Matches the entity against the passed in options. Uses the + * location of the entity for matching if the location is not + * specified in the passed in EntityQueryOptions. + * + * @param options + * The query to perform the match against. + * @returns + * Returns true if the entity matches the criteria in the + * passed in EntityQueryOptions, otherwise it returns false. + * @throws + * Throws if the query options are misconfigured. */ - readonly canFloat: boolean; + matches(options: EntityQueryOptions): boolean; /** - * Tells the pathfinder whether or not it can jump up blocks. - * @throws This property can throw when used. + * @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. */ - readonly canJump: boolean; + playAnimation(animationName: string, options?: PlayAnimationOptions): void; /** - * 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. + * @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. */ - readonly canOpenDoors: boolean; + remove(): void; /** - * 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. + * @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. */ - readonly canOpenIronDoors: boolean; + removeEffect(effectType: EffectType | string): boolean; /** - * Whether a path can be created through a door. - * @throws This property can throw when used. + * @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. */ - readonly canPassDoors: boolean; + removeTag(tag: string): boolean; /** - * Tells the pathfinder that it can start pathing when in the - * air. - * @throws This property can throw when used. + * @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. + * + * {@link minecraftcommon.EngineError} + * + * {@link Error} */ - readonly canPathFromAir: boolean; + resetProperty(identifier: string): boolean | number | string; /** - * Tells the pathfinder whether or not it can travel on the - * surface of the lava. - * @throws This property can throw when used. + * @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} */ - readonly canPathOverLava: boolean; + runCommand(commandString: string): CommandResult; /** - * Tells the pathfinder whether or not it can travel on the - * surface of the water. - * @throws This property can throw when used. + * @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. */ - readonly canPathOverWater: boolean; + runCommandAsync(commandString: string): Promise; /** - * Tells the pathfinder whether or not it will be pulled down - * by gravity while in water. - * @throws This property can throw when used. + * @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. */ - readonly canSink: boolean; + setDynamicProperty(identifier: string, value?: boolean | number | string | Vector3): void; /** - * 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. + * @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 setEntityOnFire.ts + * ```typescript + * import { world, Entity, EntityComponentTypes, system } from "@minecraft/server"; + * + * function setAblaze(entity: Entity) { + * entity.setOnFire(20, true); + * + * system.runTimeout(() => { + * const onfire = entity.getComponent(EntityComponentTypes.OnFire); + * if (onfire) { + * world.sendMessage(`${onfire.onFireTicksRemaining} fire ticks remaining, extinguishing the entity.`); + * } + * // This will extinguish the entity + * entity.extinguishFire(true); + * }, 30); // Run in 30 ticks or ~1.5 seconds + * + * } + * ``` */ - readonly canSwim: boolean; + setOnFire(seconds: number, useEffects?: boolean): boolean; /** - * Tells the pathfinder whether or not it can walk on the - * ground outside water. - * @throws This property can throw when used. + * @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 */ - readonly canWalk: boolean; + setProperty(identifier: string, value: boolean | number | string): void; /** - * Tells the pathfinder whether or not it can travel in lava - * like walking on ground. - * @throws This property can throw when used. + * @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. */ - readonly canWalkInLava: boolean; + setRotation(rotation: Vector2): void; /** - * Tells the pathfinder whether or not it can walk on the - * ground or go underwater. - * @throws This property can throw when used. + * @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 + * import { world, system } from '@minecraft/server'; + * + * const overworld = world.getDimension('overworld'); + * const targetLocation = { x: 0, y: 0, z: 0 }; + * + * const pig = overworld.spawnEntity('minecraft:pig', targetLocation); + * + * let inc = 1; + * const runId = system.runInterval(() => { + * pig.teleport( + * { x: targetLocation.x + inc / 4, y: targetLocation.y + inc / 4, z: targetLocation.z + inc / 4 }, + * { + * facingLocation: targetLocation, + * }, + * ); + * + * if (inc > 100) { + * system.clearRun(runId); + * } + * inc++; + * }, 4); + * ``` */ - readonly isAmphibious: boolean; + teleport(location: Vector3, teleportOptions?: TeleportOptions): void; /** - * Identifier of this component. Should always be - * minecraft:navigation.generic. + * @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 + * // A function that spawns a creeper and triggers it to explode immediately + * import { DimensionLocation } from '@minecraft/server'; + * import { MinecraftEntityTypes } from '@minecraft/vanilla-data'; + * + * function spawnExplodingCreeper(location: DimensionLocation) { + * const creeper = location.dimension.spawnEntity(MinecraftEntityTypes.Creeper, location); + * + * creeper.triggerEvent('minecraft:start_exploding_forced'); + * } + * ``` */ - readonly typeId: string; + triggerEvent(eventName: string): void; /** - * Identifier of this component. Should always be - * minecraft:navigation.generic. - */ - 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. - */ -export class EntityNavigationHoverComponent extends IEntityComponent { - protected constructor(); - /** - * Tells the pathfinder to avoid blocks that cause damage when - * finding a path. - * @throws This property can throw when used. - */ - readonly avoidDamageBlocks: boolean; - /** - * Tells the pathfinder to avoid portals (like nether portals) - * when finding a path. - * @throws This property can throw when used. - */ - readonly avoidPortals: boolean; - /** - * Whether or not the pathfinder should avoid tiles that are - * exposed to the sun when creating paths. - * @throws This property can throw when used. + * @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. */ - readonly avoidSun: boolean; + 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(); /** - * Tells the pathfinder to avoid water when creating a path. + * @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 avoidWater: boolean; + readonly entityType: string; /** - * Tells the pathfinder whether or not it can jump out of water - * (like a dolphin). + * @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 canBreach: boolean; + 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(); /** - * Tells the pathfinder that it can path through a closed door - * and break it. + * @remarks + * Amount of time before the entity grows up, -1 for always a + * baby. + * * @throws This property can throw when used. */ - readonly canBreakDoors: boolean; + readonly duration: number; /** - * Tells the pathfinder whether or not it can float. + * @remarks + * Event that runs when this entity grows up. + * * @throws This property can throw when used. */ - readonly canFloat: boolean; + readonly growUp: Trigger; /** - * Tells the pathfinder whether or not it can jump up blocks. + * @remarks + * The feed item used will transform into this item upon + * successful interaction. + * * @throws This property can throw when used. */ - readonly canJump: boolean; + readonly transformToItem: string; + static readonly componentId = 'minecraft:ageable'; /** - * 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. + * @remarks + * List of items that the entity drops when it grows up. + * + * @throws This function can throw errors. */ - readonly canOpenDoors: boolean; + getDropItems(): string[]; /** - * 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. + * @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. */ - readonly canOpenIronDoors: boolean; + getFeedItems(): EntityDefinitionFeedItem[]; +} + +/** + * 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(); /** - * Whether a path can be created through a door. + * @remarks + * Current value of this attribute for this instance. + * * @throws This property can throw when used. */ - readonly canPassDoors: boolean; + readonly currentValue: number; /** - * Tells the pathfinder that it can start pathing when in the - * air. + * @remarks + * Returns the default defined value for this attribute. + * * @throws This property can throw when used. */ - readonly canPathFromAir: boolean; + readonly defaultValue: number; /** - * Tells the pathfinder whether or not it can travel on the - * surface of the lava. + * @remarks + * Returns the effective max of this attribute given any other + * ambient components or factors. + * * @throws This property can throw when used. */ - readonly canPathOverLava: boolean; + readonly effectiveMax: number; /** - * Tells the pathfinder whether or not it can travel on the - * surface of the water. + * @remarks + * Returns the effective min of this attribute given any other + * ambient components or factors. + * * @throws This property can throw when used. */ - readonly canPathOverWater: boolean; + readonly effectiveMin: number; /** - * Tells the pathfinder whether or not it will be pulled down - * by gravity while in water. - * @throws This property can throw when used. + * @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. */ - readonly canSink: boolean; + resetToDefaultValue(): void; /** - * 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. + * @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. */ - readonly canSwim: boolean; + resetToMaxValue(): void; /** - * Tells the pathfinder whether or not it can walk on the - * ground outside water. - * @throws This property can throw when used. + * @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. */ - readonly canWalk: boolean; + resetToMinValue(): void; /** - * Tells the pathfinder whether or not it can travel in lava - * like walking on ground. - * @throws This property can throw when used. + * @remarks + * Sets the current value of this attribute. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - readonly canWalkInLava: boolean; + 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(); /** - * Tells the pathfinder whether or not it can walk on the - * ground or go underwater. + * @remarks + * Maximum turn rate for this movement modality of the mob. + * * @throws This property can throw when used. */ - readonly isAmphibious: boolean; - /** - * Identifier of this component. Should always be - * minecraft:navigation.hover. - */ - readonly typeId: string; - /** - * Identifier of this component. Should always be - * minecraft:navigation.hover. - */ - static readonly componentId = 'minecraft:navigation.hover'; + readonly maxTurn: number; } + /** * @beta - * Allows this entity to generate paths by walking around and - * jumping up and down a block like regular mobs. + * Defines what blocks this entity can breathe in and gives + * them the ability to suffocate. */ -export class EntityNavigationWalkComponent extends IEntityComponent { - protected constructor(); - /** - * Tells the pathfinder to avoid blocks that cause damage when - * finding a path. - * @throws This property can throw when used. - */ - readonly avoidDamageBlocks: boolean; +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityBreathableComponent extends EntityComponent { + private constructor(); /** - * Tells the pathfinder to avoid portals (like nether portals) - * when finding a path. + * @remarks + * If true, this entity can breathe in air. + * * @throws This property can throw when used. */ - readonly avoidPortals: boolean; + readonly breathesAir: boolean; /** - * Whether or not the pathfinder should avoid tiles that are - * exposed to the sun when creating paths. + * @remarks + * If true, this entity can breathe in lava. + * * @throws This property can throw when used. */ - readonly avoidSun: boolean; + readonly breathesLava: boolean; /** - * Tells the pathfinder to avoid water when creating a path. + * @remarks + * If true, this entity can breathe in solid blocks. + * * @throws This property can throw when used. */ - readonly avoidWater: boolean; + readonly breathesSolids: boolean; /** - * Tells the pathfinder whether or not it can jump out of water - * (like a dolphin). + * @remarks + * If true, this entity can breathe in water. + * * @throws This property can throw when used. */ - readonly canBreach: boolean; + readonly breathesWater: boolean; /** - * Tells the pathfinder that it can path through a closed door - * and break it. + * @remarks + * If true, this entity will have visible bubbles while in + * water. + * * @throws This property can throw when used. */ - readonly canBreakDoors: boolean; + readonly generatesBubbles: boolean; /** - * Tells the pathfinder whether or not it can float. + * @remarks + * Time in seconds to recover breath to maximum. + * * @throws This property can throw when used. */ - readonly canFloat: boolean; + readonly inhaleTime: number; /** - * Tells the pathfinder whether or not it can jump up blocks. + * @remarks + * Time in seconds between suffocation damage. + * * @throws This property can throw when used. */ - readonly canJump: boolean; + readonly suffocateTime: number; /** - * Tells the pathfinder that it can path through a closed door - * assuming the AI will open the door. + * @remarks + * Time in seconds the entity can hold its breath. + * * @throws This property can throw when used. */ - readonly canOpenDoors: boolean; + readonly totalSupply: number; + static readonly componentId = 'minecraft:breathable'; /** - * 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. + * @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. */ - readonly canOpenIronDoors: boolean; + getBreatheBlocks(): BlockPermutation[]; /** - * Whether a path can be created through a door. - * @throws This property can throw when used. + * @remarks + * List of blocks this entity can't breathe in. + * + * @throws This function can throw errors. */ - readonly canPassDoors: boolean; + getNonBreatheBlocks(): BlockPermutation[]; /** - * Tells the pathfinder that it can start pathing when in the - * air. - * @throws This property can throw when used. + * @remarks + * Sets the current air supply of the entity. + * + * @param value + * New air supply for the entity. + * @throws This function can throw errors. */ - readonly canPathFromAir: boolean; - /** - * 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; - /** - * 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; - /** - * 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; - /** - * 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; - /** - * Tells the pathfinder whether or not it can walk on the - * ground outside water. - * @throws This property can throw when used. - */ - readonly canWalk: boolean; - /** - * 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; - /** - * 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; - /** - * Identifier of this component. Should always be - * minecraft:navigation.swim. - */ - readonly typeId: string; - /** - * Identifier of this component. Should always be - * minecraft:navigation.swim. - */ - static readonly componentId = 'minecraft:navigation.walk'; + setAirSupply(value: number): void; } + /** - * @beta - * When present on an entity, this entity is on fire. + * When added, this component signifies that the entity can + * climb up ladders. */ -export class EntityOnFireComponent extends IEntityComponent { - protected constructor(); - /** - * The number of ticks remaining before the fire goes out. - */ - readonly onFireTicksRemaining: number; - /** - * Should be 'minecraft:onfire'. - */ - readonly typeId: string; - static readonly componentId = 'minecraft:onfire'; +// @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'; +} + /** * @beta - * Sets the distance through which the entity can push through. */ -export class EntityPushThroughComponent extends IEntityComponent { - protected constructor(); +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityColor2Component extends EntityComponent { + private constructor(); /** - * Identifier of this component. Should always be - * minecraft:push_through. + * @throws This property can throw when used. */ - readonly typeId: string; + readonly value: PaletteColor; + static readonly componentId = 'minecraft:color2'; +} + +/** + * 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(); /** - * The value of the entity's push-through, in blocks. + * @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(); /** - * Identifier of this component. Should always be - * minecraft:push_through. + * @beta + * @remarks + * The entity that owns this component. The entity will be + * undefined if it has been removed. + * */ - static readonly componentId = 'minecraft:push_through'; + readonly entity: Entity; } + /** * @beta - * When added, this component adds the capability that an - * entity can be ridden by another entity. + * 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 EntityRideableComponent extends IEntityComponent { - protected constructor(); - /** - * Zero-based index of the seat that can used to control this - * entity. - * @throws This property can throw when used. - */ - readonly controllingSeat: number; - /** - * Determines whether interactions are not supported if the - * entity is crouching. - * @throws This property can throw when used. - */ - readonly crouchingSkipInteract: boolean; - /** - * 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; - /** - * 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; +export class EntityDefinitionFeedItem { + private constructor(); /** - * If true, this entity will be picked when looked at by the - * rider. - * @throws This property can throw when used. + * @remarks + * The amount by which an entity's age will increase when fed + * this item. Values usually range between 0 and 1. + * */ - readonly riderCanInteract: boolean; + readonly growth: number; /** - * Number of seats for riders defined for this entity. - * @throws This property can throw when used. + * @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 seatCount: number; + readonly item: string; +} + +/** + * Contains data related to the death of an entity in the game. + */ +export class EntityDieAfterEvent { + private constructor(); /** - * Identifier of this component. Should always be - * minecraft:rideable. + * @remarks + * If specified, provides more information on the source of + * damage that caused the death of this entity. + * */ - readonly typeId: string; + readonly damageSource: EntityDamageSource; /** - * Identifier of this component. Should always be - * minecraft:rideable. + * @remarks + * Now-dead entity object. + * */ - static readonly componentId = 'minecraft:rideable'; + readonly deadEntity: Entity; +} + +/** + * Supports registering for an event that fires after an entity + * has died. + */ +export class EntityDieAfterEventSignal { + private constructor(); /** * @remarks - * Adds an entity to this entity as a rider. - * @param rider - * Entity that will become the rider of this entity. + * 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 - * True if the rider entity was successfully added. - * @throws This function can throw errors. + * Returns the closure that can be used in future downstream + * calls to unsubscribe. */ - addRider(rider: Entity): boolean; + subscribe( + callback: (arg: EntityDieAfterEvent) => void, + options?: EntityEventOptions, + ): (arg: EntityDieAfterEvent) => void; /** * @remarks - * Ejects the specified rider of this entity. - * @param rider - * Entity that should be ejected from this entity. + * 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. */ - ejectRider(rider: Entity): void; + unsubscribe(callback: (arg: EntityDieAfterEvent) => void): void; +} + +/** + * Provides access to a mob's equipment slots. This component + * exists for all mob entities. + * @example givePlayerElytra.ts + * ```typescript + * // Gives the player Elytra + * import { EquipmentSlot, ItemStack, Player, EntityComponentTypes } from '@minecraft/server'; + * import { MinecraftItemTypes } from '@minecraft/vanilla-data'; + * + * function giveEquipment(player: Player) { + * const equipmentCompPlayer = player.getComponent(EntityComponentTypes.Equippable); + * if (equipmentCompPlayer) { + * equipmentCompPlayer.setEquipment(EquipmentSlot.Chest, new ItemStack(MinecraftItemTypes.Elytra)); + * } + * } + * ``` + * @example givePlayerEquipment.ts + * ```typescript + * // Gives the player some equipment + * import { EquipmentSlot, ItemStack, Player, EntityComponentTypes } from '@minecraft/server'; + * import { MinecraftItemTypes } from '@minecraft/vanilla-data'; + * + * function giveEquipment(player: Player) { + * const equipmentCompPlayer = player.getComponent(EntityComponentTypes.Equippable); + * if (equipmentCompPlayer) { + * equipmentCompPlayer.setEquipment(EquipmentSlot.Head, new ItemStack(MinecraftItemTypes.GoldenHelmet)); + * equipmentCompPlayer.setEquipment(EquipmentSlot.Chest, new ItemStack(MinecraftItemTypes.IronChestplate)); + * equipmentCompPlayer.setEquipment(EquipmentSlot.Legs, new ItemStack(MinecraftItemTypes.DiamondLeggings)); + * equipmentCompPlayer.setEquipment(EquipmentSlot.Feet, new ItemStack(MinecraftItemTypes.NetheriteBoots)); + * equipmentCompPlayer.setEquipment(EquipmentSlot.Mainhand, new ItemStack(MinecraftItemTypes.WoodenSword)); + * equipmentCompPlayer.setEquipment(EquipmentSlot.Offhand, new ItemStack(MinecraftItemTypes.Shield)); + * } else { + * console.warn('No equipment component found on player'); + * } + * } + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityEquippableComponent extends EntityComponent { + private constructor(); + static readonly componentId = 'minecraft:equippable'; /** * @remarks - * Ejects all riders of this entity. + * Gets the equipped item for the given EquipmentSlot. + * + * @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. */ - ejectRiders(): void; + getEquipment(equipmentSlot: EquipmentSlot): ItemStack | undefined; /** * @remarks - * A string-list of entity types that this entity can support - * as riders. + * Gets the ContainerSlot corresponding to the given + * EquipmentSlot. + * + * @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. */ - getFamilyTypes(): string[]; + getEquipmentSlot(equipmentSlot: EquipmentSlot): ContainerSlot; /** * @remarks - * Gets a list of positions and number of riders for each - * position for entities riding this entity. + * 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. */ - getSeats(): Seat[]; + setEquipment(equipmentSlot: EquipmentSlot, itemStack?: ItemStack): boolean; } + /** - * @beta - * Sets the entity's visual size. + * When added, this component signifies that this entity + * doesn't take damage from fire. */ -export class EntityScaleComponent extends IEntityComponent { - protected constructor(); - /** - * Identifier of this component. Should always be - * minecraft:scale. - */ - readonly typeId: string; - /** - * The value of the scale. 1.0 means the entity will appear at - * the scale they are defined in their model. Higher numbers - * make the entity bigger. - */ - value: number; - /** - * Identifier of this component. Should always be - * minecraft:scale. - */ - static readonly componentId = 'minecraft:scale'; +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityFireImmuneComponent extends EntityComponent { + private constructor(); + static readonly componentId = 'minecraft:fire_immune'; } + /** - * @beta - * Skin Id value. Can be used to differentiate skins, such as - * base skins for villagers. + * When added, this component signifies that this entity can + * float in liquid blocks. */ -export class EntitySkinIdComponent extends IEntityComponent { - protected constructor(); - /** - * Identifier of this component. Should always be - * minecraft:skin_id. - */ - readonly typeId: string; +// @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(); /** - * The identifier of the skin. By convention, 0 is the - * identifier of the base skin. + * @remarks + * Current value of the flying speed of the associated entity. + * + * This property can't be edited in read-only mode. + * */ value: number; - /** - * Identifier of this component. Should always be - * minecraft:skin_id. - */ - static readonly componentId = 'minecraft:skin_id'; + static readonly componentId = 'minecraft:flying_speed'; } + /** - * @beta - * Contains data related to an entity spawning within the - * world. + * Defines how much friction affects this entity. */ -export class EntitySpawnEvent { - protected constructor(); +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityFrictionModifierComponent extends EntityComponent { + private constructor(); /** - * Entity that was spawned. + * @remarks + * Current value of the friction modifier of the associated + * entity. + * + * This property can't be edited in read-only mode. + * */ - entity: Entity; + value: number; + static readonly componentId = 'minecraft:friction_modifier'; } + /** - * @beta - * Registers a script-based event handler for handling what - * happens when an entity spawns. + * Sets the offset from the ground that the entity is actually + * at. */ -export class EntitySpawnEventSignal { - protected constructor(); - /** - * @remarks - * Method to register an event handler for what happens when an - * entity spawns. - * @param callback - * Function that handles the spawn event. - */ - subscribe(callback: (arg: EntitySpawnEvent) => void): (arg: EntitySpawnEvent) => void; +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityGroundOffsetComponent extends EntityComponent { + private constructor(); /** * @remarks - * Unregisters a method that was previously subscribed to the - * subscription event. - * @param callback - * Original function that was passed into the subscribe event, - * that is to be unregistered. - * @throws This function can throw errors. + * 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. + * */ - unsubscribe(callback: (arg: EntitySpawnEvent) => void): void; + value: number; + static readonly componentId = 'minecraft:ground_offset'; } + /** - * @beta - * Defines the entity's strength to carry items. + * Defines the interactions with this entity for healing it. */ -export class EntityStrengthComponent extends IEntityComponent { - protected constructor(); - /** - * Maximum strength of this entity, as defined in the entity - * type definition. - * @throws This property can throw when used. - */ - readonly max: number; +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityHealableComponent extends EntityComponent { + private constructor(); /** - * Identifier of this component. Should always be - * minecraft:strength. - */ - readonly typeId: string; - /** - * Current strength value of this entity, after any effects or - * component updates are applied. + * @remarks + * Determines if an item can be used regardless of the entity + * being at full health. + * * @throws This property can throw when used. */ - readonly value: number; + readonly forceUse: boolean; + static readonly componentId = 'minecraft:healable'; /** - * Identifier of this component. Should always be - * minecraft:strength. + * @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. */ - static readonly componentId = 'minecraft:strength'; + getFeedItems(): FeedItem[]; } + /** - * @beta - * Defines the rules for a mob to be tamed by the player. + * 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 EntityTameableComponent extends IEntityComponent { - protected constructor(); - /** - * 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; +export class EntityHealthChangedAfterEvent { + private constructor(); /** - * Event to run when this entity becomes tamed. - * @throws This property can throw when used. - */ - readonly tameEvent: Trigger; - /** - * Identifier of this component. Should always be - * minecraft:tameable. + * @remarks + * Entity whose health changed. + * */ - readonly typeId: string; + readonly entity: Entity; /** - * Identifier of this component. Should always be - * minecraft:tameable. + * @remarks + * New health value of the entity. + * */ - static readonly componentId = 'minecraft:tameable'; - getTameItems(): string[]; + readonly newValue: number; /** * @remarks - * Tames this entity. - * @returns - * Returns true if the entity was tamed. - * @throws This function can throw errors. + * Old health value of the entity. + * */ - tame(): boolean; + readonly oldValue: number; } + /** - * @beta - * Represents information about a type of entity. + * Manages callbacks that are connected to when the health of + * an entity changes. */ -export class EntityType { - protected constructor(); +export class EntityHealthChangedAfterEventSignal { + private constructor(); /** - * Identifier of this entity type - for example, - * 'minecraft:skeleton'. + * @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. + * */ - readonly id: string; + 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 - * An iterator that loops through available entity types. + * Defines the health properties of an entity. + * @example applyDamageThenHeal.ts + * ```typescript + * // A function that applies damage and then heals the entity + * import { Entity, EntityComponentTypes, system, world } from '@minecraft/server'; + * + * function applyDamageAndHeal(entity: Entity) { + * entity.applyDamage(19); // Many mobs have max damage of 20 so this is a near-death mob + * + * system.runTimeout(() => { + * const health = entity.getComponent(EntityComponentTypes.Health); + * if (health) { + * world.sendMessage(`Entity health before heal: ${health.currentValue}`); + * + * health.resetToMaxValue(); + * + * world.sendMessage(`Entity after before heal: ${health.currentValue}`); + * } else { + * console.warn('Entity does not have health component'); + * } + * }, 40); // Run in a few seconds (40 ticks) + * } + * ``` */ -export class EntityTypeIterator implements Iterable { - protected constructor(); - [Symbol.iterator](): Iterator; - next(): IteratorResult; +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityHealthComponent extends EntityAttributeComponent { + private constructor(); + static readonly componentId = 'minecraft:health'; } + /** - * @beta - * Used for accessing all entity types currently available for - * use within the world. + * Contains information related to an entity hitting a block. */ -// tslint:disable-next-line:no-unnecessary-class -export class EntityTypes { - protected constructor(); +export class EntityHitBlockAfterEvent { + private constructor(); /** * @remarks - * Retrieves an entity type using a string-based identifier. - * @param identifier + * Face of the block that was hit. + * */ - static get(identifier: string): EntityType; + readonly blockFace: Direction; /** * @remarks - * Retrieves an iterator of all entity types within this world. + * Entity that made the attack. + * */ - static getAll(): EntityTypeIterator; -} -/** - * @beta - * Defines the general movement speed underwater of this - * entity. - */ -export class EntityUnderwaterMovementComponent extends IEntityComponent { - protected constructor(); + readonly damagingEntity: Entity; /** - * Read-only. Returns the current value of movement speed - * underwater for the entity. - * @throws This property can throw when used. + * @remarks + * Block that was hit by the attack. + * */ - readonly current: number; + readonly hitBlock: Block; /** - * Identifier of this component. Should always be - * minecraft:underwater_movement. + * @beta + * @remarks + * Block permutation that was hit by the attack. + * */ - readonly typeId: string; + readonly hitBlockPermutation: BlockPermutation; +} + +/** + * Manages callbacks that are connected to when an entity hits + * a block. + */ +export class EntityHitBlockAfterEventSignal { + private constructor(); /** - * Value for movement speed underwater as defined through - * entity components. - * @throws This property can throw when used. + * @remarks + * Adds a callback that will be called when an entity hits a + * block. + * + * This function can't be called in read-only mode. + * */ - readonly value: number; + subscribe( + callback: (arg: EntityHitBlockAfterEvent) => void, + options?: EntityEventOptions, + ): (arg: EntityHitBlockAfterEvent) => void; /** - * Identifier of this component. Should always be - * minecraft:underwater_movement. + * @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. */ - static readonly componentId = 'minecraft:underwater_movement'; + unsubscribe(callback: (arg: EntityHitBlockAfterEvent) => void): void; +} + +/** + * Contains information related to an entity hitting (melee + * attacking) another entity. + */ +export class EntityHitEntityAfterEvent { + private constructor(); /** * @remarks - * Resets the current movement speed underwater for the entity - * to the default value implied by the current component state - * of the entity. - * @throws This function can throw errors. + * Entity that made a hit/melee attack. + * */ - resetToDefaultValue(): void; + readonly damagingEntity: Entity; /** * @remarks - * Resets the movement speed underwater to the maximum value - * for the entity, as determined by the set of components that - * are on the entity. - * @throws This function can throw errors. + * Entity that was hit by the attack. + * */ - resetToMaxValue(): void; + 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 - * Resets the movement speed underwater to the minimum value as - * defined by the component state of this entity. - * @throws This function can throw errors. + * Adds a callback that will be called when an entity hits + * another entity. + * + * This function can't be called in read-only mode. + * */ - resetToMinValue(): void; + subscribe( + callback: (arg: EntityHitEntityAfterEvent) => void, + options?: EntityEventOptions, + ): (arg: EntityHitEntityAfterEvent) => void; /** * @remarks - * Sets the current value of movement speed underwater for the - * entity. - * @param value + * 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. */ - setCurrent(value: number): boolean; + unsubscribe(callback: (arg: EntityHitEntityAfterEvent) => void): void; } + /** - * @beta - * Used to differentiate the component group of a variant of an - * entity from others. (e.g. ocelot, villager). + * Contains information related to an entity getting hurt. */ -export class EntityVariantComponent extends IEntityComponent { - protected constructor(); +export class EntityHurtAfterEvent { + private constructor(); /** - * Identifier of this component. Should always be - * minecraft:variant. + * @remarks + * Describes the amount of damage caused. + * */ - readonly typeId: string; + readonly damage: number; /** - * The identifier of the variant. By convention, 0 is the - * identifier of the base entity. - * @throws This property can throw when used. + * @remarks + * Source information on the entity that may have applied this + * damage. + * */ - readonly value: number; + readonly damageSource: EntityDamageSource; /** - * Identifier of this component. Should always be - * minecraft:variant. + * @remarks + * Entity that was hurt. + * */ - static readonly componentId = 'minecraft:variant'; + readonly hurtEntity: Entity; } + /** - * @beta - * When added, this component signifies that this entity wants - * to become a jockey. + * Manages callbacks that are connected to when an entity is + * hurt. */ -export class EntityWantsJockeyComponent extends IEntityComponent { - protected constructor(); +export class EntityHurtAfterEventSignal { + private constructor(); /** - * Identifier of this component. Should always be - * minecraft:wants_jockey. + * @remarks + * Adds a callback that will be called when an entity is hurt. + * + * This function can't be called in read-only mode. + * */ - readonly typeId: string; + subscribe( + callback: (arg: EntityHurtAfterEvent) => void, + options?: EntityEventOptions, + ): (arg: EntityHurtAfterEvent) => void; /** - * Identifier of this component. Should always be - * minecraft:wants_jockey. + * @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. */ - static readonly componentId = 'minecraft:wants_jockey'; + unsubscribe(callback: (arg: EntityHurtAfterEvent) => void): void; } + /** - * @beta - * Contains a set of events that are available across the scope - * of the World. + * Defines this entity's inventory properties. */ -export class Events { - protected constructor(); +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityInventoryComponent extends EntityComponent { + private constructor(); /** - * This event fires before a chat message is broadcast or - * delivered. The event can be canceled, and the message can - * also be updated. + * @remarks + * Number of slots that this entity can gain per extra + * strength. + * + * @throws This property can throw when used. */ - readonly beforeChat: BeforeChatEventSignal; + readonly additionalSlotsPerStrength: number; /** - * This event is fired before the triggering of an entity event - * that updates the component definition state of an entity. - * Within this event, you can cancel or shape the impacted - * components and event triggers. + * @remarks + * If true, the contents of this inventory can be removed by a + * hopper. + * + * @throws This property can throw when used. */ - readonly beforeDataDrivenEntityTriggerEvent: BeforeDataDrivenEntityTriggerEventSignal; + readonly canBeSiphonedFrom: boolean; /** - * This event is fired before an explosion occurs. + * @remarks + * Defines the container for this entity. The container will be + * undefined if the entity has been removed. + * + * @throws This property can throw when used. */ - readonly beforeExplosion: BeforeExplosionEventSignal; + readonly container?: Container; /** - * For custom items, this event is triggered before the set of - * defined components for the item change in response to a - * triggered event. Note that this event is only fired for - * custom data-driven items. + * @remarks + * Type of container this entity has. + * + * @throws This property can throw when used. */ - readonly beforeItemDefinitionEvent: BeforeItemDefinitionEventSignal; + readonly containerType: string; /** - * This event fires before an item is used by an entity or - * player. + * @remarks + * Number of slots the container has. + * + * @throws This property can throw when used. */ - readonly beforeItemUse: BeforeItemUseEventSignal; + readonly inventorySize: number; /** - * This event fires before an item is used on a block by an - * entity or player. + * @remarks + * If true, the entity will not drop it's inventory on death. + * + * @throws This property can throw when used. */ - readonly beforeItemUseOn: BeforeItemUseOnEventSignal; + readonly 'private': boolean; /** - * Fires before a piston is activated. - */ - readonly beforePistonActivate: BeforePistonActivateEventSignal; - /** - * This event fires for a block that is broken by a player. - */ - readonly blockBreak: BlockBreakEventSignal; - /** - * This event fires for each BlockLocation destroyed by an - * explosion. It is fired after the blocks have already been - * destroyed. - */ - readonly blockExplode: BlockExplodeEventSignal; - /** - * This event fires for a block that is placed by a player. - */ - readonly blockPlace: BlockPlaceEventSignal; - /** - * This event fires when a button is pushed. - */ - readonly buttonPush: ButtonPushEventSignal; - /** - * This event is triggered after a chat message has been - * broadcast or sent to players. - */ - readonly chat: ChatEventSignal; - /** - * This event is fired when an entity event has been triggered - * that will update the component definition state of an - * entity. - */ - readonly dataDrivenEntityTriggerEvent: DataDrivenEntityTriggerEventSignal; - /** - * This event fires when an effect, like poisoning, is added to - * an entity. - */ - readonly effectAdd: EffectAddEventSignal; - readonly entityDie: EntityDieEventSignal; - /** - * This event fires when an entity hits (makes a melee attack) - * and potentially impacts another entity or block. - */ - readonly entityHit: EntityHitEventSignal; - /** - * This event fires when an entity is hurt (takes damage). - */ - readonly entityHurt: EntityHurtEventSignal; - /** - * This event fires when an entity is spawned. - */ - readonly entitySpawn: EntitySpawnEventSignal; - /** - * This event is fired after an explosion occurs. - */ - readonly explosion: ExplosionEventSignal; - /** - * This event fires when a chargeable item completes charging. - */ - readonly itemCompleteCharge: ItemCompleteChargeEventSignal; - /** - * 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: ItemDefinitionEventSignal; - /** - * This event fires when a chargeable item is released from - * charging. - */ - readonly itemReleaseCharge: ItemReleaseChargeEventSignal; - /** - * This event fires when a chargeable item starts charging. - */ - readonly itemStartCharge: ItemStartChargeEventSignal; - /** - * This event fires when any particular item is starting to be - * used by an entity or player. - */ - readonly itemStartUseOn: ItemStartUseOnEventSignal; - /** - * This event fires when a chargeable item stops charging. - */ - readonly itemStopCharge: ItemStopChargeEventSignal; - /** - * This event fires when any particular item is ending being - * used by an entity or player. - */ - readonly itemStopUseOn: ItemStopUseOnEventSignal; - /** - * This event fires when any particular item is used by an - * entity or player. - */ - readonly itemUse: ItemUseEventSignal; - /** - * This event fires when any particular item is used on a block - * by an entity or player. - */ - readonly itemUseOn: ItemUseOnEventSignal; - /** - * This event fires when a lever activates or is deactivated. - */ - readonly leverActivate: LeverActionEventSignal; - /** - * This event is an internal implementation detail, and is - * otherwise not currently functional. - */ - readonly messageReceive: ServerMessageSignal; - /** - * This event fires when a piston expands or retracts. - */ - readonly pistonActivate: PistonActivateEventSignal; - /** - * 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: PlayerJoinEventSignal; - /** - * This event fires when a player leaves a world. - */ - readonly playerLeave: PlayerLeaveEventSignal; - /** - * 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: PlayerSpawnEventSignal; - /** - * This event fires when a projectile hits an entity or block. - */ - readonly projectileHit: ProjectileHitEventSignal; - /** - * This event will be triggered when the weather changes within - * Minecraft. - */ - readonly weatherChange: WeatherChangeEventSignal; - /** - * 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. + * @remarks + * If true, the entity's inventory can only be accessed by its + * owner or itself. + * + * @throws This property can throw when used. */ - readonly worldInitialize: WorldInitializeEventSignal; + readonly restrictToOwner: boolean; + static readonly componentId = 'minecraft:inventory'; } + /** - * @beta - * Contains information regarding an explosion that has - * happened. + * When added, this component signifies that this entity is a + * baby. */ -export class ExplosionEvent { - protected constructor(); - /** - * Dimension where the explosion has occurred. - */ - readonly dimension: Dimension; - /** - * Optional source of the explosion. - */ - readonly source: Entity; - getImpactedBlocks(): Vector3[]; +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityIsBabyComponent extends EntityComponent { + private constructor(); + static readonly componentId = 'minecraft:is_baby'; } + /** - * @beta - * Manages callbacks that are connected to when an explosion - * occurs. + * When added, this component signifies that this entity is + * charged. */ -export class ExplosionEventSignal { - protected constructor(); - /** - * @remarks - * Adds a callback that will be called when an explosion - * occurs. - * @param callback - */ - subscribe(callback: (arg: ExplosionEvent) => void): (arg: ExplosionEvent) => void; - /** - * @remarks - * Removes a callback from being called when an explosion - * occurs. - * @param callback - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ExplosionEvent) => void): void; +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityIsChargedComponent extends EntityComponent { + private constructor(); + static readonly componentId = 'minecraft:is_charged'; } + /** - * @beta - * As part of the Healable component, represents a specific - * item that can be fed to an entity to cause health effects. + * When added, this component signifies that this entity is + * currently carrying a chest. */ -export class FeedItem { - protected constructor(); - /** - * 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; - /** - * 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; - getEffects(): FeedItemEffect[]; +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityIsChestedComponent extends EntityComponent { + private constructor(); + static readonly componentId = 'minecraft:is_chested'; } + /** - * @beta - * Represents an effect that is applied as a result of a food - * item being fed to an entity. + * When added, this component signifies that dyes can be used + * on this entity to change its color. */ -export class FeedItemEffect { - protected constructor(); - /** - * 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; - /** - * 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; - /** - * Gets the duration, in ticks, of this effect. - */ - readonly duration: number; - /** - * Gets the identifier of the effect to apply. Example values - * include 'fire_resistance' or 'regeneration'. - */ - readonly name: string; +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityIsDyeableComponent extends EntityComponent { + private constructor(); + static readonly componentId = 'minecraft:is_dyeable'; } + /** - * @beta - * Represents a set of filters for when an event should occur. + * When added, this component signifies that this entity can + * hide from hostile mobs while invisible. */ -// tslint:disable-next-line:no-unnecessary-class -export class FilterGroup { - protected constructor(); +// @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 - * Represents constants related to fluid containers. + * When added, this component signifies that this entity this + * currently on fire. */ -// tslint:disable-next-line:no-unnecessary-class -export class FluidContainer { - protected constructor(); - /** - * Constant that represents the maximum fill level of a fluid - * container. - */ - static readonly maxFillLevel = 6; - /** - * Constant that represents the minimum fill level of a fluid - * container. - */ - static readonly minFillLevel = 0; +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityIsIgnitedComponent extends EntityComponent { + private constructor(); + static readonly componentId = 'minecraft:is_ignited'; } + /** - * @beta - * Base interface that defines components associated with an - * entity. + * When added, this component signifies that this entity is an + * illager captain. */ -export class IEntityComponent { - protected constructor(); - /** - * Identifier of the type of entity component. - */ - readonly typeId: string; +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityIsIllagerCaptainComponent extends EntityComponent { + private constructor(); + static readonly componentId = 'minecraft:is_illager_captain'; } -export class InventoryComponentContainer extends Container { - protected constructor(); - readonly emptySlotsCount: number; - readonly size: number; - addItem(itemStack: ItemStack): void; - clearAll(): void; - clearItem(slot: number): void; - getItem(slot: number): ItemStack; - getSlot(slot: number): ContainerSlot; - setItem(slot: number, itemStack?: ItemStack): void; - swapItems(slot: number, otherSlot: number, otherContainer: Container): boolean; - transferItem(fromSlot: number, toSlot: number, toContainer: Container): boolean; + +/** + * 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 - * Contains information related to a chargeable item completing - * being charged. + * When added, this component signifies that this entity is + * currently shaking. */ -export class ItemCompleteChargeEvent { - protected constructor(); - /** - * Returns the item stack that has completed charging. - */ - readonly itemStack: ItemStack; - /** - * Returns the source entity that triggered this item event. - */ - readonly source: Entity; - /** - * Returns the time, in ticks, for the remaining duration left - * before the charge completes its cycle. - */ - readonly useDuration: number; +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityIsShakingComponent extends EntityComponent { + private constructor(); + static readonly componentId = 'minecraft:is_shaking'; } + /** - * @beta - * Manages callbacks that are connected to the completion of - * charging for a chargeable item. + * When added, this component signifies that this entity is + * currently sheared. */ -export class ItemCompleteChargeEventSignal { - protected constructor(); - /** - * @remarks - * Adds a callback that will be called when a chargeable item - * completes charging. - * @param callback - */ - subscribe(callback: (arg: ItemCompleteChargeEvent) => void): (arg: ItemCompleteChargeEvent) => void; - /** - * @remarks - * Removes a callback from being called when a chargeable item - * completes charging. - * @param callback - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemCompleteChargeEvent) => void): void; +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityIsShearedComponent extends EntityComponent { + private constructor(); + static readonly componentId = 'minecraft:is_sheared'; } + /** - * @beta - * When present on an item, this item has a cooldown effect - * when used by entities. + * When added, this component signifies that this entity can be + * stacked. */ -export class ItemCooldownComponent { - protected constructor(); - /** - * Represents the cooldown category that this item is - * associated with. - * @throws This property can throw when used. - */ - readonly cooldownCategory: string; - /** - * Amount of time, in ticks, that remain for this item - * cooldown. - * @throws This property can throw when used. - */ - readonly cooldownTicks: number; - /** - * Identifier of this component. Should always be - * 'minecraft:cooldown'. - */ - static readonly componentId = 'minecraft:cooldown'; - /** - * @remarks - * Starts a new cooldown period for this item. - * @param player - * @throws This function can throw errors. - */ - startCooldown(player: Player): void; +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityIsStackableComponent extends EntityComponent { + private constructor(); + static readonly componentId = 'minecraft:is_stackable'; } + /** - * @beta - * Manages callbacks that are connected to an item's definition - * and components changing. + * When added, this component signifies that this entity is + * currently stunned. */ -export class ItemDefinitionEventSignal { - protected constructor(); - /** - * @remarks - * Adds a callback that will be called when an item's - * definition and components change. - * @param callback - */ - subscribe(callback: (arg: ItemDefinitionTriggeredEvent) => void): (arg: ItemDefinitionTriggeredEvent) => void; - /** - * @remarks - * Removes a callback from being called when an item's - * definition and components change. - * @param callback - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemDefinitionTriggeredEvent) => void): void; +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityIsStunnedComponent extends EntityComponent { + private constructor(); + static readonly componentId = 'minecraft:is_stunned'; } + /** - * @beta - * Contains information related to a custom item having a data - * definition change being triggered. + * When added, this component signifies that this entity is + * currently tamed. */ -export class ItemDefinitionTriggeredEvent { - protected constructor(); - /** - * Name of the data-driven item event that is triggering this - * change. - */ - readonly eventName: string; - /** - * The impacted item stack that is being used. - */ - item: ItemStack; - /** - * Returns the source entity that triggered this item event. - */ - readonly source: Entity; +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityIsTamedComponent extends EntityComponent { + private constructor(); + static readonly componentId = 'minecraft:is_tamed'; } + /** - * @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. + * 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. + * @example checkFeatherNearby.ts + * ```typescript + * import { DimensionLocation, EntityComponentTypes } from "@minecraft/server"; + * + * // Returns true if a feather item entity is within 'distance' blocks of 'location'. + * function isFeatherNear(location: DimensionLocation, distance: number): boolean { + * const items = location.dimension.getEntities({ + * location: location, + * maxDistance: 20, + * }); + * + * for (const item of items) { + * const itemComp = item.getComponent(EntityComponentTypes.Item); + * + * if (itemComp) { + * if (itemComp.itemStack.typeId.endsWith('feather')) { + * return true; + * } + * } + * } + * + * return false; + * } + * ``` */ -export class ItemDurabilityComponent { - protected constructor(); - /** - * Returns the current damage level of this particular item. - */ - damage: number; - /** - * Represents the amount of damage that this item can take - * before breaking. - * @throws This property can throw when used. - */ - readonly maxDurability: number; - /** - * Identifier of this component. Should always be - * 'minecraft:durability'. - */ - static readonly componentId = 'minecraft:durability'; +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityItemComponent extends EntityComponent { + private constructor(); /** * @remarks - * Returns the maximum chance that this item would be damaged - * using the damageRange property, given an unbreaking level. - * @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. + * Item stack represented by this entity in the world. + * + * @throws This property can throw when used. */ - getDamageChance(unbreaking?: number): number; - getDamageRange(): NumberRange; + readonly itemStack: ItemStack; + static readonly componentId = 'minecraft:item'; } + /** * @beta - * When present on an item, this item has applied enchantment - * effects. Note that this component only applies to - * data-driven items. + * 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 ItemEnchantsComponent { - protected constructor(); - /** - * Returns a collection of the enchantments applied to this - * item stack. - */ - enchantments: EnchantmentList; +export class EntityIterator implements Iterable { + private constructor(); /** - * Identifier of this component. + * @remarks + * This function can't be called in read-only mode. + * */ - static readonly componentId = 'minecraft:enchantments'; + [Symbol.iterator](): Iterator; /** * @remarks - * Removes all enchantments applied to this item stack. - * @throws This function can throw errors. + * 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. + * */ - removeAllEnchantments(): void; + next(): IteratorResult; } + /** * @beta - * When present on an item, this item is consumable by - * entities. Note that this component only applies to - * data-driven items. + * Defines the base movement speed in lava of this entity. */ -export class ItemFoodComponent { - protected constructor(); - /** - * If true, the player can always eat this item (even when not - * hungry). - * @throws This property can throw when used. - */ - readonly canAlwaysEat: boolean; - /** - * Represents how much nutrition this food item will give an - * entity when eaten. - * @throws This property can throw when used. - */ - readonly nutrition: number; +// @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(); /** - * When an item is eaten, this value is used according to this - * formula (nutrition * saturation_modifier * 2) to apply a - * saturation buff. + * @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 saturationModifier: number; + readonly softDistance: number; + static readonly componentId = 'minecraft:leashable'; /** - * When specified, converts the active item to the one - * specified by this property. - * @throws This property can throw when used. + * @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. */ - readonly usingConvertsTo: string; + leash(leashHolder: Entity): void; /** - * Identifier of this component. Should always be - * 'minecraft:food'. + * @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. */ - static readonly componentId = 'minecraft:food'; + unleash(): void; } + /** - * @beta - * Contains information related to a chargeable item when the - * player has finished using the item and released the build - * action. + * 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 ItemReleaseChargeEvent { - protected constructor(); - /** - * Returns the item stack that triggered this item event. - */ - readonly itemStack: ItemStack; - /** - * Returns the source entity that triggered this item event. - */ - readonly source: Entity; +export class EntityLoadAfterEvent { + private constructor(); /** - * Returns the time, in ticks, for the remaining duration left - * before the charge completes its cycle. + * @remarks + * Entity that was loaded. + * + * This property can't be edited in read-only mode. + * */ - readonly useDuration: number; + entity: Entity; } + /** - * @beta - * Manages callbacks that are connected to the releasing of - * charging for a chargeable item. + * Registers a script-based event handler for handling what + * happens when an entity loads. */ -export class ItemReleaseChargeEventSignal { - protected constructor(); +export class EntityLoadAfterEventSignal { + private constructor(); /** * @remarks - * Adds a callback that will be called when a chargeable item - * is released from charging. + * 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: ItemReleaseChargeEvent) => void): (arg: ItemReleaseChargeEvent) => void; + subscribe(callback: (arg: EntityLoadAfterEvent) => void): (arg: EntityLoadAfterEvent) => void; /** * @remarks - * Removes a callback from being called when a chargeable item - * is released from charging. + * 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: ItemReleaseChargeEvent) => void): void; + unsubscribe(callback: (arg: EntityLoadAfterEvent) => void): void; } + /** - * @beta - * Represents a collection of all of the available item types - * in Minecraft. + * Additional variant value. Can be used to further + * differentiate variants. */ -// tslint:disable-next-line:no-unnecessary-class -export class Items { - protected constructor(); +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityMarkVariantComponent extends EntityComponent { + private constructor(); /** * @remarks - * Returns an item type given an item type identifier. - * @param itemId - * Type of the item to return. + * Value of the mark variant value for this entity. + * + * This property can't be edited in read-only mode. + * */ - static get(itemId: string): ItemType; + 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'; +} + /** * @beta - * Defines a collection of items. + * Defines the general movement speed of this entity. */ -export class ItemStack { - /** - * 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. - * @throws - * Throws if the value is outside the range of 1-255. - */ - amount: number; - /** - * 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; - /** - * Gets or sets whether the item is kept on death. - */ - keepOnDeath: boolean; - /** - * Gets or sets the item's lock mode. The default value is - * `ItemLockMode.none`. - */ - lockMode: ItemLockMode; - /** - * 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; - /** - * 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. - * @throws - * Throws if the length exceeds 255 characters. - */ - nameTag?: string; - /** - * The type of the item. - */ - readonly 'type': ItemType; - /** - * 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 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 - * Creates an exact copy of the item stack, including any - * custom data or properties. - */ - clone(): ItemStack; - /** - * @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, 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): any; - /** - * @remarks - * Returns all components that are both present on this item - * stack and supported by the API. - */ - getComponents(): any[]; - /** - * @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. - */ - 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 - */ - isStackableWith(itemStack: ItemStack): 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. - * @param blockIdentifiers - * @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; - /** - * @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. - * @param blockIdentifiers - * @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; - /** - * @remarks - * Sets the lore value - a secondary display string - for an - * ItemStack. - * @param loreList - * @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; - /** - * @remarks - * Triggers an item type event. For custom items, a number of - * events are defined in an items' definition for key item - * behaviors. - * @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 ItemStartChargeEvent { - protected constructor(); - /** - * The impacted item stack that is starting to be charged. - */ - readonly itemStack: ItemStack; - /** - * Returns the source entity that triggered this item event. - */ - readonly source: Entity; - /** - * 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 ItemStartChargeEventSignal { - protected constructor(); - /** - * @remarks - * Adds a callback that will be called when a chargeable item - * starts charging. - * @param callback - */ - subscribe(callback: (arg: ItemStartChargeEvent) => void): (arg: ItemStartChargeEvent) => void; - /** - * @remarks - * Removes a callback from being called when a chargeable item - * starts charging. - * @param callback - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemStartChargeEvent) => void): void; -} -/** - * @beta - * Contains information related to an item being used on a - * block. - */ -export class ItemStartUseOnEvent { - protected constructor(); - /** - * The face of the block that an item is being used on. - */ - readonly blockFace: Direction; - /** - * The impacted item stack that is starting to be used. - */ - item: ItemStack; - /** - * Returns the source entity that triggered this item event. - */ - readonly source: Entity; - getBlockLocation(): Vector3; - getBuildBlockLocation(): Vector3; -} -/** - * @beta - * Manages callbacks that are connected to an item starting - * being used on a block event. - */ -export class ItemStartUseOnEventSignal { - protected constructor(); - /** - * @remarks - * Adds a callback that will be called when an item is used on - * a block. - * @param callback - */ - subscribe(callback: (arg: ItemStartUseOnEvent) => void): (arg: ItemStartUseOnEvent) => void; - /** - * @remarks - * Removes a callback from being called when an item is used on - * a block. - * @param callback - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemStartUseOnEvent) => void): void; +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityMovementComponent extends EntityAttributeComponent { + private constructor(); + static readonly componentId = 'minecraft:movement'; } + /** - * @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. + * When added, this move control causes the mob to fly. */ -export class ItemStopChargeEvent { - protected constructor(); - /** - * The impacted item stack that is stopping being charged. - */ - readonly itemStack: ItemStack; - /** - * Returns the source entity that triggered this item event. - */ - readonly source: Entity; - /** - * Returns the time, in ticks, for the remaining duration left - * before the charge completes its cycle. - */ - readonly useDuration: number; +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityMovementFlyComponent extends EntityBaseMovementComponent { + private constructor(); + static readonly componentId = 'minecraft:movement.fly'; } + /** - * @beta - * Manages callbacks that are connected to the stopping of - * charging for an item that has a registered - * minecraft:chargeable component. + * When added, this move control allows a mob to fly, swim, + * climb, etc. */ -export class ItemStopChargeEventSignal { - protected constructor(); - /** - * @remarks - * Adds a callback that will be called when a chargeable item - * stops charging. - * @param callback - */ - subscribe(callback: (arg: ItemStopChargeEvent) => void): (arg: ItemStopChargeEvent) => void; - /** - * @remarks - * Removes a callback from being called when a chargeable item - * stops charging. - * @param callback - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemStopChargeEvent) => void): void; -} -/** - * @beta - * Contains information related to an item that has stopped - * being used on a block. - */ -export class ItemStopUseOnEvent { - protected constructor(); - /** - * The impacted item stack that is being used on a block. - */ - item: ItemStack; - /** - * Returns the source entity that triggered this item event. - */ - readonly source: Entity; - getBlockLocation(): Vector3; -} -/** - * @beta - * Manages callbacks that are connected to an item stops used - * on a block event. - */ -export class ItemStopUseOnEventSignal { - protected constructor(); - /** - * @remarks - * Adds a callback that will be called when an item stops being - * used on a block. - * @param callback - */ - subscribe(callback: (arg: ItemStopUseOnEvent) => void): (arg: ItemStopUseOnEvent) => void; - /** - * @remarks - * Removes a callback from being called when an item is used on - * a block. - * @param callback - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemStopUseOnEvent) => void): void; -} -/** - * @beta - * Represents the type of an item - for example, Wool. - */ -export class ItemType { - protected constructor(); - /** - * Returns the identifier of the item type - for example, - * 'minecraft:apple'. - */ - readonly id: string; -} -/** - * @beta - * An iterator over a set of available item types. - */ -export class ItemTypeIterator implements Iterable { - protected constructor(); - [Symbol.iterator](): Iterator; - next(): IteratorResult; -} -/** - * @beta - * Returns the set of item types registered within Minecraft. - */ -// tslint:disable-next-line:no-unnecessary-class -export class ItemTypes { - protected constructor(); - /** - * @remarks - * Returns a specific item type, if available within Minecraft. - * @param itemId - */ - static get(itemId: string): ItemType; - /** - * @remarks - * Retrieves all available item types registered within - * Minecraft. - */ - static getAll(): ItemTypeIterator; -} -/** - * @beta - * Contains information related to an item being used. - */ -export class ItemUseEvent { - protected constructor(); - /** - * The impacted item stack that is being used. - */ - item: ItemStack; - /** - * Returns the source entity that triggered this item event. - */ - readonly source: Entity; -} -/** - * @beta - * Manages callbacks that are connected to an item use event. - */ -export class ItemUseEventSignal { - protected constructor(); - /** - * @remarks - * Adds a callback that will be called when an item is used. - * @param callback - */ - subscribe(callback: (arg: ItemUseEvent) => void): (arg: ItemUseEvent) => void; - /** - * @remarks - * Removes a callback from being called when an item is used. - * @param callback - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemUseEvent) => void): void; -} -/** - * @beta - * Contains information related to an item being used on a - * block. - */ -export class ItemUseOnEvent { - protected constructor(); - /** - * The face of the block that an item is being used on. - */ - readonly blockFace: Direction; - /** - * X coordinate of the item-use impact location on the face of - * the target block. - */ - readonly faceLocationX: number; - /** - * Y coordinate of the item-use impact location on the face of - * the target block. - */ - readonly faceLocationY: number; - /** - * The impacted item stack that is being used on a block. - */ - item: ItemStack; - /** - * Returns the source entity that triggered this item event. - */ - readonly source: Entity; - getBlockLocation(): Vector3; -} -/** - * @beta - * Manages callbacks that are connected to an item being used - * on a block event. - */ -export class ItemUseOnEventSignal { - protected constructor(); - /** - * @remarks - * Adds a callback that will be called when an item is used on - * a block. - * @param callback - */ - subscribe(callback: (arg: ItemUseOnEvent) => void): (arg: ItemUseOnEvent) => void; - /** - * @remarks - * Removes a callback from being called when an item is used on - * a block. - * @param callback - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: ItemUseOnEvent) => void): void; -} -/** - * @beta - * Contains information related to changes to a lever - * activating or deactivating. - */ -export class LeverActionEvent extends BlockEvent { - protected constructor(); - /** - * Block impacted by this event. - */ - readonly block: Block; - /** - * Dimension that contains the block that is the subject of - * this event. - */ - readonly dimension: Dimension; - /** - * True if the lever is activated (that is, transmitting - * power). - */ - readonly isPowered: boolean; - /** - * Optional player that triggered the lever activation. - */ - readonly player: Player; -} -/** - * @beta - * Manages callbacks that are connected to lever moves - * (activates or deactivates). - */ -export class LeverActionEventSignal { - protected constructor(); - /** - * @remarks - * Adds a callback that will be called when a lever is moved - * (activates or deactivates). - * @param callback - */ - subscribe(callback: (arg: LeverActionEvent) => void): (arg: LeverActionEvent) => void; - /** - * @remarks - * Removes a callback from being called when a lever is moved - * (activates or deactivates). - * @param callback - * @throws This function can throw errors. - */ - unsubscribe(callback: (arg: LeverActionEvent) => void): void; -} -/** - * @beta - * A specific currently-internal event used for passing - * messages from client to server. - */ -export class MessageReceiveEvent { - protected constructor(); - readonly id: string; - readonly message: string; - readonly player: Player; - readonly sourceType: MessageSourceType; -} -/** - * @beta - * Contains definitions of standard Minecraft and Minecraft - * Education Edition block types. - */ -// tslint:disable-next-line:no-unnecessary-class -export class MinecraftBlockTypes { - protected constructor(); - /** - * Represents an acacia button within Minecraft. - */ - static readonly acaciaButton: BlockType; - /** - * Represents an acacia door within Minecraft. - */ - static readonly acaciaDoor: BlockType; - /** - * Represents an acacia fence gate within Minecraft. - */ - static readonly acaciaFenceGate: BlockType; - static readonly acaciaHangingSign: BlockType; - /** - * Represents an acacia pressure plate within Minecraft. - */ - static readonly acaciaPressurePlate: BlockType; - /** - * Represents a set of acacia stairs within Minecraft. - */ - static readonly acaciaStairs: BlockType; - /** - * Represents an acacia standing sign within Minecraft. - */ - static readonly acaciaStandingSign: BlockType; - /** - * Represents an acacia trapdoor within Minecraft. - */ - static readonly acaciaTrapdoor: BlockType; - /** - * Represents an acacia wall sign within Minecraft. - */ - static readonly acaciaWallSign: BlockType; - /** - * Represents an activator rail within Minecraft. - */ - static readonly activatorRail: BlockType; - /** - * Represents an empty space (air) within Minecraft. - */ - static readonly air: BlockType; - /** - * Represents an allow block within Minecraft. - */ - static readonly allow: BlockType; - /** - * Represents an amethyst block within Minecraft. - */ - static readonly amethystBlock: BlockType; - /** - * Represents a cluster of amethyst within Minecraft. - */ - static readonly amethystCluster: BlockType; - /** - * Represents ancient debris within Minecraft. - */ - static readonly ancientDebris: BlockType; - /** - * Represents andesite stairs within Minecraft. - */ - static readonly andesiteStairs: BlockType; - /** - * Represents an anvil within Minecraft. - */ - static readonly anvil: BlockType; - /** - * Represents an azalea flowering plant within Minecraft. - */ - static readonly azalea: BlockType; - /** - * Represents azalea leaves within Minecraft. - */ - static readonly azaleaLeaves: BlockType; - /** - * Represents flowered azalea leaves within Minecraft. - */ - static readonly azaleaLeavesFlowered: BlockType; - /** - * Represents a bamboo tree within Minecraft. - */ - static readonly bamboo: BlockType; - static readonly bambooBlock: BlockType; - static readonly bambooButton: BlockType; - static readonly bambooDoor: BlockType; - static readonly bambooDoubleSlab: BlockType; - static readonly bambooFence: BlockType; - static readonly bambooFenceGate: BlockType; - static readonly bambooHangingSign: BlockType; - static readonly bambooMosaic: BlockType; - static readonly bambooMosaicDoubleSlab: BlockType; - static readonly bambooMosaicSlab: BlockType; - static readonly bambooMosaicStairs: BlockType; - static readonly bambooPlanks: BlockType; - static readonly bambooPressurePlate: BlockType; - /** - * Represents a bamboo sapling within Minecraft. - */ - static readonly bambooSapling: BlockType; - static readonly bambooSlab: BlockType; - static readonly bambooStairs: BlockType; - static readonly bambooStandingSign: BlockType; - static readonly bambooTrapdoor: BlockType; - static readonly bambooWallSign: BlockType; - /** - * Represents a barrel within Minecraft. - */ - static readonly barrel: BlockType; - /** - * Represents an invisible but logical barrier within - * Minecraft. - */ - static readonly barrier: BlockType; - /** - * Represents a basalt block within Minecraft. - */ - static readonly basalt: BlockType; - /** - * Represents a beacon within Minecraft. - */ - static readonly beacon: BlockType; - /** - * Represents a bed within Minecraft. - */ - static readonly bed: BlockType; - /** - * Represents a bedrock block within Minecraft. - */ - static readonly bedrock: BlockType; - /** - * Represents a beehive within Minecraft. - */ - static readonly beehive: BlockType; - /** - * Represents a bee nest within Minecraft. - */ - static readonly beeNest: BlockType; - /** - * Represents a beetroot vegetable within Minecraft. - */ - static readonly beetroot: BlockType; - /** - * Represents a bell within Minecraft. - */ - static readonly bell: BlockType; - /** - * Represents a big dripleaf plant within Minecraft. - */ - static readonly bigDripleaf: BlockType; - /** - * Represents a birch button within Minecraft. - */ - static readonly birchButton: BlockType; - /** - * Represents a birch door within Minecraft. - */ - static readonly birchDoor: BlockType; - /** - * Represents a birch fence gate within Minecraft. - */ - static readonly birchFenceGate: BlockType; - static readonly birchHangingSign: BlockType; - /** - * Represents a birch pressure plate within Minecraft. - */ - static readonly birchPressurePlate: BlockType; - /** - * Represents a birch stairs block within Minecraft. - */ - static readonly birchStairs: BlockType; - /** - * Represents a birch standing sign within Minecraft. - */ - static readonly birchStandingSign: BlockType; - /** - * Represents a birch trapdoor within Minecraft. - */ - static readonly birchTrapdoor: BlockType; - /** - * Represents a birch wall sign within Minecraft. - */ - static readonly birchWallSign: BlockType; - /** - * Represents a black candle within Minecraft. - */ - static readonly blackCandle: BlockType; - /** - * Represents a black candle cake within Minecraft. - */ - static readonly blackCandleCake: BlockType; - /** - * Represents a black glazed terracotta block within Minecraft. - */ - static readonly blackGlazedTerracotta: BlockType; - /** - * Represents a blackstone block within Minecraft. - */ - static readonly blackstone: BlockType; - /** - * Represents a blackstone double slab within Minecraft. - */ - static readonly blackstoneDoubleSlab: BlockType; - /** - * Represents a blackstone slab within Minecraft. - */ - static readonly blackstoneSlab: BlockType; - /** - * Represents blackstone stairs within Minecraft. - */ - static readonly blackstoneStairs: BlockType; - /** - * Represents a blackstone wall within Minecraft. - */ - static readonly blackstoneWall: BlockType; - static readonly blackWool: BlockType; - /** - * Represents a blast furnace within Minecraft. - */ - static readonly blastFurnace: BlockType; - /** - * Represents a blue candle within Minecraft. - */ - static readonly blueCandle: BlockType; - /** - * Represents a blue candle cake within Minecraft. - */ - static readonly blueCandleCake: BlockType; - /** - * Represents a blue glazed terracotta block within Minecraft. - */ - static readonly blueGlazedTerracotta: BlockType; - /** - * Represents a blue ice block within Minecraft. - */ - static readonly blueIce: BlockType; - static readonly blueWool: BlockType; - /** - * Represents a bone block within Minecraft. - */ - static readonly boneBlock: BlockType; - /** - * Represents an unbreakable border block within Minecraft. - */ - static readonly bookshelf: BlockType; - /** - * Represents a border block within Minecraft. - */ - static readonly borderBlock: BlockType; - /** - * Represents a brewing stand within Minecraft. - */ - static readonly brewingStand: BlockType; - /** - * Represents a block of brick within Minecraft. - */ - static readonly brickBlock: BlockType; - /** - * Represents brick stairs within Minecraft. - */ - static readonly brickStairs: BlockType; - /** - * Represents a brown candle within Minecraft. - */ - static readonly brownCandle: BlockType; - /** - * Represents a brown candle cake within Minecraft. - */ - static readonly brownCandleCake: BlockType; - /** - * Represents a brown glazed terracotta block within Minecraft. - */ - static readonly brownGlazedTerracotta: BlockType; - /** - * Represents a brown mushroom within Minecraft. - */ - static readonly brownMushroom: BlockType; - /** - * Represents a block of brown mushroom within Minecraft. - */ - static readonly brownMushroomBlock: BlockType; - static readonly brownWool: BlockType; - /** - * Represents a column of bubbles within Minecraft. - */ - static readonly bubbleColumn: BlockType; - /** - * Represents a block of budding amethyst within Minecraft. - */ - static readonly buddingAmethyst: BlockType; - /** - * Represents a cactus within Minecraft. - */ - static readonly cactus: BlockType; - /** - * Represents a cake within Minecraft. - */ - static readonly cake: BlockType; - /** - * Represents a calcite block within Minecraft. - */ - static readonly calcite: BlockType; - /** - * Represents a camera within Minecraft Education Edition. It - * is not available in Minecraft Bedrock Edition. - */ - static readonly camera: BlockType; - /** - * Represents a campfire within Minecraft. - */ - static readonly campfire: BlockType; - /** - * Represents a candle within Minecraft. - */ - static readonly candle: BlockType; - /** - * Represents a cake with candles within Minecraft. - */ - static readonly candleCake: BlockType; - /** - * Represents a carpet within Minecraft. - */ - static readonly carpet: BlockType; - /** - * Represents carrots within Minecraft. - */ - static readonly carrots: BlockType; - /** - * Represents a cartography table block within Minecraft. - */ - static readonly cartographyTable: BlockType; - /** - * Represents a carved pumpkin within Minecraft. - */ - static readonly carvedPumpkin: BlockType; - /** - * Represents a cauldron within Minecraft. - */ - static readonly cauldron: BlockType; - /** - * Represents a set of cave vines within Minecraft. - */ - static readonly caveVines: BlockType; - /** - * Represents the body of a set of cave vines with berries - * within Minecraft. - */ - static readonly caveVinesBodyWithBerries: BlockType; - /** - * Represents the head of a set of cave vines with berries - * within Minecraft. - */ - static readonly caveVinesHeadWithBerries: BlockType; - /** - * Represents a metallic chain within Minecraft. - */ - static readonly chain: BlockType; - /** - * Represents a block that gives off heat but not light, within - * Minecraft Education Edition or Bedrock Edition with - * Education features. - */ - static readonly chainCommandBlock: BlockType; - /** - * Represents a chemical heat block within Minecraft. - */ - static readonly chemicalHeat: BlockType; - /** - * Represents a chemistry table within Minecraft Education - * experiences. - */ - static readonly chemistryTable: BlockType; - /** - * Represents a chest within Minecraft. - */ - static readonly chest: BlockType; - static readonly chiseledBookshelf: BlockType; - /** - * Represents a set of chiseled deepslate within Minecraft. - */ - static readonly chiseledDeepslate: BlockType; - /** - * Represents a block of chiseled nether bricks within - * Minecraft. - */ - static readonly chiseledNetherBricks: BlockType; - /** - * Represents a block of chiseled polished blackstone within - * Minecraft. - */ - static readonly chiseledPolishedBlackstone: BlockType; - /** - * Represents a chorus flower within Minecraft. - */ - static readonly chorusFlower: BlockType; - /** - * Represents a chorus plant within Minecraft. - */ - static readonly chorusPlant: BlockType; - /** - * Represents a block of clay within Minecraft. - */ - static readonly clay: BlockType; - static readonly clientRequestPlaceholderBlock: BlockType; - /** - * Represents a block of solid coal within Minecraft. - */ - static readonly coalBlock: BlockType; - /** - * Represents a block with embedded coal ore within Minecraft. - */ - static readonly coalOre: BlockType; - /** - * Represents a block of cobbled deepslate within Minecraft. - */ - static readonly cobbledDeepslate: BlockType; - /** - * Represents a double slab of cobbled deepslate within - * Minecraft. - */ - static readonly cobbledDeepslateDoubleSlab: BlockType; - /** - * Represents a slab of deepslate within Minecraft. - */ - static readonly cobbledDeepslateSlab: BlockType; - /** - * Represents cobbled deepslate stairs within Minecraft. - */ - static readonly cobbledDeepslateStairs: BlockType; - /** - * Represents a cobbled deepslate wall within Minecraft. - */ - static readonly cobbledDeepslateWall: BlockType; - /** - * Represents a block of cobblestone within Minecraft. - */ - static readonly cobblestone: BlockType; - /** - * Represents a wall of cobblestone within Minecraft. - */ - static readonly cobblestoneWall: BlockType; - /** - * Represents a set of cocoa beans (typically on a tree) within - * Minecraft. - */ - static readonly cocoa: BlockType; - /** - * Represents blue/purple torches within Minecraft. - */ - static readonly coloredTorchBp: BlockType; - /** - * Represents red/green torches within Minecraft. - */ - static readonly coloredTorchRg: BlockType; - /** - * Represents a block that can run commands within Minecraft. - */ - static readonly commandBlock: BlockType; - /** - * Represents a composter block within Minecraft. - */ - static readonly composter: BlockType; - /** - * Represents a block of concrete powder within Minecraft. - */ - static readonly concrete: BlockType; - /** - * Represents a block of concrete powder within Minecraft. - */ - static readonly concretePowder: BlockType; - /** - * Represents a conduit block within Minecraft. - */ - static readonly conduit: BlockType; - /** - * Represents a solid block of copper within Minecraft. - */ - static readonly copperBlock: BlockType; - /** - * Represents a block with embedded copper ore within - * Minecraft. - */ - static readonly copperOre: BlockType; - /** - * Represents coral within Minecraft. - */ - static readonly coral: BlockType; - /** - * Represents a solid block of coral within Minecraft. - */ - static readonly coralBlock: BlockType; - /** - * Represents a fan formation of coral within Minecraft. - */ - static readonly coralFan: BlockType; - /** - * Represents a fan formation of dead coral within Minecraft. - */ - static readonly coralFanDead: BlockType; - /** - * Represents a hanging fan formation of coral within - * Minecraft. - */ - static readonly coralFanHang: BlockType; - /** - * Represents an alternate hanging fan formation of coral (#2) - * within Minecraft. - */ - static readonly coralFanHang2: BlockType; - /** - * Represents an alternate hanging fan formation of coral (#3) - * within Minecraft. - */ - static readonly coralFanHang3: BlockType; - /** - * Represents a block of cracked deepslate bricks within - * Minecraft. - */ - static readonly crackedDeepslateBricks: BlockType; - /** - * Represents tiles of cracked deepslate within Minecraft. - */ - static readonly crackedDeepslateTiles: BlockType; - /** - * Represents a block of cracked nether bricks within - * Minecraft. - */ - static readonly crackedNetherBricks: BlockType; - /** - * Represents a block of cracked and polished blackstone bricks - * within Minecraft. - */ - static readonly crackedPolishedBlackstoneBricks: BlockType; - /** - * Represents a crafting table within Minecraft. - */ - static readonly craftingTable: BlockType; - /** - * Represents a crimson button within Minecraft. - */ - static readonly crimsonButton: BlockType; - /** - * Represents a crimson door within Minecraft. - */ - static readonly crimsonDoor: BlockType; - /** - * Represents a crimson double slab within Minecraft. - */ - static readonly crimsonDoubleSlab: BlockType; - /** - * Represents a crimson fence within Minecraft. - */ - static readonly crimsonFence: BlockType; - /** - * Represents a crimson fence gate within Minecraft. - */ - static readonly crimsonFenceGate: BlockType; - /** - * Represents a crimson fungus within Minecraft. - */ - static readonly crimsonFungus: BlockType; - static readonly crimsonHangingSign: BlockType; - /** - * Represents crimson hyphae within Minecraft. - */ - static readonly crimsonHyphae: BlockType; - /** - * Represents crimson nylium within Minecraft. - */ - static readonly crimsonNylium: BlockType; - /** - * Represents a set of crimson planks within Minecraft. - */ - static readonly crimsonPlanks: BlockType; - /** - * Represents a crimson pressure plate within Minecraft. - */ - static readonly crimsonPressurePlate: BlockType; - /** - * Represents a set of crimson roots within Minecraft. - */ - static readonly crimsonRoots: BlockType; - /** - * Represents a crimson slab within Minecraft. - */ - static readonly crimsonSlab: BlockType; - /** - * Represents a set of crimson stairs within Minecraft. - */ - static readonly crimsonStairs: BlockType; - /** - * Represents a crimson standing sign within Minecraft. - */ - static readonly crimsonStandingSign: BlockType; - /** - * Represents a crimson stem within Minecraft. - */ - static readonly crimsonStem: BlockType; - /** - * Represents a crimson trapdoor within Minecraft. - */ - static readonly crimsonTrapdoor: BlockType; - /** - * Represents a crimson wall sign within Minecraft. - */ - static readonly crimsonWallSign: BlockType; - /** - * Represents crying obsidian within Minecraft. - */ - static readonly cryingObsidian: BlockType; - /** - * Represents a cut copper block within Minecraft. - */ - static readonly cutCopper: BlockType; - /** - * Represents a cut copper slab within Minecraft. - */ - static readonly cutCopperSlab: BlockType; - /** - * Represents a set of cut copper stairs within Minecraft. - */ - static readonly cutCopperStairs: BlockType; - /** - * Represents a cyan-colored candle within Minecraft. - */ - static readonly cyanCandle: BlockType; - /** - * Represents a cake with a cyan-colored candle within - * Minecraft. - */ - static readonly cyanCandleCake: BlockType; - /** - * Represents a block of cyan-colored glazed terracotta within - * Minecraft. - */ - static readonly cyanGlazedTerracotta: BlockType; - static readonly cyanWool: BlockType; - /** - * Represents a dark oak button within Minecraft. - */ - static readonly darkOakButton: BlockType; - /** - * Represents a dark oak door within Minecraft. - */ - static readonly darkOakDoor: BlockType; - /** - * Represents a dark oak fence gate within Minecraft. - */ - static readonly darkOakFenceGate: BlockType; - static readonly darkOakHangingSign: BlockType; - /** - * Represents a dark oak pressure plate within Minecraft. - */ - static readonly darkOakPressurePlate: BlockType; - /** - * Represents a set of dark oak stairs within Minecraft. - */ - static readonly darkOakStairs: BlockType; - /** - * Represents a dark oak standing sign within Minecraft. - */ - static readonly darkoakStandingSign: BlockType; - /** - * Represents a dark oak trapdoor within Minecraft. - */ - static readonly darkOakTrapdoor: BlockType; - /** - * Represents a dark oak wall sign within Minecraft. - */ - static readonly darkoakWallSign: BlockType; - /** - * Represents a set of dark prismarine stairs within Minecraft. - */ - static readonly darkPrismarineStairs: BlockType; - /** - * Represents a daylight detector within Minecraft. - */ - static readonly daylightDetector: BlockType; - /** - * Represents an inverted daylight detector within Minecraft. - */ - static readonly daylightDetectorInverted: BlockType; - /** - * Represents a dead bush within Minecraft. - */ - static readonly deadbush: BlockType; - static readonly decoratedPot: BlockType; - /** - * Represents a block of deepslate within Minecraft. - */ - static readonly deepslate: BlockType; - /** - * Represents a double slab of deepslate brick within - * Minecraft. - */ - static readonly deepslateBrickDoubleSlab: BlockType; - /** - * Represents a block of deepslate bricks within Minecraft. - */ - static readonly deepslateBricks: BlockType; - /** - * Represents a slab of deepslate brick within Minecraft. - */ - static readonly deepslateBrickSlab: BlockType; - /** - * Represents a set of deepslate brick stairs within Minecraft. - */ - static readonly deepslateBrickStairs: BlockType; - /** - * Represents a deepslate brick wall within Minecraft. - */ - static readonly deepslateBrickWall: BlockType; - /** - * Represents a block of deepslate with embedded coal ore - * within Minecraft. - */ - static readonly deepslateCoalOre: BlockType; - /** - * Represents a block of deepslate with embedded copper ore - * within Minecraft. - */ - static readonly deepslateCopperOre: BlockType; - /** - * Represents a block of deepslate with embedded diamond ore - * within Minecraft. - */ - static readonly deepslateDiamondOre: BlockType; - /** - * Represents a block of deepslate with embedded emerald ore - * within Minecraft. - */ - static readonly deepslateEmeraldOre: BlockType; - /** - * Represents a block of deepslate with embedded gold ore - * within Minecraft. - */ - static readonly deepslateGoldOre: BlockType; - /** - * Represents a block of deepslate with embedded iron ore - * within Minecraft. - */ - static readonly deepslateIronOre: BlockType; - /** - * Represents a block of deepslate with embedded lapis lazuli - * ore within Minecraft. - */ - static readonly deepslateLapisOre: BlockType; - /** - * Represents a block of deepslate with embedded redstone ore - * within Minecraft. - */ - static readonly deepslateRedstoneOre: BlockType; - /** - * Represents a double slab of tiled deepslate within - * Minecraft. - */ - static readonly deepslateTileDoubleSlab: BlockType; - /** - * Represents a set of deepslate tiles within Minecraft. - */ - static readonly deepslateTiles: BlockType; - /** - * Represents a slab of deepslate tiles within Minecraft. - */ - static readonly deepslateTileSlab: BlockType; - /** - * Represents a set of deepslate tile stairs within Minecraft. - */ - static readonly deepslateTileStairs: BlockType; - /** - * Represents a wall of deepslate tile within Minecraft. - */ - static readonly deepslateTileWall: BlockType; - /** - * Represents a logical but generally invisible Deny logic - * block within Minecraft. - */ - static readonly deny: BlockType; - /** - * Represents a detector rail within Minecraft. - */ - static readonly detectorRail: BlockType; - /** - * Represents a block of diamond within Minecraft. - */ - static readonly diamondBlock: BlockType; - /** - * Represents a block with embedded diamond ore within - * Minecraft. - */ - static readonly diamondOre: BlockType; - /** - * Represents a set of diorite stairs within Minecraft. - */ - static readonly dioriteStairs: BlockType; - /** - * Represents a block of dirt within Minecraft. - */ - static readonly dirt: BlockType; - /** - * Represents a block of dirt with roots within Minecraft. - */ - static readonly dirtWithRoots: BlockType; - /** - * Represents a dispenser within Minecraft. - */ - static readonly dispenser: BlockType; - /** - * Represents a slab of double cut copper within Minecraft. - */ - static readonly doubleCutCopperSlab: BlockType; - /** - * Represents a double plant within Minecraft. - */ - static readonly doublePlant: BlockType; - static readonly doubleStoneBlockSlab: BlockType; - static readonly doubleStoneBlockSlab2: BlockType; - static readonly doubleStoneBlockSlab3: BlockType; - static readonly doubleStoneBlockSlab4: BlockType; - /** - * Represents a double slab of stone within Minecraft. - */ - static readonly doubleStoneSlab: BlockType; - /** - * Represents an alternate double slab of stone (#2) within - * Minecraft. - */ - static readonly doubleStoneSlab2: BlockType; - /** - * Represents an alternate double slab of stone (#3) within - * Minecraft. - */ - static readonly doubleStoneSlab3: BlockType; - /** - * Represents an alternate double slab of stone (#4) within - * Minecraft. - */ - static readonly doubleStoneSlab4: BlockType; - /** - * Represents a double slab of wood within Minecraft. - */ - static readonly doubleWoodenSlab: BlockType; - /** - * Represents a dragon egg within Minecraft. - */ - static readonly dragonEgg: BlockType; - /** - * Represents a block of dried kelp within Minecraft. - */ - static readonly driedKelpBlock: BlockType; - /** - * Represents a block of dripstone within Minecraft. - */ - static readonly dripstoneBlock: BlockType; - /** - * Represents a dropper within Minecraft. - */ - static readonly dropper: BlockType; - /** - * Represents an element in Minecraft Education experiences. - */ - static readonly element0: BlockType; - /** - * Represents the hydrogen element in Minecraft Education - * experiences. - */ - static readonly element1: BlockType; - /** - * Represents the neon element in Minecraft Education - * experiences. - */ - static readonly element10: BlockType; - /** - * Represents the fermium element in Minecraft Education - * experiences. - */ - static readonly element100: BlockType; - /** - * Represents the mendelevium element in Minecraft Education - * experiences. - */ - static readonly element101: BlockType; - /** - * Represents the nobelium element in Minecraft Education - * experiences. - */ - static readonly element102: BlockType; - /** - * Represents the lawrencium element in Minecraft Education - * experiences. - */ - static readonly element103: BlockType; - /** - * Represents the rutherfordium element in Minecraft Education - * experiences. - */ - static readonly element104: BlockType; - /** - * Represents the dubnium element in Minecraft Education - * experiences. - */ - static readonly element105: BlockType; - /** - * Represents the seaborgium element in Minecraft Education - * experiences. - */ - static readonly element106: BlockType; - /** - * Represents the bohrium element in Minecraft Education - * experiences. - */ - static readonly element107: BlockType; - /** - * Represents the hassium element in Minecraft Education - * experiences. - */ - static readonly element108: BlockType; - /** - * Represents the meitnerium element in Minecraft Education - * experiences. - */ - static readonly element109: BlockType; - /** - * Represents the sodium element in Minecraft Education - * experiences. - */ - static readonly element11: BlockType; - /** - * Represents the darmstadtium element in Minecraft Education - * experiences. - */ - static readonly element110: BlockType; - /** - * Represents the roentgenium element in Minecraft Education - * experiences. - */ - static readonly element111: BlockType; - /** - * Represents the copernicium element in Minecraft Education - * experiences. - */ - static readonly element112: BlockType; - /** - * Represents the nihonium element in Minecraft Education - * experiences. - */ - static readonly element113: BlockType; - /** - * Represents the flerovium element in Minecraft Education - * experiences. - */ - static readonly element114: BlockType; - /** - * Represents the moscovium element in Minecraft Education - * experiences. - */ - static readonly element115: BlockType; - /** - * Represents the livermorium element in Minecraft Education - * experiences. - */ - static readonly element116: BlockType; - /** - * Represents the tennessine element in Minecraft Education - * experiences. - */ - static readonly element117: BlockType; - /** - * Represents the oganesson element in Minecraft Education - * experiences. - */ - static readonly element118: BlockType; - /** - * Represents the magnesium element in Minecraft Education - * experiences. - */ - static readonly element12: BlockType; - /** - * Represents the aluminum element in Minecraft Education - * experiences. - */ - static readonly element13: BlockType; - /** - * Represents the silicon element in Minecraft Education - * experiences. - */ - static readonly element14: BlockType; - /** - * Represents the phosphorus element in Minecraft Education - * experiences. - */ - static readonly element15: BlockType; - /** - * Represents the sulfur element in Minecraft Education - * experiences. - */ - static readonly element16: BlockType; - /** - * Represents the chlorine element in Minecraft Education - * experiences. - */ - static readonly element17: BlockType; - /** - * Represents the argon element in Minecraft Education - * experiences. - */ - static readonly element18: BlockType; - /** - * Represents the potassium element in Minecraft Education - * experiences. - */ - static readonly element19: BlockType; - /** - * Represents the helium element in Minecraft Education - * experiences. - */ - static readonly element2: BlockType; - /** - * Represents the calcium element in Minecraft Education - * experiences. - */ - static readonly element20: BlockType; - /** - * Represents the scandium element in Minecraft Education - * experiences. - */ - static readonly element21: BlockType; - /** - * Represents the titanium element in Minecraft Education - * experiences. - */ - static readonly element22: BlockType; - /** - * Represents the vanadium element in Minecraft Education - * experiences. - */ - static readonly element23: BlockType; - /** - * Represents the chromium element in Minecraft Education - * experiences. - */ - static readonly element24: BlockType; - /** - * Represents the manganese element in Minecraft Education - * experiences. - */ - static readonly element25: BlockType; - /** - * Represents the iron element in Minecraft Education - * experiences. - */ - static readonly element26: BlockType; - /** - * Represents the cobalt element in Minecraft Education - * experiences. - */ - static readonly element27: BlockType; - /** - * Represents the nickel element in Minecraft Education - * experiences. - */ - static readonly element28: BlockType; - /** - * Represents the copper element in Minecraft Education - * experiences. - */ - static readonly element29: BlockType; - /** - * Represents a lithium element in Minecraft Education - * experiences. - */ - static readonly element3: BlockType; - /** - * Represents the zinc element in Minecraft Education - * experiences. - */ - static readonly element30: BlockType; - /** - * Represents the gallium element in Minecraft Education - * experiences. - */ - static readonly element31: BlockType; - /** - * Represents a germanium element in Minecraft Education - * experiences. - */ - static readonly element32: BlockType; - /** - * Represents the arsenic element in Minecraft Education - * experiences. - */ - static readonly element33: BlockType; - /** - * Represents the selenium element in Minecraft Education - * experiences. - */ - static readonly element34: BlockType; - /** - * Represents the bromine element in Minecraft Education - * experiences. - */ - static readonly element35: BlockType; - /** - * Represents the krypton element in Minecraft Education - * experiences. - */ - static readonly element36: BlockType; - /** - * Represents the rubidium element in Minecraft Education - * experiences. - */ - static readonly element37: BlockType; - /** - * Represents the strontium element in Minecraft Education - * experiences. - */ - static readonly element38: BlockType; - /** - * Represents the yttrium element in Minecraft Education - * experiences. - */ - static readonly element39: BlockType; - /** - * Represents a beryllium element in Minecraft Education - * experiences. - */ - static readonly element4: BlockType; - /** - * Represents the zirconium element in Minecraft Education - * experiences. - */ - static readonly element40: BlockType; - /** - * Represents the niobium element in Minecraft Education - * experiences. - */ - static readonly element41: BlockType; - /** - * Represents the molybdenum element in Minecraft Education - * experiences. - */ - static readonly element42: BlockType; - /** - * Represents the technetium element in Minecraft Education - * experiences. - */ - static readonly element43: BlockType; - /** - * Represents the ruthenium element in Minecraft Education - * experiences. - */ - static readonly element44: BlockType; - /** - * Represents the rhodium element in Minecraft Education - * experiences. - */ - static readonly element45: BlockType; - /** - * Represents the palladium element in Minecraft Education - * experiences. - */ - static readonly element46: BlockType; - /** - * Represents the silver element in Minecraft Education - * experiences. - */ - static readonly element47: BlockType; - /** - * Represents the cadmium element in Minecraft Education - * experiences. - */ - static readonly element48: BlockType; - /** - * Represents the indium element in Minecraft Education - * experiences. - */ - static readonly element49: BlockType; - /** - * Represents the boron element in Minecraft Education - * experiences. - */ - static readonly element5: BlockType; - /** - * Represents the tin element in Minecraft Education - * experiences. - */ - static readonly element50: BlockType; - /** - * Represents the antimony element in Minecraft Education - * experiences. - */ - static readonly element51: BlockType; - /** - * Represents the tellurium element in Minecraft Education - * experiences. - */ - static readonly element52: BlockType; - /** - * Represents the iodine element in Minecraft Education - * experiences. - */ - static readonly element53: BlockType; - /** - * Represents the xenon element in Minecraft Education - * experiences. - */ - static readonly element54: BlockType; - /** - * Represents the cesium element in Minecraft Education - * experiences. - */ - static readonly element55: BlockType; - /** - * Represents the barium element in Minecraft Education - * experiences. - */ - static readonly element56: BlockType; - /** - * Represents the lanthanum element in Minecraft Education - * experiences. - */ - static readonly element57: BlockType; - /** - * Represents the cerium element in Minecraft Education - * experiences. - */ - static readonly element58: BlockType; - /** - * Represents the praseodymium element in Minecraft Education - * experiences. - */ - static readonly element59: BlockType; - /** - * Represents the carbon element in Minecraft Education - * experiences. - */ - static readonly element6: BlockType; - /** - * Represents the neodymium element in Minecraft Education - * experiences. - */ - static readonly element60: BlockType; - /** - * Represents the promethium element in Minecraft Education - * experiences. - */ - static readonly element61: BlockType; - /** - * Represents the samarium element in Minecraft Education - * experiences. - */ - static readonly element62: BlockType; - /** - * Represents the europium element in Minecraft Education - * experiences. - */ - static readonly element63: BlockType; - /** - * Represents the gadolinium element in Minecraft Education - * experiences. - */ - static readonly element64: BlockType; - /** - * Represents a terbium element in Minecraft Education - * experiences. - */ - static readonly element65: BlockType; - /** - * Represents the dysprosium element in Minecraft Education - * experiences. - */ - static readonly element66: BlockType; - /** - * Represents the holmium element in Minecraft Education - * experiences. - */ - static readonly element67: BlockType; - /** - * Represents the erbium element in Minecraft Education - * experiences. - */ - static readonly element68: BlockType; - /** - * Represents the thulium element in Minecraft Education - * experiences. - */ - static readonly element69: BlockType; - /** - * Represents the nitrogen element in Minecraft Education - * experiences. - */ - static readonly element7: BlockType; - /** - * Represents the ytterbium element in Minecraft Education - * experiences. - */ - static readonly element70: BlockType; - /** - * Represents the lutetium element in Minecraft Education - * experiences. - */ - static readonly element71: BlockType; - /** - * Represents a hafnium element in Minecraft Education - * experiences. - */ - static readonly element72: BlockType; - /** - * Represents the tantalum element in Minecraft Education - * experiences. - */ - static readonly element73: BlockType; - /** - * Represents the tungsten element in Minecraft Education - * experiences. - */ - static readonly element74: BlockType; - /** - * Represents the rhenium element in Minecraft Education - * experiences. - */ - static readonly element75: BlockType; - /** - * Represents the osmium element in Minecraft Education - * experiences. - */ - static readonly element76: BlockType; - /** - * Represents the iridium element in Minecraft Education - * experiences. - */ - static readonly element77: BlockType; - /** - * Represents the platinum element in Minecraft Education - * experiences. - */ - static readonly element78: BlockType; - /** - * Represents the gold element in Minecraft Education - * experiences. - */ - static readonly element79: BlockType; - /** - * Represents the oxygen element in Minecraft Education - * experiences. - */ - static readonly element8: BlockType; - /** - * Represents the mercury element in Minecraft Education - * experiences. - */ - static readonly element80: BlockType; - /** - * Represents the thallium element in Minecraft Education - * experiences. - */ - static readonly element81: BlockType; - /** - * Represents the lead element in Minecraft Education - * experiences. - */ - static readonly element82: BlockType; - /** - * Represents the bismuth element in Minecraft Education - * experiences. - */ - static readonly element83: BlockType; - /** - * Represents the polonium element in Minecraft Education - * experiences. - */ - static readonly element84: BlockType; - /** - * Represents the astatine element in Minecraft Education - * experiences. - */ - static readonly element85: BlockType; - /** - * Represents the radon element in Minecraft Education - * experiences. - */ - static readonly element86: BlockType; - /** - * Represents the francium element in Minecraft Education - * experiences. - */ - static readonly element87: BlockType; - /** - * Represents the radium element in Minecraft Education - * experiences. - */ - static readonly element88: BlockType; - /** - * Represents the actinium element in Minecraft Education - * experiences. - */ - static readonly element89: BlockType; - /** - * Represents the fluorine element in Minecraft Education - * experiences. - */ - static readonly element9: BlockType; - /** - * Represents the thorium element in Minecraft Education - * experiences. - */ - static readonly element90: BlockType; - /** - * Represents the protactinium element in Minecraft Education - * experiences. - */ - static readonly element91: BlockType; - /** - * Represents the uranium element in Minecraft Education - * experiences. - */ - static readonly element92: BlockType; - /** - * Represents the neptunium element in Minecraft Education - * experiences. - */ - static readonly element93: BlockType; - /** - * Represents the plutonium element in Minecraft Education - * experiences. - */ - static readonly element94: BlockType; - /** - * Represents the americium element in Minecraft Education - * experiences. - */ - static readonly element95: BlockType; - /** - * Represents the curium element in Minecraft Education - * experiences. - */ - static readonly element96: BlockType; - /** - * Represents the berkelium element in Minecraft Education - * experiences. - */ - static readonly element97: BlockType; - /** - * Represents the californium element in Minecraft Education - * experiences. - */ - static readonly element98: BlockType; - /** - * Represents the einsteinium element in Minecraft Education - * experiences. - */ - static readonly element99: BlockType; - /** - * Represents a block of emerald within Minecraft. - */ - static readonly emeraldBlock: BlockType; - /** - * Represents a block with embedded emerald ore within - * Minecraft. - */ - static readonly emeraldOre: BlockType; - /** - * Represents an enchanting table within Minecraft. - */ - static readonly enchantingTable: BlockType; - /** - * Represents an end bricks block within Minecraft. - */ - static readonly endBricks: BlockType; - /** - * Represents a set of end brick stairs within Minecraft. - */ - static readonly endBrickStairs: BlockType; - /** - * Represents an ender chest within Minecraft. - */ - static readonly enderChest: BlockType; - /** - * Represents an end gateway within Minecraft. - */ - static readonly endGateway: BlockType; - /** - * Represents an end portal block within Minecraft. - */ - static readonly endPortal: BlockType; - /** - * Represents an end portal frame within Minecraft. - */ - static readonly endPortalFrame: BlockType; - /** - * Represents an end rod within Minecraft. - */ - static readonly endRod: BlockType; - /** - * Represents an end stone block within Minecraft. - */ - static readonly endStone: BlockType; - /** - * Represents a block of exposed copper within Minecraft. - */ - static readonly exposedCopper: BlockType; - /** - * Represents a block of exposed cut copper within Minecraft. - */ - static readonly exposedCutCopper: BlockType; - /** - * Represents a slab of exposed cut copper within Minecraft. - */ - static readonly exposedCutCopperSlab: BlockType; - /** - * Represents a set of exposed cut copper stairs within - * Minecraft. - */ - static readonly exposedCutCopperStairs: BlockType; - /** - * Represents a double slab of exposed cut copper within - * Minecraft. - */ - static readonly exposedDoubleCutCopperSlab: BlockType; - /** - * Represents a farmland block within Minecraft. - */ - static readonly farmland: BlockType; - /** - * Represents a fence within Minecraft. - */ - static readonly fence: BlockType; - /** - * Represents a fence gate within Minecraft. - */ - static readonly fenceGate: BlockType; - /** - * Represents a fire within Minecraft. - */ - static readonly fire: BlockType; - /** - * Represents a fletching table within Minecraft. - */ - static readonly fletchingTable: BlockType; - /** - * Represents a flowering azalea plant within Minecraft. - */ - static readonly floweringAzalea: BlockType; - /** - * Represents a flower pot within Minecraft. - */ - static readonly flowerPot: BlockType; - /** - * Represents flowing lava within Minecraft. - */ - static readonly flowingLava: BlockType; - /** - * Represents flowing water within Minecraft. - */ - static readonly flowingWater: BlockType; - /** - * Represents a frame within Minecraft. - */ - static readonly frame: BlockType; - static readonly frogSpawn: BlockType; - /** - * Represents a frosted ice block within Minecraft. - */ - static readonly frostedIce: BlockType; - /** - * Represents a furnace within Minecraft. - */ - static readonly furnace: BlockType; - /** - * Represents a block of gilded blackstone within Minecraft. - */ - static readonly gildedBlackstone: BlockType; - /** - * Represents a glass block within Minecraft. - */ - static readonly glass: BlockType; - /** - * Represents a pane of glass within Minecraft. - */ - static readonly glassPane: BlockType; - /** - * Represents a glowing frame within Minecraft. - */ - static readonly glowFrame: BlockType; - /** - * Represents a glowing obsidian block within Minecraft. - */ - static readonly glowingobsidian: BlockType; - /** - * Represents glow lichen within Minecraft. - */ - static readonly glowLichen: BlockType; - /** - * Represents a block of glowstone within Minecraft. - */ - static readonly glowstone: BlockType; - /** - * Represents a gold block within Minecraft. - */ - static readonly goldBlock: BlockType; - /** - * Represents a golden rail element within Minecraft. - */ - static readonly goldenRail: BlockType; - /** - * Represents a block with embedded gold ore within Minecraft. - */ - static readonly goldOre: BlockType; - /** - * Represents a set of granite stairs within Minecraft. - */ - static readonly graniteStairs: BlockType; - /** - * Represents a block of dirt and grass within Minecraft. - */ - static readonly grass: BlockType; - /** - * Represents a block of dirt and grass with a path within - * Minecraft. - */ - static readonly grassPath: BlockType; - /** - * Represents a block of gravel within Minecraft. - */ - static readonly gravel: BlockType; - /** - * Represents a gray-colored candle within Minecraft. - */ - static readonly grayCandle: BlockType; - /** - * Represents a cake with gray-colored candle within Minecraft. - */ - static readonly grayCandleCake: BlockType; - /** - * Represents a gray-colored block of glazed terracotta within - * Minecraft. - */ - static readonly grayGlazedTerracotta: BlockType; - static readonly grayWool: BlockType; - /** - * Represents a green-colored candle within Minecraft. - */ - static readonly greenCandle: BlockType; - /** - * Represents a green-colored candle cake within Minecraft. - */ - static readonly greenCandleCake: BlockType; - /** - * Represents a green block of glazed terracotta within - * Minecraft. - */ - static readonly greenGlazedTerracotta: BlockType; - static readonly greenWool: BlockType; - /** - * Represents a grindstone within Minecraft. - */ - static readonly grindstone: BlockType; - /** - * Represents a set of hanging roots within Minecraft. - */ - static readonly hangingRoots: BlockType; - /** - * Represents a block of hardened clay within Minecraft. - */ - static readonly hardenedClay: BlockType; - /** - * Represents a block of hard glass within Minecraft. - */ - static readonly hardGlass: BlockType; - /** - * Represents a pane of hard glass within Minecraft. - */ - static readonly hardGlassPane: BlockType; - /** - * Represents a stained hard glass block within Minecraft. - */ - static readonly hardStainedGlass: BlockType; - /** - * Represents a stained pane of hard glass within Minecraft. - */ - static readonly hardStainedGlassPane: BlockType; - /** - * Represents a block of hay within Minecraft. - */ - static readonly hayBlock: BlockType; - /** - * Represents a heavy weighted pressure plate within Minecraft. - */ - static readonly heavyWeightedPressurePlate: BlockType; - /** - * Represents a block of honey within Minecraft. - */ - static readonly honeyBlock: BlockType; - /** - * Represents a honeycomb block within Minecraft. - */ - static readonly honeycombBlock: BlockType; - /** - * Represents a hopper within Minecraft. - */ - static readonly hopper: BlockType; - /** - * Represents a block of ice within Minecraft. - */ - static readonly ice: BlockType; - /** - * Represents an infested block of deepslate within Minecraft. - */ - static readonly infestedDeepslate: BlockType; - /** - * Represents an information update block within Minecraft. - */ - static readonly infoUpdate: BlockType; - /** - * Represents an information update block within Minecraft. - */ - static readonly infoUpdate2: BlockType; - /** - * Represents an invisible boundary bedrock block within - * Minecraft. - */ - static readonly invisibleBedrock: BlockType; - /** - * Represents iron bars within Minecraft. - */ - static readonly ironBars: BlockType; - /** - * Represents a block of iron within Minecraft. - */ - static readonly ironBlock: BlockType; - /** - * Represents an iron door within Minecraft. - */ - static readonly ironDoor: BlockType; - /** - * Represents a block with embedded iron ore within Minecraft. - */ - static readonly ironOre: BlockType; - /** - * Represents an iron trapdoor within Minecraft. - */ - static readonly ironTrapdoor: BlockType; - /** - * Represents a jigsaw within Minecraft. - */ - static readonly jigsaw: BlockType; - /** - * Represents a jukebox within Minecraft. - */ - static readonly jukebox: BlockType; - /** - * Represents jungle wood button within Minecraft. - */ - static readonly jungleButton: BlockType; - /** - * Represents a jungle wood door within Minecraft. - */ - static readonly jungleDoor: BlockType; - /** - * Represents a jungle wood fence gate within Minecraft. - */ - static readonly jungleFenceGate: BlockType; - static readonly jungleHangingSign: BlockType; - /** - * Represents a jungle wood pressure plate within Minecraft. - */ - static readonly junglePressurePlate: BlockType; - /** - * Represents a set of jungle wood stairs within Minecraft. - */ - static readonly jungleStairs: BlockType; - /** - * Represents a jungle wood standing sign within Minecraft. - */ - static readonly jungleStandingSign: BlockType; - /** - * Represents a jungle wood trapdoor within Minecraft. - */ - static readonly jungleTrapdoor: BlockType; - /** - * Represents a jungle wood wall sign within Minecraft. - */ - static readonly jungleWallSign: BlockType; - /** - * Represents a set of kelp within Minecraft. - */ - static readonly kelp: BlockType; - /** - * Represents a ladder within Minecraft. - */ - static readonly ladder: BlockType; - /** - * Represents a lantern within Minecraft. - */ - static readonly lantern: BlockType; - /** - * Represents a block of lapis lazuli within Minecraft. - */ - static readonly lapisBlock: BlockType; - /** - * Represents a block with embedded lapis lazuli within - * Minecraft. - */ - static readonly lapisOre: BlockType; - /** - * Represents a bud of large amethyst within Minecraft. - */ - static readonly largeAmethystBud: BlockType; - /** - * Represents lava within Minecraft. - */ - static readonly lava: BlockType; - /** - * Represents a cauldron filled with lava within Minecraft. - */ - static readonly lavaCauldron: BlockType; - /** - * Represents a set of leaves within Minecraft. - */ - static readonly leaves: BlockType; - /** - * Represents an updated set of leaves within Minecraft. - */ - static readonly leaves2: BlockType; - /** - * Represents a lectern within Minecraft. - */ - static readonly lectern: BlockType; - /** - * Represents a lever within Minecraft. - */ - static readonly lever: BlockType; - /** - * Represents a block of light within Minecraft. - */ - static readonly lightBlock: BlockType; - /** - * Represents a light blue candle within Minecraft. - */ - static readonly lightBlueCandle: BlockType; - /** - * Represents a light blue candle cake within Minecraft. - */ - static readonly lightBlueCandleCake: BlockType; - /** - * Represents a light blue block of glazed terracotta within - * Minecraft. - */ - static readonly lightBlueGlazedTerracotta: BlockType; - static readonly lightBlueWool: BlockType; - /** - * Represents a light gray candle within Minecraft. - */ - static readonly lightGrayCandle: BlockType; - /** - * Represents a light gray candle cake within Minecraft. - */ - static readonly lightGrayCandleCake: BlockType; - static readonly lightGrayWool: BlockType; - /** - * Represents a lightning rod within Minecraft. - */ - static readonly lightningRod: BlockType; - /** - * Represents a light weighted pressure plate within Minecraft. - */ - static readonly lightWeightedPressurePlate: BlockType; - /** - * Represents a lime candle within Minecraft. - */ - static readonly limeCandle: BlockType; - /** - * Represents a lime-colored candle cake within Minecraft. - */ - static readonly limeCandleCake: BlockType; - /** - * Represents a lime-colored block of glazed terracotta within - * Minecraft. - */ - static readonly limeGlazedTerracotta: BlockType; - static readonly limeWool: BlockType; - /** - * Represents a lit blast furnace within Minecraft. - */ - static readonly litBlastFurnace: BlockType; - /** - * Represents lit deepslate redstone ore within Minecraft. - */ - static readonly litDeepslateRedstoneOre: BlockType; - /** - * Represents a lit furnace within Minecraft. - */ - static readonly litFurnace: BlockType; - /** - * Represents a lit pumpkin within Minecraft. - */ - static readonly litPumpkin: BlockType; - /** - * Represents a lit redstone lamp within Minecraft. - */ - static readonly litRedstoneLamp: BlockType; - /** - * Represents lit redstone ore within Minecraft. - */ - static readonly litRedstoneOre: BlockType; - /** - * Represents a lit smoker within Minecraft. - */ - static readonly litSmoker: BlockType; - /** - * Represents a lodestone within Minecraft. - */ - static readonly lodestone: BlockType; - /** - * Represents a log within Minecraft. - */ - static readonly log: BlockType; - /** - * Represents a more updated, customizable log within - * Minecraft. - */ - static readonly log2: BlockType; - /** - * Represents a loom within Minecraft. - */ - static readonly loom: BlockType; - /** - * Represents a magenta candle within Minecraft. - */ - static readonly magentaCandle: BlockType; - /** - * Represents a magenta candle cake within Minecraft. - */ - static readonly magentaCandleCake: BlockType; - /** - * Represents a block of magenta-colored glazed terracotta - * within Minecraft. - */ - static readonly magentaGlazedTerracotta: BlockType; - static readonly magentaWool: BlockType; - /** - * Represents magma within Minecraft. - */ - static readonly magma: BlockType; - static readonly mangroveButton: BlockType; - static readonly mangroveDoor: BlockType; - static readonly mangroveDoubleSlab: BlockType; - static readonly mangroveFence: BlockType; - static readonly mangroveFenceGate: BlockType; - static readonly mangroveHangingSign: BlockType; - static readonly mangroveLeaves: BlockType; - static readonly mangroveLog: BlockType; - static readonly mangrovePlanks: BlockType; - static readonly mangrovePressurePlate: BlockType; - static readonly mangrovePropagule: BlockType; - static readonly mangroveRoots: BlockType; - static readonly mangroveSlab: BlockType; - static readonly mangroveStairs: BlockType; - static readonly mangroveStandingSign: BlockType; - static readonly mangroveTrapdoor: BlockType; - static readonly mangroveWallSign: BlockType; - static readonly mangroveWood: BlockType; - /** - * Represents a medium-sized bud of amethyst within Minecraft. - */ - static readonly mediumAmethystBud: BlockType; - /** - * Represents a block of melon within Minecraft. - */ - static readonly melonBlock: BlockType; - /** - * Represents a stem of melon within Minecraft. - */ - static readonly melonStem: BlockType; - /** - * Represents a mob spawner within Minecraft. - */ - static readonly mobSpawner: BlockType; - /** - * Represents a monster egg within Minecraft. - */ - static readonly monsterEgg: BlockType; - /** - * Represents a block of moss within Minecraft. - */ - static readonly mossBlock: BlockType; - /** - * Represents a carpet of moss within Minecraft. - */ - static readonly mossCarpet: BlockType; - /** - * Represents a block of cobblestone with moss within - * Minecraft. - */ - static readonly mossyCobblestone: BlockType; - /** - * Represents a set of mossy cobblestone stairs within - * Minecraft. - */ - static readonly mossyCobblestoneStairs: BlockType; - /** - * Represents a set of mossy stone brick stairs within - * Minecraft. - */ - static readonly mossyStoneBrickStairs: BlockType; - static readonly movingBlock: BlockType; - static readonly mud: BlockType; - static readonly mudBrickDoubleSlab: BlockType; - static readonly mudBricks: BlockType; - static readonly mudBrickSlab: BlockType; - static readonly mudBrickStairs: BlockType; - static readonly mudBrickWall: BlockType; - static readonly muddyMangroveRoots: BlockType; - /** - * Represents a mycelium plant within Minecraft. - */ - static readonly mycelium: BlockType; - /** - * Represents a nether brick block within Minecraft. - */ - static readonly netherBrick: BlockType; - /** - * Represents a nether brick fence within Minecraft. - */ - static readonly netherBrickFence: BlockType; - /** - * Represents a set of nether brick stairs within Minecraft. - */ - static readonly netherBrickStairs: BlockType; - /** - * Represents a block of nether with embedded gold ore within - * Minecraft. - */ - static readonly netherGoldOre: BlockType; - /** - * Represents a block of netherite within Minecraft. - */ - static readonly netheriteBlock: BlockType; - /** - * Represents a block of netherrack within Minecraft. - */ - static readonly netherrack: BlockType; - /** - * Represents a nether rock within Minecraft. - */ - static readonly netherreactor: BlockType; - /** - * Represents nether sprouts within Minecraft. - */ - static readonly netherSprouts: BlockType; - /** - * Represents nether wart within Minecraft. - */ - static readonly netherWart: BlockType; - /** - * Represents a block of nether wart within Minecraft. - */ - static readonly netherWartBlock: BlockType; - /** - * Represents a standard set of stone stairs within Minecraft. - */ - static readonly normalStoneStairs: BlockType; - /** - * Represents a note block within Minecraft. - */ - static readonly noteblock: BlockType; - static readonly oakHangingSign: BlockType; - /** - * Represents a set of oak stairs within Minecraft. - */ - static readonly oakStairs: BlockType; - /** - * Represents an observer within Minecraft. - */ - static readonly observer: BlockType; - /** - * Represents an obsidian block within Minecraft. - */ - static readonly obsidian: BlockType; - static readonly ochreFroglight: BlockType; - /** - * Represents an orange candle within Minecraft. - */ - static readonly orangeCandle: BlockType; - /** - * Represents an orange candle cake within Minecraft. - */ - static readonly orangeCandleCake: BlockType; - /** - * Represents a block of orange-colored glazed terracotta - * within Minecraft. - */ - static readonly orangeGlazedTerracotta: BlockType; - static readonly orangeWool: BlockType; - /** - * Represents a block of oxidized copper within Minecraft. - */ - static readonly oxidizedCopper: BlockType; - /** - * Represents a block of oxidized cut copper within Minecraft. - */ - static readonly oxidizedCutCopper: BlockType; - /** - * Represents a slab of oxidized cut copper within Minecraft. - */ - static readonly oxidizedCutCopperSlab: BlockType; - /** - * Represents a set of oxidized cut copper stairs within - * Minecraft. - */ - static readonly oxidizedCutCopperStairs: BlockType; - /** - * Represents a double slab of oxidized cut copper within - * Minecraft. - */ - static readonly oxidizedDoubleCutCopperSlab: BlockType; - /** - * Represents a block of packed ice within Minecraft. - */ - static readonly packedIce: BlockType; - static readonly packedMud: BlockType; - static readonly pearlescentFroglight: BlockType; - /** - * Represents a pink candle within Minecraft. - */ - static readonly pinkCandle: BlockType; - /** - * Represents a pink candle cake within Minecraft. - */ - static readonly pinkCandleCake: BlockType; - /** - * Represents a pink-colored block of glazed terracotta within - * Minecraft. - */ - static readonly pinkGlazedTerracotta: BlockType; - static readonly pinkWool: BlockType; - /** - * Represents a piston within Minecraft. - */ - static readonly piston: BlockType; - static readonly pistonArmCollision: BlockType; - /** - * Represents a set of planks within Minecraft. - */ - static readonly planks: BlockType; - /** - * Represents podzol within Minecraft. - */ - static readonly podzol: BlockType; - /** - * Represents pointed dripstone within Minecraft. - */ - static readonly pointedDripstone: BlockType; - /** - * Represents a set of polished andesite stairs within - * Minecraft. - */ - static readonly polishedAndesiteStairs: BlockType; - /** - * Represents a block of polished basalt within Minecraft. - */ - static readonly polishedBasalt: BlockType; - /** - * Represents a block of polished blackstone within Minecraft. - */ - static readonly polishedBlackstone: BlockType; - /** - * Represents a double slab of polished blackstone brick within - * Minecraft. - */ - static readonly polishedBlackstoneBrickDoubleSlab: BlockType; - /** - * Represents a block of polished blackstone bricks within - * Minecraft. - */ - static readonly polishedBlackstoneBricks: BlockType; - /** - * Represents a slab of polished blackstone within Minecraft. - */ - static readonly polishedBlackstoneBrickSlab: BlockType; - /** - * Represents a set of polished blackstone brick stairs within - * Minecraft. - */ - static readonly polishedBlackstoneBrickStairs: BlockType; - /** - * Represents a polished blackstone brick wall within - * Minecraft. - */ - static readonly polishedBlackstoneBrickWall: BlockType; - /** - * Represents a polished blackstone button within Minecraft. - */ - static readonly polishedBlackstoneButton: BlockType; - /** - * Represents a double slab of polished blackstone within - * Minecraft. - */ - static readonly polishedBlackstoneDoubleSlab: BlockType; - /** - * Represents a polished blackstone pressure plate within - * Minecraft. - */ - static readonly polishedBlackstonePressurePlate: BlockType; - /** - * Represents a slab of polished blackstone within Minecraft. - */ - static readonly polishedBlackstoneSlab: BlockType; - /** - * Represents a set of polished blackstone stairs within - * Minecraft. - */ - static readonly polishedBlackstoneStairs: BlockType; - /** - * Represents a polished blackstone wall within Minecraft. - */ - static readonly polishedBlackstoneWall: BlockType; - /** - * Represents a block of polished deepslate within Minecraft. - */ - static readonly polishedDeepslate: BlockType; - /** - * Represents a double slab of polished deepslate within - * Minecraft. - */ - static readonly polishedDeepslateDoubleSlab: BlockType; - /** - * Represents a slab of polished deepslate within Minecraft. - */ - static readonly polishedDeepslateSlab: BlockType; - /** - * Represents a set of polished deepslate stairs within - * Minecraft. - */ - static readonly polishedDeepslateStairs: BlockType; - /** - * Represents a wall of polished deepslate within Minecraft. - */ - static readonly polishedDeepslateWall: BlockType; - /** - * Represents a block of polished diorite within Minecraft. - */ - static readonly polishedDioriteStairs: BlockType; - /** - * Represents a set of polished granite stairs within - * Minecraft. - */ - static readonly polishedGraniteStairs: BlockType; - /** - * Represents a portal within Minecraft. - */ - static readonly portal: BlockType; - /** - * Represents a set of potatoes within Minecraft. - */ - static readonly potatoes: BlockType; - /** - * Represents a block of powder snow within Minecraft. - */ - static readonly powderSnow: BlockType; - /** - * Represents a powered comparator within Minecraft. - */ - static readonly poweredComparator: BlockType; - /** - * Represents a powered repeater within Minecraft. - */ - static readonly poweredRepeater: BlockType; - /** - * Represents a block of prismarine within Minecraft. - */ - static readonly prismarine: BlockType; - /** - * Represents a set of prismarine brick stairs within - * Minecraft. - */ - static readonly prismarineBricksStairs: BlockType; - /** - * Represents a set of prismarine stairs within Minecraft. - */ - static readonly prismarineStairs: BlockType; - /** - * Represents a pumpkin within Minecraft. - */ - static readonly pumpkin: BlockType; - /** - * Represents a pumpkin stem within Minecraft. - */ - static readonly pumpkinStem: BlockType; - /** - * Represents a purple candle within Minecraft. - */ - static readonly purpleCandle: BlockType; - /** - * Represents a purple colored candle cake within Minecraft. - */ - static readonly purpleCandleCake: BlockType; - /** - * Represents a purple-colored block of glazed terracotta - * within Minecraft. - */ - static readonly purpleGlazedTerracotta: BlockType; - static readonly purpleWool: BlockType; - /** - * Represents a purpur block within Minecraft. - */ - static readonly purpurBlock: BlockType; - /** - * Represents a set of purpur stairs within Minecraft. - */ - static readonly purpurStairs: BlockType; - /** - * Represents a block of solid quartz within Minecraft. - */ - static readonly quartzBlock: BlockType; - /** - * Represents a block of solid quartz bricks within Minecraft. - */ - static readonly quartzBricks: BlockType; - /** - * Represents a block with embedded quartz ore within - * Minecraft. - */ - static readonly quartzOre: BlockType; - /** - * Represents a set of quartz stairs within Minecraft. - */ - static readonly quartzStairs: BlockType; - /** - * Represents a set of rails within Minecraft. - */ - static readonly rail: BlockType; - /** - * Represents a block of raw copper within Minecraft. - */ - static readonly rawCopperBlock: BlockType; - /** - * Represents a block of raw gold within Minecraft. - */ - static readonly rawGoldBlock: BlockType; - /** - * Represents a block of raw iron within Minecraft. - */ - static readonly rawIronBlock: BlockType; - /** - * Represents a red candle within Minecraft. - */ - static readonly redCandle: BlockType; - /** - * Represents a red candle cake within Minecraft. - */ - static readonly redCandleCake: BlockType; - /** - * Represents a red flower within Minecraft. - */ - static readonly redFlower: BlockType; - /** - * Represents a red-colored block of glazed terracotta within - * Minecraft. - */ - static readonly redGlazedTerracotta: BlockType; - /** - * Represents a red mushroom within Minecraft. - */ - static readonly redMushroom: BlockType; - /** - * Represents a block of red mushroom within Minecraft. - */ - static readonly redMushroomBlock: BlockType; - /** - * Represents a block of red nether brick within Minecraft. - */ - static readonly redNetherBrick: BlockType; - /** - * Represents a set of red nether brick stairs within - * Minecraft. - */ - static readonly redNetherBrickStairs: BlockType; - /** - * Represents a block of red sandstone within Minecraft. - */ - static readonly redSandstone: BlockType; - /** - * Represents a set of red sandstone stairs within Minecraft. - */ - static readonly redSandstoneStairs: BlockType; - /** - * Represents a block of redstone within Minecraft. - */ - static readonly redstoneBlock: BlockType; - /** - * Represents a redstone lamp within Minecraft. - */ - static readonly redstoneLamp: BlockType; - /** - * Represents a block with embedded redstone ore within - * Minecraft. - */ - static readonly redstoneOre: BlockType; - /** - * Represents a redstone torch within Minecraft. - */ - static readonly redstoneTorch: BlockType; - /** - * Represents a redstone wire within Minecraft. - */ - static readonly redstoneWire: BlockType; - static readonly redWool: BlockType; - /** - * Represents reeds within Minecraft. - */ - static readonly reeds: BlockType; - static readonly reinforcedDeepslate: BlockType; - /** - * Represents a repeating command block within Minecraft. - */ - static readonly repeatingCommandBlock: BlockType; - /** - * Represents a reserved block within Minecraft. - */ - static readonly reserved6: BlockType; - /** - * Represents a respawn anchor within Minecraft. - */ - static readonly respawnAnchor: BlockType; - /** - * Represents a block of sand within Minecraft. - */ - static readonly sand: BlockType; - /** - * Represents a block of sandstone within Minecraft. - */ - static readonly sandstone: BlockType; - /** - * Represents a set of sandstone stairs within Minecraft. - */ - static readonly sandstoneStairs: BlockType; - /** - * Represents a sapling within Minecraft. - */ - static readonly sapling: BlockType; - /** - * Represents a set of scaffolding within Minecraft. - */ - static readonly scaffolding: BlockType; - static readonly sculk: BlockType; - static readonly sculkCatalyst: BlockType; - /** - * Represents a sculk sensor within Minecraft. - */ - static readonly sculkSensor: BlockType; - static readonly sculkShrieker: BlockType; - static readonly sculkVein: BlockType; - /** - * Represents seagrass within Minecraft. - */ - static readonly seagrass: BlockType; - /** - * Represents a sealantern within Minecraft. - */ - static readonly seaLantern: BlockType; - /** - * Represents a seapickle within Minecraft. - */ - static readonly seaPickle: BlockType; - /** - * Represents a shroom light within Minecraft. - */ - static readonly shroomlight: BlockType; - /** - * Represents a shulker box within Minecraft. - */ - static readonly shulkerBox: BlockType; - /** - * Represents a silver-colored block of glazed terracotta - * within Minecraft. - */ - static readonly silverGlazedTerracotta: BlockType; - /** - * Represents a skull within Minecraft. - */ - static readonly skull: BlockType; - /** - * Represents slime within Minecraft. - */ - static readonly slime: BlockType; - /** - * Represents a small bud of amethyst within Minecraft. - */ - static readonly smallAmethystBud: BlockType; - /** - * Represents a small dripleaf block within Minecraft. - */ - static readonly smallDripleafBlock: BlockType; - /** - * Represents a smithing table within Minecraft. - */ - static readonly smithingTable: BlockType; - /** - * Represents a smoker within Minecraft. - */ - static readonly smoker: BlockType; - /** - * Represents a block of smooth basalt within Minecraft. - */ - static readonly smoothBasalt: BlockType; - /** - * Represents a set of smooth quartz stairs within Minecraft. - */ - static readonly smoothQuartzStairs: BlockType; - /** - * Represents a set of smooth red sandstone stairs within - * Minecraft. - */ - static readonly smoothRedSandstoneStairs: BlockType; - /** - * Represents a set of smooth redstone stairs within Minecraft. - */ - static readonly smoothSandstoneStairs: BlockType; - /** - * Represents a smooth stone block within Minecraft. - */ - static readonly smoothStone: BlockType; - /** - * Represents snow within Minecraft. - */ - static readonly snow: BlockType; - /** - * Represents a layer of snow within Minecraft. - */ - static readonly snowLayer: BlockType; - /** - * Represents a soul campfire within Minecraft. - */ - static readonly soulCampfire: BlockType; - /** - * Represents soul fire within Minecraft. - */ - static readonly soulFire: BlockType; - /** - * Represents a soul lantern within Minecraft. - */ - static readonly soulLantern: BlockType; - /** - * Represents a block of soul sand within Minecraft. - */ - static readonly soulSand: BlockType; - /** - * Represents soul soil within Minecraft. - */ - static readonly soulSoil: BlockType; - /** - * Represents a soul torch within Minecraft. - */ - static readonly soulTorch: BlockType; - /** - * Represents a sponge within Minecraft. - */ - static readonly sponge: BlockType; - /** - * Represents a spore blossom within Minecraft. - */ - static readonly sporeBlossom: BlockType; - /** - * Represents a spruce wood button within Minecraft. - */ - static readonly spruceButton: BlockType; - /** - * Represents a spruce wood door within Minecraft. - */ - static readonly spruceDoor: BlockType; - /** - * Represents a spruce wood fence gate within Minecraft. - */ - static readonly spruceFenceGate: BlockType; - static readonly spruceHangingSign: BlockType; - /** - * Represents a spruce wood pressure plate within Minecraft. - */ - static readonly sprucePressurePlate: BlockType; - /** - * Represents a set of spruce wood stairs within Minecraft. - */ - static readonly spruceStairs: BlockType; - /** - * Represents a spruce wood standing sign within Minecraft. - */ - static readonly spruceStandingSign: BlockType; - /** - * Represents a spruce wood trapdoor within Minecraft. - */ - static readonly spruceTrapdoor: BlockType; - /** - * Represents a spruce wood wall sign within Minecraft. - */ - static readonly spruceWallSign: BlockType; - /** - * Represents stained glass within Minecraft. - */ - static readonly stainedGlass: BlockType; - /** - * Represents a pane of stained glass within Minecraft. - */ - static readonly stainedGlassPane: BlockType; - /** - * Represents a block of stained hardened clay within - * Minecraft. - */ - static readonly stainedHardenedClay: BlockType; - /** - * Represents a standing banner within Minecraft. - */ - static readonly standingBanner: BlockType; - /** - * Represents a standing sign within Minecraft. - */ - static readonly standingSign: BlockType; - /** - * Represents a piston block with a sticky arm within - * Minecraft. - */ - static readonly stickyPiston: BlockType; - static readonly stickyPistonArmCollision: BlockType; - /** - * Represents a block of stone within Minecraft. - */ - static readonly stone: BlockType; - static readonly stoneBlockSlab: BlockType; - static readonly stoneBlockSlab2: BlockType; - static readonly stoneBlockSlab3: BlockType; - static readonly stoneBlockSlab4: BlockType; - /** - * Represents a block of stone brick within Minecraft. - */ - static readonly stonebrick: BlockType; - /** - * Represents a set of stone brick stairs within Minecraft. - */ - static readonly stoneBrickStairs: BlockType; - /** - * Represents a stone button within Minecraft. - */ - static readonly stoneButton: BlockType; - /** - * Represents a stonecutter within Minecraft. - */ - static readonly stonecutter: BlockType; - /** - * Represents a stonecutter block within Minecraft. - */ - static readonly stonecutterBlock: BlockType; - /** - * Represents a stone pressure plate within Minecraft. - */ - static readonly stonePressurePlate: BlockType; - /** - * Represents a slab of stone within Minecraft. - */ - static readonly stoneSlab: BlockType; - /** - * Represents a variant of a slab of stone (#2) within - * Minecraft. - */ - static readonly stoneSlab2: BlockType; - /** - * Represents a slab of stone (variant #3) within Minecraft. - */ - static readonly stoneSlab3: BlockType; - /** - * Represents a slab of stone (variant #4) within Minecraft. - */ - static readonly stoneSlab4: BlockType; - /** - * Represents a set of stone stairs within Minecraft. - */ - static readonly stoneStairs: BlockType; - /** - * Represents a stripped acacia log within Minecraft. - */ - static readonly strippedAcaciaLog: BlockType; - static readonly strippedBambooBlock: BlockType; - /** - * Represents a stripped birch log within Minecraft. - */ - static readonly strippedBirchLog: BlockType; - /** - * Represents stripped crimson hyphae within Minecraft. - */ - static readonly strippedCrimsonHyphae: BlockType; - /** - * Represents a stripped crimson stem within Minecraft. - */ - static readonly strippedCrimsonStem: BlockType; - /** - * Represents a stripped dark oak log within Minecraft. - */ - static readonly strippedDarkOakLog: BlockType; - /** - * Represents a stripped jungle log within Minecraft. - */ - static readonly strippedJungleLog: BlockType; - static readonly strippedMangroveLog: BlockType; - static readonly strippedMangroveWood: BlockType; - /** - * Represents a stripped oak log within Minecraft. - */ - static readonly strippedOakLog: BlockType; - /** - * Represents a stripped spruce log within Minecraft. - */ - static readonly strippedSpruceLog: BlockType; - /** - * Represents stripped warped hyphae within Minecraft. - */ - static readonly strippedWarpedHyphae: BlockType; - /** - * Represents stripped warped stem within Minecraft. - */ - static readonly strippedWarpedStem: BlockType; - /** - * Represents a structure block, which provides for the saving - * and loading of block structures, within Minecraft. - */ - static readonly structureBlock: BlockType; - /** - * Represents a structure void within Minecraft. - */ - static readonly structureVoid: BlockType; - static readonly suspiciousSand: BlockType; - /** - * Represents a sweet berry bush within Minecraft. - */ - static readonly sweetBerryBush: BlockType; - /** - * Represents tall grass within Minecraft. - */ - static readonly tallgrass: BlockType; - /** - * Represents a target within Minecraft. - */ - static readonly target: BlockType; - /** - * Represents tinted glass within Minecraft. - */ - static readonly tintedGlass: BlockType; - /** - * Represents a block of TnT within Minecraft. - */ - static readonly tnt: BlockType; - /** - * Represents a torch within Minecraft. - */ - static readonly torch: BlockType; - static readonly torchflower: BlockType; - static readonly torchflowerCrop: BlockType; - /** - * Represents a trapdoor within Minecraft. - */ - static readonly trapdoor: BlockType; - /** - * Represents a trapped chest within Minecraft. - */ - static readonly trappedChest: BlockType; - static readonly tripWire: BlockType; - /** - * Represents a tripwire hook within Minecraft. - */ - static readonly tripwireHook: BlockType; - /** - * Represents a block of tuff within Minecraft. - */ - static readonly tuff: BlockType; - /** - * Represents a turtle egg within Minecraft. - */ - static readonly turtleEgg: BlockType; - /** - * Represents a set of twisting vines within Minecraft. - */ - static readonly twistingVines: BlockType; - /** - * Represents an underwater torch within Minecraft. - */ - static readonly underwaterTorch: BlockType; - /** - * Represents an undyed shulker box within Minecraft. - */ - static readonly undyedShulkerBox: BlockType; - /** - * Represents an unknown block within Minecraft. - */ - static readonly unknown: BlockType; - /** - * Represents an unlit redstone torch within Minecraft. - */ - static readonly unlitRedstoneTorch: BlockType; - /** - * Represents an unpowered comparator within Minecraft. - */ - static readonly unpoweredComparator: BlockType; - /** - * Represents an unpowered repeater within Minecraft. - */ - static readonly unpoweredRepeater: BlockType; - static readonly verdantFroglight: BlockType; - /** - * Represents a set of vines within Minecraft. - */ - static readonly vine: BlockType; - /** - * Represents a wall banner within Minecraft. - */ - static readonly wallBanner: BlockType; - /** - * Represents a wall sign within Minecraft. - */ - static readonly wallSign: BlockType; - /** - * Represents a warped button within Minecraft. - */ - static readonly warpedButton: BlockType; - /** - * Represents a warped door within Minecraft. - */ - static readonly warpedDoor: BlockType; - /** - * Represents a double slab of warped within Minecraft. - */ - static readonly warpedDoubleSlab: BlockType; - /** - * Represents a warped fence within Minecraft. - */ - static readonly warpedFence: BlockType; - /** - * Represents a warped fence gate within Minecraft. - */ - static readonly warpedFenceGate: BlockType; - /** - * Represents warped fungus within Minecraft. - */ - static readonly warpedFungus: BlockType; - static readonly warpedHangingSign: BlockType; - /** - * Represents warped hyphae within Minecraft. - */ - static readonly warpedHyphae: BlockType; - /** - * Represents warped nylium within Minecraft. - */ - static readonly warpedNylium: BlockType; - /** - * Represents warped planks within Minecraft. - */ - static readonly warpedPlanks: BlockType; - /** - * Represents a warped pressure plate within Minecraft. - */ - static readonly warpedPressurePlate: BlockType; - /** - * Represents a set of warped roots within Minecraft. - */ - static readonly warpedRoots: BlockType; - /** - * Represents a slab of warped material within Minecraft. - */ - static readonly warpedSlab: BlockType; - /** - * Represents a set of warped stairs within Minecraft. - */ - static readonly warpedStairs: BlockType; - /** - * Represents a warped standing sign within Minecraft. - */ - static readonly warpedStandingSign: BlockType; - /** - * Represents a warped stem within Minecraft. - */ - static readonly warpedStem: BlockType; - /** - * Represents a warped trapdoor within Minecraft. - */ - static readonly warpedTrapdoor: BlockType; - /** - * Represents a warped wall sign within Minecraft. - */ - static readonly warpedWallSign: BlockType; - /** - * Represents a warped wart block within Minecraft. - */ - static readonly warpedWartBlock: BlockType; - /** - * Represents water within Minecraft. - */ - static readonly water: BlockType; - /** - * Represents a water lily within Minecraft. - */ - static readonly waterlily: BlockType; - /** - * Represents a block of waxed copper within Minecraft. - */ - static readonly waxedCopper: BlockType; - /** - * Represents a block of waxed cut copper within Minecraft. - */ - static readonly waxedCutCopper: BlockType; - /** - * Represents a slab of waxed cut copper within Minecraft. - */ - static readonly waxedCutCopperSlab: BlockType; - /** - * Represents a set of waxed cut copper stairs within - * Minecraft. - */ - static readonly waxedCutCopperStairs: BlockType; - /** - * Represents a double slab of waxed cut copper within - * Minecraft. - */ - static readonly waxedDoubleCutCopperSlab: BlockType; - /** - * Represents a block of waxed exposed copper within Minecraft. - */ - static readonly waxedExposedCopper: BlockType; - /** - * Represents a block of waxed exposed cut copper within - * Minecraft. - */ - static readonly waxedExposedCutCopper: BlockType; - /** - * Represents a slab of waxed exposed cut copper within - * Minecraft. - */ - static readonly waxedExposedCutCopperSlab: BlockType; - /** - * Represents a set of waxed exposed cut copper stairs within - * Minecraft. - */ - static readonly waxedExposedCutCopperStairs: BlockType; - /** - * Represents a double slab of waxed exposed cut copper within - * Minecraft. - */ - static readonly waxedExposedDoubleCutCopperSlab: BlockType; - /** - * Represents a block of waxed oxidized copper within - * Minecraft. - */ - static readonly waxedOxidizedCopper: BlockType; - /** - * Represents a block of waxed oxidized cut copper within - * Minecraft. - */ - static readonly waxedOxidizedCutCopper: BlockType; - /** - * Represents a slab of waxed oxidized cut copper within - * Minecraft. - */ - static readonly waxedOxidizedCutCopperSlab: BlockType; - /** - * Represents a set of waxed oxidized cut copper stairs within - * Minecraft. - */ - static readonly waxedOxidizedCutCopperStairs: BlockType; - /** - * Represents a double slab of waxed oxidized cut copper within - * Minecraft. - */ - static readonly waxedOxidizedDoubleCutCopperSlab: BlockType; - /** - * Represents a block of waxed weathered copper within - * Minecraft. - */ - static readonly waxedWeatheredCopper: BlockType; +// @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(); /** - * Represents a block of waxed weathered cut copper within - * Minecraft. + * @remarks + * Speed in effect when the entity is turning. + * + * @throws This property can throw when used. */ - static readonly waxedWeatheredCutCopper: BlockType; + readonly speedWhenTurning: number; /** - * Represents a slab of waxed weathered cut copper within - * Minecraft. + * @remarks + * Start speed during a glide. + * + * @throws This property can throw when used. */ - static readonly waxedWeatheredCutCopperSlab: BlockType; + readonly startSpeed: number; + static readonly componentId = 'minecraft:movement.glide'; +} + +/** + * 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'; +} + +/** + * @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(); /** - * Represents a set of waxed weathered cut copper stairs within - * Minecraft. + * @remarks + * Amplitude of the sway motion. + * + * @throws This property can throw when used. */ - static readonly waxedWeatheredCutCopperStairs: BlockType; + readonly swayAmplitude: number; /** - * Represents a double slab of waxed weathered cut copper - * within Minecraft. + * @remarks + * Amount of sway frequency. + * + * @throws This property can throw when used. */ - static readonly waxedWeatheredDoubleCutCopperSlab: BlockType; + 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(); /** - * Represents a block of weathered copper within Minecraft. + * @remarks + * Tells the pathfinder to avoid blocks that cause damage when + * finding a path. + * + * @throws This property can throw when used. */ - static readonly weatheredCopper: BlockType; + readonly avoidDamageBlocks: boolean; /** - * Represents a block of weathered cut copper within Minecraft. + * @remarks + * Tells the pathfinder to avoid portals (like nether portals) + * when finding a path. + * + * @throws This property can throw when used. */ - static readonly weatheredCutCopper: BlockType; + readonly avoidPortals: boolean; /** - * Represents a slab of weathered cut copper within Minecraft. + * @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. */ - static readonly weatheredCutCopperSlab: BlockType; + readonly avoidSun: boolean; /** - * Represents a set of weathered cut copper stairs within - * Minecraft. + * @remarks + * Tells the pathfinder to avoid water when creating a path. + * + * @throws This property can throw when used. */ - static readonly weatheredCutCopperStairs: BlockType; + readonly avoidWater: boolean; /** - * Represents a double slab of weathered cut copper within - * Minecraft. + * @remarks + * Tells the pathfinder whether or not it can jump out of water + * (like a dolphin). + * + * @throws This property can throw when used. */ - static readonly weatheredDoubleCutCopperSlab: BlockType; + readonly canBreach: boolean; /** - * Represents a web within Minecraft. + * @remarks + * Tells the pathfinder that it can path through a closed door + * and break it. + * + * @throws This property can throw when used. */ - static readonly web: BlockType; + readonly canBreakDoors: boolean; /** - * Represents a set of weeping vines within Minecraft. + * @remarks + * Tells the pathfinder whether or not it can float. + * + * @throws This property can throw when used. */ - static readonly weepingVines: BlockType; + readonly canFloat: boolean; /** - * Represents wheat within Minecraft. + * @remarks + * Tells the pathfinder whether or not it can jump up blocks. + * + * @throws This property can throw when used. */ - static readonly wheat: BlockType; + readonly canJump: boolean; /** - * Represents a white candle within Minecraft. + * @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. */ - static readonly whiteCandle: BlockType; + readonly canOpenDoors: boolean; /** - * Represents a white candle cake within Minecraft. + * @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. */ - static readonly whiteCandleCake: BlockType; + readonly canOpenIronDoors: boolean; /** - * Represents a block of white glazed terracotta within - * Minecraft. + * @remarks + * Whether a path can be created through a door. + * + * @throws This property can throw when used. */ - static readonly whiteGlazedTerracotta: BlockType; - static readonly whiteWool: BlockType; + readonly canPassDoors: boolean; /** - * Represents a wither rose within Minecraft. + * @remarks + * Tells the pathfinder that it can start pathing when in the + * air. + * + * @throws This property can throw when used. */ - static readonly witherRose: BlockType; + readonly canPathFromAir: boolean; /** - * Represents a block of wood within Minecraft. + * @remarks + * Tells the pathfinder whether or not it can travel on the + * surface of the lava. + * + * @throws This property can throw when used. */ - static readonly wood: BlockType; + readonly canPathOverLava: boolean; /** - * Represents a wooden button within Minecraft. + * @remarks + * Tells the pathfinder whether or not it can travel on the + * surface of the water. + * + * @throws This property can throw when used. */ - static readonly woodenButton: BlockType; + readonly canPathOverWater: boolean; /** - * Represents a wooden door within Minecraft. + * @remarks + * Tells the pathfinder whether or not it will be pulled down + * by gravity while in water. + * + * @throws This property can throw when used. */ - static readonly woodenDoor: BlockType; + readonly canSink: boolean; /** - * Represents a wooden pressure plate within Minecraft. + * @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. */ - static readonly woodenPressurePlate: BlockType; + readonly canSwim: boolean; /** - * Represents a wooden slab within Minecraft. + * @remarks + * Tells the pathfinder whether or not it can walk on the + * ground outside water. + * + * @throws This property can throw when used. */ - static readonly woodenSlab: BlockType; + readonly canWalk: boolean; /** - * Represents a yellow candle within Minecraft. + * @remarks + * Tells the pathfinder whether or not it can travel in lava + * like walking on ground. + * + * @throws This property can throw when used. */ - static readonly yellowCandle: BlockType; + readonly canWalkInLava: boolean; /** - * Represents a yellow candle cake within Minecraft. + * @remarks + * Tells the pathfinder whether or not it can walk on the + * ground or go underwater. + * + * @throws This property can throw when used. */ - static readonly yellowCandleCake: BlockType; + 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 + * Adds NPC capabilities to an entity such as custom skin, + * name, and dialogue interactions. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityNpcComponent extends EntityComponent { + private constructor(); /** - * Represents a yellow flower within Minecraft. + * @remarks + * The DialogueScene that is opened when players first interact + * with the NPC. + * + * This property can't be edited in read-only mode. + * */ - static readonly yellowFlower: BlockType; + defaultScene: string; /** - * Represents a yellow block of glazed terracotta within - * Minecraft. + * @remarks + * The name of the NPC as it is displayed to players. + * + * This property can't be edited in read-only mode. + * */ - static readonly yellowGlazedTerracotta: BlockType; - static readonly yellowWool: BlockType; + name: string; /** * @remarks - * Returns a specific Minecraft block type given a type id. - * @param typeName + * The index of the skin the NPC will use. + * + * This property can't be edited in read-only mode. + * */ - static get(typeName: string): BlockType; + skinIndex: number; + static readonly componentId = 'minecraft:npc'; +} + +/** + * When present on an entity, this entity is on fire. + * @example setEntityOnFire.ts + * ```typescript + * import { world, Entity, EntityComponentTypes, system } from "@minecraft/server"; + * + * function setAblaze(entity: Entity) { + * entity.setOnFire(20, true); + * + * system.runTimeout(() => { + * const onfire = entity.getComponent(EntityComponentTypes.OnFire); + * if (onfire) { + * world.sendMessage(`${onfire.onFireTicksRemaining} fire ticks remaining, extinguishing the entity.`); + * } + * // This will extinguish the entity + * entity.extinguishFire(true); + * }, 30); // Run in 30 ticks or ~1.5 seconds + * + * } + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityOnFireComponent extends EntityComponent { + private constructor(); /** * @remarks - * Returns an array of all block types within Minecraft. + * The number of ticks remaining before the fire goes out. + * */ - static getAllBlockTypes(): BlockType[]; + readonly onFireTicksRemaining: number; + static readonly componentId = 'minecraft:onfire'; } + /** - * A collection of default Minecraft dimension types. + * The projectile component controls the properties of a + * projectile entity and allows it to be shot in a given + * direction. + * This component is present when the entity has the + * minecraft:projectile component. + * @example shootArrow.ts + * ```typescript + * import { world, Vector3 } from '@minecraft/server'; + * + * const location: Vector3 = { x: 0, y: -59, z: 0 }; // Replace with the coordinates of where you want to spawn the arrow + * const velocity: Vector3 = { x: 0, y: 0, z: 5 }; + * const arrow = world.getDimension('overworld').spawnEntity('minecraft:arrow', location); + * const projectileComp = arrow.getComponent('minecraft:projectile'); + * projectileComp?.shoot(velocity); + * ``` */ -// tslint:disable-next-line:no-unnecessary-class -export class MinecraftDimensionTypes { - protected constructor(); +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityProjectileComponent extends EntityComponent { + private constructor(); /** - * 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. + * @remarks + * The fraction of the projectile's speed maintained every tick + * while traveling through air. + * + * This property can't be edited in read-only mode. + * */ - static readonly nether = 'minecraft:nether'; + airInertia: number; /** - * 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. + * @remarks + * If true, the entity will be set on fire when hurt. The + * default burn duration is 5 seconds. This duration can be + * modified via the onFireTime property. The entity will not + * catch fire if immune or if the entity is wet. + * + * This property can't be edited in read-only mode. + * */ - static readonly overworld = 'minecraft:overworld'; + catchFireOnHurt: boolean; /** - * 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. + * @remarks + * If true, the projectile will spawn crit particles when hit + * by a player. E.g. Player attacking a Shulker bullet. + * + * This property can't be edited in read-only mode. + * */ - static readonly theEnd = 'minecraft:the_end'; -} -/** - * @beta - * Returns available installed effect types within Minecraft. - */ -// tslint:disable-next-line:no-unnecessary-class -export class MinecraftEffectTypes { - protected constructor(); - static readonly absorption: EffectType; - static readonly badOmen: EffectType; - static readonly blindness: EffectType; - static readonly conduitPower: EffectType; - static readonly darkness: EffectType; - static readonly empty: EffectType; - static readonly fatalPoison: EffectType; - static readonly fireResistance: EffectType; - static readonly haste: EffectType; - static readonly healthBoost: EffectType; - static readonly hunger: EffectType; - static readonly instantDamage: EffectType; - static readonly instantHealth: EffectType; - static readonly invisibility: EffectType; - static readonly jumpBoost: EffectType; - static readonly levitation: EffectType; - static readonly miningFatigue: EffectType; - static readonly nausea: EffectType; - static readonly nightVision: EffectType; - static readonly poison: EffectType; - static readonly regeneration: EffectType; - static readonly resistance: EffectType; - static readonly saturation: EffectType; - static readonly slowFalling: EffectType; - static readonly slowness: EffectType; - static readonly speed: EffectType; - static readonly strength: EffectType; - static readonly villageHero: EffectType; - static readonly waterBreathing: EffectType; - static readonly weakness: EffectType; - static readonly wither: EffectType; -} -/** - * @beta - * Describes a set of enchantment types. - */ -// tslint:disable-next-line:no-unnecessary-class -export class MinecraftEnchantmentTypes { - protected constructor(); - static readonly aquaAffinity: EnchantmentType; - static readonly baneOfArthropods: EnchantmentType; - static readonly binding: EnchantmentType; - static readonly blastProtection: EnchantmentType; - static readonly channeling: EnchantmentType; - static readonly depthStrider: EnchantmentType; - static readonly efficiency: EnchantmentType; - static readonly featherFalling: EnchantmentType; - static readonly fireAspect: EnchantmentType; - static readonly fireProtection: EnchantmentType; - static readonly flame: EnchantmentType; - static readonly fortune: EnchantmentType; - static readonly frostWalker: EnchantmentType; - static readonly impaling: EnchantmentType; - static readonly infinity: EnchantmentType; - static readonly knockback: EnchantmentType; - static readonly looting: EnchantmentType; - static readonly loyalty: EnchantmentType; - static readonly luckOfTheSea: EnchantmentType; - static readonly lure: EnchantmentType; - static readonly mending: EnchantmentType; - static readonly multishot: EnchantmentType; - static readonly piercing: EnchantmentType; - static readonly power: EnchantmentType; - static readonly projectileProtection: EnchantmentType; - static readonly protection: EnchantmentType; - static readonly punch: EnchantmentType; - static readonly quickCharge: EnchantmentType; - static readonly respiration: EnchantmentType; - static readonly riptide: EnchantmentType; - static readonly sharpness: EnchantmentType; - static readonly silkTouch: EnchantmentType; - static readonly smite: EnchantmentType; - static readonly soulSpeed: EnchantmentType; - static readonly swiftSneak: EnchantmentType; - static readonly thorns: EnchantmentType; - static readonly unbreaking: EnchantmentType; - static readonly vanishing: EnchantmentType; -} -// tslint:disable-next-line:no-unnecessary-class -export class MinecraftEntityTypes { - protected constructor(); - static readonly agent: EntityType; - static readonly allay: EntityType; - static readonly areaEffectCloud: EntityType; - static readonly armorStand: EntityType; - static readonly arrow: EntityType; - static readonly axolotl: EntityType; - static readonly bat: EntityType; - static readonly bee: EntityType; - static readonly blaze: EntityType; - static readonly boat: EntityType; - static readonly cat: EntityType; - static readonly caveSpider: EntityType; - static readonly chestBoat: EntityType; - static readonly chestMinecart: EntityType; - static readonly chicken: EntityType; - static readonly cod: EntityType; - static readonly commandBlockMinecart: EntityType; - static readonly cow: EntityType; - static readonly creeper: EntityType; - static readonly dolphin: EntityType; - static readonly donkey: EntityType; - static readonly dragonFireball: EntityType; - static readonly drowned: EntityType; - static readonly egg: EntityType; - static readonly elderGuardian: EntityType; - static readonly enderCrystal: EntityType; - static readonly enderDragon: EntityType; - static readonly enderman: EntityType; - static readonly endermite: EntityType; - static readonly enderPearl: EntityType; - static readonly evocationIllager: EntityType; - static readonly eyeOfEnderSignal: EntityType; - static readonly fireball: EntityType; - static readonly fireworksRocket: EntityType; - static readonly fishingHook: EntityType; - static readonly fox: EntityType; - static readonly frog: EntityType; - static readonly ghast: EntityType; - static readonly glowSquid: EntityType; - static readonly goat: EntityType; - static readonly guardian: EntityType; - static readonly hoglin: EntityType; - static readonly hopperMinecart: EntityType; - static readonly horse: EntityType; - static readonly husk: EntityType; - static readonly ironGolem: EntityType; - static readonly lightningBolt: EntityType; - static readonly lingeringPotion: EntityType; - static readonly llama: EntityType; - static readonly llamaSpit: EntityType; - static readonly magmaCube: EntityType; - static readonly minecart: EntityType; - static readonly mooshroom: EntityType; - static readonly mule: EntityType; - static readonly npc: EntityType; - static readonly ocelot: EntityType; - static readonly panda: EntityType; - static readonly parrot: EntityType; - static readonly phantom: EntityType; - static readonly pig: EntityType; - static readonly piglin: EntityType; - static readonly piglinBrute: EntityType; - static readonly pillager: EntityType; - static readonly player: EntityType; - static readonly polarBear: EntityType; - static readonly pufferfish: EntityType; - static readonly rabbit: EntityType; - static readonly ravager: EntityType; - static readonly salmon: EntityType; - static readonly sheep: EntityType; - static readonly shulker: EntityType; - static readonly shulkerBullet: EntityType; - static readonly silverfish: EntityType; - static readonly skeleton: EntityType; - static readonly skeletonHorse: EntityType; - static readonly slime: EntityType; - static readonly smallFireball: EntityType; - static readonly snowball: EntityType; - static readonly snowGolem: EntityType; - static readonly spider: EntityType; - static readonly splashPotion: EntityType; - static readonly squid: EntityType; - static readonly stray: EntityType; - static readonly strider: EntityType; - static readonly tadpole: EntityType; - static readonly thrownTrident: EntityType; - static readonly tnt: EntityType; - static readonly tntMinecart: EntityType; - static readonly traderLlama: EntityType; - static readonly tripodCamera: EntityType; - static readonly tropicalfish: EntityType; - static readonly turtle: EntityType; - static readonly vex: EntityType; - static readonly villager: EntityType; - static readonly villagerV2: EntityType; - static readonly vindicator: EntityType; - static readonly wanderingTrader: EntityType; - static readonly warden: EntityType; - static readonly witch: EntityType; - static readonly wither: EntityType; - static readonly witherSkeleton: EntityType; - static readonly witherSkull: EntityType; - static readonly witherSkullDangerous: EntityType; - static readonly wolf: EntityType; - static readonly xpBottle: EntityType; - static readonly xpOrb: EntityType; - static readonly zoglin: EntityType; - static readonly zombie: EntityType; - static readonly zombieHorse: EntityType; - static readonly zombiePigman: EntityType; - static readonly zombieVillager: EntityType; - static readonly zombieVillagerV2: EntityType; -} -/** - * @beta - * Contains definitions of standard Minecraft and Minecraft - * Education Edition block types. - */ -// tslint:disable-next-line:no-unnecessary-class -export class MinecraftItemTypes { - protected constructor(); - static readonly acaciaBoat: ItemType; - /** - * Represents an item that can place an acacia button within - * Minecraft. + critParticlesOnProjectileHurt: boolean; + /** + * @remarks + * If true, the projectile will be destroyed when it takes + * damage. E.g. Player attacking a Shulker bullet. + * + * This property can't be edited in read-only mode. + * */ - static readonly acaciaButton: ItemType; - static readonly acaciaChestBoat: ItemType; + destroyOnProjectileHurt: boolean; /** - * Represents an item that can place an acacia door within - * Minecraft. + * @remarks + * The gravity applied to the projectile. When the entity is + * not on the ground, subtracts this amount from the + * projectile’s change in vertical position every tick. The + * higher the value, the faster the projectile falls. If + * negative, the entity will rise instead of fall. + * + * This property can't be edited in read-only mode. + * */ - static readonly acaciaDoor: ItemType; + gravity: number; /** - * Represents an item that can place an acacia fence gate - * within Minecraft. + * @remarks + * The sound that plays when the projectile hits an entity. + * + * This property can't be edited in read-only mode. + * */ - static readonly acaciaFenceGate: ItemType; + hitEntitySound?: string; /** - * Represents an item that can place an acacia pressure plate - * within Minecraft. + * @remarks + * The sound that plays when the projectile hits a block. + * + * This property can't be edited in read-only mode. + * */ - static readonly acaciaPressurePlate: ItemType; + hitGroundSound?: string; /** - * Represents an item that can place an acacia sign within - * Minecraft. + * @remarks + * The particle that spawns when the projectile hits something. + * + * This property can't be edited in read-only mode. + * */ - static readonly acaciaSign: ItemType; + hitParticle?: string; /** - * Represents an item that can place a set of acacia stairs - * within Minecraft. + * @remarks + * If true and the weather is thunder and the entity has line + * of sight to the sky, the entity will be struck by lightning + * when hit. E.g. A thrown Trident with the Channeling + * enchantment. + * + * This property can't be edited in read-only mode. + * */ - static readonly acaciaStairs: ItemType; + lightningStrikeOnHit: boolean; /** - * Represents an item that can place an acacia trapdoor within - * Minecraft. + * @remarks + * The fraction of the projectile's speed maintained every tick + * while traveling through a liquid. + * + * This property can't be edited in read-only mode. + * */ - static readonly acaciaTrapdoor: ItemType; + liquidInertia: number; /** - * Represents an item that can place an activator rail within - * Minecraft. + * @remarks + * Duration in seconds that the entity hit will be on fire for + * when catchFireOnHurt is set to true. + * + * This property can't be edited in read-only mode. + * */ - static readonly activatorRail: ItemType; - static readonly allaySpawnEgg: ItemType; + onFireTime: number; /** - * Represents an item that can place an allow block within - * Minecraft. + * @remarks + * The owner of the projectile. This is used to determine what + * the projectile can collide with and damage. It also + * determines which entity is assigned as the attacker. + * + * This property can't be edited in read-only mode. + * */ - static readonly allow: ItemType; + owner?: Entity; /** - * Represents an item that can place an amethyst block within - * Minecraft. + * @remarks + * If true, the projectile will bounce off mobs when no damage + * is taken. E.g. A spawning wither. + * + * This property can't be edited in read-only mode. + * */ - static readonly amethystBlock: ItemType; + shouldBounceOnHit: boolean; /** - * Represents an item that can place a cluster of amethyst - * within Minecraft. + * @remarks + * If true, the projectile will stop moving when an entity is + * hit as thought it had been blocked. E.g. Thrown trident on + * hit behavior. + * + * This property can't be edited in read-only mode. + * */ - static readonly amethystCluster: ItemType; - static readonly amethystShard: ItemType; + stopOnHit: boolean; + static readonly componentId = 'minecraft:projectile'; /** - * Represents an item that can place ancient debris within - * Minecraft. + * @remarks + * Shoots the projectile with a given velocity. The projectile + * will be shot from its current location. + * + * This function can't be called in read-only mode. + * + * @param velocity + * The velocity to fire the projectile. This controls both the + * speed and direction which which the projectile will be shot. + * @param options + * Optional configuration for the shoot. + * @throws + * Throws if the component or entity no longer exist. */ - static readonly ancientDebris: ItemType; + shoot(velocity: Vector3, options?: ProjectileShootOptions): void; +} + +/** + * 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(); /** - * Represents an item that can place andesite stairs within - * Minecraft. + * @remarks + * Value of the push through distances of this entity. + * + * This property can't be edited in read-only mode. + * */ - static readonly andesiteStairs: ItemType; + value: number; + static readonly componentId = 'minecraft:push_through'; +} + +/** + * 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(); /** - * Represents an item that can place an anvil within Minecraft. + * @remarks + * Id of the entity that was removed. + * */ - static readonly anvil: ItemType; - static readonly apple: ItemType; - static readonly armorStand: ItemType; - static readonly arrow: ItemType; - static readonly axolotlBucket: ItemType; - static readonly axolotlSpawnEgg: ItemType; + readonly removedEntityId: string; /** - * Represents an item that can place an azalea flowering plant - * within Minecraft. + * @remarks + * Identifier of the type of the entity removed - for example, + * 'minecraft:skeleton'. + * */ - static readonly azalea: ItemType; + readonly typeId: string; +} + +/** + * 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(); /** - * Represents an item that can place azalea leaves within - * Minecraft. + * @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. */ - static readonly azaleaLeaves: ItemType; + subscribe( + callback: (arg: EntityRemoveAfterEvent) => void, + options?: EntityEventOptions, + ): (arg: EntityRemoveAfterEvent) => void; /** - * Represents flowered azalea leaves within Minecraft. + * @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. */ - static readonly azaleaLeavesFlowered: ItemType; - static readonly bakedPotato: ItemType; + unsubscribe(callback: (arg: EntityRemoveAfterEvent) => void): void; +} + +/** + * 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(); /** - * Represents an item that can place a bamboo tree within - * Minecraft. + * @remarks + * Reference to an entity that is being removed. + * */ - static readonly bamboo: ItemType; - static readonly banner: ItemType; - static readonly bannerPattern: ItemType; + readonly removedEntity: Entity; +} + +/** + * 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(); /** - * Represents an item that can place a barrel within Minecraft. + * @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. */ - static readonly barrel: ItemType; + subscribe(callback: (arg: EntityRemoveBeforeEvent) => void): (arg: EntityRemoveBeforeEvent) => void; /** - * Represents an item that can place an invisible but logical - * barrier within Minecraft. + * @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. */ - static readonly barrier: ItemType; + 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(); /** - * Represents an item that can place a basalt block within - * Minecraft. + * @remarks + * Zero-based index of the seat that can used to control this + * entity. + * + * @throws This property can throw when used. */ - static readonly basalt: ItemType; - static readonly batSpawnEgg: ItemType; + readonly controllingSeat: number; /** - * Represents an item that can place a beacon within Minecraft. + * @remarks + * Determines whether interactions are not supported if the + * entity is crouching. + * + * @throws This property can throw when used. */ - static readonly beacon: ItemType; + readonly crouchingSkipInteract: boolean; /** - * Represents an item that can place a bed within Minecraft. + * @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. */ - static readonly bed: ItemType; + readonly interactText: string; /** - * Represents an item that can place a bedrock block within - * Minecraft. + * @remarks + * The max width a mob can be to be a passenger. + * + * @throws This property can throw when used. */ - static readonly bedrock: ItemType; - static readonly beef: ItemType; + readonly passengerMaxWidth: number; /** - * Represents an item that can place a beehive within - * Minecraft. + * @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. */ - static readonly beehive: ItemType; + readonly pullInEntities: boolean; /** - * Represents an item that can place a bee nest within - * Minecraft. + * @remarks + * If true, this entity will be picked when looked at by the + * rider. + * + * @throws This property can throw when used. */ - static readonly beeNest: ItemType; - static readonly beeSpawnEgg: ItemType; + readonly riderCanInteract: boolean; /** - * Represents an item that can place a beetroot vegetable - * within Minecraft. + * @remarks + * Number of seats for riders defined for this entity. + * + * @throws This property can throw when used. */ - static readonly beetroot: ItemType; - static readonly beetrootSeeds: ItemType; - static readonly beetrootSoup: ItemType; + readonly seatCount: number; + static readonly componentId = 'minecraft:rideable'; /** - * Represents an item that can place a bell within Minecraft. + * @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. */ - static readonly bell: ItemType; + addRider(rider: Entity): boolean; /** - * Represents an item that can place a big dripleaf plant - * within Minecraft. + * @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. */ - static readonly bigDripleaf: ItemType; - static readonly birchBoat: ItemType; + ejectRider(rider: Entity): void; /** - * Represents an item that can place a birch button within - * Minecraft. + * @remarks + * Ejects all riders of this entity. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly birchButton: ItemType; - static readonly birchChestBoat: ItemType; + ejectRiders(): void; /** - * Represents an item that can place a birch door within - * Minecraft. + * @remarks + * A string-list of entity types that this entity can support + * as riders. + * + * @throws This function can throw errors. */ - static readonly birchDoor: ItemType; + getFamilyTypes(): string[]; /** - * Represents an item that can place a birch fence gate within - * Minecraft. + * @remarks + * Gets a list of the all the entities currently riding this + * entity. + * + * @throws This function can throw errors. */ - static readonly birchFenceGate: ItemType; + getRiders(): Entity[]; /** - * Represents an item that can place a birch pressure plate - * within Minecraft. + * @remarks + * Gets a list of positions and number of riders for each + * position for entities riding this entity. + * + * @throws This function can throw errors. */ - static readonly birchPressurePlate: ItemType; + 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(); /** - * Represents an item that can place a birch sign within - * Minecraft. + * @remarks + * The entity this entity is currently riding on. + * + * @throws This property can throw when used. */ - static readonly birchSign: ItemType; + readonly entityRidingOn: Entity; + static readonly componentId = 'minecraft:riding'; +} + +/** + * Sets the entity's visual size. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityScaleComponent extends EntityComponent { + private constructor(); /** - * Represents an item that can place a birch stairs block - * within Minecraft. + * @remarks + * Current value for the scale property set on entities. + * + * This property can't be edited in read-only mode. + * */ - static readonly birchStairs: ItemType; + 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(); /** - * Represents an item that can place a birch trapdoor within - * Minecraft. + * @remarks + * Returns the value of the skin Id identifier of the entity. + * + * This property can't be edited in read-only mode. + * */ - static readonly birchTrapdoor: ItemType; + value: number; + static readonly componentId = 'minecraft:skin_id'; +} + +/** + * Contains data related to an entity spawning within the + * world. + * @example logEntitySpawnEvents.ts + * ```typescript + * // Register a new function that is called when a new entity is created. + * import { world, EntitySpawnAfterEvent } from '@minecraft/server'; + * + * world.afterEvents.entitySpawn.subscribe((entityEvent: EntitySpawnAfterEvent) => { + * const spawnLocation = entityEvent.entity.location; + * world.sendMessage( + * `New entity of type '${entityEvent.entity.typeId}' spawned at ${spawnLocation.x}, ${spawnLocation.y}, ${spawnLocation.z}!`, + * ); + * }); + * ``` + */ +export class EntitySpawnAfterEvent { + private constructor(); /** - * Represents an item that can place a black candle within - * Minecraft. + * @remarks + * Initialization cause (Spawned, Born ...). + * */ - static readonly blackCandle: ItemType; - static readonly blackDye: ItemType; + readonly cause: EntityInitializationCause; /** - * Represents an item that can place a black glazed terracotta - * block within Minecraft. + * @remarks + * Entity that was spawned. + * + * This property can't be edited in read-only mode. + * */ - static readonly blackGlazedTerracotta: ItemType; + entity: Entity; +} + +/** + * Registers a script-based event handler for handling what + * happens when an entity spawns. + * @example logEntitySpawnEvents.ts + * ```typescript + * // Register a new function that is called when a new entity is created. + * import { world, EntitySpawnAfterEvent } from '@minecraft/server'; + * + * world.afterEvents.entitySpawn.subscribe((entityEvent: EntitySpawnAfterEvent) => { + * const spawnLocation = entityEvent.entity.location; + * world.sendMessage( + * `New entity of type '${entityEvent.entity.typeId}' spawned at ${spawnLocation.x}, ${spawnLocation.y}, ${spawnLocation.z}!`, + * ); + * }); + * ``` + */ +export class EntitySpawnAfterEventSignal { + private constructor(); /** - * Represents an item that can place a blackstone block within - * Minecraft. + * @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. */ - static readonly blackstone: ItemType; + subscribe(callback: (arg: EntitySpawnAfterEvent) => void): (arg: EntitySpawnAfterEvent) => void; /** - * Represents an item that can place a blackstone slab within - * Minecraft. + * @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. */ - static readonly blackstoneSlab: ItemType; + 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(); /** - * Represents blackstone stairs within Minecraft. + * @remarks + * Maximum strength of this entity, as defined in the entity + * type definition. + * + * @throws This property can throw when used. */ - static readonly blackstoneStairs: ItemType; + readonly max: number; /** - * Represents an item that can place a blackstone wall within - * Minecraft. + * @remarks + * Current value of the strength component that has been set + * for entities. + * + * @throws This property can throw when used. */ - static readonly blackstoneWall: ItemType; - static readonly blackWool: ItemType; + 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(); /** - * Represents an item that can place a blast furnace within - * Minecraft. + * @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. */ - static readonly blastFurnace: ItemType; - static readonly blazePowder: ItemType; - static readonly blazeRod: ItemType; - static readonly blazeSpawnEgg: ItemType; + readonly probability: number; + static readonly componentId = 'minecraft:tameable'; /** - * Represents an item that can place a blue candle within - * Minecraft. + * @remarks + * Returns a set of items that can be used to tame this entity. + * + * @throws This function can throw errors. */ - static readonly blueCandle: ItemType; - static readonly blueDye: ItemType; + getTameItems(): string[]; /** - * Represents an item that can place a blue glazed terracotta - * block within Minecraft. + * @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. */ - static readonly blueGlazedTerracotta: ItemType; + tame(): boolean; +} + +/** + * @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 EntityTameMountComponent extends EntityComponent { + private constructor(); + static readonly componentId = 'minecraft:tamemount'; /** - * Represents an item that can place a blue ice block within - * Minecraft. + * @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. */ - static readonly blueIce: ItemType; - static readonly blueWool: ItemType; - static readonly boat: ItemType; - static readonly bone: ItemType; + tame(showParticles: boolean): void; +} + +/** + * Represents information about a type of entity. + */ +export class EntityType { + private constructor(); /** - * Represents an item that can place a bone block within - * Minecraft. + * @remarks + * Identifier of this entity type - for example, + * 'minecraft:skeleton'. + * */ - static readonly boneBlock: ItemType; - static readonly boneMeal: ItemType; - static readonly book: ItemType; + readonly id: string; +} + +// @ts-ignore Class inheritance allowed for native defined classes +export class EntityTypeFamilyComponent extends EntityComponent { + private constructor(); + static readonly componentId = 'minecraft:type_family'; /** - * Represents an item that can place an unbreakable border - * block within Minecraft. + * @throws This function can throw errors. */ - static readonly bookshelf: ItemType; + getTypeFamilies(): string[]; /** - * Represents an item that can place a border block within - * Minecraft. + * @throws This function can throw errors. */ - static readonly borderBlock: ItemType; - static readonly bordureIndentedBannerPattern: ItemType; - static readonly bow: ItemType; - static readonly bowl: ItemType; - static readonly bread: ItemType; + hasTypeFamily(typeFamily: string): boolean; +} + +/** + * @beta + * An iterator that loops through available entity types. + */ +export class EntityTypeIterator implements Iterable { + private constructor(); /** - * Represents an item that can place a brewing stand within - * Minecraft. + * @remarks + * This function can't be called in read-only mode. + * */ - static readonly brewingStand: ItemType; - static readonly brick: ItemType; + [Symbol.iterator](): Iterator; /** - * Represents an item that can place a block of brick within - * Minecraft. + * @remarks + * This function can't be called in read-only mode. + * */ - static readonly brickBlock: ItemType; + next(): IteratorResult; +} + +/** + * Used for accessing all entity types currently available for + * use within the world. + */ +export class EntityTypes { + private constructor(); /** - * Represents brick stairs within Minecraft. + * @remarks + * Retrieves an entity type using a string-based identifier. + * */ - static readonly brickStairs: ItemType; + static get(identifier: string): EntityType | undefined; /** - * Represents an item that can place a brown candle within - * Minecraft. + * @remarks + * Retrieves a set of all entity types within this world. + * */ - static readonly brownCandle: ItemType; - static readonly brownDye: ItemType; + static getAll(): EntityType[]; +} + +/** + * @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'; +} + +/** + * 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(); /** - * Represents an item that can place a brown glazed terracotta - * block within Minecraft. + * @remarks + * Current value for variant for this entity, as specified via + * components. + * + * @throws This property can throw when used. */ - static readonly brownGlazedTerracotta: ItemType; + 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'; +} + +/** + * Contains information regarding an explosion that has + * happened. + */ +export class ExplosionAfterEvent { + private constructor(); /** - * Represents an item that can place a brown mushroom within - * Minecraft. + * @remarks + * Dimension where the explosion has occurred. + * */ - static readonly brownMushroom: ItemType; + readonly dimension: Dimension; /** - * Represents an item that can place a block of brown mushroom - * within Minecraft. + * @remarks + * Optional source of the explosion. + * */ - static readonly brownMushroomBlock: ItemType; - static readonly brownWool: ItemType; - static readonly bucket: ItemType; + readonly source?: Entity; /** - * Represents an item that can place a block of budding - * amethyst within Minecraft. + * @remarks + * A collection of blocks impacted by this explosion event. + * */ - static readonly buddingAmethyst: ItemType; + getImpactedBlocks(): Block[]; +} + +/** + * Manages callbacks that are connected to when an explosion + * occurs. + */ +export class ExplosionAfterEventSignal { + private constructor(); /** - * Represents an item that can place a cactus within Minecraft. + * @remarks + * Adds a callback that will be called when an explosion + * occurs. + * + * This function can't be called in read-only mode. + * */ - static readonly cactus: ItemType; + subscribe(callback: (arg: ExplosionAfterEvent) => void): (arg: ExplosionAfterEvent) => void; /** - * Represents an item that can place a cake within Minecraft. + * @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. */ - static readonly cake: ItemType; + unsubscribe(callback: (arg: ExplosionAfterEvent) => void): void; +} + +/** + * Contains information regarding an explosion that has + * happened. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class ExplosionBeforeEvent extends ExplosionAfterEvent { + private constructor(); /** - * Represents an item that can place a calcite block within - * Minecraft. + * @remarks + * If set to true, cancels the explosion event. + * */ - static readonly calcite: ItemType; + cancel: boolean; /** - * Represents an item that can place a campfire within - * Minecraft. + * @remarks + * Updates a collection of blocks impacted by this explosion + * event. + * + * @param blocks + * New list of blocks that are impacted by this explosion. */ - static readonly campfire: ItemType; + setImpactedBlocks(blocks: Block[]): void; +} + +/** + * Manages callbacks that are connected to before an explosion + * occurs. + */ +export class ExplosionBeforeEventSignal { + private constructor(); /** - * Represents an item that can place a candle within Minecraft. + * @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. + * */ - static readonly candle: ItemType; + subscribe(callback: (arg: ExplosionBeforeEvent) => void): (arg: ExplosionBeforeEvent) => void; /** - * Represents an item that can place a carpet within Minecraft. + * @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. */ - static readonly carpet: ItemType; - static readonly carrot: ItemType; - static readonly carrotOnAStick: ItemType; + unsubscribe(callback: (arg: ExplosionBeforeEvent) => void): void; +} + +/** + * 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(); /** - * Represents an item that can place a cartography table block - * within Minecraft. + * @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. + * */ - static readonly cartographyTable: ItemType; + readonly healAmount: number; /** - * Represents an item that can place a carved pumpkin within - * Minecraft. + * @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'. + * */ - static readonly carvedPumpkin: ItemType; - static readonly catSpawnEgg: ItemType; + readonly item: string; /** - * Represents an item that can place a cauldron within - * Minecraft. + * @remarks + * As part of the Healable component, an optional collection of + * side effects that can occur from being fed an item. + * */ - static readonly cauldron: ItemType; - static readonly caveSpiderSpawnEgg: ItemType; + 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(); /** - * Represents an item that can place a metallic chain within - * Minecraft. + * @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. + * */ - static readonly chain: ItemType; + readonly amplifier: number; /** - * Represents an item that can place a block that gives off - * heat but not light, within Minecraft Education Edition or - * Bedrock Edition with Education features. + * @remarks + * Chance that this effect is applied as a result of the entity + * being fed this item. Valid values range between 0 and 1. + * */ - static readonly chainCommandBlock: ItemType; - static readonly chainmailBoots: ItemType; - static readonly chainmailChestplate: ItemType; - static readonly chainmailHelmet: ItemType; - static readonly chainmailLeggings: ItemType; - static readonly charcoal: ItemType; + readonly chance: number; /** - * Represents an item that can place a chest within Minecraft. + * @remarks + * Gets the duration, in ticks, of this effect. + * */ - static readonly chest: ItemType; - static readonly chestBoat: ItemType; - static readonly chestMinecart: ItemType; - static readonly chicken: ItemType; - static readonly chickenSpawnEgg: ItemType; + readonly duration: number; /** - * Represents an item that can place a set of chiseled - * deepslate within Minecraft. + * @remarks + * Gets the identifier of the effect to apply. Example values + * include 'fire_resistance' or 'regeneration'. + * */ - static readonly chiseledDeepslate: ItemType; + 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(); /** - * Represents an item that can place a block of chiseled nether - * bricks within Minecraft. + * @remarks + * Constant that represents the maximum fill level of a fluid + * container. + * */ - static readonly chiseledNetherBricks: ItemType; + static readonly maxFillLevel = 6; /** - * Represents an item that can place a block of chiseled - * polished blackstone within Minecraft. + * @remarks + * Constant that represents the minimum fill level of a fluid + * container. + * */ - static readonly chiseledPolishedBlackstone: ItemType; + static readonly minFillLevel = 0; +} + +/** + * @beta + * Contains information regarding a changed world.gameRules + * property. + */ +export class GameRuleChangeAfterEvent { + private constructor(); /** - * Represents an item that can place a chorus flower within - * Minecraft. + * @remarks + * The rule identifier pertaining to the changed + * world.gameRules property. + * */ - static readonly chorusFlower: ItemType; - static readonly chorusFruit: ItemType; + readonly rule: GameRule; /** - * Represents an item that can place a chorus plant within - * Minecraft. + * @remarks + * The value of the world.gameRules property after being + * changed. + * */ - static readonly chorusPlant: ItemType; + readonly value: boolean | number; +} + +/** + * @beta + * Manages callbacks that are connected to when a + * world.gameRules property has changed. + */ +export class GameRuleChangeAfterEventSignal { + private constructor(); /** - * Represents an item that can place a block of clay within - * Minecraft. + * @remarks + * Adds a callback that will be called when a world.gameRules + * property is changed. + * + * This function can't be called in read-only mode. + * */ - static readonly clay: ItemType; - static readonly clayBall: ItemType; - static readonly clock: ItemType; - static readonly coal: ItemType; + subscribe(callback: (arg: GameRuleChangeAfterEvent) => void): (arg: GameRuleChangeAfterEvent) => void; /** - * Represents an item that can place a block of solid coal - * within Minecraft. + * @remarks + * Removes a callback from being called when a world.gameRules + * property is changed. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly coalBlock: ItemType; + unsubscribe(callback: (arg: GameRuleChangeAfterEvent) => void): void; +} + +/** + * @beta + * Represents the game rules for a world experience. + */ +export class GameRules { + private constructor(); /** - * Represents an item that can place a block with embedded coal - * ore within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly coalOre: ItemType; + commandBlockOutput: boolean; /** - * Represents an item that can place a block of cobbled - * deepslate within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly cobbledDeepslate: ItemType; + commandBlocksEnabled: boolean; /** - * Represents an item that can place a slab of deepslate within - * Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly cobbledDeepslateSlab: ItemType; + doDayLightCycle: boolean; /** - * Represents cobbled deepslate stairs within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly cobbledDeepslateStairs: ItemType; + doEntityDrops: boolean; /** - * Represents an item that can place a cobbled deepslate wall - * within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly cobbledDeepslateWall: ItemType; + doFireTick: boolean; /** - * Represents an item that can place a block of cobblestone - * within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly cobblestone: ItemType; + doImmediateRespawn: boolean; /** - * Represents an item that can place a wall of cobblestone - * within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly cobblestoneWall: ItemType; - static readonly cocoaBeans: ItemType; - static readonly cod: ItemType; - static readonly codBucket: ItemType; - static readonly codSpawnEgg: ItemType; + doInsomnia: boolean; /** - * Represents an item that can place a block that can run - * commands within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly commandBlock: ItemType; - static readonly commandBlockMinecart: ItemType; - static readonly comparator: ItemType; - static readonly compass: ItemType; + doLimitedCrafting: boolean; /** - * Represents an item that can place a composter block within - * Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly composter: ItemType; + doMobLoot: boolean; /** - * Represents an item that can place a block of concrete powder - * within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly concrete: ItemType; - static readonly concretePowder: ItemType; + doMobSpawning: boolean; /** - * Represents an item that can place a conduit block within - * Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly conduit: ItemType; - static readonly cookedBeef: ItemType; - static readonly cookedChicken: ItemType; - static readonly cookedCod: ItemType; - static readonly cookedMutton: ItemType; - static readonly cookedPorkchop: ItemType; - static readonly cookedRabbit: ItemType; - static readonly cookedSalmon: ItemType; - static readonly cookie: ItemType; + doTileDrops: boolean; /** - * Represents an item that can place a solid block of copper - * within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly copperBlock: ItemType; - static readonly copperIngot: ItemType; + doWeatherCycle: boolean; /** - * Represents an item that can place a block with embedded - * copper ore within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly copperOre: ItemType; + drowningDamage: boolean; /** - * Represents coral within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly coral: ItemType; + fallDamage: boolean; /** - * Represents an item that can place a solid block of coral - * within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly coralBlock: ItemType; + fireDamage: boolean; /** - * Represents an item that can place a fan formation of coral - * within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly coralFan: ItemType; + freezeDamage: boolean; /** - * Represents an item that can place a fan formation of dead - * coral within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly coralFanDead: ItemType; - static readonly cowSpawnEgg: ItemType; + functionCommandLimit: number; /** - * Represents an item that can place a block of cracked - * deepslate bricks within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly crackedDeepslateBricks: ItemType; + keepInventory: boolean; /** - * Represents tiles of cracked deepslate within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly crackedDeepslateTiles: ItemType; + maxCommandChainLength: number; /** - * Represents an item that can place a block of cracked nether - * bricks within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly crackedNetherBricks: ItemType; + mobGriefing: boolean; /** - * Represents an item that can place a block of cracked and - * polished blackstone bricks within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly crackedPolishedBlackstoneBricks: ItemType; + naturalRegeneration: boolean; /** - * Represents an item that can place a crafting table within - * Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly craftingTable: ItemType; - static readonly creeperBannerPattern: ItemType; - static readonly creeperSpawnEgg: ItemType; + playersSleepingPercentage: number; /** - * Represents an item that can place a crimson button within - * Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly crimsonButton: ItemType; + projectilesCanBreakBlocks: boolean; /** - * Represents an item that can place a crimson door within - * Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly crimsonDoor: ItemType; + pvp: boolean; /** - * Represents an item that can place a crimson fence within - * Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly crimsonFence: ItemType; + randomTickSpeed: number; /** - * Represents an item that can place a crimson fence gate - * within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly crimsonFenceGate: ItemType; + recipesUnlock: boolean; /** - * Represents an item that can place a crimson fungus within - * Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly crimsonFungus: ItemType; + respawnBlocksExplode: boolean; /** - * Represents crimson hyphae within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly crimsonHyphae: ItemType; + sendCommandFeedback: boolean; /** - * Represents crimson nylium within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly crimsonNylium: ItemType; + showBorderEffect: boolean; /** - * Represents an item that can place a set of crimson planks - * within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly crimsonPlanks: ItemType; + showCoordinates: boolean; /** - * Represents an item that can place a crimson pressure plate - * within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly crimsonPressurePlate: ItemType; + showDeathMessages: boolean; /** - * Represents an item that can place a set of crimson roots - * within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly crimsonRoots: ItemType; - static readonly crimsonSign: ItemType; + showRecipeMessages: boolean; /** - * Represents an item that can place a crimson slab within - * Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly crimsonSlab: ItemType; + showTags: boolean; /** - * Represents an item that can place a set of crimson stairs - * within Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly crimsonStairs: ItemType; + spawnRadius: number; /** - * Represents an item that can place a crimson stem within - * Minecraft. + * @remarks + * This property can't be edited in read-only mode. + * */ - static readonly crimsonStem: ItemType; + tntExplodes: boolean; +} + +/** + * Provides an adaptable interface for callers to subscribe to + * an event that fires when a button is pushed. + */ +export class IButtonPushAfterEventSignal { + private constructor(); /** - * Represents an item that can place a crimson trapdoor within - * Minecraft. + * @remarks + * Subscribes to the event. + * + * This function can't be called in read-only mode. + * */ - static readonly crimsonTrapdoor: ItemType; - static readonly crossbow: ItemType; + subscribe(callback: (arg: ButtonPushAfterEvent) => void): (arg: ButtonPushAfterEvent) => void; /** - * Represents crying obsidian within Minecraft. + * @remarks + * Unsubscribes from the event. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly cryingObsidian: ItemType; + 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(); /** - * Represents an item that can place a cut copper block within - * Minecraft. + * @remarks + * Subscribes to the event. + * + * This function can't be called in read-only mode. + * */ - static readonly cutCopper: ItemType; + subscribe(callback: (arg: LeverActionAfterEvent) => void): (arg: LeverActionAfterEvent) => void; /** - * Represents an item that can place a cut copper slab within - * Minecraft. + * @remarks + * Unsubscribes from the event. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly cutCopperSlab: ItemType; + 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(); /** - * Represents an item that can place a set of cut copper stairs - * within Minecraft. + * @remarks + * Subscribes to the event. + * + * This function can't be called in read-only mode. + * */ - static readonly cutCopperStairs: ItemType; + subscribe(callback: (arg: PlayerJoinAfterEvent) => void): (arg: PlayerJoinAfterEvent) => void; /** - * Represents an item that can place a cyan-colored candle - * within Minecraft. + * @remarks + * Unsubscribes from the event. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly cyanCandle: ItemType; - static readonly cyanDye: ItemType; + 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(); /** - * Represents an item that can place a block of cyan-colored - * glazed terracotta within Minecraft. + * @remarks + * Subscribes to the event. + * + * This function can't be called in read-only mode. + * */ - static readonly cyanGlazedTerracotta: ItemType; - static readonly cyanWool: ItemType; - static readonly darkOakBoat: ItemType; + subscribe(callback: (arg: PlayerLeaveAfterEvent) => void): (arg: PlayerLeaveAfterEvent) => void; /** - * Represents an item that can place a dark oak button within - * Minecraft. + * @remarks + * Unsubscribes from the event. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly darkOakButton: ItemType; - static readonly darkOakChestBoat: ItemType; + 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(); /** - * Represents an item that can place a dark oak door within - * Minecraft. + * @remarks + * Subscribes to the event. + * + * This function can't be called in read-only mode. + * */ - static readonly darkOakDoor: ItemType; + subscribe(callback: (arg: PlayerSpawnAfterEvent) => void): (arg: PlayerSpawnAfterEvent) => void; /** - * Represents an item that can place a dark oak fence gate - * within Minecraft. + * @remarks + * Unsubscribes from the event. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly darkOakFenceGate: ItemType; + unsubscribe(callback: (arg: PlayerSpawnAfterEvent) => void): void; +} + +/** + * Contains information related to a chargeable item completing + * being charged. + */ +export class ItemCompleteUseAfterEvent { + private constructor(); /** - * Represents an item that can place a dark oak pressure plate - * within Minecraft. + * @remarks + * Returns the item stack that has completed charging. + * */ - static readonly darkOakPressurePlate: ItemType; + readonly itemStack: ItemStack; /** - * Represents an item that can place a dark oak sign within - * Minecraft. + * @remarks + * Returns the source entity that triggered this item event. + * */ - static readonly darkOakSign: ItemType; + readonly source: Player; /** - * Represents an item that can place a set of dark oak stairs - * within Minecraft. + * @remarks + * Returns the time, in ticks, for the remaining duration left + * before the charge completes its cycle. + * */ - static readonly darkOakStairs: ItemType; + readonly useDuration: number; +} + +/** + * Manages callbacks that are connected to the completion of + * charging for a chargeable item. + */ +export class ItemCompleteUseAfterEventSignal { + private constructor(); /** - * Represents an item that can place a dark oak trapdoor within - * Minecraft. + * @remarks + * Adds a callback that will be called when a chargeable item + * completes charging. + * + * This function can't be called in read-only mode. + * */ - static readonly darkOakTrapdoor: ItemType; + subscribe(callback: (arg: ItemCompleteUseAfterEvent) => void): (arg: ItemCompleteUseAfterEvent) => void; /** - * Represents an item that can place a set of dark prismarine - * stairs within Minecraft. + * @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. */ - static readonly darkPrismarineStairs: ItemType; + 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(); +} + +/** + * @beta + */ +export class ItemComponentRegistry { + private constructor(); /** - * Represents an item that can place a daylight detector within - * Minecraft. + * @throws This function can throw errors. + * + * {@link ItemCustomComponentAlreadyRegisteredError} + * + * {@link ItemCustomComponentNameError} + * + * {@link ItemCustomComponentReloadNewComponentError} + * + * {@link ItemCustomComponentReloadNewEventError} + * + * {@link ItemCustomComponentReloadVersionError} */ - static readonly daylightDetector: ItemType; + registerCustomComponent(name: string, itemCustomComponent: ItemCustomComponent): void; +} + +/** + * @beta + */ +export class ItemComponentUseEvent { + private constructor(); + readonly itemStack?: ItemStack; + readonly source: Player; +} + +/** + * 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(); /** - * Represents an item that can place a dead bush within - * Minecraft. + * @remarks + * Represents the cooldown category that this item is + * associated with. + * + * @throws This property can throw when used. */ - static readonly deadbush: ItemType; + readonly cooldownCategory: string; /** - * Represents an item that can place a block of deepslate - * within Minecraft. + * @remarks + * Amount of time, in ticks, it will take this item to + * cooldown. + * + * @throws This property can throw when used. */ - static readonly deepslate: ItemType; + readonly cooldownTicks: number; + static readonly componentId = 'minecraft:cooldown'; /** - * Represents an item that can place a block of deepslate - * bricks within Minecraft. + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly deepslateBricks: ItemType; + getCooldownTicksRemaining(player: Player): number; /** - * Represents an item that can place a slab of deepslate brick - * within Minecraft. + * @remarks + * Will return true if the item is the cooldown category passed + * in and false otherwise. + * + * This function can't be called in read-only mode. + * + * @param cooldownCategory + * The cooldown category that might be associated with this + * item. + * @returns + * True if the item is the given cooldown category. + * @throws This function can throw errors. */ - static readonly deepslateBrickSlab: ItemType; + isCooldownCategory(cooldownCategory: string): boolean; /** - * Represents an item that can place a set of deepslate brick - * stairs within Minecraft. + * @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. */ - static readonly deepslateBrickStairs: ItemType; + startCooldown(player: Player): void; +} + +/** + * 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(); /** - * Represents an item that can place a deepslate brick wall - * within Minecraft. + * @remarks + * Returns the current damage level of this particular item. + * + * This property can't be edited in read-only mode. + * */ - static readonly deepslateBrickWall: ItemType; + damage: number; /** - * Represents an item that can place a block of deepslate with - * embedded coal ore within Minecraft. + * @remarks + * Represents the amount of damage that this item can take + * before breaking. + * + * @throws This property can throw when used. */ - static readonly deepslateCoalOre: ItemType; + readonly maxDurability: number; + static readonly componentId = 'minecraft:durability'; /** - * Represents an item that can place a block of deepslate with - * embedded copper ore within Minecraft. + * @remarks + * Returns the maximum chance that this item would be damaged + * using the damageRange property, given an unbreaking + * enchantment level. + * + * This function can't be called in read-only mode. + * + * @param unbreakingEnchantmentLevel + * Unbreaking factor to consider in factoring the damage + * chance. Incoming unbreaking parameter must be within the + * range [0, 3]. + * @throws This function can throw errors. */ - static readonly deepslateCopperOre: ItemType; + getDamageChance(unbreakingEnchantmentLevel?: number): number; /** - * Represents an item that can place a block of deepslate with - * embedded diamond ore within Minecraft. + * @remarks + * A range of numbers that is used to calculate the damage + * chance for an item. The damage chance will fall within this + * range. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly deepslateDiamondOre: ItemType; + getDamageChanceRange(): minecraftcommon.NumberRange; +} + +/** + * @beta + * When present on an item, this item can have enchantments + * applied to it. + * @example givePlayerIronFireSword.ts + * ```typescript + * // Spawns a bunch of item stacks + * import { ItemComponentTypes, ItemStack, Player } from '@minecraft/server'; + * import { MinecraftItemTypes, MinecraftEnchantmentTypes } from '@minecraft/vanilla-data'; + * + * function giveFireSword(player: Player) { + * const ironFireSword = new ItemStack(MinecraftItemTypes.DiamondSword, 1); + * + * const enchantments = ironFireSword?.getComponent(ItemComponentTypes.Enchantable); + * if (enchantments) { + * enchantments.addEnchantment({ type: MinecraftEnchantmentTypes.FireAspect, level: 1 }); + * } + * + * const inventory = player.getComponent('minecraft:inventory'); + * if (inventory === undefined || inventory.container === undefined) { + * return; + * } + * inventory.container.setItem(0, ironFireSword); + * } + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class ItemEnchantableComponent extends ItemComponent { + private constructor(); /** - * Represents an item that can place a block of deepslate with - * embedded emerald ore within Minecraft. + * @throws This property can throw when used. */ - static readonly deepslateEmeraldOre: ItemType; + readonly slots: EnchantmentSlot[]; + static readonly componentId = 'minecraft:enchantable'; /** - * Represents an item that can place a block of deepslate with - * embedded gold ore within Minecraft. + * @remarks + * Adds an enchantment to the item stack. + * + * This function can't be called in read-only mode. + * + * @param enchantment + * The enchantment interface to be added. + * @throws + * ScriptItemEnchantmentUnknownIdError: Exception thrown if the + * enchantment type does not exist. + * + * ScriptItemEnchantmentLevelOutOfBoundsError: Exception thrown + * if the enchantment level is outside the allowable range for + * the given enchantment type. + * + * ScriptItemEnchantmentTypeNotCompatibleError: Exception + * thrown if the enchantment is not compatible with the item + * stack. + * + * + * {@link EnchantmentLevelOutOfBoundsError} + * + * {@link EnchantmentTypeNotCompatibleError} + * + * {@link EnchantmentTypeUnknownIdError} + * + * {@link Error} */ - static readonly deepslateGoldOre: ItemType; + addEnchantment(enchantment: Enchantment): void; /** - * Represents an item that can place a block of deepslate with - * embedded iron ore within Minecraft. + * @remarks + * Adds a list of enchantments to the item stack. + * + * This function can't be called in read-only mode. + * + * @param enchantments + * The list of enchantments to be added. + * @throws + * ScriptItemEnchantmentUnknownIdError: Exception thrown if any + * enchantment type does not exist. + * + * ScriptItemEnchantmentLevelOutOfBoundsError: Exception thrown + * if any enchantment level is outside the allowable range for + * the given enchantment type. + * + * ScriptItemEnchantmentTypeNotCompatibleError: Exception + * thrown if any enchantment is not compatible with the item + * stack. + * + * + * {@link EnchantmentLevelOutOfBoundsError} + * + * {@link EnchantmentTypeNotCompatibleError} + * + * {@link EnchantmentTypeUnknownIdError} + * + * {@link Error} */ - static readonly deepslateIronOre: ItemType; + addEnchantments(enchantments: Enchantment[]): void; /** - * Represents an item that can place a block of deepslate with - * embedded lapis lazuli ore within Minecraft. + * @remarks + * Checks whether an enchantment can be added to the item + * stack. + * + * @param enchantment + * The enchantment interface to be added. + * @returns + * Returns true if the enchantment can be added to the item + * stack. + * @throws + * ScriptItemEnchantmentUnknownIdError: Exception thrown if the + * enchantment type does not exist. + * + * ScriptItemEnchantmentLevelOutOfBoundsError: Exception thrown + * if the enchantment level is outside the allowable range for + * the given enchantment type. + * + * + * {@link EnchantmentLevelOutOfBoundsError} + * + * {@link EnchantmentTypeUnknownIdError} */ - static readonly deepslateLapisOre: ItemType; + canAddEnchantment(enchantment: Enchantment): boolean; /** - * Represents an item that can place a block of deepslate with - * embedded redstone ore within Minecraft. + * @remarks + * Gets the enchantment of a given type from the item stack. + * + * @param enchantmentType + * The enchantment type to get. + * @returns + * Returns the enchantment if it exists on the item stack. + * @throws + * ScriptItemEnchantmentUnknownIdError: Exception thrown if the + * enchantment type does not exist. + * + * + * {@link EnchantmentTypeUnknownIdError} */ - static readonly deepslateRedstoneOre: ItemType; + getEnchantment(enchantmentType: EnchantmentType | string): Enchantment | undefined; /** - * Represents an item that can place a set of deepslate tiles - * within Minecraft. + * @remarks + * Gets all enchantments on the item stack. + * + * @returns + * Returns a list of enchantments on the item stack. + * @throws This function can throw errors. */ - static readonly deepslateTiles: ItemType; + getEnchantments(): Enchantment[]; /** - * Represents an item that can place a slab of deepslate tiles - * within Minecraft. + * @remarks + * Checks whether an item stack has a given enchantment type. + * + * @param enchantmentType + * The enchantment type to check for. + * @returns + * Returns true if the item stack has the enchantment type. + * @throws + * ScriptItemEnchantmentUnknownIdError: Exception thrown if the + * enchantment type does not exist. + * + * + * {@link EnchantmentTypeUnknownIdError} */ - static readonly deepslateTileSlab: ItemType; + hasEnchantment(enchantmentType: EnchantmentType | string): boolean; /** - * Represents an item that can place a set of deepslate tile - * stairs within Minecraft. + * @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. */ - static readonly deepslateTileStairs: ItemType; + removeAllEnchantments(): void; /** - * Represents an item that can place a wall of deepslate tile - * within Minecraft. + * @remarks + * Removes an enchantment of the given type. + * + * This function can't be called in read-only mode. + * + * @param enchantmentType + * The enchantment type to remove. + * @throws + * ScriptItemEnchantmentUnknownIdError: Exception thrown if the + * enchantment type does not exist. + * + * + * {@link EnchantmentTypeUnknownIdError} + * + * {@link Error} */ - static readonly deepslateTileWall: ItemType; + removeEnchantment(enchantmentType: EnchantmentType | string): void; +} + +/** + * 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(); /** - * Represents an item that can place a logical but generally - * invisible Deny logic block within Minecraft. + * @remarks + * If true, the player can always eat this item (even when not + * hungry). + * + * @throws This property can throw when used. */ - static readonly deny: ItemType; + readonly canAlwaysEat: boolean; /** - * Represents an item that can place a detector rail within - * Minecraft. + * @remarks + * Represents how much nutrition this food item will give an + * entity when eaten. + * + * @throws This property can throw when used. */ - static readonly detectorRail: ItemType; - static readonly diamond: ItemType; - static readonly diamondAxe: ItemType; + readonly nutrition: number; /** - * Represents an item that can place a block of diamond within - * Minecraft. + * @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. */ - static readonly diamondBlock: ItemType; - static readonly diamondBoots: ItemType; - static readonly diamondChestplate: ItemType; - static readonly diamondHelmet: ItemType; - static readonly diamondHoe: ItemType; - static readonly diamondHorseArmor: ItemType; - static readonly diamondLeggings: ItemType; + readonly saturationModifier: number; /** - * Represents an item that can place a block with embedded - * diamond ore within Minecraft. + * @remarks + * When specified, converts the active item to the one + * specified by this property. + * + * @throws This property can throw when used. */ - static readonly diamondOre: ItemType; - static readonly diamondPickaxe: ItemType; - static readonly diamondShovel: ItemType; - static readonly diamondSword: ItemType; + readonly usingConvertsTo: string; + static readonly componentId = 'minecraft:food'; +} + +/** + * 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(); /** - * Represents an item that can place a set of diorite stairs - * within Minecraft. + * @remarks + * Returns the item stack that triggered this item event. + * */ - static readonly dioriteStairs: ItemType; + readonly itemStack?: ItemStack; /** - * Represents an item that can place a block of dirt within - * Minecraft. + * @remarks + * Returns the source entity that triggered this item event. + * */ - static readonly dirt: ItemType; + readonly source: Player; /** - * Represents an item that can place a block of dirt with roots - * within Minecraft. + * @remarks + * Returns the time, in ticks, for the remaining duration left + * before the charge completes its cycle. + * */ - static readonly dirtWithRoots: ItemType; - static readonly discFragment5: ItemType; + readonly useDuration: number; +} + +/** + * Manages callbacks that are connected to the releasing of + * charging for a chargeable item. + */ +export class ItemReleaseUseAfterEventSignal { + private constructor(); /** - * Represents an item that can place a dispenser within - * Minecraft. + * @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. + * */ - static readonly dispenser: ItemType; - static readonly dolphinSpawnEgg: ItemType; - static readonly donkeySpawnEgg: ItemType; + subscribe(callback: (arg: ItemReleaseUseAfterEvent) => void): (arg: ItemReleaseUseAfterEvent) => void; /** - * Represents an item that can place a double plant within - * Minecraft. + * @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. */ - static readonly doublePlant: ItemType; - static readonly dragonBreath: ItemType; + unsubscribe(callback: (arg: ItemReleaseUseAfterEvent) => void): void; +} + +/** + * Defines a collection of items. + * @example givePlayerIronFireSword.ts + * ```typescript + * // Spawns a bunch of item stacks + * import { ItemComponentTypes, ItemStack, Player } from '@minecraft/server'; + * import { MinecraftItemTypes, MinecraftEnchantmentTypes } from '@minecraft/vanilla-data'; + * + * function giveFireSword(player: Player) { + * const ironFireSword = new ItemStack(MinecraftItemTypes.DiamondSword, 1); + * + * const enchantments = ironFireSword?.getComponent(ItemComponentTypes.Enchantable); + * if (enchantments) { + * enchantments.addEnchantment({ type: MinecraftEnchantmentTypes.FireAspect, level: 1 }); + * } + * + * const inventory = player.getComponent('minecraft:inventory'); + * if (inventory === undefined || inventory.container === undefined) { + * return; + * } + * inventory.container.setItem(0, ironFireSword); + * } + * ``` + * @example givePlayerEquipment.ts + * ```typescript + * // Gives the player some equipment + * import { EquipmentSlot, ItemStack, Player, EntityComponentTypes } from '@minecraft/server'; + * import { MinecraftItemTypes } from '@minecraft/vanilla-data'; + * + * function giveEquipment(player: Player) { + * const equipmentCompPlayer = player.getComponent(EntityComponentTypes.Equippable); + * if (equipmentCompPlayer) { + * equipmentCompPlayer.setEquipment(EquipmentSlot.Head, new ItemStack(MinecraftItemTypes.GoldenHelmet)); + * equipmentCompPlayer.setEquipment(EquipmentSlot.Chest, new ItemStack(MinecraftItemTypes.IronChestplate)); + * equipmentCompPlayer.setEquipment(EquipmentSlot.Legs, new ItemStack(MinecraftItemTypes.DiamondLeggings)); + * equipmentCompPlayer.setEquipment(EquipmentSlot.Feet, new ItemStack(MinecraftItemTypes.NetheriteBoots)); + * equipmentCompPlayer.setEquipment(EquipmentSlot.Mainhand, new ItemStack(MinecraftItemTypes.WoodenSword)); + * equipmentCompPlayer.setEquipment(EquipmentSlot.Offhand, new ItemStack(MinecraftItemTypes.Shield)); + * } else { + * console.warn('No equipment component found on player'); + * } + * } + * ``` + * @example spawnFeatherItem.ts + * ```typescript + * // Spawns a feather at a location + * import { ItemStack, DimensionLocation } from '@minecraft/server'; + * import { MinecraftItemTypes } from '@minecraft/vanilla-data'; + * + * function spawnFeather(location: DimensionLocation) { + * const featherItem = new ItemStack(MinecraftItemTypes.Feather, 1); + * location.dimension.spawnItem(featherItem, location); + * } + * ``` + */ +export class ItemStack { /** - * Represents an item that can place a dragon egg within - * Minecraft. + * @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. */ - static readonly dragonEgg: ItemType; - static readonly driedKelp: ItemType; + amount: number; /** - * Represents an item that can place a block of dried kelp - * within Minecraft. + * @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. + * */ - static readonly driedKelpBlock: ItemType; + readonly isStackable: boolean; /** - * Represents an item that can place a block of dripstone - * within Minecraft. + * @remarks + * Gets or sets whether the item is kept on death. + * + * This property can't be edited in read-only mode. + * */ - static readonly dripstoneBlock: ItemType; + keepOnDeath: boolean; /** - * Represents an item that can place a dropper within - * Minecraft. + * @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. + * */ - static readonly dropper: ItemType; - static readonly drownedSpawnEgg: ItemType; - static readonly dye: ItemType; - static readonly echoShard: ItemType; - static readonly egg: ItemType; - static readonly elderGuardianSpawnEgg: ItemType; - static readonly elytra: ItemType; - static readonly emerald: ItemType; + lockMode: ItemLockMode; /** - * Represents an item that can place a block of emerald within - * Minecraft. + * @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. + * */ - static readonly emeraldBlock: ItemType; + readonly maxAmount: number; /** - * Represents an item that can place a block with embedded - * emerald ore within Minecraft. + * @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. */ - static readonly emeraldOre: ItemType; - static readonly emptyMap: ItemType; - static readonly enchantedBook: ItemType; - static readonly enchantedGoldenApple: ItemType; + nameTag?: string; /** - * Represents an item that can place an enchanting table within - * Minecraft. + * @remarks + * The type of the item. + * */ - static readonly enchantingTable: ItemType; + readonly 'type': ItemType; /** - * Represents an item that can place an end bricks block within - * Minecraft. + * @remarks + * Identifier of the type of items for the stack. If a + * namespace is not specified, 'minecraft:' is assumed. + * Examples include 'wheat' or 'apple'. + * */ - static readonly endBricks: ItemType; + readonly typeId: string; /** - * Represents an item that can place a set of end brick stairs - * within Minecraft. + * @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. */ - static readonly endBrickStairs: ItemType; - static readonly endCrystal: ItemType; + constructor(itemType: ItemType | string, amount?: number); /** - * Represents an item that can place an ender chest within - * Minecraft. + * @remarks + * Clears all dynamic properties that have been set on this + * item stack. + * */ - static readonly enderChest: ItemType; - static readonly enderDragonSpawnEgg: ItemType; - static readonly enderEye: ItemType; - static readonly endermanSpawnEgg: ItemType; - static readonly endermiteSpawnEgg: ItemType; - static readonly enderPearl: ItemType; + clearDynamicProperties(): void; /** - * Represents an item that can place an end portal frame within - * Minecraft. + * @remarks + * Creates an exact copy of the item stack, including any + * custom data or properties. + * + * @returns + * Returns a copy of this item stack. */ - static readonly endPortalFrame: ItemType; + clone(): ItemStack; /** - * Represents an item that can place an end rod within - * Minecraft. + * @remarks + * Get the list of block types this item can break in Adventure + * mode. + * + * This function can't be called in read-only mode. + * */ - static readonly endRod: ItemType; + getCanDestroy(): string[]; /** - * Represents an item that can place an end stone block within - * Minecraft. + * @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. + * */ - static readonly endStone: ItemType; - static readonly evokerSpawnEgg: ItemType; - static readonly experienceBottle: ItemType; + getCanPlaceOn(): string[]; /** - * Represents an item that can place a block of exposed copper - * within Minecraft. + * @remarks + * Gets a component (that represents additional capabilities) + * for an item stack. + * + * @param componentId + * The identifier of the component (e.g., 'minecraft:food'). If + * no namespace prefix is specified, 'minecraft:' is assumed. + * Available component IDs can be found as part of the {@link + * ItemComponentTypes} enum. + * @returns + * Returns the component if it exists on the item stack, + * otherwise undefined. + * @example durability.ts + * ```typescript + * // Gives a player a half-damaged diamond sword + * import { ItemStack, Player, ItemComponentTypes, EntityComponentTypes } from '@minecraft/server'; + * import { MinecraftItemTypes } from '@minecraft/vanilla-data'; + * + * function giveHurtDiamondSword(player: Player) { + * const hurtDiamondSword = new ItemStack(MinecraftItemTypes.DiamondSword); + * const durabilityComponent = hurtDiamondSword.getComponent(ItemComponentTypes.Durability); + * if (durabilityComponent !== undefined) { + * durabilityComponent.damage = durabilityComponent.maxDurability / 2; + * } + * + * const inventory = player.getComponent(EntityComponentTypes.Inventory); + * if (inventory === undefined || inventory.container === undefined) { + * return; + * } + * + * inventory.container.addItem(hurtDiamondSword); + * } + * ``` */ - static readonly exposedCopper: ItemType; + getComponent(componentId: T): ItemComponentTypeMap[T] | undefined; /** - * Represents an item that can place a block of exposed cut - * copper within Minecraft. + * @remarks + * Returns all components that are both present on this item + * stack and supported by the API. + * */ - static readonly exposedCutCopper: ItemType; + getComponents(): ItemComponent[]; /** - * Represents an item that can place a slab of exposed cut - * copper within Minecraft. + * @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. */ - static readonly exposedCutCopperSlab: ItemType; + getDynamicProperty(identifier: string): boolean | number | string | Vector3 | undefined; /** - * Represents an item that can place a set of exposed cut - * copper stairs within Minecraft. + * @remarks + * Returns the available set of dynamic property identifiers + * that have been used on this entity. + * + * @returns + * A string array of the dynamic properties set on this entity. */ - static readonly exposedCutCopperStairs: ItemType; + getDynamicPropertyIds(): string[]; /** - * Represents an item that can place a farmland block within - * Minecraft. + * @remarks + * Returns the total size, in bytes, of all the dynamic + * properties that are currently stored for this entity. This + * includes the size of both the key and the value. This can + * be useful for diagnosing performance warning signs - if, for + * example, an entity has many megabytes of associated dynamic + * properties, it may be slow to load on various devices. + * */ - static readonly farmland: ItemType; - static readonly feather: ItemType; + getDynamicPropertyTotalByteCount(): number; /** - * Represents an item that can place a fence within Minecraft. + * @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. */ - static readonly fence: ItemType; + getLore(): string[]; /** - * Represents an item that can place a fence gate within - * Minecraft. + * @remarks + * Returns a set of tags associated with this item stack. + * */ - static readonly fenceGate: ItemType; - static readonly fermentedSpiderEye: ItemType; - static readonly fieldMasonedBannerPattern: ItemType; - static readonly filledMap: ItemType; - static readonly fireCharge: ItemType; - static readonly fireworkRocket: ItemType; - static readonly fireworkStar: ItemType; - static readonly fishingRod: ItemType; + getTags(): string[]; /** - * Represents an item that can place a fletching table within - * Minecraft. + * @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. */ - static readonly fletchingTable: ItemType; - static readonly flint: ItemType; - static readonly flintAndSteel: ItemType; - static readonly flowerBannerPattern: ItemType; + hasComponent(componentId: string): boolean; /** - * Represents an item that can place a flowering azalea plant - * within Minecraft. + * @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. */ - static readonly floweringAzalea: ItemType; + hasTag(tag: string): boolean; /** - * Represents an item that can place a flower pot within - * Minecraft. + * @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. */ - static readonly flowerPot: ItemType; - static readonly foxSpawnEgg: ItemType; + isStackableWith(itemStack: ItemStack): boolean; /** - * Represents an item that can place a frame within Minecraft. + * @beta + * @remarks + * Version safe way of checking if an item matches. + * + * @param itemName + * Identifier of the item. + * @param states + * Applicable only for blocks. An optional set of states to + * compare against. If states is not specified, matches checks + * against the set of types more broadly. + * @returns + * Returns a boolean whether the specified item matches. */ - static readonly frame: ItemType; - static readonly frogSpawn: ItemType; - static readonly frogSpawnEgg: ItemType; + matches(itemName: string, states?: Record): boolean; /** - * Represents an item that can place a frosted ice block within - * Minecraft. + * @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 + * const specialPickaxe = new ItemStack('minecraft:diamond_pickaxe'); + * specialPickaxe.setCanDestroy(['minecraft:cobblestone', 'minecraft:obsidian']); + * + * // Creates a diamond pickaxe that can destroy cobblestone and obsidian + * import { ItemStack, Player } from '@minecraft/server'; + * import { MinecraftItemTypes } from '@minecraft/vanilla-data'; + * + * function giveRestrictedPickaxe(player: Player) { + * const specialPickaxe = new ItemStack(MinecraftItemTypes.DiamondPickaxe); + * specialPickaxe.setCanPlaceOn([MinecraftItemTypes.Cobblestone, MinecraftItemTypes.Obsidian]); + * + * const inventory = player.getComponent('inventory'); + * if (inventory === undefined || inventory.container === undefined) { + * return; + * } + * + * inventory.container.addItem(specialPickaxe); + * } + * ``` */ - static readonly frostedIce: ItemType; + setCanDestroy(blockIdentifiers?: string[]): void; /** - * Represents an item that can place a furnace within - * Minecraft. + * @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 + * import { ItemStack, Player, EntityComponentTypes } from '@minecraft/server'; + * import { MinecraftItemTypes } from '@minecraft/vanilla-data'; + * + * function giveRestrictedGoldBlock(player: Player) { + * const specialGoldBlock = new ItemStack(MinecraftItemTypes.GoldBlock); + * specialGoldBlock.setCanPlaceOn([MinecraftItemTypes.Grass, MinecraftItemTypes.Dirt]); + * + * const inventory = player.getComponent(EntityComponentTypes.Inventory); + * if (inventory === undefined || inventory.container === undefined) { + * return; + * } + * + * inventory.container.addItem(specialGoldBlock); + * } + * ``` */ - static readonly furnace: ItemType; - static readonly ghastSpawnEgg: ItemType; - static readonly ghastTear: ItemType; + setCanPlaceOn(blockIdentifiers?: string[]): void; /** - * Represents an item that can place a block of gilded - * blackstone within Minecraft. + * @remarks + * Sets a specified property to a value. Note: This function + * only works with non-stackable items. + * + * @param identifier + * The property identifier. + * @param value + * Data value of the property to set. + * @throws + * Throws if the item stack is stackable. */ - static readonly gildedBlackstone: ItemType; + setDynamicProperty(identifier: string, value?: boolean | number | string | Vector3): void; /** - * Represents an item that can place a glass block within - * Minecraft. + * @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 + * import { EntityComponentTypes, ItemStack, Player } from '@minecraft/server'; + * import { MinecraftItemTypes } from '@minecraft/vanilla-data'; + * + * function giveAwesomeSword(player: Player) { + * const diamondAwesomeSword = new ItemStack(MinecraftItemTypes.DiamondSword, 1); + * 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 = player.getComponent(EntityComponentTypes.Inventory); + * if (inventory === undefined || inventory.container === undefined) { + * return; + * } + * + * inventory.container.setItem(0, diamondAwesomeSword); + * } + * ``` */ - static readonly glass: ItemType; - static readonly glassBottle: ItemType; + setLore(loreList?: string[]): void; +} + +/** + * Contains information related to a chargeable item starting + * to be charged. + */ +export class ItemStartUseAfterEvent { + private constructor(); /** - * Represents an item that can place a pane of glass within - * Minecraft. + * @remarks + * The impacted item stack that is starting to be charged. + * */ - static readonly glassPane: ItemType; - static readonly glisteringMelonSlice: ItemType; - static readonly globeBannerPattern: ItemType; - static readonly glowBerries: ItemType; + readonly itemStack: ItemStack; /** - * Represents an item that can place a glowing frame within - * Minecraft. + * @remarks + * Returns the source entity that triggered this item event. + * */ - static readonly glowFrame: ItemType; - static readonly glowInkSac: ItemType; + readonly source: Player; /** - * Represents glow lichen within Minecraft. + * @remarks + * Returns the time, in ticks, for the remaining duration left + * before the charge completes its cycle. + * */ - static readonly glowLichen: ItemType; - static readonly glowSquidSpawnEgg: ItemType; + readonly useDuration: number; +} + +/** + * Manages callbacks that are connected to the start of + * charging for a chargeable item. + */ +export class ItemStartUseAfterEventSignal { + private constructor(); /** - * Represents an item that can place a block of glowstone - * within Minecraft. + * @remarks + * Adds a callback that will be called when a chargeable item + * starts charging. + * + * This function can't be called in read-only mode. + * */ - static readonly glowstone: ItemType; - static readonly glowstoneDust: ItemType; - static readonly goatHorn: ItemType; - static readonly goatSpawnEgg: ItemType; + subscribe(callback: (arg: ItemStartUseAfterEvent) => void): (arg: ItemStartUseAfterEvent) => void; /** - * Represents an item that can place a gold block within - * Minecraft. + * @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. */ - static readonly goldBlock: ItemType; - static readonly goldenApple: ItemType; - static readonly goldenAxe: ItemType; - static readonly goldenBoots: ItemType; - static readonly goldenCarrot: ItemType; - static readonly goldenChestplate: ItemType; - static readonly goldenHelmet: ItemType; - static readonly goldenHoe: ItemType; - static readonly goldenHorseArmor: ItemType; - static readonly goldenLeggings: ItemType; - static readonly goldenPickaxe: ItemType; + 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(); /** - * Represents an item that can place a golden rail element - * within Minecraft. + * @remarks + * The block that the item is used on. + * */ - static readonly goldenRail: ItemType; - static readonly goldenShovel: ItemType; - static readonly goldenSword: ItemType; - static readonly goldIngot: ItemType; - static readonly goldNugget: ItemType; + readonly block: Block; /** - * Represents an item that can place a block with embedded gold - * ore within Minecraft. + * @remarks + * The face of the block that an item is being used on. + * */ - static readonly goldOre: ItemType; + readonly blockFace: Direction; /** - * Represents an item that can place a set of granite stairs - * within Minecraft. + * @remarks + * The impacted item stack that is starting to be used. Can be + * undefined in some gameplay scenarios like pushing a button + * with an empty hand. + * */ - static readonly graniteStairs: ItemType; + readonly itemStack?: ItemStack; /** - * Represents an item that can place a block of dirt and grass - * within Minecraft. + * @remarks + * Returns the source entity that triggered this item event. + * */ - static readonly grass: ItemType; + readonly source: Player; +} + +/** + * Manages callbacks that are connected to an item starting + * being used on a block event. + */ +export class ItemStartUseOnAfterEventSignal { + private constructor(); /** - * Represents an item that can place a block of dirt and grass - * with a path within Minecraft. + * @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. + * */ - static readonly grassPath: ItemType; + subscribe(callback: (arg: ItemStartUseOnAfterEvent) => void): (arg: ItemStartUseOnAfterEvent) => void; /** - * Represents an item that can place a block of gravel within - * Minecraft. + * @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. */ - static readonly gravel: ItemType; + 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(); /** - * Represents an item that can place a gray-colored candle - * within Minecraft. + * @remarks + * The impacted item stack that is stopping being charged. + * ItemStopUseAfterEvent can be called when teleporting to a + * different dimension and this can be undefined. + * */ - static readonly grayCandle: ItemType; - static readonly grayDye: ItemType; + readonly itemStack?: ItemStack; /** - * Represents an item that can place a gray-colored block of - * glazed terracotta within Minecraft. + * @remarks + * Returns the source entity that triggered this item event. + * */ - static readonly grayGlazedTerracotta: ItemType; - static readonly grayWool: ItemType; + readonly source: Player; /** - * Represents an item that can place a green-colored candle - * within Minecraft. + * @remarks + * Returns the time, in ticks, for the remaining duration left + * before the charge completes its cycle. + * */ - static readonly greenCandle: ItemType; - static readonly greenDye: ItemType; + 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(); /** - * Represents an item that can place a green block of glazed - * terracotta within Minecraft. + * @remarks + * Adds a callback that will be called when a chargeable item + * stops charging. + * + * This function can't be called in read-only mode. + * */ - static readonly greenGlazedTerracotta: ItemType; - static readonly greenWool: ItemType; + subscribe(callback: (arg: ItemStopUseAfterEvent) => void): (arg: ItemStopUseAfterEvent) => void; /** - * Represents an item that can place a grindstone within - * Minecraft. + * @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. */ - static readonly grindstone: ItemType; - static readonly guardianSpawnEgg: ItemType; - static readonly gunpowder: ItemType; + 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(); /** - * Represents an item that can place a set of hanging roots - * within Minecraft. + * @remarks + * The block that the item is used on. + * */ - static readonly hangingRoots: ItemType; + readonly block: Block; /** - * Represents an item that can place a block of hardened clay - * within Minecraft. + * @remarks + * The impacted item stack that is being used on a block. + * */ - static readonly hardenedClay: ItemType; + readonly itemStack?: ItemStack; /** - * Represents an item that can place a block of hay within - * Minecraft. + * @remarks + * Returns the source entity that triggered this item event. + * */ - static readonly hayBlock: ItemType; - static readonly heartOfTheSea: ItemType; + readonly source: Player; +} + +/** + * Manages callbacks that are connected to an item stops used + * on a block event. + */ +export class ItemStopUseOnAfterEventSignal { + private constructor(); /** - * Represents an item that can place a heavy weighted pressure - * plate within Minecraft. + * @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. + * */ - static readonly heavyWeightedPressurePlate: ItemType; - static readonly hoglinSpawnEgg: ItemType; + subscribe(callback: (arg: ItemStopUseOnAfterEvent) => void): (arg: ItemStopUseOnAfterEvent) => void; /** - * Represents an item that can place a block of honey within - * Minecraft. + * @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. */ - static readonly honeyBlock: ItemType; - static readonly honeyBottle: ItemType; - static readonly honeycomb: ItemType; + unsubscribe(callback: (arg: ItemStopUseOnAfterEvent) => void): void; +} + +/** + * Represents the type of an item - for example, Wool. + */ +export class ItemType { + private constructor(); /** - * Represents an item that can place a honeycomb block within - * Minecraft. + * @remarks + * Returns the identifier of the item type - for example, + * 'minecraft:apple'. + * */ - static readonly honeycombBlock: ItemType; + readonly id: string; +} + +/** + * @beta + * Returns the set of item types registered within Minecraft. + */ +export class ItemTypes { + private constructor(); /** - * Represents an item that can place a hopper within Minecraft. + * @remarks + * Returns a specific item type, if available within Minecraft. + * */ - static readonly hopper: ItemType; - static readonly hopperMinecart: ItemType; - static readonly horseSpawnEgg: ItemType; - static readonly huskSpawnEgg: ItemType; + static get(itemId: string): ItemType | undefined; /** - * Represents an item that can place a block of ice within + * @remarks + * Retrieves all available item types registered within * Minecraft. + * */ - static readonly ice: ItemType; + static getAll(): ItemType[]; +} + +/** + * Contains information related to an item being used on a + * block. This event fires when an item used by a player + * successfully triggers an entity interaction. + */ +export class ItemUseAfterEvent { + private constructor(); /** - * Represents an item that can place an infested block of - * deepslate within Minecraft. + * @remarks + * The impacted item stack that is being used. + * */ - static readonly infestedDeepslate: ItemType; - static readonly inkSac: ItemType; - static readonly ironAxe: ItemType; + itemStack: ItemStack; /** - * Represents iron bars within Minecraft. + * @remarks + * Returns the source entity that triggered this item event. + * */ - static readonly ironBars: ItemType; + readonly source: Player; +} + +/** + * Manages callbacks that are connected to an item use event. + */ +export class ItemUseAfterEventSignal { + private constructor(); /** - * Represents an item that can place a block of iron within - * Minecraft. + * @remarks + * Adds a callback that will be called when an item is used. + * + * This function can't be called in read-only mode. + * */ - static readonly ironBlock: ItemType; - static readonly ironBoots: ItemType; - static readonly ironChestplate: ItemType; + subscribe(callback: (arg: ItemUseAfterEvent) => void): (arg: ItemUseAfterEvent) => void; /** - * Represents an item that can place an iron door within - * Minecraft. + * @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. */ - static readonly ironDoor: ItemType; - static readonly ironGolemSpawnEgg: ItemType; - static readonly ironHelmet: ItemType; - static readonly ironHoe: ItemType; - static readonly ironHorseArmor: ItemType; - static readonly ironIngot: ItemType; - static readonly ironLeggings: ItemType; - static readonly ironNugget: ItemType; + 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(); /** - * Represents an item that can place a block with embedded iron - * ore within Minecraft. + * @remarks + * If set to true, this will cancel the item use behavior. + * */ - static readonly ironOre: ItemType; - static readonly ironPickaxe: ItemType; - static readonly ironShovel: ItemType; - static readonly ironSword: ItemType; + cancel: boolean; +} + +/** + * Manages callbacks that fire before an item is used. + */ +export class ItemUseBeforeEventSignal { + private constructor(); /** - * Represents an item that can place an iron trapdoor within - * Minecraft. + * @remarks + * Adds a callback that will be called before an item is used. + * + * This function can't be called in read-only mode. + * */ - static readonly ironTrapdoor: ItemType; + subscribe(callback: (arg: ItemUseBeforeEvent) => void): (arg: ItemUseBeforeEvent) => void; /** - * Represents an item that can place a jigsaw within Minecraft. + * @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. */ - static readonly jigsaw: ItemType; + unsubscribe(callback: (arg: ItemUseBeforeEvent) => void): void; +} + +/** + * Contains information related to an item being used on a + * block. This event fires when an item used by a player + * successfully triggers a block interaction. + */ +export class ItemUseOnAfterEvent { + private constructor(); /** - * Represents an item that can place a jukebox within - * Minecraft. + * @remarks + * The block that the item is used on. + * */ - static readonly jukebox: ItemType; - static readonly jungleBoat: ItemType; + readonly block: Block; /** - * Represents jungle wood button within Minecraft. + * @remarks + * The face of the block that an item is being used on. + * */ - static readonly jungleButton: ItemType; - static readonly jungleChestBoat: ItemType; + readonly blockFace: Direction; /** - * Represents an item that can place a jungle wood door within - * Minecraft. + * @remarks + * Location relative to the bottom north-west corner of the + * block where the item is placed. + * */ - static readonly jungleDoor: ItemType; + readonly faceLocation: Vector3; /** - * Represents an item that can place a jungle wood fence gate - * within Minecraft. + * @remarks + * The impacted item stack that is being used on a block. + * */ - static readonly jungleFenceGate: ItemType; + readonly itemStack: ItemStack; /** - * Represents an item that can place a jungle wood pressure - * plate within Minecraft. + * @remarks + * Returns the source entity that triggered this item event. + * */ - static readonly junglePressurePlate: ItemType; + readonly source: Player; +} + +/** + * Manages callbacks that are connected to an item being used + * on a block event. + */ +export class ItemUseOnAfterEventSignal { + private constructor(); /** - * Represents an item that can place a jungle sign within - * Minecraft. + * @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. + * */ - static readonly jungleSign: ItemType; + subscribe(callback: (arg: ItemUseOnAfterEvent) => void): (arg: ItemUseOnAfterEvent) => void; /** - * Represents an item that can place a set of jungle wood - * stairs within Minecraft. + * @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. */ - static readonly jungleStairs: ItemType; + 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(); /** - * Represents an item that can place a jungle wood trapdoor - * within Minecraft. + * @remarks + * If set to true, this will cancel the item use behavior. + * */ - static readonly jungleTrapdoor: ItemType; + cancel: boolean; +} + +/** + * Manages callbacks that fire before an item being used on a + * block event. + */ +export class ItemUseOnBeforeEventSignal { + private constructor(); /** - * Represents an item that can place a set of kelp within - * Minecraft. + * @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. + * */ - static readonly kelp: ItemType; + subscribe(callback: (arg: ItemUseOnBeforeEvent) => void): (arg: ItemUseOnBeforeEvent) => void; /** - * Represents an item that can place a ladder within Minecraft. + * @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. */ - static readonly ladder: ItemType; + unsubscribe(callback: (arg: ItemUseOnBeforeEvent) => void): void; +} + +/** + * Contains information related to changes to a lever + * activating or deactivating. + * @example leverActionEvent.ts + * ```typescript + * import { world, system, LeverActionAfterEvent } from '@minecraft/server'; + * + * world.afterEvents.leverAction.subscribe((leverActivateEvent: LeverActionAfterEvent) => { + * console.warn( + * `Lever event at ${system.currentTick} with power: ${leverActivateEvent.block.getRedstonePower()}`, + * ); + * }); + * + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class LeverActionAfterEvent extends BlockEvent { + private constructor(); /** - * Represents an item that can place a lantern within - * Minecraft. + * @remarks + * True if the lever is activated (that is, transmitting + * power). + * */ - static readonly lantern: ItemType; + readonly isPowered: boolean; /** - * Represents an item that can place a block of lapis lazuli - * within Minecraft. + * @remarks + * Optional player that triggered the lever activation. + * */ - static readonly lapisBlock: ItemType; - static readonly lapisLazuli: ItemType; + readonly player: Player; +} + +/** + * Manages callbacks that are connected to lever moves + * (activates or deactivates). + * @example leverActionEvent.ts + * ```typescript + * import { world, system, LeverActionAfterEvent } from '@minecraft/server'; + * + * world.afterEvents.leverAction.subscribe((leverActivateEvent: LeverActionAfterEvent) => { + * console.warn( + * `Lever event at ${system.currentTick} with power: ${leverActivateEvent.block.getRedstonePower()}`, + * ); + * }); + * + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class LeverActionAfterEventSignal extends ILeverActionAfterEventSignal { + private constructor(); +} + +/** + * @beta + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class ListBlockVolume extends BlockVolumeBase { + constructor(locations: Vector3[]); /** - * Represents an item that can place a block with embedded - * lapis lazuli within Minecraft. + * @remarks + * This function can't be called in read-only mode. + * */ - static readonly lapisOre: ItemType; + add(locations: Vector3[]): void; /** - * Represents an item that can place a bud of large amethyst - * within Minecraft. + * @remarks + * This function can't be called in read-only mode. + * */ - static readonly largeAmethystBud: ItemType; - static readonly lavaBucket: ItemType; - static readonly lead: ItemType; - static readonly leather: ItemType; - static readonly leatherBoots: ItemType; - static readonly leatherChestplate: ItemType; - static readonly leatherHelmet: ItemType; - static readonly leatherHorseArmor: ItemType; - static readonly leatherLeggings: ItemType; + remove(locations: Vector3[]): void; +} + +/** + * @beta + * A specific currently-internal event used for passing + * messages from client to server. + */ +export class MessageReceiveAfterEvent { + private constructor(); /** - * Represents an item that can place a set of leaves within - * Minecraft. + * @remarks + * The message identifier. + * */ - static readonly leaves: ItemType; + readonly id: string; /** - * Represents an item that can place an updated set of leaves - * within Minecraft. + * @remarks + * The message. + * */ - static readonly leaves2: ItemType; + readonly message: string; /** - * Represents an item that can place a lectern within - * Minecraft. + * @remarks + * The player who sent the message. + * */ - static readonly lectern: ItemType; + readonly player: Player; +} + +/** + * DEPRECATED + * Use @minecraft/vanilla-data.MinecraftDimensionTypes + * A collection of default Minecraft dimension types. + */ +export class MinecraftDimensionTypes { + private constructor(); /** - * Represents an item that can place a lever within Minecraft. + * @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 lever: ItemType; + static readonly nether = 'minecraft:nether'; /** - * Represents an item that can place a block of light within - * Minecraft. + * @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 lightBlock: ItemType; + static readonly overworld = 'minecraft:overworld'; /** - * Represents an item that can place a light blue candle within - * Minecraft. + * @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 lightBlueCandle: ItemType; - static readonly lightBlueDye: ItemType; + static readonly theEnd = 'minecraft:the_end'; +} + +/** + * Contains a set of additional variable values for further + * defining how rendering and animations function. + */ +export class MolangVariableMap { /** - * Represents an item that can place a light blue block of - * glazed terracotta within Minecraft. + * @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. */ - static readonly lightBlueGlazedTerracotta: ItemType; - static readonly lightBlueWool: ItemType; + setColorRGB(variableName: string, color: RGB): void; /** - * Represents an item that can place a light gray candle within - * Minecraft. + * @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. */ - static readonly lightGrayCandle: ItemType; - static readonly lightGrayDye: ItemType; - static readonly lightGrayWool: ItemType; + setColorRGBA(variableName: string, color: RGBA): void; /** - * Represents an item that can place a lightning rod within - * Minecraft. + * @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. */ - static readonly lightningRod: ItemType; + setFloat(variableName: string, number: number): void; /** - * Represents an item that can place a light weighted pressure - * plate within Minecraft. + * @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. */ - static readonly lightWeightedPressurePlate: ItemType; + setSpeedAndDirection(variableName: string, speed: number, direction: Vector3): void; /** - * Represents an item that can place a lime candle within - * Minecraft. + * @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. */ - static readonly limeCandle: ItemType; - static readonly limeDye: ItemType; + setVector3(variableName: string, vector: Vector3): void; +} + +/** + * Contains information related to changes to a piston + * expanding or retracting. + * @example pistonAfterEvent.ts + * ```typescript + * import { world, system, PistonActivateAfterEvent } from '@minecraft/server'; + * + * world.afterEvents.pistonActivate.subscribe((pistonEvent: PistonActivateAfterEvent) => { + * console.warn( + * `Piston event at ${system.currentTick} ${(pistonEvent.piston.isMoving ? ' Moving' : 'Not moving')} with state: ${pistonEvent.piston.state}`, + * ); + * }); + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class PistonActivateAfterEvent extends BlockEvent { + private constructor(); /** - * Represents an item that can place a lime-colored block of - * glazed terracotta within Minecraft. + * @remarks + * True if the piston is the process of expanding. + * */ - static readonly limeGlazedTerracotta: ItemType; - static readonly limeWool: ItemType; - static readonly lingeringPotion: ItemType; + readonly isExpanding: boolean; /** - * Represents an item that can place a lit pumpkin within - * Minecraft. + * @remarks + * Contains additional properties and details of the piston. + * */ - static readonly litPumpkin: ItemType; - static readonly llamaSpawnEgg: ItemType; + readonly piston: BlockPistonComponent; +} + +/** + * Manages callbacks that are connected to piston activations. + * @example pistonAfterEvent.ts + * ```typescript + * import { world, system, PistonActivateAfterEvent } from '@minecraft/server'; + * + * world.afterEvents.pistonActivate.subscribe((pistonEvent: PistonActivateAfterEvent) => { + * console.warn( + * `Piston event at ${system.currentTick} ${(pistonEvent.piston.isMoving ? ' Moving' : 'Not moving')} with state: ${pistonEvent.piston.state}`, + * ); + * }); + * ``` + */ +export class PistonActivateAfterEventSignal { + private constructor(); /** - * Represents an item that can place a lodestone within - * Minecraft. + * @remarks + * This function can't be called in read-only mode. + * */ - static readonly lodestone: ItemType; - static readonly lodestoneCompass: ItemType; + subscribe(callback: (arg: PistonActivateAfterEvent) => void): (arg: PistonActivateAfterEvent) => void; /** - * Represents an item that can place a log within Minecraft. + * @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. */ - static readonly log: ItemType; + unsubscribe(callback: (arg: PistonActivateAfterEvent) => void): void; +} + +/** + * Represents a player within the world. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class Player extends Entity { + private constructor(); /** - * Represents an item that can place a more updated, - * customizable log within Minecraft. + * @remarks + * The player's Camera. + * + * @throws This property can throw when used. */ - static readonly log2: ItemType; + readonly camera: Camera; /** - * Represents an item that can place a loom within Minecraft. + * @remarks + * If true, the player is currently emoting. + * + * @throws This property can throw when used. */ - static readonly loom: ItemType; + readonly isEmoting: boolean; /** - * Represents an item that can place a magenta candle within - * Minecraft. - */ - static readonly magentaCandle: ItemType; - static readonly magentaDye: ItemType; - /** - * Represents an item that can place a block of magenta-colored - * glazed terracotta within Minecraft. - */ - static readonly magentaGlazedTerracotta: ItemType; - static readonly magentaWool: ItemType; - /** - * Represents magma within Minecraft. - */ - static readonly magma: ItemType; - static readonly magmaCream: ItemType; - static readonly magmaCubeSpawnEgg: ItemType; - static readonly mangroveBoat: ItemType; - static readonly mangroveButton: ItemType; - static readonly mangroveChestBoat: ItemType; - static readonly mangroveDoor: ItemType; - static readonly mangroveFence: ItemType; - static readonly mangroveFenceGate: ItemType; - static readonly mangroveLeaves: ItemType; - static readonly mangroveLog: ItemType; - static readonly mangrovePlanks: ItemType; - static readonly mangrovePressurePlate: ItemType; - static readonly mangrovePropagule: ItemType; - static readonly mangroveRoots: ItemType; - static readonly mangroveSign: ItemType; - static readonly mangroveSlab: ItemType; - static readonly mangroveStairs: ItemType; - static readonly mangroveTrapdoor: ItemType; - static readonly mangroveWood: ItemType; - /** - * Represents an item that can place a medium-sized bud of - * amethyst within Minecraft. - */ - static readonly mediumAmethystBud: ItemType; - /** - * Represents an item that can place a block of melon within - * Minecraft. + * @remarks + * Whether the player is flying. For example, in Creative or + * Spectator mode. + * + * @throws This property can throw when used. */ - static readonly melonBlock: ItemType; - static readonly melonSeeds: ItemType; - static readonly melonSlice: ItemType; - static readonly milkBucket: ItemType; - static readonly minecart: ItemType; + readonly isFlying: boolean; /** - * Represents an item that can place a mob spawner within - * Minecraft. + * @remarks + * Whether the player is gliding with Elytra. + * + * @throws This property can throw when used. */ - static readonly mobSpawner: ItemType; - static readonly mojangBannerPattern: ItemType; + readonly isGliding: boolean; /** - * Represents an item that can place a monster egg within - * Minecraft. + * @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. */ - static readonly monsterEgg: ItemType; - static readonly mooshroomSpawnEgg: ItemType; + readonly isJumping: boolean; /** - * Represents an item that can place a block of moss within - * Minecraft. + * @remarks + * The current overall level for the player, based on their + * experience. + * + * @throws This property can throw when used. */ - static readonly mossBlock: ItemType; + readonly level: number; /** - * Represents an item that can place a carpet of moss within - * Minecraft. - */ - static readonly mossCarpet: ItemType; - /** - * Represents an item that can place a block of cobblestone - * with moss within Minecraft. - */ - static readonly mossyCobblestone: ItemType; - /** - * Represents an item that can place a set of mossy cobblestone - * stairs within Minecraft. - */ - static readonly mossyCobblestoneStairs: ItemType; - /** - * Represents an item that can place a set of mossy stone brick - * stairs within Minecraft. - */ - static readonly mossyStoneBrickStairs: ItemType; - static readonly mud: ItemType; - static readonly mudBricks: ItemType; - static readonly mudBrickSlab: ItemType; - static readonly mudBrickStairs: ItemType; - static readonly mudBrickWall: ItemType; - static readonly muddyMangroveRoots: ItemType; - static readonly muleSpawnEgg: ItemType; - static readonly mushroomStew: ItemType; - static readonly musicDisc11: ItemType; - static readonly musicDisc13: ItemType; - static readonly musicDisc5: ItemType; - static readonly musicDiscBlocks: ItemType; - static readonly musicDiscCat: ItemType; - static readonly musicDiscChirp: ItemType; - static readonly musicDiscFar: ItemType; - static readonly musicDiscMall: ItemType; - static readonly musicDiscMellohi: ItemType; - static readonly musicDiscOtherside: ItemType; - static readonly musicDiscPigstep: ItemType; - static readonly musicDiscStal: ItemType; - static readonly musicDiscStrad: ItemType; - static readonly musicDiscWait: ItemType; - static readonly musicDiscWard: ItemType; - static readonly mutton: ItemType; - /** - * Represents an item that can place a mycelium plant within - * Minecraft. + * @remarks + * Name of the player. + * + * @throws This property can throw when used. */ - static readonly mycelium: ItemType; - static readonly nameTag: ItemType; - static readonly nautilusShell: ItemType; + readonly name: string; /** - * Represents an item that can place a nether brick block - * within Minecraft. + * @remarks + * Contains methods for manipulating the on-screen display of a + * Player. + * + * @throws This property can throw when used. */ - static readonly netherbrick: ItemType; + readonly onScreenDisplay: ScreenDisplay; /** - * Represents an item that can place a nether brick block - * within Minecraft. + * @beta + * @remarks + * Manages the selected slot in the player's hotbar. + * + * This property can't be edited in read-only mode. + * */ - static readonly netherBrick: ItemType; + selectedSlot: number; /** - * Represents an item that can place a nether brick fence - * within Minecraft. + * @remarks + * The overall total set of experience needed to achieve the + * next level for a player. + * + * @throws This property can throw when used. */ - static readonly netherBrickFence: ItemType; + readonly totalXpNeededForNextLevel: number; /** - * Represents an item that can place a set of nether brick - * stairs within Minecraft. + * @remarks + * The current set of experience achieved for the player. + * + * @throws This property can throw when used. */ - static readonly netherBrickStairs: ItemType; + readonly xpEarnedAtCurrentLevel: number; /** - * Represents an item that can place a block of nether with - * embedded gold ore within Minecraft. + * @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. */ - static readonly netherGoldOre: ItemType; - static readonly netheriteAxe: ItemType; + addExperience(amount: number): number; /** - * Represents an item that can place a block of netherite - * within Minecraft. + * @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. */ - static readonly netheriteBlock: ItemType; - static readonly netheriteBoots: ItemType; - static readonly netheriteChestplate: ItemType; - static readonly netheriteHelmet: ItemType; - static readonly netheriteHoe: ItemType; - static readonly netheriteIngot: ItemType; - static readonly netheriteLeggings: ItemType; - static readonly netheritePickaxe: ItemType; - static readonly netheriteScrap: ItemType; - static readonly netheriteShovel: ItemType; - static readonly netheriteSword: ItemType; + addLevels(amount: number): number; /** - * Represents an item that can place a block of netherrack - * within Minecraft. + * @beta + * @remarks + * Eats an item, providing the item's hunger and saturation + * effects to the player. Can only be used on food items. + * + * This function can't be called in read-only mode. + * + * @param itemStack + * The item to eat. + * @throws + * Throws if the item is not a food item. */ - static readonly netherrack: ItemType; + eatItem(itemStack: ItemStack): void; /** - * Represents nether sprouts within Minecraft. + * @beta + * @throws This function can throw errors. */ - static readonly netherSprouts: ItemType; - static readonly netherStar: ItemType; + getGameMode(): GameMode; /** - * Represents nether wart within Minecraft. + * @beta + * @remarks + * Gets the current item cooldown time for a particular + * cooldown category. + * + * @param cooldownCategory + * Specifies the cooldown category to retrieve the current + * cooldown for. + * @throws This function can throw errors. */ - static readonly netherWart: ItemType; + getItemCooldown(cooldownCategory: string): number; /** - * Represents an item that can place a block of nether wart - * within Minecraft. + * @remarks + * Gets the current spawn point of the player. + * + * @throws This function can throw errors. */ - static readonly netherWartBlock: ItemType; + getSpawnPoint(): DimensionLocation | undefined; /** - * Represents an item that can place a standard set of stone - * stairs within Minecraft. + * @remarks + * Gets the total experience of the Player. + * + * @throws This function can throw errors. */ - static readonly normalStoneStairs: ItemType; + getTotalXp(): number; /** - * Represents an item that can place a note block within - * Minecraft. + * @beta + * @remarks + * Returns true if this player has operator-level permissions. + * + * @throws This function can throw errors. */ - static readonly noteblock: ItemType; - static readonly oakBoat: ItemType; - static readonly oakChestBoat: ItemType; - static readonly oakSign: ItemType; + isOp(): boolean; /** - * Represents an item that can place a set of oak stairs within - * Minecraft. + * @remarks + * Plays a music track that only this particular player can + * hear. + * + * This function can't be called in read-only mode. + * + * @param trackId + * Identifier of the music track to play. + * @param musicOptions + * Additional options for the music track. + * @throws This function can throw errors. */ - static readonly oakStairs: ItemType; + playMusic(trackId: string, musicOptions?: MusicOptions): void; /** - * Represents an item that can place an observer within - * Minecraft. + * @remarks + * Plays a sound that only this particular player can hear. + * + * This function can't be called in read-only mode. + * + * @param soundOptions + * Additional optional options for the sound. + * @throws This function can throw errors. */ - static readonly observer: ItemType; + playSound(soundId: string, soundOptions?: PlayerSoundOptions): void; /** - * Represents an item that can place an obsidian block within - * Minecraft. + * @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. */ - static readonly obsidian: ItemType; - static readonly ocelotSpawnEgg: ItemType; - static readonly ochreFroglight: ItemType; + postClientMessage(id: string, value: string): void; /** - * Represents an item that can place an orange candle within - * Minecraft. + * @remarks + * Queues an additional music track that only this particular + * player can hear. If a track is not playing, a music track + * will play. + * + * This function can't be called in read-only mode. + * + * @param trackId + * Identifier of the music track to play. + * @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. + * */ - static readonly orangeCandle: ItemType; - static readonly orangeDye: ItemType; + queueMusic(trackId: string, musicOptions?: MusicOptions): void; /** - * Represents an item that can place a block of orange-colored - * glazed terracotta within Minecraft. + * @remarks + * Resets the level of the player. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly orangeGlazedTerracotta: ItemType; - static readonly orangeWool: ItemType; + resetLevel(): void; /** - * Represents an item that can place a block of oxidized copper - * within Minecraft. + * @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 sendMessagesToPlayer.ts + * ```typescript + * import { Player } from "@minecraft/server"; + * + * function sendPlayerMessages(player: Player) { + * // Displays "First or Second" + * const rawMessage = { translate: 'accessibility.list.or.two', with: ['First', 'Second'] }; + * player.sendMessage(rawMessage); + * + * // Displays "Hello, world!" + * player.sendMessage('Hello, world!'); + * + * // Displays "Welcome, Amazing Player 1!" + * player.sendMessage({ translate: 'authentication.welcome', with: ['Amazing Player 1'] }); + * + * // Displays the player's score for objective "obj". Each player will see their own score. + * const rawMessageWithScore = { score: { name: '*', objective: 'obj' } }; + * player.sendMessage(rawMessageWithScore); + * + * // Displays "Apple or Coal" + * const rawMessageWithNestedTranslations = { + * translate: 'accessibility.list.or.two', + * with: { rawtext: [{ translate: 'item.apple.name' }, { translate: 'item.coal.name' }] }, + * }; + * player.sendMessage(rawMessageWithNestedTranslations); + * } + * ``` */ - static readonly oxidizedCopper: ItemType; + sendMessage(message: (RawMessage | string)[] | RawMessage | string): void; /** - * Represents an item that can place a block of oxidized cut - * copper within Minecraft. + * @beta + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly oxidizedCutCopper: ItemType; + setGameMode(gameMode?: GameMode): void; /** - * Represents an item that can place a slab of oxidized cut - * copper within Minecraft. + * @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. */ - static readonly oxidizedCutCopperSlab: ItemType; + setOp(isOp: boolean): void; /** - * Represents an item that can place a set of oxidized cut - * copper stairs within Minecraft. + * @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} */ - static readonly oxidizedCutCopperStairs: ItemType; + setSpawnPoint(spawnPoint?: DimensionLocation): void; /** - * Represents an item that can place a block of packed ice - * within Minecraft. + * @beta + * @remarks + * Creates a new particle emitter at a specified location in + * the world. Only visible to the target player. + * + * 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 Error} + * + * {@link LocationInUnloadedChunkError} + * + * {@link LocationOutOfWorldBoundariesError} + * @example spawnParticle.ts + * ```typescript + * import { world, MolangVariableMap, Vector3 } from '@minecraft/server'; + * + * world.afterEvents.playerSpawn.subscribe(event => { + * const targetLocation = event.player.location; + * for (let i = 0; i < 100; i++) { + * const molang = new MolangVariableMap(); + * + * molang.setColorRGB('variable.color', { + * red: Math.random(), + * green: Math.random(), + * blue: Math.random() + * }); + * + * const newLocation: Vector3 = { + * 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, + * }; + * event.player.spawnParticle('minecraft:colored_flame_particle', newLocation, molang); + * } + * }); + * ``` */ - static readonly packedIce: ItemType; - static readonly packedMud: ItemType; - static readonly painting: ItemType; - static readonly pandaSpawnEgg: ItemType; - static readonly paper: ItemType; - static readonly parrotSpawnEgg: ItemType; - static readonly pearlescentFroglight: ItemType; - static readonly phantomMembrane: ItemType; - static readonly phantomSpawnEgg: ItemType; - static readonly piglinBannerPattern: ItemType; - static readonly piglinBruteSpawnEgg: ItemType; - static readonly piglinSpawnEgg: ItemType; - static readonly pigSpawnEgg: ItemType; - static readonly pillagerSpawnEgg: ItemType; + spawnParticle(effectName: string, location: Vector3, molangVariables?: MolangVariableMap): void; /** - * Represents an item that can place a pink candle within - * Minecraft. + * @beta + * @remarks + * Sets the item cooldown time for a particular cooldown + * category. + * + * This function can't be called in read-only mode. + * + * @param cooldownCategory + * 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. */ - static readonly pinkCandle: ItemType; - static readonly pinkDye: ItemType; + startItemCooldown(cooldownCategory: string, tickDuration: number): void; /** - * Represents an item that can place a pink-colored block of - * glazed terracotta within Minecraft. + * @remarks + * Stops any music tracks from playing for this particular + * player. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly pinkGlazedTerracotta: ItemType; - static readonly pinkWool: ItemType; + stopMusic(): void; +} + +/** + * 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(); /** - * Represents an item that can place a piston within Minecraft. + * @remarks + * Returns permutation information about this block before it + * was broken. + * */ - static readonly piston: ItemType; + readonly brokenBlockPermutation: BlockPermutation; /** - * Represents an item that can place a set of planks within - * Minecraft. + * @remarks + * The item stack that was used to break the block after the + * block was broken, or undefined if empty hand. + * */ - static readonly planks: ItemType; + readonly itemStackAfterBreak?: ItemStack; /** - * Represents podzol within Minecraft. + * @remarks + * The item stack that was used to break the block before the + * block was broken, or undefined if empty hand. + * */ - static readonly podzol: ItemType; + readonly itemStackBeforeBreak?: ItemStack; /** - * Represents pointed dripstone within Minecraft. + * @remarks + * Player that broke the block for this event. + * */ - static readonly pointedDripstone: ItemType; - static readonly poisonousPotato: ItemType; - static readonly polarBearSpawnEgg: ItemType; + readonly player: Player; +} + +/** + * Manages callbacks that are connected to when a player breaks + * a block. + */ +export class PlayerBreakBlockAfterEventSignal { + private constructor(); /** - * Represents an item that can place a set of polished andesite - * stairs within Minecraft. + * @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. + * */ - static readonly polishedAndesiteStairs: ItemType; + subscribe( + callback: (arg: PlayerBreakBlockAfterEvent) => void, + options?: BlockEventOptions, + ): (arg: PlayerBreakBlockAfterEvent) => void; /** - * Represents an item that can place a block of polished basalt - * within Minecraft. + * @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. */ - static readonly polishedBasalt: ItemType; + unsubscribe(callback: (arg: PlayerBreakBlockAfterEvent) => void): void; +} + +/** + * 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(); /** - * Represents an item that can place a block of polished - * blackstone within Minecraft. + * @remarks + * If set to true, cancels the block break event. + * */ - static readonly polishedBlackstone: ItemType; + cancel: boolean; /** - * Represents an item that can place a block of polished - * blackstone bricks within Minecraft. + * @remarks + * The item stack that is being used to break the block, or + * undefined if empty hand. + * */ - static readonly polishedBlackstoneBricks: ItemType; + itemStack?: ItemStack; /** - * Represents an item that can place a slab of polished - * blackstone within Minecraft. + * @remarks + * Player breaking the block for this event. + * */ - static readonly polishedBlackstoneBrickSlab: ItemType; + readonly player: Player; +} + +/** + * Manages callbacks that are connected to before a player + * breaks a block. + */ +export class PlayerBreakBlockBeforeEventSignal { + private constructor(); /** - * Represents an item that can place a set of polished - * blackstone brick stairs within Minecraft. + * @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. + * */ - static readonly polishedBlackstoneBrickStairs: ItemType; + subscribe( + callback: (arg: PlayerBreakBlockBeforeEvent) => void, + options?: BlockEventOptions, + ): (arg: PlayerBreakBlockBeforeEvent) => void; /** - * Represents an item that can place a polished blackstone - * brick wall within Minecraft. + * @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. */ - static readonly polishedBlackstoneBrickWall: ItemType; + unsubscribe(callback: (arg: PlayerBreakBlockBeforeEvent) => void): void; +} + +/** + * Contains information related to changes to a player's + * dimension having been changed. + */ +export class PlayerDimensionChangeAfterEvent { + private constructor(); /** - * Represents an item that can place a polished blackstone - * button within Minecraft. + * @remarks + * The dimension the player is changing from. + * */ - static readonly polishedBlackstoneButton: ItemType; + readonly fromDimension: Dimension; /** - * Represents an item that can place a polished blackstone - * pressure plate within Minecraft. + * @remarks + * The location the player was at before changing dimensions. + * */ - static readonly polishedBlackstonePressurePlate: ItemType; + readonly fromLocation: Vector3; /** - * Represents an item that can place a slab of polished - * blackstone within Minecraft. + * @remarks + * Handle to the player that is changing dimensions. + * */ - static readonly polishedBlackstoneSlab: ItemType; + readonly player: Player; /** - * Represents an item that can place a set of polished - * blackstone stairs within Minecraft. + * @remarks + * The dimension that the player is changing to. + * */ - static readonly polishedBlackstoneStairs: ItemType; + readonly toDimension: Dimension; /** - * Represents an item that can place a polished blackstone wall - * within Minecraft. + * @remarks + * The location the player will spawn to after changing + * dimensions. + * */ - static readonly polishedBlackstoneWall: ItemType; + readonly toLocation: Vector3; +} + +/** + * Manages callbacks that are connected to successful player + * dimension changes. + */ +export class PlayerDimensionChangeAfterEventSignal { + private constructor(); /** - * Represents an item that can place a block of polished - * deepslate within Minecraft. + * @remarks + * Subscribes the specified callback to a player dimension + * change after event. + * + * This function can't be called in read-only mode. + * */ - static readonly polishedDeepslate: ItemType; + subscribe(callback: (arg: PlayerDimensionChangeAfterEvent) => void): (arg: PlayerDimensionChangeAfterEvent) => void; /** - * Represents an item that can place a slab of polished - * deepslate within Minecraft. + * @remarks + * Removes the specified callback from a player dimension + * change after event. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly polishedDeepslateSlab: ItemType; + unsubscribe(callback: (arg: PlayerDimensionChangeAfterEvent) => void): void; +} + +/** + * @beta + */ +export class PlayerGameModeChangeAfterEvent { + private constructor(); + readonly fromGameMode: GameMode; + readonly player: Player; + readonly toGameMode: GameMode; +} + +/** + * @beta + */ +export class PlayerGameModeChangeAfterEventSignal { + private constructor(); /** - * Represents an item that can place a set of polished - * deepslate stairs within Minecraft. + * @remarks + * This function can't be called in read-only mode. + * */ - static readonly polishedDeepslateStairs: ItemType; + subscribe(callback: (arg: PlayerGameModeChangeAfterEvent) => void): (arg: PlayerGameModeChangeAfterEvent) => void; /** - * Represents an item that can place a wall of polished - * deepslate within Minecraft. + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly polishedDeepslateWall: ItemType; + unsubscribe(callback: (arg: PlayerGameModeChangeAfterEvent) => void): void; +} + +/** + * @beta + */ +export class PlayerGameModeChangeBeforeEvent { + private constructor(); + cancel: boolean; + readonly fromGameMode: GameMode; + readonly player: Player; + toGameMode: GameMode; +} + +/** + * @beta + */ +export class PlayerGameModeChangeBeforeEventSignal { + private constructor(); /** - * Represents an item that can place a block of polished - * diorite within Minecraft. + * @remarks + * This function can't be called in read-only mode. + * */ - static readonly polishedDioriteStairs: ItemType; + subscribe(callback: (arg: PlayerGameModeChangeBeforeEvent) => void): (arg: PlayerGameModeChangeBeforeEvent) => void; /** - * Represents an item that can place a set of polished granite - * stairs within Minecraft. + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly polishedGraniteStairs: ItemType; - static readonly poppedChorusFruit: ItemType; - static readonly porkchop: ItemType; - static readonly potato: ItemType; - static readonly potion: ItemType; - static readonly powderSnowBucket: ItemType; + unsubscribe(callback: (arg: PlayerGameModeChangeBeforeEvent) => void): void; +} + +/** + * Contains information regarding an event after a player + * interacts with a block. + */ +export class PlayerInteractWithBlockAfterEvent { + private constructor(); /** - * Represents an item that can place a block of prismarine - * within Minecraft. + * @remarks + * The block that will be interacted with. + * */ - static readonly prismarine: ItemType; + readonly block: Block; /** - * Represents an item that can place a set of prismarine brick - * stairs within Minecraft. + * @remarks + * The face of the block that is being interacted with. + * */ - static readonly prismarineBricksStairs: ItemType; - static readonly prismarineCrystals: ItemType; - static readonly prismarineShard: ItemType; + readonly blockFace: Direction; /** - * Represents an item that can place a set of prismarine stairs - * within Minecraft. + * @remarks + * Location relative to the bottom north-west corner of the + * block where the item is placed. + * */ - static readonly prismarineStairs: ItemType; - static readonly pufferfish: ItemType; - static readonly pufferfishBucket: ItemType; - static readonly pufferfishSpawnEgg: ItemType; + readonly faceLocation: Vector3; /** - * Represents an item that can place a pumpkin within - * Minecraft. + * @remarks + * The item stack that is being used in the interaction, or + * undefined if empty hand. + * */ - static readonly pumpkin: ItemType; - static readonly pumpkinPie: ItemType; - static readonly pumpkinSeeds: ItemType; + readonly itemStack?: ItemStack; /** - * Represents an item that can place a purple candle within - * Minecraft. + * @remarks + * Source Player for this event. + * */ - static readonly purpleCandle: ItemType; - static readonly purpleDye: ItemType; + readonly player: Player; +} + +/** + * Manages callbacks that are connected to after a player + * interacts with a block. + */ +export class PlayerInteractWithBlockAfterEventSignal { + private constructor(); /** - * Represents an item that can place a purple-colored block of - * glazed terracotta within Minecraft. + * @remarks + * Adds a callback that will be called after a player interacts + * with a block. + * + * This function can't be called in read-only mode. + * */ - static readonly purpleGlazedTerracotta: ItemType; - static readonly purpleWool: ItemType; + subscribe( + callback: (arg: PlayerInteractWithBlockAfterEvent) => void, + ): (arg: PlayerInteractWithBlockAfterEvent) => void; /** - * Represents an item that can place a purpur block within - * Minecraft. + * @remarks + * Removes a callback from being called after a player + * interacts with a block. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly purpurBlock: ItemType; + unsubscribe(callback: (arg: PlayerInteractWithBlockAfterEvent) => void): void; +} + +/** + * Contains information regarding an event before a player + * interacts with a block. + */ +export class PlayerInteractWithBlockBeforeEvent { + private constructor(); /** - * Represents an item that can place a set of purpur stairs - * within Minecraft. + * @remarks + * The block that will be interacted with. + * */ - static readonly purpurStairs: ItemType; - static readonly quartz: ItemType; + readonly block: Block; /** - * Represents an item that can place a block of solid quartz - * within Minecraft. + * @remarks + * The face of the block that is being interacted with. + * */ - static readonly quartzBlock: ItemType; + readonly blockFace: Direction; /** - * Represents an item that can place a block of solid quartz - * bricks within Minecraft. + * @remarks + * If set to true the interaction will be cancelled. + * */ - static readonly quartzBricks: ItemType; + cancel: boolean; /** - * Represents an item that can place a block with embedded - * quartz ore within Minecraft. + * @remarks + * Location relative to the bottom north-west corner of the + * block where the item is placed. + * */ - static readonly quartzOre: ItemType; + readonly faceLocation: Vector3; /** - * Represents an item that can place a set of quartz stairs - * within Minecraft. + * @remarks + * The item stack that is being used in the interaction, or + * undefined if empty hand. + * */ - static readonly quartzStairs: ItemType; - static readonly rabbit: ItemType; - static readonly rabbitFoot: ItemType; - static readonly rabbitHide: ItemType; - static readonly rabbitSpawnEgg: ItemType; - static readonly rabbitStew: ItemType; + readonly itemStack?: ItemStack; /** - * Represents an item that can place a set of rails within - * Minecraft. + * @remarks + * Source Player for this event. + * */ - static readonly rail: ItemType; - static readonly ravagerSpawnEgg: ItemType; - static readonly rawCopper: ItemType; + readonly player: Player; +} + +/** + * Manages callbacks that are connected to before a player + * interacts with a block. + */ +export class PlayerInteractWithBlockBeforeEventSignal { + private constructor(); /** - * Represents an item that can place a block of raw copper - * within Minecraft. + * @remarks + * Adds a callback that will be called before a player + * interacts with a block. + * + * This function can't be called in read-only mode. + * */ - static readonly rawCopperBlock: ItemType; - static readonly rawGold: ItemType; + subscribe( + callback: (arg: PlayerInteractWithBlockBeforeEvent) => void, + ): (arg: PlayerInteractWithBlockBeforeEvent) => void; /** - * Represents an item that can place a block of raw gold within - * Minecraft. + * @remarks + * Removes a callback from being called before a player + * interacts with a block. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly rawGoldBlock: ItemType; - static readonly rawIron: ItemType; + unsubscribe(callback: (arg: PlayerInteractWithBlockBeforeEvent) => void): void; +} + +/** + * Contains information regarding an event after a player + * interacts with an entity. + */ +export class PlayerInteractWithEntityAfterEvent { + private constructor(); /** - * Represents an item that can place a block of raw iron within - * Minecraft. + * @remarks + * The item stack that is being used in the interaction, or + * undefined if empty hand. + * */ - static readonly rawIronBlock: ItemType; - static readonly recoveryCompass: ItemType; + readonly itemStack?: ItemStack; /** - * Represents an item that can place a red candle within - * Minecraft. + * @remarks + * Source Player for this event. + * */ - static readonly redCandle: ItemType; - static readonly redDye: ItemType; + readonly player: Player; /** - * Represents an item that can place a red flower within - * Minecraft. + * @remarks + * The entity that will be interacted with. + * */ - static readonly redFlower: ItemType; + readonly target: Entity; +} + +/** + * Manages callbacks that are connected to after a player + * interacts with an entity. + */ +export class PlayerInteractWithEntityAfterEventSignal { + private constructor(); /** - * Represents an item that can place a red-colored block of - * glazed terracotta within Minecraft. + * @remarks + * Adds a callback that will be called after a player interacts + * with an entity. + * + * This function can't be called in read-only mode. + * */ - static readonly redGlazedTerracotta: ItemType; + subscribe( + callback: (arg: PlayerInteractWithEntityAfterEvent) => void, + ): (arg: PlayerInteractWithEntityAfterEvent) => void; /** - * Represents an item that can place a red mushroom within - * Minecraft. + * @remarks + * Removes a callback from being called after a player + * interacts with an entity. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly redMushroom: ItemType; + unsubscribe(callback: (arg: PlayerInteractWithEntityAfterEvent) => void): void; +} + +/** + * Contains information regarding an event before a player + * interacts with an entity. + */ +export class PlayerInteractWithEntityBeforeEvent { + private constructor(); /** - * Represents an item that can place a block of red mushroom - * within Minecraft. + * @remarks + * If set to true the interaction will be cancelled. + * */ - static readonly redMushroomBlock: ItemType; + cancel: boolean; /** - * Represents an item that can place a block of red nether - * brick within Minecraft. + * @remarks + * The item stack that is being used in the interaction, or + * undefined if empty hand. + * */ - static readonly redNetherBrick: ItemType; + readonly itemStack?: ItemStack; /** - * Represents an item that can place a set of red nether brick - * stairs within Minecraft. + * @remarks + * Source Player for this event. + * */ - static readonly redNetherBrickStairs: ItemType; + readonly player: Player; /** - * Represents an item that can place a block of red sandstone - * within Minecraft. + * @remarks + * The entity that will be interacted with. + * */ - static readonly redSandstone: ItemType; + readonly target: Entity; +} + +/** + * Manages callbacks that are connected to before a player + * interacts with an entity. + */ +export class PlayerInteractWithEntityBeforeEventSignal { + private constructor(); /** - * Represents an item that can place a set of red sandstone - * stairs within Minecraft. + * @remarks + * Adds a callback that will be called before a player + * interacts with an entity. + * + * This function can't be called in read-only mode. + * */ - static readonly redSandstoneStairs: ItemType; - static readonly redstone: ItemType; + subscribe( + callback: (arg: PlayerInteractWithEntityBeforeEvent) => void, + ): (arg: PlayerInteractWithEntityBeforeEvent) => void; /** - * Represents an item that can place a block of redstone within - * Minecraft. + * @remarks + * Removes a callback from being called before a player + * interacts with an entity. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly redstoneBlock: ItemType; + unsubscribe(callback: (arg: PlayerInteractWithEntityBeforeEvent) => 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(); /** - * Represents an item that can place a redstone lamp within - * Minecraft. + * @remarks + * This function can't be called in read-only mode. + * */ - static readonly redstoneLamp: ItemType; + [Symbol.iterator](): Iterator; /** - * Represents an item that can place a block with embedded - * redstone ore within Minecraft. + * @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. + * */ - static readonly redstoneOre: ItemType; + next(): IteratorResult; +} + +/** + * 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(); /** - * Represents an item that can place a redstone torch within - * Minecraft. + * @remarks + * Opaque string identifier of the player that joined the game. + * */ - static readonly redstoneTorch: ItemType; - static readonly redWool: ItemType; - static readonly reinforcedDeepslate: ItemType; - static readonly repeater: ItemType; + readonly playerId: string; /** - * Represents an item that can place a repeating command block - * within Minecraft. + * @remarks + * Name of the player that has joined. + * */ - static readonly repeatingCommandBlock: ItemType; + 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(); /** - * Represents an item that can place a respawn anchor within - * Minecraft. + * @remarks + * Opaque string identifier of the player that has left the + * event. + * */ - static readonly respawnAnchor: ItemType; - static readonly rottenFlesh: ItemType; - static readonly saddle: ItemType; - static readonly salmon: ItemType; - static readonly salmonBucket: ItemType; - static readonly salmonSpawnEgg: ItemType; + readonly playerId: string; /** - * Represents an item that can place a block of sand within - * Minecraft. + * @remarks + * Player that has left the world. + * */ - static readonly sand: ItemType; + 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(); +} + +/** + * Contains information regarding a player that is leaving the + * world. + */ +export class PlayerLeaveBeforeEvent { + private constructor(); /** - * Represents an item that can place a block of sandstone - * within Minecraft. + * @remarks + * The leaving player. + * */ - static readonly sandstone: ItemType; + readonly player: Player; +} + +/** + * Manages callbacks that are connected to a player leaving the + * world. + */ +export class PlayerLeaveBeforeEventSignal { + private constructor(); /** - * Represents an item that can place a set of sandstone stairs - * within Minecraft. + * @remarks + * Adds a callback that will be called when a player leaves the + * world. + * + * This function can't be called in read-only mode. + * */ - static readonly sandstoneStairs: ItemType; + subscribe(callback: (arg: PlayerLeaveBeforeEvent) => void): (arg: PlayerLeaveBeforeEvent) => void; /** - * Represents an item that can place a sapling within - * Minecraft. + * @remarks + * Removes a callback that will be called when a player leaves + * the world. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly sapling: ItemType; + unsubscribe(callback: (arg: PlayerLeaveBeforeEvent) => void): void; +} + +/** + * 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(); /** - * Represents an item that can place a set of scaffolding - * within Minecraft. + * @remarks + * Player that placed the block for this event. + * */ - static readonly scaffolding: ItemType; - static readonly sculk: ItemType; - static readonly sculkCatalyst: ItemType; + readonly player: Player; +} + +/** + * Manages callbacks that are connected to when a block is + * placed by a player. + */ +export class PlayerPlaceBlockAfterEventSignal { + private constructor(); /** - * Represents an item that can place a sculk sensor within - * Minecraft. + * @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. + * */ - static readonly sculkSensor: ItemType; - static readonly sculkShrieker: ItemType; - static readonly sculkVein: ItemType; - static readonly scute: ItemType; + subscribe( + callback: (arg: PlayerPlaceBlockAfterEvent) => void, + options?: BlockEventOptions, + ): (arg: PlayerPlaceBlockAfterEvent) => void; /** - * Represents seagrass within Minecraft. + * @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. */ - static readonly seagrass: ItemType; - static readonly seaLantern: ItemType; + 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(); /** - * Represents an item that can place a seapickle within - * Minecraft. + * @remarks + * If set to true, cancels the block place event. + * */ - static readonly seaPickle: ItemType; - static readonly shears: ItemType; - static readonly sheepSpawnEgg: ItemType; - static readonly shield: ItemType; + cancel: boolean; /** - * Represents an item that can place a shroom light within - * Minecraft. + * @remarks + * The face of the block that the new block is being placed on. + * */ - static readonly shroomlight: ItemType; + readonly face: Direction; /** - * Represents an item that can place a shulker box within - * Minecraft. + * @remarks + * Location relative to the bottom north-west corner of the + * block where the new block is being placed onto. + * */ - static readonly shulkerBox: ItemType; - static readonly shulkerShell: ItemType; - static readonly shulkerSpawnEgg: ItemType; - static readonly silverfishSpawnEgg: ItemType; + readonly faceLocation: Vector3; /** - * Represents an item that can place a silver-colored block of - * glazed terracotta within Minecraft. + * @remarks + * The block permutation that is being placed. + * */ - static readonly silverGlazedTerracotta: ItemType; - static readonly skeletonHorseSpawnEgg: ItemType; - static readonly skeletonSpawnEgg: ItemType; + readonly permutationBeingPlaced: BlockPermutation; /** - * Represents an item that can place a skull within Minecraft. + * @remarks + * Player that is placing the block for this event. + * */ - static readonly skull: ItemType; - static readonly skullBannerPattern: ItemType; + readonly player: Player; +} + +/** + * @beta + * Manages callbacks that are connected to before a block is + * placed by a player. + */ +export class PlayerPlaceBlockBeforeEventSignal { + private constructor(); /** - * Represents slime within Minecraft. + * @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. + * */ - static readonly slime: ItemType; - static readonly slimeBall: ItemType; - static readonly slimeSpawnEgg: ItemType; + subscribe( + callback: (arg: PlayerPlaceBlockBeforeEvent) => void, + options?: BlockEventOptions, + ): (arg: PlayerPlaceBlockBeforeEvent) => void; /** - * Represents an item that can place a small bud of amethyst - * within Minecraft. + * @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. */ - static readonly smallAmethystBud: ItemType; + unsubscribe(callback: (arg: PlayerPlaceBlockBeforeEvent) => void): void; +} + +/** + * An event that contains more information about a player + * spawning. + */ +export class PlayerSpawnAfterEvent { + private constructor(); /** - * Represents an item that can place a small dripleaf block - * within Minecraft. + * @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. + * */ - static readonly smallDripleafBlock: ItemType; + initialSpawn: boolean; /** - * Represents an item that can place a smithing table within - * Minecraft. + * @remarks + * Object that represents the player that joined the game. + * + * This property can't be edited in read-only mode. + * */ - static readonly smithingTable: ItemType; + 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(); /** - * Represents an item that can place a smoker within Minecraft. + * @remarks + * The redstone power of the pressure plate before it was + * popped. + * */ - static readonly smoker: ItemType; + readonly previousRedstonePower: number; /** - * Represents an item that can place a block of smooth basalt - * within Minecraft. + * @remarks + * The redstone power of the pressure plate at the time of the + * pop. + * */ - static readonly smoothBasalt: ItemType; + readonly redstonePower: number; +} + +/** + * Manages callbacks that are connected to when a pressure + * plate is popped. + */ +export class PressurePlatePopAfterEventSignal { + private constructor(); /** - * Represents an item that can place a set of smooth quartz - * stairs within Minecraft. + * @remarks + * Adds a callback that will be called when a pressure plate is + * popped. + * + * This function can't be called in read-only mode. + * */ - static readonly smoothQuartzStairs: ItemType; + subscribe(callback: (arg: PressurePlatePopAfterEvent) => void): (arg: PressurePlatePopAfterEvent) => void; /** - * Represents an item that can place a set of smooth red - * sandstone stairs within Minecraft. + * @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. */ - static readonly smoothRedSandstoneStairs: ItemType; + 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(); /** - * Represents an item that can place a set of smooth redstone - * stairs within Minecraft. + * @remarks + * The redstone power of the pressure plate before it was + * pushed. + * */ - static readonly smoothSandstoneStairs: ItemType; + readonly previousRedstonePower: number; /** - * Represents an item that can place a smooth stone block - * within Minecraft. + * @remarks + * The redstone power of the pressure plate at the time of the + * push. + * */ - static readonly smoothStone: ItemType; + readonly redstonePower: number; /** - * Represents snow within Minecraft. + * @remarks + * Source that triggered the pressure plate push. + * */ - static readonly snow: ItemType; - static readonly snowball: ItemType; - static readonly snowGolemSpawnEgg: ItemType; + readonly source: Entity; +} + +/** + * Manages callbacks that are connected to when a pressure + * plate is pushed. + */ +export class PressurePlatePushAfterEventSignal { + private constructor(); /** - * Represents an item that can place a layer of snow within - * Minecraft. + * @remarks + * Adds a callback that will be called when a pressure plate is + * pushed. + * + * This function can't be called in read-only mode. + * */ - static readonly snowLayer: ItemType; + subscribe(callback: (arg: PressurePlatePushAfterEvent) => void): (arg: PressurePlatePushAfterEvent) => void; /** - * Represents an item that can place a soul campfire within - * Minecraft. + * @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. */ - static readonly soulCampfire: ItemType; + unsubscribe(callback: (arg: PressurePlatePushAfterEvent) => void): void; +} + +/** + * Contains information related to a projectile hitting a + * block. + */ +export class ProjectileHitBlockAfterEvent { + private constructor(); /** - * Represents an item that can place a soul lantern within - * Minecraft. + * @remarks + * Dimension where this projectile hit took place. + * */ - static readonly soulLantern: ItemType; + readonly dimension: Dimension; /** - * Represents an item that can place a block of soul sand - * within Minecraft. + * @remarks + * Direction vector of the projectile as it hit a block. + * */ - static readonly soulSand: ItemType; + readonly hitVector: Vector3; /** - * Represents soul soil within Minecraft. + * @remarks + * Location where the projectile hit occurred. + * */ - static readonly soulSoil: ItemType; + readonly location: Vector3; /** - * Represents an item that can place a soul torch within - * Minecraft. + * @remarks + * Entity for the projectile that hit a block. + * */ - static readonly soulTorch: ItemType; - static readonly spawnEgg: ItemType; - static readonly spiderEye: ItemType; - static readonly spiderSpawnEgg: ItemType; - static readonly splashPotion: ItemType; + readonly projectile: Entity; /** - * Represents an item that can place a sponge within Minecraft. + * @remarks + * Optional source entity that fired the projectile. + * */ - static readonly sponge: ItemType; + readonly source?: Entity; /** - * Represents an item that can place a spore blossom within - * Minecraft. + * @remarks + * Contains additional information about the block that was hit + * by the projectile. + * + * This function can't be called in read-only mode. + * */ - static readonly sporeBlossom: ItemType; - static readonly spruceBoat: ItemType; + getBlockHit(): BlockHitInformation; +} + +/** + * Manages callbacks that are connected to when a projectile + * hits a block. + */ +export class ProjectileHitBlockAfterEventSignal { + private constructor(); /** - * Represents an item that can place a spruce wood button - * within Minecraft. + * @remarks + * Adds a callback that will be called when a projectile hits a + * block. + * + * This function can't be called in read-only mode. + * */ - static readonly spruceButton: ItemType; - static readonly spruceChestBoat: ItemType; + subscribe(callback: (arg: ProjectileHitBlockAfterEvent) => void): (arg: ProjectileHitBlockAfterEvent) => void; /** - * Represents an item that can place a spruce wood door within - * Minecraft. + * @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. */ - static readonly spruceDoor: ItemType; + unsubscribe(callback: (arg: ProjectileHitBlockAfterEvent) => void): void; +} + +/** + * Contains information related to a projectile hitting an + * entity. + */ +export class ProjectileHitEntityAfterEvent { + private constructor(); /** - * Represents an item that can place a spruce wood fence gate - * within Minecraft. + * @remarks + * Dimension where this projectile hit took place. + * */ - static readonly spruceFenceGate: ItemType; + readonly dimension: Dimension; /** - * Represents an item that can place a spruce wood pressure - * plate within Minecraft. + * @remarks + * Direction vector of the projectile as it hit an entity. + * */ - static readonly sprucePressurePlate: ItemType; + readonly hitVector: Vector3; /** - * Represents an item that can place a spruce sign within - * Minecraft. + * @remarks + * Location where the projectile hit occurred. + * */ - static readonly spruceSign: ItemType; + readonly location: Vector3; /** - * Represents an item that can place a set of spruce wood - * stairs within Minecraft. + * @remarks + * Entity for the projectile that hit an entity. + * */ - static readonly spruceStairs: ItemType; + readonly projectile: Entity; /** - * Represents an item that can place a spruce wood trapdoor - * within Minecraft. + * @remarks + * Optional source entity that fired the projectile. + * */ - static readonly spruceTrapdoor: ItemType; - static readonly spyglass: ItemType; - static readonly squidSpawnEgg: ItemType; + readonly source?: Entity; /** - * Represents stained glass within Minecraft. + * @remarks + * Contains additional information about an entity that was + * hit. + * + * This function can't be called in read-only mode. + * */ - static readonly stainedGlass: ItemType; + getEntityHit(): EntityHitInformation; +} + +/** + * Manages callbacks that are connected to when a projectile + * hits an entity. + */ +export class ProjectileHitEntityAfterEventSignal { + private constructor(); /** - * Represents an item that can place a pane of stained glass - * within Minecraft. + * @remarks + * Adds a callback that will be called when a projectile hits + * an entity. + * + * This function can't be called in read-only mode. + * */ - static readonly stainedGlassPane: ItemType; + subscribe(callback: (arg: ProjectileHitEntityAfterEvent) => void): (arg: ProjectileHitEntityAfterEvent) => void; /** - * Represents an item that can place a block of stained - * hardened clay within Minecraft. + * @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. */ - static readonly stainedHardenedClay: ItemType; - static readonly stick: ItemType; + unsubscribe(callback: (arg: ProjectileHitEntityAfterEvent) => void): void; +} + +/** + * Contains objectives and participants for the scoreboard. + */ +export class Scoreboard { + private constructor(); /** - * Represents an item that can place a piston block with a - * sticky arm within Minecraft. + * @remarks + * Adds a new objective to the scoreboard. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly stickyPiston: ItemType; + addObjective(objectiveId: string, displayName?: string): ScoreboardObjective; /** - * Represents an item that can place a block of stone within - * Minecraft. + * @remarks + * Clears the objective that occupies a display slot. + * + * This function can't be called in read-only mode. + * */ - static readonly stone: ItemType; - static readonly stoneAxe: ItemType; - static readonly stoneBlockSlab: ItemType; - static readonly stoneBlockSlab2: ItemType; - static readonly stoneBlockSlab3: ItemType; - static readonly stoneBlockSlab4: ItemType; + clearObjectiveAtDisplaySlot(displaySlotId: DisplaySlotId): ScoreboardObjective | undefined; /** - * Represents an item that can place a block of stone brick - * within Minecraft. + * @remarks + * Returns a specific objective (by id). + * + * @param objectiveId + * Identifier of the objective. */ - static readonly stonebrick: ItemType; + getObjective(objectiveId: string): ScoreboardObjective | undefined; /** - * Represents an item that can place a set of stone brick - * stairs within Minecraft. + * @remarks + * Returns an objective that occupies the specified display + * slot. + * */ - static readonly stoneBrickStairs: ItemType; + getObjectiveAtDisplaySlot(displaySlotId: DisplaySlotId): ScoreboardObjectiveDisplayOptions | undefined; /** - * Represents an item that can place a stone button within - * Minecraft. + * @remarks + * Returns all defined objectives. + * */ - static readonly stoneButton: ItemType; + getObjectives(): ScoreboardObjective[]; /** - * Represents an item that can place a stonecutter block within - * Minecraft. + * @remarks + * Returns all defined scoreboard identities. + * */ - static readonly stonecutterBlock: ItemType; - static readonly stoneHoe: ItemType; - static readonly stonePickaxe: ItemType; + getParticipants(): ScoreboardIdentity[]; /** - * Represents an item that can place a stone pressure plate - * within Minecraft. + * @remarks + * Removes an objective from the scoreboard. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly stonePressurePlate: ItemType; - static readonly stoneShovel: ItemType; + removeObjective(objectiveId: ScoreboardObjective | string): boolean; /** - * Represents an item that can place a set of stone stairs - * within Minecraft. + * @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. */ - static readonly stoneStairs: ItemType; - static readonly stoneSword: ItemType; - static readonly straySpawnEgg: ItemType; - static readonly striderSpawnEgg: ItemType; - static readonly 'string': ItemType; + setObjectiveAtDisplaySlot( + displaySlotId: DisplaySlotId, + objectiveDisplaySetting: ScoreboardObjectiveDisplayOptions, + ): ScoreboardObjective | undefined; +} + +/** + * Contains an identity of the scoreboard item. + */ +export class ScoreboardIdentity { + private constructor(); /** - * Represents an item that can place a stripped acacia log - * within Minecraft. + * @remarks + * Returns the player-visible name of this identity. + * */ - static readonly strippedAcaciaLog: ItemType; + readonly displayName: string; /** - * Represents an item that can place a stripped birch log - * within Minecraft. + * @remarks + * Identifier of the scoreboard identity. + * */ - static readonly strippedBirchLog: ItemType; + readonly id: number; /** - * Represents stripped crimson hyphae within Minecraft. + * @remarks + * Type of the scoreboard identity. + * */ - static readonly strippedCrimsonHyphae: ItemType; + readonly 'type': ScoreboardIdentityType; /** - * Represents an item that can place a stripped crimson stem - * within Minecraft. + * @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. */ - static readonly strippedCrimsonStem: ItemType; + getEntity(): Entity | undefined; /** - * Represents an item that can place a stripped dark oak log - * within Minecraft. + * @remarks + * Returns true if the ScoreboardIdentity reference is still + * valid. + * */ - static readonly strippedDarkOakLog: ItemType; + isValid(): boolean; +} + +/** + * Contains objectives and participants for the scoreboard. + */ +export class ScoreboardObjective { + private constructor(); /** - * Represents an item that can place a stripped jungle log - * within Minecraft. + * @remarks + * Returns the player-visible name of this scoreboard + * objective. + * + * @throws This property can throw when used. */ - static readonly strippedJungleLog: ItemType; - static readonly strippedMangroveLog: ItemType; - static readonly strippedMangroveWood: ItemType; + readonly displayName: string; /** - * Represents an item that can place a stripped oak log within - * Minecraft. + * @remarks + * Identifier of the scoreboard objective. + * + * @throws This property can throw when used. */ - static readonly strippedOakLog: ItemType; + readonly id: string; /** - * Represents an item that can place a stripped spruce log - * within Minecraft. + * @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. */ - static readonly strippedSpruceLog: ItemType; + addScore(participant: Entity | ScoreboardIdentity | string, scoreToAdd: number): number; /** - * Represents stripped warped hyphae within Minecraft. + * @remarks + * Returns all objective participant identities. + * + * @throws This function can throw errors. */ - static readonly strippedWarpedHyphae: ItemType; + getParticipants(): ScoreboardIdentity[]; /** - * Represents stripped warped stem within Minecraft. + * @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. */ - static readonly strippedWarpedStem: ItemType; + getScore(participant: Entity | ScoreboardIdentity | string): number | undefined; /** - * Represents an item that can place a structure block, which - * provides for the saving and loading of block structures, - * within Minecraft. + * @remarks + * Returns specific scores for this objective for all + * participants. + * + * @throws This function can throw errors. */ - static readonly structureBlock: ItemType; + getScores(): ScoreboardScoreInfo[]; /** - * Represents an item that can place a structure void within - * Minecraft. + * @remarks + * Returns if the specified identity is a participant of the + * scoreboard objective. + * + * @throws This function can throw errors. */ - static readonly structureVoid: ItemType; - static readonly sugar: ItemType; - static readonly sugarCane: ItemType; - static readonly suspiciousStew: ItemType; - static readonly sweetBerries: ItemType; - static readonly tadpoleBucket: ItemType; - static readonly tadpoleSpawnEgg: ItemType; + hasParticipant(participant: Entity | ScoreboardIdentity | string): boolean; /** - * Represents tall grass within Minecraft. + * @remarks + * Returns true if the ScoreboardObjective reference is still + * valid. + * */ - static readonly tallgrass: ItemType; + isValid(): boolean; /** - * Represents an item that can place a target within Minecraft. + * @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. */ - static readonly target: ItemType; + removeParticipant(participant: Entity | ScoreboardIdentity | string): boolean; /** - * Represents tinted glass within Minecraft. + * @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. */ - static readonly tintedGlass: ItemType; + setScore(participant: Entity | ScoreboardIdentity | string, score: number): void; +} + +/** + * Contains a pair of a scoreboard participant and its + * respective score. + */ +export class ScoreboardScoreInfo { + private constructor(); /** - * Represents an item that can place a block of TnT within - * Minecraft. + * @remarks + * This scoreboard participant for this score. + * */ - static readonly tnt: ItemType; - static readonly tntMinecart: ItemType; + readonly participant: ScoreboardIdentity; /** - * Represents an item that can place a torch within Minecraft. + * @remarks + * Score value of the identity for this objective. + * */ - static readonly torch: ItemType; - static readonly totemOfUndying: ItemType; - static readonly traderLlamaSpawnEgg: ItemType; + readonly score: number; +} + +/** + * Contains information about user interface elements that are + * showing up on the screen. + * @example setTitle.ts + * ```typescript + * import { world } from '@minecraft/server'; + * + * world.afterEvents.playerSpawn.subscribe((event) => { + * event.player.onScreenDisplay.setTitle('§o§6You respawned!§r'); + * }); + * ``` + * @example setTitleAndSubtitle.ts + * ```typescript + * import { world } from '@minecraft/server'; + * + * world.afterEvents.playerSpawn.subscribe((event) => { + * event.player.onScreenDisplay.setTitle('You respawned', { + * stayDuration: 100, + * fadeInDuration: 2, + * fadeOutDuration: 4, + * subtitle: 'Try not to die next time!', + * }); + * }); + * ``` + * @example titleCountdown.ts + * ```typescript + * import { world, system } from '@minecraft/server'; + * + * world.afterEvents.playerSpawn.subscribe(event => { + * event.player.onScreenDisplay.setTitle('Get ready!', { + * stayDuration: 220, + * fadeInDuration: 2, + * fadeOutDuration: 4, + * subtitle: '10', + * }); + * + * let countdown = 10; + * + * const intervalId = system.runInterval(() => { + * countdown--; + * event.player.onScreenDisplay.updateSubtitle(countdown.toString()); + * + * if (countdown == 0) { + * system.clearRun(intervalId); + * } + * }, 20); + * }); + * ``` + */ +export class ScreenDisplay { + private constructor(); /** - * Represents an item that can place a trapdoor within - * Minecraft. + * @beta + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly trapdoor: ItemType; + getHiddenHudElements(): HudElement[]; /** - * Represents an item that can place a trapped chest within - * Minecraft. + * @beta + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly trappedChest: ItemType; - static readonly trident: ItemType; + hideAllExcept(hudElements?: HudElement[]): void; /** - * Represents an item that can place a tripwire hook within - * Minecraft. + * @beta + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly tripwireHook: ItemType; - static readonly tropicalFish: ItemType; - static readonly tropicalFishBucket: ItemType; - static readonly tropicalFishSpawnEgg: ItemType; + isForcedHidden(hudElement: HudElement): boolean; /** - * Represents an item that can place a block of tuff within - * Minecraft. + * @remarks + * Returns true if the current reference to this screen display + * manager object is valid and functional. + * */ - static readonly tuff: ItemType; + isValid(): boolean; /** - * Represents an item that can place a turtle egg within - * Minecraft. + * @beta + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly turtleEgg: ItemType; - static readonly turtleHelmet: ItemType; - static readonly turtleSpawnEgg: ItemType; + resetHudElements(): void; /** - * Represents an item that can place a set of twisting vines - * within Minecraft. + * @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. */ - static readonly twistingVines: ItemType; + setActionBar(text: (RawMessage | string)[] | RawMessage | string): void; /** - * Represents an item that can place an undyed shulker box - * within Minecraft. + * @beta + * @remarks + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - static readonly undyedShulkerBox: ItemType; - static readonly verdantFroglight: ItemType; - static readonly vexSpawnEgg: ItemType; - static readonly villagerSpawnEgg: ItemType; - static readonly vindicatorSpawnEgg: ItemType; + setHudVisibility(visible: HudVisibility, hudElements?: HudElement[]): void; /** - * Represents an item that can place a set of vines within - * Minecraft. + * @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 setTitle.ts + * ```typescript + * import { world } from '@minecraft/server'; + * + * world.afterEvents.playerSpawn.subscribe((event) => { + * event.player.onScreenDisplay.setTitle('§o§6You respawned!§r'); + * }); + * ``` + * @example setTitleAndSubtitle.ts + * ```typescript + * import { world } from '@minecraft/server'; + * + * world.afterEvents.playerSpawn.subscribe((event) => { + * event.player.onScreenDisplay.setTitle('You respawned', { + * stayDuration: 100, + * fadeInDuration: 2, + * fadeOutDuration: 4, + * subtitle: 'Try not to die next time!', + * }); + * }); + * ``` + * @example titleCountdown.ts + * ```typescript + * import { world, system } from '@minecraft/server'; + * + * world.afterEvents.playerSpawn.subscribe(event => { + * event.player.onScreenDisplay.setTitle('Get ready!', { + * stayDuration: 220, + * fadeInDuration: 2, + * fadeOutDuration: 4, + * subtitle: '10', + * }); + * + * let countdown = 10; + * + * const intervalId = system.runInterval(() => { + * countdown--; + * event.player.onScreenDisplay.updateSubtitle(countdown.toString()); + * + * if (countdown == 0) { + * system.clearRun(intervalId); + * } + * }, 20); + * }); + * ``` */ - static readonly vine: ItemType; - static readonly wanderingTraderSpawnEgg: ItemType; - static readonly wardenSpawnEgg: ItemType; + setTitle(title: (RawMessage | string)[] | RawMessage | string, options?: TitleDisplayOptions): void; /** - * Represents an item that can place a warped button within - * Minecraft. + * @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. */ - static readonly warpedButton: ItemType; + updateSubtitle(subtitle: (RawMessage | string)[] | RawMessage | string): void; +} + +/** + * Returns additional data about a /scriptevent command + * invocation. + */ +export class ScriptEventCommandMessageAfterEvent { + private constructor(); /** - * Represents an item that can place a warped door within - * Minecraft. + * @remarks + * Identifier of this ScriptEvent command message. + * */ - static readonly warpedDoor: ItemType; + readonly id: string; /** - * Represents an item that can place a warped fence within - * Minecraft. + * @remarks + * If this command was initiated via an NPC, returns the entity + * that initiated the NPC dialogue. + * */ - static readonly warpedFence: ItemType; + readonly initiator?: Entity; /** - * Represents an item that can place a warped fence gate within - * Minecraft. + * @remarks + * Optional additional data passed in with the script event + * command. + * */ - static readonly warpedFenceGate: ItemType; + readonly message: string; /** - * Represents warped fungus within Minecraft. + * @remarks + * Source block if this command was triggered via a block + * (e.g., a commandblock.) + * */ - static readonly warpedFungus: ItemType; - static readonly warpedFungusOnAStick: ItemType; + readonly sourceBlock?: Block; /** - * Represents warped hyphae within Minecraft. + * @remarks + * Source entity if this command was triggered by an entity + * (e.g., a NPC). + * */ - static readonly warpedHyphae: ItemType; + readonly sourceEntity?: Entity; /** - * Represents warped nylium within Minecraft. + * @remarks + * Returns the type of source that fired this command. + * */ - static readonly warpedNylium: ItemType; + readonly sourceType: ScriptEventSource; +} + +/** + * Allows for registering an event handler that responds to + * inbound /scriptevent commands. + */ +export class ScriptEventCommandMessageAfterEventSignal { + private constructor(); /** - * Represents warped planks within Minecraft. + * @remarks + * Registers a new ScriptEvent handler. + * + * This function can't be called in read-only mode. + * */ - static readonly warpedPlanks: ItemType; + subscribe( + callback: (arg: ScriptEventCommandMessageAfterEvent) => void, + options?: ScriptEventMessageFilterOptions, + ): (arg: ScriptEventCommandMessageAfterEvent) => void; /** - * Represents an item that can place a warped pressure plate - * within Minecraft. + * @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. */ - static readonly warpedPressurePlate: ItemType; + unsubscribe(callback: (arg: ScriptEventCommandMessageAfterEvent) => void): void; +} + +/** + * @beta + * Describes a particular seating position on this rideable + * entity. + */ +export class Seat { + private constructor(); /** - * Represents an item that can place a set of warped roots - * within Minecraft. + * @remarks + * Angle in degrees that a rider is allowed to rotate while + * riding this entity. + * */ - static readonly warpedRoots: ItemType; - static readonly warpedSign: ItemType; + readonly lockRiderRotation: number; /** - * Represents an item that can place a slab of warped material - * within Minecraft. + * @remarks + * A maximum number of riders that this seat can support. + * */ - static readonly warpedSlab: ItemType; + readonly maxRiderCount: number; /** - * Represents an item that can place a set of warped stairs - * within Minecraft. + * @remarks + * A minimum number of riders that can be placed in this seat + * position, if this seat is to be filled. + * */ - static readonly warpedStairs: ItemType; + readonly minRiderCount: number; /** - * Represents an item that can place a warped stem within - * Minecraft. + * @remarks + * Physical location of this seat, relative to the entity's + * location. + * */ - static readonly warpedStem: ItemType; + readonly position: Vector3; /** - * Represents an item that can place a warped trapdoor within - * Minecraft. + * @remarks + * Angle in degrees to rotate riders by. + * */ - static readonly warpedTrapdoor: ItemType; + readonly seatRotation: number; +} + +/** + * @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(); /** - * Represents an item that can place a warped wart block within - * Minecraft. + * @remarks + * Adds a callback that will be called when an internal message + * is passed. + * + * This function can't be called in read-only mode. + * */ - static readonly warpedWartBlock: ItemType; - static readonly waterBucket: ItemType; + subscribe(callback: (arg: MessageReceiveAfterEvent) => void): (arg: MessageReceiveAfterEvent) => void; /** - * Represents an item that can place a water lily within - * Minecraft. + * @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. */ - static readonly waterlily: ItemType; + unsubscribe(callback: (arg: MessageReceiveAfterEvent) => void): void; +} + +/** + * Represents a loaded structure template (.mcstructure file). + * Structures can be placed in a world using the /structure + * command or the {@link StructureManager} APIs. + */ +export class Structure { + private constructor(); /** - * Represents an item that can place a block of waxed copper - * within Minecraft. + * @remarks + * The name of the structure. The identifier must include a + * namespace. For structures created via the /structure command + * or structure blocks, this namespace defaults to + * "mystructure". + * */ - static readonly waxedCopper: ItemType; + readonly id: string; /** - * Represents an item that can place a block of waxed cut - * copper within Minecraft. + * @remarks + * The dimensions of the structure. For example, a single block + * structure will have a size of {x:1, y:1, z:1} + * + * @throws This property can throw when used. + * + * {@link InvalidStructureError} */ - static readonly waxedCutCopper: ItemType; + readonly size: Vector3; /** - * Represents an item that can place a slab of waxed cut copper - * within Minecraft. + * @remarks + * Returns a BlockPermutation representing the block contained + * within the Structure at the given location. + * + * @param location + * The block location relative to the Structure's origin. + * @returns + * Returns a BlockPermutation. Returns undefined if a block + * does not exist at the given location. + * @throws + * Throws if the location is outside the structure's bounds. + * Throws if the Structure has been deleted. + * + * {@link minecraftcommon.InvalidArgumentError} + * + * {@link InvalidStructureError} */ - static readonly waxedCutCopperSlab: ItemType; + getBlockPermutation(location: Vector3): BlockPermutation | undefined; /** - * Represents an item that can place a set of waxed cut copper - * stairs within Minecraft. + * @remarks + * Returns whether the block at the given location is + * waterlogged. + * + * @param location + * The block location relative to the Structure's origin. + * @returns + * Returns whether the block at the given location is + * waterlogged. Returns false if a block does not exist at the + * given location. + * @throws + * Throws if the location is outside the structure's bounds. + * Throws if the Structure has been deleted. + * + * {@link minecraftcommon.InvalidArgumentError} + * + * {@link InvalidStructureError} */ - static readonly waxedCutCopperStairs: ItemType; + getIsWaterlogged(location: Vector3): boolean; /** - * Represents an item that can place a block of waxed exposed - * copper within Minecraft. + * @remarks + * Returns whether the Structure is valid. The Structure may + * become invalid if it is deleted. + * + * @returns + * Returns whether the Structure is valid. */ - static readonly waxedExposedCopper: ItemType; + isValid(): boolean; /** - * Represents an item that can place a block of waxed exposed - * cut copper within Minecraft. + * @beta + * @remarks + * Creates a copy of a Structure and saves it with a new name. + * + * This function can't be called in read-only mode. + * + * @param identifier + * The name of the newly created Structure. + * @param saveMode + * Determines how the Structure should be saved. Defaults to + * saving to the world. + * @returns + * Returns the newly created structure. + * @throws + * Throws if the identifier is invalid. A valid identifier must + * include a namespace and must be unique. + * Throws if the Structure has been deleted. + * + * {@link minecraftcommon.EngineError} + * + * {@link minecraftcommon.InvalidArgumentError} + * + * {@link InvalidStructureError} */ - static readonly waxedExposedCutCopper: ItemType; + saveAs(identifier: string, saveMode?: StructureSaveMode): Structure; /** - * Represents an item that can place a slab of waxed exposed - * cut copper within Minecraft. + * @beta + * @remarks + * Saves a modified Structure to the world file. + * + * This function can't be called in read-only mode. + * + * @throws + * Throws if the Structure has been deleted. + * + * {@link InvalidStructureError} */ - static readonly waxedExposedCutCopperSlab: ItemType; + saveToWorld(): void; /** - * Represents an item that can place a set of waxed exposed cut - * copper stairs within Minecraft. + * @beta + * @remarks + * Sets a BlockPermutation within a Structure. + * + * This function can't be called in read-only mode. + * + * @param location + * The block location relative to the Structure's origin. + * @param blockPermutation + * The BlockPermutation to set. + * @param waterlogged + * Specifies whether the block should be waterlogged. Air and + * undefined blocks cannot be waterlogged. + * @throws + * Throws if the type of block is StructureVoid. + * Throws if the block is undefined and waterlogged is set to + * true. + * Throws if the block is air and waterlogged is set to true. + * Throws if the location is outside the structure's bounds. + * Throws if the Structure has been deleted. + * + * {@link minecraftcommon.InvalidArgumentError} + * + * {@link InvalidStructureError} */ - static readonly waxedExposedCutCopperStairs: ItemType; + setBlockPermutation(location: Vector3, blockPermutation?: BlockPermutation, waterlogged?: boolean): void; +} + +/** + * Manager for Structure related APIs. Includes APIs for + * creating, getting, placing and deleting Structures. + */ +export class StructureManager { + private constructor(); /** - * Represents an item that can place a block of waxed oxidized - * copper within Minecraft. + * @remarks + * Creates an empty Structure in memory. Use {@link + * Structure.setBlockPermutation} to populate the structure + * with blocks and save changes with {@link + * @minecraft/server.Structure.save}. + * + * This function can't be called in read-only mode. + * + * @param identifier + * The name of the structure. A valid identifier must include a + * namespace and must be unique. + * @param size + * The size of the structure. For example, to create a single + * block structure the size should be {x:1, y:1, z:1}. + * @param saveMode + * How the Structure should be saved upon creation. Defaults to + * StructureSaveMode.Memory. + * @returns + * Returns the newly created Structure. + * @throws + * Throws if the identifier is invalid. A valid identifier must + * include a namespace and must be unique. + * + * {@link minecraftcommon.EngineError} + * + * {@link minecraftcommon.InvalidArgumentError} */ - static readonly waxedOxidizedCopper: ItemType; + createEmpty(identifier: string, size: Vector3, saveMode?: StructureSaveMode): Structure; /** - * Represents an item that can place a block of waxed oxidized - * cut copper within Minecraft. + * @beta + * @remarks + * Creates a new Structure from blocks in the world. This is + * functionally equivalent to the /structure save command. + * + * This function can't be called in read-only mode. + * + * @param identifier + * The name of the structure. A valid identifier must include a + * namespace and must be unique. + * @param dimension + * The dimension where the blocks should be read from. + * @param blockVolume + * The location and bounds of the blocks that should be read. + * @param options + * Additional options for creating a structure from the world. + * @returns + * Returns the newly created Structure. + * @throws + * Throws if the identifier is invalid. A valid identifier must + * include a namespace and must be unique. + * Throws if the structure bounds exceed the maximum size. + * Throws if the structure bounds contains blocks outside the + * world bounds. + * + * + * {@link minecraftcommon.InvalidArgumentError} */ - static readonly waxedOxidizedCutCopper: ItemType; + createFromWorld( + identifier: string, + dimension: Dimension, + blockVolume: BlockVolume, + options?: StructureCreateOptions, + ): Structure; /** - * Represents an item that can place a slab of waxed oxidized - * cut copper within Minecraft. + * @remarks + * Deletes a structure from memory and from the world if it + * exists. + * + * This function can't be called in read-only mode. + * + * @param structure + * The structure identifier or Structure object that should be + * deleted. Note, a Structure object will become invalid after + * it is deleted. + * @returns + * Returns whether the structure was removed. + * @throws + * Throws if a structure cannot be removed. For example, a + * structure loaded from a Behavior Pack. + * + * {@link minecraftcommon.InvalidArgumentError} */ - static readonly waxedOxidizedCutCopperSlab: ItemType; + delete(structure: string | Structure): boolean; /** - * Represents an item that can place a set of waxed oxidized - * cut copper stairs within Minecraft. + * @remarks + * Gets a Structure that is saved to memory or the world. + * + * This function can't be called in read-only mode. + * + * @param identifier + * The name of the structure to get. + * @returns + * Returns a Structure if it exists, otherwise undefined. */ - static readonly waxedOxidizedCutCopperStairs: ItemType; + get(identifier: string): Structure | undefined; /** - * Represents an item that can place a block of waxed weathered - * copper within Minecraft. + * @beta + * @remarks + * This function can't be called in read-only mode. + * */ - static readonly waxedWeatheredCopper: ItemType; + getIds(): string[]; /** - * Represents an item that can place a block of waxed weathered - * cut copper within Minecraft. + * @remarks + * Places a structure in the world. Structures placed in + * unloaded chunks will be queued for loading. + * + * This function can't be called in read-only mode. + * + * @param structure + * The structure's identifier or a Structure object. + * @param dimension + * The dimension where the Structure should be placed. + * @param location + * The location within the dimension where the Structure should + * be placed. + * @param options + * Additional options for Structure placement. + * @throws + * Throws if the integrity value is outside of the range [0,1] + * Throws if the integrity seed is invalid. + * Throws if the placement location contains blocks that are + * outside the world bounds. + * + * {@link minecraftcommon.ArgumentOutOfBoundsError} + * + * {@link minecraftcommon.InvalidArgumentError} + * + * {@link InvalidStructureError} */ - static readonly waxedWeatheredCutCopper: ItemType; + place( + structure: string | Structure, + dimension: Dimension, + location: Vector3, + options?: StructurePlaceOptions, + ): void; +} + +/** + * A class that provides system-level events and functions. + */ +export class System { + private constructor(); /** - * Represents an item that can place a slab of waxed weathered - * cut copper within Minecraft. + * @remarks + * Returns a collection of after-events for system-level + * operations. + * */ - static readonly waxedWeatheredCutCopperSlab: ItemType; + readonly afterEvents: SystemAfterEvents; /** - * Represents an item that can place a set of waxed weathered - * cut copper stairs within Minecraft. + * @beta + * @remarks + * Returns a collection of before-events for system-level + * operations. + * */ - static readonly waxedWeatheredCutCopperStairs: ItemType; + readonly beforeEvents: SystemBeforeEvents; /** - * Represents an item that can place a block of weathered - * copper within Minecraft. + * @remarks + * Represents the current world tick of the server. + * */ - static readonly weatheredCopper: ItemType; + readonly currentTick: number; /** - * Represents an item that can place a block of weathered cut - * copper within Minecraft. + * @beta + * @remarks + * Cancels the execution of a job queued via {@link + * System.runJob}. + * + * @param jobId + * The job ID returned from {@link System.runJob}. */ - static readonly weatheredCutCopper: ItemType; + clearJob(jobId: number): void; /** - * Represents an item that can place a slab of weathered cut - * copper within Minecraft. + * @remarks + * Cancels the execution of a function run that was previously + * scheduled via {@link System.run}. + * */ - static readonly weatheredCutCopperSlab: ItemType; + clearRun(runId: number): void; /** - * Represents an item that can place a set of weathered cut - * copper stairs within Minecraft. + * @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 + * import { system, world } from '@minecraft/server'; + * + * function printEveryMinute() { + * try { + * // Minecraft runs at 20 ticks per second. + * if (system.currentTick % 1200 === 0) { + * world.sendMessage('Another minute passes...'); + * } + * } catch (e) { + * console.warn('Error: ' + e); + * } + * + * system.run(printEveryMinute); + * } + * + * printEveryMinute(); + * ``` */ - static readonly weatheredCutCopperStairs: ItemType; + run(callback: () => void): number; /** - * Represents an item that can place a web within Minecraft. + * @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 + * import { system, world } from '@minecraft/server'; + * + * const intervalRunIdentifier = Math.floor(Math.random() * 10000); + * + * system.runInterval(() => { + * world.sendMessage('This is an interval run ' + intervalRunIdentifier + ' sending a message every 30 seconds.'); + * }, 600); + * ``` */ - static readonly web: ItemType; + runInterval(callback: () => void, tickInterval?: number): number; /** - * Represents an item that can place a set of weeping vines - * within Minecraft. + * @beta + * @remarks + * Queues a generator to run until completion. The generator + * will be given a time slice each tick, and will be run until + * it yields or completes. + * + * @param generator + * The instance of the generator to run. + * @returns + * An opaque handle that can be used with {@link + * System.clearJob} to stop the run of this generator. + * @example cubeGenerator.ts + * ```typescript + * import { BlockPermutation, DimensionLocation, world, ButtonPushAfterEvent, system } from '@minecraft/server'; + * + * // A simple generator that places blocks in a cube at a specific location + * // with a specific size, yielding after every block place. + * function* blockPlacingGenerator(blockPerm: BlockPermutation, startingLocation: DimensionLocation, size: number) { + * for (let x = startingLocation.x; x < startingLocation.x + size; x++) { + * for (let y = startingLocation.y; y < startingLocation.y + size; y++) { + * for (let z = startingLocation.z; z < startingLocation.z + size; z++) { + * const block = startingLocation.dimension.getBlock({ x: x, y: y, z: z }); + * if (block) { + * block.setPermutation(blockPerm); + * } + * yield; + * } + * } + * } + * } + * + * // When a button is pushed, we will place a 15x15x15 cube of cobblestone 10 blocks above it + * world.afterEvents.buttonPush.subscribe((buttonPushEvent: ButtonPushAfterEvent) => { + * const cubePos = buttonPushEvent.block.location; + * cubePos.y += 10; + * + * const blockPerm = BlockPermutation.resolve('minecraft:cobblestone'); + * + * system.runJob(blockPlacingGenerator(blockPerm, { dimension: buttonPushEvent.dimension, ...cubePos }, 15)); + * }); + * ``` */ - static readonly weepingVines: ItemType; + runJob(generator: Generator): number; /** - * Represents wheat within Minecraft. + * @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. */ - static readonly wheat: ItemType; - static readonly wheatSeeds: ItemType; + 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(); /** - * Represents an item that can place a white candle within - * Minecraft. + * @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. + * */ - static readonly whiteCandle: ItemType; - static readonly whiteDye: ItemType; + 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(); /** - * Represents an item that can place a block of white glazed - * terracotta within Minecraft. + * @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. + * */ - static readonly whiteGlazedTerracotta: ItemType; - static readonly whiteWool: ItemType; - static readonly witchSpawnEgg: ItemType; + readonly watchdogTerminate: WatchdogTerminateBeforeEventSignal; +} + +/** + * 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(); /** - * Represents an item that can place a wither rose within - * Minecraft. + * @remarks + * The position where the source hit the block. + * */ - static readonly witherRose: ItemType; - static readonly witherSkeletonSpawnEgg: ItemType; - static readonly witherSpawnEgg: ItemType; - static readonly wolfSpawnEgg: ItemType; + readonly hitVector: Vector3; /** - * Represents an item that can place a block of wood within - * Minecraft. + * @remarks + * The redstone power before the block is hit. + * */ - static readonly wood: ItemType; - static readonly woodenAxe: ItemType; + readonly previousRedstonePower: number; /** - * Represents an item that can place a wooden button within - * Minecraft. + * @remarks + * The redstone power at the time the block is hit. + * */ - static readonly woodenButton: ItemType; + readonly redstonePower: number; /** - * Represents an item that can place a wooden door within - * Minecraft. + * @remarks + * Optional source that hit the target block. + * */ - static readonly woodenDoor: ItemType; - static readonly woodenHoe: ItemType; - static readonly woodenPickaxe: ItemType; + readonly source: Entity; +} + +/** + * Manages callbacks that are connected to when a target block + * is hit. + */ +export class TargetBlockHitAfterEventSignal { + private constructor(); /** - * Represents an item that can place a wooden pressure plate - * within Minecraft. + * @remarks + * Adds a callback that will be called when a target block is + * hit. + * + * This function can't be called in read-only mode. + * */ - static readonly woodenPressurePlate: ItemType; - static readonly woodenShovel: ItemType; + subscribe(callback: (arg: TargetBlockHitAfterEvent) => void): (arg: TargetBlockHitAfterEvent) => void; /** - * Represents an item that can place a wooden slab within - * Minecraft. + * @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. */ - static readonly woodenSlab: ItemType; - static readonly woodenSword: ItemType; + unsubscribe(callback: (arg: TargetBlockHitAfterEvent) => void): void; +} + +/** + * @beta + * Represents a trigger for firing an event. + */ +export class Trigger { /** - * Represents wool within Minecraft. + * @remarks + * Event name of the trigger. + * */ - static readonly wool: ItemType; - static readonly writableBook: ItemType; + eventName: string; /** - * Represents an item that can place a yellow candle within - * Minecraft. + * @remarks + * Creates a new trigger. + * */ - static readonly yellowCandle: ItemType; - static readonly yellowDye: ItemType; + constructor(eventName: string); +} + +/** + * Contains information related to changes to a trip wire trip. + * @example tripWireTripEvent.ts + * ```typescript + * import { Vector3, world, BlockPermutation, TripWireTripAfterEvent, system } from '@minecraft/server'; + * + * const overworld = world.getDimension('overworld'); + * const targetLocation: Vector3 = { x: 0, y: 0, z: 0 }; + * + * // set up a tripwire + * const redstone = overworld.getBlock({ x: targetLocation.x, y: targetLocation.y - 1, z: targetLocation.z }); + * const tripwire = overworld.getBlock(targetLocation); + * + * if (redstone === undefined || tripwire === undefined) { + * console.warn('Could not find block at location.'); + * } else { + * + * redstone.setPermutation(BlockPermutation.resolve('redstone_block')); + * tripwire.setPermutation(BlockPermutation.resolve('tripwire')); + * + * world.afterEvents.tripWireTrip.subscribe((tripWireTripEvent: TripWireTripAfterEvent) => { + * const eventLoc = tripWireTripEvent.block.location; + * + * if (eventLoc.x === targetLocation.x && eventLoc.y === targetLocation.y && eventLoc.z === targetLocation.z) { + * console.warn( + * 'Tripwire trip event at tick ' + + * system.currentTick + + * (tripWireTripEvent.sources.length > 0 ? ' by entity ' + tripWireTripEvent.sources[0].id : ''), + * ); + * } + * }); + * } + * ``` + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class TripWireTripAfterEvent extends BlockEvent { + private constructor(); /** - * Represents an item that can place a yellow flower within - * Minecraft. + * @remarks + * Whether or not the block has redstone power. + * */ - static readonly yellowFlower: ItemType; + readonly isPowered: boolean; /** - * Represents an item that can place a yellow block of glazed - * terracotta within Minecraft. + * @remarks + * The sources that triggered the trip wire to trip. + * */ - static readonly yellowGlazedTerracotta: ItemType; - static readonly yellowWool: ItemType; - static readonly zoglinSpawnEgg: ItemType; - static readonly zombieHorseSpawnEgg: ItemType; - static readonly zombiePigmanSpawnEgg: ItemType; - static readonly zombieSpawnEgg: ItemType; - static readonly zombieVillagerSpawnEgg: ItemType; + readonly sources: Entity[]; } + /** - * @beta - * Contains a set of additional variable values for further - * defining how rendering and animations function. + * Manages callbacks that are connected to when a trip wire is + * tripped. + * @example tripWireTripEvent.ts + * ```typescript + * import { Vector3, world, BlockPermutation, TripWireTripAfterEvent, system } from '@minecraft/server'; + * + * const overworld = world.getDimension('overworld'); + * const targetLocation: Vector3 = { x: 0, y: 0, z: 0 }; + * + * // set up a tripwire + * const redstone = overworld.getBlock({ x: targetLocation.x, y: targetLocation.y - 1, z: targetLocation.z }); + * const tripwire = overworld.getBlock(targetLocation); + * + * if (redstone === undefined || tripwire === undefined) { + * console.warn('Could not find block at location.'); + * } else { + * + * redstone.setPermutation(BlockPermutation.resolve('redstone_block')); + * tripwire.setPermutation(BlockPermutation.resolve('tripwire')); + * + * world.afterEvents.tripWireTrip.subscribe((tripWireTripEvent: TripWireTripAfterEvent) => { + * const eventLoc = tripWireTripEvent.block.location; + * + * if (eventLoc.x === targetLocation.x && eventLoc.y === targetLocation.y && eventLoc.z === targetLocation.z) { + * console.warn( + * 'Tripwire trip event at tick ' + + * system.currentTick + + * (tripWireTripEvent.sources.length > 0 ? ' by entity ' + tripWireTripEvent.sources[0].id : ''), + * ); + * } + * }); + * } + * ``` */ -export class MolangVariableMap { +export class TripWireTripAfterEventSignal { + private constructor(); /** * @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] - * @param variableName - * @param color + * Adds a callback that will be called when a trip wire is + * tripped. + * + * This function can't be called in read-only mode. + * */ - setColorRGB(variableName: string, color: Color): MolangVariableMap; + subscribe(callback: (arg: TripWireTripAfterEvent) => void): (arg: TripWireTripAfterEvent) => 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] - * @param variableName - * @param color + * 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. */ - setColorRGBA(variableName: string, color: Color): MolangVariableMap; + unsubscribe(callback: (arg: TripWireTripAfterEvent) => void): void; +} + +/** + * @beta + * Contains information related to a script watchdog + * termination. + */ +export class WatchdogTerminateBeforeEvent { + private constructor(); /** * @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 - * @param variableName - * @param speed - * @param direction + * 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. + * */ - setSpeedAndDirection(variableName: string, speed: number, direction: Vector): MolangVariableMap; + cancel: boolean; /** * @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 - * @param variableName - * @param vector + * Contains the reason why a script runtime is to be + * terminated. + * */ - setVector3(variableName: string, vector: Vector): MolangVariableMap; + readonly terminateReason: WatchdogTerminateReason; } + /** * @beta - * Contains data resulting from a navigation operation, - * including whether the navigation is possible and the path of - * navigation. + * 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 NavigationResult { - protected constructor(); +export class WatchdogTerminateBeforeEventSignal { + private constructor(); /** - * Whether the navigation result contains a full path, - * including to the requested destination. + * @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. */ - readonly isFullPath: boolean; - getPath(): Vector3[]; + unsubscribe(callback: (arg: WatchdogTerminateBeforeEvent) => void): void; } + /** - * @beta - * Contains information related to changes to a piston - * expanding or retracting. + * Contains information related to changes in weather in the + * environment. */ -export class PistonActivateEvent extends BlockEvent { - protected constructor(); - /** - * Block impacted by this event. - */ - readonly block: Block; +export class WeatherChangeAfterEvent { + private constructor(); /** - * Dimension that contains the block that is the subject of - * this event. + * @remarks + * Dimension in which the weather has changed. + * */ - readonly dimension: Dimension; + readonly dimension: string; /** - * True if the piston is the process of expanding. + * @remarks + * The weather type after the weather was changed. + * */ - readonly isExpanding: boolean; + readonly newWeather: WeatherType; /** - * Contains additional properties and details of the piston. + * @remarks + * The weather type before the weather was changed. + * */ - readonly piston: BlockPistonComponent; + readonly previousWeather: WeatherType; } + /** - * @beta - * Manages callbacks that are connected to piston activations. + * Manages callbacks that are connected to weather changing. */ -export class PistonActivateEventSignal { - protected constructor(); +export class WeatherChangeAfterEventSignal { + private constructor(); /** * @remarks - * Adds a callback that will be called when a piston expands or - * retracts. - * @param callback - * @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.events.beforePistonActivate.subscribe((pistonEvent: mc.BeforePistonActivateEvent) => { - * if (pistonEvent.piston.location.equals(pistonLoc)) { - * log("Cancelling piston event"); - * pistonEvent.cancel = true; - * canceled = true; - * } - * }); + * Adds a callback that will be called when weather changes. * + * This function can't be called in read-only mode. * - * ``` */ - subscribe(callback: (arg: PistonActivateEvent) => void): (arg: PistonActivateEvent) => void; + subscribe(callback: (arg: WeatherChangeAfterEvent) => void): (arg: WeatherChangeAfterEvent) => void; /** * @remarks - * Removes a callback from being called when a piston expands - * or retracts. - * @param callback + * 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: PistonActivateEvent) => void): void; + unsubscribe(callback: (arg: WeatherChangeAfterEvent) => void): void; } + /** - * Represents a player within the world. + * @beta + * Contains information related to changes in weather in the + * environment. */ -export class Player extends Entity { - protected constructor(); - /** - * @beta - * Dimension that the entity is currently within. - * @throws This property can throw when used. - */ - readonly dimension: Dimension; +export class WeatherChangeBeforeEvent { + private constructor(); /** - * Unique identifier of the player. 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. - * @throws This property can throw when used. + * @remarks + * If set to true the weather change will be cancelled. + * */ - readonly id: string; + cancel: boolean; /** - * @beta - * True if the player is currently using a sneaking movement. + * @remarks + * Sets the duration of the new weather (in ticks). + * */ - isSneaking: boolean; - readonly level: number; + duration: number; /** - * @beta - * Current location of the player. - * @throws This property can throw when used. + * @remarks + * The type of weather that will be applied. + * */ - readonly location: Vector3; + newWeather: WeatherType; /** - * Name of the player. - * @throws This property can throw when used. + * @remarks + * The type of weather that it was prior to the event being + * fired. + * */ - readonly name: string; + readonly previousWeather: WeatherType; +} + +/** + * @beta + * Manages callbacks that are connected to before weather + * changing. + */ +export class WeatherChangeBeforeEventSignal { + private constructor(); /** - * @beta - * Optional name tag of the player. + * @remarks + * Adds a callback that will be called before weather changes. + * + * This function can't be called in read-only mode. + * */ - nameTag: string; + subscribe(callback: (arg: WeatherChangeBeforeEvent) => void): (arg: WeatherChangeBeforeEvent) => void; /** - * @beta - * Contains methods for manipulating the on-screen display of a - * Player. + * @remarks + * Removes a callback from being called before weather changes. + * + * This function can't be called in read-only mode. + * + * @throws This function can throw errors. */ - readonly onScreenDisplay: ScreenDisplay; + unsubscribe(callback: (arg: WeatherChangeBeforeEvent) => 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 - * Returns a scoreboard identity that represents this entity. - * @throws This property can throw when used. + * @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 scoreboard: ScoreboardIdentity; + readonly afterEvents: WorldAfterEvents; /** - * @beta - * Manages the selected slot in the player's hotbar. + * @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. + * */ - selectedSlot: number; - readonly spawnDimension?: Dimension; + readonly beforeEvents: WorldBeforeEvents; /** * @beta - * Retrieves or sets an entity that is used as the target of - * AI-related behaviors, like attacking. For players, which - * don't use any AI semantics, this property does not do - * anything. - * @throws This property can throw when used. - */ - readonly target: Entity; - readonly totalXpNeededForNextLevel: number; - /** - * Unique identifier of the type of the entity - for example, - * 'minecraft:player'. - * @throws This property can throw when used. + * @remarks + * The game rules that apply to the world. + * */ - readonly typeId: string; - readonly xpEarnedAtCurrentLevel: number; + readonly gameRules: GameRules; /** - * @beta * @remarks - * Adds an effect, like poison, to the entity. - * @param effectType - * Type of effect to add to the entity. - * @param duration - * Amount of time, in ticks, for the effect to apply. - * @param amplifier - * Optional amplification of the effect to apply. - * @param showParticles - * @throws This function can throw errors. + * Returns the general global scoreboard that applies to the + * world. + * */ - addEffect(effectType: EffectType, duration: number, amplifier?: number, showParticles?: boolean): void; + readonly scoreboard: Scoreboard; /** - * @beta * @remarks - * Adds/removes experience to/from the Player and returns the - * current experience of the Player. - * @param amount - * Amount of experience to add. Note that this can be negative. - * @returns - * Returns the current experience of the Player. - * @throws This function can throw errors. + * Returns the manager for {@link Structure} related APIs. + * */ - addExperience(amount: number): number; + readonly structureManager: StructureManager; /** * @beta * @remarks - * Adds/removes level to/from the Player and returns the - * current level of the Player. - * @param amount - * Amount to add to the player. - * @returns - * Returns the current level of the Player. - * @throws This function can throw errors. + * 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. */ - addLevels(amount: number): number; + broadcastClientMessage(id: string, value: string): void; /** - * @beta * @remarks - * Adds a specified tag to an entity. - * @param tag - * Content of the tag to add. - * @throws This function can throw errors. + * Clears the set of dynamic properties declared for this + * behavior pack within the world. + * */ - addTag(tag: string): boolean; + clearDynamicProperties(): void; /** - * @beta * @remarks - * Applies damage to the player. - * @param amount - * Amount of damage to apply. - * @param source - * Additional information around the source of damage that can - * apply to the player. - * @throws This function can throw errors. + * Returns the absolute time since the start of the world. + * */ - applyDamage(amount: number, source?: EntityDamageSource): boolean; - applyImpulse(vector: Vector3): void; - applyKnockback(directionX: number, directionZ: number, horizontalStrength: number, verticalStrength: number): void; - clearSpawn(): void; - clearVelocity(): void; + getAbsoluteTime(): number; /** - * @beta * @remarks - * Extinguishes the fire if the player is on fire. Note that - * you can call getComponent('minecraft:onfire') and, if - * present, the player is on fire." - * @param useEffects - * Whether to show any visual effects connected to the - * extinguishing. + * Returns an array of all active players within the world. + * * @throws This function can throw errors. */ - extinguishFire(useEffects?: boolean): boolean; + getAllPlayers(): Player[]; /** - * @beta * @remarks - * Returns the first intersecting block from the direction that - * this player is looking at. - * @param options - * @throws This function can throw errors. + * 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. */ - getBlockFromViewDirection(options?: BlockRaycastOptions): Block; + getDay(): number; /** - * @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 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. */ - getComponent(componentId: string): IEntityComponent; + getDefaultSpawnLocation(): Vector3; /** - * @beta * @remarks - * Returns all components that are both present on this entity - * and supported by the API. + * 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 */ - getComponents(): IEntityComponent[]; + 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 This function can throw errors. + * @throws + * Throws if the given dynamic property identifier is not + * defined. + * @example incrementDynamicProperty.ts + * ```typescript + * import * as mc from '@minecraft/server'; + * + * function incrementProperty(propertyName: string): boolean { + * let number = mc.world.getDynamicProperty(propertyName); + * + * console.warn('Current value is: ' + number); + * + * if (number === undefined) { + * number = 0; + * } + * + * if (typeof number !== 'number') { + * console.warn('Number is of an unexpected type.'); + * return false; + * } + * + * mc.world.setDynamicProperty(propertyName, number + 1); + * return true; + * } + * + * incrementProperty('samplelibrary:number'); + * ``` + * @example incrementDynamicPropertyInJsonBlob.ts + * ```typescript + * import * as mc from '@minecraft/server'; + * + * function updateWorldProperty(propertyName: string): boolean { + * let paintStr = mc.world.getDynamicProperty(propertyName); + * let paint: { color: string; intensity: number } | undefined = undefined; + * + * console.log('Current value is: ' + paintStr); + * + * if (paintStr === undefined) { + * paint = { + * color: 'purple', + * intensity: 0, + * }; + * } else { + * if (typeof paintStr !== 'string') { + * console.warn('Paint is of an unexpected type.'); + * return false; + * } + * + * try { + * paint = JSON.parse(paintStr); + * } catch (e) { + * console.warn('Error parsing serialized struct.'); + * return false; + * } + * } + * + * if (!paint) { + * console.warn('Error parsing serialized struct.'); + * return false; + * } + * + * paint.intensity++; + * paintStr = JSON.stringify(paint); // be very careful to ensure your serialized JSON str cannot exceed limits + * mc.world.setDynamicProperty(propertyName, paintStr); + * + * return true; + * } + * + * updateWorldProperty('samplelibrary:longerjson'); + * ``` */ - getDynamicProperty(identifier: string): boolean | number | string | undefined; + getDynamicProperty(identifier: string): boolean | number | string | Vector3 | undefined; /** - * @beta * @remarks - * Returns the effect for the specified EffectType on the - * entity, or undefined if the effect is not present. - * @param effectType + * Gets a set of dynamic property identifiers that have been + * set in this world. + * * @returns - * Effect object for the specified effect, or undefined if the - * effect is not present. - * @throws This function can throw errors. + * A string array of active dynamic property identifiers. */ - getEffect(effectType: EffectType): Effect; + getDynamicPropertyIds(): string[]; /** - * @beta * @remarks - * Returns a set of effects applied to this player. - * @throws This function can throw errors. + * Gets the total byte count of dynamic properties. This could + * potentially be used for your own analytics to ensure you're + * not storing gigantic sets of dynamic properties. + * */ - getEffects(): Effect[]; + getDynamicPropertyTotalByteCount(): number; /** - * @beta * @remarks - * Returns a potential set of entities from the direction that - * this player is looking at. - * @param options - * @throws This function can throw errors. + * 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. */ - getEntitiesFromViewDirection(options?: EntityRaycastOptions): Entity[]; - getHeadLocation(): Vector3; + getEntity(id: string): Entity | undefined; /** - * @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. + * Returns the MoonPhase for the current time. + * */ - getItemCooldown(itemCategory: string): number; - getRotation(): XYRotation; - getSpawnPosition(): Vector3 | undefined; + getMoonPhase(): MoonPhase; /** - * @beta * @remarks - * Returns all tags associated with an entity. - * @throws This function can throw errors. + * 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. */ - getTags(): string[]; + getPlayers(options?: EntityQueryOptions): Player[]; /** - * @beta * @remarks - * Gets the total experience of the Player. + * 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 + * import { world, MusicOptions, WorldSoundOptions, PlayerSoundOptions, Vector3 } from '@minecraft/server'; + * + * const players = world.getPlayers(); + * const targetLocation: Vector3 = { + * x: 0, + * y: 0, + * z: 0, + * }; + * + * const musicOptions: MusicOptions = { + * fade: 0.5, + * loop: true, + * volume: 1.0, + * }; + * world.playMusic('music.menu', musicOptions); + * + * const worldSoundOptions: WorldSoundOptions = { + * pitch: 0.5, + * volume: 4.0, + * }; + * world.playSound('ambient.weather.thunder', targetLocation, worldSoundOptions); + * + * const playerSoundOptions: PlayerSoundOptions = { + * pitch: 1.0, + * volume: 1.0, + * }; + * + * players[0].playSound('bucket.fill_water', playerSoundOptions); + * ``` */ - getTotalXp(): number; - getVelocity(): Vector3; - getViewDirection(): Vector3; + playMusic(trackId: string, musicOptions?: MusicOptions): void; /** - * @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. + * 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 + * import { world, MusicOptions, WorldSoundOptions, PlayerSoundOptions, Vector3 } from '@minecraft/server'; + * + * const players = world.getPlayers(); + * const targetLocation: Vector3 = { + * x: 0, + * y: 0, + * z: 0, + * }; + * + * const musicOptions: MusicOptions = { + * fade: 0.5, + * loop: true, + * volume: 1.0, + * }; + * world.playMusic('music.menu', musicOptions); + * + * const worldSoundOptions: WorldSoundOptions = { + * pitch: 0.5, + * volume: 4.0, + * }; + * world.playSound('ambient.weather.thunder', targetLocation, worldSoundOptions); + * + * const playerSoundOptions: PlayerSoundOptions = { + * pitch: 1.0, + * volume: 1.0, + * }; + * + * players[0].playSound('bucket.fill_water', playerSoundOptions); + * ``` */ - hasComponent(componentId: string): boolean; + playSound(soundId: string, location: Vector3, soundOptions?: WorldSoundOptions): void; /** - * @beta * @remarks - * Tests whether an entity has a particular tag. - * @param tag - * Identifier of the tag to test for. - * @throws This function can throw errors. + * 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 trackId + * Identifier of the music track to play. + * @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. + * */ - hasTag(tag: string): boolean; + queueMusic(trackId: string, musicOptions?: MusicOptions): void; /** - * @beta * @remarks - * Returns true if this player has operator-level permissions. - * @throws This function can throw errors. + * 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 + * import { world } from '@minecraft/server'; + * + * // Displays "Apple or Coal" + * const rawMessage = { + * translate: 'accessibility.list.or.two', + * with: { rawtext: [{ translate: 'item.apple.name' }, { translate: 'item.coal.name' }] }, + * }; + * world.sendMessage(rawMessage); + * ``` + * @example scoreWildcard.ts + * ```typescript + * import { world } from '@minecraft/server'; + * + * // 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 + * import { world } from '@minecraft/server'; + * + * // Displays "Hello, world!" + * world.sendMessage('Hello, world!'); + * ``` + * @example translation.ts + * ```typescript + * import { world } from '@minecraft/server'; + * + * // Displays "First or Second" + * const rawMessage = { translate: 'accessibility.list.or.two', with: ['First', 'Second'] }; + * world.sendMessage(rawMessage); + * ``` */ - isOp(): boolean; + sendMessage(message: (RawMessage | string)[] | RawMessage | string): void; /** - * @beta * @remarks - * Kills this entity. The entity will drop loot as normal. - * @throws This function can throw errors. + * Sets the world time. + * + * This function can't be called in read-only mode. + * + * @param absoluteTime + * The world time, in ticks. */ - kill(): void; - playAnimation(animationName: string, options?: PlayAnimationOptions): void; + setAbsoluteTime(absoluteTime: number): void; /** - * @beta * @remarks - * Plays a sound that only this particular player can hear. - * @param soundID - * Identifier of the sound to play. - * @param soundOptions - * Additional optional options for the sound. - * @throws This function can throw errors. + * 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} */ - playSound(soundID: string, soundOptions?: SoundOptions): void; + setDefaultSpawnLocation(spawnLocation: Vector3): void; /** - * @beta * @remarks - * This is an internal-facing method for posting a system - * message to downstream clients. - * @param id + * Sets a specified property to a value. + * + * @param identifier + * The property identifier. * @param value - * @throws This function can throw errors. + * Data value of the property to set. + * @throws + * Throws if the given dynamic property identifier is not + * defined. + * @example incrementDynamicProperty.ts + * ```typescript + * import * as mc from '@minecraft/server'; + * + * function incrementProperty(propertyName: string): boolean { + * let number = mc.world.getDynamicProperty(propertyName); + * + * console.warn('Current value is: ' + number); + * + * if (number === undefined) { + * number = 0; + * } + * + * if (typeof number !== 'number') { + * console.warn('Number is of an unexpected type.'); + * return false; + * } + * + * mc.world.setDynamicProperty(propertyName, number + 1); + * return true; + * } + * + * incrementProperty('samplelibrary:number'); + * ``` + * @example incrementDynamicPropertyInJsonBlob.ts + * ```typescript + * import * as mc from '@minecraft/server'; + * + * function updateWorldProperty(propertyName: string): boolean { + * let paintStr = mc.world.getDynamicProperty(propertyName); + * let paint: { color: string; intensity: number } | undefined = undefined; + * + * console.log('Current value is: ' + paintStr); + * + * if (paintStr === undefined) { + * paint = { + * color: 'purple', + * intensity: 0, + * }; + * } else { + * if (typeof paintStr !== 'string') { + * console.warn('Paint is of an unexpected type.'); + * return false; + * } + * + * try { + * paint = JSON.parse(paintStr); + * } catch (e) { + * console.warn('Error parsing serialized struct.'); + * return false; + * } + * } + * + * if (!paint) { + * console.warn('Error parsing serialized struct.'); + * return false; + * } + * + * paint.intensity++; + * paintStr = JSON.stringify(paint); // be very careful to ensure your serialized JSON str cannot exceed limits + * mc.world.setDynamicProperty(propertyName, paintStr); + * + * return true; + * } + * + * updateWorldProperty('samplelibrary:longerjson'); + * ``` */ - postClientMessage(id: string, value: string): void; + setDynamicProperty(identifier: string, value?: boolean | number | string | Vector3): void; /** - * @beta * @remarks - * Removes a specified property. - * @param identifier - * @throws This function can throw errors. + * 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. */ - removeDynamicProperty(identifier: string): boolean; + setTimeOfDay(timeOfDay: number | TimeOfDay): void; /** - * @beta * @remarks - * Removes a specified tag from an entity. - * @param tag - * Content of the tag to remove. - * @throws This function can throw errors. + * Stops any music tracks from playing. + * + * This function can't be called in read-only mode. + * */ - removeTag(tag: string): boolean; + stopMusic(): void; +} + +/** + * Contains a set of events that are available across the scope + * of the World. + */ +export class WorldAfterEvents { + private constructor(); /** * @beta * @remarks - * Resets the level of the player. - * @throws This function can throw errors. + * This event fires for each BlockLocation destroyed by an + * explosion. It is fired after the blocks have already been + * destroyed. + * */ - resetLevel(): void; + readonly blockExplode: BlockExplodeAfterEventSignal; /** * @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. + * This event fires when a button is pushed. + * */ - runCommandAsync(commandString: string): Promise; + readonly buttonPush: ButtonPushAfterEventSignal; /** * @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 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); + * This event is triggered after a chat message has been + * broadcast or sent to players. * - * ``` */ - sendMessage(message: (RawMessage | string)[] | RawMessage | string): void; + readonly chatSend: ChatSendAfterEventSignal; /** - * @beta * @remarks - * Sets a specified property to a value. - * @param identifier - * @param value - * Data value of the property to set. - * @throws This function can throw errors. + * This event is fired when an entity event has been triggered + * that will update the component definition state of an + * entity. + * */ - setDynamicProperty(identifier: string, value: boolean | number | string): void; + readonly dataDrivenEntityTrigger: DataDrivenEntityTriggerAfterEventSignal; /** - * @beta * @remarks - * Sets a player on fire (if it is not in water or rain). Note - * that you can call getComponent('minecraft:onfire') and, if - * present, the player is on fire. - * @param seconds - * Length of time to set the player on fire. - * @param useEffects - * @throws This function can throw errors. + * This event fires when an effect, like poisoning, is added to + * an entity. + * */ - setOnFire(seconds: number, useEffects?: boolean): boolean; + readonly effectAdd: EffectAddAfterEventSignal; /** - * @beta * @remarks - * Will change the specified players permissions, and whether - * they are operator or not. - * @param isOp - * @throws This function can throw errors. + * This event fires when an entity dies. + * */ - setOp(isOp: boolean): void; + readonly entityDie: EntityDieAfterEventSignal; /** - * @beta * @remarks - * Sets the main rotation of the entity. - * @param degreesX - * @param degreesY - * @throws This function can throw errors. + * This event fires when entity health changes in any degree. + * */ - setRotation(degreesX: number, degreesY: number): void; - setSpawn(spawnPosition: Vector3, spawnDimension: Dimension): void; + readonly entityHealthChanged: EntityHealthChangedAfterEventSignal; /** - * @beta * @remarks - * Sets the item cooldown time for a particular cooldown - * category. - * @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. + * This event fires when an entity hits (that is, melee + * attacks) a block. + * */ - startItemCooldown(itemCategory: string, tickDuration: number): void; + readonly entityHitBlock: EntityHitBlockAfterEventSignal; /** - * @beta * @remarks - * Teleports the selected player to a new location - * @param location - * New location for the player. - * @param dimension - * Dimension to move the selected player to. - * @param xRotation - * X rotation of the player after teleportation. - * @param yRotation - * Y rotation of the player after teleportation. - * @param keepVelocity - * @throws This function can throw errors. + * This event fires when an entity hits (that is, melee + * attacks) another entity. + * */ - teleport( - location: Vector3, - dimension: Dimension, - xRotation: number, - yRotation: number, - keepVelocity?: boolean, - ): void; + readonly entityHitEntity: EntityHitEntityAfterEventSignal; /** - * @beta * @remarks - * Teleports the selected player to a new location, and will - * have the player facing a specified location. - * @param location - * New location for the player. - * @param dimension - * Dimension to move the selected player to. - * @param facingLocation - * Location that this player will be facing. - * @param keepVelocity - * @throws This function can throw errors. + * This event fires when an entity is hurt (takes damage). + * */ - teleportFacing(location: Vector3, dimension: Dimension, facingLocation: Vector3, keepVelocity?: boolean): void; + readonly entityHurt: EntityHurtAfterEventSignal; /** - * @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. - * @param eventName - * Name of the entity type event to trigger. If a namespace is - * not specified, minecraft: is assumed. - * @throws This function can throw errors. + * Fires when an entity is loaded. + * */ - triggerEvent(eventName: string): void; -} -export class PlayerInventoryComponentContainer extends InventoryComponentContainer { - protected constructor(); - readonly emptySlotsCount: number; - readonly size: number; - addItem(itemStack: ItemStack): void; - clearAll(): void; - clearItem(slot: number): void; - getItem(slot: number): ItemStack; - getSlot(slot: number): ContainerSlot; - setItem(slot: number, itemStack?: ItemStack): void; - swapItems(slot: number, otherSlot: number, otherContainer: Container): boolean; - transferItem(fromSlot: number, toSlot: number, toContainer: Container): boolean; -} -/** - * @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 { - protected constructor(); - [Symbol.iterator](): Iterator; + readonly entityLoad: EntityLoadAfterEventSignal; /** * @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. + * Fires when an entity is removed (for example, potentially + * unloaded, or removed after being killed). + * */ - 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 PlayerJoinEvent { - protected constructor(); + readonly entityRemove: EntityRemoveAfterEventSignal; /** - * Opaque string identifier of the player that joined the game. + * @remarks + * This event fires when an entity is spawned. + * */ - readonly playerId: string; + readonly entitySpawn: EntitySpawnAfterEventSignal; /** - * Name of the player that has joined. + * @remarks + * This event is fired after an explosion occurs. + * */ - readonly playerName: string; -} -/** - * @beta - * Manages callbacks that are connected to a player joining the - * world. - */ -export class PlayerJoinEventSignal { - protected constructor(); + readonly explosion: ExplosionAfterEventSignal; /** + * @beta * @remarks - * Adds a callback that will be called when a player joins the - * world. - * @param callback + * This event fires when a world.gameRules property has + * changed. + * */ - subscribe(callback: (arg: PlayerJoinEvent) => void): (arg: PlayerJoinEvent) => void; + readonly gameRuleChange: GameRuleChangeAfterEventSignal; /** * @remarks - * Removes a callback from being called when a player joins the - * world. - * @param callback - * @throws This function can throw errors. + * This event fires when a chargeable item completes charging. + * */ - unsubscribe(callback: (arg: PlayerJoinEvent) => void): void; -} -/** - * @beta - * Contains information regarding a player that has left the - * world. - */ -export class PlayerLeaveEvent { - protected constructor(); + readonly itemCompleteUse: ItemCompleteUseAfterEventSignal; /** - * Opaque string identifier of the player that has left the - * event. + * @remarks + * This event fires when a chargeable item is released from + * charging. + * */ - readonly playerId: string; + readonly itemReleaseUse: ItemReleaseUseAfterEventSignal; /** - * Player that has left the world. + * @remarks + * This event fires when a chargeable item starts charging. + * */ - readonly playerName: string; -} -/** - * @beta - * Manages callbacks that are connected to a player leaving the - * world. - */ -export class PlayerLeaveEventSignal { - protected constructor(); + readonly itemStartUse: ItemStartUseAfterEventSignal; /** * @remarks - * Adds a callback that will be called when a player leaves the - * world. - * @param callback + * 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. + * */ - subscribe(callback: (arg: PlayerLeaveEvent) => void): (arg: PlayerLeaveEvent) => void; + readonly itemStartUseOn: ItemStartUseOnAfterEventSignal; /** * @remarks - * Removes a callback from being called when a player leaves - * the world. - * @param callback - * @throws This function can throw errors. + * This event fires when a chargeable item stops charging. + * */ - unsubscribe(callback: (arg: PlayerLeaveEvent) => void): void; -} -/** - * @beta - * An event that contains more information about a player - * spawning. - */ -export class PlayerSpawnEvent { - protected constructor(); + readonly itemStopUse: ItemStopUseAfterEventSignal; /** - * If true, this is the initial spawn of a player after joining - * the game. + * @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. + * */ - initialSpawn: boolean; + readonly itemStopUseOn: ItemStopUseOnAfterEventSignal; /** - * Object that represents the player that joined the game. + * @remarks + * This event fires when an item is successfully used by a + * player. + * */ - player: Player; -} -/** - * @beta - * Registers an event when a player is spawned (or re-spawned - * after death) and fully ready within the world. - */ -export class PlayerSpawnEventSignal { - protected constructor(); + readonly itemUse: ItemUseAfterEventSignal; /** * @remarks - * Registers a new event receiver for this particular type of - * event. - * @param callback + * This event fires when an item is used on a block by a + * player. + * */ - subscribe(callback: (arg: PlayerSpawnEvent) => void): (arg: PlayerSpawnEvent) => void; + readonly itemUseOn: ItemUseOnAfterEventSignal; /** * @remarks - * De-registers an event receiver for the player spawn event. - * @param callback - * @throws This function can throw errors. + * A lever has been pulled. + * */ - unsubscribe(callback: (arg: PlayerSpawnEvent) => void): void; -} -/** - * @beta - * Contains information related to a projectile hitting an - * entity or block. - */ -export class ProjectileHitEvent { - protected constructor(); + readonly leverAction: LeverActionAfterEventSignal; /** - * Dimension where this projectile hit took place. + * @beta + * @remarks + * This event is an internal implementation detail, and is + * otherwise not currently functional. + * */ - readonly dimension: Dimension; + readonly messageReceive: ServerMessageAfterEventSignal; /** - * Direction vector of the projectile as it hit a block/entity. + * @remarks + * This event fires when a piston expands or retracts. + * */ - readonly hitVector: Vector; + readonly pistonActivate: PistonActivateAfterEventSignal; /** - * Location where the projectile hit occurred. + * @remarks + * This event fires for a block that is broken by a player. + * */ - readonly location: Vector3; + readonly playerBreakBlock: PlayerBreakBlockAfterEventSignal; /** - * Entity for the projectile that hit a block/entity. + * @remarks + * Fires when a player moved to a different dimension. + * */ - readonly projectile: Entity; + readonly playerDimensionChange: PlayerDimensionChangeAfterEventSignal; /** - * Optional source entity that fired the projectile. + * @beta */ - readonly source: Entity; - getBlockHit(): BlockHitInformation | undefined; - getEntityHit(): EntityHitInformation | undefined; -} -/** - * @beta - * Manages callbacks that are connected to when a projectile - * hits an entity or block. - */ -export class ProjectileHitEventSignal { - protected constructor(); + readonly playerGameModeChange: PlayerGameModeChangeAfterEventSignal; /** + * @beta * @remarks - * Adds a callback that will be called when a projectile hits - * an entity or block. - * @param callback + * An event for when a player interacts with a block. + * */ - subscribe(callback: (arg: ProjectileHitEvent) => void): (arg: ProjectileHitEvent) => void; + readonly playerInteractWithBlock: PlayerInteractWithBlockAfterEventSignal; /** - * @remarks - * Removes a callback from being called when a projectile hits - * an entity or block. - * @param callback - * @throws This function can throw errors. + * @beta + * @remarks + * This event fires when a player interacts with an entity. + * */ - unsubscribe(callback: (arg: ProjectileHitEvent) => 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 { - protected constructor(); + readonly playerInteractWithEntity: PlayerInteractWithEntityAfterEventSignal; /** * @remarks - * Registers a dynamic property for a particular entity type - * (e.g., a minecraft:skeleton.). - * @param propertiesDefinition - * @param entityType - * @throws This function can throw errors. + * 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. + * */ - registerEntityTypeDynamicProperties( - propertiesDefinition: DynamicPropertiesDefinition, - entityType: EntityType, - ): void; + readonly playerJoin: PlayerJoinAfterEventSignal; /** * @remarks - * Registers a globally available dynamic property for a world. - * @param propertiesDefinition - * @throws This function can throw errors. + * This event fires when a player leaves a world. + * */ - registerWorldDynamicProperties(propertiesDefinition: DynamicPropertiesDefinition): void; -} -/** - * @beta - * Contains objectives and participants for the scoreboard. - */ -export class Scoreboard { - protected constructor(); + readonly playerLeave: PlayerLeaveAfterEventSignal; /** * @remarks - * Adds a new objective to the scoreboard. - * @param objectiveId - * @param displayName - * @throws This function can throw errors. + * This event fires for a block that is placed by a player. + * */ - addObjective(objectiveId: string, displayName: string): ScoreboardObjective; + readonly playerPlaceBlock: PlayerPlaceBlockAfterEventSignal; /** * @remarks - * Clears the objective that occupies a display slot. - * @param displaySlotId - * @throws This function can throw errors. + * 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. + * */ - clearObjectiveAtDisplaySlot(displaySlotId: string): ScoreboardObjective; + readonly playerSpawn: PlayerSpawnAfterEventSignal; /** * @remarks - * Returns a specific objective (by id). - * @param objectiveId - * Identifier of the objective. - * @throws This function can throw errors. + * A pressure plate has popped back up (i.e., there are no + * entities on the pressure plate.) + * */ - getObjective(objectiveId: string): ScoreboardObjective; + readonly pressurePlatePop: PressurePlatePopAfterEventSignal; /** * @remarks - * Returns an objective that occupies the specified display - * slot. - * @param displaySlotId - * @throws This function can throw errors. + * A pressure plate has pushed (at least one entity has moved + * onto a pressure plate.) + * */ - getObjectiveAtDisplaySlot(displaySlotId: string): ScoreboardObjectiveDisplayOptions; + readonly pressurePlatePush: PressurePlatePushAfterEventSignal; /** * @remarks - * Returns all defined objectives. - * @throws This function can throw errors. + * This event fires when a projectile hits a block. + * */ - getObjectives(): ScoreboardObjective[]; + readonly projectileHitBlock: ProjectileHitBlockAfterEventSignal; /** * @remarks - * Returns all defined scoreboard identities. - * @throws This function can throw errors. + * This event fires when a projectile hits an entity. + * */ - getParticipants(): ScoreboardIdentity[]; + readonly projectileHitEntity: ProjectileHitEntityAfterEventSignal; /** * @remarks - * Returns a score given an objective and participant. - * @param objective - * Objective to retrieve the score for. - * @param participant - * Participant to retrieve the score for. - * @returns - * Score value. - * @throws This function can throw errors. + * A target block was hit. + * */ - getScore(objective: ScoreboardObjective, participant: ScoreboardIdentity): number; + readonly targetBlockHit: TargetBlockHitAfterEventSignal; /** * @remarks - * Removes an objective from the scoreboard. - * @param objectiveId - * @throws This function can throw errors. + * A trip wire was tripped. + * */ - removeObjective(objectiveId: ScoreboardObjective | string): boolean; + readonly tripWireTrip: TripWireTripAfterEventSignal; /** * @remarks - * Sets an objective into a display slot with specified - * additional display settings. - * @param displaySlotId - * @param objectiveDisplaySetting - * @throws This function can throw errors. + * This event will be triggered when the weather changes within + * Minecraft. + * */ - setObjectiveAtDisplaySlot( - displaySlotId: string, - objectiveDisplaySetting: ScoreboardObjectiveDisplayOptions, - ): ScoreboardObjective; + readonly weatherChange: WeatherChangeAfterEventSignal; /** * @remarks - * Sets the score given a participant and objective. - * @param objective - * Objective to use for the scoreboard. - * @param participant - * Participant to apply the scoreboard value to. - * @param score - * @throws This function can throw errors. + * This event fires when the script environment is initialized + * on a World. + * */ - setScore(objective: ScoreboardObjective, participant: ScoreboardIdentity, score: number): boolean; + readonly worldInitialize: WorldInitializeAfterEventSignal; } + /** - * @beta - * Contains an identity of the scoreboard item. + * 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 ScoreboardIdentity { - protected constructor(); +export class WorldBeforeEvents { + private constructor(); /** - * Returns the player-visible name of this identity. + * @beta + * @remarks + * This event is triggered after a chat message has been + * broadcast or sent to players. + * */ - readonly displayName: string; + readonly chatSend: ChatSendBeforeEventSignal; /** - * Identifier of the scoreboard identity. + * @remarks + * This event is triggered after an event has been added to an + * entity. + * */ - readonly id: number; + readonly effectAdd: EffectAddBeforeEventSignal; /** - * Type of the scoreboard identity. + * @remarks + * Fires before an entity is removed from the world (for + * example, unloaded or removed after being killed.) + * */ - readonly 'type': ScoreboardIdentityType; + readonly entityRemove: EntityRemoveBeforeEventSignal; /** * @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. + * This event is fired after an explosion occurs. + * */ - getEntity(): Entity; + readonly explosion: ExplosionBeforeEventSignal; /** * @remarks - * Gets the current score for this participant based on an - * objective. - * @param objective - * The objective to retrieve the score for. - * @returns - * Score value. - * @throws This function can throw errors. + * This event fires when an item is successfully used by a + * player. + * */ - getScore(objective: ScoreboardObjective): number; + readonly itemUse: ItemUseBeforeEventSignal; /** * @remarks - * Removes this participant from an objective. - * @param objective - * The objective to remove this participant from. - * @throws This function can throw errors. + * This event fires when an item is used on a block by a + * player. + * */ - removeFromObjective(objective: ScoreboardObjective): boolean; + readonly itemUseOn: ItemUseOnBeforeEventSignal; /** * @remarks - * Sets a score for this participant for a particular - * objective. - * @param objective - * Objective to apply the score to. - * @param score - * Score value. - * @throws This function can throw errors. + * This event fires before a block is broken by a player. + * */ - setScore(objective: ScoreboardObjective, score: number): boolean; -} -/** - * @beta - * Contains objectives and participants for the scoreboard. - */ -export class ScoreboardObjective { - protected constructor(); + readonly playerBreakBlock: PlayerBreakBlockBeforeEventSignal; /** - * Returns the player-visible name of this scoreboard - * objective. - * @throws This property can throw when used. + * @beta */ - readonly displayName: string; + readonly playerGameModeChange: PlayerGameModeChangeBeforeEventSignal; /** - * Identifier of the scoreboard objective. - * @throws This property can throw when used. + * @beta + * @remarks + * Fires before a player interacts with a block. + * */ - readonly id: string; + readonly playerInteractWithBlock: PlayerInteractWithBlockBeforeEventSignal; /** + * @beta * @remarks - * Returns all objective participant identities. - * @throws This function can throw errors. + * Fires before a player interacts with an entity. + * */ - getParticipants(): ScoreboardIdentity[]; + readonly playerInteractWithEntity: PlayerInteractWithEntityBeforeEventSignal; /** * @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. + * Fires when a player leaves the game. + * */ - getScore(participant: ScoreboardIdentity): number; + readonly playerLeave: PlayerLeaveBeforeEventSignal; /** + * @beta * @remarks - * Returns specific scores for this objective for all - * participants. - * @throws This function can throw errors. + * This event fires before a block is placed by a player. + * */ - getScores(): ScoreboardScoreInfo[]; + readonly playerPlaceBlock: PlayerPlaceBlockBeforeEventSignal; /** - * @remarks - * Removes a participant from this scoreboard objective. - * @param participant - * Participant to remove from being tracked with this - * objective. - * @throws This function can throw errors. + * @beta */ - removeParticipant(participant: ScoreboardIdentity): boolean; + readonly weatherChange: WeatherChangeBeforeEventSignal; /** + * @beta * @remarks - * Sets a score for a participant. - * @param participant - * Identity of the participant. - * @param score - * New value of the score. - * @throws This function can throw errors. + * This event fires immediately when the script environment is + * initialized on a World. Not all script functionality may be + * available. For guaranteed access to world state, use the + * world initialize after event. + * */ - setScore(participant: ScoreboardIdentity, score: number): boolean; + readonly worldInitialize: WorldInitializeBeforeEventSignal; } + /** - * @beta - * Contains a pair of a scoreboard participant and its - * respective score. + * Contains information and methods that can be used at the + * initialization of the scripting environment for a World. */ -export class ScoreboardScoreInfo { - protected constructor(); +export class WorldInitializeAfterEvent { + private constructor(); +} + +/** + * Manages callbacks that are run on the first tick of the + * 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(); /** - * This scoreboard participant for this score. + * @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. + * */ - readonly participant: ScoreboardIdentity; + subscribe(callback: (arg: WorldInitializeAfterEvent) => void): (arg: WorldInitializeAfterEvent) => void; /** - * Score value of the identity for this objective. + * @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. */ - readonly score: number; + unsubscribe(callback: (arg: WorldInitializeAfterEvent) => void): void; } + /** * @beta - * Contains information about user interface elements that are - * showing up on the screen. + * Contains information and methods that can be used at the + * initialization of the scripting environment for a World. + * Also, use the supplied blockRegistry object to register + * block custom components within the scope of the World + * Initialize execution. */ -export class ScreenDisplay { - protected constructor(); - /** - * @remarks - * Clears the title and subtitle, if currently displayed. - * @throws This function can throw errors. - */ - clearTitle(): void; +export class WorldInitializeBeforeEvent { + private constructor(); + readonly blockTypeRegistry: BlockComponentRegistry; + readonly itemComponentRegistry: ItemComponentRegistry; +} + +/** + * @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 WorldInitializeBeforeEventSignal { + private constructor(); /** * @remarks - * Set the action bar text - a piece of text that displays - * beneath the title and above the hot-bar. - * @param text - * @throws This function can throw errors. + * 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. + * */ - setActionBar(text: string): void; + subscribe(callback: (arg: WorldInitializeBeforeEvent) => void): (arg: WorldInitializeBeforeEvent) => void; /** * @remarks - * Will cause a title to show up on the player's on screen - * display. You can optionally specify an additional subtitle - * as well as fade in, stay and fade out times. - * @param title - * @param options + * 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. */ - setTitle(title: string, options?: TitleDisplayOptions): void; + unsubscribe(callback: (arg: WorldInitializeBeforeEvent) => void): void; +} + +/** + * @beta + * Contains additional options for searches for the + * dimension.findNearestBiome API. + */ +export interface BiomeSearchOptions { /** * @remarks - * Updates the subtitle if the subtitle was previously - * displayed via the setTitle method. - * @param subtitle - * @throws This function can throw errors. + * Bounding volume size to look within. + * */ - updateSubtitle(subtitle: string): void; + boundingSize?: Vector3; } + /** * @beta - * Returns additional data about a /scriptevent command - * invocation. + * Contains a set of events that will be raised for a block. + * This object must be bound using the BlockRegistry. */ -export class ScriptEventCommandMessageEvent { - protected constructor(); +export interface BlockCustomComponent { /** - * Identifier of this ScriptEvent command message. + * @remarks + * This function will be called before a player places the + * block. + * */ - readonly id: string; + beforeOnPlayerPlace?: (arg: BlockComponentPlayerPlaceBeforeEvent) => void; /** - * If this command was initiated via an NPC, returns the entity - * that initiated the NPC dialogue. + * @remarks + * This function will be called when an entity falls onto the + * block that this custom component is bound to. + * */ - readonly initiator: Entity; + onEntityFallOn?: (arg: BlockComponentEntityFallOnEvent) => void; /** - * Optional additional data passed in with the script event - * command. + * @remarks + * This function will be called when the block that this custom + * component is bound to is placed. + * */ - readonly message: string; + onPlace?: (arg: BlockComponentOnPlaceEvent) => void; /** - * Source block if this command was triggered via a block - * (e.g., a commandblock.) + * @remarks + * This function will be called when a player destroys a + * specific block. + * + */ + onPlayerDestroy?: (arg: BlockComponentPlayerDestroyEvent) => void; + /** + * @remarks + * This function will be called when a player sucessfully + * interacts with the block that this custom component is bound + * to. + * + */ + onPlayerInteract?: (arg: BlockComponentPlayerInteractEvent) => void; + /** + * @remarks + * This function will be called when a block randomly ticks. + * + */ + onRandomTick?: (arg: BlockComponentRandomTickEvent) => void; + /** + * @remarks + * This function will be called when an entity steps off the + * block that this custom component is bound to. + * */ - readonly sourceBlock: Block; + onStepOff?: (arg: BlockComponentStepOffEvent) => void; /** - * Source entity if this command was triggered by an entity - * (e.g., a NPC). + * @remarks + * This function will be called when an entity steps onto the + * block that this custom component is bound to. + * */ - readonly sourceEntity: Entity; + onStepOn?: (arg: BlockComponentStepOnEvent) => void; /** - * Returns the type of source that fired this command. + * @remarks + * This function will be called when a block ticks. + * */ - readonly sourceType: MessageSourceType; + onTick?: (arg: BlockComponentTickEvent) => void; } + /** - * @beta - * Allows for registering an event handler that responds to - * inbound /scriptevent commands. + * Contains optional parameters for registering a block event. */ -export class ScriptEventCommandMessageSignal { - protected constructor(); +export interface BlockEventOptions { /** * @remarks - * Registers a new ScriptEvent handler. - * @param callback - * @param options + * If this value is set, this event will only fire if the + * impacted block's type matches this parameter. + * */ - subscribe( - callback: (arg: ScriptEventCommandMessageEvent) => void, - options?: ScriptEventMessageFilterOptions, - ): (arg: ScriptEventCommandMessageEvent) => void; + blockTypes?: string[]; /** * @remarks - * Unsubscribes a particular handler for a ScriptEvent event. - * @param callback - * @throws This function can throw errors. + * If this value is set, this event will only fire if the + * impacted block's permutation matches this parameter. + * */ - unsubscribe(callback: (arg: ScriptEventCommandMessageEvent) => void): void; + permutations?: BlockPermutation[]; } + /** * @beta - * Describes a particular seating position on this rideable - * entity. + * Contains additional options for a block fill operation. */ -export class Seat { - protected constructor(); +export interface BlockFillOptions { /** - * If specified, contains a forced rotation that the riders in - * this seat are facing. + * @remarks + * When specified, the fill operation will only apply to blocks + * that match this description. + * */ - readonly lockRiderRotation: number; + matchingBlock?: BlockPermutation; +} + +/** + * @beta + */ +export interface BlockFilter { + excludePermutations?: BlockPermutation[]; + excludeTags?: string[]; + excludeTypes?: string[]; + includePermutations?: BlockPermutation[]; + includeTags?: string[]; + includeTypes?: string[]; +} + +/** + * Contains more information for events where a block is hit. + */ +export interface BlockHitInformation { /** - * A maximum number of riders that this seat can support. + * @remarks + * Block that was hit. + * */ - readonly maxRiderCount: number; + block: Block; /** - * A minimum number of riders that can be placed in this seat - * position, if this seat is to be filled. + * @remarks + * Face of the block that was hit. + * */ - readonly minRiderCount: number; + face: Direction; /** - * Physical location of this seat, relative to the entity's - * location. + * @remarks + * Location relative to the bottom north-west corner of the + * block. + * */ - readonly position: Vector3; + faceLocation: Vector3; } + /** - * @beta - * Manages callbacks that are message passing to a server. This - * event is not currently fully implemented, and should not be - * used. + * Contains information for block raycast hit results. */ -export class ServerMessageSignal { - protected constructor(); +export interface BlockRaycastHit { /** * @remarks - * Adds a callback that will be called when an internal message - * is passed. - * @param callback + * Block that was hit. + * */ - subscribe(callback: (arg: MessageReceiveEvent) => void): (arg: MessageReceiveEvent) => void; + block: Block; /** * @remarks - * Removes a callback from being called when an internal - * message is passed. - * @param callback - * @throws This function can throw errors. + * Face of the block that was hit. + * + */ + face: Direction; + /** + * @remarks + * Hit location relative to the bottom north-west corner of the + * block. + * */ - unsubscribe(callback: (arg: MessageReceiveEvent) => void): void; + faceLocation: Vector3; } + /** - * A class that provides system-level events and functions. + * Contains additional options for configuring a block raycast + * query. */ -export class System { - protected constructor(); +export interface BlockRaycastOptions { /** * @beta - * Represents the current world tick of the server. */ - readonly currentTick: number; + blockFilter?: BlockFilter; /** - * @beta - * Contains a set of events that are applicable for the - * lifecycle of items in the Minecraft system. + * @remarks + * If true, liquid blocks will be considered as blocks that + * 'stop' the raycast. + * */ - readonly events: SystemEvents; + includeLiquidBlocks?: boolean; /** - * @beta * @remarks - * Cancels the execution of a function run that was previously - * scheduled via the `run` function. - * @param runId + * If true, passable blocks like vines and flowers will be + * considered as blocks that 'stop' the raycast. + * */ - clearRun(runId: number): void; + includePassableBlocks?: boolean; /** * @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. + * Maximum distance, in blocks, to process the raycast. + * */ - run(callback: () => void): number; + maxDistance?: number; +} + +/** + * @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 { /** - * @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. + * A {@link @minecraft-server.Vector3} that represents the + * largest corner of the rectangle + * */ - runInterval(callback: () => void, tickInterval?: number): number; + max: Vector3; /** - * @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. + * A {@link @minecraft-server.Vector3} that represents the + * smallest corner of the rectangle + * */ - runTimeout(callback: () => void, tickDelay?: number): number; + min: Vector3; +} + +export interface CameraDefaultOptions { + /** + * @remarks + * Sets a set of easing options for the camera. + * + */ + easeOptions: CameraEaseOptions; } + /** - * @beta - * Contains a set of events that are available across the scope - * of the Minecraft add-on system. + * Contains options associated with a camera ease operation. */ -export class SystemEvents { - protected constructor(); +export interface CameraEaseOptions { /** - * This event fires before a the performance watchdog - * terminates scripting execution due to exceeding a - * performance boundary. Depending on the configuration of the - * runtime environment, this event can be canceled. For - * example, on certain dedicated server environments the - * ability to override termination events may be disabled. + * @remarks + * Time for the ease operation. + * */ - readonly beforeWatchdogTerminate: BeforeWatchdogTerminateEventSignal; + easeTime?: number; /** - * This event fires if a /scriptevent command is invoked by a - * player, NPC, or block. + * @remarks + * Type of ease operation to use. + * */ - readonly scriptEventReceive: ScriptEventCommandMessageSignal; + easeType?: EasingType; } + /** - * @beta - * An event for handling updates, that fires 20 times every - * second. + * Used to initiate a full-screen color fade. */ -export class TickEvent { - protected constructor(); +export interface CameraFadeOptions { /** - * Current tick at the time this event was fired. + * @remarks + * Fade color to use. + * */ - readonly currentTick: number; + fadeColor?: RGB; /** - * Time since the last tick was fired. + * @remarks + * Time in seconds for the fade-in, hold, and fade-out seconds. + * */ - readonly deltaTime: number; + fadeTime?: CameraFadeTimeOptions; } + /** - * @beta - * Manages callbacks that are connected to a tick event. + * Contains timings for a fade transition. */ -export class TickEventSignal { - protected constructor(); +export interface CameraFadeTimeOptions { /** * @remarks - * Adds a callback that will be called on every tick. - * @param callback + * Time, in seconds, for a fade-in. + * */ - subscribe(callback: (arg: TickEvent) => void): (arg: TickEvent) => void; + fadeInTime: number; /** * @remarks - * Removes a callback from being called every tick. - * @param callback - * @throws This function can throw errors. + * Time, in seconds, for a fade-out. + * + */ + fadeOutTime: number; + /** + * @remarks + * Time, in seconds, to hold the full screen color. + * */ - unsubscribe(callback: (arg: TickEvent) => void): void; + holdTime: number; +} + +export interface CameraSetFacingOptions { + easeOptions?: CameraEaseOptions; + facingEntity: Entity; + location?: Vector3; +} + +export interface CameraSetLocationOptions { + easeOptions?: CameraEaseOptions; + location: Vector3; +} + +export interface CameraSetPosOptions { + easeOptions?: CameraEaseOptions; + facingLocation: Vector3; + location?: Vector3; } + +export interface CameraSetRotOptions { + easeOptions?: CameraEaseOptions; + location?: Vector3; + rotation: Vector2; +} + /** * @beta - * Represents a trigger for firing an event. + * This interface defines an entry into the {@link + * @minecraft-server/CompoundBlockVolume} which represents a + * volume of positive or negative space. + * */ -export class Trigger { +export interface CompoundBlockVolumeItem { /** - * Event name of the trigger. + * @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. + * */ - eventName: string; + action?: CompoundBlockVolumeAction; /** * @remarks - * Creates a new trigger. - * @param eventName + * The relativity enumeration determines whether the + * BlockVolume specified is positioned relative to the parent + * compound block volume origin, or in absolute world space. + * */ - constructor(eventName: string); + locationRelativity?: CompoundBlockVolumePositionRelativity; + /** + * @remarks + * The volume of space + * + */ + volume: BlockVolume; } + /** - * @beta - * Contains a description of a vector. + * Contains a set of updates to the component definition state + * of an entity. */ -export class Vector { +export interface DefinitionModifier { /** - * X component of this vector. + * @remarks + * Retrieves the list of component groups that will be added + * via this definition modification. + * */ - x: number; + addedComponentGroups: string[]; /** - * Y component of this vector. + * @remarks + * The list of component groups that will be removed via this + * definition modification. + * */ - y: number; + removedComponentGroups: string[]; /** - * Z component of this vector. + * @beta + * @remarks + * The list of entity definition events that will be fired via + * this update. + * */ - z: number; + triggers: Trigger[]; +} + +/** + * An exact coordinate within the world, including its + * dimension and location. + */ +export interface DimensionLocation { /** - * A constant vector that represents (0, 0, -1). + * @remarks + * Dimension that this coordinate is associated with. + * */ - static readonly back: Vector; + dimension: Dimension; /** - * A constant vector that represents (0, -1, 0). + * @remarks + * X component of this dimension-location. + * */ - static readonly down: Vector; + x: number; /** - * A constant vector that represents (0, 0, 1). + * @remarks + * Y component of this dimension-location. + * */ - static readonly forward: Vector; + y: number; /** - * A constant vector that represents (-1, 0, 0). + * @remarks + * Z component of this dimension-location. + * */ - static readonly left: Vector; + z: number; +} + +/** + * @beta + * This interface represents a specific leveled enchantment + * that is applied to an item. + */ +export interface Enchantment { /** - * A constant vector that represents (1, 1, 1). + * @remarks + * The level of this enchantment instance. + * */ - static readonly one: Vector; + level: number; /** - * A constant vector that represents (1, 0, 0). + * @remarks + * The enchantment type of this instance. + * */ - static readonly right: Vector; + type: EnchantmentType; +} + +/** + * Additional options for when damage has been applied via a + * projectile. + */ +export interface EntityApplyDamageByProjectileOptions { /** - * A constant vector that represents (0, 1, 0). + * @remarks + * Optional entity that fired the projectile. + * */ - static readonly up: Vector; + damagingEntity?: Entity; /** - * A constant vector that represents (0, 0, 0). + * @remarks + * Projectile that caused damage. + * */ - static readonly zero: Vector; + damagingProjectile: Entity; +} + +/** + * Additional descriptions and metadata for a damage event. + */ +export interface EntityApplyDamageOptions { /** * @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. + * Underlying cause of the damage. + * */ - constructor(x: number, y: number, z: number); + cause: EntityDamageCause; /** * @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. + * Optional entity that caused the damage. + * */ - equals(other: Vector): boolean; + damagingEntity?: Entity; +} + +/** + * Provides information about how damage has been applied to an + * entity. + */ +export interface EntityDamageSource { /** * @remarks - * Returns the length of this vector. + * Cause enumeration of damage. + * */ - length(): number; + cause: EntityDamageCause; /** * @remarks - * Returns the squared length of this vector. + * Optional entity that caused the damage. + * */ - lengthSquared(): number; + damagingEntity?: Entity; /** * @remarks - * Returns this vector as a normalized vector. + * Optional projectile that may have caused damage. + * */ - normalized(): Vector; + damagingProjectile?: Entity; +} + +/** + * Specifies additional filters that are used in registering a + * data driven trigger event for entities. + */ +export interface EntityDataDrivenTriggerEventOptions { /** * @remarks - * Returns the addition of these vectors. - * @param a - * @param b + * If this value is set, this event will only fire for entities + * that match the entities within this collection. + * */ - static add(a: Vector3, b: Vector3): Vector; + entities?: Entity[]; /** * @remarks - * Returns the cross product of these two vectors. - * @param a - * @param b + * If this value is set, this event will only fire if the + * impacted entities' type matches this parameter. + * */ - static cross(a: Vector3, b: Vector3): Vector; + entityTypes?: string[]; /** * @remarks - * Returns the distance between two vectors. - * @param a - * @param b + * If this value is set, this event will only fire if the + * impacted triggered event matches one of the events listed in + * this parameter. + * */ - static distance(a: Vector3, b: Vector3): number; + eventTypes?: string[]; +} + +/** + * Contains additional options for entity effects. + */ +export interface EntityEffectOptions { /** * @remarks - * Returns the component-wise division of these vectors. - * @param a - * @param b + * The strength of the effect. + * */ - static divide(a: Vector3, b: number | Vector3): Vector; + amplifier?: number; /** * @remarks - * Returns the linear interpolation between a and b using t as - * the control. - * @param a - * @param b - * @param t + * If true, will show particles when effect is on the entity. + * */ - static lerp(a: Vector3, b: Vector3, t: number): Vector; + showParticles?: boolean; +} + +/** + * Contains optional parameters for registering an entity + * event. + */ +export interface EntityEventOptions { /** * @remarks - * Returns a vector that is made from the largest components of - * two vectors. - * @param a - * @param b + * If this value is set, this event will only fire for entities + * that match the entities within this collection. + * */ - static max(a: Vector3, b: Vector3): Vector; + entities?: Entity[]; /** * @remarks - * Returns a vector that is made from the smallest components - * of two vectors. - * @param a - * @param b + * If this value is set, this event will only fire if the + * impacted entities' type matches this parameter. + * */ - static min(a: Vector3, b: Vector3): Vector; + entityTypes?: string[]; +} + +/** + * Contains additional information about an entity that was + * hit. + */ +export interface EntityHitInformation { /** * @remarks - * Returns the component-wise product of these vectors. - * @param a - * @param b + * Entity that was hit. + * */ - static multiply(a: Vector3, b: number | Vector3): Vector; + entity?: Entity; +} + +/** + * Contains options for selecting entities within an area. + * @example testBlockConditional.ts + * ```typescript + * import { Dimension } from '@minecraft/server'; + * + * // Having this command: + * + * // execute as @e[type=fox] positioned as @s if block ^ ^-1 ^ stone run summon salmon + * + * // Equivalent scripting code would be: + * function spawnFish(dimension: Dimension) { + * dimension + * .getEntities({ + * type: 'fox', + * }) + * .filter(entity => { + * const block = dimension.getBlock({ + * x: entity.location.x, + * y: entity.location.y - 1, + * z: entity.location.z, + * }); + * + * return block !== undefined && block.matches('minecraft:stone'); + * }) + * .forEach(entity => { + * dimension.spawnEntity('salmon', entity.location); + * }); + * } + * ``` + * @example testPlaySoundChained.ts + * ```typescript + * import { Dimension } from '@minecraft/server'; + * + * // Having this command: + * + * // execute as @e[type=armor_stand,name=myArmorStand,tag=dummyTag1,tag=!dummyTag2] run playsound raid.horn @a + * + * // Equivalent scripting code would be: + * function playSounds(dimension: Dimension) { + * const targetPlayers = dimension.getPlayers(); + * const originEntities = dimension.getEntities({ + * type: 'armor_stand', + * name: 'myArmorStand', + * tags: ['dummyTag1'], + * excludeTags: ['dummyTag2'], + * }); + * + * originEntities.forEach(entity => { + * targetPlayers.forEach(player => { + * player.playSound('raid.horn'); + * }); + * }); + * } + * ``` + * @example testSendMessageAllPlayers.ts + * ```typescript + * import { Dimension } from '@minecraft/server'; + * + * // Having this command: + * + * // execute as @e[type=armor_stand,name=myArmorStand,tag=dummyTag1,tag=!dummyTag2] run tellraw @a { "rawtext": [{"translate": "hello.world" }] } + * + * // Equivalent scripting code would be: + * function sendMessagesToPlayers(dimension: Dimension) { + * const targetPlayers = dimension.getPlayers(); + * const originEntities = dimension.getEntities({ + * type: 'armor_stand', + * name: 'myArmorStand', + * tags: ['dummyTag1'], + * excludeTags: ['dummyTag2'], + * }); + * + * originEntities.forEach(entity => { + * targetPlayers.forEach(player => { + * player.sendMessage({ rawtext: [{ translate: 'hello.world' }] }); + * }); + * }); + * } + * ``` + * @example testSetScoreBoardChained.ts + * ```typescript + * import { Dimension, world } from '@minecraft/server'; + * + * // Having these commands: + * + * // scoreboard objectives add scoreObjective1 dummy + * // scoreboard players set @e[type=armor_stand,name=myArmorStand] scoreObjective1 -1 + * + * // Equivalent scripting code would be: + * function setScores(dimension: Dimension) { + * const objective = world.scoreboard.addObjective('scoreObjective1', 'dummy'); + * dimension + * .getEntities({ + * type: 'armor_stand', + * name: 'myArmorStand', + * }) + * .forEach(entity => { + * if (entity.scoreboardIdentity !== undefined) { + * objective.setScore(entity.scoreboardIdentity, -1); + * } + * }); + * } + * ``` + * @example testSummonMobChained.ts + * ```typescript + * import { Dimension } from '@minecraft/server'; + * + * // Having this command: + * + * // execute as @e[type=armor_stand] run execute as @a[x=0,y=-60,z=0,c=4,r=15] run summon pig ~1 ~ ~ + * + * // Equivalent scripting code would be: + * function spawnPigs(dimension: Dimension) { + * const armorStandArray = dimension.getEntities({ + * type: 'armor_stand', + * }); + * const playerArray = dimension.getPlayers({ + * location: { x: 0, y: -60, z: 0 }, + * closest: 4, + * maxDistance: 15, + * }); + * armorStandArray.forEach(entity => { + * playerArray.forEach(player => { + * dimension.spawnEntity('pig', { + * x: player.location.x + 1, + * y: player.location.y, + * z: player.location.z, + * }); + * }); + * }); + * } + * ``` + * @example checkFeatherNearby.ts + * ```typescript + * import { DimensionLocation, EntityComponentTypes } from "@minecraft/server"; + * + * // Returns true if a feather item entity is within 'distance' blocks of 'location'. + * function isFeatherNear(location: DimensionLocation, distance: number): boolean { + * const items = location.dimension.getEntities({ + * location: location, + * maxDistance: 20, + * }); + * + * for (const item of items) { + * const itemComp = item.getComponent(EntityComponentTypes.Item); + * + * if (itemComp) { + * if (itemComp.itemStack.typeId.endsWith('feather')) { + * return true; + * } + * } + * } + * + * return false; + * } + * ``` + */ +export interface EntityQueryOptions { /** * @remarks - * Returns the spherical linear interpolation between a and b - * using s as the control. - * @param a - * @param b - * @param s + * 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. + * */ - static slerp(a: Vector3, b: Vector3, s: number): Vector; + closest?: number; /** * @remarks - * Returns the subtraction of these vectors. - * @param a - * @param b + * Excludes entities that match one or more of the specified + * families. + * */ - static subtract(a: Vector3, b: Vector3): Vector; -} -/** - * @beta - * Contains information related to changes in weather in the - * environment. - */ -export class WeatherChangeEvent { - protected constructor(); + excludeFamilies?: string[]; /** - * Dimension in which the weather has changed. + * @remarks + * Excludes entities if have a specific gamemode that matches + * the specified gamemode. + * */ - readonly dimension: string; + excludeGameModes?: GameMode[]; /** - * Whether it is lightning after the change in weather. + * @remarks + * Excludes entities that have a name that match one of the + * specified values. + * */ - readonly lightning: boolean; + excludeNames?: string[]; /** - * Whether it is raining after the change in weather. + * @remarks + * Excludes entities with a tag that matches one of the + * specified values. + * */ - readonly raining: boolean; -} -/** - * @beta - * Manages callbacks that are connected to weather changing. - */ -export class WeatherChangeEventSignal { - protected constructor(); + excludeTags?: string[]; /** * @remarks - * Adds a callback that will be called when weather changes. - * @param callback + * Excludes entities if they are one of the specified types. + * */ - subscribe(callback: (arg: WeatherChangeEvent) => void): (arg: WeatherChangeEvent) => void; + excludeTypes?: string[]; /** * @remarks - * Removes a callback from being called when weather changes. - * @param callback - * @throws This function can throw errors. + * If specified, includes entities that match all of the + * specified families. + * */ - unsubscribe(callback: (arg: WeatherChangeEvent) => void): void; -} -/** - * A class that wraps the state of a world - a set of - * dimensions and the environment of Minecraft. - */ -export class World { - protected constructor(); + families?: string[]; /** - * @beta - * Contains a set of events that are applicable to the entirety - * of the world. + * @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. + * */ - readonly events: Events; + farthest?: number; /** - * @beta - * Returns the general global scoreboard that applies to the - * world. + * @remarks + * If specified, includes entities with a gamemode that matches + * the specified gamemode. + * */ - readonly scoreboard: Scoreboard; + gameMode?: GameMode; /** - * @beta * @remarks - * A method that is internal-only, used for broadcasting - * specific messages between client and server. - * @param id - * @param value + * Adds a seed location to the query that is used in + * conjunction with closest, farthest, limit, volume, and + * distance properties. + * */ - broadcastClientMessage(id: string, value: string): void; + location?: Vector3; /** - * @beta * @remarks - * Returns the absolute time since the start of the world. + * If specified, includes entities that are less than this + * distance away from the location specified in the location + * property. + * */ - getAbsoluteTime(): number; + maxDistance?: number; /** * @remarks - * Returns an array of all active players within the world. - * @throws This function can throw errors. + * If specified, will only include entities that have at most + * this horizontal rotation. + * */ - getAllPlayers(): Player[]; - getDefaultSpawnPosition(): Vector3; + maxHorizontalRotation?: number; /** * @remarks - * Returns a dimension object. - * @param dimensionId - * @returns - * The requested dimension - * @throws - * Throws if the given dimension name is invalid + * If defined, only players that have at most this level are + * returned. + * */ - getDimension(dimensionId: string): Dimension; + maxLevel?: number; /** - * @beta * @remarks - * Returns a property value. - * @param identifier - * @returns - * Returns the value for the property, or undefined if the - * property has not been set. - * @throws This function can throw errors. + * If specified, only entities that have at most this vertical + * rotation are returned. + * */ - getDynamicProperty(identifier: string): boolean | number | string | undefined; + maxVerticalRotation?: number; /** - * @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. + * If specified, includes entities that are least this distance + * away from the location specified in the location property. + * */ - getPlayers(options?: EntityQueryOptions): PlayerIterator; + minDistance?: number; /** - * @beta * @remarks - * Sets the current game time of the day. + * If specified, will only include entities that have at a + * minimum this horizontal rotation. + * */ - getTime(): number; + minHorizontalRotation?: number; /** - * @beta * @remarks - * Plays a particular music track for all players. - * @param trackID - * @param musicOptions + * If defined, only players that have at least this level are + * returned. + * */ - playMusic(trackID: string, musicOptions?: MusicOptions): void; + minLevel?: number; /** - * @beta * @remarks - * Plays a sound for all players. - * @param soundID - * @param soundOptions + * If specified, will only include entities that have at least + * this vertical rotation. + * */ - playSound(soundID: string, soundOptions?: SoundOptions): void; + minVerticalRotation?: number; /** - * @beta * @remarks - * Queues an additional music track for players. If a track is - * not playing, a music track will play. - * @param trackID - * @param musicOptions + * Includes entities with the specified name. + * */ - queueMusic(trackID: string, musicOptions?: MusicOptions): void; + name?: string; /** * @beta * @remarks - * Removes a specified property. - * @param identifier - * @throws This function can throw errors. + * Gets/sets a collection of EntityQueryPropertyOptions objects + * with filters for specific properties. + * */ - removeDynamicProperty(identifier: string): boolean; + propertyOptions?: EntityQueryPropertyOptions[]; /** - * @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); + * Gets/sets a collection of EntityQueryScoreOptions objects + * with filters for specific scoreboard objectives. * - * ``` */ - sendMessage(message: (RawMessage | string)[] | RawMessage | string): void; - setDefaultSpawn(spawnPosition: Vector3): void; + scoreOptions?: EntityQueryScoreOptions[]; /** - * @beta * @remarks - * Sets a specified property to a value. - * @param identifier - * @param value - * Data value of the property to set. - * @throws This function can throw errors. + * Includes entities that match all of the specified tags. + * */ - setDynamicProperty(identifier: string, value: boolean | number | string): void; + tags?: string[]; /** - * @beta * @remarks - * Returns the current game time of the day. - * @param timeOfDay + * If defined, entities that match this type are included. + * */ - setTime(timeOfDay: number): void; + type?: string; /** * @beta * @remarks - * Stops any music tracks from playing. + * In conjunction with location, specified a cuboid volume of + * entities to include. + * */ - stopMusic(): void; + volume?: Vector3; } + /** * @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 WorldInitializeEvent { - protected constructor(); - /** - * Contains methods for scripts to initialize and register - * dynamic properties they may wish to use within a world. - * @example propertyRegistration.js - * ```typescript - * import { DynamicPropertiesDefinition, MinecraftEntityTypes, world } from "@minecraft/server"; - * - * world.events.worldInitialize.subscribe((e) => { - * let def = new DynamicPropertiesDefinition(); - * - * def.defineNumber("rpgStrength"); - * def.defineString("rpgRole", 16); - * def.defineBoolean("rpgIsHero"); - * - * e.propertyRegistry.registerEntityTypeDynamicProperties(def, MinecraftEntityTypes.skeleton); - * }); - * - * ``` - */ - readonly propertyRegistry: PropertyRegistry; +export interface EntityQueryPropertyOptions { + exclude?: boolean; + propertyId: string; + value?: + | boolean + | string + | EqualsComparison + | GreaterThanComparison + | GreaterThanOrEqualsComparison + | LessThanComparison + | LessThanOrEqualsComparison + | NotEqualsComparison + | RangeComparison; } + /** - * @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. + * Contains additional options for filtering players based on + * their score for an objective. */ -export class WorldInitializeEventSignal { - protected constructor(); +export interface EntityQueryScoreOptions { /** * @remarks - * Adds a callback that will be called when the scripting - * environment is initialized for a World. - * @param callback + * If set to true, entities and players within this score range + * are excluded from query results. + * */ - subscribe(callback: (arg: WorldInitializeEvent) => void): (arg: WorldInitializeEvent) => void; + exclude?: boolean; /** * @remarks - * Removes a callback from being called the scripting - * environment is initialized for a World. - * @param callback - * @throws This function can throw errors. + * If defined, only players that have a score equal to or under + * maxScore are included. + * */ - unsubscribe(callback: (arg: WorldInitializeEvent) => void): void; -} -/** - * @beta - * Represents a rotation structure with pitch and yaw - * components. - */ -export class XYRotation { - protected constructor(); + maxScore?: number; /** - * Yaw component (left-to-right) of this position. + * @remarks + * If defined, only players that have a score equal to or over + * minScore are included. + * */ - x: number; + minScore?: number; /** - * Pitch (up-and-down) element of this rotation. + * @remarks + * Identifier of the scoreboard objective to filter on. + * */ - y: number; -} -export interface BlockFillOptions { - matchingBlock?: BlockPermutation; + objective?: string; } + /** - * @beta - * Contains more information for events where a block is hit. + * Contains information for entity raycast hit results. */ -export interface BlockHitInformation { - /** - * Block that was hit. - */ - block: Block; - /** - * Face of the block that was hit. - */ - face: Direction; +export interface EntityRaycastHit { /** - * X coordinate on the face that was hit. + * @remarks + * Distance from ray origin to entity bounds. + * */ - faceLocationX: number; + distance: number; /** - * Y coordinate on the face that was hit. + * @remarks + * Entity that was hit. + * */ - faceLocationY: number; + entity: Entity; } + /** - * @beta - * Contains additional options for configuring a block raycast - * query. + * Contains additional options for an entity raycast operation. */ -export interface BlockRaycastOptions { - /** - * If true, liquid blocks will be considered as blocks that - * 'stop' the raycast. - */ - includeLiquidBlocks?: boolean; - /** - * If true, passable blocks like vines and flowers will be - * considered as blocks that 'stop' the raycast. - */ - includePassableBlocks?: boolean; +export interface EntityRaycastOptions { /** + * @remarks * Maximum distance, in blocks, to process the raycast. + * */ maxDistance?: number; } + /** * @beta - * Represents a fully customizable color within Minecraft. + * Equal to operator. */ -export interface Color { +export interface EqualsComparison { /** - * Determines a color's alpha (opacity) component. Valid values - * are between 0 (transparent) and 1.0 (opaque). + * @remarks + * Threshold value compared against. + * */ - alpha: number; + equals: boolean | number | string; +} + +/** + * Additional configuration options for the {@link + * Dimension.createExplosion} method. + * @example createExplosions.ts + * ```typescript + * // Creates an explosion of radius 15 that does not break blocks + * import { DimensionLocation } from '@minecraft/server'; + * + * function createExplosions(location: DimensionLocation) { + * // Creates an explosion of radius 15 that does not break blocks + * location.dimension.createExplosion(location, 15, { breaksBlocks: false }); + * + * // Creates an explosion of radius 15 that does not cause fire + * location.dimension.createExplosion(location, 15, { causesFire: true }); + * + * // Creates an explosion of radius 10 that can go underwater + * location.dimension.createExplosion(location, 10, { allowUnderwater: true }); + * } + * ``` + */ +export interface ExplosionOptions { /** - * Determines a color's blue component. Valid values are - * between 0 and 1.0. + * @remarks + * Whether parts of the explosion also impact underwater. + * */ - blue: number; + allowUnderwater?: boolean; /** - * Determines a color's green component. Valid values are - * between 0 and 1.0. + * @remarks + * Whether the explosion will break blocks within the blast + * radius. + * */ - green: number; + breaksBlocks?: boolean; /** - * Determines a color's red component. Valid values are between - * 0 and 1.0. + * @remarks + * If true, the explosion is accompanied by fires within or + * near the blast radius. + * */ - red: number; -} -export interface EntityDamageSource { - cause: EntityDamageCause; - damagingEntity?: Entity; - damagingProjectile?: Entity; + causesFire?: boolean; + /** + * @remarks + * Optional source of the explosion. + * + */ + source?: Entity; } + /** * @beta - * Specifies additional filters that are used in registering a - * data driven trigger event for entities. + * Greater than operator. */ -export interface EntityDataDrivenTriggerEventOptions { +export interface GreaterThanComparison { /** - * If this value is set, this event will only fire for entities - * that match the entities within this collection. - */ - entities?: Entity[]; - /** - * If this value is set, this event will only fire if the - * impacted entities' type matches this parameter. - */ - entityTypes?: string[]; - /** - * If this value is set, this event will only fire if the - * impacted triggered event matches one of the events listed in - * this parameter. + * @remarks + * Threshold value compared against. + * */ - eventTypes?: string[]; + greaterThan: number; } + /** * @beta - * Contains optional parameters for registering an entity - * event. + * Greater than or equal to operator. */ -export interface EntityEventOptions { +export interface GreaterThanOrEqualsComparison { /** - * If this value is set, this event will only fire for entities - * that match the entities within this collection. + * @remarks + * Threshold value compared against. + * */ - entities?: Entity[]; + greaterThanOrEquals: number; +} + +/** + * @beta + */ +export interface ItemCustomComponent { + onUse?: (arg: ItemComponentUseEvent) => void; +} + +/** + * @beta + * Less than operator. + */ +export interface LessThanComparison { /** - * If this value is set, this event will only fire if the - * impacted entities' type matches this parameter. + * @remarks + * Threshold value compared against. + * */ - entityTypes?: string[]; + lessThan: number; } + /** * @beta - * Contains additional information about an entity that was - * hit. + * Less than or equal to operator. */ -export interface EntityHitInformation { +export interface LessThanOrEqualsComparison { /** - * Entity that was hit. + * @remarks + * Threshold value compared against. + * */ - entity: Entity; + lessThanOrEquals: number; } + /** - * @beta - * Contains options for selecting entities within an area. + * Additional configuration options for {@link + * World.playMusic}/{@link World.queueMusic} methods. */ -export interface EntityQueryOptions { +export interface MusicOptions { /** - * 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. + * @remarks + * Specifies a fade overlap for music at the end of play. + * */ - closest?: number; + fade?: number; /** - * Excludes entities that match one or more of the specified - * families. + * @remarks + * If set to true, this music track will play repeatedly. + * */ - excludeFamilies?: string[]; + loop?: boolean; /** - * Excludes entities if have a specific gamemode that matches - * the specified gamemode. + * @remarks + * Relative volume level of the music. + * */ - excludeGameModes?: GameMode[]; + volume?: number; +} + +/** + * @beta + * Not equal to operator. + */ +export interface NotEqualsComparison { /** - * Excludes entities that have a name that match one of the - * specified values. + * @remarks + * Threshold value compared against. + * */ - excludeNames?: string[]; + notEquals: boolean | number | string; +} + +/** + * Contains additional options for how an animation is played. + */ +export interface PlayAnimationOptions { /** - * Excludes entities with a tag that matches one of the - * specified values. + * @remarks + * Amount of time to fade out after an animation stops. + * */ - excludeTags?: string[]; + blendOutTime?: number; /** - * Excludes entities if they are one of the specified types. + * @remarks + * Specifies a controller to use that has been defined on the + * entity. + * */ - excludeTypes?: string[]; + controller?: string; /** - * If specified, includes entities that match all of the - * specified families. + * @remarks + * Specifies the state to transition to. + * */ - families?: string[]; + nextState?: string; /** - * 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. + * @remarks + * A list of players the animation will be visible to. + * */ - farthest?: number; + players?: string[]; /** - * If specified, includes entities with a gamemode that matches - * the specified gamemode. + * @remarks + * Specifies a Molang expression for when this animation should + * complete. + * */ - gameMode?: GameMode; + stopExpression?: string; +} + +/** + * Additional options for how a sound plays for a player. + */ +export interface PlayerSoundOptions { /** - * Adds a seed location to the query that is used in - * conjunction with closest, farthest, limit, volume, and - * distance properties. + * @remarks + * Location of the sound; if not specified, the sound is played + * near a player. + * */ location?: Vector3; /** - * If specified, includes entities that are less than this - * distance away from the location specified in the location - * property. + * @remarks + * Optional pitch of the sound. + * */ - maxDistance?: number; + pitch?: number; /** - * If specified, will only include entities that have at most - * this horizontal rotation. + * @remarks + * Optional volume of the sound. + * */ - maxHorizontalRotation?: number; + volume?: number; +} + +export interface ProjectileShootOptions { + uncertainty?: number; +} + +/** + * @beta + * Operator represents a lower/upper bound structure for + * expressing a potential range of numbers. + */ +export interface RangeComparison { /** - * If defined, only players that have at most this level are - * returned. + * @remarks + * Lower bound within a range. + * */ - maxLevel?: number; + lowerBound: number; /** - * If specified, only entities that have at most this vertical - * rotation are returned. + * @remarks + * Upper bound within a range. + * */ - maxVerticalRotation?: number; + upperBound: number; +} + +/** + * Defines a JSON structure that is used for more flexible. + * @example addTranslatedSign.ts + * ```typescript + * import { DimensionLocation, world, BlockPermutation, BlockComponentTypes } from '@minecraft/server'; + * + * function placeTranslatedSign(location: DimensionLocation, text: string) { + * const signBlock = location.dimension.getBlock(location); + * + * if (!signBlock) { + * console.warn('Could not find a block at specified location.'); + * return; + * } + * const signPerm = BlockPermutation.resolve('minecraft:standing_sign', { ground_sign_direction: 8 }); + * signBlock.setPermutation(signPerm); + * + * const signComponent = signBlock.getComponent(BlockComponentTypes.Sign); + * if (signComponent) { + * signComponent.setText({ translate: 'item.skull.player.name', with: [text] }); + * } else { + * console.error('Could not find a sign component on the block.'); + * } + * } + * + * placeTranslatedSign( + * { + * dimension: world.getDimension('overworld'), + * x: 0, + * y: 0, + * z: 0, + * }, + * 'Steve', + * ); + * ``` + * @example showTranslatedMessageForm.ts + * ```typescript + * import { world, Player } from '@minecraft/server'; + * import { MessageFormData, MessageFormResponse } from '@minecraft/server-ui'; + * + * function showMessage(player: Player) { + * const messageForm = new MessageFormData() + * .title({ translate: 'permissions.removeplayer' }) + * .body({ translate: 'accessibility.list.or.two', with: ['Player 1', 'Player 2'] }) + * .button1('Player 1') + * .button2('Player 2'); + * + * messageForm + * .show(player) + * .then((formData: MessageFormResponse) => { + * // player canceled the form, or another dialog was up and open. + * if (formData.canceled || formData.selection === undefined) { + * return; + * } + * + * console.warn(`You selected ${formData.selection === 0 ? 'Player 1' : 'Player 2'}`); + * }) + * .catch((error: Error) => { + * console.warn('Failed to show form: ' + error); + * }); + * }; + * + * showMessage(world.getAllPlayers()[0]); + * ``` + */ +export interface RawMessage { /** - * If specified, includes entities that are least this distance - * away from the location specified in the location property. + * @remarks + * Provides a raw-text equivalent of the current message. + * */ - minDistance?: number; + rawtext?: RawMessage[]; /** - * If specified, will only include entities that have at a - * minimum this horizontal rotation. + * @remarks + * Provides a token that will get replaced with the value of a + * score. + * */ - minHorizontalRotation?: number; + score?: RawMessageScore; /** - * If defined, only players that have at least this level are - * returned. + * @remarks + * Provides a string literal value to use. + * */ - minLevel?: number; + text?: string; /** - * If specified, will only include entities that have at least - * this vertical rotation. + * @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. + * */ - minVerticalRotation?: number; + translate?: string; /** - * Includes entities with the specified name. + * @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; /** - * Gets/sets a collection of EntityQueryScoreOptions objects - * with filters for specific scoreboard objectives. + * @remarks + * Name of the score value to match. + * */ - scoreOptions?: EntityQueryScoreOptions[]; + objective?: string; +} + +/** + * 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 { /** - * Includes entities that match all of the specified tags. + * @remarks + * A serialization of the current value of an associated sign. + * */ - tags?: string[]; + rawtext?: RawMessage[]; +} + +/** + * Represents a fully customizable color within Minecraft. + */ +export interface RGB { /** - * If defined, entities that match this type are included. + * @remarks + * Determines a color's blue component. Valid values are + * between 0 and 1.0. + * */ - type?: string; + blue: number; /** - * In conjunction with location, specified a cuboid volume of - * entities to include. + * @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. + * */ - volume?: BlockAreaSize; + red: number; } + /** - * @beta - * Contains additional options for filtering players based on - * their score for an objective. + * Represents a fully customizable color within Minecraft. */ -export interface EntityQueryScoreOptions { +// @ts-ignore Class inheritance allowed for native defined classes +export interface RGBA extends RGB { /** - * If set to true, entities and players within this score range - * are excluded from query results. + * @remarks + * Determines a color's alpha (opacity) component. Valid values + * are between 0 (transparent) and 1.0 (opaque). + * */ - exclude?: boolean; + alpha: number; +} + +/** + * Contains additional options for how a scoreboard should be + * displayed within its display slot. + */ +export interface ScoreboardObjectiveDisplayOptions { /** - * If defined, only players that have a score equal to or under - * maxScore are included. + * @remarks + * Objective to be displayed. + * */ - maxScore?: number; + objective: ScoreboardObjective; /** - * If defined, only players that have a score equal to or over - * minScore are included. + * @remarks + * The sort order to display the objective items within. + * */ - minScore?: number; + sortOrder?: ObjectiveSortOrder; +} + +/** + * Contains additional options for registering a script event + * event callback. + */ +export interface ScriptEventMessageFilterOptions { /** - * Identifier of the scoreboard objective to filter on. + * @remarks + * Optional list of namespaces to filter inbound script event + * messages. + * */ - objective?: string; + namespaces: string[]; } + /** * @beta - * Contains additional options for an entity raycast operation. */ -export interface EntityRaycastOptions { +export interface SpawnEntityOptions { + initialPersistence?: boolean; +} + +/** + * Provides additional options for {@link + * StructureManager.createFromWorld} + */ +export interface StructureCreateOptions { /** - * Maximum distance, in blocks, to process the raycast. + * @remarks + * Whether blocks should be included in the structure. Defaults + * to true. + * */ - maxDistance?: number; + includeBlocks?: boolean; + /** + * @remarks + * Whether entities should be included in the structure. + * Defaults to true. + * + */ + includeEntities?: boolean; + /** + * @remarks + * How the Structure should be saved. Defaults to + * StructureSaveMode.World. + * + */ + saveMode?: StructureSaveMode; } + /** - * @beta - * Additional configuration options for the {@link - * Dimension.createExplosion} method. + * Provides additional options for {@link + * StructureManager.place} */ -export interface ExplosionOptions { +export interface StructurePlaceOptions { /** - * Whether parts of the explosion also impact underwater. + * @remarks + * How the Structure should be animated when placed. + * */ - allowUnderwater?: boolean; + animationMode?: StructureAnimationMode; /** - * Whether the explosion will break blocks within the blast - * radius. + * @remarks + * How many seconds the animation should take. + * */ - breaksBlocks?: boolean; + animationSeconds?: number; /** - * If true, the explosion is accompanied by fires within or - * near the blast radius. + * @remarks + * Whether blocks should be included in the structure. Defaults + * to true. + * */ - causesFire?: boolean; + includeBlocks?: boolean; /** - * Optional source of the explosion. + * @remarks + * Whether entities should be included in the structure. + * Defaults to true. + * */ - source?: Entity; -} -/** - * @beta - * Additional configuration options for {@link - * World.playMusic}/{@link World.queueMusic} methods. - */ -export interface MusicOptions { + includeEntities?: boolean; /** - * Specifies a fade overlap for music at the end of play. + * @remarks + * What percentage of blocks should be placed. A value of 1 + * will place 100% of the blocks while a value of 0 will place + * none. The blocks are chosen randomly based on the {@link + * StructurePlaceOptions.integritySeed}. + * */ - fade?: number; + integrity?: number; /** - * If set to true, this music track will play repeatedly. + * @remarks + * Seed that determines which blocks are randomly chosen to be + * placed. Defaults to a random seed. + * */ - loop?: boolean; + integritySeed?: string; /** - * Relative volume level of the music. + * @remarks + * Which axes the Structure should be mirrored on when placed. + * Defaults to StructureMirrorAxis.None. + * */ - volume?: number; -} -/** - * @beta - * Represents a min/max structure for expressing a potential - * range of numbers. - */ -export interface NumberRange { + mirror?: StructureMirrorAxis; /** - * Maximum value within a range. + * @remarks + * How the Structure should be rotated when placed. Defaults to + * AxisAlignedRotation.None. + * */ - max: number; + rotation?: StructureRotation; /** - * Minimum value within a range. + * @remarks + * Whether the structure should be waterlogged when placed. + * Defaults to false. If true, blocks will become waterlogged + * when placed in water. + * */ - min: number; -} -export interface PlayAnimationOptions { - blendOutTime?: number; - controller?: string; - nextState?: string; - stopExpression?: string; -} -export interface RawMessage { - rawtext?: (RawMessage | string)[]; - score?: RawMessageScore; - text?: string; - translate?: string; - with?: string[] | RawMessage; -} -export interface RawMessageScore { - name?: string; - objective?: string; + waterlogged?: boolean; } + /** - * @beta - * Contains additional options for how a scoreboard should be - * displayed within its display slot. + * Contains additional options for teleporting an entity. + * @example teleportMovement.ts + * ```typescript + * import { world, system } from '@minecraft/server'; + * + * const overworld = world.getDimension('overworld'); + * const targetLocation = { x: 0, y: 0, z: 0 }; + * + * const pig = overworld.spawnEntity('minecraft:pig', targetLocation); + * + * let inc = 1; + * const runId = system.runInterval(() => { + * pig.teleport( + * { x: targetLocation.x + inc / 4, y: targetLocation.y + inc / 4, z: targetLocation.z + inc / 4 }, + * { + * facingLocation: targetLocation, + * }, + * ); + * + * if (inc > 100) { + * system.clearRun(runId); + * } + * inc++; + * }, 4); + * ``` */ -export interface ScoreboardObjectiveDisplayOptions { +export interface TeleportOptions { /** - * Objective to be displayed. + * @remarks + * Whether to check whether blocks will block the entity after + * teleport. + * */ - objective: ScoreboardObjective; + checkForBlocks?: boolean; /** - * The sort order to display the objective items within. + * @remarks + * Dimension to potentially move the entity to. If not + * specified, the entity is teleported within the dimension + * that they reside. + * */ - sortOrder?: ObjectiveSortOrder; -} -export interface ScriptEventMessageFilterOptions { - namespaces: string[]; -} -/** - * @beta - * Additional configuration options for the {@link - * Player.playSound}/{@link World.playSound} method. - */ -export interface SoundOptions { + dimension?: Dimension; /** - * Specifies a location of where to play a particular sound. + * @remarks + * Location that the entity should be facing after teleport. + * */ - location?: Vector3; + facingLocation?: Vector3; /** - * Pitch adjustment level for the sound. + * @remarks + * Whether to retain the entities velocity after teleport. + * */ - pitch?: number; + keepVelocity?: boolean; /** - * Relative volume level of the sound. + * @remarks + * Rotation of the entity after teleport. + * */ - volume?: number; + rotation?: Vector2; } + /** - * @beta * Contains additional options for displaying a title and * optional subtitle. */ export interface TitleDisplayOptions { /** - * Fade-in time for the title and subtitle, in seconds. + * @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. + * */ - fadeInSeconds: number; + fadeInDuration: number; /** - * Fade-out time for the title and subtitle, in seconds. + * @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. + * */ - fadeOutSeconds: number; + fadeOutDuration: number; /** - * Amount of time for the title and subtitle to stay in place. + * @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. + * */ - staySeconds: number; + stayDuration: number; /** + * @remarks * Optional subtitle text. + * */ - subtitle?: string; + 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; +} + /** - * @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; } -export const TicksPerDay = 24000; + +/** + * 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(); +} + +/** + * @beta + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class EnchantmentLevelOutOfBoundsError extends Error { + private constructor(); +} + +/** + * @beta + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class EnchantmentTypeNotCompatibleError extends Error { + private constructor(); +} + /** * @beta + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class EnchantmentTypeUnknownIdError extends Error { + private constructor(); +} + +// @ts-ignore Class inheritance allowed for native defined classes +export class InvalidContainerSlotError extends Error { + private constructor(); +} + +/** + * Thrown when a Structure is invalid. A structure becomes + * invalid when it is deleted. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class InvalidStructureError extends Error { + private constructor(); +} + +/** + * @beta + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class ItemCustomComponentAlreadyRegisteredError extends Error { + private constructor(); +} + +/** + * @beta + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class ItemCustomComponentNameError extends Error { + private constructor(); +} + +/** + * @beta + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class ItemCustomComponentReloadNewComponentError extends Error { + private constructor(); +} + +/** + * @beta + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class ItemCustomComponentReloadNewEventError extends Error { + private constructor(); +} + +/** + * @beta + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class ItemCustomComponentReloadVersionError extends Error { + private constructor(); +} + +/** + * Thrown when the chunk for provided location or bounding area + * is not loaded. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class LocationInUnloadedChunkError extends Error { + private constructor(); +} + +/** + * Thrown when a provided location or bounding area is outside + * the minimum or maximum dimension height. + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class LocationOutOfWorldBoundariesError extends Error { + private constructor(); +} + +/** + * @beta + */ +// @ts-ignore Class inheritance allowed for native defined classes +export class UnloadedChunksError extends Error { + private constructor(); +} + +/** + * @beta + */ +export const HudElementsCount = 13; +/** + * @beta + */ +export const HudVisibilityCount = 2; +/** + * @remarks + * Holds the number of MoonPhases + * + */ +export const MoonPhaseCount = 8; +/** + * @beta + */ +export const TicksPerDay = 24000; +/** + * @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;