@minecraft/server 1.2.0-rc.1.20.0-preview.23 → 1.2.0-rc.1.20.0-preview.25
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 +98 -77
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
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.25"
|
|
20
20
|
* }
|
|
21
21
|
* ```
|
|
22
22
|
*
|
|
@@ -320,10 +320,9 @@ export class Container {
|
|
|
320
320
|
* out of bounds.
|
|
321
321
|
* @example getItem.ts
|
|
322
322
|
* ```typescript
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
323
|
+
* // Get a copy of the first item in the player's hotbar
|
|
324
|
+
* const inventory = player.getComponent("inventory") as EntityInventoryComponent;
|
|
325
|
+
* const itemStack = inventory.container.getItem(0);
|
|
327
326
|
* ```
|
|
328
327
|
*/
|
|
329
328
|
getItem(slot: number): ItemStack | undefined;
|
|
@@ -348,11 +347,10 @@ export class Container {
|
|
|
348
347
|
* or if the `fromSlot` or `toSlot` indices out of bounds.
|
|
349
348
|
* @example moveItem.ts
|
|
350
349
|
* ```typescript
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
350
|
+
* // Move an item from the first slot of fromPlayer's inventory to the fifth slot of toPlayer's inventory
|
|
351
|
+
* const fromInventory = fromPlayer.getComponent('inventory') as EntityInventoryComponent;
|
|
352
|
+
* const toInventory = toPlayer.getComponent('inventory') as EntityInventoryComponent;
|
|
353
|
+
* fromInventory.container.moveItem(0, 4, toInventory.container);
|
|
356
354
|
* ```
|
|
357
355
|
*/
|
|
358
356
|
moveItem(fromSlot: number, toSlot: number, toContainer: Container): void;
|
|
@@ -390,10 +388,9 @@ export class Container {
|
|
|
390
388
|
* invalid or if the `slot` or `otherSlot` are out of bounds.
|
|
391
389
|
* @example swapItems.ts
|
|
392
390
|
* ```typescript
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
391
|
+
* // Swaps an item between slots 0 and 4 in the player's inventory
|
|
392
|
+
* const inventory = fromPlayer.getComponent('inventory') as EntityInventoryComponent;
|
|
393
|
+
* inventory.container.swapItems(0, 4, inventory);
|
|
397
394
|
* ```
|
|
398
395
|
*/
|
|
399
396
|
swapItems(slot: number, otherSlot: number, otherContainer: Container): void;
|
|
@@ -415,11 +412,10 @@ export class Container {
|
|
|
415
412
|
* or if the `fromSlot` or `toSlot` indices out of bounds.
|
|
416
413
|
* @example transferItem.ts
|
|
417
414
|
* ```typescript
|
|
418
|
-
*
|
|
419
|
-
*
|
|
420
|
-
*
|
|
421
|
-
*
|
|
422
|
-
*
|
|
415
|
+
* // Transfer an item from the first slot of fromPlayer's inventory to toPlayer's inventory
|
|
416
|
+
* const fromInventory = fromPlayer.getComponent('inventory') as EntityInventoryComponent;
|
|
417
|
+
* const toInventory = toPlayer.getComponent('inventory') as EntityInventoryComponent;
|
|
418
|
+
* fromInventory.container.transferItem(0, toInventory.container);
|
|
423
419
|
* ```
|
|
424
420
|
*/
|
|
425
421
|
transferItem(fromSlot: number, toContainer: Container): ItemStack;
|
|
@@ -464,22 +460,21 @@ export class Dimension {
|
|
|
464
460
|
* @throws This function can throw errors.
|
|
465
461
|
* @example testThatEntityIsFeatherItem.ts
|
|
466
462
|
* ```typescript
|
|
467
|
-
*
|
|
468
|
-
*
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
478
|
-
*
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
-
*
|
|
463
|
+
* const query = {
|
|
464
|
+
* type: "item",
|
|
465
|
+
* location: targetLocation,
|
|
466
|
+
* };
|
|
467
|
+
* const items = overworld.getEntities(query);
|
|
468
|
+
*
|
|
469
|
+
* for (const item of items) {
|
|
470
|
+
* const itemComp = item.getComponent("item") as any;
|
|
471
|
+
*
|
|
472
|
+
* if (itemComp) {
|
|
473
|
+
* if (itemComp.itemStack.id.endsWith("feather")) {
|
|
474
|
+
* console.log("Success! Found a feather", 1);
|
|
475
|
+
* }
|
|
476
|
+
* }
|
|
477
|
+
* }
|
|
483
478
|
* ```
|
|
484
479
|
*/
|
|
485
480
|
getEntities(options?: EntityQueryOptions): Entity[];
|
|
@@ -592,6 +587,9 @@ export class Entity {
|
|
|
592
587
|
*
|
|
593
588
|
* @param tag
|
|
594
589
|
* Content of the tag to add.
|
|
590
|
+
* @returns
|
|
591
|
+
* Returns true if the tag was added successfully. This can
|
|
592
|
+
* fail if the tag already exists on the entity.
|
|
595
593
|
* @throws This function can throw errors.
|
|
596
594
|
*/
|
|
597
595
|
addTag(tag: string): boolean;
|
|
@@ -608,6 +606,10 @@ export class Entity {
|
|
|
608
606
|
* Additional options about the source of damage, which may add
|
|
609
607
|
* additional effects or spur additional behaviors on this
|
|
610
608
|
* entity.
|
|
609
|
+
* @returns
|
|
610
|
+
* Whether the entity takes any damage. This can return false
|
|
611
|
+
* if the entity is invulnerable or if the damage applied is
|
|
612
|
+
* less than or equal to 0.
|
|
611
613
|
* @throws This function can throw errors.
|
|
612
614
|
*/
|
|
613
615
|
applyDamage(amount: number, options?: EntityApplyDamageByProjectileOptions | EntityApplyDamageOptions): boolean;
|
|
@@ -665,6 +667,9 @@ export class Entity {
|
|
|
665
667
|
* to retrieve. If no namespace prefix is specified,
|
|
666
668
|
* 'minecraft:' is assumed. If the component is not present on
|
|
667
669
|
* the entity, undefined is returned.
|
|
670
|
+
* @returns
|
|
671
|
+
* Returns the component if it exists on the entity, otherwise
|
|
672
|
+
* undefined.
|
|
668
673
|
*/
|
|
669
674
|
getComponent(componentId: string): EntityComponent | undefined;
|
|
670
675
|
/**
|
|
@@ -673,6 +678,9 @@ export class Entity {
|
|
|
673
678
|
* Returns all components that are both present on this entity
|
|
674
679
|
* and supported by the API.
|
|
675
680
|
*
|
|
681
|
+
* @returns
|
|
682
|
+
* Returns all components that are both present on this entity
|
|
683
|
+
* and supported by the API.
|
|
676
684
|
*/
|
|
677
685
|
getComponents(): EntityComponent[];
|
|
678
686
|
/**
|
|
@@ -681,6 +689,9 @@ export class Entity {
|
|
|
681
689
|
* Returns the current location of the head component of this
|
|
682
690
|
* entity.
|
|
683
691
|
*
|
|
692
|
+
* @returns
|
|
693
|
+
* Returns the current location of the head component of this
|
|
694
|
+
* entity.
|
|
684
695
|
* @throws This function can throw errors.
|
|
685
696
|
*/
|
|
686
697
|
getHeadLocation(): Vector3;
|
|
@@ -689,6 +700,8 @@ export class Entity {
|
|
|
689
700
|
* @remarks
|
|
690
701
|
* Returns all tags associated with an entity.
|
|
691
702
|
*
|
|
703
|
+
* @returns
|
|
704
|
+
* Returns the current rotation component of this entity.
|
|
692
705
|
* @throws This function can throw errors.
|
|
693
706
|
*/
|
|
694
707
|
getTags(): string[];
|
|
@@ -697,6 +710,8 @@ export class Entity {
|
|
|
697
710
|
* @remarks
|
|
698
711
|
* Returns the current velocity vector of the entity.
|
|
699
712
|
*
|
|
713
|
+
* @returns
|
|
714
|
+
* Returns the current velocity vector of the entity.
|
|
700
715
|
* @throws This function can throw errors.
|
|
701
716
|
*/
|
|
702
717
|
getVelocity(): Vector3;
|
|
@@ -705,6 +720,8 @@ export class Entity {
|
|
|
705
720
|
* @remarks
|
|
706
721
|
* Returns the current view direction of the entity.
|
|
707
722
|
*
|
|
723
|
+
* @returns
|
|
724
|
+
* Returns the current view direction of the entity.
|
|
708
725
|
* @throws This function can throw errors.
|
|
709
726
|
*/
|
|
710
727
|
getViewDirection(): Vector3;
|
|
@@ -718,15 +735,20 @@ export class Entity {
|
|
|
718
735
|
* The identifier of the component (e.g., 'minecraft:rideable')
|
|
719
736
|
* to retrieve. If no namespace prefix is specified,
|
|
720
737
|
* 'minecraft:' is assumed.
|
|
738
|
+
* @returns
|
|
739
|
+
* Returns true if the specified component is present on this
|
|
740
|
+
* entity.
|
|
721
741
|
*/
|
|
722
742
|
hasComponent(componentId: string): boolean;
|
|
723
743
|
/**
|
|
724
744
|
* @beta
|
|
725
745
|
* @remarks
|
|
726
|
-
*
|
|
746
|
+
* Returns whether an entity has a particular tag.
|
|
727
747
|
*
|
|
728
748
|
* @param tag
|
|
729
749
|
* Identifier of the tag to test for.
|
|
750
|
+
* @returns
|
|
751
|
+
* Returns whether an entity has a particular tag.
|
|
730
752
|
* @throws This function can throw errors.
|
|
731
753
|
*/
|
|
732
754
|
hasTag(tag: string): boolean;
|
|
@@ -752,6 +774,8 @@ export class Entity {
|
|
|
752
774
|
*
|
|
753
775
|
* @param tag
|
|
754
776
|
* Content of the tag to remove.
|
|
777
|
+
* @returns
|
|
778
|
+
* Returns whether the tag existed on the entity.
|
|
755
779
|
* @throws This function can throw errors.
|
|
756
780
|
*/
|
|
757
781
|
removeTag(tag: string): boolean;
|
|
@@ -762,6 +786,12 @@ export class Entity {
|
|
|
762
786
|
*
|
|
763
787
|
* This function can't be called in read-only mode.
|
|
764
788
|
*
|
|
789
|
+
* @param commandString
|
|
790
|
+
* The command string. Note: This should not include a leading
|
|
791
|
+
* forward slash.
|
|
792
|
+
* @returns
|
|
793
|
+
* A command result containing whether the command was
|
|
794
|
+
* successful.
|
|
765
795
|
* @throws This function can throw errors.
|
|
766
796
|
*/
|
|
767
797
|
runCommand(commandString: string): CommandResult;
|
|
@@ -1600,11 +1630,10 @@ export class ItemStack {
|
|
|
1600
1630
|
* stack, undefined is returned.
|
|
1601
1631
|
* @example durability.ts
|
|
1602
1632
|
* ```typescript
|
|
1603
|
-
*
|
|
1604
|
-
*
|
|
1605
|
-
*
|
|
1606
|
-
*
|
|
1607
|
-
*
|
|
1633
|
+
* // Get the maximum durability of a custom sword item
|
|
1634
|
+
* const itemStack = new ItemStack("custom:sword");
|
|
1635
|
+
* const durability = itemStack.getComponent("minecraft:durability") as ItemDurabilityComponent;
|
|
1636
|
+
* const maxDurability = durability.maxDurability;
|
|
1608
1637
|
* ```
|
|
1609
1638
|
*/
|
|
1610
1639
|
getComponent(componentId: string): ItemComponent | undefined;
|
|
@@ -1732,33 +1761,29 @@ export class Player extends Entity {
|
|
|
1732
1761
|
* is provided to `score`.
|
|
1733
1762
|
* @example nestedTranslation.ts
|
|
1734
1763
|
* ```typescript
|
|
1735
|
-
*
|
|
1736
|
-
*
|
|
1737
|
-
*
|
|
1738
|
-
*
|
|
1739
|
-
*
|
|
1740
|
-
*
|
|
1741
|
-
*
|
|
1764
|
+
* // Displays "Apple or Coal"
|
|
1765
|
+
* let rawMessage = {
|
|
1766
|
+
* translate: "accessibility.list.or.two",
|
|
1767
|
+
* with: { rawtext: [{ translate: "item.apple.name" }, { translate: "item.coal.name" }] },
|
|
1768
|
+
* };
|
|
1769
|
+
* player.sendMessage(rawMessage);
|
|
1742
1770
|
* ```
|
|
1743
1771
|
* @example scoreWildcard.ts
|
|
1744
1772
|
* ```typescript
|
|
1745
|
-
*
|
|
1746
|
-
*
|
|
1747
|
-
*
|
|
1748
|
-
*
|
|
1773
|
+
* // Displays the player's score for objective "obj". Each player will see their own score.
|
|
1774
|
+
* const rawMessage = { score: { name: "*", objective: "obj" } };
|
|
1775
|
+
* world.sendMessage(rawMessage);
|
|
1749
1776
|
* ```
|
|
1750
1777
|
* @example simpleString.ts
|
|
1751
1778
|
* ```typescript
|
|
1752
|
-
*
|
|
1753
|
-
*
|
|
1754
|
-
*
|
|
1779
|
+
* // Displays "Hello, world!"
|
|
1780
|
+
* world.sendMessage("Hello, world!");
|
|
1755
1781
|
* ```
|
|
1756
1782
|
* @example translation.ts
|
|
1757
1783
|
* ```typescript
|
|
1758
|
-
*
|
|
1759
|
-
*
|
|
1760
|
-
*
|
|
1761
|
-
*
|
|
1784
|
+
* // Displays "First or Second"
|
|
1785
|
+
* const rawMessage = { translate: "accessibility.list.or.two", with: ["First", "Second"] };
|
|
1786
|
+
* player.sendMessage(rawMessage);
|
|
1762
1787
|
* ```
|
|
1763
1788
|
*/
|
|
1764
1789
|
sendMessage(message: (RawMessage | string)[] | RawMessage | string): void;
|
|
@@ -1911,33 +1936,29 @@ export class World {
|
|
|
1911
1936
|
* is provided to `score`.
|
|
1912
1937
|
* @example nestedTranslation.ts
|
|
1913
1938
|
* ```typescript
|
|
1914
|
-
*
|
|
1915
|
-
*
|
|
1916
|
-
*
|
|
1917
|
-
*
|
|
1918
|
-
*
|
|
1919
|
-
*
|
|
1920
|
-
*
|
|
1939
|
+
* // Displays "Apple or Coal"
|
|
1940
|
+
* let rawMessage = {
|
|
1941
|
+
* translate: "accessibility.list.or.two",
|
|
1942
|
+
* with: { rawtext: [{ translate: "item.apple.name" }, { translate: "item.coal.name" }] },
|
|
1943
|
+
* };
|
|
1944
|
+
* world.sendMessage(rawMessage);
|
|
1921
1945
|
* ```
|
|
1922
1946
|
* @example scoreWildcard.ts
|
|
1923
1947
|
* ```typescript
|
|
1924
|
-
*
|
|
1925
|
-
*
|
|
1926
|
-
*
|
|
1927
|
-
*
|
|
1948
|
+
* // Displays the player's score for objective "obj". Each player will see their own score.
|
|
1949
|
+
* const rawMessage = { score: { name: "*", objective: "obj" } };
|
|
1950
|
+
* world.sendMessage(rawMessage);
|
|
1928
1951
|
* ```
|
|
1929
1952
|
* @example simpleString.ts
|
|
1930
1953
|
* ```typescript
|
|
1931
|
-
*
|
|
1932
|
-
*
|
|
1933
|
-
*
|
|
1954
|
+
* // Displays "Hello, world!"
|
|
1955
|
+
* world.sendMessage("Hello, world!");
|
|
1934
1956
|
* ```
|
|
1935
1957
|
* @example translation.ts
|
|
1936
1958
|
* ```typescript
|
|
1937
|
-
*
|
|
1938
|
-
*
|
|
1939
|
-
*
|
|
1940
|
-
*
|
|
1959
|
+
* // Displays "First or Second"
|
|
1960
|
+
* const rawMessage = { translate: "accessibility.list.or.two", with: ["First", "Second"] };
|
|
1961
|
+
* world.sendMessage(rawMessage);
|
|
1941
1962
|
* ```
|
|
1942
1963
|
*/
|
|
1943
1964
|
sendMessage(message: (RawMessage | string)[] | RawMessage | string): void;
|