@minecraft/server-gametest 1.0.0-beta.00001b01
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +23 -0
- package/README.md +9 -0
- package/index.d.ts +2065 -0
- package/package.json +19 -0
- package/tests.ts +140 -0
- package/tsconfig.json +20 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,2065 @@
|
|
|
1
|
+
// Type definitions for Minecraft Bedrock Edition script APIs
|
|
2
|
+
// Project: https://docs.microsoft.com/minecraft/creator/
|
|
3
|
+
// Definitions by: Jake Shirley <https://github.com/JakeShirley>
|
|
4
|
+
// Mike Ammerlaan <https://github.com/mammerla>
|
|
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.00001b01"
|
|
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 <tag>`.
|
|
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
|
+
* Identifier for the player.
|
|
326
|
+
* @throws This property can throw when used.
|
|
327
|
+
*/
|
|
328
|
+
readonly id: string;
|
|
329
|
+
/**
|
|
330
|
+
* True if the player is currently using a sneaking movement.
|
|
331
|
+
*/
|
|
332
|
+
isSneaking: boolean;
|
|
333
|
+
/**
|
|
334
|
+
* Current location of the player.
|
|
335
|
+
* @throws This property can throw when used.
|
|
336
|
+
*/
|
|
337
|
+
readonly location: minecraftserver.IVec3;
|
|
338
|
+
/**
|
|
339
|
+
* Name of the player.
|
|
340
|
+
* @throws This property can throw when used.
|
|
341
|
+
*/
|
|
342
|
+
readonly name: string;
|
|
343
|
+
/**
|
|
344
|
+
* Optional name tag of the player.
|
|
345
|
+
*/
|
|
346
|
+
nameTag: string;
|
|
347
|
+
/**
|
|
348
|
+
* Contains methods for manipulating the on-screen display of a
|
|
349
|
+
* Player.
|
|
350
|
+
*/
|
|
351
|
+
readonly onScreenDisplay: minecraftserver.ScreenDisplay;
|
|
352
|
+
/**
|
|
353
|
+
* Main rotation of the entity.
|
|
354
|
+
* @throws This property can throw when used.
|
|
355
|
+
*/
|
|
356
|
+
readonly rotation: minecraftserver.XYRotation;
|
|
357
|
+
/**
|
|
358
|
+
* Returns a scoreboard identity that represents this entity.
|
|
359
|
+
* @throws This property can throw when used.
|
|
360
|
+
*/
|
|
361
|
+
readonly scoreboard: minecraftserver.ScoreboardIdentity;
|
|
362
|
+
/**
|
|
363
|
+
* Manages the selected slot in the player's hotbar.
|
|
364
|
+
*/
|
|
365
|
+
selectedSlot: number;
|
|
366
|
+
/**
|
|
367
|
+
* Retrieves or sets an entity that is used as the target of
|
|
368
|
+
* AI-related behaviors, like attacking.
|
|
369
|
+
* @throws This property can throw when used.
|
|
370
|
+
*/
|
|
371
|
+
readonly target: minecraftserver.Entity;
|
|
372
|
+
readonly typeId: string;
|
|
373
|
+
/**
|
|
374
|
+
* Current speed of the player across X, Y, and Z dimensions.
|
|
375
|
+
* @throws This property can throw when used.
|
|
376
|
+
*/
|
|
377
|
+
readonly velocity: minecraftserver.Vector;
|
|
378
|
+
/**
|
|
379
|
+
* Vector of the current view of the player.
|
|
380
|
+
* @throws This property can throw when used.
|
|
381
|
+
*/
|
|
382
|
+
readonly viewVector: minecraftserver.Vector;
|
|
383
|
+
/**
|
|
384
|
+
* @remarks
|
|
385
|
+
* Adds an effect, like poison, to the entity.
|
|
386
|
+
* @param effectType
|
|
387
|
+
* Type of effect to add to the entity.
|
|
388
|
+
* @param duration
|
|
389
|
+
* Amount of time, in ticks, for the effect to apply.
|
|
390
|
+
* @param amplifier
|
|
391
|
+
* Optional amplification of the effect to apply.
|
|
392
|
+
* @param showParticles
|
|
393
|
+
* @throws This function can throw errors.
|
|
394
|
+
*/
|
|
395
|
+
addEffect(
|
|
396
|
+
effectType: minecraftserver.EffectType,
|
|
397
|
+
duration: number,
|
|
398
|
+
amplifier?: number,
|
|
399
|
+
showParticles?: boolean,
|
|
400
|
+
): void;
|
|
401
|
+
addExperience(amount: number): boolean;
|
|
402
|
+
/**
|
|
403
|
+
* @remarks
|
|
404
|
+
* Adds a specified tag to a simulated player.
|
|
405
|
+
* @param tag
|
|
406
|
+
* Content of the tag to add.
|
|
407
|
+
* @throws This function can throw errors.
|
|
408
|
+
*/
|
|
409
|
+
addTag(tag: string): boolean;
|
|
410
|
+
/**
|
|
411
|
+
* @remarks
|
|
412
|
+
* Causes the simulated player to make an attack 'swipe'.
|
|
413
|
+
* Returns true if the attack was performed - for example, the
|
|
414
|
+
* player was not on cooldown and had a valid target. Target
|
|
415
|
+
* selection is performed by raycasting from the player's head.
|
|
416
|
+
* @throws This function can throw errors.
|
|
417
|
+
*/
|
|
418
|
+
attack(): boolean;
|
|
419
|
+
/**
|
|
420
|
+
* @remarks
|
|
421
|
+
* Causes the simulated player to attack the provided target.
|
|
422
|
+
* Returns true if the attack was performed - for example, the
|
|
423
|
+
* player was not on cooldown and had a valid target. The
|
|
424
|
+
* attack can be performed at any distance and does not require
|
|
425
|
+
* line of sight to the target entity.
|
|
426
|
+
* @param entity
|
|
427
|
+
* @throws This function can throw errors.
|
|
428
|
+
*/
|
|
429
|
+
attackEntity(entity: minecraftserver.Entity): boolean;
|
|
430
|
+
/**
|
|
431
|
+
* @remarks
|
|
432
|
+
* Destroys the block at blockLocation, respecting the rules of
|
|
433
|
+
* the server player's game mode. The block will be hit until
|
|
434
|
+
* broken, an item is used or stopBreakingBlock is called.
|
|
435
|
+
* Returns true if the block at blockLocation is solid.
|
|
436
|
+
* @param blockLocation
|
|
437
|
+
* Location of the block to interact with.
|
|
438
|
+
* @param direction
|
|
439
|
+
* Direction to place the specified item within.
|
|
440
|
+
* @throws This function can throw errors.
|
|
441
|
+
*/
|
|
442
|
+
breakBlock(blockLocation: minecraftserver.BlockLocation, direction?: minecraftserver.Direction): boolean;
|
|
443
|
+
/**
|
|
444
|
+
* @remarks
|
|
445
|
+
* Gets the first block that intersects with the vector of the
|
|
446
|
+
* view of this entity.
|
|
447
|
+
* @param options
|
|
448
|
+
* Additional options for processing this raycast query.
|
|
449
|
+
* @throws This function can throw errors.
|
|
450
|
+
*/
|
|
451
|
+
getBlockFromViewVector(options?: minecraftserver.BlockRaycastOptions): minecraftserver.Block;
|
|
452
|
+
/**
|
|
453
|
+
* @remarks
|
|
454
|
+
* Gets a component (that represents additional capabilities)
|
|
455
|
+
* for an entity.
|
|
456
|
+
* @param componentId
|
|
457
|
+
* The identifier of the component (e.g., 'minecraft:rideable')
|
|
458
|
+
* to retrieve. If no namespace prefix is specified,
|
|
459
|
+
* 'minecraft:' is assumed. If the component is not present on
|
|
460
|
+
* the entity, undefined is returned.
|
|
461
|
+
*/
|
|
462
|
+
getComponent(componentId: string): minecraftserver.IEntityComponent;
|
|
463
|
+
/**
|
|
464
|
+
* @remarks
|
|
465
|
+
* Returns all components that are both present on this entity
|
|
466
|
+
* and supported by the API.
|
|
467
|
+
*/
|
|
468
|
+
getComponents(): minecraftserver.IEntityComponent[];
|
|
469
|
+
/**
|
|
470
|
+
* @remarks
|
|
471
|
+
* Returns a property value.
|
|
472
|
+
* @param identifier
|
|
473
|
+
* @returns
|
|
474
|
+
* Returns the value for the property, or undefined if the
|
|
475
|
+
* property has not been set.
|
|
476
|
+
* @throws This function can throw errors.
|
|
477
|
+
*/
|
|
478
|
+
getDynamicProperty(identifier: string): boolean | number | string;
|
|
479
|
+
/**
|
|
480
|
+
* @remarks
|
|
481
|
+
* Returns the effect for the specified EffectType on the
|
|
482
|
+
* entity, or undefined if the effect is not present.
|
|
483
|
+
* @param effectType
|
|
484
|
+
* @returns
|
|
485
|
+
* Effect object for the specified effect, or undefined if the
|
|
486
|
+
* effect is not present.
|
|
487
|
+
* @throws This function can throw errors.
|
|
488
|
+
*/
|
|
489
|
+
getEffect(effectType: minecraftserver.EffectType): minecraftserver.Effect;
|
|
490
|
+
/**
|
|
491
|
+
* @remarks
|
|
492
|
+
* Gets the first entity that intersects with the vector of the
|
|
493
|
+
* view of this entity.
|
|
494
|
+
* @param options
|
|
495
|
+
* Additional options for processing this raycast query.
|
|
496
|
+
* @throws This function can throw errors.
|
|
497
|
+
*/
|
|
498
|
+
getEntitiesFromViewVector(options?: minecraftserver.EntityRaycastOptions): minecraftserver.Entity[];
|
|
499
|
+
/**
|
|
500
|
+
* @remarks
|
|
501
|
+
* Gets the current item cooldown time for a particular
|
|
502
|
+
* cooldown category.
|
|
503
|
+
* @param itemCategory
|
|
504
|
+
* Specifies the cooldown category to retrieve the current
|
|
505
|
+
* cooldown for.
|
|
506
|
+
* @throws This function can throw errors.
|
|
507
|
+
*/
|
|
508
|
+
getItemCooldown(itemCategory: string): number;
|
|
509
|
+
/**
|
|
510
|
+
* @remarks
|
|
511
|
+
* Returns all tags associated with this simulated player.
|
|
512
|
+
* @throws This function can throw errors.
|
|
513
|
+
*/
|
|
514
|
+
getTags(): string[];
|
|
515
|
+
/**
|
|
516
|
+
* @remarks
|
|
517
|
+
* Gives the simulated player a particular item stack.
|
|
518
|
+
* @param itemStack
|
|
519
|
+
* Item to give.
|
|
520
|
+
* @param selectSlot
|
|
521
|
+
* Whether to set the selected slot once given.
|
|
522
|
+
* @throws This function can throw errors.
|
|
523
|
+
*/
|
|
524
|
+
giveItem(itemStack: minecraftserver.ItemStack, selectSlot?: boolean): boolean;
|
|
525
|
+
/**
|
|
526
|
+
* @remarks
|
|
527
|
+
* Returns true if the specified component is present on this
|
|
528
|
+
* entity.
|
|
529
|
+
* @param componentId
|
|
530
|
+
* The identifier of the component (e.g., 'minecraft:rideable')
|
|
531
|
+
* to retrieve. If no namespace prefix is specified,
|
|
532
|
+
* 'minecraft:' is assumed.
|
|
533
|
+
*/
|
|
534
|
+
hasComponent(componentId: string): boolean;
|
|
535
|
+
/**
|
|
536
|
+
* @remarks
|
|
537
|
+
* Tests whether a simulated player has a particular tag.
|
|
538
|
+
* @param tag
|
|
539
|
+
* Identifier of the tag to test for.
|
|
540
|
+
* @throws This function can throw errors.
|
|
541
|
+
*/
|
|
542
|
+
hasTag(tag: string): boolean;
|
|
543
|
+
/**
|
|
544
|
+
* @remarks
|
|
545
|
+
* Performs a raycast from the player’s head and interacts with
|
|
546
|
+
* the first intersected block or entity. Returns true if the
|
|
547
|
+
* interaction was successful. Maximum range is 6 blocks.
|
|
548
|
+
* @throws This function can throw errors.
|
|
549
|
+
*/
|
|
550
|
+
interact(): boolean;
|
|
551
|
+
/**
|
|
552
|
+
* @remarks
|
|
553
|
+
* Causes the simulated player to interact with a block. The
|
|
554
|
+
* block at the specified block location must be solid. Returns
|
|
555
|
+
* true if the interaction was performed.
|
|
556
|
+
* @param blockLocation
|
|
557
|
+
* Location of the block to interact with.
|
|
558
|
+
* @param direction
|
|
559
|
+
* Direction to place the specified item within.
|
|
560
|
+
* @throws This function can throw errors.
|
|
561
|
+
*/
|
|
562
|
+
interactWithBlock(blockLocation: minecraftserver.BlockLocation, direction?: minecraftserver.Direction): boolean;
|
|
563
|
+
/**
|
|
564
|
+
* @remarks
|
|
565
|
+
* Causes the simulated player to interact with a mob. Returns
|
|
566
|
+
* true if the interaction was performed.
|
|
567
|
+
* @param entity
|
|
568
|
+
* Entity to interact with.
|
|
569
|
+
* @throws This function can throw errors.
|
|
570
|
+
*/
|
|
571
|
+
interactWithEntity(entity: minecraftserver.Entity): boolean;
|
|
572
|
+
/**
|
|
573
|
+
* @remarks
|
|
574
|
+
* Causes the simulated player to jump.
|
|
575
|
+
* @returns
|
|
576
|
+
* True if a jump was performed.
|
|
577
|
+
* @throws This function can throw errors.
|
|
578
|
+
*/
|
|
579
|
+
jump(): boolean;
|
|
580
|
+
/**
|
|
581
|
+
* @remarks
|
|
582
|
+
* Kills this entity. The entity will drop loot as normal.
|
|
583
|
+
* @throws This function can throw errors.
|
|
584
|
+
*/
|
|
585
|
+
kill(): void;
|
|
586
|
+
/**
|
|
587
|
+
* @remarks
|
|
588
|
+
* Rotates the simulated player's head/body to look at the
|
|
589
|
+
* given block location.
|
|
590
|
+
* @param blockLocation
|
|
591
|
+
* @throws This function can throw errors.
|
|
592
|
+
*/
|
|
593
|
+
lookAtBlock(blockLocation: minecraftserver.BlockLocation): void;
|
|
594
|
+
/**
|
|
595
|
+
* @remarks
|
|
596
|
+
* Rotates the simulated player's head/body to look at the
|
|
597
|
+
* given entity.
|
|
598
|
+
* @param entity
|
|
599
|
+
* @throws This function can throw errors.
|
|
600
|
+
*/
|
|
601
|
+
lookAtEntity(entity: minecraftserver.Entity): void;
|
|
602
|
+
/**
|
|
603
|
+
* @remarks
|
|
604
|
+
* Rotates the simulated player's head/body to look at the
|
|
605
|
+
* given location.
|
|
606
|
+
* @param location
|
|
607
|
+
* @throws This function can throw errors.
|
|
608
|
+
*/
|
|
609
|
+
lookAtLocation(location: minecraftserver.Location): void;
|
|
610
|
+
/**
|
|
611
|
+
* @remarks
|
|
612
|
+
* Orders the simulated player to walk in the given direction
|
|
613
|
+
* relative to the GameTest.
|
|
614
|
+
* @param westEast
|
|
615
|
+
* @param northSouth
|
|
616
|
+
* @param speed
|
|
617
|
+
* @throws This function can throw errors.
|
|
618
|
+
*/
|
|
619
|
+
move(westEast: number, northSouth: number, speed?: number): void;
|
|
620
|
+
/**
|
|
621
|
+
* @remarks
|
|
622
|
+
* Orders the simulated player to walk in the given direction
|
|
623
|
+
* relative to the player's current rotation.
|
|
624
|
+
* @param leftRight
|
|
625
|
+
* @param backwardForward
|
|
626
|
+
* @param speed
|
|
627
|
+
* @throws This function can throw errors.
|
|
628
|
+
*/
|
|
629
|
+
moveRelative(leftRight: number, backwardForward: number, speed?: number): void;
|
|
630
|
+
/**
|
|
631
|
+
* @remarks
|
|
632
|
+
* Orders the simulated player to move to the given block
|
|
633
|
+
* location in a straight line. If a move or navigation is
|
|
634
|
+
* already playing, this will override the last
|
|
635
|
+
* move/navigation.
|
|
636
|
+
* @param blockLocation
|
|
637
|
+
* @param speed
|
|
638
|
+
* @throws This function can throw errors.
|
|
639
|
+
*/
|
|
640
|
+
moveToBlock(blockLocation: minecraftserver.BlockLocation, speed?: number): void;
|
|
641
|
+
/**
|
|
642
|
+
* @remarks
|
|
643
|
+
* Orders the simulated player to move to the given location in
|
|
644
|
+
* a straight line. If a move or navigation is already playing,
|
|
645
|
+
* this will override the last move/navigation.
|
|
646
|
+
* @param location
|
|
647
|
+
* @param speed
|
|
648
|
+
* @throws This function can throw errors.
|
|
649
|
+
*/
|
|
650
|
+
moveToLocation(location: minecraftserver.Location, speed?: number): void;
|
|
651
|
+
/**
|
|
652
|
+
* @remarks
|
|
653
|
+
* Orders the simulated player to move to a specific block
|
|
654
|
+
* location using navigation. If a move or navigation is
|
|
655
|
+
* already playing, this will override the last move/walk. Note
|
|
656
|
+
* that if the simulated player gets stuck, that simulated
|
|
657
|
+
* player will stop. The player must be touching the ground in
|
|
658
|
+
* order to start navigation.
|
|
659
|
+
* @param blockLocation
|
|
660
|
+
* @param speed
|
|
661
|
+
* @throws This function can throw errors.
|
|
662
|
+
*/
|
|
663
|
+
navigateToBlock(blockLocation: minecraftserver.BlockLocation, speed?: number): minecraftserver.NavigationResult;
|
|
664
|
+
/**
|
|
665
|
+
* @remarks
|
|
666
|
+
* Will use navigation to follow the selected entity to within
|
|
667
|
+
* a one block radius. If a move or navigation is already
|
|
668
|
+
* playing, this will override the last move/navigation.
|
|
669
|
+
* @param entity
|
|
670
|
+
* @param speed
|
|
671
|
+
* @throws This function can throw errors.
|
|
672
|
+
*/
|
|
673
|
+
navigateToEntity(entity: minecraftserver.Entity, speed?: number): minecraftserver.NavigationResult;
|
|
674
|
+
/**
|
|
675
|
+
* @remarks
|
|
676
|
+
* Orders the simulated player to move to a specific location
|
|
677
|
+
* using navigation. If a move or navigation is already
|
|
678
|
+
* playing, this will override the last move/walk. Note that if
|
|
679
|
+
* the simulated player gets stuck, that simulated player will
|
|
680
|
+
* stop. The player must be touching the ground in order to
|
|
681
|
+
* start navigation.
|
|
682
|
+
* @param location
|
|
683
|
+
* @param speed
|
|
684
|
+
* @throws This function can throw errors.
|
|
685
|
+
*/
|
|
686
|
+
navigateToLocation(location: minecraftserver.Location, speed?: number): minecraftserver.NavigationResult;
|
|
687
|
+
/**
|
|
688
|
+
* @remarks
|
|
689
|
+
* Use navigation to follow the route provided via the
|
|
690
|
+
* locations parameter. If a move or navigation is already
|
|
691
|
+
* playing, this will override the last move/navigation.
|
|
692
|
+
* @param locations
|
|
693
|
+
* A list of locations to use for routing.
|
|
694
|
+
* @param speed
|
|
695
|
+
* Net speed to use for doing the navigation.
|
|
696
|
+
* @throws This function can throw errors.
|
|
697
|
+
*/
|
|
698
|
+
navigateToLocations(locations: minecraftserver.Location[], speed?: number): void;
|
|
699
|
+
/**
|
|
700
|
+
* @remarks
|
|
701
|
+
* This method is inherited from Player, but is inoperative in
|
|
702
|
+
* the case of a SimulatedPlayer.
|
|
703
|
+
* @param soundID
|
|
704
|
+
* Identifier of the sound to play.
|
|
705
|
+
* @param soundOptions
|
|
706
|
+
* Additional optional options for the sound.
|
|
707
|
+
* @throws This function can throw errors.
|
|
708
|
+
*/
|
|
709
|
+
playSound(soundID: string, soundOptions?: minecraftserver.SoundOptions): void;
|
|
710
|
+
postClientMessage(id: string, value: string): void;
|
|
711
|
+
/**
|
|
712
|
+
* @remarks
|
|
713
|
+
* Removes a specified property.
|
|
714
|
+
* @param identifier
|
|
715
|
+
* @throws This function can throw errors.
|
|
716
|
+
*/
|
|
717
|
+
removeDynamicProperty(identifier: string): boolean;
|
|
718
|
+
/**
|
|
719
|
+
* @remarks
|
|
720
|
+
* Removes a specified tag from a simulated player.
|
|
721
|
+
* @param tag
|
|
722
|
+
* Content of the tag to remove.
|
|
723
|
+
* @throws This function can throw errors.
|
|
724
|
+
*/
|
|
725
|
+
removeTag(tag: string): boolean;
|
|
726
|
+
/**
|
|
727
|
+
* @remarks
|
|
728
|
+
* Causes the simulated player to turn by the provided angle,
|
|
729
|
+
* relative to the player's current rotation.
|
|
730
|
+
* @param angleInDegrees
|
|
731
|
+
* @throws This function can throw errors.
|
|
732
|
+
*/
|
|
733
|
+
rotateBody(angleInDegrees: number): void;
|
|
734
|
+
/**
|
|
735
|
+
* @remarks
|
|
736
|
+
* Runs a particular command from the context of this simulated
|
|
737
|
+
* player.
|
|
738
|
+
* @param commandString
|
|
739
|
+
* Command to run. Note that command strings should not start
|
|
740
|
+
* with slash.
|
|
741
|
+
* @returns
|
|
742
|
+
* For commands that return data, returns a JSON structure with
|
|
743
|
+
* command response values.
|
|
744
|
+
* @throws This function can throw errors.
|
|
745
|
+
* @example commands.js
|
|
746
|
+
* ```typescript
|
|
747
|
+
* player.runCommand("say You got a new high score!");
|
|
748
|
+
* player.runCommand("scoreboard players set @s score 10");
|
|
749
|
+
*
|
|
750
|
+
* ```
|
|
751
|
+
*/
|
|
752
|
+
runCommand(commandString: string): any;
|
|
753
|
+
/**
|
|
754
|
+
* @remarks
|
|
755
|
+
* Runs a particular command asynchronously from the context of
|
|
756
|
+
* this entity. Where possible, running a command
|
|
757
|
+
* asynchronously is recommended, especially for long running
|
|
758
|
+
* operations.
|
|
759
|
+
* @param commandString
|
|
760
|
+
* Command to run. Note that command strings should not start
|
|
761
|
+
* with slash.
|
|
762
|
+
* @returns
|
|
763
|
+
* For commands that return data, returns a JSON structure with
|
|
764
|
+
* command response values.
|
|
765
|
+
* @throws This function can throw errors.
|
|
766
|
+
*/
|
|
767
|
+
runCommandAsync(commandString: string): Promise<minecraftserver.CommandResult>;
|
|
768
|
+
sendTestSkin(geoData: string, base64ImageData: string, skinResourcePatch: string): void;
|
|
769
|
+
/**
|
|
770
|
+
* @remarks
|
|
771
|
+
* Causes the simulated player to turn to face the provided
|
|
772
|
+
* angle, relative to the GameTest.
|
|
773
|
+
* @param angleInDegrees
|
|
774
|
+
* @throws This function can throw errors.
|
|
775
|
+
*/
|
|
776
|
+
setBodyRotation(angleInDegrees: number): void;
|
|
777
|
+
/**
|
|
778
|
+
* @remarks
|
|
779
|
+
* Sets a specified property to a value.
|
|
780
|
+
* @param identifier
|
|
781
|
+
* @param value
|
|
782
|
+
* Data value of the property to set.
|
|
783
|
+
* @throws This function can throw errors.
|
|
784
|
+
*/
|
|
785
|
+
setDynamicProperty(identifier: string, value: boolean | number | string): void;
|
|
786
|
+
/**
|
|
787
|
+
* @remarks
|
|
788
|
+
* Sets the game mode that the simulated player is operating
|
|
789
|
+
* under.
|
|
790
|
+
* @param gameMode
|
|
791
|
+
* Game mode to set.
|
|
792
|
+
* @throws This function can throw errors.
|
|
793
|
+
*/
|
|
794
|
+
setGameMode(gameMode: minecraftserver.GameMode): void;
|
|
795
|
+
/**
|
|
796
|
+
* @remarks
|
|
797
|
+
* Sets a particular item for the simulated player.
|
|
798
|
+
* @param itemStack
|
|
799
|
+
* Item to set.
|
|
800
|
+
* @param slot
|
|
801
|
+
* Slot to place the given item in.
|
|
802
|
+
* @param selectSlot
|
|
803
|
+
* Whether to set the selected slot once set.
|
|
804
|
+
* @throws This function can throw errors.
|
|
805
|
+
*/
|
|
806
|
+
setItem(itemStack: minecraftserver.ItemStack, slot: number, selectSlot?: boolean): boolean;
|
|
807
|
+
/**
|
|
808
|
+
* @remarks
|
|
809
|
+
* Sets the main rotation of the entity.
|
|
810
|
+
* @param degreesX
|
|
811
|
+
* @param degreesY
|
|
812
|
+
* @throws This function can throw errors.
|
|
813
|
+
*/
|
|
814
|
+
setRotation(degreesX: number, degreesY: number): void;
|
|
815
|
+
/**
|
|
816
|
+
* @remarks
|
|
817
|
+
* Sets a velocity for the entity to move with.
|
|
818
|
+
* @param velocity
|
|
819
|
+
* X/Y/Z components of the velocity.
|
|
820
|
+
* @throws This function can throw errors.
|
|
821
|
+
*/
|
|
822
|
+
setVelocity(velocity: minecraftserver.IVec3): void;
|
|
823
|
+
/**
|
|
824
|
+
* @remarks
|
|
825
|
+
* Sets the item cooldown time for a particular cooldown
|
|
826
|
+
* category.
|
|
827
|
+
* @param itemCategory
|
|
828
|
+
* Specifies the cooldown category to retrieve the current
|
|
829
|
+
* cooldown for.
|
|
830
|
+
* @param tickDuration
|
|
831
|
+
* Duration in ticks of the item cooldown.
|
|
832
|
+
* @throws This function can throw errors.
|
|
833
|
+
*/
|
|
834
|
+
startItemCooldown(itemCategory: string, tickDuration: number): void;
|
|
835
|
+
/**
|
|
836
|
+
* @remarks
|
|
837
|
+
* Stops destroying the block that is currently being hit.
|
|
838
|
+
* @throws This function can throw errors.
|
|
839
|
+
*/
|
|
840
|
+
stopBreakingBlock(): void;
|
|
841
|
+
/**
|
|
842
|
+
* @remarks
|
|
843
|
+
* Stops interacting with entities or blocks.
|
|
844
|
+
* @throws This function can throw errors.
|
|
845
|
+
*/
|
|
846
|
+
stopInteracting(): void;
|
|
847
|
+
/**
|
|
848
|
+
* @remarks
|
|
849
|
+
* Stops moving/walking/following if the simulated player is
|
|
850
|
+
* moving.
|
|
851
|
+
* @throws This function can throw errors.
|
|
852
|
+
*/
|
|
853
|
+
stopMoving(): void;
|
|
854
|
+
/**
|
|
855
|
+
* @remarks
|
|
856
|
+
* Stops using the currently active item.
|
|
857
|
+
* @throws This function can throw errors.
|
|
858
|
+
*/
|
|
859
|
+
stopUsingItem(): void;
|
|
860
|
+
/**
|
|
861
|
+
* @remarks
|
|
862
|
+
* Teleports the selected player to a new location
|
|
863
|
+
* @param location
|
|
864
|
+
* New location for the player.
|
|
865
|
+
* @param dimension
|
|
866
|
+
* Dimension to move the selected player to.
|
|
867
|
+
* @param xRotation
|
|
868
|
+
* X rotation of the player after teleportation.
|
|
869
|
+
* @param yRotation
|
|
870
|
+
* Y rotation of the player after teleportation.
|
|
871
|
+
* @param keepVelocity
|
|
872
|
+
* @throws This function can throw errors.
|
|
873
|
+
*/
|
|
874
|
+
teleport(
|
|
875
|
+
location: minecraftserver.IVec3,
|
|
876
|
+
dimension: minecraftserver.Dimension,
|
|
877
|
+
xRotation: number,
|
|
878
|
+
yRotation: number,
|
|
879
|
+
keepVelocity?: boolean,
|
|
880
|
+
): void;
|
|
881
|
+
/**
|
|
882
|
+
* @remarks
|
|
883
|
+
* Teleports the selected player to a new location, and will
|
|
884
|
+
* have the player facing a specified location.
|
|
885
|
+
* @param location
|
|
886
|
+
* New location for the player.
|
|
887
|
+
* @param dimension
|
|
888
|
+
* Dimension to move the selected player to.
|
|
889
|
+
* @param facingLocation
|
|
890
|
+
* Location that this player will be facing.
|
|
891
|
+
* @param keepVelocity
|
|
892
|
+
* @throws This function can throw errors.
|
|
893
|
+
*/
|
|
894
|
+
teleportFacing(
|
|
895
|
+
location: minecraftserver.IVec3,
|
|
896
|
+
dimension: minecraftserver.Dimension,
|
|
897
|
+
facingLocation: minecraftserver.IVec3,
|
|
898
|
+
keepVelocity?: boolean,
|
|
899
|
+
): void;
|
|
900
|
+
/**
|
|
901
|
+
* @remarks
|
|
902
|
+
* For simulated players, this API is effectively a no-op as
|
|
903
|
+
* simulated players do not have a connected client.
|
|
904
|
+
* @param message
|
|
905
|
+
* @throws This function can throw errors.
|
|
906
|
+
*/
|
|
907
|
+
tell(message: minecraftserver.IRawMessage | string): void;
|
|
908
|
+
/**
|
|
909
|
+
* @remarks
|
|
910
|
+
* Triggers an entity type event. For every entity, a number of
|
|
911
|
+
* events are defined in an entities' definition for key entity
|
|
912
|
+
* behaviors; for example, creepers have a
|
|
913
|
+
* minecraft:start_exploding type event.
|
|
914
|
+
* @param eventName
|
|
915
|
+
* Name of the entity type event to trigger. If a namespace is
|
|
916
|
+
* not specified, minecraft: is assumed.
|
|
917
|
+
* @throws This function can throw errors.
|
|
918
|
+
*/
|
|
919
|
+
triggerEvent(eventName: string): void;
|
|
920
|
+
/**
|
|
921
|
+
* @remarks
|
|
922
|
+
* Causes the simulated player to use an item. Does not consume
|
|
923
|
+
* the item. Returns false if the item is on cooldown.
|
|
924
|
+
* @param itemStack
|
|
925
|
+
* Item to use.
|
|
926
|
+
* @throws This function can throw errors.
|
|
927
|
+
*/
|
|
928
|
+
useItem(itemStack: minecraftserver.ItemStack): boolean;
|
|
929
|
+
/**
|
|
930
|
+
* @remarks
|
|
931
|
+
* Causes the simulated player to hold and use an item in their
|
|
932
|
+
* inventory.
|
|
933
|
+
* @param slot
|
|
934
|
+
* Index of the inventory slot.
|
|
935
|
+
* @throws This function can throw errors.
|
|
936
|
+
*/
|
|
937
|
+
useItemInSlot(slot: number): boolean;
|
|
938
|
+
/**
|
|
939
|
+
* @remarks
|
|
940
|
+
* Causes the simulated player to use an item in their
|
|
941
|
+
* inventory on a block. The block at the specified block
|
|
942
|
+
* location must be solid. Returns true if the item was used.
|
|
943
|
+
* @param slot
|
|
944
|
+
* Index of the slot to use.
|
|
945
|
+
* @param blockLocation
|
|
946
|
+
* Location to use the item upon.
|
|
947
|
+
* @param direction
|
|
948
|
+
* Direction to place the specified item within.
|
|
949
|
+
* @param faceLocationX
|
|
950
|
+
* Block-face-relative X position where to place the item.
|
|
951
|
+
* @param faceLocationY
|
|
952
|
+
* Block-face-relative Y position where to place the item.
|
|
953
|
+
* @throws This function can throw errors.
|
|
954
|
+
*/
|
|
955
|
+
useItemInSlotOnBlock(
|
|
956
|
+
slot: number,
|
|
957
|
+
blockLocation: minecraftserver.BlockLocation,
|
|
958
|
+
direction?: minecraftserver.Direction,
|
|
959
|
+
faceLocationX?: number,
|
|
960
|
+
faceLocationY?: number,
|
|
961
|
+
): boolean;
|
|
962
|
+
/**
|
|
963
|
+
* @remarks
|
|
964
|
+
* Causes the simulated player to use an item on a block. The
|
|
965
|
+
* block at the specified block location must be solid. Returns
|
|
966
|
+
* true if the item was used.
|
|
967
|
+
* @param itemStack
|
|
968
|
+
* Item to use.
|
|
969
|
+
* @param blockLocation
|
|
970
|
+
* Location to use the item upon.
|
|
971
|
+
* @param direction
|
|
972
|
+
* Direction to place the specified item within.
|
|
973
|
+
* @param faceLocationX
|
|
974
|
+
* Block-face-relative X position where to place the item.
|
|
975
|
+
* @param faceLocationY
|
|
976
|
+
* Block-face-relative Y position where to place the item.
|
|
977
|
+
* @throws This function can throw errors.
|
|
978
|
+
*/
|
|
979
|
+
useItemOnBlock(
|
|
980
|
+
itemStack: minecraftserver.ItemStack,
|
|
981
|
+
blockLocation: minecraftserver.BlockLocation,
|
|
982
|
+
direction?: minecraftserver.Direction,
|
|
983
|
+
faceLocationX?: number,
|
|
984
|
+
faceLocationY?: number,
|
|
985
|
+
): boolean;
|
|
986
|
+
protected constructor();
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* These well-known tags can be used to classify different
|
|
990
|
+
* tests into suites to run.
|
|
991
|
+
*/
|
|
992
|
+
// tslint:disable-next-line:no-unnecessary-class
|
|
993
|
+
export class Tags {
|
|
994
|
+
/**
|
|
995
|
+
* Indicates that the tagged test should be a part of all
|
|
996
|
+
* suites.
|
|
997
|
+
*/
|
|
998
|
+
static readonly suiteAll = 'suite:all';
|
|
999
|
+
/**
|
|
1000
|
+
* Indicates that the tagged test should be a part of an
|
|
1001
|
+
* internal (debug) test suite.
|
|
1002
|
+
*/
|
|
1003
|
+
static readonly suiteDebug = 'suite:debug';
|
|
1004
|
+
/**
|
|
1005
|
+
* Indicates that the tagged test should be a part of the
|
|
1006
|
+
* default test suite.
|
|
1007
|
+
*/
|
|
1008
|
+
static readonly suiteDefault = 'suite:default';
|
|
1009
|
+
/**
|
|
1010
|
+
* Indicates that the tagged test should be a part of a suite
|
|
1011
|
+
* of disabled tests.
|
|
1012
|
+
*/
|
|
1013
|
+
static readonly suiteDisabled = 'suite:disabled';
|
|
1014
|
+
protected constructor();
|
|
1015
|
+
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Main class for GameTest functions, with helpers and data for
|
|
1018
|
+
* manipulating the respective test. Note that all methods of
|
|
1019
|
+
* this class expect BlockLocations and Locations relative to
|
|
1020
|
+
* the GameTest structure block.
|
|
1021
|
+
*/
|
|
1022
|
+
export class Test {
|
|
1023
|
+
/**
|
|
1024
|
+
* @remarks
|
|
1025
|
+
* Tests that the condition specified in _condition_ is true.
|
|
1026
|
+
* If not, an error with the specified _message_ is thrown.
|
|
1027
|
+
* @param condition
|
|
1028
|
+
* Expression of the condition to evaluate.
|
|
1029
|
+
* @param message
|
|
1030
|
+
* Message that is passed if the _condition_ does not evaluate
|
|
1031
|
+
* to true.
|
|
1032
|
+
* @throws This function can throw errors.
|
|
1033
|
+
*/
|
|
1034
|
+
assert(condition: boolean, message: string): void;
|
|
1035
|
+
/**
|
|
1036
|
+
* @remarks
|
|
1037
|
+
* Tests that a block of the specified type is present at the
|
|
1038
|
+
* specified location. If it is not, an exception is thrown.
|
|
1039
|
+
* @param blockType
|
|
1040
|
+
* Expected block type.
|
|
1041
|
+
* @param blockLocation
|
|
1042
|
+
* Location of the block to test at.
|
|
1043
|
+
* @param isPresent
|
|
1044
|
+
* If true, this function tests whether a block of the
|
|
1045
|
+
* specified type is at the location. If false, tests that a
|
|
1046
|
+
* block of the specified type is not present.
|
|
1047
|
+
* @throws This function can throw errors.
|
|
1048
|
+
*/
|
|
1049
|
+
assertBlockPresent(
|
|
1050
|
+
blockType: minecraftserver.BlockType,
|
|
1051
|
+
blockLocation: minecraftserver.BlockLocation,
|
|
1052
|
+
isPresent?: boolean,
|
|
1053
|
+
): void;
|
|
1054
|
+
/**
|
|
1055
|
+
* @remarks
|
|
1056
|
+
* Tests that a block has a particular state value at the
|
|
1057
|
+
* specified location. If it does not have that state value, an
|
|
1058
|
+
* exception is thrown.
|
|
1059
|
+
* @param blockLocation
|
|
1060
|
+
* Location of the block to test at.
|
|
1061
|
+
* @param callback
|
|
1062
|
+
* Callback function that contains additional tests based on
|
|
1063
|
+
* the block at the specified location.
|
|
1064
|
+
* @throws This function can throw errors.
|
|
1065
|
+
* @example testIfButtonNotPressed.js
|
|
1066
|
+
* ```typescript
|
|
1067
|
+
* test.assertBlockState(buttonPos, (block) => {
|
|
1068
|
+
* return block.permutation.getProperty("button_pressed_bit") == 0;
|
|
1069
|
+
* });
|
|
1070
|
+
*
|
|
1071
|
+
* ```
|
|
1072
|
+
*/
|
|
1073
|
+
assertBlockState(
|
|
1074
|
+
blockLocation: minecraftserver.BlockLocation,
|
|
1075
|
+
callback: (arg: minecraftserver.Block) => boolean,
|
|
1076
|
+
): void;
|
|
1077
|
+
/**
|
|
1078
|
+
* @remarks
|
|
1079
|
+
* Tests that an entity can reach a particular location.
|
|
1080
|
+
* Depending on the value of canReach, throws an exception if
|
|
1081
|
+
* the condition is not met.
|
|
1082
|
+
* @param mob
|
|
1083
|
+
* Entity that you wish to test the location against.
|
|
1084
|
+
* @param blockLocation
|
|
1085
|
+
* Structure-relative location to test whether the specified
|
|
1086
|
+
* mob can reach.
|
|
1087
|
+
* @param canReach
|
|
1088
|
+
* If true, tests whether the mob can reach the location. If
|
|
1089
|
+
* false, tests whether the mob is not able to reach the
|
|
1090
|
+
* location.
|
|
1091
|
+
* @throws This function can throw errors.
|
|
1092
|
+
*/
|
|
1093
|
+
assertCanReachLocation(
|
|
1094
|
+
mob: minecraftserver.Entity,
|
|
1095
|
+
blockLocation: minecraftserver.BlockLocation,
|
|
1096
|
+
canReach?: boolean,
|
|
1097
|
+
): void;
|
|
1098
|
+
/**
|
|
1099
|
+
* @remarks
|
|
1100
|
+
* Tests that a container (e.g., a chest) at the specified
|
|
1101
|
+
* location contains a specified of item stack. If not, an
|
|
1102
|
+
* error is thrown.
|
|
1103
|
+
* @param itemStack
|
|
1104
|
+
* Represents the type of item to check for. The specified
|
|
1105
|
+
* container must contain at least 1 item matching the item
|
|
1106
|
+
* type defined in _itemStack_.
|
|
1107
|
+
* @param blockLocation
|
|
1108
|
+
* Location of the block with a container (for example, a
|
|
1109
|
+
* chest) to test the contents of.
|
|
1110
|
+
* @throws This function can throw errors.
|
|
1111
|
+
*/
|
|
1112
|
+
assertContainerContains(itemStack: minecraftserver.ItemStack, blockLocation: minecraftserver.BlockLocation): void;
|
|
1113
|
+
/**
|
|
1114
|
+
* @remarks
|
|
1115
|
+
* Tests that a container (e.g., a chest) at the specified
|
|
1116
|
+
* location is empty. If not, an error is thrown.
|
|
1117
|
+
* @param blockLocation
|
|
1118
|
+
* Location of the block with a container (for example, a
|
|
1119
|
+
* chest) to test is empty of contents.
|
|
1120
|
+
* @throws This function can throw errors.
|
|
1121
|
+
*/
|
|
1122
|
+
assertContainerEmpty(blockLocation: minecraftserver.BlockLocation): void;
|
|
1123
|
+
/**
|
|
1124
|
+
* @remarks
|
|
1125
|
+
* Tests that an entity has a specific piece of armor equipped.
|
|
1126
|
+
* If not, an error is thrown.
|
|
1127
|
+
* @param entityTypeIdentifier
|
|
1128
|
+
* Identifier of the entity to match (e.g.,
|
|
1129
|
+
* 'minecraft:skeleton').
|
|
1130
|
+
* @param armorSlot
|
|
1131
|
+
* Container slot index to test.
|
|
1132
|
+
* @param armorName
|
|
1133
|
+
* Name of the armor to look for.
|
|
1134
|
+
* @param armorData
|
|
1135
|
+
* Data value integer to look for.
|
|
1136
|
+
* @param blockLocation
|
|
1137
|
+
* Location of the entity with armor to test for.
|
|
1138
|
+
* @param hasArmor
|
|
1139
|
+
* Whether or not the entity is expected to have the specified
|
|
1140
|
+
* armor equipped.
|
|
1141
|
+
* @throws This function can throw errors.
|
|
1142
|
+
* @example horseArmorTest.js
|
|
1143
|
+
* ```typescript
|
|
1144
|
+
* test.assertEntityHasArmor("minecraft:horse", armorSlotTorso, "diamond_horse_armor", 0, horseLocation, true);
|
|
1145
|
+
*
|
|
1146
|
+
* ```
|
|
1147
|
+
*/
|
|
1148
|
+
assertEntityHasArmor(
|
|
1149
|
+
entityTypeIdentifier: string,
|
|
1150
|
+
armorSlot: number,
|
|
1151
|
+
armorName: string,
|
|
1152
|
+
armorData: number,
|
|
1153
|
+
blockLocation: minecraftserver.BlockLocation,
|
|
1154
|
+
hasArmor?: boolean,
|
|
1155
|
+
): void;
|
|
1156
|
+
/**
|
|
1157
|
+
* @remarks
|
|
1158
|
+
* Tests that an entity has a particular component. If not, an
|
|
1159
|
+
* exception is thrown.
|
|
1160
|
+
* @param entityTypeIdentifier
|
|
1161
|
+
* Identifier of the specified entity (e.g.,
|
|
1162
|
+
* 'minecraft:skeleton'). If the namespace is not specified,
|
|
1163
|
+
* 'minecraft:' is assumed.
|
|
1164
|
+
* @param componentIdentifier
|
|
1165
|
+
* Identifier of the component to check for. If the namespace
|
|
1166
|
+
* is not specified, 'minecraft:' is assumed.
|
|
1167
|
+
* @param blockLocation
|
|
1168
|
+
* Location of the block with a container (for example, a
|
|
1169
|
+
* chest.)
|
|
1170
|
+
* @param hasComponent
|
|
1171
|
+
* Determines whether to test that the component exists, or
|
|
1172
|
+
* does not.
|
|
1173
|
+
* @throws This function can throw errors.
|
|
1174
|
+
* @example sheepShearedTest.js
|
|
1175
|
+
* ```typescript
|
|
1176
|
+
* test.assertEntityHasComponent("minecraft:sheep", "minecraft:is_sheared", entityLoc, false);
|
|
1177
|
+
*
|
|
1178
|
+
* ```
|
|
1179
|
+
*/
|
|
1180
|
+
assertEntityHasComponent(
|
|
1181
|
+
entityTypeIdentifier: string,
|
|
1182
|
+
componentIdentifier: string,
|
|
1183
|
+
blockLocation: minecraftserver.BlockLocation,
|
|
1184
|
+
hasComponent?: boolean,
|
|
1185
|
+
): void;
|
|
1186
|
+
/**
|
|
1187
|
+
* @remarks
|
|
1188
|
+
* Depending on the value for isPresent, tests that a
|
|
1189
|
+
* particular entity is present or not present at the specified
|
|
1190
|
+
* location. Depending on the value of isPresent, if the entity
|
|
1191
|
+
* is found or not found, an error is thrown.
|
|
1192
|
+
* @param entity
|
|
1193
|
+
* Specific entity to test for.
|
|
1194
|
+
* @param blockLocation
|
|
1195
|
+
* Location of the entity to test for.
|
|
1196
|
+
* @param isPresent
|
|
1197
|
+
* Whether to test that an entity is present or not present at
|
|
1198
|
+
* the specified location.
|
|
1199
|
+
* @throws This function can throw errors.
|
|
1200
|
+
*/
|
|
1201
|
+
assertEntityInstancePresent(
|
|
1202
|
+
entity: minecraftserver.Entity,
|
|
1203
|
+
blockLocation: minecraftserver.BlockLocation,
|
|
1204
|
+
isPresent?: boolean,
|
|
1205
|
+
): void;
|
|
1206
|
+
/**
|
|
1207
|
+
* @remarks
|
|
1208
|
+
* Depending on the value of isPresent, tests for the presence
|
|
1209
|
+
* or non-presence of entity of a specified type at a
|
|
1210
|
+
* particular location. If the condition is not met, an
|
|
1211
|
+
* exception is thrown.
|
|
1212
|
+
* @param entityTypeIdentifier
|
|
1213
|
+
* Type of entity to test for (e.g., 'minecraft:skeleton'). If
|
|
1214
|
+
* an entity namespace is not specified, 'minecraft:' is
|
|
1215
|
+
* assumed.
|
|
1216
|
+
* @param blockLocation
|
|
1217
|
+
* Location of the entity to test for.
|
|
1218
|
+
* @param isPresent
|
|
1219
|
+
* If true, this function tests whether an entity of the
|
|
1220
|
+
* specified type is present. If false, tests that an entity of
|
|
1221
|
+
* the specified type is not present.
|
|
1222
|
+
* @throws This function can throw errors.
|
|
1223
|
+
*/
|
|
1224
|
+
assertEntityPresent(
|
|
1225
|
+
entityTypeIdentifier: string,
|
|
1226
|
+
blockLocation: minecraftserver.BlockLocation,
|
|
1227
|
+
isPresent?: boolean,
|
|
1228
|
+
): void;
|
|
1229
|
+
/**
|
|
1230
|
+
* @remarks
|
|
1231
|
+
* Tests that an entity of a specified type is present within
|
|
1232
|
+
* the GameTest area. If not, an exception is thrown.
|
|
1233
|
+
* @param entityTypeIdentifier
|
|
1234
|
+
* Type of entity to test for (e.g., 'minecraft:skeleton'). If
|
|
1235
|
+
* an entity namespace is not specified, 'minecraft:' is
|
|
1236
|
+
* assumed.
|
|
1237
|
+
* @param isPresent
|
|
1238
|
+
* If true, this function tests whether an entity of the
|
|
1239
|
+
* specified type is present in the GameTest area. If false,
|
|
1240
|
+
* tests that an entity of the specified type is not present.
|
|
1241
|
+
* @throws This function can throw errors.
|
|
1242
|
+
* @example simpleMobTest.ts
|
|
1243
|
+
* ```typescript
|
|
1244
|
+
* gt.register("StarterTests", "simpleMobTest", (test: gt.Test) => {
|
|
1245
|
+
* const attackerId = "fox";
|
|
1246
|
+
* const victimId = "chicken";
|
|
1247
|
+
*
|
|
1248
|
+
* test.spawn(attackerId, new mc.BlockLocation(5, 2, 5));
|
|
1249
|
+
* test.spawn(victimId, new mc.BlockLocation(2, 2, 2));
|
|
1250
|
+
*
|
|
1251
|
+
* test.assertEntityPresentInArea(victimId, true);
|
|
1252
|
+
*
|
|
1253
|
+
* test.succeedWhen(() => {
|
|
1254
|
+
* test.assertEntityPresentInArea(victimId, false);
|
|
1255
|
+
* });
|
|
1256
|
+
* })
|
|
1257
|
+
* .maxTicks(400)
|
|
1258
|
+
* .structureName("gametests:mediumglass");
|
|
1259
|
+
* ```
|
|
1260
|
+
*/
|
|
1261
|
+
assertEntityPresentInArea(entityTypeIdentifier: string, isPresent?: boolean): void;
|
|
1262
|
+
/**
|
|
1263
|
+
* @remarks
|
|
1264
|
+
* Tests that an entity (e.g., a skeleton) at the specified
|
|
1265
|
+
* location has a particular piece of data. If not, an error is
|
|
1266
|
+
* thrown.
|
|
1267
|
+
* @param blockLocation
|
|
1268
|
+
* Location of the entity to look for.
|
|
1269
|
+
* @param entityTypeIdentifier
|
|
1270
|
+
* Identifier of the entity (e.g., 'minecraft:skeleton') to
|
|
1271
|
+
* look for. Note if no namespace is specified, 'minecraft:' is
|
|
1272
|
+
* assumed.
|
|
1273
|
+
* @param callback
|
|
1274
|
+
* Callback function where facets of the selected entity can be
|
|
1275
|
+
* tested for. If this callback function returns false or no
|
|
1276
|
+
* entity with the specified identifier is found, an exception
|
|
1277
|
+
* is thrown.
|
|
1278
|
+
* @throws This function can throw errors.
|
|
1279
|
+
* @example villagerEffectTest.js
|
|
1280
|
+
* ```typescript
|
|
1281
|
+
* test.assertEntityState(
|
|
1282
|
+
* villagerPos,
|
|
1283
|
+
* "minecraft:villager_v2",
|
|
1284
|
+
* (entity) => entity.getEffect(MinecraftEffectTypes.regeneration).duration > 120
|
|
1285
|
+
* ); // At least 6 seconds remaining in the villagers' effect
|
|
1286
|
+
*
|
|
1287
|
+
* ```
|
|
1288
|
+
*/
|
|
1289
|
+
assertEntityState(
|
|
1290
|
+
blockLocation: minecraftserver.BlockLocation,
|
|
1291
|
+
entityTypeIdentifier: string,
|
|
1292
|
+
callback: (arg: minecraftserver.Entity) => boolean,
|
|
1293
|
+
): void;
|
|
1294
|
+
/**
|
|
1295
|
+
* @remarks
|
|
1296
|
+
* Depending on the value of isTouching, tests that an entity
|
|
1297
|
+
* of a specified type is touching or connected to another
|
|
1298
|
+
* entity. If the condition is not met, an exception is thrown.
|
|
1299
|
+
* @param entityTypeIdentifier
|
|
1300
|
+
* Type of entity to test for (e.g., 'minecraft:skeleton'). If
|
|
1301
|
+
* an entity namespace is not specified, 'minecraft:' is
|
|
1302
|
+
* assumed.
|
|
1303
|
+
* @param location
|
|
1304
|
+
* Location of the entity to test for.
|
|
1305
|
+
* @param isTouching
|
|
1306
|
+
* If true, this function tests whether the entity is touching
|
|
1307
|
+
* the specified location. If false, tests that an entity is
|
|
1308
|
+
* not testing the specified location.
|
|
1309
|
+
* @throws This function can throw errors.
|
|
1310
|
+
*/
|
|
1311
|
+
assertEntityTouching(entityTypeIdentifier: string, location: minecraftserver.Location, isTouching?: boolean): void;
|
|
1312
|
+
/**
|
|
1313
|
+
* @remarks
|
|
1314
|
+
* Depending on the value of isWaterlogged, tests that a block
|
|
1315
|
+
* at a location contains water. If the condition is not met,
|
|
1316
|
+
* an error is thrown. Pure water blocks are not considered to
|
|
1317
|
+
* be waterlogged.
|
|
1318
|
+
* @param blockLocation
|
|
1319
|
+
* Location of the block to test for.
|
|
1320
|
+
* @param isWaterlogged
|
|
1321
|
+
* Whether to test that the block at _position_ is expected to
|
|
1322
|
+
* be waterlogged.
|
|
1323
|
+
* @throws This function can throw errors.
|
|
1324
|
+
*/
|
|
1325
|
+
assertIsWaterlogged(blockLocation: minecraftserver.BlockLocation, isWaterlogged?: boolean): void;
|
|
1326
|
+
/**
|
|
1327
|
+
* @remarks
|
|
1328
|
+
* Tests that items of a particular type and count are present
|
|
1329
|
+
* within an area. If not, an error is thrown.
|
|
1330
|
+
* @param itemType
|
|
1331
|
+
* Type of item to look for.
|
|
1332
|
+
* @param blockLocation
|
|
1333
|
+
* Location to search around for the specified set of items.
|
|
1334
|
+
* @param searchDistance
|
|
1335
|
+
* Range, in blocks, to aggregate a count of items around. If
|
|
1336
|
+
* 0, will only search the particular block at _position_.
|
|
1337
|
+
* @param count
|
|
1338
|
+
* Number of items, at minimum, to look and test for.
|
|
1339
|
+
* @throws This function can throw errors.
|
|
1340
|
+
* @example findFeathers.js
|
|
1341
|
+
* ```typescript
|
|
1342
|
+
* test.assertItemEntityCountIs(Items.feather, expectedFeatherLoc, 0, 1);
|
|
1343
|
+
*
|
|
1344
|
+
* ```
|
|
1345
|
+
*/
|
|
1346
|
+
assertItemEntityCountIs(
|
|
1347
|
+
itemType: minecraftserver.ItemType,
|
|
1348
|
+
blockLocation: minecraftserver.BlockLocation,
|
|
1349
|
+
searchDistance: number,
|
|
1350
|
+
count: number,
|
|
1351
|
+
): void;
|
|
1352
|
+
/**
|
|
1353
|
+
* @remarks
|
|
1354
|
+
* Depending on the value of isPresent, tests whether a
|
|
1355
|
+
* particular item entity is present or not at a particular
|
|
1356
|
+
* location. If the condition is not met, an exception is
|
|
1357
|
+
* thrown.
|
|
1358
|
+
* @param itemType
|
|
1359
|
+
* Type of item to test for.
|
|
1360
|
+
* @param blockLocation
|
|
1361
|
+
* Location of the item entity to test for.
|
|
1362
|
+
* @param searchDistance
|
|
1363
|
+
* Radius in blocks to look for the item entity.
|
|
1364
|
+
* @param isPresent
|
|
1365
|
+
* If true, this function tests whether an item entity of the
|
|
1366
|
+
* specified type is present. If false, tests that an item
|
|
1367
|
+
* entity of the specified type is not present.
|
|
1368
|
+
* @throws This function can throw errors.
|
|
1369
|
+
*/
|
|
1370
|
+
assertItemEntityPresent(
|
|
1371
|
+
itemType: minecraftserver.ItemType,
|
|
1372
|
+
blockLocation: minecraftserver.BlockLocation,
|
|
1373
|
+
searchDistance: number,
|
|
1374
|
+
isPresent?: boolean,
|
|
1375
|
+
): void;
|
|
1376
|
+
/**
|
|
1377
|
+
* @remarks
|
|
1378
|
+
* Tests that Redstone power at a particular location matches a
|
|
1379
|
+
* particular value. If not, an exception is thrown.
|
|
1380
|
+
* @param blockLocation
|
|
1381
|
+
* Location to test.
|
|
1382
|
+
* @param power
|
|
1383
|
+
* Expected power level.
|
|
1384
|
+
* @throws This function can throw errors.
|
|
1385
|
+
*/
|
|
1386
|
+
assertRedstonePower(blockLocation: minecraftserver.BlockLocation, power: number): void;
|
|
1387
|
+
destroyBlock(blockLocation: minecraftserver.BlockLocation, dropResources?: boolean): void;
|
|
1388
|
+
/**
|
|
1389
|
+
* @remarks
|
|
1390
|
+
* Marks the current test as a failure case.
|
|
1391
|
+
* @param errorMessage
|
|
1392
|
+
* Error message summarizing the failure condition.
|
|
1393
|
+
* @throws This function can throw errors.
|
|
1394
|
+
*/
|
|
1395
|
+
fail(errorMessage: string): void;
|
|
1396
|
+
/**
|
|
1397
|
+
* @remarks
|
|
1398
|
+
* Runs the given callback. If the callback does not throw an
|
|
1399
|
+
* exception, the test is marked as a failure.
|
|
1400
|
+
* @param callback
|
|
1401
|
+
* Callback function that runs. If the function runs
|
|
1402
|
+
* successfully, the test is marked as a failure. Typically,
|
|
1403
|
+
* this function will have .assertXyz method calls within it.
|
|
1404
|
+
* @throws This function can throw errors.
|
|
1405
|
+
*/
|
|
1406
|
+
failIf(callback: () => void): void;
|
|
1407
|
+
/**
|
|
1408
|
+
* @remarks
|
|
1409
|
+
* Gets a block at the specified block location.
|
|
1410
|
+
* @param blockLocation
|
|
1411
|
+
* Location of the block to retrieve.
|
|
1412
|
+
* @throws This function can throw errors.
|
|
1413
|
+
*/
|
|
1414
|
+
getBlock(blockLocation: minecraftserver.BlockLocation): minecraftserver.Block;
|
|
1415
|
+
/**
|
|
1416
|
+
* @remarks
|
|
1417
|
+
* Gets the dimension of this test.
|
|
1418
|
+
* @throws This function can throw errors.
|
|
1419
|
+
*/
|
|
1420
|
+
getDimension(): minecraftserver.Dimension;
|
|
1421
|
+
/**
|
|
1422
|
+
* @remarks
|
|
1423
|
+
* If the block at the specified block location is a fence,
|
|
1424
|
+
* this returns a helper object with details on how a fence is
|
|
1425
|
+
* connected.
|
|
1426
|
+
* @param blockLocation
|
|
1427
|
+
* Location of the block to retrieve.
|
|
1428
|
+
* @throws This function can throw errors.
|
|
1429
|
+
*/
|
|
1430
|
+
getFenceConnectivity(blockLocation: minecraftserver.BlockLocation): FenceConnectivity;
|
|
1431
|
+
/**
|
|
1432
|
+
* @remarks
|
|
1433
|
+
* Retrieves a sculk spreader object that can be used to
|
|
1434
|
+
* control and manage how sculk grows from a block.
|
|
1435
|
+
* @param blockLocation
|
|
1436
|
+
* Location of the block to retrieve a sculk spreader from.
|
|
1437
|
+
* @throws This function can throw errors.
|
|
1438
|
+
*/
|
|
1439
|
+
getSculkSpreader(blockLocation: minecraftserver.BlockLocation): SculkSpreader;
|
|
1440
|
+
/**
|
|
1441
|
+
* @remarks
|
|
1442
|
+
* Returns the direction of the current test - see the {@link
|
|
1443
|
+
* @minecraft/server.Direction} enum for more information on
|
|
1444
|
+
* potential values (north, east, south, west - values 2-5).
|
|
1445
|
+
*/
|
|
1446
|
+
getTestDirection(): minecraftserver.Direction;
|
|
1447
|
+
/**
|
|
1448
|
+
* @remarks
|
|
1449
|
+
* This asynchronous function will wait for the specified time
|
|
1450
|
+
* in ticks before continuing execution.
|
|
1451
|
+
* @param tickDelay
|
|
1452
|
+
* Amount of time to wait, in ticks.
|
|
1453
|
+
*/
|
|
1454
|
+
idle(tickDelay: number): Promise<void>;
|
|
1455
|
+
/**
|
|
1456
|
+
* @remarks
|
|
1457
|
+
* Kills all entities within the GameTest structure.
|
|
1458
|
+
* @throws This function can throw errors.
|
|
1459
|
+
*/
|
|
1460
|
+
killAllEntities(): void;
|
|
1461
|
+
/**
|
|
1462
|
+
* @remarks
|
|
1463
|
+
* Presses a button at a block location.
|
|
1464
|
+
* @param blockLocation
|
|
1465
|
+
* Location to push the button at.
|
|
1466
|
+
* @throws
|
|
1467
|
+
* Will throw an error if a button is not present at the
|
|
1468
|
+
* specified position.
|
|
1469
|
+
*/
|
|
1470
|
+
pressButton(blockLocation: minecraftserver.BlockLocation): void;
|
|
1471
|
+
/**
|
|
1472
|
+
* @remarks
|
|
1473
|
+
* Displays the specified message to all players.
|
|
1474
|
+
* @param text
|
|
1475
|
+
* Message to display.
|
|
1476
|
+
* @throws This function can throw errors.
|
|
1477
|
+
*/
|
|
1478
|
+
print(text: string): void;
|
|
1479
|
+
/**
|
|
1480
|
+
* @remarks
|
|
1481
|
+
* Pulls a lever at a block location.
|
|
1482
|
+
* @param blockLocation
|
|
1483
|
+
* Location to pull the lever at.
|
|
1484
|
+
* @throws
|
|
1485
|
+
* Will throw an error if a lever is not present at the
|
|
1486
|
+
* specified position.
|
|
1487
|
+
*/
|
|
1488
|
+
pullLever(blockLocation: minecraftserver.BlockLocation): void;
|
|
1489
|
+
/**
|
|
1490
|
+
* @remarks
|
|
1491
|
+
* Sends a Redstone pulse at a particular location by creating
|
|
1492
|
+
* a temporary Redstone block.
|
|
1493
|
+
* @param blockLocation
|
|
1494
|
+
* Location to pulse Redstone at.
|
|
1495
|
+
* @param duration
|
|
1496
|
+
* Number of ticks to pulse Redstone.
|
|
1497
|
+
* @throws This function can throw errors.
|
|
1498
|
+
*/
|
|
1499
|
+
pulseRedstone(blockLocation: minecraftserver.BlockLocation, duration: number): void;
|
|
1500
|
+
/**
|
|
1501
|
+
* @remarks
|
|
1502
|
+
* From a BlockLocation, returns a new BlockLocation with
|
|
1503
|
+
* coordinates relative to the current GameTest structure
|
|
1504
|
+
* block. For example, the relative coordinates for the block
|
|
1505
|
+
* above the structure block are (0, 1, 0). Rotation of the
|
|
1506
|
+
* GameTest structure is also taken into account.
|
|
1507
|
+
* @param worldBlockLocation
|
|
1508
|
+
* Absolute location in the world to convert to a relative
|
|
1509
|
+
* location.
|
|
1510
|
+
* @returns
|
|
1511
|
+
* A location relative to the GameTest command block.
|
|
1512
|
+
* @throws This function can throw errors.
|
|
1513
|
+
*/
|
|
1514
|
+
relativeBlockLocation(worldBlockLocation: minecraftserver.IVec3): minecraftserver.BlockLocation;
|
|
1515
|
+
/**
|
|
1516
|
+
* @remarks
|
|
1517
|
+
* From a location, returns a new location with coordinates
|
|
1518
|
+
* relative to the current GameTest structure block. For
|
|
1519
|
+
* example, the relative coordinates for the block above the
|
|
1520
|
+
* structure block are (0, 1, 0). Rotation of the GameTest
|
|
1521
|
+
* structure is also taken into account.
|
|
1522
|
+
* @param worldLocation
|
|
1523
|
+
* Absolute location in the world to convert to a relative
|
|
1524
|
+
* location.
|
|
1525
|
+
* @returns
|
|
1526
|
+
* A location relative to the GameTest command block.
|
|
1527
|
+
* @throws This function can throw errors.
|
|
1528
|
+
*/
|
|
1529
|
+
relativeLocation(worldLocation: minecraftserver.IVec3): minecraftserver.Location;
|
|
1530
|
+
/**
|
|
1531
|
+
* @remarks
|
|
1532
|
+
* Removes a simulated player from the world.
|
|
1533
|
+
* @param simulatedPlayer
|
|
1534
|
+
* Simulated player to remove.
|
|
1535
|
+
*/
|
|
1536
|
+
removeSimulatedPlayer(simulatedPlayer: SimulatedPlayer): void;
|
|
1537
|
+
/**
|
|
1538
|
+
* @remarks
|
|
1539
|
+
* Returns a relative direction given the current rotation of
|
|
1540
|
+
* the current test. Passing in Direction.south will return the
|
|
1541
|
+
* test direction; Passing in Direction.north will return the
|
|
1542
|
+
* opposite of the test direction, and so on.
|
|
1543
|
+
* @param direction
|
|
1544
|
+
* Direction to translate into a direction relative to the
|
|
1545
|
+
* GameTest facing. Passing in Direction.south will return the
|
|
1546
|
+
* test direction; Passing in Direction.north will return the
|
|
1547
|
+
* opposite of the test direction, and so on.
|
|
1548
|
+
* @throws This function can throw errors.
|
|
1549
|
+
*/
|
|
1550
|
+
rotateDirection(direction: minecraftserver.Direction): minecraftserver.Direction;
|
|
1551
|
+
rotateVector(vector: minecraftserver.Vector): minecraftserver.Vector;
|
|
1552
|
+
/**
|
|
1553
|
+
* @remarks
|
|
1554
|
+
* Runs a specific callback after a specified delay of ticks
|
|
1555
|
+
* @param delayTicks
|
|
1556
|
+
* Number of ticks to delay before running the specified
|
|
1557
|
+
* callback.
|
|
1558
|
+
* @param callback
|
|
1559
|
+
* Callback function to execute.
|
|
1560
|
+
* @throws This function can throw errors.
|
|
1561
|
+
*/
|
|
1562
|
+
runAfterDelay(delayTicks: number, callback: () => void): void;
|
|
1563
|
+
/**
|
|
1564
|
+
* @remarks
|
|
1565
|
+
* Runs the given callback after a delay of _tick_ ticks from
|
|
1566
|
+
* the start of the GameTest.
|
|
1567
|
+
* @param tick
|
|
1568
|
+
* Tick (after the start of the GameTest) to run the callback
|
|
1569
|
+
* at.
|
|
1570
|
+
* @param callback
|
|
1571
|
+
* Callback function to execute.
|
|
1572
|
+
* @throws This function can throw errors.
|
|
1573
|
+
*/
|
|
1574
|
+
runAtTickTime(tick: number, callback: () => void): void;
|
|
1575
|
+
/**
|
|
1576
|
+
* @remarks
|
|
1577
|
+
* Sets a block to a particular configuration (a
|
|
1578
|
+
* BlockPermutation) at the specified block location.
|
|
1579
|
+
* @param blockData
|
|
1580
|
+
* Permutation that contains the configuration data for a
|
|
1581
|
+
* block.
|
|
1582
|
+
* @param blockLocation
|
|
1583
|
+
* Location of the block to set.
|
|
1584
|
+
* @throws This function can throw errors.
|
|
1585
|
+
*/
|
|
1586
|
+
setBlockPermutation(
|
|
1587
|
+
blockData: minecraftserver.BlockPermutation,
|
|
1588
|
+
blockLocation: minecraftserver.BlockLocation,
|
|
1589
|
+
): void;
|
|
1590
|
+
/**
|
|
1591
|
+
* @remarks
|
|
1592
|
+
* Sets a block to a particular type at the specified block
|
|
1593
|
+
* location.
|
|
1594
|
+
* @param blockType
|
|
1595
|
+
* Type of block to set.
|
|
1596
|
+
* @param blockLocation
|
|
1597
|
+
* Location of the block to set.
|
|
1598
|
+
* @throws This function can throw errors.
|
|
1599
|
+
*/
|
|
1600
|
+
setBlockType(blockType: minecraftserver.BlockType, blockLocation: minecraftserver.BlockLocation): void;
|
|
1601
|
+
/**
|
|
1602
|
+
* @remarks
|
|
1603
|
+
* For blocks that are fluid containers - like a cauldron -
|
|
1604
|
+
* changes the type of fluid within that container.
|
|
1605
|
+
* @param location
|
|
1606
|
+
* Location of the fluid container block.
|
|
1607
|
+
* @param type
|
|
1608
|
+
* Type of fluid to set. See {@link
|
|
1609
|
+
* @minecraft/server-gametest.FluidType} for a list of values.
|
|
1610
|
+
* @throws This function can throw errors.
|
|
1611
|
+
*/
|
|
1612
|
+
setFluidContainer(location: minecraftserver.BlockLocation, type: minecraftserver.FluidType): void;
|
|
1613
|
+
/**
|
|
1614
|
+
* @remarks
|
|
1615
|
+
* Sets the fuse of an explodable entity.
|
|
1616
|
+
* @param entity
|
|
1617
|
+
* Entity that is explodable.
|
|
1618
|
+
* @param fuseLength
|
|
1619
|
+
* Length of time, in ticks, before the entity explodes.
|
|
1620
|
+
* @throws This function can throw errors.
|
|
1621
|
+
*/
|
|
1622
|
+
setTntFuse(entity: minecraftserver.Entity, fuseLength: number): void;
|
|
1623
|
+
/**
|
|
1624
|
+
* @remarks
|
|
1625
|
+
* Spawns an entity at a location.
|
|
1626
|
+
* @param entityTypeIdentifier
|
|
1627
|
+
* Type of entity to create. If no namespace is provided,
|
|
1628
|
+
* 'minecraft:' is assumed. Note that an optional initial spawn
|
|
1629
|
+
* event can be specified between less than/greater than signs
|
|
1630
|
+
* (e.g., namespace:entityType<spawnEvent>).
|
|
1631
|
+
* @param blockLocation
|
|
1632
|
+
* @returns
|
|
1633
|
+
* The spawned entity. If the entity cannot be spawned, returns
|
|
1634
|
+
* undefined.
|
|
1635
|
+
* @throws This function can throw errors.
|
|
1636
|
+
* @example simpleMobTest.ts
|
|
1637
|
+
* ```typescript
|
|
1638
|
+
* gt.register("StarterTests", "simpleMobTest", (test: gt.Test) => {
|
|
1639
|
+
* const attackerId = "fox";
|
|
1640
|
+
* const victimId = "chicken";
|
|
1641
|
+
*
|
|
1642
|
+
* test.spawn(attackerId, new mc.BlockLocation(5, 2, 5));
|
|
1643
|
+
* test.spawn(victimId, new mc.BlockLocation(2, 2, 2));
|
|
1644
|
+
*
|
|
1645
|
+
* test.assertEntityPresentInArea(victimId, true);
|
|
1646
|
+
*
|
|
1647
|
+
* test.succeedWhen(() => {
|
|
1648
|
+
* test.assertEntityPresentInArea(victimId, false);
|
|
1649
|
+
* });
|
|
1650
|
+
* })
|
|
1651
|
+
* .maxTicks(400)
|
|
1652
|
+
* .structureName("gametests:mediumglass");
|
|
1653
|
+
* ```
|
|
1654
|
+
* @example spawnAdultPig.js
|
|
1655
|
+
* ```typescript
|
|
1656
|
+
* test.spawn("minecraft:pig<minecraft:ageable_grow_up>", new BlockLocation(1, 2, 1));
|
|
1657
|
+
*
|
|
1658
|
+
* ```
|
|
1659
|
+
*/
|
|
1660
|
+
spawn(entityTypeIdentifier: string, blockLocation: minecraftserver.BlockLocation): minecraftserver.Entity;
|
|
1661
|
+
/**
|
|
1662
|
+
* @remarks
|
|
1663
|
+
* Spawns an entity at a location.
|
|
1664
|
+
* @param entityTypeIdentifier
|
|
1665
|
+
* Type of entity to create. If no namespace is provided,
|
|
1666
|
+
* 'minecraft:' is assumed. Note that an optional initial spawn
|
|
1667
|
+
* event can be specified between less than/greater than signs
|
|
1668
|
+
* (e.g., namespace:entityType<spawnEvent>).
|
|
1669
|
+
* @param location
|
|
1670
|
+
* @returns
|
|
1671
|
+
* The spawned entity. If the entity cannot be spawned, returns
|
|
1672
|
+
* undefined.
|
|
1673
|
+
* @throws This function can throw errors.
|
|
1674
|
+
* @example spawnAdultPig.js
|
|
1675
|
+
* ```typescript
|
|
1676
|
+
* test.spawn("minecraft:pig<minecraft:ageable_grow_up>", new Location(1.5, 2, 1.5));
|
|
1677
|
+
* ```
|
|
1678
|
+
*/
|
|
1679
|
+
spawnAtLocation(entityTypeIdentifier: string, location: minecraftserver.Location): minecraftserver.Entity;
|
|
1680
|
+
/**
|
|
1681
|
+
* @remarks
|
|
1682
|
+
* Spawns an item entity at a specified location.
|
|
1683
|
+
* @param itemStack
|
|
1684
|
+
* ItemStack that describes the item entity to create.
|
|
1685
|
+
* @param location
|
|
1686
|
+
* Location to create the item entity at.
|
|
1687
|
+
* @throws This function can throw errors.
|
|
1688
|
+
* @example spawnEmeralds.js
|
|
1689
|
+
* ```typescript
|
|
1690
|
+
* const oneEmerald = new ItemStack(MinecraftItemTypes.emerald, 1, 0);
|
|
1691
|
+
* const fiveEmeralds = new ItemStack(MinecraftItemTypes.emerald, 5, 0);
|
|
1692
|
+
*
|
|
1693
|
+
* test.spawnItem(oneEmerald, new Location(3.5, 3, 1.5));
|
|
1694
|
+
* test.spawnItem(fiveEmeralds, new Location(1.5, 3, 1.5));
|
|
1695
|
+
*
|
|
1696
|
+
* ```
|
|
1697
|
+
*/
|
|
1698
|
+
spawnItem(itemStack: minecraftserver.ItemStack, location: minecraftserver.Location): minecraftserver.Entity;
|
|
1699
|
+
/**
|
|
1700
|
+
* @remarks
|
|
1701
|
+
* Creates a new simulated player within the world.
|
|
1702
|
+
* @param blockLocation
|
|
1703
|
+
* Location where to spawn the simulated player.
|
|
1704
|
+
* @param name
|
|
1705
|
+
* Name to give the new simulated player.
|
|
1706
|
+
* @param gameMode
|
|
1707
|
+
* @throws This function can throw errors.
|
|
1708
|
+
*/
|
|
1709
|
+
spawnSimulatedPlayer(
|
|
1710
|
+
blockLocation: minecraftserver.BlockLocation,
|
|
1711
|
+
name?: string,
|
|
1712
|
+
gameMode?: minecraftserver.GameMode,
|
|
1713
|
+
): SimulatedPlayer;
|
|
1714
|
+
/**
|
|
1715
|
+
* @remarks
|
|
1716
|
+
* Spawns an entity at a location without any AI behaviors.
|
|
1717
|
+
* This method is frequently used in conjunction with methods
|
|
1718
|
+
* like .walkTo to create predictable mob actions.
|
|
1719
|
+
* @param entityTypeIdentifier
|
|
1720
|
+
* @param blockLocation
|
|
1721
|
+
* Location where the entity should be spawned.
|
|
1722
|
+
* @throws This function can throw errors.
|
|
1723
|
+
*/
|
|
1724
|
+
spawnWithoutBehaviors(
|
|
1725
|
+
entityTypeIdentifier: string,
|
|
1726
|
+
blockLocation: minecraftserver.BlockLocation,
|
|
1727
|
+
): minecraftserver.Entity;
|
|
1728
|
+
/**
|
|
1729
|
+
* @remarks
|
|
1730
|
+
* Spawns an entity at a location without any AI behaviors.
|
|
1731
|
+
* This method is frequently used in conjunction with methods
|
|
1732
|
+
* like .walkTo to create predictable mob actions.
|
|
1733
|
+
* @param entityTypeIdentifier
|
|
1734
|
+
* @param location
|
|
1735
|
+
* Location where the entity should be spawned.
|
|
1736
|
+
* @throws This function can throw errors.
|
|
1737
|
+
*/
|
|
1738
|
+
spawnWithoutBehaviorsAtLocation(
|
|
1739
|
+
entityTypeIdentifier: string,
|
|
1740
|
+
location: minecraftserver.Location,
|
|
1741
|
+
): minecraftserver.Entity;
|
|
1742
|
+
/**
|
|
1743
|
+
* @remarks
|
|
1744
|
+
* Tests that a particular item entity is present at a
|
|
1745
|
+
* particular location. If not, an exception is thrown.
|
|
1746
|
+
* @param blockLocation
|
|
1747
|
+
* BlockLocation containing a multiface block.
|
|
1748
|
+
* @param fromFace
|
|
1749
|
+
* Face to spread from. This face must already be set.
|
|
1750
|
+
* @param direction
|
|
1751
|
+
* Direction to spread. Use the Minecraft.Direction enum to
|
|
1752
|
+
* specify a direction.
|
|
1753
|
+
* @throws This function can throw errors.
|
|
1754
|
+
* @example spreadFromFaceTowardDirection.js
|
|
1755
|
+
* ```typescript
|
|
1756
|
+
* test.spreadFromFaceTowardDirection(new BlockLocation(1, 2, 1), Direction.south, Direction.down);
|
|
1757
|
+
* ```
|
|
1758
|
+
*/
|
|
1759
|
+
spreadFromFaceTowardDirection(
|
|
1760
|
+
blockLocation: minecraftserver.BlockLocation,
|
|
1761
|
+
fromFace: minecraftserver.Direction,
|
|
1762
|
+
direction: minecraftserver.Direction,
|
|
1763
|
+
): void;
|
|
1764
|
+
/**
|
|
1765
|
+
* @remarks
|
|
1766
|
+
* Creates a new GameTestSequence - A set of steps that play
|
|
1767
|
+
* out sequentially within a GameTest.
|
|
1768
|
+
* @returns
|
|
1769
|
+
* A new GameTestSequence with chaining methods that facilitate
|
|
1770
|
+
* creating a set of steps.
|
|
1771
|
+
*/
|
|
1772
|
+
startSequence(): GameTestSequence;
|
|
1773
|
+
/**
|
|
1774
|
+
* @remarks
|
|
1775
|
+
* Marks the current test as a success case.
|
|
1776
|
+
* @throws This function can throw errors.
|
|
1777
|
+
*/
|
|
1778
|
+
succeed(): void;
|
|
1779
|
+
/**
|
|
1780
|
+
* @remarks
|
|
1781
|
+
* Runs the given callback. If the callback does not throw an
|
|
1782
|
+
* exception, the test is marked as a success.
|
|
1783
|
+
* @param callback
|
|
1784
|
+
* Callback function that runs. If the function runs
|
|
1785
|
+
* successfully, the test is marked as a success. Typically,
|
|
1786
|
+
* this function will have .assertXyz method calls within it.
|
|
1787
|
+
* @throws This function can throw errors.
|
|
1788
|
+
*/
|
|
1789
|
+
succeedIf(callback: () => void): void;
|
|
1790
|
+
/**
|
|
1791
|
+
* @remarks
|
|
1792
|
+
* Marks the test as a success at the specified tick.
|
|
1793
|
+
* @param tick
|
|
1794
|
+
* Tick after the start of the GameTest to mark the test as
|
|
1795
|
+
* successful.
|
|
1796
|
+
* @throws This function can throw errors.
|
|
1797
|
+
*/
|
|
1798
|
+
succeedOnTick(tick: number): void;
|
|
1799
|
+
/**
|
|
1800
|
+
* @remarks
|
|
1801
|
+
* Runs the given callback at _tick_ ticks after the start of
|
|
1802
|
+
* the test. If the callback does not throw an exception, the
|
|
1803
|
+
* test is marked as a failure.
|
|
1804
|
+
* @param tick
|
|
1805
|
+
* Tick after the start of the GameTest to run the testing
|
|
1806
|
+
* callback at.
|
|
1807
|
+
* @param callback
|
|
1808
|
+
* Callback function that runs. If the function runs
|
|
1809
|
+
* successfully, the test is marked as a success.
|
|
1810
|
+
* @throws This function can throw errors.
|
|
1811
|
+
*/
|
|
1812
|
+
succeedOnTickWhen(tick: number, callback: () => void): void;
|
|
1813
|
+
/**
|
|
1814
|
+
* @remarks
|
|
1815
|
+
* Runs the given callback every tick. When the callback
|
|
1816
|
+
* successfully executes, the test is marked as a success.
|
|
1817
|
+
* Specifically, the test will succeed when the callback does
|
|
1818
|
+
* not throw an exception.
|
|
1819
|
+
* @param callback
|
|
1820
|
+
* Testing callback function that runs. If the function runs
|
|
1821
|
+
* successfully, the test is marked as a success.
|
|
1822
|
+
* @throws This function can throw errors.
|
|
1823
|
+
* @example simpleMobTest.ts
|
|
1824
|
+
* ```typescript
|
|
1825
|
+
* gt.register("StarterTests", "simpleMobTest", (test: gt.Test) => {
|
|
1826
|
+
* const attackerId = "fox";
|
|
1827
|
+
* const victimId = "chicken";
|
|
1828
|
+
*
|
|
1829
|
+
* test.spawn(attackerId, new mc.BlockLocation(5, 2, 5));
|
|
1830
|
+
* test.spawn(victimId, new mc.BlockLocation(2, 2, 2));
|
|
1831
|
+
*
|
|
1832
|
+
* test.assertEntityPresentInArea(victimId, true);
|
|
1833
|
+
*
|
|
1834
|
+
* test.succeedWhen(() => {
|
|
1835
|
+
* test.assertEntityPresentInArea(victimId, false);
|
|
1836
|
+
* });
|
|
1837
|
+
* })
|
|
1838
|
+
* .maxTicks(400)
|
|
1839
|
+
* .structureName("gametests:mediumglass");
|
|
1840
|
+
*
|
|
1841
|
+
* ```
|
|
1842
|
+
*/
|
|
1843
|
+
succeedWhen(callback: () => void): void;
|
|
1844
|
+
/**
|
|
1845
|
+
* @remarks
|
|
1846
|
+
* Depending on the condition of isPresent, tests for the
|
|
1847
|
+
* presence of a block of a particular type on every tick. When
|
|
1848
|
+
* the specified block of a type is found or not found
|
|
1849
|
+
* (depending on isPresent), the test is marked as a success.
|
|
1850
|
+
* @param blockType
|
|
1851
|
+
* Type of block to test for.
|
|
1852
|
+
* @param blockLocation
|
|
1853
|
+
* Location of the block to test at.
|
|
1854
|
+
* @param isPresent
|
|
1855
|
+
* If true, this function tests whether a block of the
|
|
1856
|
+
* specified type is present. If false, tests that a block of
|
|
1857
|
+
* the specified type is not present.
|
|
1858
|
+
* @throws This function can throw errors.
|
|
1859
|
+
*/
|
|
1860
|
+
succeedWhenBlockPresent(
|
|
1861
|
+
blockType: minecraftserver.BlockType,
|
|
1862
|
+
blockLocation: minecraftserver.BlockLocation,
|
|
1863
|
+
isPresent?: boolean,
|
|
1864
|
+
): void;
|
|
1865
|
+
/**
|
|
1866
|
+
* @remarks
|
|
1867
|
+
* Tests for the presence of a component on every tick.
|
|
1868
|
+
* Depending on the value of hasComponent, when the specified
|
|
1869
|
+
* component is found, the test is marked as a success.
|
|
1870
|
+
* @param entityTypeIdentifier
|
|
1871
|
+
* Type of entity to look for. If no namespace is specified,
|
|
1872
|
+
* 'minecraft:' is assumed.
|
|
1873
|
+
* @param componentIdentifier
|
|
1874
|
+
* Type of component to test for the presence of. If no
|
|
1875
|
+
* namespace is specified, 'minecraft:' is assumed.
|
|
1876
|
+
* @param blockLocation
|
|
1877
|
+
* Block location of the entity to test.
|
|
1878
|
+
* @param hasComponent
|
|
1879
|
+
* If true, this function tests for the presence of a
|
|
1880
|
+
* component. If false, this function tests for the lack of a
|
|
1881
|
+
* component.
|
|
1882
|
+
* @throws This function can throw errors.
|
|
1883
|
+
*/
|
|
1884
|
+
succeedWhenEntityHasComponent(
|
|
1885
|
+
entityTypeIdentifier: string,
|
|
1886
|
+
componentIdentifier: string,
|
|
1887
|
+
blockLocation: minecraftserver.BlockLocation,
|
|
1888
|
+
hasComponent: boolean,
|
|
1889
|
+
): void;
|
|
1890
|
+
/**
|
|
1891
|
+
* @remarks
|
|
1892
|
+
* Depending on the value of isPresent, tests for the presence
|
|
1893
|
+
* of an entity on every tick. When an entity of the specified
|
|
1894
|
+
* type is found or not found (depending on isPresent), the
|
|
1895
|
+
* test is marked as a success.
|
|
1896
|
+
* @param entityTypeIdentifier
|
|
1897
|
+
* Type of entity to test for (e.g., 'minecraft:skeleton'). If
|
|
1898
|
+
* an entity namespace is not specified, 'minecraft:' is
|
|
1899
|
+
* assumed.
|
|
1900
|
+
* @param blockLocation
|
|
1901
|
+
* Location of the entity to test for.
|
|
1902
|
+
* @param isPresent
|
|
1903
|
+
* If true, this function tests whether an entity of the
|
|
1904
|
+
* specified type is present. If false, tests that an entity of
|
|
1905
|
+
* the specified type is not present.
|
|
1906
|
+
* @throws This function can throw errors.
|
|
1907
|
+
*/
|
|
1908
|
+
succeedWhenEntityPresent(
|
|
1909
|
+
entityTypeIdentifier: string,
|
|
1910
|
+
blockLocation: minecraftserver.BlockLocation,
|
|
1911
|
+
isPresent?: boolean,
|
|
1912
|
+
): void;
|
|
1913
|
+
/**
|
|
1914
|
+
* @remarks
|
|
1915
|
+
* Triggers a block event from a fixed list of available block
|
|
1916
|
+
* events.
|
|
1917
|
+
* @param blockLocation
|
|
1918
|
+
* @param event
|
|
1919
|
+
* Event to trigger. Valid values include minecraft:drip,
|
|
1920
|
+
* minecraft:grow_stalagtite, minecraft:grow_stalagmite,
|
|
1921
|
+
* minecraft:grow_up, minecraft:grow_down and
|
|
1922
|
+
* minecraft:grow_sideways.
|
|
1923
|
+
* @param eventParameters
|
|
1924
|
+
* @throws This function can throw errors.
|
|
1925
|
+
*/
|
|
1926
|
+
triggerInternalBlockEvent(
|
|
1927
|
+
blockLocation: minecraftserver.BlockLocation,
|
|
1928
|
+
event: string,
|
|
1929
|
+
eventParameters?: number[],
|
|
1930
|
+
): void;
|
|
1931
|
+
/**
|
|
1932
|
+
* @remarks
|
|
1933
|
+
* This asynchronous function will wait until the code in the
|
|
1934
|
+
* specified callback successfully completes. until can be used
|
|
1935
|
+
* in conjunction with .assert functions to evaluate that a
|
|
1936
|
+
* condition is true.
|
|
1937
|
+
* @param callback
|
|
1938
|
+
* Function with code to evaluate.
|
|
1939
|
+
*/
|
|
1940
|
+
until(callback: () => void): Promise<void>;
|
|
1941
|
+
/**
|
|
1942
|
+
* @remarks
|
|
1943
|
+
* Forces a mob to walk to a particular location. Usually used
|
|
1944
|
+
* in conjunction with methods like .spawnWithoutBehaviors to
|
|
1945
|
+
* have more predictable mob behaviors. Mobs will stop
|
|
1946
|
+
* navigation as soon as they intersect the target location.
|
|
1947
|
+
* @param mob
|
|
1948
|
+
* Mob entity to give orders to.
|
|
1949
|
+
* @param blockLocation
|
|
1950
|
+
* Location where the entity should be walk to.
|
|
1951
|
+
* @param speedModifier
|
|
1952
|
+
* Adjustable modifier to the mob's walking speed.
|
|
1953
|
+
* @throws This function can throw errors.
|
|
1954
|
+
*/
|
|
1955
|
+
walkTo(mob: minecraftserver.Entity, blockLocation: minecraftserver.BlockLocation, speedModifier?: number): void;
|
|
1956
|
+
/**
|
|
1957
|
+
* @remarks
|
|
1958
|
+
* Forces a mob to walk to a particular location. Usually used
|
|
1959
|
+
* in conjunction with methods like .spawnWithoutBehaviors to
|
|
1960
|
+
* have more predictable mob behaviors. Mobs will stop
|
|
1961
|
+
* navigation as soon as they intersect the target location.
|
|
1962
|
+
* @param mob
|
|
1963
|
+
* Mob entity to give orders to.
|
|
1964
|
+
* @param location
|
|
1965
|
+
* Location where the entity should be walk to.
|
|
1966
|
+
* @param speedModifier
|
|
1967
|
+
* Adjustable modifier to the mob's walking speed.
|
|
1968
|
+
* @throws This function can throw errors.
|
|
1969
|
+
*/
|
|
1970
|
+
walkToLocation(mob: minecraftserver.Entity, location: minecraftserver.Location, speedModifier?: number): void;
|
|
1971
|
+
/**
|
|
1972
|
+
* @remarks
|
|
1973
|
+
* From a BlockLocation with coordinates relative to the
|
|
1974
|
+
* GameTest structure block, returns a new BlockLocation with
|
|
1975
|
+
* coordinates relative to world. Rotation of the GameTest
|
|
1976
|
+
* structure is also taken into account.
|
|
1977
|
+
* @param relativeBlockLocation
|
|
1978
|
+
* Location relative to the GameTest command block.
|
|
1979
|
+
* @returns
|
|
1980
|
+
* An absolute location relative to the GameTest command block.
|
|
1981
|
+
* @throws This function can throw errors.
|
|
1982
|
+
*/
|
|
1983
|
+
worldBlockLocation(relativeBlockLocation: minecraftserver.BlockLocation): minecraftserver.BlockLocation;
|
|
1984
|
+
/**
|
|
1985
|
+
* @remarks
|
|
1986
|
+
* From a location with coordinates relative to the GameTest
|
|
1987
|
+
* structure block, returns a new location with coordinates
|
|
1988
|
+
* relative to world. Rotation of the GameTest structure is
|
|
1989
|
+
* also taken into account.
|
|
1990
|
+
* @param relativeLocation
|
|
1991
|
+
* Location relative to the GameTest command block.
|
|
1992
|
+
* @returns
|
|
1993
|
+
* An absolute location relative to the GameTest command block.
|
|
1994
|
+
* @throws This function can throw errors.
|
|
1995
|
+
*/
|
|
1996
|
+
worldLocation(relativeLocation: minecraftserver.IVec3): minecraftserver.Location;
|
|
1997
|
+
protected constructor();
|
|
1998
|
+
}
|
|
1999
|
+
/**
|
|
2000
|
+
* @remarks
|
|
2001
|
+
* Registers a new GameTest function. This GameTest will become
|
|
2002
|
+
* available in Minecraft via /gametest run
|
|
2003
|
+
* [testClassName]:[testName].
|
|
2004
|
+
* @param testClassName
|
|
2005
|
+
* Name of the class of tests this test should be a part of.
|
|
2006
|
+
* @param testName
|
|
2007
|
+
* Name of this specific test.
|
|
2008
|
+
* @param testFunction
|
|
2009
|
+
* Implementation of the test function.
|
|
2010
|
+
* @returns
|
|
2011
|
+
* Returns a {@link RegistrationBuilder} object where
|
|
2012
|
+
* additional options for this test can be specified via
|
|
2013
|
+
* builder methods.
|
|
2014
|
+
* @example example1.js
|
|
2015
|
+
* ```typescript
|
|
2016
|
+
* GameTest.register("ExampleTests", "alwaysFail", (test) => {
|
|
2017
|
+
* test.fail("This test, runnable via '/gametest run ExampleTests:alwaysFail', will always fail");
|
|
2018
|
+
* });
|
|
2019
|
+
*
|
|
2020
|
+
* ```
|
|
2021
|
+
* @example simpleMobTest.ts
|
|
2022
|
+
* ```typescript
|
|
2023
|
+
* gt.register("StarterTests", "simpleMobTest", (test: gt.Test) => {
|
|
2024
|
+
* const attackerId = "fox";
|
|
2025
|
+
* const victimId = "chicken";
|
|
2026
|
+
*
|
|
2027
|
+
* test.spawn(attackerId, new mc.BlockLocation(5, 2, 5));
|
|
2028
|
+
* test.spawn(victimId, new mc.BlockLocation(2, 2, 2));
|
|
2029
|
+
*
|
|
2030
|
+
* test.assertEntityPresentInArea(victimId, true);
|
|
2031
|
+
*
|
|
2032
|
+
* test.succeedWhen(() => {
|
|
2033
|
+
* test.assertEntityPresentInArea(victimId, false);
|
|
2034
|
+
* });
|
|
2035
|
+
* })
|
|
2036
|
+
* .maxTicks(400)
|
|
2037
|
+
* .structureName("gametests:mediumglass");
|
|
2038
|
+
* ```
|
|
2039
|
+
*/
|
|
2040
|
+
export function register(
|
|
2041
|
+
testClassName: string,
|
|
2042
|
+
testName: string,
|
|
2043
|
+
testFunction: (arg: Test) => void,
|
|
2044
|
+
): RegistrationBuilder;
|
|
2045
|
+
/**
|
|
2046
|
+
* @remarks
|
|
2047
|
+
* Registers a new GameTest function that is designed for
|
|
2048
|
+
* asynchronous execution. This GameTest will become available
|
|
2049
|
+
* in Minecraft via /gametest run [testClassName]:[testName].
|
|
2050
|
+
* @param testClassName
|
|
2051
|
+
* Name of the class of tests this test should be a part of.
|
|
2052
|
+
* @param testName
|
|
2053
|
+
* Name of this specific test.
|
|
2054
|
+
* @param testFunction
|
|
2055
|
+
* Implementation of the test function.
|
|
2056
|
+
* @returns
|
|
2057
|
+
* Returns a {@link RegistrationBuilder} object where
|
|
2058
|
+
* additional options for this test can be specified via
|
|
2059
|
+
* builder methods.
|
|
2060
|
+
*/
|
|
2061
|
+
export function registerAsync(
|
|
2062
|
+
testClassName: string,
|
|
2063
|
+
testName: string,
|
|
2064
|
+
testFunction: (arg: Test) => Promise<void>,
|
|
2065
|
+
): RegistrationBuilder;
|