@minecraft/server 1.1.0-beta.1.19.70-preview.23 → 1.1.0-beta.1.19.70-preview.24

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.
Files changed (2) hide show
  1. package/index.d.ts +334 -353
  2. 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.1.0-internal.1.19.70-preview.23"
19
+ * "version": "1.1.0-internal.1.19.70-preview.24"
20
20
  * }
21
21
  * ```
22
22
  *
@@ -996,117 +996,17 @@ export class BlockInventoryComponent extends BlockComponent {
996
996
  */
997
997
  static readonly componentId = 'minecraft:inventory';
998
998
  }
999
- /**
1000
- * @beta
1001
- * Represents the inventory of a {@link Block} in the world.
1002
- * Used with blocks like chests.
1003
- */
1004
999
  export class BlockInventoryComponentContainer extends Container {
1005
1000
  protected constructor();
1006
- /**
1007
- * Contains a count of the slots in the container that are
1008
- * empty.
1009
- * @throws This property can throw when used.
1010
- */
1011
1001
  readonly emptySlotsCount: number;
1012
- /**
1013
- * Returns the size capacity of the inventory container on this
1014
- * block.
1015
- * @throws This property can throw when used.
1016
- */
1017
1002
  readonly size: number;
1018
- /**
1019
- * @remarks
1020
- * Adds an item to the specified container. Item will be placed
1021
- * in the first available empty slot. (use .setItem if you wish
1022
- * to set items in a particular slot.)
1023
- * @param itemStack
1024
- * The stack of items to add.
1025
- * @throws This function can throw errors.
1026
- */
1027
1003
  addItem(itemStack: ItemStack): void;
1028
- /**
1029
- * @remarks
1030
- * Clears the entirety of the inventory of this block (i.e.,
1031
- * chest)
1032
- * @throws This function can throw errors.
1033
- */
1034
1004
  clearAll(): void;
1035
- /**
1036
- * @remarks
1037
- * Clears a specific item within the chest.
1038
- * @param slot
1039
- * @throws This function can throw errors.
1040
- */
1041
1005
  clearItem(slot: number): void;
1042
- /**
1043
- * @remarks
1044
- * Gets the item stack for the set of items at the specified
1045
- * slot. If the slot is empty, returns undefined. This method
1046
- * does not change or clear the contents of the specified slot.
1047
- * @param slot
1048
- * Zero-based index of the slot to retrieve items from.
1049
- * @throws This function can throw errors.
1050
- * @example getItem.js
1051
- * ```typescript
1052
- * const itemStack = rightChestContainer.getItem(0);
1053
- * test.assert(itemStack.id === "apple", "Expected apple");
1054
- * test.assert(itemStack.amount === 10, "Expected 10 apples");
1055
- * ```
1056
- */
1057
1006
  getItem(slot: number): ItemStack;
1058
- /**
1059
- * @remarks
1060
- * Gets a container slot within the chest.
1061
- * @param slot
1062
- * @throws This function can throw errors.
1063
- */
1064
1007
  getSlot(slot: number): ContainerSlot;
1065
- /**
1066
- * @remarks
1067
- * Sets an item stack within a particular slot.
1068
- * @param slot
1069
- * Zero-based index of the slot to set an item at.
1070
- * @param itemStack
1071
- * Stack of items to place within the specified slot.
1072
- * @throws This function can throw errors.
1073
- */
1074
1008
  setItem(slot: number, itemStack?: ItemStack): void;
1075
- /**
1076
- * @remarks
1077
- * Swaps items between two different slots within containers.
1078
- * @param slot
1079
- * Zero-based index of the slot to swap from this container.
1080
- * @param otherSlot
1081
- * Zero-based index of the slot to swap with.
1082
- * @param otherContainer
1083
- * Target container to swap with. Note this can be the same
1084
- * container as this source.
1085
- * @throws This function can throw errors.
1086
- * @example swapItems.js
1087
- * ```typescript
1088
- * rightChestContainer.swapItems(1, 0, leftChestContainer); // swap item in slot 1 of rightChestContainer with item in slot 0 of leftChestContainer
1089
- *
1090
- * ```
1091
- */
1092
1009
  swapItems(slot: number, otherSlot: number, otherContainer: Container): boolean;
1093
- /**
1094
- * @remarks
1095
- * Moves an item from one slot to another, potentially across
1096
- * containers.
1097
- * @param fromSlot
1098
- * @param toSlot
1099
- * Zero-based index of the slot to move to.
1100
- * @param toContainer
1101
- * Target container to transfer to. Note this can be the same
1102
- * container as the source.
1103
- * @throws This function can throw errors.
1104
- * @example transferItem.js
1105
- * ```typescript
1106
- * rightChestContainer.transferItem(0, 4, chestCartContainer); // transfer the apple from the right chest to a chest cart
1107
- *
1108
- * ```
1109
- */
1110
1010
  transferItem(fromSlot: number, toSlot: number, toContainer: Container): boolean;
1111
1011
  }
1112
1012
  /**
@@ -1591,23 +1491,26 @@ export class CommandResult {
1591
1491
  export class Container {
1592
1492
  protected constructor();
1593
1493
  /**
1594
- * Contains a count of the slots in the container that are
1595
- * empty.
1596
- * @throws This property can throw when used.
1494
+ * Count of the slots in the container that are empty.
1495
+ * @throws
1496
+ * Throws if the container is invalid.
1597
1497
  */
1598
1498
  readonly emptySlotsCount: number;
1599
1499
  /**
1600
- * Represents the size of the container. For example, a
1601
- * standard single-block chest has a size of 27, for the 27
1602
- * slots in their inventory.
1603
- * @throws This property can throw when used.
1500
+ * The number of slots in this container. For example, a
1501
+ * standard single-block chest has a size of 27. Note, a
1502
+ * player's inventory container contains a total of 36 slots, 9
1503
+ * hotbar slots plus 27 inventory slots.
1504
+ * @throws
1505
+ * Throws if the container is invalid.
1604
1506
  */
1605
1507
  readonly size: number;
1606
1508
  /**
1607
1509
  * @remarks
1608
- * Adds an item to the specified container. Item will be placed
1609
- * in the first available empty slot. (use .setItem if you wish
1610
- * to set items in a particular slot.)
1510
+ * Adds an item to the container. The item is placed in the
1511
+ * first available slot(s) and can be stacked with existing
1512
+ * items of the same type. Note, use {@link Container.setItem}
1513
+ * if you wish to set the item in a particular slot.
1611
1514
  * @param itemStack
1612
1515
  * The stack of items to add.
1613
1516
  * @throws This function can throw errors.
@@ -1616,41 +1519,49 @@ export class Container {
1616
1519
  /**
1617
1520
  * @remarks
1618
1521
  * Clears all inventory items in the container.
1619
- * @throws This function can throw errors.
1522
+ * @throws
1523
+ * Throws if the container is invalid.
1620
1524
  */
1621
1525
  clearAll(): void;
1622
1526
  /**
1623
1527
  * @remarks
1624
1528
  * Clears a specific item at a slot within the container.
1625
1529
  * @param slot
1626
- * @throws This function can throw errors.
1530
+ * @throws
1531
+ * Throws if the container is invalid.
1627
1532
  */
1628
1533
  clearItem(slot: number): void;
1629
1534
  /**
1630
1535
  * @remarks
1631
- * Gets the item stack for the set of items at the specified
1632
- * slot. If the slot is empty, returns undefined. This method
1633
- * does not change or clear the contents of the specified slot.
1536
+ * Gets an {@link ItemStack} of the item at the specified slot.
1537
+ * If the slot is empty, returns `undefined`. This method does
1538
+ * not change or clear the contents of the specified slot. To
1539
+ * get a reference to a particular slot, see {@link
1540
+ * Container.getSlot}.
1634
1541
  * @param slot
1635
1542
  * Zero-based index of the slot to retrieve items from.
1636
- * @throws This function can throw errors.
1637
- * @example getItem.js
1543
+ * @throws
1544
+ * Throws if the container is invalid or if the `slot` index is
1545
+ * out of bounds.
1546
+ * @example getItem.ts
1638
1547
  * ```typescript
1639
- * const rightInventoryComp = rightChestCart.getComponent("inventory");
1640
- * const rightChestContainer = rightInventoryComp.container;
1641
- *
1642
- * const itemStack = rightChestContainer.getItem(0);
1548
+ * // Get a copy of the first item in the player's hotbar
1549
+ * const inventory = player.getComponent("inventory") as EntityInventoryComponent;
1550
+ * const itemStack = inventory.container.getItem(0);
1643
1551
  *
1644
- * test.assert(itemStack.id === "apple", "Expected apple");
1645
- * test.assert(itemStack.amount === 10, "Expected 10 apples");
1646
1552
  * ```
1647
1553
  */
1648
1554
  getItem(slot: number): ItemStack;
1649
1555
  /**
1650
1556
  * @remarks
1651
- * Returns a container slot item holder within the container.
1557
+ * Returns a container slot. This acts as a reference to a slot
1558
+ * at the given index for this container.
1652
1559
  * @param slot
1653
- * @throws This function can throw errors.
1560
+ * The index of the slot to return. This index must be within
1561
+ * the bounds of the container.
1562
+ * @throws
1563
+ * Throws if the container is invalid or if the `slot` index is
1564
+ * out of bounds.
1654
1565
  */
1655
1566
  getSlot(slot: number): ContainerSlot;
1656
1567
  /**
@@ -1659,8 +1570,11 @@ export class Container {
1659
1570
  * @param slot
1660
1571
  * Zero-based index of the slot to set an item at.
1661
1572
  * @param itemStack
1662
- * Stack of items to place within the specified slot.
1663
- * @throws This function can throw errors.
1573
+ * Stack of items to place within the specified slot. Setting
1574
+ * `itemStack` to undefined will clear the slot.
1575
+ * @throws
1576
+ * Throws if the container is invalid or if the `slot` index is
1577
+ * out of bounds.
1664
1578
  */
1665
1579
  setItem(slot: number, itemStack?: ItemStack): void;
1666
1580
  /**
@@ -1673,28 +1587,38 @@ export class Container {
1673
1587
  * @param otherContainer
1674
1588
  * Target container to swap with. Note this can be the same
1675
1589
  * container as this source.
1676
- * @throws This function can throw errors.
1677
- * @example swapItems.js
1590
+ * @throws
1591
+ * Throws if either this container or `otherContainer` are
1592
+ * invalid or if the `slot` or `otherSlot` are out of bounds.
1593
+ * @example swapItems.ts
1678
1594
  * ```typescript
1679
- * rightChestContainer.swapItems(1, 0, leftChestContainer); // swap the cake and emerald
1595
+ * // Swaps an item between slots 0 and 4 in the player's inventory
1596
+ * const inventory = fromPlayer.getComponent('inventory') as EntityInventoryComponent;
1597
+ * inventory.container.swapItems(0, 4, inventory);
1680
1598
  *
1681
1599
  * ```
1682
1600
  */
1683
1601
  swapItems(slot: number, otherSlot: number, otherContainer: Container): boolean;
1684
1602
  /**
1685
1603
  * @remarks
1686
- * Moves an item from one slot to another, potentially across
1687
- * containers.
1604
+ * Moves an item from one slot to another container, or to the
1605
+ * first available slot in the same container.
1688
1606
  * @param fromSlot
1607
+ * Zero-based index of the slot to transfer an item from, on
1608
+ * this container.
1689
1609
  * @param toSlot
1690
- * Zero-based index of the slot to move to.
1691
1610
  * @param toContainer
1692
1611
  * Target container to transfer to. Note this can be the same
1693
1612
  * container as the source.
1694
- * @throws This function can throw errors.
1695
- * @example transferItem.js
1613
+ * @throws
1614
+ * Throws if either this container or `toContainer` are invalid
1615
+ * or if the `fromSlot` or `toSlot` indices out of bounds.
1616
+ * @example transferItem.ts
1696
1617
  * ```typescript
1697
- * rightChestContainer.transferItem(0, 4, chestCartContainer); // transfer the apple from the right chest to a chest cart
1618
+ * // Transfer an item from the first slot of fromPlayer's inventory to toPlayer's inventory
1619
+ * const fromInventory = fromPlayer.getComponent('inventory') as EntityInventoryComponent;
1620
+ * const toInventory = toPlayer.getComponent('inventory') as EntityInventoryComponent;
1621
+ * fromInventory.container.transferItem(0, toInventory.container);
1698
1622
  *
1699
1623
  * ```
1700
1624
  */
@@ -1708,65 +1632,130 @@ export class Container {
1708
1632
  export class ContainerSlot {
1709
1633
  protected constructor();
1710
1634
  /**
1711
- * Amount of the specified item within the container slot.
1635
+ * Number of the items in the stack. Valid values range between
1636
+ * 1-255. The provided value will be clamped to the item's
1637
+ * maximum stack size.
1638
+ * @throws
1639
+ * Throws if the value is outside the range of 1-255.
1712
1640
  */
1713
1641
  amount: number;
1642
+ data: number;
1714
1643
  /**
1715
- * Modifier value for the item type stored within the slot.
1644
+ * Returns whether the item is stackable. An item is considered
1645
+ * stackable if the item's maximum stack size is greater than 1
1646
+ * and the item does not contain any custom data or properties.
1647
+ * @throws
1648
+ * Throws if the slot's container is invalid.
1716
1649
  */
1717
- data: number;
1718
1650
  readonly isStackable: boolean;
1651
+ readonly isValid: boolean;
1719
1652
  /**
1720
- * If true, the state of this container slot is still valid
1721
- * (e.g., the underlying block or entity for this container
1722
- * slot still exists.)
1653
+ * Gets or sets whether the item is kept on death.
1654
+ * @throws
1655
+ * Throws if the slot's container is invalid.
1723
1656
  */
1724
- readonly isValid: boolean;
1725
1657
  keepOnDeath: boolean;
1658
+ /**
1659
+ * Gets or sets the item's lock mode. The default value is
1660
+ * `ItemLockMode.none`.
1661
+ * @throws
1662
+ * Throws if the slot's container is invalid.
1663
+ */
1726
1664
  lockMode: ItemLockMode;
1665
+ /**
1666
+ * The maximum stack size. This value varies depending on the
1667
+ * type of item. For example, torches have a maximum stack size
1668
+ * of 64, while eggs have a maximum stack size of 16.
1669
+ * @throws
1670
+ * Throws if the slot's container is invalid.
1671
+ */
1727
1672
  readonly maxAmount: number;
1728
1673
  /**
1729
- * Returns a name tag for the container slot.
1674
+ * Given name of this stack of items. The name tag is displayed
1675
+ * when hovering over the item. Setting the name tag to an
1676
+ * empty string or `undefined` will remove the name tag.
1677
+ * @throws
1678
+ * Throws if the slot's container is invalid. Also throws if
1679
+ * the length exceeds 255 characters.
1730
1680
  */
1731
1681
  nameTag?: string;
1682
+ /**
1683
+ * The type of the item.
1684
+ * @throws
1685
+ * Throws if the slot's container is invalid.
1686
+ */
1732
1687
  readonly 'type': ItemType;
1733
1688
  /**
1734
- * Returns a string identifier of the type if item stored in
1735
- * this slot.
1736
- * @throws This property can throw when used.
1689
+ * Identifier of the type of items for the stack. If a
1690
+ * namespace is not specified, 'minecraft:' is assumed.
1691
+ * Examples include 'wheat' or 'apple'.
1692
+ * @throws
1693
+ * Throws if the slot's container is invalid.
1737
1694
  */
1738
1695
  readonly typeId?: string;
1739
- clone(): ItemStack;
1740
1696
  /**
1741
1697
  * @remarks
1742
- * Returns the item stored within the container.
1743
- * @throws This function can throw errors.
1698
+ * Creates an exact copy of the item stack, including any
1699
+ * custom data or properties.
1700
+ * @throws
1701
+ * Throws if the slot's container is invalid.
1744
1702
  */
1703
+ clone(): ItemStack;
1745
1704
  getItem(): ItemStack;
1746
1705
  /**
1747
1706
  * @remarks
1748
- * Returns the lore value for the item stored within this
1749
- * container slot.
1750
- * @throws This function can throw errors.
1707
+ * Returns the lore value - a secondary display string - for an
1708
+ * ItemStack.
1709
+ * @returns
1710
+ * An array of lore strings. If the item does not have lore,
1711
+ * returns an empty array.
1712
+ * @throws
1713
+ * Throws if the slot's container is invalid.
1751
1714
  */
1752
1715
  getLore(): string[];
1716
+ /**
1717
+ * @remarks
1718
+ * Returns whether this item stack can be stacked with the
1719
+ * given `itemStack`. This is determined by comparing the item
1720
+ * type and any custom data and properties associated with the
1721
+ * item stacks. The amount of each item stack is not taken into
1722
+ * consideration.
1723
+ * @param itemStack
1724
+ * @throws
1725
+ * Throws if the slot's container is invalid.
1726
+ */
1753
1727
  isStackableWith(itemStack: ItemStack): boolean;
1728
+ /**
1729
+ * @remarks
1730
+ * The list of block types this item can break in Adventure
1731
+ * mode. The block names are displayed in the item's tooltip.
1732
+ * Setting the value to undefined will clear the list.
1733
+ * @param blockIdentifiers
1734
+ * @throws
1735
+ * Throws if the slot's container is invalid. Also throws if
1736
+ * any of the provided block identifiers are invalid.
1737
+ */
1754
1738
  setCanDestroy(blockIdentifiers?: string[]): void;
1755
- setCanPlaceOn(blockIdentifiers?: string[]): void;
1756
1739
  /**
1757
1740
  * @remarks
1758
- * Sets the item within the slot to a new value.
1759
- * @param itemStack
1760
- * The item stack to set within this container slot.
1761
- * @throws This function can throw errors.
1741
+ * The list of block types this item can be placed on in
1742
+ * Adventure mode. This is only applicable to block items. The
1743
+ * block names are displayed in the item's tooltip. Setting the
1744
+ * value to undefined will clear the list.
1745
+ * @param blockIdentifiers
1746
+ * @throws
1747
+ * Throws if the slot's container is invalid. Also throws if
1748
+ * any of the provided block identifiers are invalid.
1762
1749
  */
1750
+ setCanPlaceOn(blockIdentifiers?: string[]): void;
1763
1751
  setItem(itemStack?: ItemStack): void;
1764
1752
  /**
1765
1753
  * @remarks
1766
- * Sets the lore string for the item at the specified slot.
1754
+ * Sets the lore value - a secondary display string - for an
1755
+ * ItemStack.
1767
1756
  * @param loreList
1768
- * An array of strings for lines of text for this lore.
1769
- * @throws This function can throw errors.
1757
+ * @throws
1758
+ * Throws if the slot's container is invalid.
1770
1759
  */
1771
1760
  setLore(loreList?: string[]): void;
1772
1761
  }
@@ -5437,119 +5426,17 @@ export class IEntityComponent {
5437
5426
  */
5438
5427
  readonly typeId: string;
5439
5428
  }
5440
- /**
5441
- * @beta
5442
- * Represents a container that can hold stacks of items. Used
5443
- * for entities like players, chest minecarts, llamas, and
5444
- * more.
5445
- */
5446
5429
  export class InventoryComponentContainer extends Container {
5447
5430
  protected constructor();
5448
- /**
5449
- * The number of empty slots in the container.
5450
- * @throws This property can throw when used.
5451
- */
5452
5431
  readonly emptySlotsCount: number;
5453
- /**
5454
- * Represents the size of the container. For example, a
5455
- * standard single-block chest has a size of 27, for the 27
5456
- * slots in their inventory.
5457
- * @throws This property can throw when used.
5458
- */
5459
5432
  readonly size: number;
5460
- /**
5461
- * @remarks
5462
- * Adds an item to the specified container. Items will be
5463
- * placed in the first available empty slot. (Use {@link
5464
- * InventoryComponentContainer.setItem} if you wish to set
5465
- * items in a particular slot.)
5466
- * @param itemStack
5467
- * The stack of items to add.
5468
- * @throws This function can throw errors.
5469
- */
5470
5433
  addItem(itemStack: ItemStack): void;
5471
- /**
5472
- * @remarks
5473
- * Empties all items in this entities' inventory.
5474
- * @throws This function can throw errors.
5475
- */
5476
5434
  clearAll(): void;
5477
- /**
5478
- * @remarks
5479
- * Clears out a specific item at the specified slot index.
5480
- * @param slot
5481
- * @throws This function can throw errors.
5482
- */
5483
5435
  clearItem(slot: number): void;
5484
- /**
5485
- * @remarks
5486
- * Gets the item stack for the set of items at the specified
5487
- * slot. If the slot is empty, returns undefined. This method
5488
- * does not change or clear the contents of the specified slot.
5489
- * @param slot
5490
- * Zero-based index of the slot to retrieve items from.
5491
- * @throws This function can throw errors.
5492
- * @example getItem.js
5493
- * ```typescript
5494
- * const itemStack = rightChestContainer.getItem(0);
5495
- * test.assert(itemStack.id === "apple", "Expected apple");
5496
- * test.assert(itemStack.amount === 10, "Expected 10 apples");
5497
- * ```
5498
- */
5499
5436
  getItem(slot: number): ItemStack;
5500
- /**
5501
- * @remarks
5502
- * Returns a slot object for specifically managing a slot
5503
- * within a broader inventory.
5504
- * @param slot
5505
- * @throws This function can throw errors.
5506
- */
5507
5437
  getSlot(slot: number): ContainerSlot;
5508
- /**
5509
- * @remarks
5510
- * Sets an item stack within a particular slot.
5511
- * @param slot
5512
- * Zero-based index of the slot to set an item at.
5513
- * @param itemStack
5514
- * Stack of items to place within the specified slot.
5515
- * @throws This function can throw errors.
5516
- */
5517
5438
  setItem(slot: number, itemStack?: ItemStack): void;
5518
- /**
5519
- * @remarks
5520
- * Swaps items between two different slots within containers.
5521
- * @param slot
5522
- * Zero-based index of the slot to swap from this container.
5523
- * @param otherSlot
5524
- * Zero-based index of the slot to swap with.
5525
- * @param otherContainer
5526
- * Target container to swap with. Note this can be the same
5527
- * container as this source.
5528
- * @throws This function can throw errors.
5529
- * @example swapItems.js
5530
- * ```typescript
5531
- * rightChestContainer.swapItems(1, 0, leftChestContainer); // swap the cake and emerald
5532
- *
5533
- * ```
5534
- */
5535
5439
  swapItems(slot: number, otherSlot: number, otherContainer: Container): boolean;
5536
- /**
5537
- * @remarks
5538
- * Moves an item from one slot to another, potentially across
5539
- * containers.
5540
- * @param fromSlot
5541
- * @param toSlot
5542
- * Zero-based index of the slot to move to.
5543
- * @param toContainer
5544
- * Target container to transfer to. Note this can be the same
5545
- * container as the source.
5546
- * @throws This function can throw errors.
5547
- * @example transferItem.js
5548
- * ```typescript
5549
- * rightChestContainer.transferItem(0, 4, chestCartContainer); // transfer the apple from the right chest to a chest cart
5550
- *
5551
- * ```
5552
- */
5553
5440
  transferItem(fromSlot: number, toSlot: number, toContainer: Container): boolean;
5554
5441
  }
5555
5442
  /**
@@ -5839,17 +5726,44 @@ export class Items {
5839
5726
  export class ItemStack {
5840
5727
  /**
5841
5728
  * Number of the items in the stack. Valid values range between
5842
- * 0 and 64.
5729
+ * 1-255. The provided value will be clamped to the item's
5730
+ * maximum stack size.
5731
+ * @throws
5732
+ * Throws if the value is outside the range of 1-255.
5843
5733
  */
5844
5734
  amount: number;
5735
+ /**
5736
+ * Returns whether the item is stackable. An item is considered
5737
+ * stackable if the item's maximum stack size is greater than 1
5738
+ * and the item does not contain any custom data or properties.
5739
+ */
5845
5740
  readonly isStackable: boolean;
5741
+ /**
5742
+ * Gets or sets whether the item is kept on death.
5743
+ */
5846
5744
  keepOnDeath: boolean;
5745
+ /**
5746
+ * Gets or sets the item's lock mode. The default value is
5747
+ * `ItemLockMode.none`.
5748
+ */
5847
5749
  lockMode: ItemLockMode;
5750
+ /**
5751
+ * The maximum stack size. This value varies depending on the
5752
+ * type of item. For example, torches have a maximum stack size
5753
+ * of 64, while eggs have a maximum stack size of 16.
5754
+ */
5848
5755
  readonly maxAmount: number;
5849
5756
  /**
5850
- * Given name of this stack of items.
5757
+ * Given name of this stack of items. The name tag is displayed
5758
+ * when hovering over the item. Setting the name tag to an
5759
+ * empty string or `undefined` will remove the name tag.
5760
+ * @throws
5761
+ * Throws if the length exceeds 255 characters.
5851
5762
  */
5852
5763
  nameTag?: string;
5764
+ /**
5765
+ * The type of the item.
5766
+ */
5853
5767
  readonly 'type': ItemType;
5854
5768
  /**
5855
5769
  * Identifier of the type of items for the stack. If a
@@ -5866,11 +5780,20 @@ export class ItemStack {
5866
5780
  * enumeration for a list of standard item types in Minecraft
5867
5781
  * experiences.
5868
5782
  * @param amount
5869
- * Number of items to place in the stack, between 1 and 64.
5870
- * Note that certain items can only have one item in the stack.
5871
- * @throws This function can throw errors.
5783
+ * Number of items to place in the stack, between 1-255. The
5784
+ * provided value will be clamped to the item's maximum stack
5785
+ * size. Note that certain items can only have one item in the
5786
+ * stack.
5787
+ * @throws
5788
+ * Throws if `itemType` is invalid, or if `amount` is outside
5789
+ * the range of 1-255.
5872
5790
  */
5873
5791
  constructor(itemType: ItemType | string, amount?: number);
5792
+ /**
5793
+ * @remarks
5794
+ * Creates an exact copy of the item stack, including any
5795
+ * custom data or properties.
5796
+ */
5874
5797
  clone(): ItemStack;
5875
5798
  /**
5876
5799
  * @remarks
@@ -5881,6 +5804,14 @@ export class ItemStack {
5881
5804
  * retrieve. If no namespace prefix is specified, 'minecraft:'
5882
5805
  * is assumed. If the component is not present on the item
5883
5806
  * stack, undefined is returned.
5807
+ * @example durability.ts
5808
+ * ```typescript
5809
+ * // Get the maximum durability of a custom sword item
5810
+ * const itemStack = new ItemStack("custom:sword");
5811
+ * const durability = itemStack.getComponent("minecraft:durability") as ItemDurabilityComponent;
5812
+ * const maxDurability = durability.maxDurability;
5813
+ *
5814
+ * ```
5884
5815
  */
5885
5816
  getComponent(componentId: string): any;
5886
5817
  /**
@@ -5893,6 +5824,9 @@ export class ItemStack {
5893
5824
  * @remarks
5894
5825
  * Returns the lore value - a secondary display string - for an
5895
5826
  * ItemStack.
5827
+ * @returns
5828
+ * An array of lore strings. If the item does not have lore,
5829
+ * returns an empty array.
5896
5830
  */
5897
5831
  getLore(): string[];
5898
5832
  /**
@@ -5905,14 +5839,63 @@ export class ItemStack {
5905
5839
  * is assumed.
5906
5840
  */
5907
5841
  hasComponent(componentId: string): boolean;
5842
+ /**
5843
+ * @remarks
5844
+ * Returns whether this item stack can be stacked with the
5845
+ * given `itemStack`. This is determined by comparing the item
5846
+ * type and any custom data and properties associated with the
5847
+ * item stacks. The amount of each item stack is not taken into
5848
+ * consideration.
5849
+ * @param itemStack
5850
+ */
5908
5851
  isStackableWith(itemStack: ItemStack): boolean;
5852
+ /**
5853
+ * @remarks
5854
+ * The list of block types this item can break in Adventure
5855
+ * mode. The block names are displayed in the item's tooltip.
5856
+ * Setting the value to undefined will clear the list.
5857
+ * @param blockIdentifiers
5858
+ * @throws
5859
+ * Throws if any of the provided block identifiers are invalid.
5860
+ * @example example.ts
5861
+ * ```typescript
5862
+ * // Creates a diamond pickaxe that can destroy cobblestone and obsidian
5863
+ * const specialPickaxe = new ItemStack("minecraft:diamond_pickaxe");
5864
+ * specialPickaxe.setCanDestroy(["minecraft:cobblestone", "minecraft:obsidian"]);
5865
+ *
5866
+ * ```
5867
+ */
5909
5868
  setCanDestroy(blockIdentifiers?: string[]): void;
5869
+ /**
5870
+ * @remarks
5871
+ * The list of block types this item can be placed on in
5872
+ * Adventure mode. This is only applicable to block items. The
5873
+ * block names are displayed in the item's tooltip. Setting the
5874
+ * value to undefined will clear the list.
5875
+ * @param blockIdentifiers
5876
+ * @throws
5877
+ * Throws if any of the provided block identifiers are invalid.
5878
+ * @example example.ts
5879
+ * ```typescript
5880
+ * // Creates a gold block that can be placed on grass and dirt
5881
+ * const specialGoldBlock = new ItemStack("minecraft:gold_block");
5882
+ * specialPickaxe.setCanPlaceOn(["minecraft:grass", "minecraft:dirt"]);
5883
+ *
5884
+ * ```
5885
+ */
5910
5886
  setCanPlaceOn(blockIdentifiers?: string[]): void;
5911
5887
  /**
5912
5888
  * @remarks
5913
5889
  * Sets the lore value - a secondary display string - for an
5914
5890
  * ItemStack.
5915
5891
  * @param loreList
5892
+ * @example multilineLore.ts
5893
+ * ```typescript
5894
+ * // Set the lore of an item to multiple lines of text
5895
+ * const itemStack = new ItemStack("minecraft:diamond_sword");
5896
+ * itemStack.setLore(["Line 1", "Line 2", "Line 3"]);
5897
+ *
5898
+ * ```
5916
5899
  */
5917
5900
  setLore(loreList?: string[]): void;
5918
5901
  /**
@@ -10336,7 +10319,6 @@ export class MinecraftItemTypes {
10336
10319
  * Minecraft.
10337
10320
  */
10338
10321
  static readonly deadbush: ItemType;
10339
- static readonly debugStick: ItemType;
10340
10322
  /**
10341
10323
  * Represents an item that can place a block of deepslate
10342
10324
  * within Minecraft.
@@ -12704,6 +12686,47 @@ export class Player extends Entity {
12704
12686
  * @throws This function can throw errors.
12705
12687
  */
12706
12688
  runCommandAsync(commandString: string): Promise<CommandResult>;
12689
+ /**
12690
+ * @beta
12691
+ * @remarks
12692
+ * Sends a message to the player.
12693
+ * @param message
12694
+ * The message to be displayed.
12695
+ * @throws
12696
+ * This method can throw if the provided {@link RawMessage} is
12697
+ * in an invalid format. For example, if an empty `name` string
12698
+ * is provided to `score`.
12699
+ * @example nestedTranslation.ts
12700
+ * ```typescript
12701
+ * // Displays "Apple or Coal"
12702
+ * let rawMessage = {
12703
+ * translate: "accessibility.list.or.two",
12704
+ * with: { rawtext: [{ translate: "item.apple.name" }, { translate: "item.coal.name" }] },
12705
+ * };
12706
+ * player.sendMessage(rawMessage);
12707
+ *
12708
+ * ```
12709
+ * @example scoreWildcard.ts
12710
+ * ```typescript
12711
+ * // Displays the player's score for objective "obj". Each player will see their own score.
12712
+ * const rawMessage = { score: { name: "*", objective: "obj" } };
12713
+ * world.sendMessage(rawMessage);
12714
+ *
12715
+ * ```
12716
+ * @example simpleString.ts
12717
+ * ```typescript
12718
+ * // Displays "Hello, world!"
12719
+ * world.sendMessage("Hello, world!");
12720
+ *
12721
+ * ```
12722
+ * @example translation.ts
12723
+ * ```typescript
12724
+ * // Displays "First or Second"
12725
+ * const rawMessage = { translate: "accessibility.list.or.two", with: ["First", "Second"] };
12726
+ * player.sendMessage(rawMessage);
12727
+ *
12728
+ * ```
12729
+ */
12707
12730
  sendMessage(message: (RawMessage | string)[] | RawMessage | string): void;
12708
12731
  /**
12709
12732
  * @beta
@@ -12799,100 +12822,17 @@ export class Player extends Entity {
12799
12822
  */
12800
12823
  triggerEvent(eventName: string): void;
12801
12824
  }
12802
- /**
12803
- * @beta
12804
- * Represents the inventory of a {@link Player} in the world.
12805
- */
12806
12825
  export class PlayerInventoryComponentContainer extends InventoryComponentContainer {
12807
12826
  protected constructor();
12808
- /**
12809
- * Contains a count of the slots in the container that are
12810
- * empty.
12811
- * @throws This property can throw when used.
12812
- */
12813
12827
  readonly emptySlotsCount: number;
12814
- /**
12815
- * Returns the size capacity of the inventory container on this
12816
- * block.
12817
- * @throws This property can throw when used.
12818
- */
12819
12828
  readonly size: number;
12820
- /**
12821
- * @remarks
12822
- * Adds an item to the specified container. Item will be placed
12823
- * in the first available empty slot. (use .setItem if you wish
12824
- * to set items in a particular slot.)
12825
- * @param itemStack
12826
- * The stack of items to add.
12827
- * @throws This function can throw errors.
12828
- */
12829
12829
  addItem(itemStack: ItemStack): void;
12830
- /**
12831
- * @remarks
12832
- * Empties all items in this players' inventory.
12833
- * @throws This function can throw errors.
12834
- */
12835
12830
  clearAll(): void;
12836
- /**
12837
- * @remarks
12838
- * Clears out a specific item at the specified slot index.
12839
- * @param slot
12840
- * @throws This function can throw errors.
12841
- */
12842
12831
  clearItem(slot: number): void;
12843
- /**
12844
- * @remarks
12845
- * Gets the item stack for the set of items at the specified
12846
- * slot. If the slot is empty, returns undefined. This method
12847
- * does not change or clear the contents of the specified slot.
12848
- * @param slot
12849
- * Zero-based index of the slot to retrieve items from.
12850
- * @throws This function can throw errors.
12851
- */
12852
12832
  getItem(slot: number): ItemStack;
12853
- /**
12854
- * @remarks
12855
- * Returns a slot object for specifically managing a slot
12856
- * within a broader inventory.
12857
- * @param slot
12858
- * @throws This function can throw errors.
12859
- */
12860
12833
  getSlot(slot: number): ContainerSlot;
12861
- /**
12862
- * @remarks
12863
- * Sets an item stack within a particular slot.
12864
- * @param slot
12865
- * Zero-based index of the slot to set an item at.
12866
- * @param itemStack
12867
- * Stack of items to place within the specified slot.
12868
- * @throws This function can throw errors.
12869
- */
12870
12834
  setItem(slot: number, itemStack?: ItemStack): void;
12871
- /**
12872
- * @remarks
12873
- * Swaps items between two different slots within containers.
12874
- * @param slot
12875
- * Zero-based index of the slot to swap from this container.
12876
- * @param otherSlot
12877
- * Zero-based index of the slot to swap with.
12878
- * @param otherContainer
12879
- * Target container to swap with. Note this can be the same
12880
- * container as this source.
12881
- * @throws This function can throw errors.
12882
- */
12883
12835
  swapItems(slot: number, otherSlot: number, otherContainer: Container): boolean;
12884
- /**
12885
- * @remarks
12886
- * Moves an item from one slot to another, potentially across
12887
- * containers.
12888
- * @param fromSlot
12889
- * @param toSlot
12890
- * Zero-based index of the slot to move to.
12891
- * @param toContainer
12892
- * Target container to transfer to. Note this can be the same
12893
- * container as the source.
12894
- * @throws This function can throw errors.
12895
- */
12896
12836
  transferItem(fromSlot: number, toSlot: number, toContainer: Container): boolean;
12897
12837
  }
12898
12838
  /**
@@ -13816,6 +13756,47 @@ export class World {
13816
13756
  * @throws This function can throw errors.
13817
13757
  */
13818
13758
  removeDynamicProperty(identifier: string): boolean;
13759
+ /**
13760
+ * @beta
13761
+ * @remarks
13762
+ * Sends a message to all players.
13763
+ * @param message
13764
+ * The message to be displayed.
13765
+ * @throws
13766
+ * This method can throw if the provided {@link RawMessage} is
13767
+ * in an invalid format. For example, if an empty `name` string
13768
+ * is provided to `score`.
13769
+ * @example nestedTranslation.ts
13770
+ * ```typescript
13771
+ * // Displays "Apple or Coal"
13772
+ * let rawMessage = {
13773
+ * translate: "accessibility.list.or.two",
13774
+ * with: { rawtext: [{ translate: "item.apple.name" }, { translate: "item.coal.name" }] },
13775
+ * };
13776
+ * world.sendMessage(rawMessage);
13777
+ *
13778
+ * ```
13779
+ * @example scoreWildcard.ts
13780
+ * ```typescript
13781
+ * // Displays the player's score for objective "obj". Each player will see their own score.
13782
+ * const rawMessage = { score: { name: "*", objective: "obj" } };
13783
+ * world.sendMessage(rawMessage);
13784
+ *
13785
+ * ```
13786
+ * @example simpleString.ts
13787
+ * ```typescript
13788
+ * // Displays "Hello, world!"
13789
+ * world.sendMessage("Hello, world!");
13790
+ *
13791
+ * ```
13792
+ * @example translation.ts
13793
+ * ```typescript
13794
+ * // Displays "First or Second"
13795
+ * const rawMessage = { translate: "accessibility.list.or.two", with: ["First", "Second"] };
13796
+ * world.sendMessage(rawMessage);
13797
+ *
13798
+ * ```
13799
+ */
13819
13800
  sendMessage(message: (RawMessage | string)[] | RawMessage | string): void;
13820
13801
  setDefaultSpawn(spawnPosition: Vector3): void;
13821
13802
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minecraft/server",
3
- "version": "1.1.0-beta.1.19.70-preview.23",
3
+ "version": "1.1.0-beta.1.19.70-preview.24",
4
4
  "description": "",
5
5
  "contributors": [
6
6
  {