@minecraft/server 1.2.0-rc.1.20.0-preview.21 → 1.2.0-rc.1.20.0-preview.22
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/index.d.ts +731 -2
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -16,11 +16,48 @@
|
|
|
16
16
|
* ```json
|
|
17
17
|
* {
|
|
18
18
|
* "module_name": "@minecraft/server",
|
|
19
|
-
* "version": "1.3.0-internal.1.20.0-preview.
|
|
19
|
+
* "version": "1.3.0-internal.1.20.0-preview.22"
|
|
20
20
|
* }
|
|
21
21
|
* ```
|
|
22
22
|
*
|
|
23
23
|
*/
|
|
24
|
+
/**
|
|
25
|
+
* @beta
|
|
26
|
+
*/
|
|
27
|
+
export enum EntityDamageCause {
|
|
28
|
+
anvil = 'anvil',
|
|
29
|
+
blockExplosion = 'blockExplosion',
|
|
30
|
+
charging = 'charging',
|
|
31
|
+
contact = 'contact',
|
|
32
|
+
drowning = 'drowning',
|
|
33
|
+
entityAttack = 'entityAttack',
|
|
34
|
+
entityExplosion = 'entityExplosion',
|
|
35
|
+
fall = 'fall',
|
|
36
|
+
fallingBlock = 'fallingBlock',
|
|
37
|
+
fire = 'fire',
|
|
38
|
+
fireTick = 'fireTick',
|
|
39
|
+
fireworks = 'fireworks',
|
|
40
|
+
flyIntoWall = 'flyIntoWall',
|
|
41
|
+
freezing = 'freezing',
|
|
42
|
+
lava = 'lava',
|
|
43
|
+
lightning = 'lightning',
|
|
44
|
+
magic = 'magic',
|
|
45
|
+
magma = 'magma',
|
|
46
|
+
none = 'none',
|
|
47
|
+
override = 'override',
|
|
48
|
+
piston = 'piston',
|
|
49
|
+
projectile = 'projectile',
|
|
50
|
+
stalactite = 'stalactite',
|
|
51
|
+
stalagmite = 'stalagmite',
|
|
52
|
+
starve = 'starve',
|
|
53
|
+
suffocation = 'suffocation',
|
|
54
|
+
suicide = 'suicide',
|
|
55
|
+
temperature = 'temperature',
|
|
56
|
+
thorns = 'thorns',
|
|
57
|
+
'void' = 'void',
|
|
58
|
+
wither = 'wither',
|
|
59
|
+
}
|
|
60
|
+
|
|
24
61
|
/**
|
|
25
62
|
* @beta
|
|
26
63
|
* Represents a game mode for the current world experience.
|
|
@@ -60,6 +97,16 @@ export enum GameMode {
|
|
|
60
97
|
*/
|
|
61
98
|
survival = 'survival',
|
|
62
99
|
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @beta
|
|
103
|
+
*/
|
|
104
|
+
export enum ItemLockMode {
|
|
105
|
+
inventory = 'inventory',
|
|
106
|
+
none = 'none',
|
|
107
|
+
slot = 'slot',
|
|
108
|
+
}
|
|
109
|
+
|
|
63
110
|
/**
|
|
64
111
|
* @beta
|
|
65
112
|
* Represents a block in a dimension. A block represents a
|
|
@@ -122,6 +169,23 @@ export class Block {
|
|
|
122
169
|
*/
|
|
123
170
|
setPermutation(permutation: BlockPermutation): void;
|
|
124
171
|
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* @beta
|
|
175
|
+
* Represents the inventory of a block in the world. Used with
|
|
176
|
+
* blocks like chests.
|
|
177
|
+
*/
|
|
178
|
+
export class BlockInventoryComponent {
|
|
179
|
+
protected constructor();
|
|
180
|
+
/**
|
|
181
|
+
* @remarks
|
|
182
|
+
* The container which holds an {@link ItemStack}.
|
|
183
|
+
*
|
|
184
|
+
* @throws This property can throw when used.
|
|
185
|
+
*/
|
|
186
|
+
readonly container: Container;
|
|
187
|
+
}
|
|
188
|
+
|
|
125
189
|
/**
|
|
126
190
|
* @beta
|
|
127
191
|
* Contains the combination of type {@link BlockType} and
|
|
@@ -153,6 +217,7 @@ export class BlockPermutation {
|
|
|
153
217
|
*/
|
|
154
218
|
static resolve(blockName: string, states?: Record<string, boolean | number | string>): BlockPermutation;
|
|
155
219
|
}
|
|
220
|
+
|
|
156
221
|
/**
|
|
157
222
|
* Contains return data on the result of a command execution.
|
|
158
223
|
*/
|
|
@@ -167,6 +232,178 @@ export class CommandResult {
|
|
|
167
232
|
*/
|
|
168
233
|
readonly successCount: number;
|
|
169
234
|
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* @beta
|
|
238
|
+
* Represents a container that can hold sets of items. Used
|
|
239
|
+
* with entities such as Players, Chest Minecarts, Llamas, and
|
|
240
|
+
* more.
|
|
241
|
+
*/
|
|
242
|
+
export class Container {
|
|
243
|
+
protected constructor();
|
|
244
|
+
/**
|
|
245
|
+
* @remarks
|
|
246
|
+
* Count of the slots in the container that are empty.
|
|
247
|
+
*
|
|
248
|
+
* @throws
|
|
249
|
+
* Throws if the container is invalid.
|
|
250
|
+
*/
|
|
251
|
+
readonly emptySlotsCount: number;
|
|
252
|
+
/**
|
|
253
|
+
* @remarks
|
|
254
|
+
* The number of slots in this container. For example, a
|
|
255
|
+
* standard single-block chest has a size of 27. Note, a
|
|
256
|
+
* player's inventory container contains a total of 36 slots, 9
|
|
257
|
+
* hotbar slots plus 27 inventory slots.
|
|
258
|
+
*
|
|
259
|
+
* @throws
|
|
260
|
+
* Throws if the container is invalid.
|
|
261
|
+
*/
|
|
262
|
+
readonly size: number;
|
|
263
|
+
/**
|
|
264
|
+
* @remarks
|
|
265
|
+
* Adds an item to the container. The item is placed in the
|
|
266
|
+
* first available slot(s) and can be stacked with existing
|
|
267
|
+
* items of the same type. Note, use {@link Container.setItem}
|
|
268
|
+
* if you wish to set the item in a particular slot.
|
|
269
|
+
*
|
|
270
|
+
* This function can't be called in read-only mode.
|
|
271
|
+
*
|
|
272
|
+
* @param itemStack
|
|
273
|
+
* The stack of items to add.
|
|
274
|
+
* @throws This function can throw errors.
|
|
275
|
+
*/
|
|
276
|
+
addItem(itemStack: ItemStack): ItemStack;
|
|
277
|
+
/**
|
|
278
|
+
* @remarks
|
|
279
|
+
* Clears all inventory items in the container.
|
|
280
|
+
*
|
|
281
|
+
* This function can't be called in read-only mode.
|
|
282
|
+
*
|
|
283
|
+
* @throws
|
|
284
|
+
* Throws if the container is invalid.
|
|
285
|
+
*/
|
|
286
|
+
clearAll(): void;
|
|
287
|
+
/**
|
|
288
|
+
* @remarks
|
|
289
|
+
* Gets an {@link ItemStack} of the item at the specified slot.
|
|
290
|
+
* If the slot is empty, returns `undefined`. This method does
|
|
291
|
+
* not change or clear the contents of the specified slot. To
|
|
292
|
+
* get a reference to a particular slot, see {@link
|
|
293
|
+
* Container.getSlot}.
|
|
294
|
+
*
|
|
295
|
+
* @param slot
|
|
296
|
+
* Zero-based index of the slot to retrieve items from.
|
|
297
|
+
* @throws
|
|
298
|
+
* Throws if the container is invalid or if the `slot` index is
|
|
299
|
+
* out of bounds.
|
|
300
|
+
* @example getItem.ts
|
|
301
|
+
* ```typescript
|
|
302
|
+
* // Get a copy of the first item in the player's hotbar
|
|
303
|
+
* const inventory = player.getComponent("inventory") as EntityInventoryComponent;
|
|
304
|
+
* const itemStack = inventory.container.getItem(0);
|
|
305
|
+
*
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
getItem(slot: number): ItemStack | undefined;
|
|
309
|
+
/**
|
|
310
|
+
* @remarks
|
|
311
|
+
* Moves an item from one slot to another, potentially across
|
|
312
|
+
* containers.
|
|
313
|
+
*
|
|
314
|
+
* This function can't be called in read-only mode.
|
|
315
|
+
*
|
|
316
|
+
* @param fromSlot
|
|
317
|
+
* Zero-based index of the slot to transfer an item from, on
|
|
318
|
+
* this container.
|
|
319
|
+
* @param toSlot
|
|
320
|
+
* Zero-based index of the slot to transfer an item to, on
|
|
321
|
+
* `toContainer`.
|
|
322
|
+
* @param toContainer
|
|
323
|
+
* Target container to transfer to. Note this can be the same
|
|
324
|
+
* container as the source.
|
|
325
|
+
* @throws
|
|
326
|
+
* Throws if either this container or `toContainer` are invalid
|
|
327
|
+
* or if the `fromSlot` or `toSlot` indices out of bounds.
|
|
328
|
+
* @example moveItem.ts
|
|
329
|
+
* ```typescript
|
|
330
|
+
* // Move an item from the first slot of fromPlayer's inventory to the fifth slot of toPlayer's inventory
|
|
331
|
+
* const fromInventory = fromPlayer.getComponent('inventory') as EntityInventoryComponent;
|
|
332
|
+
* const toInventory = toPlayer.getComponent('inventory') as EntityInventoryComponent;
|
|
333
|
+
* fromInventory.container.moveItem(0, 4, toInventory.container);
|
|
334
|
+
*
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
moveItem(fromSlot: number, toSlot: number, toContainer: Container): void;
|
|
338
|
+
/**
|
|
339
|
+
* @remarks
|
|
340
|
+
* Sets an item stack within a particular slot.
|
|
341
|
+
*
|
|
342
|
+
* This function can't be called in read-only mode.
|
|
343
|
+
*
|
|
344
|
+
* @param slot
|
|
345
|
+
* Zero-based index of the slot to set an item at.
|
|
346
|
+
* @param itemStack
|
|
347
|
+
* Stack of items to place within the specified slot. Setting
|
|
348
|
+
* `itemStack` to undefined will clear the slot.
|
|
349
|
+
* @throws
|
|
350
|
+
* Throws if the container is invalid or if the `slot` index is
|
|
351
|
+
* out of bounds.
|
|
352
|
+
*/
|
|
353
|
+
setItem(slot: number, itemStack?: ItemStack): void;
|
|
354
|
+
/**
|
|
355
|
+
* @remarks
|
|
356
|
+
* Swaps items between two different slots within containers.
|
|
357
|
+
*
|
|
358
|
+
* This function can't be called in read-only mode.
|
|
359
|
+
*
|
|
360
|
+
* @param slot
|
|
361
|
+
* Zero-based index of the slot to swap from this container.
|
|
362
|
+
* @param otherSlot
|
|
363
|
+
* Zero-based index of the slot to swap with.
|
|
364
|
+
* @param otherContainer
|
|
365
|
+
* Target container to swap with. Note this can be the same
|
|
366
|
+
* container as this source.
|
|
367
|
+
* @throws
|
|
368
|
+
* Throws if either this container or `otherContainer` are
|
|
369
|
+
* invalid or if the `slot` or `otherSlot` are out of bounds.
|
|
370
|
+
* @example swapItems.ts
|
|
371
|
+
* ```typescript
|
|
372
|
+
* // Swaps an item between slots 0 and 4 in the player's inventory
|
|
373
|
+
* const inventory = fromPlayer.getComponent('inventory') as EntityInventoryComponent;
|
|
374
|
+
* inventory.container.swapItems(0, 4, inventory);
|
|
375
|
+
*
|
|
376
|
+
* ```
|
|
377
|
+
*/
|
|
378
|
+
swapItems(slot: number, otherSlot: number, otherContainer: Container): void;
|
|
379
|
+
/**
|
|
380
|
+
* @remarks
|
|
381
|
+
* Moves an item from one slot to another container, or to the
|
|
382
|
+
* first available slot in the same container.
|
|
383
|
+
*
|
|
384
|
+
* This function can't be called in read-only mode.
|
|
385
|
+
*
|
|
386
|
+
* @param fromSlot
|
|
387
|
+
* Zero-based index of the slot to transfer an item from, on
|
|
388
|
+
* this container.
|
|
389
|
+
* @param toContainer
|
|
390
|
+
* Target container to transfer to. Note this can be the same
|
|
391
|
+
* container as the source.
|
|
392
|
+
* @throws
|
|
393
|
+
* Throws if either this container or `toContainer` are invalid
|
|
394
|
+
* or if the `fromSlot` or `toSlot` indices out of bounds.
|
|
395
|
+
* @example transferItem.ts
|
|
396
|
+
* ```typescript
|
|
397
|
+
* // Transfer an item from the first slot of fromPlayer's inventory to toPlayer's inventory
|
|
398
|
+
* const fromInventory = fromPlayer.getComponent('inventory') as EntityInventoryComponent;
|
|
399
|
+
* const toInventory = toPlayer.getComponent('inventory') as EntityInventoryComponent;
|
|
400
|
+
* fromInventory.container.transferItem(0, toInventory.container);
|
|
401
|
+
*
|
|
402
|
+
* ```
|
|
403
|
+
*/
|
|
404
|
+
transferItem(fromSlot: number, toContainer: Container): ItemStack;
|
|
405
|
+
}
|
|
406
|
+
|
|
170
407
|
/**
|
|
171
408
|
* A class that represents a particular dimension (e.g., The
|
|
172
409
|
* End) within a world.
|
|
@@ -192,7 +429,7 @@ export class Dimension {
|
|
|
192
429
|
* Block at the specified location.
|
|
193
430
|
* @throws This function can throw errors.
|
|
194
431
|
*/
|
|
195
|
-
getBlock(location: Vector3): Block;
|
|
432
|
+
getBlock(location: Vector3): Block | undefined;
|
|
196
433
|
/**
|
|
197
434
|
* @beta
|
|
198
435
|
* @remarks
|
|
@@ -251,6 +488,14 @@ export class Dimension {
|
|
|
251
488
|
* @throws This function can throw errors.
|
|
252
489
|
*/
|
|
253
490
|
getPlayers(options?: EntityQueryOptions): Player[];
|
|
491
|
+
/**
|
|
492
|
+
* @beta
|
|
493
|
+
* @remarks
|
|
494
|
+
* This function can't be called in read-only mode.
|
|
495
|
+
*
|
|
496
|
+
* @throws This function can throw errors.
|
|
497
|
+
*/
|
|
498
|
+
runCommand(commandString: string): CommandResult;
|
|
254
499
|
/**
|
|
255
500
|
* @remarks
|
|
256
501
|
* Runs a particular command asynchronously from the context of
|
|
@@ -268,6 +513,7 @@ export class Dimension {
|
|
|
268
513
|
*/
|
|
269
514
|
runCommandAsync(commandString: string): Promise<CommandResult>;
|
|
270
515
|
}
|
|
516
|
+
|
|
271
517
|
/**
|
|
272
518
|
* Represents the state of an entity (a mob, the player, or
|
|
273
519
|
* other moving objects like minecarts) in the world.
|
|
@@ -317,6 +563,77 @@ export class Entity {
|
|
|
317
563
|
* @throws This property can throw when used.
|
|
318
564
|
*/
|
|
319
565
|
readonly typeId: string;
|
|
566
|
+
/**
|
|
567
|
+
* @beta
|
|
568
|
+
* @remarks
|
|
569
|
+
* Adds a specified tag to an entity.
|
|
570
|
+
*
|
|
571
|
+
* This function can't be called in read-only mode.
|
|
572
|
+
*
|
|
573
|
+
* @param tag
|
|
574
|
+
* Content of the tag to add.
|
|
575
|
+
* @throws This function can throw errors.
|
|
576
|
+
*/
|
|
577
|
+
addTag(tag: string): boolean;
|
|
578
|
+
/**
|
|
579
|
+
* @beta
|
|
580
|
+
* @remarks
|
|
581
|
+
* Applies a set of damage to an entity.
|
|
582
|
+
*
|
|
583
|
+
* This function can't be called in read-only mode.
|
|
584
|
+
*
|
|
585
|
+
* @param amount
|
|
586
|
+
* Amount of damage to apply.
|
|
587
|
+
* @param options
|
|
588
|
+
* Additional options about the source of damage, which may add
|
|
589
|
+
* additional effects or spur additional behaviors on this
|
|
590
|
+
* entity.
|
|
591
|
+
* @throws This function can throw errors.
|
|
592
|
+
*/
|
|
593
|
+
applyDamage(amount: number, options?: EntityApplyDamageByProjectileOptions | EntityApplyDamageOptions): boolean;
|
|
594
|
+
/**
|
|
595
|
+
* @beta
|
|
596
|
+
* @remarks
|
|
597
|
+
* Applies impulse vector to the current velocity of the
|
|
598
|
+
* entity.
|
|
599
|
+
*
|
|
600
|
+
* This function can't be called in read-only mode.
|
|
601
|
+
*
|
|
602
|
+
* @param vector
|
|
603
|
+
* Impulse vector.
|
|
604
|
+
* @throws This function can throw errors.
|
|
605
|
+
*/
|
|
606
|
+
applyImpulse(vector: Vector3): void;
|
|
607
|
+
/**
|
|
608
|
+
* @beta
|
|
609
|
+
* @remarks
|
|
610
|
+
* Applies impulse vector to the current velocity of the
|
|
611
|
+
* entity.
|
|
612
|
+
*
|
|
613
|
+
* This function can't be called in read-only mode.
|
|
614
|
+
*
|
|
615
|
+
* @param directionX
|
|
616
|
+
* X direction in horizontal plane.
|
|
617
|
+
* @param directionZ
|
|
618
|
+
* Z direction in horizontal plane.
|
|
619
|
+
* @param horizontalStrength
|
|
620
|
+
* Knockback strength for the horizontal vector.
|
|
621
|
+
* @param verticalStrength
|
|
622
|
+
* Knockback strength for the vertical vector.
|
|
623
|
+
* @throws This function can throw errors.
|
|
624
|
+
*/
|
|
625
|
+
applyKnockback(directionX: number, directionZ: number, horizontalStrength: number, verticalStrength: number): void;
|
|
626
|
+
/**
|
|
627
|
+
* @beta
|
|
628
|
+
* @remarks
|
|
629
|
+
* Sets the current velocity of the Entity to zero. Note that
|
|
630
|
+
* this method may not have an impact on Players.
|
|
631
|
+
*
|
|
632
|
+
* This function can't be called in read-only mode.
|
|
633
|
+
*
|
|
634
|
+
* @throws This function can throw errors.
|
|
635
|
+
*/
|
|
636
|
+
clearVelocity(): void;
|
|
320
637
|
/**
|
|
321
638
|
* @beta
|
|
322
639
|
* @remarks
|
|
@@ -326,6 +643,14 @@ export class Entity {
|
|
|
326
643
|
* @throws This function can throw errors.
|
|
327
644
|
*/
|
|
328
645
|
getHeadLocation(): Vector3;
|
|
646
|
+
/**
|
|
647
|
+
* @beta
|
|
648
|
+
* @remarks
|
|
649
|
+
* Returns all tags associated with an entity.
|
|
650
|
+
*
|
|
651
|
+
* @throws This function can throw errors.
|
|
652
|
+
*/
|
|
653
|
+
getTags(): string[];
|
|
329
654
|
/**
|
|
330
655
|
* @beta
|
|
331
656
|
* @remarks
|
|
@@ -342,6 +667,49 @@ export class Entity {
|
|
|
342
667
|
* @throws This function can throw errors.
|
|
343
668
|
*/
|
|
344
669
|
getViewDirection(): Vector3;
|
|
670
|
+
/**
|
|
671
|
+
* @beta
|
|
672
|
+
* @remarks
|
|
673
|
+
* Tests whether an entity has a particular tag.
|
|
674
|
+
*
|
|
675
|
+
* @param tag
|
|
676
|
+
* Identifier of the tag to test for.
|
|
677
|
+
* @throws This function can throw errors.
|
|
678
|
+
*/
|
|
679
|
+
hasTag(tag: string): boolean;
|
|
680
|
+
/**
|
|
681
|
+
* @beta
|
|
682
|
+
* @remarks
|
|
683
|
+
* Kills this entity. The entity will drop loot as normal.
|
|
684
|
+
*
|
|
685
|
+
* This function can't be called in read-only mode.
|
|
686
|
+
*
|
|
687
|
+
* @returns
|
|
688
|
+
* Returns true if entity can be killed (even if it is already
|
|
689
|
+
* dead), otherwise it returns false.
|
|
690
|
+
* @throws This function can throw errors.
|
|
691
|
+
*/
|
|
692
|
+
kill(): boolean;
|
|
693
|
+
/**
|
|
694
|
+
* @beta
|
|
695
|
+
* @remarks
|
|
696
|
+
* Removes a specified tag from an entity.
|
|
697
|
+
*
|
|
698
|
+
* This function can't be called in read-only mode.
|
|
699
|
+
*
|
|
700
|
+
* @param tag
|
|
701
|
+
* Content of the tag to remove.
|
|
702
|
+
* @throws This function can throw errors.
|
|
703
|
+
*/
|
|
704
|
+
removeTag(tag: string): boolean;
|
|
705
|
+
/**
|
|
706
|
+
* @beta
|
|
707
|
+
* @remarks
|
|
708
|
+
* This function can't be called in read-only mode.
|
|
709
|
+
*
|
|
710
|
+
* @throws This function can throw errors.
|
|
711
|
+
*/
|
|
712
|
+
runCommand(commandString: string): CommandResult;
|
|
345
713
|
/**
|
|
346
714
|
* @remarks
|
|
347
715
|
* Runs a particular command asynchronously from the context of
|
|
@@ -358,6 +726,245 @@ export class Entity {
|
|
|
358
726
|
*/
|
|
359
727
|
runCommandAsync(commandString: string): Promise<CommandResult>;
|
|
360
728
|
}
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* @beta
|
|
732
|
+
* Defines this entity's inventory properties.
|
|
733
|
+
*/
|
|
734
|
+
export class EntityInventoryComponent {
|
|
735
|
+
protected constructor();
|
|
736
|
+
/**
|
|
737
|
+
* @remarks
|
|
738
|
+
* Number of slots that this entity can gain per extra
|
|
739
|
+
* strength.
|
|
740
|
+
*
|
|
741
|
+
* @throws This property can throw when used.
|
|
742
|
+
*/
|
|
743
|
+
readonly additionalSlotsPerStrength: number;
|
|
744
|
+
/**
|
|
745
|
+
* @remarks
|
|
746
|
+
* If true, the contents of this inventory can be removed by a
|
|
747
|
+
* hopper.
|
|
748
|
+
*
|
|
749
|
+
* @throws This property can throw when used.
|
|
750
|
+
*/
|
|
751
|
+
readonly canBeSiphonedFrom: boolean;
|
|
752
|
+
/**
|
|
753
|
+
* @remarks
|
|
754
|
+
* Defines the container for this entity.
|
|
755
|
+
*
|
|
756
|
+
* @throws This property can throw when used.
|
|
757
|
+
*/
|
|
758
|
+
readonly container: Container;
|
|
759
|
+
/**
|
|
760
|
+
* @remarks
|
|
761
|
+
* Type of container this entity has.
|
|
762
|
+
*
|
|
763
|
+
* @throws This property can throw when used.
|
|
764
|
+
*/
|
|
765
|
+
readonly containerType: string;
|
|
766
|
+
/**
|
|
767
|
+
* @remarks
|
|
768
|
+
* Number of slots the container has.
|
|
769
|
+
*
|
|
770
|
+
* @throws This property can throw when used.
|
|
771
|
+
*/
|
|
772
|
+
readonly inventorySize: number;
|
|
773
|
+
/**
|
|
774
|
+
* @remarks
|
|
775
|
+
* If true, the entity will not drop it's inventory on death.
|
|
776
|
+
*
|
|
777
|
+
* @throws This property can throw when used.
|
|
778
|
+
*/
|
|
779
|
+
readonly 'private': boolean;
|
|
780
|
+
/**
|
|
781
|
+
* @remarks
|
|
782
|
+
* If true, the entity's inventory can only be accessed by its
|
|
783
|
+
* owner or itself.
|
|
784
|
+
*
|
|
785
|
+
* @throws This property can throw when used.
|
|
786
|
+
*/
|
|
787
|
+
readonly restrictToOwner: boolean;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* @beta
|
|
792
|
+
* If added onto the entity, this indicates that the entity
|
|
793
|
+
* represents a free-floating item in the world. Lets you
|
|
794
|
+
* retrieve the actual item stack contents via the itemStack
|
|
795
|
+
* property.
|
|
796
|
+
*/
|
|
797
|
+
export class EntityItemComponent {
|
|
798
|
+
protected constructor();
|
|
799
|
+
/**
|
|
800
|
+
* @remarks
|
|
801
|
+
* Item stack represented by this entity in the world.
|
|
802
|
+
*
|
|
803
|
+
* @throws This property can throw when used.
|
|
804
|
+
*/
|
|
805
|
+
readonly itemStack: ItemStack;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* @beta
|
|
810
|
+
* Base class for item components.
|
|
811
|
+
*/
|
|
812
|
+
export class ItemComponent {
|
|
813
|
+
protected constructor();
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* @beta
|
|
818
|
+
* Defines a collection of items.
|
|
819
|
+
*/
|
|
820
|
+
export class ItemStack {
|
|
821
|
+
/**
|
|
822
|
+
* @remarks
|
|
823
|
+
* Number of the items in the stack. Valid values range between
|
|
824
|
+
* 1-255. The provided value will be clamped to the item's
|
|
825
|
+
* maximum stack size.
|
|
826
|
+
*
|
|
827
|
+
* @throws
|
|
828
|
+
* Throws if the value is outside the range of 1-255.
|
|
829
|
+
*/
|
|
830
|
+
readonly amount: number;
|
|
831
|
+
/**
|
|
832
|
+
* @remarks
|
|
833
|
+
* Returns whether the item is stackable. An item is considered
|
|
834
|
+
* stackable if the item's maximum stack size is greater than 1
|
|
835
|
+
* and the item does not contain any custom data or properties.
|
|
836
|
+
*
|
|
837
|
+
*/
|
|
838
|
+
readonly isStackable: boolean;
|
|
839
|
+
/**
|
|
840
|
+
* @remarks
|
|
841
|
+
* Gets or sets whether the item is kept on death.
|
|
842
|
+
*
|
|
843
|
+
*/
|
|
844
|
+
readonly keepOnDeath: boolean;
|
|
845
|
+
/**
|
|
846
|
+
* @remarks
|
|
847
|
+
* Gets or sets the item's lock mode. The default value is
|
|
848
|
+
* `ItemLockMode.none`.
|
|
849
|
+
*
|
|
850
|
+
*/
|
|
851
|
+
readonly lockMode: ItemLockMode;
|
|
852
|
+
/**
|
|
853
|
+
* @remarks
|
|
854
|
+
* The maximum stack size. This value varies depending on the
|
|
855
|
+
* type of item. For example, torches have a maximum stack size
|
|
856
|
+
* of 64, while eggs have a maximum stack size of 16.
|
|
857
|
+
*
|
|
858
|
+
*/
|
|
859
|
+
readonly maxAmount: number;
|
|
860
|
+
/**
|
|
861
|
+
* @remarks
|
|
862
|
+
* Given name of this stack of items. The name tag is displayed
|
|
863
|
+
* when hovering over the item. Setting the name tag to an
|
|
864
|
+
* empty string or `undefined` will remove the name tag.
|
|
865
|
+
*
|
|
866
|
+
* @throws
|
|
867
|
+
* Throws if the length exceeds 255 characters.
|
|
868
|
+
*/
|
|
869
|
+
readonly nameTag?: string;
|
|
870
|
+
/**
|
|
871
|
+
* @remarks
|
|
872
|
+
* The type of the item.
|
|
873
|
+
*
|
|
874
|
+
*/
|
|
875
|
+
readonly 'type': ItemType;
|
|
876
|
+
/**
|
|
877
|
+
* @remarks
|
|
878
|
+
* Identifier of the type of items for the stack. If a
|
|
879
|
+
* namespace is not specified, 'minecraft:' is assumed.
|
|
880
|
+
* Examples include 'wheat' or 'apple'.
|
|
881
|
+
*
|
|
882
|
+
*/
|
|
883
|
+
readonly typeId: string;
|
|
884
|
+
/**
|
|
885
|
+
* @remarks
|
|
886
|
+
* Creates a new instance of a stack of items for use in the
|
|
887
|
+
* world.
|
|
888
|
+
*
|
|
889
|
+
* @param itemType
|
|
890
|
+
* Type of item to create. See the {@link MinecraftItemTypes}
|
|
891
|
+
* enumeration for a list of standard item types in Minecraft
|
|
892
|
+
* experiences.
|
|
893
|
+
* @param amount
|
|
894
|
+
* Number of items to place in the stack, between 1-255. The
|
|
895
|
+
* provided value will be clamped to the item's maximum stack
|
|
896
|
+
* size. Note that certain items can only have one item in the
|
|
897
|
+
* stack.
|
|
898
|
+
* @throws
|
|
899
|
+
* Throws if `itemType` is invalid, or if `amount` is outside
|
|
900
|
+
* the range of 1-255.
|
|
901
|
+
*/
|
|
902
|
+
constructor(itemType: ItemType | string, amount?: number);
|
|
903
|
+
/**
|
|
904
|
+
* @remarks
|
|
905
|
+
* Gets a component (that represents additional capabilities)
|
|
906
|
+
* for an item stack.
|
|
907
|
+
*
|
|
908
|
+
* @param componentId
|
|
909
|
+
* The identifier of the component (e.g., 'minecraft:food') to
|
|
910
|
+
* retrieve. If no namespace prefix is specified, 'minecraft:'
|
|
911
|
+
* is assumed. If the component is not present on the item
|
|
912
|
+
* stack, undefined is returned.
|
|
913
|
+
* @example durability.ts
|
|
914
|
+
* ```typescript
|
|
915
|
+
* // Get the maximum durability of a custom sword item
|
|
916
|
+
* const itemStack = new ItemStack("custom:sword");
|
|
917
|
+
* const durability = itemStack.getComponent("minecraft:durability") as ItemDurabilityComponent;
|
|
918
|
+
* const maxDurability = durability.maxDurability;
|
|
919
|
+
*
|
|
920
|
+
* ```
|
|
921
|
+
*/
|
|
922
|
+
getComponent(componentId: string): ItemComponent | undefined;
|
|
923
|
+
/**
|
|
924
|
+
* @remarks
|
|
925
|
+
* Returns all components that are both present on this item
|
|
926
|
+
* stack and supported by the API.
|
|
927
|
+
*
|
|
928
|
+
*/
|
|
929
|
+
getComponents(): ItemComponent[];
|
|
930
|
+
/**
|
|
931
|
+
* @remarks
|
|
932
|
+
* Returns true if the specified component is present on this
|
|
933
|
+
* item stack.
|
|
934
|
+
*
|
|
935
|
+
* @param componentId
|
|
936
|
+
* The identifier of the component (e.g., 'minecraft:food') to
|
|
937
|
+
* retrieve. If no namespace prefix is specified, 'minecraft:'
|
|
938
|
+
* is assumed.
|
|
939
|
+
*/
|
|
940
|
+
hasComponent(componentId: string): boolean;
|
|
941
|
+
/**
|
|
942
|
+
* @remarks
|
|
943
|
+
* Returns whether this item stack can be stacked with the
|
|
944
|
+
* given `itemStack`. This is determined by comparing the item
|
|
945
|
+
* type and any custom data and properties associated with the
|
|
946
|
+
* item stacks. The amount of each item stack is not taken into
|
|
947
|
+
* consideration.
|
|
948
|
+
*
|
|
949
|
+
*/
|
|
950
|
+
isStackableWith(itemStack: ItemStack): boolean;
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
/**
|
|
954
|
+
* @beta
|
|
955
|
+
* Represents the type of an item - for example, Wool.
|
|
956
|
+
*/
|
|
957
|
+
export class ItemType {
|
|
958
|
+
protected constructor();
|
|
959
|
+
/**
|
|
960
|
+
* @remarks
|
|
961
|
+
* Returns the identifier of the item type - for example,
|
|
962
|
+
* 'minecraft:apple'.
|
|
963
|
+
*
|
|
964
|
+
*/
|
|
965
|
+
readonly id: string;
|
|
966
|
+
}
|
|
967
|
+
|
|
361
968
|
/**
|
|
362
969
|
* A collection of default Minecraft dimension types.
|
|
363
970
|
*/
|
|
@@ -397,6 +1004,7 @@ export class MinecraftDimensionTypes {
|
|
|
397
1004
|
*/
|
|
398
1005
|
static readonly theEnd = 'minecraft:the_end';
|
|
399
1006
|
}
|
|
1007
|
+
|
|
400
1008
|
/**
|
|
401
1009
|
* Represents a player within the world.
|
|
402
1010
|
*/
|
|
@@ -409,6 +1017,20 @@ export class Player extends Entity {
|
|
|
409
1017
|
* @throws This property can throw when used.
|
|
410
1018
|
*/
|
|
411
1019
|
readonly name: string;
|
|
1020
|
+
/**
|
|
1021
|
+
* @beta
|
|
1022
|
+
* @remarks
|
|
1023
|
+
* Plays a sound that only this particular player can hear.
|
|
1024
|
+
*
|
|
1025
|
+
* This function can't be called in read-only mode.
|
|
1026
|
+
*
|
|
1027
|
+
* @param soundID
|
|
1028
|
+
* Identifier of the sound to play.
|
|
1029
|
+
* @param soundOptions
|
|
1030
|
+
* Additional optional options for the sound.
|
|
1031
|
+
* @throws This function can throw errors.
|
|
1032
|
+
*/
|
|
1033
|
+
playSound(soundID: string, soundOptions?: PlayerSoundOptions): void;
|
|
412
1034
|
/**
|
|
413
1035
|
* @beta
|
|
414
1036
|
* @remarks
|
|
@@ -453,6 +1075,7 @@ export class Player extends Entity {
|
|
|
453
1075
|
*/
|
|
454
1076
|
sendMessage(message: (RawMessage | string)[] | RawMessage | string): void;
|
|
455
1077
|
}
|
|
1078
|
+
|
|
456
1079
|
/**
|
|
457
1080
|
* A class that provides system-level events and functions.
|
|
458
1081
|
*/
|
|
@@ -518,6 +1141,7 @@ export class System {
|
|
|
518
1141
|
*/
|
|
519
1142
|
runTimeout(callback: () => void, tickDelay?: number): number;
|
|
520
1143
|
}
|
|
1144
|
+
|
|
521
1145
|
/**
|
|
522
1146
|
* A class that wraps the state of a world - a set of
|
|
523
1147
|
* dimensions and the environment of Minecraft.
|
|
@@ -555,6 +1179,37 @@ export class World {
|
|
|
555
1179
|
* @throws This function can throw errors.
|
|
556
1180
|
*/
|
|
557
1181
|
getPlayers(options?: EntityQueryOptions): Player[];
|
|
1182
|
+
/**
|
|
1183
|
+
* @beta
|
|
1184
|
+
* @remarks
|
|
1185
|
+
* Plays a particular music track for all players.
|
|
1186
|
+
*
|
|
1187
|
+
* This function can't be called in read-only mode.
|
|
1188
|
+
*
|
|
1189
|
+
* @throws This function can throw errors.
|
|
1190
|
+
*/
|
|
1191
|
+
playMusic(trackID: string, musicOptions?: MusicOptions): void;
|
|
1192
|
+
/**
|
|
1193
|
+
* @beta
|
|
1194
|
+
* @remarks
|
|
1195
|
+
* Plays a sound for all players.
|
|
1196
|
+
*
|
|
1197
|
+
* This function can't be called in read-only mode.
|
|
1198
|
+
*
|
|
1199
|
+
* @throws This function can throw errors.
|
|
1200
|
+
*/
|
|
1201
|
+
playSound(soundID: string, location: Vector3, soundOptions?: WorldSoundOptions): void;
|
|
1202
|
+
/**
|
|
1203
|
+
* @beta
|
|
1204
|
+
* @remarks
|
|
1205
|
+
* Queues an additional music track for players. If a track is
|
|
1206
|
+
* not playing, a music track will play.
|
|
1207
|
+
*
|
|
1208
|
+
* This function can't be called in read-only mode.
|
|
1209
|
+
*
|
|
1210
|
+
* @throws This function can throw errors.
|
|
1211
|
+
*/
|
|
1212
|
+
queueMusic(trackID: string, musicOptions?: MusicOptions): void;
|
|
558
1213
|
/**
|
|
559
1214
|
* @beta
|
|
560
1215
|
* @remarks
|
|
@@ -598,7 +1253,33 @@ export class World {
|
|
|
598
1253
|
* ```
|
|
599
1254
|
*/
|
|
600
1255
|
sendMessage(message: (RawMessage | string)[] | RawMessage | string): void;
|
|
1256
|
+
/**
|
|
1257
|
+
* @beta
|
|
1258
|
+
* @remarks
|
|
1259
|
+
* Stops any music tracks from playing.
|
|
1260
|
+
*
|
|
1261
|
+
* This function can't be called in read-only mode.
|
|
1262
|
+
*
|
|
1263
|
+
*/
|
|
1264
|
+
stopMusic(): void;
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
/**
|
|
1268
|
+
* @beta
|
|
1269
|
+
*/
|
|
1270
|
+
export interface EntityApplyDamageByProjectileOptions {
|
|
1271
|
+
damagingEntity?: Entity;
|
|
1272
|
+
damagingProjectile: Entity;
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
/**
|
|
1276
|
+
* @beta
|
|
1277
|
+
*/
|
|
1278
|
+
export interface EntityApplyDamageOptions {
|
|
1279
|
+
cause: EntityDamageCause;
|
|
1280
|
+
damagingEntity?: Entity;
|
|
601
1281
|
}
|
|
1282
|
+
|
|
602
1283
|
/**
|
|
603
1284
|
* @beta
|
|
604
1285
|
* Contains options for selecting entities within an area.
|
|
@@ -761,6 +1442,7 @@ export interface EntityQueryOptions {
|
|
|
761
1442
|
*/
|
|
762
1443
|
type?: string;
|
|
763
1444
|
}
|
|
1445
|
+
|
|
764
1446
|
/**
|
|
765
1447
|
* @beta
|
|
766
1448
|
* Contains additional options for filtering players based on
|
|
@@ -795,6 +1477,42 @@ export interface EntityQueryScoreOptions {
|
|
|
795
1477
|
*/
|
|
796
1478
|
objective?: string;
|
|
797
1479
|
}
|
|
1480
|
+
|
|
1481
|
+
/**
|
|
1482
|
+
* @beta
|
|
1483
|
+
* Additional configuration options for {@link
|
|
1484
|
+
* World.playMusic}/{@link World.queueMusic} methods.
|
|
1485
|
+
*/
|
|
1486
|
+
export interface MusicOptions {
|
|
1487
|
+
/**
|
|
1488
|
+
* @remarks
|
|
1489
|
+
* Specifies a fade overlap for music at the end of play.
|
|
1490
|
+
*
|
|
1491
|
+
*/
|
|
1492
|
+
fade?: number;
|
|
1493
|
+
/**
|
|
1494
|
+
* @remarks
|
|
1495
|
+
* If set to true, this music track will play repeatedly.
|
|
1496
|
+
*
|
|
1497
|
+
*/
|
|
1498
|
+
loop?: boolean;
|
|
1499
|
+
/**
|
|
1500
|
+
* @remarks
|
|
1501
|
+
* Relative volume level of the music.
|
|
1502
|
+
*
|
|
1503
|
+
*/
|
|
1504
|
+
volume?: number;
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
/**
|
|
1508
|
+
* @beta
|
|
1509
|
+
*/
|
|
1510
|
+
export interface PlayerSoundOptions {
|
|
1511
|
+
location?: Vector3;
|
|
1512
|
+
pitch?: number;
|
|
1513
|
+
volume?: number;
|
|
1514
|
+
}
|
|
1515
|
+
|
|
798
1516
|
/**
|
|
799
1517
|
* @beta
|
|
800
1518
|
*/
|
|
@@ -805,6 +1523,7 @@ export interface RawMessage {
|
|
|
805
1523
|
translate?: string;
|
|
806
1524
|
with?: string[] | RawMessage;
|
|
807
1525
|
}
|
|
1526
|
+
|
|
808
1527
|
/**
|
|
809
1528
|
* @beta
|
|
810
1529
|
*/
|
|
@@ -812,6 +1531,7 @@ export interface RawMessageScore {
|
|
|
812
1531
|
name?: string;
|
|
813
1532
|
objective?: string;
|
|
814
1533
|
}
|
|
1534
|
+
|
|
815
1535
|
/**
|
|
816
1536
|
* @beta
|
|
817
1537
|
* Contains a description of a vector.
|
|
@@ -836,6 +1556,15 @@ export interface Vector3 {
|
|
|
836
1556
|
*/
|
|
837
1557
|
z: number;
|
|
838
1558
|
}
|
|
1559
|
+
|
|
1560
|
+
/**
|
|
1561
|
+
* @beta
|
|
1562
|
+
*/
|
|
1563
|
+
export interface WorldSoundOptions {
|
|
1564
|
+
pitch?: number;
|
|
1565
|
+
volume?: number;
|
|
1566
|
+
}
|
|
1567
|
+
|
|
839
1568
|
/**
|
|
840
1569
|
* @remarks
|
|
841
1570
|
* A class that provides system-level events and functions.
|