@minecraft/server 1.2.0-rc.1.20.0-preview.24 → 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 +62 -76
- 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.
|
|
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[];
|
|
@@ -1635,11 +1630,10 @@ export class ItemStack {
|
|
|
1635
1630
|
* stack, undefined is returned.
|
|
1636
1631
|
* @example durability.ts
|
|
1637
1632
|
* ```typescript
|
|
1638
|
-
*
|
|
1639
|
-
*
|
|
1640
|
-
*
|
|
1641
|
-
*
|
|
1642
|
-
*
|
|
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;
|
|
1643
1637
|
* ```
|
|
1644
1638
|
*/
|
|
1645
1639
|
getComponent(componentId: string): ItemComponent | undefined;
|
|
@@ -1767,33 +1761,29 @@ export class Player extends Entity {
|
|
|
1767
1761
|
* is provided to `score`.
|
|
1768
1762
|
* @example nestedTranslation.ts
|
|
1769
1763
|
* ```typescript
|
|
1770
|
-
*
|
|
1771
|
-
*
|
|
1772
|
-
*
|
|
1773
|
-
*
|
|
1774
|
-
*
|
|
1775
|
-
*
|
|
1776
|
-
*
|
|
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);
|
|
1777
1770
|
* ```
|
|
1778
1771
|
* @example scoreWildcard.ts
|
|
1779
1772
|
* ```typescript
|
|
1780
|
-
*
|
|
1781
|
-
*
|
|
1782
|
-
*
|
|
1783
|
-
*
|
|
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);
|
|
1784
1776
|
* ```
|
|
1785
1777
|
* @example simpleString.ts
|
|
1786
1778
|
* ```typescript
|
|
1787
|
-
*
|
|
1788
|
-
*
|
|
1789
|
-
*
|
|
1779
|
+
* // Displays "Hello, world!"
|
|
1780
|
+
* world.sendMessage("Hello, world!");
|
|
1790
1781
|
* ```
|
|
1791
1782
|
* @example translation.ts
|
|
1792
1783
|
* ```typescript
|
|
1793
|
-
*
|
|
1794
|
-
*
|
|
1795
|
-
*
|
|
1796
|
-
*
|
|
1784
|
+
* // Displays "First or Second"
|
|
1785
|
+
* const rawMessage = { translate: "accessibility.list.or.two", with: ["First", "Second"] };
|
|
1786
|
+
* player.sendMessage(rawMessage);
|
|
1797
1787
|
* ```
|
|
1798
1788
|
*/
|
|
1799
1789
|
sendMessage(message: (RawMessage | string)[] | RawMessage | string): void;
|
|
@@ -1946,33 +1936,29 @@ export class World {
|
|
|
1946
1936
|
* is provided to `score`.
|
|
1947
1937
|
* @example nestedTranslation.ts
|
|
1948
1938
|
* ```typescript
|
|
1949
|
-
*
|
|
1950
|
-
*
|
|
1951
|
-
*
|
|
1952
|
-
*
|
|
1953
|
-
*
|
|
1954
|
-
*
|
|
1955
|
-
*
|
|
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);
|
|
1956
1945
|
* ```
|
|
1957
1946
|
* @example scoreWildcard.ts
|
|
1958
1947
|
* ```typescript
|
|
1959
|
-
*
|
|
1960
|
-
*
|
|
1961
|
-
*
|
|
1962
|
-
*
|
|
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);
|
|
1963
1951
|
* ```
|
|
1964
1952
|
* @example simpleString.ts
|
|
1965
1953
|
* ```typescript
|
|
1966
|
-
*
|
|
1967
|
-
*
|
|
1968
|
-
*
|
|
1954
|
+
* // Displays "Hello, world!"
|
|
1955
|
+
* world.sendMessage("Hello, world!");
|
|
1969
1956
|
* ```
|
|
1970
1957
|
* @example translation.ts
|
|
1971
1958
|
* ```typescript
|
|
1972
|
-
*
|
|
1973
|
-
*
|
|
1974
|
-
*
|
|
1975
|
-
*
|
|
1959
|
+
* // Displays "First or Second"
|
|
1960
|
+
* const rawMessage = { translate: "accessibility.list.or.two", with: ["First", "Second"] };
|
|
1961
|
+
* world.sendMessage(rawMessage);
|
|
1976
1962
|
* ```
|
|
1977
1963
|
*/
|
|
1978
1964
|
sendMessage(message: (RawMessage | string)[] | RawMessage | string): void;
|