├── LICENSE ├── README.md ├── guides ├── EN.md └── ES.md ├── manifest.json ├── node_modules └── @minecraft │ ├── server-gametest │ ├── README.md │ ├── index.d.ts │ ├── node_modules │ │ └── @minecraft │ │ │ └── server │ │ │ ├── README.md │ │ │ ├── index.d.ts │ │ │ ├── package.json │ │ │ ├── tests.ts │ │ │ └── tsconfig.json │ ├── package.json │ ├── tests.ts │ └── tsconfig.json │ └── server │ ├── README.md │ ├── index.d.ts │ ├── package.json │ ├── tests.ts │ └── tsconfig.json ├── pack_icon.png ├── package.json ├── scripts ├── main.js └── src │ ├── data.js │ └── players.js └── structures └── FP └── Server.mcstructure /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 AlecsDeveloper 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > [!NOTE] 2 | > Guides: [Español](/guides/ES.md) **/** [English](/guides/EN.md) **/** [Video](https://youtu.be/FMnSQ2R94PI) 3 | 4 | > [!IMPORTANT] 5 | > **Experimental Modes:** 6 | > - Beta APIs 7 | > 8 | > **Gamerules Fixer** 9 | > - Download and use this pack to fix the gamerules issues: 10 | > [Download here](https://cdn.discordapp.com/attachments/1208481601676382351/1208850823442858044/Gamerules_1.19.mcpack?ex=67b18d4f&is=67b03bcf&hm=c87fe4096271a71e7f3ee44d5c3a880cb698d9e9a602d1a9d51689bf99ca6607&) 11 | 12 | --- 13 | 14 | > [!TIP] 15 | > # Fakeplayer Rework 16 | > Use `#fakeplayer --help` to see the guide 17 | > - [1.21.60+](https://www.curseforge.com/minecraft-bedrock/scripts/fakeplayer/download/6183099) 18 | > - [1.21.50](https://www.curseforge.com/minecraft-bedrock/scripts/fakeplayer/download/5969210) 19 | > - [1.21.40](https://www.curseforge.com/minecraft-bedrock/scripts/fakeplayer/download/5852156) 20 | > - [1.21.20](https://www.curseforge.com/minecraft-bedrock/scripts/fakeplayer/download/5626237) 21 | > - [1.21 - 1.21.2](https://www.curseforge.com/minecraft-bedrock/scripts/fakeplayer/download/5441504) 22 | > - [1.20.80 - 1.20.81](https://www.curseforge.com/minecraft-bedrock/scripts/fakeplayer/download/5393806) 23 | 24 | > [!WARNING] 25 | > # Fakeplayer 26 | > - [1.20.70](https://www.mediafire.com/file/ux4aqssczlwl9cu/Fakeplayer_1.20.70.mcpack/file) 27 | > - [1.20.60](https://www.mediafire.com/file/6szquispqc3hc9t/Fakeplayer_1.20.60.mcpack/file) 28 | > - [1.20.50 - 1.20.51](https://www.mediafire.com/file/3zh0lpzczgb62st/Fakeplayer_1.20.50.mcpack/file) 29 | > - [1.20.40 - 1.20.41](https://www.mediafire.com/file/p38nnpzv92xt745/Fakeplayer_1.20.40.mcpack/file) 30 | > - [1.20.30](https://www.mediafire.com/file/i674gb2jixfbgw6/Fakeplayer_1.20.30.mcpack/file) 31 | > - [1.20.10 - 1.20.15](https://www.mediafire.com/file/90orvm8v9rop1pj/Fakeplayer_1.20.10.mcpack/file) 32 | > - [1.20 - 1.20.1](https://www.mediafire.com/file/z9xtd8f1ez7yiyp/Fakeplayer_1.20.mcpack/file) 33 | > - [1.19.80 - 1.19.83](https://www.mediafire.com/file/qsf0xswv7duzgi3/Fakeplayer_1.19.80.mcpack/file) 34 | > - [1.19.70 - 1.19.73](https://www.mediafire.com/file/7ppkbmo1kijz3ys/Fakeplayer+1.19.70.mcpack/file) 35 | > - [1.19.50 - 1.19.63](https://www.mediafire.com/download/n6yr81m6z0r4392) 36 | 37 | --- 38 | > [!NOTE] 39 | > ## Developed by Alecs. 40 | > ### [Discord Server](https://discord.gg/96Uyt3KWT5) **-** [YT Channel](https://www.youtube.com/@yosoyalexD) 41 | --- 42 | -------------------------------------------------------------------------------- /guides/EN.md: -------------------------------------------------------------------------------- 1 | # English Guide 2 | --- 3 | ## Introduction 4 | 5 | ## What is? 6 | `Fakeplayers Addon` is a tool capable of providing the ability to generate players using commands and methods. 7 | 8 | ## What is for it? 9 | By being able to generate these players, they will obtain `almost` all the capabilities of a normal player (like you) among these capabilities are: 10 | 11 | | Capabilities | Can? | 12 | | ----------- | :------: | 13 | | Load Terrain | ✅ | 14 | | Generate Mobs | ✅ | 15 | | Perform Actions | ✅ | 16 | 17 | ## [Download](https://www.mediafire.com/file/ux4aqssczlwl9cu/Fakeplayer_1.20.70.mcpack/file) 18 | --- 19 | ## Commands guide 20 | 21 | Prefix: `./player`
22 | Reserved method: `server` 23 | 24 |
25 | 26 | ## Basic commands 27 | `./player spawn `
28 | It generates a player, it can have an optional value after the `spawn` method, this can be survival or creative, in case of not being entered any, survival will be placed by default. 29 | 30 | `./player kill`
31 | Kick the player entered in the `username` parameter. 32 | 33 | `./player respawn`
34 | Respawn the dead player. 35 | 36 | `./player tp`
37 | Teleport the entered player to your position. 38 | 39 |
40 | 41 | ## Action commands 42 | `./player jump`
43 | Causes the entered player to perform a jump. 44 | 45 | `./player attack`
46 | Causes the entered player to perform a attack. 47 | 48 | `./player use <0-9>`
49 | It makes the player select and use the slot element entered in the parameter `0-9`, if it is not a value between 0 and 9, slot 0 will be used by default, this command can also be used to select a slot. 50 | 51 | `./player interact`
52 | It makes the player interact with what he has in front of him, he will use the item he has in his hand, to select a slot you can use the command `use` mentioned above. 53 | 54 |
55 | 56 | ## Advanced commands 57 | `./player repeat `
58 | It makes the player repeat a certain action, such actions can be accumulated, that is, the player can perform 2, 3 or more actions at the same time. 59 | 60 | `./player stop`
61 | It makes the player finish repeating the previously set actions. 62 | 63 | `./player rotate <0-360>`
64 | It allows to rotate the body of the player according to the degrees entered in the parameter `<0-360>`, in case of not being any value entered, it will be set by default in `20`. 65 | 66 |
67 | 68 | ## Server commands 69 | `./player server ?`
70 | Displays information about server methods. 71 | 72 | `./player server reload`
73 | Reload the entire fakeplayer server. 74 | 75 | `./player server cls/clear`
76 | Clean up the user's chat. 77 | -------------------------------------------------------------------------------- /guides/ES.md: -------------------------------------------------------------------------------- 1 | # Guía en Español 2 | --- 3 | ## Introducción 4 | 5 | ## ¿Qué es? 6 | `Fakeplayers Addon` es una herramienta capaz de proporcionar la capacidad de generar jugadores mediante comandos y metodos. 7 | 8 | ## ¿Para que sirve? 9 | Al poder generar dichos jugadores, estos obtendran `casi` todas las capacidades de un jugador normal (cómo tú) entre dichas capacidades se encuentran: 10 | 11 | | Capacidades | Puede? | 12 | | ----------- | :------: | 13 | | Cargar Terreno | ✅ | 14 | | Generar Mobs | ✅ | 15 | | Realizar Acciones | ✅ | 16 | 17 | ## [Descarga](https://www.mediafire.com/file/ux4aqssczlwl9cu/Fakeplayer_1.20.70.mcpack/file) 18 | 19 | --- 20 | ## Guía de comandos 21 | 22 | Prefix: `./player`
23 | Metodo reservado: `server` 24 | 25 |
26 | 27 | ## Comandos basicos 28 | `./player spawn `
29 | Genera un jugador, puede tener un valor opcional despues del metodo `spawn`, este puede ser survival o creative, en caso de no ser ingresado ninguno, se colocara survival por defecto. 30 | 31 | `./player kill`
32 | Expulsa al jugador ingresado en el parametro `username`. 33 | 34 | `./player respawn`
35 | Respawnea un jugador muerto. 36 | 37 | `./player tp`
38 | Teletransporta el jugador ingresado hacía tu posición. 39 | 40 |
41 | 42 | ## Comandos de acciones 43 | `./player jump`
44 | Hace que el jugador ingresado realize un salto. 45 | 46 | `./player attack`
47 | Hace que el jugador ingresado realize un ataque. 48 | 49 | `./player use <0-9>`
50 | Hace que el jugador seleccione y use el elemento del slot ingresado en el parametro `0-9`, de no ser un valor entre el 0 y 9, se usara por defecto el slot 0, este comando tambien puede ser utilizado para seleccionar un slot. 51 | 52 | `./player interact`
53 | Hace que el jugador interactue con lo que tiene delante de el, usara el item que tenga en la mano, para seleccionar un slot se puede usar el comando `use` mencionado anteriormente. 54 | 55 |
56 | 57 | ## Comandos avanzados 58 | `./player repeat `
59 | Hace que el jugador repita una accion determinada, dichas acciones pueden ser acumuladas, es decir, el jugador puede realizar 2, 3 o más acciones al mismo tiempo. 60 | 61 | `./player stop`
62 | Hace que el jugador termine de repetir las acciones anteriormente establecidas. 63 | 64 | `./player rotate <0-360>`
65 | Permite rotar el cuerpo del jugador conforme a los grados ingresados en el parametro `<0-360>`, en caso dde no ser ningun valor ingresado, se establecera por defecto en `20`. 66 | 67 |
68 | 69 | ## Comandos del servidor 70 | `./player server ?`
71 | Muestra la información sobre los metodos del servidor. 72 | 73 | `./player server reload`
74 | Recarga todo el servidor de fakeplayer. 75 | 76 | `./player server cls/clear`
77 | Limpia el chat del usuario. 78 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "format_version": 2, 3 | "header": { 4 | "name": "§3Fakeplayers Addon", 5 | "description": "§2Developed by Alecs", 6 | "uuid": "665ba90f-d392-4a64-9ffd-078bbf093e98", 7 | "min_engine_version": [1, 19, 50], 8 | "version": [1, 0, 0] 9 | }, 10 | "modules": [ 11 | { 12 | "description": "Behavior Pack Module", 13 | "type": "data", 14 | "uuid": "b64b1f4d-4ef8-4567-9983-983c736e8ec4", 15 | "version": [1, 0, 0] 16 | }, 17 | { 18 | "description": "Gametest Module", 19 | "type": "script", 20 | "language": "javascript", 21 | "entry": "scripts/main.js", 22 | "uuid": "49909301-b772-4234-be84-186f24d24364", 23 | "version": [1, 0, 0] 24 | } 25 | ], 26 | "dependencies": [ 27 | { 28 | "module_name": "@minecraft/server", 29 | "version": "1.1.0-beta" 30 | }, 31 | { 32 | "module_name": "@minecraft/server-gametest", 33 | "version": "1.0.0-beta" 34 | } 35 | ] 36 | } 37 | -------------------------------------------------------------------------------- /node_modules/@minecraft/server-gametest/README.md: -------------------------------------------------------------------------------- 1 | # `@minecraft/server-gametest` 2 | 3 | The @minecraft/server-gametest module provides scriptable APIs for scaffolding and testing content experiences in Minecraft. 4 | 5 | ## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.** 6 | 7 | See full documentation for this module here: 8 | 9 | https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/@minecraft/server-gametest/@minecraft/server-gametest -------------------------------------------------------------------------------- /node_modules/@minecraft/server-gametest/index.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for Minecraft Bedrock Edition script APIs 2 | // Project: https://docs.microsoft.com/minecraft/creator/ 3 | // Definitions by: Jake Shirley 4 | // Mike Ammerlaan 5 | 6 | /* ***************************************************************************** 7 | Copyright (c) Microsoft Corporation. 8 | ***************************************************************************** */ 9 | /** 10 | * @packageDocumentation 11 | * The @minecraft/server-gametest module provides scriptable 12 | * APIs for scaffolding and testing content experiences in 13 | * Minecraft. 14 | * 15 | * Manifest Details 16 | * ```json 17 | * { 18 | * "module_name": "@minecraft/server-gametest", 19 | * "version": "1.0.0-internal.11940b24" 20 | * } 21 | * ``` 22 | * 23 | */ 24 | import * as minecraftserver from '@minecraft/server'; 25 | /** 26 | * Returns information about whether this fence is connected to 27 | * other fences in several directions. 28 | */ 29 | export class FenceConnectivity { 30 | /** 31 | * Represents whether this fence block is connected to another 32 | * fence to the east (x + 1). 33 | */ 34 | readonly east: boolean; 35 | /** 36 | * Represents whether this fence block is connected to another 37 | * fence to the north (z - 1). 38 | */ 39 | readonly north: boolean; 40 | /** 41 | * Represents whether this fence block is connected to another 42 | * fence to the south (z + 1). 43 | */ 44 | readonly south: boolean; 45 | /** 46 | * Represents whether this fence block is connected to another 47 | * fence to the west (x - 1). 48 | */ 49 | readonly west: boolean; 50 | protected constructor(); 51 | } 52 | /** 53 | * Executes a set of steps defined via chained .thenXyz 54 | * methods, sequentially. This facilitates a 'script' of 55 | * GameTest setup methods and assertions over time. 56 | */ 57 | export class GameTestSequence { 58 | /** 59 | * @remarks 60 | * Runs the given callback as a step within a GameTest 61 | * sequence. Exceptions thrown within the callback will end 62 | * sequence execution. 63 | * @param callback 64 | * Callback function to execute. 65 | * @returns 66 | * Returns a GameTestSequence object where additional .thenXyz 67 | * method steps can be added. 68 | */ 69 | thenExecute(callback: () => void): GameTestSequence; 70 | /** 71 | * @remarks 72 | * After a delay, runs the given callback as a step within a 73 | * GameTest sequence. Exceptions thrown within the callback 74 | * will end sequence execution. 75 | * @param delayTicks 76 | * Number of ticks to wait before executing the callback. 77 | * @param callback 78 | * Callback function to execute. 79 | * @returns 80 | * Returns a GameTestSequence object where additional .thenXyz 81 | * method steps can be added. 82 | */ 83 | thenExecuteAfter(delayTicks: number, callback: () => void): GameTestSequence; 84 | /** 85 | * @remarks 86 | * Runs the given callback every tick for the given number of 87 | * ticks. 88 | * @param tickCount 89 | * @param callback 90 | * Callback function to execute. 91 | * @returns 92 | * Returns a GameTestSequence object where additional .thenXyz 93 | * method steps can be added. 94 | */ 95 | thenExecuteFor(tickCount: number, callback: () => void): GameTestSequence; 96 | /** 97 | * @remarks 98 | * Causes the test to fail if this step in the GameTest 99 | * sequence is reached. 100 | * @param errorMessage 101 | * Error message summarizing the failure condition. 102 | */ 103 | thenFail(errorMessage: string): void; 104 | /** 105 | * @remarks 106 | * Idles the GameTest sequence for the specified delayTicks. 107 | * @param delayTicks 108 | * Number of ticks to delay for this step in the GameTest 109 | * sequence. 110 | * @returns 111 | * Returns a GameTestSequence object where additional .thenXyz 112 | * method steps can be added. 113 | */ 114 | thenIdle(delayTicks: number): GameTestSequence; 115 | /** 116 | * @remarks 117 | * Marks the GameTest a success if this step is reached in the 118 | * GameTest sequence. 119 | */ 120 | thenSucceed(): void; 121 | /** 122 | * @remarks 123 | * Executes the given callback every tick until it succeeds. 124 | * Exceptions thrown within the callback will end sequence 125 | * execution. 126 | * @param callback 127 | * Testing callback function to execute. Typically, this 128 | * function will have .assertXyz functions within it. 129 | * @returns 130 | * Returns a GameTestSequence object where additional .thenXyz 131 | * method steps can be added. 132 | */ 133 | thenWait(callback: () => void): GameTestSequence; 134 | /** 135 | * @remarks 136 | * After a delay from the previous step, executes the given 137 | * callback every tick until it succeeds. Exceptions thrown 138 | * within the callback will end sequence execution. 139 | * @param delayTicks 140 | * Tick (after the previous step in the GameTest sequence) to 141 | * run the callback at. 142 | * @param callback 143 | * Testing callback function to execute. Typically, this 144 | * function will have .assertXyz functions within it. 145 | * @returns 146 | * Returns a GameTestSequence object where additional .thenXyz 147 | * method steps can be added. 148 | */ 149 | thenWaitAfter(delayTicks: number, callback: () => void): GameTestSequence; 150 | protected constructor(); 151 | } 152 | /** 153 | * A utility class to set GameTest parameters for a test. 154 | * Methods can be chained together to set multiple properties. 155 | */ 156 | export class RegistrationBuilder { 157 | /** 158 | * @remarks 159 | * Sets the batch for the test to run in. 160 | * @param batchName 161 | * Name of the batch for the test. 162 | * @returns 163 | * RegistrationBuilder object where additional configuration 164 | * methods can be called. 165 | */ 166 | batch(batchName: 'night' | 'day'): RegistrationBuilder; 167 | /** 168 | * @remarks 169 | * Sets the maximum number of times a test will try to rerun if 170 | * it fails. 171 | * @param attemptCount 172 | * @returns 173 | * RegistrationBuilder object where additional configuration 174 | * methods can be called. 175 | */ 176 | maxAttempts(attemptCount: number): RegistrationBuilder; 177 | /** 178 | * @remarks 179 | * Sets the maximum number of ticks a test will run for before 180 | * timing out and failing. 181 | * @param tickCount 182 | * @returns 183 | * RegistrationBuilder object where additional configuration 184 | * methods can be called. 185 | */ 186 | maxTicks(tickCount: number): RegistrationBuilder; 187 | /** 188 | * @remarks 189 | * Size around the GameTest, in blocks, that should be reserved 190 | * for the test when running multiple tests together. 191 | * @param paddingBlocks 192 | * Size, in blocks, around the GameTest where additional 193 | * GameTests should not be created. 194 | * @returns 195 | * RegistrationBuilder object where additional configuration 196 | * methods can be called. 197 | */ 198 | padding(paddingBlocks: number): RegistrationBuilder; 199 | /** 200 | * @remarks 201 | * Whether this test is required to pass as part of its broader 202 | * set of tests. 203 | * @param isRequired 204 | * If set to true, the test must pass in order for the entire 205 | * run of tests to pass. 206 | * @returns 207 | * RegistrationBuilder object where additional configuration 208 | * methods can be called. 209 | */ 210 | required(isRequired: boolean): RegistrationBuilder; 211 | /** 212 | * @remarks 213 | * Sets the number of successful test runs to be considered 214 | * successful. 215 | * @param attemptCount 216 | * @returns 217 | * RegistrationBuilder object where additional configuration 218 | * methods can be called. 219 | */ 220 | requiredSuccessfulAttempts(attemptCount: number): RegistrationBuilder; 221 | /** 222 | * @remarks 223 | * If true, runs the test in all four rotations when run via 224 | * /gametest runset. 225 | * @param rotate 226 | */ 227 | rotateTest(rotate: boolean): RegistrationBuilder; 228 | /** 229 | * @remarks 230 | * Sets the number of ticks for a test to wait before executing 231 | * when the structure is spawned. 232 | * @param tickCount 233 | * @returns 234 | * RegistrationBuilder object where additional configuration 235 | * methods can be called. 236 | */ 237 | setupTicks(tickCount: number): RegistrationBuilder; 238 | /** 239 | * @remarks 240 | * Sets the name of the structure for a test to use. "xyz:bar" 241 | * will load `/structures/xyz/bar.mcstructure` from the 242 | * behavior pack stack. 243 | * @param structureName 244 | * @returns 245 | * RegistrationBuilder object where additional configuration 246 | * methods can be called. 247 | */ 248 | structureName(structureName: string): RegistrationBuilder; 249 | /** 250 | * @remarks 251 | * Adds a tag to a test. You can run all tests with a given tag 252 | * with `/gametest runset `. 253 | * @param tag 254 | * @returns 255 | * RegistrationBuilder object where additional configuration 256 | * methods can be called. 257 | */ 258 | tag(tag: string): RegistrationBuilder; 259 | protected constructor(); 260 | } 261 | /** 262 | * Implements a class that can be used for testing sculk 263 | * spreading behaviors. This sculk spreader class can drive the 264 | * growth of sculk around a particular block. 265 | */ 266 | export class SculkSpreader { 267 | /** 268 | * Gets the maximum charge of a sculk spreader. 269 | * @throws This property can throw when used. 270 | */ 271 | readonly maxCharge: number; 272 | /** 273 | * @remarks 274 | * Adds a cursor - which is a notional waypoint that the sculk 275 | * will spread in the direction of. 276 | * @param offset 277 | * @param charge 278 | */ 279 | addCursorsWithOffset(offset: minecraftserver.BlockLocation, charge: number): void; 280 | /** 281 | * @remarks 282 | * Retrieves the current position of the specified cursor. 283 | * @param index 284 | * @throws This function can throw errors. 285 | */ 286 | getCursorPosition(index: number): minecraftserver.BlockLocation; 287 | /** 288 | * @remarks 289 | * Returns a number of overall cursors for this sculk spreader. 290 | * @throws This function can throw errors. 291 | */ 292 | getNumberOfCursors(): number; 293 | /** 294 | * @remarks 295 | * Gets the total current charge of the sculk spreader. 296 | * @throws This function can throw errors. 297 | */ 298 | getTotalCharge(): number; 299 | protected constructor(); 300 | } 301 | /** 302 | * A simulated player can be used within GameTests to represent 303 | * how a player moves throughout the world and to support 304 | * testing of how entities and the environment will react to a 305 | * player. This type derives much of its structure and methods 306 | * from the {@link @minecraft/server.Player} type. 307 | */ 308 | export class SimulatedPlayer extends minecraftserver.Player { 309 | /** 310 | * Dimension that the simulated player is currently within. 311 | * @throws This property can throw when used. 312 | */ 313 | readonly dimension: minecraftserver.Dimension; 314 | /** 315 | * Location of the center of the head component of the player. 316 | * @throws This property can throw when used. 317 | */ 318 | readonly headLocation: minecraftserver.Location; 319 | /** 320 | * Rotation of the head across pitch and yaw angles. 321 | * @throws This property can throw when used. 322 | */ 323 | readonly headRotation: minecraftserver.XYRotation; 324 | /** 325 | * Unique identifier of the player. This identifier is intended 326 | * to be consistent across loads of a world instance. No 327 | * meaning should be inferred from the value and structure of 328 | * this unique identifier - do not parse or interpret it. 329 | * @throws This property can throw when used. 330 | */ 331 | readonly id: string; 332 | /** 333 | * True if the player is currently using a sneaking movement. 334 | */ 335 | isSneaking: boolean; 336 | /** 337 | * Current location of the player. 338 | * @throws This property can throw when used. 339 | */ 340 | readonly location: minecraftserver.Location; 341 | /** 342 | * Name of the player. 343 | * @throws This property can throw when used. 344 | */ 345 | readonly name: string; 346 | /** 347 | * Optional name tag of the player. 348 | */ 349 | nameTag: string; 350 | /** 351 | * Contains methods for manipulating the on-screen display of a 352 | * Player. 353 | */ 354 | readonly onScreenDisplay: minecraftserver.ScreenDisplay; 355 | /** 356 | * Main rotation of the entity. 357 | * @throws This property can throw when used. 358 | */ 359 | readonly rotation: minecraftserver.XYRotation; 360 | /** 361 | * Returns a scoreboard identity that represents this entity. 362 | * @throws This property can throw when used. 363 | */ 364 | readonly scoreboard: minecraftserver.ScoreboardIdentity; 365 | /** 366 | * Manages the selected slot in the player's hotbar. 367 | */ 368 | selectedSlot: number; 369 | /** 370 | * Retrieves or sets an entity that is used as the target of 371 | * AI-related behaviors, like attacking. 372 | * @throws This property can throw when used. 373 | */ 374 | readonly target: minecraftserver.Entity; 375 | /** 376 | * Unique identifier of the type of the entity - for example, 377 | * 'minecraft:player'. 378 | * @throws This property can throw when used. 379 | */ 380 | readonly typeId: string; 381 | /** 382 | * Current speed of the player across X, Y, and Z dimensions. 383 | * @throws This property can throw when used. 384 | */ 385 | readonly velocity: minecraftserver.Vector; 386 | /** 387 | * Vector of the current view of the player. 388 | * @throws This property can throw when used. 389 | */ 390 | readonly viewVector: minecraftserver.Vector; 391 | /** 392 | * @remarks 393 | * Adds an effect, like poison, to the entity. 394 | * @param effectType 395 | * Type of effect to add to the entity. 396 | * @param duration 397 | * Amount of time, in ticks, for the effect to apply. 398 | * @param amplifier 399 | * Optional amplification of the effect to apply. 400 | * @param showParticles 401 | * @throws This function can throw errors. 402 | */ 403 | addEffect( 404 | effectType: minecraftserver.EffectType, 405 | duration: number, 406 | amplifier?: number, 407 | showParticles?: boolean, 408 | ): void; 409 | addExperience(amount: number): boolean; 410 | /** 411 | * @remarks 412 | * Adds a specified tag to a simulated player. 413 | * @param tag 414 | * Content of the tag to add. 415 | * @throws This function can throw errors. 416 | */ 417 | addTag(tag: string): boolean; 418 | /** 419 | * @remarks 420 | * Causes the simulated player to make an attack 'swipe'. 421 | * Returns true if the attack was performed - for example, the 422 | * player was not on cooldown and had a valid target. Target 423 | * selection is performed by raycasting from the player's head. 424 | * @throws This function can throw errors. 425 | */ 426 | attack(): boolean; 427 | /** 428 | * @remarks 429 | * Causes the simulated player to attack the provided target. 430 | * Returns true if the attack was performed - for example, the 431 | * player was not on cooldown and had a valid target. The 432 | * attack can be performed at any distance and does not require 433 | * line of sight to the target entity. 434 | * @param entity 435 | * @throws This function can throw errors. 436 | */ 437 | attackEntity(entity: minecraftserver.Entity): boolean; 438 | /** 439 | * @remarks 440 | * Destroys the block at blockLocation, respecting the rules of 441 | * the server player's game mode. The block will be hit until 442 | * broken, an item is used or stopBreakingBlock is called. 443 | * Returns true if the block at blockLocation is solid. 444 | * @param blockLocation 445 | * Location of the block to interact with. 446 | * @param direction 447 | * Direction to place the specified item within. 448 | * @throws This function can throw errors. 449 | */ 450 | breakBlock(blockLocation: minecraftserver.BlockLocation, direction?: minecraftserver.Direction): boolean; 451 | /** 452 | * @remarks 453 | * Gets the first block that intersects with the vector of the 454 | * view of this entity. 455 | * @param options 456 | * Additional options for processing this raycast query. 457 | * @throws This function can throw errors. 458 | */ 459 | getBlockFromViewVector(options?: minecraftserver.BlockRaycastOptions): minecraftserver.Block; 460 | /** 461 | * @remarks 462 | * Gets a component (that represents additional capabilities) 463 | * for an entity. 464 | * @param componentId 465 | * The identifier of the component (e.g., 'minecraft:rideable') 466 | * to retrieve. If no namespace prefix is specified, 467 | * 'minecraft:' is assumed. If the component is not present on 468 | * the entity, undefined is returned. 469 | */ 470 | getComponent(componentId: string): minecraftserver.IEntityComponent; 471 | /** 472 | * @remarks 473 | * Returns all components that are both present on this entity 474 | * and supported by the API. 475 | */ 476 | getComponents(): minecraftserver.IEntityComponent[]; 477 | /** 478 | * @remarks 479 | * Returns a property value. 480 | * @param identifier 481 | * @returns 482 | * Returns the value for the property, or undefined if the 483 | * property has not been set. 484 | * @throws This function can throw errors. 485 | */ 486 | getDynamicProperty(identifier: string): boolean | number | string; 487 | /** 488 | * @remarks 489 | * Returns the effect for the specified EffectType on the 490 | * entity, or undefined if the effect is not present. 491 | * @param effectType 492 | * @returns 493 | * Effect object for the specified effect, or undefined if the 494 | * effect is not present. 495 | * @throws This function can throw errors. 496 | */ 497 | getEffect(effectType: minecraftserver.EffectType): minecraftserver.Effect; 498 | /** 499 | * @remarks 500 | * Gets the first entity that intersects with the vector of the 501 | * view of this entity. 502 | * @param options 503 | * Additional options for processing this raycast query. 504 | * @throws This function can throw errors. 505 | */ 506 | getEntitiesFromViewVector(options?: minecraftserver.EntityRaycastOptions): minecraftserver.Entity[]; 507 | /** 508 | * @remarks 509 | * Gets the current item cooldown time for a particular 510 | * cooldown category. 511 | * @param itemCategory 512 | * Specifies the cooldown category to retrieve the current 513 | * cooldown for. 514 | * @throws This function can throw errors. 515 | */ 516 | getItemCooldown(itemCategory: string): number; 517 | /** 518 | * @remarks 519 | * Returns all tags associated with this simulated player. 520 | * @throws This function can throw errors. 521 | */ 522 | getTags(): string[]; 523 | /** 524 | * @remarks 525 | * Gives the simulated player a particular item stack. 526 | * @param itemStack 527 | * Item to give. 528 | * @param selectSlot 529 | * Whether to set the selected slot once given. 530 | * @throws This function can throw errors. 531 | */ 532 | giveItem(itemStack: minecraftserver.ItemStack, selectSlot?: boolean): boolean; 533 | /** 534 | * @remarks 535 | * Returns true if the specified component is present on this 536 | * entity. 537 | * @param componentId 538 | * The identifier of the component (e.g., 'minecraft:rideable') 539 | * to retrieve. If no namespace prefix is specified, 540 | * 'minecraft:' is assumed. 541 | */ 542 | hasComponent(componentId: string): boolean; 543 | /** 544 | * @remarks 545 | * Tests whether a simulated player has a particular tag. 546 | * @param tag 547 | * Identifier of the tag to test for. 548 | * @throws This function can throw errors. 549 | */ 550 | hasTag(tag: string): boolean; 551 | /** 552 | * @remarks 553 | * Performs a raycast from the player’s head and interacts with 554 | * the first intersected block or entity. Returns true if the 555 | * interaction was successful. Maximum range is 6 blocks. 556 | * @throws This function can throw errors. 557 | */ 558 | interact(): boolean; 559 | /** 560 | * @remarks 561 | * Causes the simulated player to interact with a block. The 562 | * block at the specified block location must be solid. Returns 563 | * true if the interaction was performed. 564 | * @param blockLocation 565 | * Location of the block to interact with. 566 | * @param direction 567 | * Direction to place the specified item within. 568 | * @throws This function can throw errors. 569 | */ 570 | interactWithBlock(blockLocation: minecraftserver.BlockLocation, direction?: minecraftserver.Direction): boolean; 571 | /** 572 | * @remarks 573 | * Causes the simulated player to interact with a mob. Returns 574 | * true if the interaction was performed. 575 | * @param entity 576 | * Entity to interact with. 577 | * @throws This function can throw errors. 578 | */ 579 | interactWithEntity(entity: minecraftserver.Entity): boolean; 580 | /** 581 | * @remarks 582 | * Causes the simulated player to jump. 583 | * @returns 584 | * True if a jump was performed. 585 | * @throws This function can throw errors. 586 | */ 587 | jump(): boolean; 588 | /** 589 | * @remarks 590 | * Kills this entity. The entity will drop loot as normal. 591 | * @throws This function can throw errors. 592 | */ 593 | kill(): void; 594 | /** 595 | * @remarks 596 | * Rotates the simulated player's head/body to look at the 597 | * given block location. 598 | * @param blockLocation 599 | * @throws This function can throw errors. 600 | */ 601 | lookAtBlock(blockLocation: minecraftserver.BlockLocation): void; 602 | /** 603 | * @remarks 604 | * Rotates the simulated player's head/body to look at the 605 | * given entity. 606 | * @param entity 607 | * @throws This function can throw errors. 608 | */ 609 | lookAtEntity(entity: minecraftserver.Entity): void; 610 | /** 611 | * @remarks 612 | * Rotates the simulated player's head/body to look at the 613 | * given location. 614 | * @param location 615 | * @throws This function can throw errors. 616 | */ 617 | lookAtLocation(location: minecraftserver.Location): void; 618 | /** 619 | * @remarks 620 | * Orders the simulated player to walk in the given direction 621 | * relative to the GameTest. 622 | * @param westEast 623 | * @param northSouth 624 | * @param speed 625 | * @throws This function can throw errors. 626 | */ 627 | move(westEast: number, northSouth: number, speed?: number): void; 628 | /** 629 | * @remarks 630 | * Orders the simulated player to walk in the given direction 631 | * relative to the player's current rotation. 632 | * @param leftRight 633 | * @param backwardForward 634 | * @param speed 635 | * @throws This function can throw errors. 636 | */ 637 | moveRelative(leftRight: number, backwardForward: number, speed?: number): void; 638 | /** 639 | * @remarks 640 | * Orders the simulated player to move to the given block 641 | * location in a straight line. If a move or navigation is 642 | * already playing, this will override the last 643 | * move/navigation. 644 | * @param blockLocation 645 | * @param speed 646 | * @throws This function can throw errors. 647 | */ 648 | moveToBlock(blockLocation: minecraftserver.BlockLocation, speed?: number): void; 649 | /** 650 | * @remarks 651 | * Orders the simulated player to move to the given location in 652 | * a straight line. If a move or navigation is already playing, 653 | * this will override the last move/navigation. 654 | * @param location 655 | * @param speed 656 | * @throws This function can throw errors. 657 | */ 658 | moveToLocation(location: minecraftserver.Location, speed?: number): void; 659 | /** 660 | * @remarks 661 | * Orders the simulated player to move to a specific block 662 | * location using navigation. If a move or navigation is 663 | * already playing, this will override the last move/walk. Note 664 | * that if the simulated player gets stuck, that simulated 665 | * player will stop. The player must be touching the ground in 666 | * order to start navigation. 667 | * @param blockLocation 668 | * @param speed 669 | * @throws This function can throw errors. 670 | */ 671 | navigateToBlock(blockLocation: minecraftserver.BlockLocation, speed?: number): minecraftserver.NavigationResult; 672 | /** 673 | * @remarks 674 | * Will use navigation to follow the selected entity to within 675 | * a one block radius. If a move or navigation is already 676 | * playing, this will override the last move/navigation. 677 | * @param entity 678 | * @param speed 679 | * @throws This function can throw errors. 680 | */ 681 | navigateToEntity(entity: minecraftserver.Entity, speed?: number): minecraftserver.NavigationResult; 682 | /** 683 | * @remarks 684 | * Orders the simulated player to move to a specific location 685 | * using navigation. If a move or navigation is already 686 | * playing, this will override the last move/walk. Note that if 687 | * the simulated player gets stuck, that simulated player will 688 | * stop. The player must be touching the ground in order to 689 | * start navigation. 690 | * @param location 691 | * @param speed 692 | * @throws This function can throw errors. 693 | */ 694 | navigateToLocation(location: minecraftserver.Location, speed?: number): minecraftserver.NavigationResult; 695 | /** 696 | * @remarks 697 | * Use navigation to follow the route provided via the 698 | * locations parameter. If a move or navigation is already 699 | * playing, this will override the last move/navigation. 700 | * @param locations 701 | * A list of locations to use for routing. 702 | * @param speed 703 | * Net speed to use for doing the navigation. 704 | * @throws This function can throw errors. 705 | */ 706 | navigateToLocations(locations: minecraftserver.Location[], speed?: number): void; 707 | /** 708 | * @remarks 709 | * This method is inherited from Player, but is inoperative in 710 | * the case of a SimulatedPlayer. 711 | * @param soundID 712 | * Identifier of the sound to play. 713 | * @param soundOptions 714 | * Additional optional options for the sound. 715 | * @throws This function can throw errors. 716 | */ 717 | playSound(soundID: string, soundOptions?: minecraftserver.SoundOptions): void; 718 | postClientMessage(id: string, value: string): void; 719 | /** 720 | * @remarks 721 | * Removes a specified property. 722 | * @param identifier 723 | * @throws This function can throw errors. 724 | */ 725 | removeDynamicProperty(identifier: string): boolean; 726 | /** 727 | * @remarks 728 | * Removes a specified tag from a simulated player. 729 | * @param tag 730 | * Content of the tag to remove. 731 | * @throws This function can throw errors. 732 | */ 733 | removeTag(tag: string): boolean; 734 | /** 735 | * @remarks 736 | * Causes the simulated player to turn by the provided angle, 737 | * relative to the player's current rotation. 738 | * @param angleInDegrees 739 | * @throws This function can throw errors. 740 | */ 741 | rotateBody(angleInDegrees: number): void; 742 | /** 743 | * @remarks 744 | * Runs a particular command from the context of this simulated 745 | * player. 746 | * @param commandString 747 | * Command to run. Note that command strings should not start 748 | * with slash. 749 | * @returns 750 | * For commands that return data, returns a JSON structure with 751 | * command response values. 752 | * @throws This function can throw errors. 753 | * @example commands.js 754 | * ```typescript 755 | * player.runCommand("say You got a new high score!"); 756 | * player.runCommand("scoreboard players set @s score 10"); 757 | * 758 | * ``` 759 | */ 760 | runCommand(commandString: string): any; 761 | /** 762 | * @remarks 763 | * Runs a particular command asynchronously from the context of 764 | * this entity. Where possible, running a command 765 | * asynchronously is recommended, especially for long running 766 | * operations. 767 | * @param commandString 768 | * Command to run. Note that command strings should not start 769 | * with slash. 770 | * @returns 771 | * For commands that return data, returns a JSON structure with 772 | * command response values. 773 | * @throws This function can throw errors. 774 | */ 775 | runCommandAsync(commandString: string): Promise; 776 | sendTestSkin(geoData: string, base64ImageData: string, skinResourcePatch: string): void; 777 | /** 778 | * @remarks 779 | * Causes the simulated player to turn to face the provided 780 | * angle, relative to the GameTest. 781 | * @param angleInDegrees 782 | * @throws This function can throw errors. 783 | */ 784 | setBodyRotation(angleInDegrees: number): void; 785 | /** 786 | * @remarks 787 | * Sets a specified property to a value. 788 | * @param identifier 789 | * @param value 790 | * Data value of the property to set. 791 | * @throws This function can throw errors. 792 | */ 793 | setDynamicProperty(identifier: string, value: boolean | number | string): void; 794 | /** 795 | * @remarks 796 | * Sets the game mode that the simulated player is operating 797 | * under. 798 | * @param gameMode 799 | * Game mode to set. 800 | * @throws This function can throw errors. 801 | */ 802 | setGameMode(gameMode: minecraftserver.GameMode): void; 803 | /** 804 | * @remarks 805 | * Sets a particular item for the simulated player. 806 | * @param itemStack 807 | * Item to set. 808 | * @param slot 809 | * Slot to place the given item in. 810 | * @param selectSlot 811 | * Whether to set the selected slot once set. 812 | * @throws This function can throw errors. 813 | */ 814 | setItem(itemStack: minecraftserver.ItemStack, slot: number, selectSlot?: boolean): boolean; 815 | /** 816 | * @remarks 817 | * Sets the main rotation of the entity. 818 | * @param degreesX 819 | * @param degreesY 820 | * @throws This function can throw errors. 821 | */ 822 | setRotation(degreesX: number, degreesY: number): void; 823 | /** 824 | * @remarks 825 | * Sets a velocity for the entity to move with. 826 | * @param velocity 827 | * X/Y/Z components of the velocity. 828 | * @throws This function can throw errors. 829 | */ 830 | setVelocity(velocity: minecraftserver.IVec3): void; 831 | /** 832 | * @remarks 833 | * Sets the item cooldown time for a particular cooldown 834 | * category. 835 | * @param itemCategory 836 | * Specifies the cooldown category to retrieve the current 837 | * cooldown for. 838 | * @param tickDuration 839 | * Duration in ticks of the item cooldown. 840 | * @throws This function can throw errors. 841 | */ 842 | startItemCooldown(itemCategory: string, tickDuration: number): void; 843 | /** 844 | * @remarks 845 | * Stops destroying the block that is currently being hit. 846 | * @throws This function can throw errors. 847 | */ 848 | stopBreakingBlock(): void; 849 | /** 850 | * @remarks 851 | * Stops interacting with entities or blocks. 852 | * @throws This function can throw errors. 853 | */ 854 | stopInteracting(): void; 855 | /** 856 | * @remarks 857 | * Stops moving/walking/following if the simulated player is 858 | * moving. 859 | * @throws This function can throw errors. 860 | */ 861 | stopMoving(): void; 862 | /** 863 | * @remarks 864 | * Stops using the currently active item. 865 | * @throws This function can throw errors. 866 | */ 867 | stopUsingItem(): void; 868 | /** 869 | * @remarks 870 | * Teleports the selected player to a new location 871 | * @param location 872 | * New location for the player. 873 | * @param dimension 874 | * Dimension to move the selected player to. 875 | * @param xRotation 876 | * X rotation of the player after teleportation. 877 | * @param yRotation 878 | * Y rotation of the player after teleportation. 879 | * @param keepVelocity 880 | * @throws This function can throw errors. 881 | */ 882 | teleport( 883 | location: minecraftserver.IVec3, 884 | dimension: minecraftserver.Dimension, 885 | xRotation: number, 886 | yRotation: number, 887 | keepVelocity?: boolean, 888 | ): void; 889 | /** 890 | * @remarks 891 | * Teleports the selected player to a new location, and will 892 | * have the player facing a specified location. 893 | * @param location 894 | * New location for the player. 895 | * @param dimension 896 | * Dimension to move the selected player to. 897 | * @param facingLocation 898 | * Location that this player will be facing. 899 | * @param keepVelocity 900 | * @throws This function can throw errors. 901 | */ 902 | teleportFacing( 903 | location: minecraftserver.IVec3, 904 | dimension: minecraftserver.Dimension, 905 | facingLocation: minecraftserver.IVec3, 906 | keepVelocity?: boolean, 907 | ): void; 908 | /** 909 | * @remarks 910 | * For simulated players, this API is effectively a no-op as 911 | * simulated players do not have a connected client. 912 | * @param message 913 | * @throws This function can throw errors. 914 | */ 915 | tell(message: minecraftserver.IRawMessage | string): void; 916 | /** 917 | * @remarks 918 | * Triggers an entity type event. For every entity, a number of 919 | * events are defined in an entities' definition for key entity 920 | * behaviors; for example, creepers have a 921 | * minecraft:start_exploding type event. 922 | * @param eventName 923 | * Name of the entity type event to trigger. If a namespace is 924 | * not specified, minecraft: is assumed. 925 | * @throws This function can throw errors. 926 | */ 927 | triggerEvent(eventName: string): void; 928 | /** 929 | * @remarks 930 | * Causes the simulated player to use an item. Does not consume 931 | * the item. Returns false if the item is on cooldown. 932 | * @param itemStack 933 | * Item to use. 934 | * @throws This function can throw errors. 935 | */ 936 | useItem(itemStack: minecraftserver.ItemStack): boolean; 937 | /** 938 | * @remarks 939 | * Causes the simulated player to hold and use an item in their 940 | * inventory. 941 | * @param slot 942 | * Index of the inventory slot. 943 | * @throws This function can throw errors. 944 | */ 945 | useItemInSlot(slot: number): boolean; 946 | /** 947 | * @remarks 948 | * Causes the simulated player to use an item in their 949 | * inventory on a block. The block at the specified block 950 | * location must be solid. Returns true if the item was used. 951 | * @param slot 952 | * Index of the slot to use. 953 | * @param blockLocation 954 | * Location to use the item upon. 955 | * @param direction 956 | * Direction to place the specified item within. 957 | * @param faceLocationX 958 | * Block-face-relative X position where to place the item. 959 | * @param faceLocationY 960 | * Block-face-relative Y position where to place the item. 961 | * @throws This function can throw errors. 962 | */ 963 | useItemInSlotOnBlock( 964 | slot: number, 965 | blockLocation: minecraftserver.BlockLocation, 966 | direction?: minecraftserver.Direction, 967 | faceLocationX?: number, 968 | faceLocationY?: number, 969 | ): boolean; 970 | /** 971 | * @remarks 972 | * Causes the simulated player to use an item on a block. The 973 | * block at the specified block location must be solid. Returns 974 | * true if the item was used. 975 | * @param itemStack 976 | * Item to use. 977 | * @param blockLocation 978 | * Location to use the item upon. 979 | * @param direction 980 | * Direction to place the specified item within. 981 | * @param faceLocationX 982 | * Block-face-relative X position where to place the item. 983 | * @param faceLocationY 984 | * Block-face-relative Y position where to place the item. 985 | * @throws This function can throw errors. 986 | */ 987 | useItemOnBlock( 988 | itemStack: minecraftserver.ItemStack, 989 | blockLocation: minecraftserver.BlockLocation, 990 | direction?: minecraftserver.Direction, 991 | faceLocationX?: number, 992 | faceLocationY?: number, 993 | ): boolean; 994 | protected constructor(); 995 | } 996 | /** 997 | * These well-known tags can be used to classify different 998 | * tests into suites to run. 999 | */ 1000 | // tslint:disable-next-line:no-unnecessary-class 1001 | export class Tags { 1002 | /** 1003 | * Indicates that the tagged test should be a part of all 1004 | * suites. 1005 | */ 1006 | static readonly suiteAll = 'suite:all'; 1007 | /** 1008 | * Indicates that the tagged test should be a part of an 1009 | * internal (debug) test suite. 1010 | */ 1011 | static readonly suiteDebug = 'suite:debug'; 1012 | /** 1013 | * Indicates that the tagged test should be a part of the 1014 | * default test suite. 1015 | */ 1016 | static readonly suiteDefault = 'suite:default'; 1017 | /** 1018 | * Indicates that the tagged test should be a part of a suite 1019 | * of disabled tests. 1020 | */ 1021 | static readonly suiteDisabled = 'suite:disabled'; 1022 | protected constructor(); 1023 | } 1024 | /** 1025 | * Main class for GameTest functions, with helpers and data for 1026 | * manipulating the respective test. Note that all methods of 1027 | * this class expect BlockLocations and Locations relative to 1028 | * the GameTest structure block. 1029 | */ 1030 | export class Test { 1031 | /** 1032 | * @remarks 1033 | * Tests that the condition specified in _condition_ is true. 1034 | * If not, an error with the specified _message_ is thrown. 1035 | * @param condition 1036 | * Expression of the condition to evaluate. 1037 | * @param message 1038 | * Message that is passed if the _condition_ does not evaluate 1039 | * to true. 1040 | * @throws This function can throw errors. 1041 | */ 1042 | assert(condition: boolean, message: string): void; 1043 | /** 1044 | * @remarks 1045 | * Tests that a block of the specified type is present at the 1046 | * specified location. If it is not, an exception is thrown. 1047 | * @param blockType 1048 | * Expected block type. 1049 | * @param blockLocation 1050 | * Location of the block to test at. 1051 | * @param isPresent 1052 | * If true, this function tests whether a block of the 1053 | * specified type is at the location. If false, tests that a 1054 | * block of the specified type is not present. 1055 | * @throws This function can throw errors. 1056 | */ 1057 | assertBlockPresent( 1058 | blockType: minecraftserver.BlockType, 1059 | blockLocation: minecraftserver.BlockLocation, 1060 | isPresent?: boolean, 1061 | ): void; 1062 | /** 1063 | * @remarks 1064 | * Tests that a block has a particular state value at the 1065 | * specified location. If it does not have that state value, an 1066 | * exception is thrown. 1067 | * @param blockLocation 1068 | * Location of the block to test at. 1069 | * @param callback 1070 | * Callback function that contains additional tests based on 1071 | * the block at the specified location. 1072 | * @throws This function can throw errors. 1073 | * @example testIfButtonNotPressed.js 1074 | * ```typescript 1075 | * test.assertBlockState(buttonPos, (block) => { 1076 | * return block.permutation.getProperty("button_pressed_bit") == 0; 1077 | * }); 1078 | * 1079 | * ``` 1080 | */ 1081 | assertBlockState( 1082 | blockLocation: minecraftserver.BlockLocation, 1083 | callback: (arg: minecraftserver.Block) => boolean, 1084 | ): void; 1085 | /** 1086 | * @remarks 1087 | * Tests that an entity can reach a particular location. 1088 | * Depending on the value of canReach, throws an exception if 1089 | * the condition is not met. 1090 | * @param mob 1091 | * Entity that you wish to test the location against. 1092 | * @param blockLocation 1093 | * Structure-relative location to test whether the specified 1094 | * mob can reach. 1095 | * @param canReach 1096 | * If true, tests whether the mob can reach the location. If 1097 | * false, tests whether the mob is not able to reach the 1098 | * location. 1099 | * @throws This function can throw errors. 1100 | */ 1101 | assertCanReachLocation( 1102 | mob: minecraftserver.Entity, 1103 | blockLocation: minecraftserver.BlockLocation, 1104 | canReach?: boolean, 1105 | ): void; 1106 | /** 1107 | * @remarks 1108 | * Tests that a container (e.g., a chest) at the specified 1109 | * location contains a specified of item stack. If not, an 1110 | * error is thrown. 1111 | * @param itemStack 1112 | * Represents the type of item to check for. The specified 1113 | * container must contain at least 1 item matching the item 1114 | * type defined in _itemStack_. 1115 | * @param blockLocation 1116 | * Location of the block with a container (for example, a 1117 | * chest) to test the contents of. 1118 | * @throws This function can throw errors. 1119 | */ 1120 | assertContainerContains(itemStack: minecraftserver.ItemStack, blockLocation: minecraftserver.BlockLocation): void; 1121 | /** 1122 | * @remarks 1123 | * Tests that a container (e.g., a chest) at the specified 1124 | * location is empty. If not, an error is thrown. 1125 | * @param blockLocation 1126 | * Location of the block with a container (for example, a 1127 | * chest) to test is empty of contents. 1128 | * @throws This function can throw errors. 1129 | */ 1130 | assertContainerEmpty(blockLocation: minecraftserver.BlockLocation): void; 1131 | /** 1132 | * @remarks 1133 | * Tests that an entity has a specific piece of armor equipped. 1134 | * If not, an error is thrown. 1135 | * @param entityTypeIdentifier 1136 | * Identifier of the entity to match (e.g., 1137 | * 'minecraft:skeleton'). 1138 | * @param armorSlot 1139 | * Container slot index to test. 1140 | * @param armorName 1141 | * Name of the armor to look for. 1142 | * @param armorData 1143 | * Data value integer to look for. 1144 | * @param blockLocation 1145 | * Location of the entity with armor to test for. 1146 | * @param hasArmor 1147 | * Whether or not the entity is expected to have the specified 1148 | * armor equipped. 1149 | * @throws This function can throw errors. 1150 | * @example horseArmorTest.js 1151 | * ```typescript 1152 | * test.assertEntityHasArmor("minecraft:horse", armorSlotTorso, "diamond_horse_armor", 0, horseLocation, true); 1153 | * 1154 | * ``` 1155 | */ 1156 | assertEntityHasArmor( 1157 | entityTypeIdentifier: string, 1158 | armorSlot: number, 1159 | armorName: string, 1160 | armorData: number, 1161 | blockLocation: minecraftserver.BlockLocation, 1162 | hasArmor?: boolean, 1163 | ): void; 1164 | /** 1165 | * @remarks 1166 | * Tests that an entity has a particular component. If not, an 1167 | * exception is thrown. 1168 | * @param entityTypeIdentifier 1169 | * Identifier of the specified entity (e.g., 1170 | * 'minecraft:skeleton'). If the namespace is not specified, 1171 | * 'minecraft:' is assumed. 1172 | * @param componentIdentifier 1173 | * Identifier of the component to check for. If the namespace 1174 | * is not specified, 'minecraft:' is assumed. 1175 | * @param blockLocation 1176 | * Location of the block with a container (for example, a 1177 | * chest.) 1178 | * @param hasComponent 1179 | * Determines whether to test that the component exists, or 1180 | * does not. 1181 | * @throws This function can throw errors. 1182 | * @example sheepShearedTest.js 1183 | * ```typescript 1184 | * test.assertEntityHasComponent("minecraft:sheep", "minecraft:is_sheared", entityLoc, false); 1185 | * 1186 | * ``` 1187 | */ 1188 | assertEntityHasComponent( 1189 | entityTypeIdentifier: string, 1190 | componentIdentifier: string, 1191 | blockLocation: minecraftserver.BlockLocation, 1192 | hasComponent?: boolean, 1193 | ): void; 1194 | /** 1195 | * @remarks 1196 | * Depending on the value for isPresent, tests that a 1197 | * particular entity is present or not present at the specified 1198 | * location. Depending on the value of isPresent, if the entity 1199 | * is found or not found, an error is thrown. 1200 | * @param entity 1201 | * Specific entity to test for. 1202 | * @param blockLocation 1203 | * Location of the entity to test for. 1204 | * @param isPresent 1205 | * Whether to test that an entity is present or not present at 1206 | * the specified location. 1207 | * @throws This function can throw errors. 1208 | */ 1209 | assertEntityInstancePresent( 1210 | entity: minecraftserver.Entity, 1211 | blockLocation: minecraftserver.BlockLocation, 1212 | isPresent?: boolean, 1213 | ): void; 1214 | /** 1215 | * @remarks 1216 | * Depending on the value of isPresent, tests for the presence 1217 | * or non-presence of entity of a specified type at a 1218 | * particular location. If the condition is not met, an 1219 | * exception is thrown. 1220 | * @param entityTypeIdentifier 1221 | * Type of entity to test for (e.g., 'minecraft:skeleton'). If 1222 | * an entity namespace is not specified, 'minecraft:' is 1223 | * assumed. 1224 | * @param blockLocation 1225 | * Location of the entity to test for. 1226 | * @param isPresent 1227 | * If true, this function tests whether an entity of the 1228 | * specified type is present. If false, tests that an entity of 1229 | * the specified type is not present. 1230 | * @throws This function can throw errors. 1231 | */ 1232 | assertEntityPresent( 1233 | entityTypeIdentifier: string, 1234 | blockLocation: minecraftserver.BlockLocation, 1235 | isPresent?: boolean, 1236 | ): void; 1237 | /** 1238 | * @remarks 1239 | * Tests that an entity of a specified type is present within 1240 | * the GameTest area. If not, an exception is thrown. 1241 | * @param entityTypeIdentifier 1242 | * Type of entity to test for (e.g., 'minecraft:skeleton'). If 1243 | * an entity namespace is not specified, 'minecraft:' is 1244 | * assumed. 1245 | * @param isPresent 1246 | * If true, this function tests whether an entity of the 1247 | * specified type is present in the GameTest area. If false, 1248 | * tests that an entity of the specified type is not present. 1249 | * @throws This function can throw errors. 1250 | * @example simpleMobTest.ts 1251 | * ```typescript 1252 | * gt.register("StarterTests", "simpleMobTest", (test: gt.Test) => { 1253 | * const attackerId = "fox"; 1254 | * const victimId = "chicken"; 1255 | * 1256 | * test.spawn(attackerId, new mc.BlockLocation(5, 2, 5)); 1257 | * test.spawn(victimId, new mc.BlockLocation(2, 2, 2)); 1258 | * 1259 | * test.assertEntityPresentInArea(victimId, true); 1260 | * 1261 | * test.succeedWhen(() => { 1262 | * test.assertEntityPresentInArea(victimId, false); 1263 | * }); 1264 | * }) 1265 | * .maxTicks(400) 1266 | * .structureName("gametests:mediumglass"); 1267 | * ``` 1268 | */ 1269 | assertEntityPresentInArea(entityTypeIdentifier: string, isPresent?: boolean): void; 1270 | /** 1271 | * @remarks 1272 | * Tests that an entity (e.g., a skeleton) at the specified 1273 | * location has a particular piece of data. If not, an error is 1274 | * thrown. 1275 | * @param blockLocation 1276 | * Location of the entity to look for. 1277 | * @param entityTypeIdentifier 1278 | * Identifier of the entity (e.g., 'minecraft:skeleton') to 1279 | * look for. Note if no namespace is specified, 'minecraft:' is 1280 | * assumed. 1281 | * @param callback 1282 | * Callback function where facets of the selected entity can be 1283 | * tested for. If this callback function returns false or no 1284 | * entity with the specified identifier is found, an exception 1285 | * is thrown. 1286 | * @throws This function can throw errors. 1287 | * @example villagerEffectTest.js 1288 | * ```typescript 1289 | * test.assertEntityState( 1290 | * villagerPos, 1291 | * "minecraft:villager_v2", 1292 | * (entity) => entity.getEffect(MinecraftEffectTypes.regeneration).duration > 120 1293 | * ); // At least 6 seconds remaining in the villagers' effect 1294 | * 1295 | * ``` 1296 | */ 1297 | assertEntityState( 1298 | blockLocation: minecraftserver.BlockLocation, 1299 | entityTypeIdentifier: string, 1300 | callback: (arg: minecraftserver.Entity) => boolean, 1301 | ): void; 1302 | /** 1303 | * @remarks 1304 | * Depending on the value of isTouching, tests that an entity 1305 | * of a specified type is touching or connected to another 1306 | * entity. If the condition is not met, an exception is thrown. 1307 | * @param entityTypeIdentifier 1308 | * Type of entity to test for (e.g., 'minecraft:skeleton'). If 1309 | * an entity namespace is not specified, 'minecraft:' is 1310 | * assumed. 1311 | * @param location 1312 | * Location of the entity to test for. 1313 | * @param isTouching 1314 | * If true, this function tests whether the entity is touching 1315 | * the specified location. If false, tests that an entity is 1316 | * not testing the specified location. 1317 | * @throws This function can throw errors. 1318 | */ 1319 | assertEntityTouching(entityTypeIdentifier: string, location: minecraftserver.Location, isTouching?: boolean): void; 1320 | /** 1321 | * @remarks 1322 | * Depending on the value of isWaterlogged, tests that a block 1323 | * at a location contains water. If the condition is not met, 1324 | * an error is thrown. Pure water blocks are not considered to 1325 | * be waterlogged. 1326 | * @param blockLocation 1327 | * Location of the block to test for. 1328 | * @param isWaterlogged 1329 | * Whether to test that the block at _position_ is expected to 1330 | * be waterlogged. 1331 | * @throws This function can throw errors. 1332 | */ 1333 | assertIsWaterlogged(blockLocation: minecraftserver.BlockLocation, isWaterlogged?: boolean): void; 1334 | /** 1335 | * @remarks 1336 | * Tests that items of a particular type and count are present 1337 | * within an area. If not, an error is thrown. 1338 | * @param itemType 1339 | * Type of item to look for. 1340 | * @param blockLocation 1341 | * Location to search around for the specified set of items. 1342 | * @param searchDistance 1343 | * Range, in blocks, to aggregate a count of items around. If 1344 | * 0, will only search the particular block at _position_. 1345 | * @param count 1346 | * Number of items, at minimum, to look and test for. 1347 | * @throws This function can throw errors. 1348 | * @example findFeathers.js 1349 | * ```typescript 1350 | * test.assertItemEntityCountIs(Items.feather, expectedFeatherLoc, 0, 1); 1351 | * 1352 | * ``` 1353 | */ 1354 | assertItemEntityCountIs( 1355 | itemType: minecraftserver.ItemType, 1356 | blockLocation: minecraftserver.BlockLocation, 1357 | searchDistance: number, 1358 | count: number, 1359 | ): void; 1360 | /** 1361 | * @remarks 1362 | * Depending on the value of isPresent, tests whether a 1363 | * particular item entity is present or not at a particular 1364 | * location. If the condition is not met, an exception is 1365 | * thrown. 1366 | * @param itemType 1367 | * Type of item to test for. 1368 | * @param blockLocation 1369 | * Location of the item entity to test for. 1370 | * @param searchDistance 1371 | * Radius in blocks to look for the item entity. 1372 | * @param isPresent 1373 | * If true, this function tests whether an item entity of the 1374 | * specified type is present. If false, tests that an item 1375 | * entity of the specified type is not present. 1376 | * @throws This function can throw errors. 1377 | */ 1378 | assertItemEntityPresent( 1379 | itemType: minecraftserver.ItemType, 1380 | blockLocation: minecraftserver.BlockLocation, 1381 | searchDistance: number, 1382 | isPresent?: boolean, 1383 | ): void; 1384 | /** 1385 | * @remarks 1386 | * Tests that Redstone power at a particular location matches a 1387 | * particular value. If not, an exception is thrown. 1388 | * @param blockLocation 1389 | * Location to test. 1390 | * @param power 1391 | * Expected power level. 1392 | * @throws This function can throw errors. 1393 | */ 1394 | assertRedstonePower(blockLocation: minecraftserver.BlockLocation, power: number): void; 1395 | destroyBlock(blockLocation: minecraftserver.BlockLocation, dropResources?: boolean): void; 1396 | /** 1397 | * @remarks 1398 | * Marks the current test as a failure case. 1399 | * @param errorMessage 1400 | * Error message summarizing the failure condition. 1401 | * @throws This function can throw errors. 1402 | */ 1403 | fail(errorMessage: string): void; 1404 | /** 1405 | * @remarks 1406 | * Runs the given callback. If the callback does not throw an 1407 | * exception, the test is marked as a failure. 1408 | * @param callback 1409 | * Callback function that runs. If the function runs 1410 | * successfully, the test is marked as a failure. Typically, 1411 | * this function will have .assertXyz method calls within it. 1412 | * @throws This function can throw errors. 1413 | */ 1414 | failIf(callback: () => void): void; 1415 | /** 1416 | * @remarks 1417 | * Gets a block at the specified block location. 1418 | * @param blockLocation 1419 | * Location of the block to retrieve. 1420 | * @throws This function can throw errors. 1421 | */ 1422 | getBlock(blockLocation: minecraftserver.BlockLocation): minecraftserver.Block; 1423 | /** 1424 | * @remarks 1425 | * Gets the dimension of this test. 1426 | * @throws This function can throw errors. 1427 | */ 1428 | getDimension(): minecraftserver.Dimension; 1429 | /** 1430 | * @remarks 1431 | * If the block at the specified block location is a fence, 1432 | * this returns a helper object with details on how a fence is 1433 | * connected. 1434 | * @param blockLocation 1435 | * Location of the block to retrieve. 1436 | * @throws This function can throw errors. 1437 | */ 1438 | getFenceConnectivity(blockLocation: minecraftserver.BlockLocation): FenceConnectivity; 1439 | /** 1440 | * @remarks 1441 | * Retrieves a sculk spreader object that can be used to 1442 | * control and manage how sculk grows from a block. 1443 | * @param blockLocation 1444 | * Location of the block to retrieve a sculk spreader from. 1445 | * @throws This function can throw errors. 1446 | */ 1447 | getSculkSpreader(blockLocation: minecraftserver.BlockLocation): SculkSpreader; 1448 | /** 1449 | * @remarks 1450 | * Returns the direction of the current test - see the {@link 1451 | * @minecraft/server.Direction} enum for more information on 1452 | * potential values (north, east, south, west - values 2-5). 1453 | */ 1454 | getTestDirection(): minecraftserver.Direction; 1455 | /** 1456 | * @remarks 1457 | * This asynchronous function will wait for the specified time 1458 | * in ticks before continuing execution. 1459 | * @param tickDelay 1460 | * Amount of time to wait, in ticks. 1461 | */ 1462 | idle(tickDelay: number): Promise; 1463 | /** 1464 | * @remarks 1465 | * Kills all entities within the GameTest structure. 1466 | * @throws This function can throw errors. 1467 | */ 1468 | killAllEntities(): void; 1469 | /** 1470 | * @remarks 1471 | * Presses a button at a block location. 1472 | * @param blockLocation 1473 | * Location to push the button at. 1474 | * @throws 1475 | * Will throw an error if a button is not present at the 1476 | * specified position. 1477 | */ 1478 | pressButton(blockLocation: minecraftserver.BlockLocation): void; 1479 | /** 1480 | * @remarks 1481 | * Displays the specified message to all players. 1482 | * @param text 1483 | * Message to display. 1484 | * @throws This function can throw errors. 1485 | */ 1486 | print(text: string): void; 1487 | /** 1488 | * @remarks 1489 | * Pulls a lever at a block location. 1490 | * @param blockLocation 1491 | * Location to pull the lever at. 1492 | * @throws 1493 | * Will throw an error if a lever is not present at the 1494 | * specified position. 1495 | */ 1496 | pullLever(blockLocation: minecraftserver.BlockLocation): void; 1497 | /** 1498 | * @remarks 1499 | * Sends a Redstone pulse at a particular location by creating 1500 | * a temporary Redstone block. 1501 | * @param blockLocation 1502 | * Location to pulse Redstone at. 1503 | * @param duration 1504 | * Number of ticks to pulse Redstone. 1505 | * @throws This function can throw errors. 1506 | */ 1507 | pulseRedstone(blockLocation: minecraftserver.BlockLocation, duration: number): void; 1508 | /** 1509 | * @remarks 1510 | * From a BlockLocation, returns a new BlockLocation with 1511 | * coordinates relative to the current GameTest structure 1512 | * block. For example, the relative coordinates for the block 1513 | * above the structure block are (0, 1, 0). Rotation of the 1514 | * GameTest structure is also taken into account. 1515 | * @param worldBlockLocation 1516 | * Absolute location in the world to convert to a relative 1517 | * location. 1518 | * @returns 1519 | * A location relative to the GameTest command block. 1520 | * @throws This function can throw errors. 1521 | */ 1522 | relativeBlockLocation(worldBlockLocation: minecraftserver.BlockLocation): minecraftserver.BlockLocation; 1523 | /** 1524 | * @remarks 1525 | * From a location, returns a new location with coordinates 1526 | * relative to the current GameTest structure block. For 1527 | * example, the relative coordinates for the block above the 1528 | * structure block are (0, 1, 0). Rotation of the GameTest 1529 | * structure is also taken into account. 1530 | * @param worldLocation 1531 | * Absolute location in the world to convert to a relative 1532 | * location. 1533 | * @returns 1534 | * A location relative to the GameTest command block. 1535 | * @throws This function can throw errors. 1536 | */ 1537 | relativeLocation(worldLocation: minecraftserver.Location): minecraftserver.Location; 1538 | /** 1539 | * @remarks 1540 | * Removes a simulated player from the world. 1541 | * @param simulatedPlayer 1542 | * Simulated player to remove. 1543 | */ 1544 | removeSimulatedPlayer(simulatedPlayer: SimulatedPlayer): void; 1545 | /** 1546 | * @remarks 1547 | * Returns a relative direction given the current rotation of 1548 | * the current test. Passing in Direction.south will return the 1549 | * test direction; Passing in Direction.north will return the 1550 | * opposite of the test direction, and so on. 1551 | * @param direction 1552 | * Direction to translate into a direction relative to the 1553 | * GameTest facing. Passing in Direction.south will return the 1554 | * test direction; Passing in Direction.north will return the 1555 | * opposite of the test direction, and so on. 1556 | * @throws This function can throw errors. 1557 | */ 1558 | rotateDirection(direction: minecraftserver.Direction): minecraftserver.Direction; 1559 | rotateVector(vector: minecraftserver.Vector): minecraftserver.Vector; 1560 | /** 1561 | * @remarks 1562 | * Runs a specific callback after a specified delay of ticks 1563 | * @param delayTicks 1564 | * Number of ticks to delay before running the specified 1565 | * callback. 1566 | * @param callback 1567 | * Callback function to execute. 1568 | * @throws This function can throw errors. 1569 | */ 1570 | runAfterDelay(delayTicks: number, callback: () => void): void; 1571 | /** 1572 | * @remarks 1573 | * Runs the given callback after a delay of _tick_ ticks from 1574 | * the start of the GameTest. 1575 | * @param tick 1576 | * Tick (after the start of the GameTest) to run the callback 1577 | * at. 1578 | * @param callback 1579 | * Callback function to execute. 1580 | * @throws This function can throw errors. 1581 | */ 1582 | runAtTickTime(tick: number, callback: () => void): void; 1583 | /** 1584 | * @remarks 1585 | * Sets a block to a particular configuration (a 1586 | * BlockPermutation) at the specified block location. 1587 | * @param blockData 1588 | * Permutation that contains the configuration data for a 1589 | * block. 1590 | * @param blockLocation 1591 | * Location of the block to set. 1592 | * @throws This function can throw errors. 1593 | */ 1594 | setBlockPermutation( 1595 | blockData: minecraftserver.BlockPermutation, 1596 | blockLocation: minecraftserver.BlockLocation, 1597 | ): void; 1598 | /** 1599 | * @remarks 1600 | * Sets a block to a particular type at the specified block 1601 | * location. 1602 | * @param blockType 1603 | * Type of block to set. 1604 | * @param blockLocation 1605 | * Location of the block to set. 1606 | * @throws This function can throw errors. 1607 | */ 1608 | setBlockType(blockType: minecraftserver.BlockType, blockLocation: minecraftserver.BlockLocation): void; 1609 | /** 1610 | * @remarks 1611 | * For blocks that are fluid containers - like a cauldron - 1612 | * changes the type of fluid within that container. 1613 | * @param location 1614 | * Location of the fluid container block. 1615 | * @param type 1616 | * Type of fluid to set. See {@link 1617 | * @minecraft/server-gametest.FluidType} for a list of values. 1618 | * @throws This function can throw errors. 1619 | */ 1620 | setFluidContainer(location: minecraftserver.BlockLocation, type: minecraftserver.FluidType): void; 1621 | /** 1622 | * @remarks 1623 | * Sets the fuse of an explodable entity. 1624 | * @param entity 1625 | * Entity that is explodable. 1626 | * @param fuseLength 1627 | * Length of time, in ticks, before the entity explodes. 1628 | * @throws This function can throw errors. 1629 | */ 1630 | setTntFuse(entity: minecraftserver.Entity, fuseLength: number): void; 1631 | /** 1632 | * @remarks 1633 | * Spawns an entity at a location. 1634 | * @param entityTypeIdentifier 1635 | * Type of entity to create. If no namespace is provided, 1636 | * 'minecraft:' is assumed. Note that an optional initial spawn 1637 | * event can be specified between less than/greater than signs 1638 | * (e.g., namespace:entityType). 1639 | * @param blockLocation 1640 | * @returns 1641 | * The spawned entity. If the entity cannot be spawned, returns 1642 | * undefined. 1643 | * @throws This function can throw errors. 1644 | * @example simpleMobTest.ts 1645 | * ```typescript 1646 | * gt.register("StarterTests", "simpleMobTest", (test: gt.Test) => { 1647 | * const attackerId = "fox"; 1648 | * const victimId = "chicken"; 1649 | * 1650 | * test.spawn(attackerId, new mc.BlockLocation(5, 2, 5)); 1651 | * test.spawn(victimId, new mc.BlockLocation(2, 2, 2)); 1652 | * 1653 | * test.assertEntityPresentInArea(victimId, true); 1654 | * 1655 | * test.succeedWhen(() => { 1656 | * test.assertEntityPresentInArea(victimId, false); 1657 | * }); 1658 | * }) 1659 | * .maxTicks(400) 1660 | * .structureName("gametests:mediumglass"); 1661 | * ``` 1662 | * @example spawnAdultPig.js 1663 | * ```typescript 1664 | * test.spawn("minecraft:pig", new BlockLocation(1, 2, 1)); 1665 | * 1666 | * ``` 1667 | */ 1668 | spawn(entityTypeIdentifier: string, blockLocation: minecraftserver.BlockLocation): minecraftserver.Entity; 1669 | /** 1670 | * @remarks 1671 | * Spawns an entity at a location. 1672 | * @param entityTypeIdentifier 1673 | * Type of entity to create. If no namespace is provided, 1674 | * 'minecraft:' is assumed. Note that an optional initial spawn 1675 | * event can be specified between less than/greater than signs 1676 | * (e.g., namespace:entityType). 1677 | * @param location 1678 | * @returns 1679 | * The spawned entity. If the entity cannot be spawned, returns 1680 | * undefined. 1681 | * @throws This function can throw errors. 1682 | * @example spawnAdultPig.js 1683 | * ```typescript 1684 | * test.spawn("minecraft:pig", new Location(1.5, 2, 1.5)); 1685 | * ``` 1686 | */ 1687 | spawnAtLocation(entityTypeIdentifier: string, location: minecraftserver.Location): minecraftserver.Entity; 1688 | /** 1689 | * @remarks 1690 | * Spawns an item entity at a specified location. 1691 | * @param itemStack 1692 | * ItemStack that describes the item entity to create. 1693 | * @param location 1694 | * Location to create the item entity at. 1695 | * @throws This function can throw errors. 1696 | * @example spawnEmeralds.js 1697 | * ```typescript 1698 | * const oneEmerald = new ItemStack(MinecraftItemTypes.emerald, 1, 0); 1699 | * const fiveEmeralds = new ItemStack(MinecraftItemTypes.emerald, 5, 0); 1700 | * 1701 | * test.spawnItem(oneEmerald, new Location(3.5, 3, 1.5)); 1702 | * test.spawnItem(fiveEmeralds, new Location(1.5, 3, 1.5)); 1703 | * 1704 | * ``` 1705 | */ 1706 | spawnItem(itemStack: minecraftserver.ItemStack, location: minecraftserver.Location): minecraftserver.Entity; 1707 | /** 1708 | * @remarks 1709 | * Creates a new simulated player within the world. 1710 | * @param blockLocation 1711 | * Location where to spawn the simulated player. 1712 | * @param name 1713 | * Name to give the new simulated player. 1714 | * @param gameMode 1715 | * @throws This function can throw errors. 1716 | */ 1717 | spawnSimulatedPlayer( 1718 | blockLocation: minecraftserver.BlockLocation, 1719 | name?: string, 1720 | gameMode?: minecraftserver.GameMode, 1721 | ): SimulatedPlayer; 1722 | /** 1723 | * @remarks 1724 | * Spawns an entity at a location without any AI behaviors. 1725 | * This method is frequently used in conjunction with methods 1726 | * like .walkTo to create predictable mob actions. 1727 | * @param entityTypeIdentifier 1728 | * @param blockLocation 1729 | * Location where the entity should be spawned. 1730 | * @throws This function can throw errors. 1731 | */ 1732 | spawnWithoutBehaviors( 1733 | entityTypeIdentifier: string, 1734 | blockLocation: minecraftserver.BlockLocation, 1735 | ): minecraftserver.Entity; 1736 | /** 1737 | * @remarks 1738 | * Spawns an entity at a location without any AI behaviors. 1739 | * This method is frequently used in conjunction with methods 1740 | * like .walkTo to create predictable mob actions. 1741 | * @param entityTypeIdentifier 1742 | * @param location 1743 | * Location where the entity should be spawned. 1744 | * @throws This function can throw errors. 1745 | */ 1746 | spawnWithoutBehaviorsAtLocation( 1747 | entityTypeIdentifier: string, 1748 | location: minecraftserver.Location, 1749 | ): minecraftserver.Entity; 1750 | /** 1751 | * @remarks 1752 | * Tests that a particular item entity is present at a 1753 | * particular location. If not, an exception is thrown. 1754 | * @param blockLocation 1755 | * BlockLocation containing a multiface block. 1756 | * @param fromFace 1757 | * Face to spread from. This face must already be set. 1758 | * @param direction 1759 | * Direction to spread. Use the Minecraft.Direction enum to 1760 | * specify a direction. 1761 | * @throws This function can throw errors. 1762 | * @example spreadFromFaceTowardDirection.js 1763 | * ```typescript 1764 | * test.spreadFromFaceTowardDirection(new BlockLocation(1, 2, 1), Direction.south, Direction.down); 1765 | * ``` 1766 | */ 1767 | spreadFromFaceTowardDirection( 1768 | blockLocation: minecraftserver.BlockLocation, 1769 | fromFace: minecraftserver.Direction, 1770 | direction: minecraftserver.Direction, 1771 | ): void; 1772 | /** 1773 | * @remarks 1774 | * Creates a new GameTestSequence - A set of steps that play 1775 | * out sequentially within a GameTest. 1776 | * @returns 1777 | * A new GameTestSequence with chaining methods that facilitate 1778 | * creating a set of steps. 1779 | */ 1780 | startSequence(): GameTestSequence; 1781 | /** 1782 | * @remarks 1783 | * Marks the current test as a success case. 1784 | * @throws This function can throw errors. 1785 | */ 1786 | succeed(): void; 1787 | /** 1788 | * @remarks 1789 | * Runs the given callback. If the callback does not throw an 1790 | * exception, the test is marked as a success. 1791 | * @param callback 1792 | * Callback function that runs. If the function runs 1793 | * successfully, the test is marked as a success. Typically, 1794 | * this function will have .assertXyz method calls within it. 1795 | * @throws This function can throw errors. 1796 | */ 1797 | succeedIf(callback: () => void): void; 1798 | /** 1799 | * @remarks 1800 | * Marks the test as a success at the specified tick. 1801 | * @param tick 1802 | * Tick after the start of the GameTest to mark the test as 1803 | * successful. 1804 | * @throws This function can throw errors. 1805 | */ 1806 | succeedOnTick(tick: number): void; 1807 | /** 1808 | * @remarks 1809 | * Runs the given callback at _tick_ ticks after the start of 1810 | * the test. If the callback does not throw an exception, the 1811 | * test is marked as a failure. 1812 | * @param tick 1813 | * Tick after the start of the GameTest to run the testing 1814 | * callback at. 1815 | * @param callback 1816 | * Callback function that runs. If the function runs 1817 | * successfully, the test is marked as a success. 1818 | * @throws This function can throw errors. 1819 | */ 1820 | succeedOnTickWhen(tick: number, callback: () => void): void; 1821 | /** 1822 | * @remarks 1823 | * Runs the given callback every tick. When the callback 1824 | * successfully executes, the test is marked as a success. 1825 | * Specifically, the test will succeed when the callback does 1826 | * not throw an exception. 1827 | * @param callback 1828 | * Testing callback function that runs. If the function runs 1829 | * successfully, the test is marked as a success. 1830 | * @throws This function can throw errors. 1831 | * @example simpleMobTest.ts 1832 | * ```typescript 1833 | * gt.register("StarterTests", "simpleMobTest", (test: gt.Test) => { 1834 | * const attackerId = "fox"; 1835 | * const victimId = "chicken"; 1836 | * 1837 | * test.spawn(attackerId, new mc.BlockLocation(5, 2, 5)); 1838 | * test.spawn(victimId, new mc.BlockLocation(2, 2, 2)); 1839 | * 1840 | * test.assertEntityPresentInArea(victimId, true); 1841 | * 1842 | * test.succeedWhen(() => { 1843 | * test.assertEntityPresentInArea(victimId, false); 1844 | * }); 1845 | * }) 1846 | * .maxTicks(400) 1847 | * .structureName("gametests:mediumglass"); 1848 | * 1849 | * ``` 1850 | */ 1851 | succeedWhen(callback: () => void): void; 1852 | /** 1853 | * @remarks 1854 | * Depending on the condition of isPresent, tests for the 1855 | * presence of a block of a particular type on every tick. When 1856 | * the specified block of a type is found or not found 1857 | * (depending on isPresent), the test is marked as a success. 1858 | * @param blockType 1859 | * Type of block to test for. 1860 | * @param blockLocation 1861 | * Location of the block to test at. 1862 | * @param isPresent 1863 | * If true, this function tests whether a block of the 1864 | * specified type is present. If false, tests that a block of 1865 | * the specified type is not present. 1866 | * @throws This function can throw errors. 1867 | */ 1868 | succeedWhenBlockPresent( 1869 | blockType: minecraftserver.BlockType, 1870 | blockLocation: minecraftserver.BlockLocation, 1871 | isPresent?: boolean, 1872 | ): void; 1873 | /** 1874 | * @remarks 1875 | * Tests for the presence of a component on every tick. 1876 | * Depending on the value of hasComponent, when the specified 1877 | * component is found, the test is marked as a success. 1878 | * @param entityTypeIdentifier 1879 | * Type of entity to look for. If no namespace is specified, 1880 | * 'minecraft:' is assumed. 1881 | * @param componentIdentifier 1882 | * Type of component to test for the presence of. If no 1883 | * namespace is specified, 'minecraft:' is assumed. 1884 | * @param blockLocation 1885 | * Block location of the entity to test. 1886 | * @param hasComponent 1887 | * If true, this function tests for the presence of a 1888 | * component. If false, this function tests for the lack of a 1889 | * component. 1890 | * @throws This function can throw errors. 1891 | */ 1892 | succeedWhenEntityHasComponent( 1893 | entityTypeIdentifier: string, 1894 | componentIdentifier: string, 1895 | blockLocation: minecraftserver.BlockLocation, 1896 | hasComponent: boolean, 1897 | ): void; 1898 | /** 1899 | * @remarks 1900 | * Depending on the value of isPresent, tests for the presence 1901 | * of an entity on every tick. When an entity of the specified 1902 | * type is found or not found (depending on isPresent), the 1903 | * test is marked as a success. 1904 | * @param entityTypeIdentifier 1905 | * Type of entity to test for (e.g., 'minecraft:skeleton'). If 1906 | * an entity namespace is not specified, 'minecraft:' is 1907 | * assumed. 1908 | * @param blockLocation 1909 | * Location of the entity to test for. 1910 | * @param isPresent 1911 | * If true, this function tests whether an entity of the 1912 | * specified type is present. If false, tests that an entity of 1913 | * the specified type is not present. 1914 | * @throws This function can throw errors. 1915 | */ 1916 | succeedWhenEntityPresent( 1917 | entityTypeIdentifier: string, 1918 | blockLocation: minecraftserver.BlockLocation, 1919 | isPresent?: boolean, 1920 | ): void; 1921 | /** 1922 | * @remarks 1923 | * Triggers a block event from a fixed list of available block 1924 | * events. 1925 | * @param blockLocation 1926 | * @param event 1927 | * Event to trigger. Valid values include minecraft:drip, 1928 | * minecraft:grow_stalagtite, minecraft:grow_stalagmite, 1929 | * minecraft:grow_up, minecraft:grow_down and 1930 | * minecraft:grow_sideways. 1931 | * @param eventParameters 1932 | * @throws This function can throw errors. 1933 | */ 1934 | triggerInternalBlockEvent( 1935 | blockLocation: minecraftserver.BlockLocation, 1936 | event: string, 1937 | eventParameters?: number[], 1938 | ): void; 1939 | /** 1940 | * @remarks 1941 | * This asynchronous function will wait until the code in the 1942 | * specified callback successfully completes. until can be used 1943 | * in conjunction with .assert functions to evaluate that a 1944 | * condition is true. 1945 | * @param callback 1946 | * Function with code to evaluate. 1947 | */ 1948 | until(callback: () => void): Promise; 1949 | /** 1950 | * @remarks 1951 | * Forces a mob to walk to a particular location. Usually used 1952 | * in conjunction with methods like .spawnWithoutBehaviors to 1953 | * have more predictable mob behaviors. Mobs will stop 1954 | * navigation as soon as they intersect the target location. 1955 | * @param mob 1956 | * Mob entity to give orders to. 1957 | * @param blockLocation 1958 | * Location where the entity should be walk to. 1959 | * @param speedModifier 1960 | * Adjustable modifier to the mob's walking speed. 1961 | * @throws This function can throw errors. 1962 | */ 1963 | walkTo(mob: minecraftserver.Entity, blockLocation: minecraftserver.BlockLocation, speedModifier?: number): void; 1964 | /** 1965 | * @remarks 1966 | * Forces a mob to walk to a particular location. Usually used 1967 | * in conjunction with methods like .spawnWithoutBehaviors to 1968 | * have more predictable mob behaviors. Mobs will stop 1969 | * navigation as soon as they intersect the target location. 1970 | * @param mob 1971 | * Mob entity to give orders to. 1972 | * @param location 1973 | * Location where the entity should be walk to. 1974 | * @param speedModifier 1975 | * Adjustable modifier to the mob's walking speed. 1976 | * @throws This function can throw errors. 1977 | */ 1978 | walkToLocation(mob: minecraftserver.Entity, location: minecraftserver.Location, speedModifier?: number): void; 1979 | /** 1980 | * @remarks 1981 | * From a BlockLocation with coordinates relative to the 1982 | * GameTest structure block, returns a new BlockLocation with 1983 | * coordinates relative to world. Rotation of the GameTest 1984 | * structure is also taken into account. 1985 | * @param relativeBlockLocation 1986 | * Location relative to the GameTest command block. 1987 | * @returns 1988 | * An absolute location relative to the GameTest command block. 1989 | * @throws This function can throw errors. 1990 | */ 1991 | worldBlockLocation(relativeBlockLocation: minecraftserver.BlockLocation): minecraftserver.BlockLocation; 1992 | /** 1993 | * @remarks 1994 | * From a location with coordinates relative to the GameTest 1995 | * structure block, returns a new location with coordinates 1996 | * relative to world. Rotation of the GameTest structure is 1997 | * also taken into account. 1998 | * @param relativeLocation 1999 | * Location relative to the GameTest command block. 2000 | * @returns 2001 | * An absolute location relative to the GameTest command block. 2002 | * @throws This function can throw errors. 2003 | */ 2004 | worldLocation(relativeLocation: minecraftserver.Location): minecraftserver.Location; 2005 | protected constructor(); 2006 | } 2007 | /** 2008 | * @remarks 2009 | * Registers a new GameTest function. This GameTest will become 2010 | * available in Minecraft via /gametest run 2011 | * [testClassName]:[testName]. 2012 | * @param testClassName 2013 | * Name of the class of tests this test should be a part of. 2014 | * @param testName 2015 | * Name of this specific test. 2016 | * @param testFunction 2017 | * Implementation of the test function. 2018 | * @returns 2019 | * Returns a {@link RegistrationBuilder} object where 2020 | * additional options for this test can be specified via 2021 | * builder methods. 2022 | * @example example1.js 2023 | * ```typescript 2024 | * GameTest.register("ExampleTests", "alwaysFail", (test) => { 2025 | * test.fail("This test, runnable via '/gametest run ExampleTests:alwaysFail', will always fail"); 2026 | * }); 2027 | * 2028 | * ``` 2029 | * @example simpleMobTest.ts 2030 | * ```typescript 2031 | * gt.register("StarterTests", "simpleMobTest", (test: gt.Test) => { 2032 | * const attackerId = "fox"; 2033 | * const victimId = "chicken"; 2034 | * 2035 | * test.spawn(attackerId, new mc.BlockLocation(5, 2, 5)); 2036 | * test.spawn(victimId, new mc.BlockLocation(2, 2, 2)); 2037 | * 2038 | * test.assertEntityPresentInArea(victimId, true); 2039 | * 2040 | * test.succeedWhen(() => { 2041 | * test.assertEntityPresentInArea(victimId, false); 2042 | * }); 2043 | * }) 2044 | * .maxTicks(400) 2045 | * .structureName("gametests:mediumglass"); 2046 | * ``` 2047 | */ 2048 | export function register( 2049 | testClassName: string, 2050 | testName: string, 2051 | testFunction: (arg: Test) => void, 2052 | ): RegistrationBuilder; 2053 | /** 2054 | * @remarks 2055 | * Registers a new GameTest function that is designed for 2056 | * asynchronous execution. This GameTest will become available 2057 | * in Minecraft via /gametest run [testClassName]:[testName]. 2058 | * @param testClassName 2059 | * Name of the class of tests this test should be a part of. 2060 | * @param testName 2061 | * Name of this specific test. 2062 | * @param testFunction 2063 | * Implementation of the test function. 2064 | * @returns 2065 | * Returns a {@link RegistrationBuilder} object where 2066 | * additional options for this test can be specified via 2067 | * builder methods. 2068 | */ 2069 | export function registerAsync( 2070 | testClassName: string, 2071 | testName: string, 2072 | testFunction: (arg: Test) => Promise, 2073 | ): RegistrationBuilder; 2074 | -------------------------------------------------------------------------------- /node_modules/@minecraft/server-gametest/node_modules/@minecraft/server/README.md: -------------------------------------------------------------------------------- 1 | # `@minecraft/server` 2 | 3 | Contains many types related to manipulating a Minecraft world, including entities, blocks, dimensions, and more. 4 | 5 | ## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.** 6 | 7 | See full documentation for this module here: 8 | 9 | https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/@minecraft/server/@minecraft/server -------------------------------------------------------------------------------- /node_modules/@minecraft/server-gametest/node_modules/@minecraft/server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@minecraft/server", 3 | "version": "1.0.0-beta.11940b24", 4 | "description": "", 5 | "contributors": [ 6 | { 7 | "name": "Jake Shirley", 8 | "email": "jake@xbox.com" 9 | }, 10 | { 11 | "name": "Mike Ammerlaan", 12 | "email": "mikeam@microsoft.com" 13 | } 14 | ], 15 | "license": "MIT" 16 | } -------------------------------------------------------------------------------- /node_modules/@minecraft/server-gametest/node_modules/@minecraft/server/tests.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-unused-vars */ 2 | import * as mc from '@minecraft/server'; 3 | 4 | export function createExplosion(log: (message: string, status?: number) => void, targetLocation: mc.Location) { 5 | const overworld = mc.world.getDimension('overworld'); 6 | 7 | log('Creating an explosion of radius 10.'); 8 | overworld.createExplosion(targetLocation, 10); 9 | } 10 | 11 | export function createNoBlockExplosion(log: (message: string, status?: number) => void, targetLocation: mc.Location) { 12 | const overworld = mc.world.getDimension('overworld'); 13 | 14 | const explodeNoBlocksLoc = new mc.Location( 15 | Math.floor(targetLocation.x + 1), 16 | Math.floor(targetLocation.y + 2), 17 | Math.floor(targetLocation.z + 1), 18 | ); 19 | 20 | log('Creating an explosion of radius 15 that does not break blocks.'); 21 | overworld.createExplosion(explodeNoBlocksLoc, 15, { breaksBlocks: false }); 22 | } 23 | 24 | export function createFireAndWaterExplosions( 25 | log: (message: string, status?: number) => void, 26 | targetLocation: mc.Location, 27 | ) { 28 | const overworld = mc.world.getDimension('overworld'); 29 | 30 | const explosionLoc = new mc.Location(targetLocation.x + 0.5, targetLocation.y + 0.5, targetLocation.z + 0.5); 31 | 32 | log('Creating an explosion of radius 15 that causes fire.'); 33 | overworld.createExplosion(explosionLoc, 15, { causesFire: true }); 34 | 35 | const belowWaterLoc = new mc.Location(targetLocation.x + 3, targetLocation.y + 1, targetLocation.z + 3); 36 | 37 | log('Creating an explosion of radius 10 that can go underwater.'); 38 | overworld.createExplosion(belowWaterLoc, 10, { allowUnderwater: true }); 39 | } 40 | 41 | export function itemStacks(log: (message: string, status?: number) => void, targetLocation: mc.Location) { 42 | const overworld = mc.world.getDimension('overworld'); 43 | 44 | const oneItemLoc = new mc.BlockLocation(targetLocation.x + targetLocation.y + 3, 2, targetLocation.z + 1); 45 | const fiveItemsLoc = new mc.BlockLocation(targetLocation.x + 1, targetLocation.y + 2, targetLocation.z + 1); 46 | const diamondPickaxeLoc = new mc.BlockLocation(targetLocation.x + 2, targetLocation.y + 2, targetLocation.z + 4); 47 | 48 | const oneEmerald = new mc.ItemStack(mc.MinecraftItemTypes.emerald, 1, 0); 49 | const onePickaxe = new mc.ItemStack(mc.MinecraftItemTypes.diamondPickaxe, 1, 0); 50 | const fiveEmeralds = new mc.ItemStack(mc.MinecraftItemTypes.emerald, 5, 0); 51 | 52 | log(`Spawning an emerald at (${oneItemLoc.x}, ${oneItemLoc.y}, ${oneItemLoc.z})`); 53 | overworld.spawnItem(oneEmerald, oneItemLoc); 54 | 55 | log(`Spawning five emeralds at (${fiveItemsLoc.x}, ${fiveItemsLoc.y}, ${fiveItemsLoc.z})`); 56 | overworld.spawnItem(fiveEmeralds, fiveItemsLoc); 57 | 58 | log(`Spawning a diamond pickaxe at (${diamondPickaxeLoc.x}, ${diamondPickaxeLoc.y}, ${diamondPickaxeLoc.z})`); 59 | overworld.spawnItem(onePickaxe, diamondPickaxeLoc); 60 | } 61 | 62 | export function quickFoxLazyDog(log: (message: string, status?: number) => void, targetLocation: mc.Location) { 63 | const overworld = mc.world.getDimension('overworld'); 64 | 65 | const fox = overworld.spawnEntity( 66 | 'minecraft:fox', 67 | new mc.BlockLocation(targetLocation.x + 1, targetLocation.y + 2, targetLocation.z + 3), 68 | ); 69 | fox.addEffect(mc.MinecraftEffectTypes.speed, 10, 20); 70 | log('Created a fox.'); 71 | 72 | const wolf = overworld.spawnEntity( 73 | 'minecraft:wolf', 74 | new mc.BlockLocation(targetLocation.x + 4, targetLocation.y + 2, targetLocation.z + 3), 75 | ); 76 | wolf.addEffect(mc.MinecraftEffectTypes.slowness, 10, 20); 77 | wolf.isSneaking = true; 78 | log('Created a sneaking wolf.', 1); 79 | } 80 | 81 | export function runEntityCreatedEvent(log: (message: string, status?: number) => void, targetLocation: mc.Location) { 82 | // register a new function that is called when a new entity is created. 83 | mc.world.events.entityCreate.subscribe((entityEvent: mc.EntityCreateEvent) => { 84 | if (entityEvent && entityEvent.entity) { 85 | log(`New entity of type '${entityEvent.entity}' created!`, 1); 86 | } else { 87 | log(`The entity event didn't work as expected.`, -1); 88 | } 89 | }); 90 | } 91 | 92 | export function createOldHorse(log: (message: string, status?: number) => void, targetLocation: mc.Location) { 93 | const overworld = mc.world.getDimension('overworld'); 94 | 95 | log("Create a horse and triggering the 'ageable_grow_up' event, ensuring the horse is created as an adult"); 96 | overworld.spawnEntity('minecraft:horse', targetLocation); 97 | } 98 | 99 | export function pistonEvent(log: (message: string, status?: number) => void, targetLocation: mc.Location) { 100 | const pistonLoc = new mc.BlockLocation( 101 | Math.floor(targetLocation.x) + 1, 102 | Math.floor(targetLocation.y) + 2, 103 | Math.floor(targetLocation.z) + 1, 104 | ); 105 | 106 | mc.world.events.beforePistonActivate.subscribe((pistonEvent: mc.BeforePistonActivateEvent) => { 107 | if (pistonEvent.piston.location.equals(pistonLoc)) { 108 | log('Cancelling piston event'); 109 | pistonEvent.cancel = true; 110 | } 111 | }); 112 | } 113 | 114 | export function spawnItem(log: (message: string, status?: number) => void, targetLocation: mc.Location) { 115 | const featherItem = new mc.ItemStack(mc.MinecraftItemTypes.feather, 1, 0); 116 | 117 | overworld.spawnItem(featherItem, targetLocation); 118 | log(`New feather created at ${targetLocation.x}, ${targetLocation.y}, ${targetLocation.z}!`); 119 | } 120 | 121 | export function testThatEntityIsFeatherItem( 122 | log: (message: string, status?: number) => void, 123 | targetLocation: mc.Location, 124 | ) { 125 | const overworld = mc.world.getDimension('overworld'); 126 | 127 | const items = overworld.getEntities({ 128 | location: targetLocation, 129 | maxDistance: 20, 130 | }); 131 | 132 | for (const item of items) { 133 | const itemComp = item.getComponent('item') as any; 134 | 135 | if (itemComp) { 136 | if (itemComp.itemStack.id.endsWith('feather')) { 137 | log('Success! Found a feather', 1); 138 | } 139 | } 140 | } 141 | } 142 | 143 | export function trapTick() { 144 | const overworld = mc.world.getDimension('overworld'); 145 | 146 | try { 147 | // Minecraft runs at 20 ticks per second 148 | if (ticks % 1200 === 0) { 149 | overworld.runCommandAsync('say Another minute passes...'); 150 | } 151 | 152 | ticks++; 153 | } catch (e) { 154 | console.warn('Error: ' + e); 155 | } 156 | 157 | mc.system.run(trapTick); 158 | } 159 | 160 | export default class SampleManager { 161 | tickCount = 0; 162 | 163 | _availableFuncs: { 164 | [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Location) => void>; 165 | }; 166 | 167 | pendingFuncs: Array<{ 168 | name: string; 169 | func: (log: (message: string, status?: number) => void, location: mc.Location) => void; 170 | location: mc.Location; 171 | }> = []; 172 | 173 | gameplayLogger(message: string, status?: number) { 174 | if (status !== undefined && status > 0) { 175 | message = 'SUCCESS: ' + message; 176 | } else if (status !== undefined && status < 0) { 177 | message = 'FAIL: ' + message; 178 | } 179 | 180 | this.say(message); 181 | } 182 | say(message: string) { 183 | mc.world.getDimension('overworld').runCommand('say ' + message); 184 | } 185 | 186 | newChatMessage(chatEvent: mc.ChatEvent) { 187 | const message = chatEvent.message.toLowerCase(); 188 | 189 | if (message.startsWith('howto') && chatEvent.sender) { 190 | const nearbyBlock = chatEvent.sender.getBlockFromViewVector(); 191 | if (!nearbyBlock) { 192 | this.gameplayLogger('Please look at the block where you want me to run this.'); 193 | return; 194 | } 195 | 196 | const nearbyBlockLoc = nearbyBlock.location; 197 | const nearbyLoc = new mc.Location(nearbyBlockLoc.x, nearbyBlockLoc.y + 1, nearbyBlockLoc.z); 198 | 199 | const sampleId = message.substring(5).trim(); 200 | 201 | if (sampleId.length < 2) { 202 | let availableFuncStr = 'Here is my list of available samples:'; 203 | 204 | for (const sampleFuncKey in this._availableFuncs) { 205 | availableFuncStr += ' ' + sampleFuncKey; 206 | } 207 | 208 | this.say(availableFuncStr); 209 | } else { 210 | for (const sampleFuncKey in this._availableFuncs) { 211 | if (sampleFuncKey.toLowerCase() === sampleId) { 212 | const sampleFunc = this._availableFuncs[sampleFuncKey]; 213 | 214 | this.runSample(sampleFuncKey + this.tickCount, sampleFunc, nearbyLoc); 215 | 216 | return; 217 | } 218 | } 219 | 220 | this.say(`I couldn't find the sample '${sampleId}"'`); 221 | } 222 | } 223 | } 224 | 225 | runSample( 226 | sampleId: string, 227 | snippetFunctions: Array<(log: (message: string, status?: number) => void, location: mc.Location) => void>, 228 | targetLocation: mc.Location, 229 | ) { 230 | for (let i = snippetFunctions.length - 1; i >= 0; i--) { 231 | this.pendingFuncs.push({ name: sampleId, func: snippetFunctions[i], location: targetLocation }); 232 | } 233 | } 234 | 235 | worldTick() { 236 | if (this.tickCount % 10 === 0) { 237 | if (this.pendingFuncs.length > 0) { 238 | const funcSet = this.pendingFuncs.pop(); 239 | 240 | if (funcSet) { 241 | funcSet.func(this.gameplayLogger, funcSet.location); 242 | } 243 | } 244 | } 245 | 246 | this.tickCount++; 247 | } 248 | 249 | constructor() { 250 | this._availableFuncs = {}; 251 | 252 | this.gameplayLogger = this.gameplayLogger.bind(this); 253 | 254 | mc.world.events.tick.subscribe(this.worldTick.bind(this)); 255 | mc.world.events.chat.subscribe(this.newChatMessage.bind(this)); 256 | } 257 | 258 | registerSamples(sampleSet: { 259 | [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Location) => void>; 260 | }) { 261 | for (const sampleKey in sampleSet) { 262 | if (sampleKey.length > 1 && sampleSet[sampleKey]) { 263 | this._availableFuncs[sampleKey] = sampleSet[sampleKey]; 264 | } 265 | } 266 | } 267 | } 268 | 269 | const mojangMinecraftFuncs: { 270 | [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Location) => void>; 271 | } = { 272 | runEntityCreatedEvent: [runEntityCreatedEvent, createOldHorse], 273 | createOldHorse: [createOldHorse], 274 | spawnItem: [spawnItem, testThatEntityIsFeatherItem], 275 | createNoBlockExplosion: [createExplosion], 276 | createFireAndWaterExplosions: [createFireAndWaterExplosions], 277 | createExplosion: [createExplosion], 278 | itemStacks: [itemStacks], 279 | quickFoxLazyDog: [quickFoxLazyDog], 280 | pistonEvent: [pistonEvent], 281 | trapTick: [trapTick], 282 | }; 283 | 284 | export function register(sampleManager: SampleManager) { 285 | sampleManager.registerSamples(mojangMinecraftFuncs); 286 | } 287 | -------------------------------------------------------------------------------- /node_modules/@minecraft/server-gametest/node_modules/@minecraft/server/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "forceConsistentCasingInFileNames": true, 7 | "noEmit": true, 8 | "noImplicitAny": true, 9 | "noImplicitThis": true, 10 | "strictFunctionTypes": true, 11 | "strictNullChecks": true, 12 | "baseUrl": "../", 13 | "typeRoots": ["../"], 14 | "types": [] 15 | }, 16 | "files": [ 17 | "index.d.ts", 18 | "tests.ts" 19 | ] 20 | } -------------------------------------------------------------------------------- /node_modules/@minecraft/server-gametest/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@minecraft/server-gametest", 3 | "version": "1.0.0-beta.11940b24", 4 | "description": "", 5 | "contributors": [ 6 | { 7 | "name": "Jake Shirley", 8 | "email": "jake@xbox.com" 9 | }, 10 | { 11 | "name": "Mike Ammerlaan", 12 | "email": "mikeam@microsoft.com" 13 | } 14 | ], 15 | "dependencies": { 16 | "@minecraft/server": "1.0.0-beta.11940b24" 17 | }, 18 | "license": "MIT" 19 | } -------------------------------------------------------------------------------- /node_modules/@minecraft/server-gametest/tests.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-unused-vars */ 2 | import * as mc from '@minecraft/server'; 3 | 4 | export function simpleMobTest(log: (message: string, status?: number) => void, targetLocation: mc.Location) { 5 | gt.register('StarterTests', 'simpleMobTest', (test: gt.Test) => { 6 | const attackerId = 'fox'; 7 | const victimId = 'chicken'; 8 | 9 | test.spawn(attackerId, new mc.BlockLocation(5, 2, 5)); 10 | test.spawn(victimId, new mc.BlockLocation(2, 2, 2)); 11 | 12 | test.assertEntityPresentInArea(victimId, true); 13 | 14 | test.succeedWhen(() => { 15 | test.assertEntityPresentInArea(victimId, false); 16 | }); 17 | }) 18 | .maxTicks(400) 19 | .structureName('gametests:mediumglass'); 20 | } 21 | 22 | export default class SampleManager { 23 | tickCount = 0; 24 | 25 | _availableFuncs: { 26 | [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Location) => void>; 27 | }; 28 | 29 | pendingFuncs: Array<{ 30 | name: string; 31 | func: (log: (message: string, status?: number) => void, location: mc.Location) => void; 32 | location: mc.Location; 33 | }> = []; 34 | 35 | gameplayLogger(message: string, status?: number) { 36 | if (status !== undefined && status > 0) { 37 | message = 'SUCCESS: ' + message; 38 | } else if (status !== undefined && status < 0) { 39 | message = 'FAIL: ' + message; 40 | } 41 | 42 | this.say(message); 43 | } 44 | say(message: string) { 45 | mc.world.getDimension('overworld').runCommand('say ' + message); 46 | } 47 | 48 | newChatMessage(chatEvent: mc.ChatEvent) { 49 | const message = chatEvent.message.toLowerCase(); 50 | 51 | if (message.startsWith('howto') && chatEvent.sender) { 52 | const nearbyBlock = chatEvent.sender.getBlockFromViewVector(); 53 | if (!nearbyBlock) { 54 | this.gameplayLogger('Please look at the block where you want me to run this.'); 55 | return; 56 | } 57 | 58 | const nearbyBlockLoc = nearbyBlock.location; 59 | const nearbyLoc = new mc.Location(nearbyBlockLoc.x, nearbyBlockLoc.y + 1, nearbyBlockLoc.z); 60 | 61 | const sampleId = message.substring(5).trim(); 62 | 63 | if (sampleId.length < 2) { 64 | let availableFuncStr = 'Here is my list of available samples:'; 65 | 66 | for (const sampleFuncKey in this._availableFuncs) { 67 | availableFuncStr += ' ' + sampleFuncKey; 68 | } 69 | 70 | this.say(availableFuncStr); 71 | } else { 72 | for (const sampleFuncKey in this._availableFuncs) { 73 | if (sampleFuncKey.toLowerCase() === sampleId) { 74 | const sampleFunc = this._availableFuncs[sampleFuncKey]; 75 | 76 | this.runSample(sampleFuncKey + this.tickCount, sampleFunc, nearbyLoc); 77 | 78 | return; 79 | } 80 | } 81 | 82 | this.say(`I couldn't find the sample '${sampleId}"'`); 83 | } 84 | } 85 | } 86 | 87 | runSample( 88 | sampleId: string, 89 | snippetFunctions: Array<(log: (message: string, status?: number) => void, location: mc.Location) => void>, 90 | targetLocation: mc.Location, 91 | ) { 92 | for (let i = snippetFunctions.length - 1; i >= 0; i--) { 93 | this.pendingFuncs.push({ name: sampleId, func: snippetFunctions[i], location: targetLocation }); 94 | } 95 | } 96 | 97 | worldTick() { 98 | if (this.tickCount % 10 === 0) { 99 | if (this.pendingFuncs.length > 0) { 100 | const funcSet = this.pendingFuncs.pop(); 101 | 102 | if (funcSet) { 103 | funcSet.func(this.gameplayLogger, funcSet.location); 104 | } 105 | } 106 | } 107 | 108 | this.tickCount++; 109 | } 110 | 111 | constructor() { 112 | this._availableFuncs = {}; 113 | 114 | this.gameplayLogger = this.gameplayLogger.bind(this); 115 | 116 | mc.world.events.tick.subscribe(this.worldTick.bind(this)); 117 | mc.world.events.chat.subscribe(this.newChatMessage.bind(this)); 118 | } 119 | 120 | registerSamples(sampleSet: { 121 | [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Location) => void>; 122 | }) { 123 | for (const sampleKey in sampleSet) { 124 | if (sampleKey.length > 1 && sampleSet[sampleKey]) { 125 | this._availableFuncs[sampleKey] = sampleSet[sampleKey]; 126 | } 127 | } 128 | } 129 | } 130 | 131 | import * as gt from '@minecraft/server-gametest'; // keep in for gametest samples 132 | 133 | const mojangGameTestFuncs: { 134 | [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Location) => void>; 135 | } = { 136 | simpleMobTest: [simpleMobTest], 137 | }; 138 | 139 | export function register(sampleManager: SampleManager) { 140 | sampleManager.registerSamples(mojangGameTestFuncs); 141 | } 142 | -------------------------------------------------------------------------------- /node_modules/@minecraft/server-gametest/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "forceConsistentCasingInFileNames": true, 7 | "noEmit": true, 8 | "noImplicitAny": true, 9 | "noImplicitThis": true, 10 | "strictFunctionTypes": true, 11 | "strictNullChecks": true, 12 | "baseUrl": "../", 13 | "typeRoots": ["../"], 14 | "types": [] 15 | }, 16 | "files": [ 17 | "index.d.ts", 18 | "tests.ts" 19 | ] 20 | } -------------------------------------------------------------------------------- /node_modules/@minecraft/server/README.md: -------------------------------------------------------------------------------- 1 | # `@minecraft/server` 2 | 3 | Contains many types related to manipulating a Minecraft world, including entities, blocks, dimensions, and more. 4 | 5 | See full documentation for this module here: 6 | 7 | https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/@minecraft/server/@minecraft/server -------------------------------------------------------------------------------- /node_modules/@minecraft/server/index.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for Minecraft Bedrock Edition script APIs 2 | // Project: https://docs.microsoft.com/minecraft/creator/ 3 | // Definitions by: Jake Shirley 4 | // Mike Ammerlaan 5 | 6 | /* ***************************************************************************** 7 | Copyright (c) Microsoft Corporation. 8 | ***************************************************************************** */ 9 | /** 10 | * @packageDocumentation 11 | * Contains many types related to manipulating a Minecraft 12 | * world, including entities, blocks, dimensions, and more. 13 | * 14 | * Manifest Details 15 | * ```json 16 | * { 17 | * "module_name": "@minecraft/server", 18 | * "version": "1.0.0" 19 | * } 20 | * ``` 21 | * 22 | */ 23 | /** 24 | * Contains return data on the result of a command execution. 25 | */ 26 | export class CommandResult { 27 | protected constructor(); 28 | /** 29 | * If the command operates against a number of entities, 30 | * blocks, or items, this returns the number of successful 31 | * applications of this command. 32 | */ 33 | readonly successCount: number; 34 | } 35 | /** 36 | * A class that represents a particular dimension (e.g., The 37 | * End) within a world. 38 | */ 39 | export class Dimension { 40 | protected constructor(); 41 | /** 42 | * Identifier of the dimension. 43 | * @throws This property can throw when used. 44 | */ 45 | readonly id: string; 46 | /** 47 | * @remarks 48 | * Runs a particular command asynchronously from the context of 49 | * the broader dimension. Note that there is a maximum queue 50 | * of 128 asynchronous commands that can be run in a given 51 | * tick. 52 | * @param commandString 53 | * Command to run. Note that command strings should not start 54 | * with slash. 55 | * @returns 56 | * For commands that return data, returns a CommandResult with 57 | * an indicator of command results. 58 | * @throws This function can throw errors. 59 | */ 60 | runCommandAsync(commandString: string): Promise; 61 | } 62 | /** 63 | * Represents the state of an entity (a mob, the player, or 64 | * other moving objects like minecarts) in the world. 65 | */ 66 | export class Entity { 67 | protected constructor(); 68 | /** 69 | * Unique identifier of the entity. This identifier is intended 70 | * to be consistent across loads of a world instance. No 71 | * meaning should be inferred from the value and structure of 72 | * this unique identifier - do not parse or interpret it. 73 | * @throws This property can throw when used. 74 | */ 75 | readonly id: string; 76 | /** 77 | * Unique identifier of the type of the entity - for example, 78 | * 'minecraft:skeleton'. 79 | * @throws This property can throw when used. 80 | */ 81 | readonly typeId: string; 82 | /** 83 | * @remarks 84 | * Runs a particular command asynchronously from the context of 85 | * this entity. Note that there is a maximum queue of 128 86 | * asynchronous commands that can be run in a given tick. 87 | * @param commandString 88 | * Command to run. Note that command strings should not start 89 | * with slash. 90 | * @returns 91 | * For commands that return data, returns a JSON structure with 92 | * command response values. 93 | * @throws This function can throw errors. 94 | */ 95 | runCommandAsync(commandString: string): Promise; 96 | } 97 | /** 98 | * A collection of default Minecraft dimension types. 99 | */ 100 | // tslint:disable-next-line:no-unnecessary-class 101 | export class MinecraftDimensionTypes { 102 | protected constructor(); 103 | /** 104 | * The Nether is a collection of biomes separate from the 105 | * Overworld, including Soul Sand Valleys and Crimson forests. 106 | * Nether fortresses contain exclusive resources. Mobs such as 107 | * Blaze, Hoglins, Piglins, and Ghasts congregate here. 108 | */ 109 | static readonly nether = 'minecraft:nether'; 110 | /** 111 | * The overworld is a collection of biomes, including forests, 112 | * plains, jungles, mountains, deserts, taiga, and more. This 113 | * is the default starter dimension for Minecraft. Mobs such as 114 | * Axolotl, Cows, Creepers, and Zombies congregate here. 115 | */ 116 | static readonly overworld = 'minecraft:overworld'; 117 | /** 118 | * The End is separate from the Overworld and the Nether and is 119 | * generated whenever you create an End portal. Here, a giant 120 | * center island is surrounded by several smaller areas and 121 | * islands. You can find Endermen here. End midlands are larger 122 | * areas that transition you from the center to the outer edges 123 | * of the End. They contain Shulkers, Endermen, End gateway 124 | * portals, and End cities. End gateway portals are commonly 125 | * found at the outermost edge of the void. You usually find 126 | * End barrens toward the edges of the main areas or land in 127 | * the End. 128 | */ 129 | static readonly theEnd = 'minecraft:the_end'; 130 | } 131 | /** 132 | * Represents a player within the world. 133 | */ 134 | export class Player extends Entity { 135 | protected constructor(); 136 | /** 137 | * Unique identifier of the player. This identifier is intended 138 | * to be consistent across loads of a world instance. No 139 | * meaning should be inferred from the value and structure of 140 | * this unique identifier - do not parse or interpret it. 141 | * @throws This property can throw when used. 142 | */ 143 | readonly id: string; 144 | /** 145 | * Name of the player. 146 | * @throws This property can throw when used. 147 | */ 148 | readonly name: string; 149 | /** 150 | * Unique identifier of the type of the entity - for example, 151 | * 'minecraft:player'. 152 | * @throws This property can throw when used. 153 | */ 154 | readonly typeId: string; 155 | /** 156 | * @remarks 157 | * Runs a particular command asynchronously from the context of 158 | * this entity. Note that there is a maximum queue of 128 159 | * asynchronous commands that can be run in a given tick. 160 | * @param commandString 161 | * Command to run. Note that command strings should not start 162 | * with slash. 163 | * @returns 164 | * For commands that return data, returns a JSON structure with 165 | * command response values. 166 | * @throws This function can throw errors. 167 | */ 168 | runCommandAsync(commandString: string): Promise; 169 | } 170 | /** 171 | * A class that provides system-level events and functions. 172 | */ 173 | export class System { 174 | protected constructor(); 175 | /** 176 | * @remarks 177 | * Runs a specified function at a future time. This is 178 | * frequently used to implement delayed behaviors and game 179 | * loops. 180 | * @param callback 181 | * Function callback to run when the tickDelay time criteria is 182 | * met. 183 | * @returns 184 | * An opaque identifier that can be used with the `clearRun` 185 | * function to cancel the execution of this run. 186 | */ 187 | run(callback: () => void): number; 188 | } 189 | /** 190 | * A class that wraps the state of a world - a set of 191 | * dimensions and the environment of Minecraft. 192 | */ 193 | export class World { 194 | protected constructor(); 195 | getAllPlayers(): Player[]; 196 | /** 197 | * @param dimensionId 198 | * @returns 199 | * The requested dimension 200 | * @throws 201 | * Throws if the given dimension name is invalid 202 | */ 203 | getDimension(dimensionId: string): Dimension; 204 | } 205 | /** 206 | * A class that provides system-level events and functions. 207 | */ 208 | export const system: System; 209 | /** 210 | * A class that wraps the state of a world - a set of 211 | * dimensions and the environment of Minecraft. 212 | */ 213 | export const world: World; 214 | -------------------------------------------------------------------------------- /node_modules/@minecraft/server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@minecraft/server", 3 | "version": "1.0.0", 4 | "description": "", 5 | "contributors": [ 6 | { 7 | "name": "Jake Shirley", 8 | "email": "jake@xbox.com" 9 | }, 10 | { 11 | "name": "Mike Ammerlaan", 12 | "email": "mikeam@microsoft.com" 13 | } 14 | ], 15 | "license": "MIT" 16 | } -------------------------------------------------------------------------------- /node_modules/@minecraft/server/tests.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-unused-vars */ 2 | import * as mc from '@minecraft/server'; 3 | 4 | export function createExplosion(log: (message: string, status?: number) => void, targetLocation: mc.Location) { 5 | const overworld = mc.world.getDimension('overworld'); 6 | 7 | log('Creating an explosion of radius 10.'); 8 | overworld.createExplosion(targetLocation, 10); 9 | } 10 | 11 | export function createNoBlockExplosion(log: (message: string, status?: number) => void, targetLocation: mc.Location) { 12 | const overworld = mc.world.getDimension('overworld'); 13 | 14 | const explodeNoBlocksLoc = new mc.Location( 15 | Math.floor(targetLocation.x + 1), 16 | Math.floor(targetLocation.y + 2), 17 | Math.floor(targetLocation.z + 1), 18 | ); 19 | 20 | log('Creating an explosion of radius 15 that does not break blocks.'); 21 | overworld.createExplosion(explodeNoBlocksLoc, 15, { breaksBlocks: false }); 22 | } 23 | 24 | export function createFireAndWaterExplosions( 25 | log: (message: string, status?: number) => void, 26 | targetLocation: mc.Location, 27 | ) { 28 | const overworld = mc.world.getDimension('overworld'); 29 | 30 | const explosionLoc = new mc.Location(targetLocation.x + 0.5, targetLocation.y + 0.5, targetLocation.z + 0.5); 31 | 32 | log('Creating an explosion of radius 15 that causes fire.'); 33 | overworld.createExplosion(explosionLoc, 15, { causesFire: true }); 34 | 35 | const belowWaterLoc = new mc.Location(targetLocation.x + 3, targetLocation.y + 1, targetLocation.z + 3); 36 | 37 | log('Creating an explosion of radius 10 that can go underwater.'); 38 | overworld.createExplosion(belowWaterLoc, 10, { allowUnderwater: true }); 39 | } 40 | 41 | export function itemStacks(log: (message: string, status?: number) => void, targetLocation: mc.Location) { 42 | const overworld = mc.world.getDimension('overworld'); 43 | 44 | const oneItemLoc = new mc.BlockLocation(targetLocation.x + targetLocation.y + 3, 2, targetLocation.z + 1); 45 | const fiveItemsLoc = new mc.BlockLocation(targetLocation.x + 1, targetLocation.y + 2, targetLocation.z + 1); 46 | const diamondPickaxeLoc = new mc.BlockLocation(targetLocation.x + 2, targetLocation.y + 2, targetLocation.z + 4); 47 | 48 | const oneEmerald = new mc.ItemStack(mc.MinecraftItemTypes.emerald, 1, 0); 49 | const onePickaxe = new mc.ItemStack(mc.MinecraftItemTypes.diamondPickaxe, 1, 0); 50 | const fiveEmeralds = new mc.ItemStack(mc.MinecraftItemTypes.emerald, 5, 0); 51 | 52 | log(`Spawning an emerald at (${oneItemLoc.x}, ${oneItemLoc.y}, ${oneItemLoc.z})`); 53 | overworld.spawnItem(oneEmerald, oneItemLoc); 54 | 55 | log(`Spawning five emeralds at (${fiveItemsLoc.x}, ${fiveItemsLoc.y}, ${fiveItemsLoc.z})`); 56 | overworld.spawnItem(fiveEmeralds, fiveItemsLoc); 57 | 58 | log(`Spawning a diamond pickaxe at (${diamondPickaxeLoc.x}, ${diamondPickaxeLoc.y}, ${diamondPickaxeLoc.z})`); 59 | overworld.spawnItem(onePickaxe, diamondPickaxeLoc); 60 | } 61 | 62 | export function quickFoxLazyDog(log: (message: string, status?: number) => void, targetLocation: mc.Location) { 63 | const overworld = mc.world.getDimension('overworld'); 64 | 65 | const fox = overworld.spawnEntity( 66 | 'minecraft:fox', 67 | new mc.BlockLocation(targetLocation.x + 1, targetLocation.y + 2, targetLocation.z + 3), 68 | ); 69 | fox.addEffect(mc.MinecraftEffectTypes.speed, 10, 20); 70 | log('Created a fox.'); 71 | 72 | const wolf = overworld.spawnEntity( 73 | 'minecraft:wolf', 74 | new mc.BlockLocation(targetLocation.x + 4, targetLocation.y + 2, targetLocation.z + 3), 75 | ); 76 | wolf.addEffect(mc.MinecraftEffectTypes.slowness, 10, 20); 77 | wolf.isSneaking = true; 78 | log('Created a sneaking wolf.', 1); 79 | } 80 | 81 | export function runEntityCreatedEvent(log: (message: string, status?: number) => void, targetLocation: mc.Location) { 82 | // register a new function that is called when a new entity is created. 83 | mc.world.events.entityCreate.subscribe((entityEvent: mc.EntityCreateEvent) => { 84 | if (entityEvent && entityEvent.entity) { 85 | log(`New entity of type '${entityEvent.entity}' created!`, 1); 86 | } else { 87 | log(`The entity event didn't work as expected.`, -1); 88 | } 89 | }); 90 | } 91 | 92 | export function createOldHorse(log: (message: string, status?: number) => void, targetLocation: mc.Location) { 93 | const overworld = mc.world.getDimension('overworld'); 94 | 95 | log("Create a horse and triggering the 'ageable_grow_up' event, ensuring the horse is created as an adult"); 96 | overworld.spawnEntity('minecraft:horse', targetLocation); 97 | } 98 | 99 | export function pistonEvent(log: (message: string, status?: number) => void, targetLocation: mc.Location) { 100 | const pistonLoc = new mc.BlockLocation( 101 | Math.floor(targetLocation.x) + 1, 102 | Math.floor(targetLocation.y) + 2, 103 | Math.floor(targetLocation.z) + 1, 104 | ); 105 | 106 | mc.world.events.beforePistonActivate.subscribe((pistonEvent: mc.BeforePistonActivateEvent) => { 107 | if (pistonEvent.piston.location.equals(pistonLoc)) { 108 | log('Cancelling piston event'); 109 | pistonEvent.cancel = true; 110 | } 111 | }); 112 | } 113 | 114 | export function spawnItem(log: (message: string, status?: number) => void, targetLocation: mc.Location) { 115 | const featherItem = new mc.ItemStack(mc.MinecraftItemTypes.feather, 1, 0); 116 | 117 | overworld.spawnItem(featherItem, targetLocation); 118 | log(`New feather created at ${targetLocation.x}, ${targetLocation.y}, ${targetLocation.z}!`); 119 | } 120 | 121 | export function testThatEntityIsFeatherItem( 122 | log: (message: string, status?: number) => void, 123 | targetLocation: mc.Location, 124 | ) { 125 | const overworld = mc.world.getDimension('overworld'); 126 | 127 | const items = overworld.getEntities({ 128 | location: targetLocation, 129 | maxDistance: 20, 130 | }); 131 | 132 | for (const item of items) { 133 | const itemComp = item.getComponent('item') as any; 134 | 135 | if (itemComp) { 136 | if (itemComp.itemStack.id.endsWith('feather')) { 137 | log('Success! Found a feather', 1); 138 | } 139 | } 140 | } 141 | } 142 | 143 | export function trapTick() { 144 | const overworld = mc.world.getDimension('overworld'); 145 | 146 | try { 147 | // Minecraft runs at 20 ticks per second 148 | if (ticks % 1200 === 0) { 149 | overworld.runCommandAsync('say Another minute passes...'); 150 | } 151 | 152 | ticks++; 153 | } catch (e) { 154 | console.warn('Error: ' + e); 155 | } 156 | 157 | mc.system.run(trapTick); 158 | } 159 | 160 | export default class SampleManager { 161 | tickCount = 0; 162 | 163 | _availableFuncs: { 164 | [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Location) => void>; 165 | }; 166 | 167 | pendingFuncs: Array<{ 168 | name: string; 169 | func: (log: (message: string, status?: number) => void, location: mc.Location) => void; 170 | location: mc.Location; 171 | }> = []; 172 | 173 | gameplayLogger(message: string, status?: number) { 174 | if (status !== undefined && status > 0) { 175 | message = 'SUCCESS: ' + message; 176 | } else if (status !== undefined && status < 0) { 177 | message = 'FAIL: ' + message; 178 | } 179 | 180 | this.say(message); 181 | } 182 | say(message: string) { 183 | mc.world.getDimension('overworld').runCommand('say ' + message); 184 | } 185 | 186 | newChatMessage(chatEvent: mc.ChatEvent) { 187 | const message = chatEvent.message.toLowerCase(); 188 | 189 | if (message.startsWith('howto') && chatEvent.sender) { 190 | const nearbyBlock = chatEvent.sender.getBlockFromViewVector(); 191 | if (!nearbyBlock) { 192 | this.gameplayLogger('Please look at the block where you want me to run this.'); 193 | return; 194 | } 195 | 196 | const nearbyBlockLoc = nearbyBlock.location; 197 | const nearbyLoc = new mc.Location(nearbyBlockLoc.x, nearbyBlockLoc.y + 1, nearbyBlockLoc.z); 198 | 199 | const sampleId = message.substring(5).trim(); 200 | 201 | if (sampleId.length < 2) { 202 | let availableFuncStr = 'Here is my list of available samples:'; 203 | 204 | for (const sampleFuncKey in this._availableFuncs) { 205 | availableFuncStr += ' ' + sampleFuncKey; 206 | } 207 | 208 | this.say(availableFuncStr); 209 | } else { 210 | for (const sampleFuncKey in this._availableFuncs) { 211 | if (sampleFuncKey.toLowerCase() === sampleId) { 212 | const sampleFunc = this._availableFuncs[sampleFuncKey]; 213 | 214 | this.runSample(sampleFuncKey + this.tickCount, sampleFunc, nearbyLoc); 215 | 216 | return; 217 | } 218 | } 219 | 220 | this.say(`I couldn't find the sample '${sampleId}"'`); 221 | } 222 | } 223 | } 224 | 225 | runSample( 226 | sampleId: string, 227 | snippetFunctions: Array<(log: (message: string, status?: number) => void, location: mc.Location) => void>, 228 | targetLocation: mc.Location, 229 | ) { 230 | for (let i = snippetFunctions.length - 1; i >= 0; i--) { 231 | this.pendingFuncs.push({ name: sampleId, func: snippetFunctions[i], location: targetLocation }); 232 | } 233 | } 234 | 235 | worldTick() { 236 | if (this.tickCount % 10 === 0) { 237 | if (this.pendingFuncs.length > 0) { 238 | const funcSet = this.pendingFuncs.pop(); 239 | 240 | if (funcSet) { 241 | funcSet.func(this.gameplayLogger, funcSet.location); 242 | } 243 | } 244 | } 245 | 246 | this.tickCount++; 247 | } 248 | 249 | constructor() { 250 | this._availableFuncs = {}; 251 | 252 | this.gameplayLogger = this.gameplayLogger.bind(this); 253 | 254 | mc.world.events.tick.subscribe(this.worldTick.bind(this)); 255 | mc.world.events.chat.subscribe(this.newChatMessage.bind(this)); 256 | } 257 | 258 | registerSamples(sampleSet: { 259 | [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Location) => void>; 260 | }) { 261 | for (const sampleKey in sampleSet) { 262 | if (sampleKey.length > 1 && sampleSet[sampleKey]) { 263 | this._availableFuncs[sampleKey] = sampleSet[sampleKey]; 264 | } 265 | } 266 | } 267 | } 268 | 269 | const mojangMinecraftFuncs: { 270 | [name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Location) => void>; 271 | } = { 272 | runEntityCreatedEvent: [runEntityCreatedEvent, createOldHorse], 273 | createOldHorse: [createOldHorse], 274 | spawnItem: [spawnItem, testThatEntityIsFeatherItem], 275 | createNoBlockExplosion: [createExplosion], 276 | createFireAndWaterExplosions: [createFireAndWaterExplosions], 277 | createExplosion: [createExplosion], 278 | itemStacks: [itemStacks], 279 | quickFoxLazyDog: [quickFoxLazyDog], 280 | pistonEvent: [pistonEvent], 281 | trapTick: [trapTick], 282 | }; 283 | 284 | export function register(sampleManager: SampleManager) { 285 | sampleManager.registerSamples(mojangMinecraftFuncs); 286 | } 287 | -------------------------------------------------------------------------------- /node_modules/@minecraft/server/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "target": "es6", 6 | "forceConsistentCasingInFileNames": true, 7 | "noEmit": true, 8 | "noImplicitAny": true, 9 | "noImplicitThis": true, 10 | "strictFunctionTypes": true, 11 | "strictNullChecks": true, 12 | "baseUrl": "../", 13 | "typeRoots": ["../"], 14 | "types": [] 15 | }, 16 | "files": [ 17 | "index.d.ts", 18 | "tests.ts" 19 | ] 20 | } -------------------------------------------------------------------------------- /pack_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlecsDeveloper/FakeplayerAddon/67aec8d32873ef11fedd9cb8b0f9be5f69f8c80d/pack_icon.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fakeplayer", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "@minecraft/server": "^1.0.0", 14 | "@minecraft/server-gametest": "^1.0.0-beta.11940b24" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /scripts/main.js: -------------------------------------------------------------------------------- 1 | import * as GameTest from "@minecraft/server-gametest"; 2 | import { world } from "@minecraft/server"; 3 | import { ephemeral, print, start } from "./src/data"; 4 | import { Client } from "./src/players"; 5 | 6 | 7 | GameTest.registerAsync('Fakeplayer','Server', async FAKEPLAYER => { 8 | 9 | // Players DB 10 | let PLAYERS = []; 11 | print(7,'Fakeplayer server started...'); 12 | 13 | // Repeat Actions 14 | world.events.tick.subscribe(ev => { 15 | if (PLAYERS.length == 0) return; 16 | PLAYERS.forEach(x => x.Actions.forEach(z => { 17 | Client.Actions(FAKEPLAYER,PLAYERS,x.Player.name,world.getDimension('overworld'),z) 18 | })) 19 | }) 20 | 21 | // Input Methods 22 | world.events.beforeChat.subscribe(ev => { 23 | // Config declarations 24 | let msg = ev.message.split(' '); 25 | const sdr = ev.sender; 26 | // Check first message argument 27 | if (msg[0] != './player') return; 28 | ev.cancel = true; 29 | msg.splice(0,1) 30 | // Server Reload 31 | if (msg[0] == 'server') { 32 | if (msg[1] == '?') ephemeral('r','§2Server methods:\n§r§3 - reload §8=> Reload a fakeplayer server§r\n§3 - guide §8=> Show all fakeplayer guide§r\n§3 - users §8=> Show all fakeplayers connected§r\n§3 - cls/clear §8=> Clear chat§r',sdr); 33 | else if (msg[1] == 'reload') { FAKEPLAYER.succeed(); start() } 34 | else if (msg[1] == 'cls' || msg[1] == 'clear') ephemeral('r','\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n',sdr) 35 | else if (msg[1] == 'guide') ephemeral('r','§2Fakeplayer Methods:\n§r§3 - ./player spawn §8=> Spawns a fakeplayer§r\n§3 - ./player kill §8=> Removes a fakeplayer§r\n§3 - ./player respawn §8=> Fakeplayer respawn§r\n§3 - ./player tp §8=> Fakeplayer tp§r\n§3 - ./player rotate <0-360> §8=> Rotate a fakeplayer§r\n§3 - ./player jump §8=> Fakeplayer jump action§r\n§3 - ./player attack §8=> Fakeplayer attack action§r\n§3 - ./player use <0-9> §8=> Fakeplayer use action§r\n§3 - ./player interact §8=> Fakeplayer interact action§r\n§3 - ./player shift §8=> Fakeplayer shift action§r\n§3 - ./player repeat §8=> Fakeplayer repeat actions§r\n§3 - ./player stop §8=> Fakeplayer stop repeat actions§r',sdr); 36 | else if (msg[1] == 'users') { 37 | if (PLAYERS.length == 0) return ephemeral('r','§7Not players found§r',sdr) 38 | ephemeral('r','§2Fakeplayers connected:§r',sdr); 39 | PLAYERS.forEach(x => ephemeral('r',`§3 - ${x.Player.name}§r`,sdr) ); 40 | } 41 | else ephemeral(8,"server it's a reserved word, check methods with './player server ?'",sdr) 42 | } 43 | // Connect, Disconnect && Actions 44 | else if (msg[1] == 'spawn') Client.Connect(PLAYERS,msg[0],sdr,FAKEPLAYER,msg[2]); 45 | else if (msg[1] == 'kill') Client.Disconnect(PLAYERS,msg[0],sdr,FAKEPLAYER); 46 | else if ( 47 | msg[1] == 'jump' || msg[1] == 'attack' || msg[1] == 'shift' || 48 | msg[1] == 'tp' || msg[1] == 'repeat' || msg[1] == 'stop' || 49 | msg[1] == 'interact' || msg[1] == 'respawn' || msg[1] == 'use' || 50 | msg[1] == 'rotate' 51 | ) Client.Actions(FAKEPLAYER,PLAYERS,msg[0],sdr,msg[1],msg[2]); 52 | // Invalid Action 53 | else ephemeral('c','Syntax error',sdr); 54 | }) 55 | 56 | }) 57 | .maxTicks(999999999) 58 | .structureName('FP:Server'); 59 | 60 | start(); -------------------------------------------------------------------------------- /scripts/src/data.js: -------------------------------------------------------------------------------- 1 | import { world } from '@minecraft/server' 2 | 3 | const ephemeral = (color,msg,sender) => sender.runCommandAsync(`tellraw @s {"rawtext":[{"text":"§${color}${msg}"}]}`); 4 | const print = (color,msg) => world.getDimension('overworld').runCommandAsync(`tellraw @a {"rawtext":[{"text":"§${color}${msg}"}]}`); 5 | const start = () => world.getDimension('overworld').runCommandAsync('execute positioned 999999999 200 999999999 run gametest run fakeplayer:server'); 6 | 7 | export { ephemeral, print, start } -------------------------------------------------------------------------------- /scripts/src/players.js: -------------------------------------------------------------------------------- 1 | import { Vector } from '@minecraft/server' 2 | import { ephemeral } from './data.js' 3 | 4 | export const Client = { 5 | 6 | Connect: function(...args) { 7 | // Config declarations 8 | const DB = args[0], username = args[1], sender = args[2], event = args[3], gamemode = args[4]; 9 | const exist = DB.findIndex(x => x.Player.name === username); 10 | // Fakeplayer connection check 11 | if (exist >= 0) return ephemeral(7,`${username} are connected`,sender) 12 | // Fakeplayer connection 13 | const FAKEPLAYER = event.spawnSimulatedPlayer(new Vector(0,4,0), username) 14 | FAKEPLAYER.setGameMode(gamemode == 'creative' || gamemode == 'creative' ? gamemode : 'survival'); 15 | FAKEPLAYER.teleport(sender.location, sender.dimension, sender.location.x, sender.location.y); 16 | FAKEPLAYER.runCommandAsync('spawnpoint @s') 17 | // Pushed player to DB 18 | DB.push({ Player: FAKEPLAYER, Actions: [] }) 19 | }, 20 | 21 | Disconnect: function(...args) { 22 | // Config declarations 23 | const DB = args[0], username = args[1], sender = args[2], event = args[3]; 24 | const exist = DB.findIndex(x => x.Player.name === username); 25 | // Fakeplayer disconnection check 26 | if (exist < 0) return ephemeral(8,'You can only manipulate existing players',sender); 27 | // Fakeplayer disconnection 28 | const FAKEPLAYER = DB[exist].Player; 29 | FAKEPLAYER.kill(); 30 | event.removeSimulatedPlayer(FAKEPLAYER) 31 | // Removed player from DB 32 | DB.splice(exist, 1); 33 | }, 34 | 35 | Actions: function(...args) { 36 | // Config declarations 37 | const EVENT = args[0], DB = args[1], username = args[2], sender = args[3], action = args[4]; 38 | const exist = DB.findIndex(x => x.Player.name === username); 39 | // Fakeplayer disconnection check 40 | if (exist < 0) return ephemeral(8,'You can only manipulate existing players',sender); 41 | // Fakeplayer action 42 | const FAKEPLAYER = DB[exist].Player; 43 | if (action == 'jump') FAKEPLAYER.jump(); 44 | else if (action == 'attack') FAKEPLAYER.attack(); 45 | else if (action == 'tp') FAKEPLAYER.teleport(sender.location, sender.dimension, sender.location.x, sender.location.y); 46 | else if (action == 'shift') FAKEPLAYER.isSneaking ? FAKEPLAYER.isSneaking = false : FAKEPLAYER.isSneaking = true; 47 | else if (action == 'respawn') FAKEPLAYER.respawn(); 48 | else if (action == 'use') FAKEPLAYER.useItemInSlot(args[5] >= 0 || args[5] <= 9 ? parseInt(args[5]) : 0); 49 | else if (action == 'interact') FAKEPLAYER.interact(); 50 | else if (action == 'rotate') FAKEPLAYER.rotateBody(parseInt(args[5]) || 20); 51 | // Repeat action 52 | else if (action == 'repeat') { 53 | const ACTIONS = DB[exist].Actions; 54 | if ( 55 | args[5] == 'jump' || 56 | args[5] == 'attack' || 57 | args[5] == 'break' || 58 | args[5] == 'use' || 59 | args[5] == 'interact' 60 | ) ACTIONS.push(args[5]); 61 | else ephemeral(7,'Invalid action to repeat',sender); 62 | } 63 | // Stop action 64 | else if (action == 'stop') DB[exist].Actions = []; 65 | } 66 | 67 | } -------------------------------------------------------------------------------- /structures/FP/Server.mcstructure: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlecsDeveloper/FakeplayerAddon/67aec8d32873ef11fedd9cb8b0f9be5f69f8c80d/structures/FP/Server.mcstructure --------------------------------------------------------------------------------