@minecraft/server 1.3.0-beta.1.20.0-preview.23 → 1.3.0-beta.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 +675 -303
- 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
|
*
|
|
@@ -792,15 +792,14 @@ export class Block {
|
|
|
792
792
|
* @throws This function can throw errors.
|
|
793
793
|
* @example check_block_tags.js
|
|
794
794
|
* ```typescript
|
|
795
|
-
*
|
|
795
|
+
* import { world } from "@minecraft/server";
|
|
796
796
|
*
|
|
797
|
-
*
|
|
798
|
-
*
|
|
799
|
-
*
|
|
800
|
-
* console.log(`Block is dirt: ${block.hasTag("dirt")}`);
|
|
801
|
-
* console.log(`Block is wood: ${block.hasTag("wood")}`);
|
|
802
|
-
* console.log(`Block is stone: ${block.hasTag("stone")}`);
|
|
797
|
+
* // Fetch the block
|
|
798
|
+
* const block = world.getDimension("overworld").getBlock({ x: 1, y: 2, z: 3 });
|
|
803
799
|
*
|
|
800
|
+
* console.log(`Block is dirt: ${block.hasTag("dirt")}`);
|
|
801
|
+
* console.log(`Block is wood: ${block.hasTag("wood")}`);
|
|
802
|
+
* console.log(`Block is stone: ${block.hasTag("stone")}`);
|
|
804
803
|
* ```
|
|
805
804
|
*/
|
|
806
805
|
hasTag(tag: string): boolean;
|
|
@@ -1072,6 +1071,21 @@ export class BlockLiquidContainerComponent extends BlockComponent {
|
|
|
1072
1071
|
|
|
1073
1072
|
/**
|
|
1074
1073
|
* @beta
|
|
1074
|
+
* A BlockLocationIterator returns the next block location of
|
|
1075
|
+
* the block volume across which it is iterating.
|
|
1076
|
+
* The BlockLocationIterator is used to abstract the shape of
|
|
1077
|
+
* the block volume it was fetched from (so it can represent
|
|
1078
|
+
* all the block locations that make up rectangles, cubes,
|
|
1079
|
+
* spheres, lines and complex shapes).
|
|
1080
|
+
* Each iteration pass returns the next valid block location in
|
|
1081
|
+
* the parent shape.
|
|
1082
|
+
* Unless otherwise specified by the parent shape - the
|
|
1083
|
+
* BlockLocationIterator will iterate over a 3D space in the
|
|
1084
|
+
* order of increasing X, followed by increasing Z followed by
|
|
1085
|
+
* increasing Y.
|
|
1086
|
+
* (Effectively stepping across the XZ plane, and when all the
|
|
1087
|
+
* locations in that plane are exhausted, increasing the Y
|
|
1088
|
+
* coordinate to the next XZ slice)
|
|
1075
1089
|
*/
|
|
1076
1090
|
export class BlockLocationIterator implements Iterable<Vector3> {
|
|
1077
1091
|
protected constructor();
|
|
@@ -1165,16 +1179,15 @@ export class BlockPermutation {
|
|
|
1165
1179
|
* Returns `true` if the permutation has the tag, else `false`.
|
|
1166
1180
|
* @example check_block_tags.js
|
|
1167
1181
|
* ```typescript
|
|
1168
|
-
*
|
|
1169
|
-
*
|
|
1170
|
-
* // Fetch the block
|
|
1171
|
-
* const block = world.getDimension("overworld").getBlock({ x: 1, y: 2, z: 3 });
|
|
1172
|
-
* const blockPerm = block.getPermutation();
|
|
1182
|
+
* import { world } from "@minecraft/server";
|
|
1173
1183
|
*
|
|
1174
|
-
*
|
|
1175
|
-
*
|
|
1176
|
-
*
|
|
1184
|
+
* // Fetch the block
|
|
1185
|
+
* const block = world.getDimension("overworld").getBlock({ x: 1, y: 2, z: 3 });
|
|
1186
|
+
* const blockPerm = block.getPermutation();
|
|
1177
1187
|
*
|
|
1188
|
+
* console.log(`Block is dirt: ${blockPerm.hasTag("dirt")}`);
|
|
1189
|
+
* console.log(`Block is wood: ${blockPerm.hasTag("wood")}`);
|
|
1190
|
+
* console.log(`Block is stone: ${blockPerm.hasTag("stone")}`);
|
|
1178
1191
|
* ```
|
|
1179
1192
|
*/
|
|
1180
1193
|
hasTag(tag: string): boolean;
|
|
@@ -1441,27 +1454,27 @@ export class BlockSignComponent extends BlockComponent {
|
|
|
1441
1454
|
* @throws This function can throw errors.
|
|
1442
1455
|
* @example SetRawMessage.ts
|
|
1443
1456
|
* ```typescript
|
|
1444
|
-
*
|
|
1445
|
-
*
|
|
1457
|
+
* const helloWorldMessage: RawMessage = { text: 'Hello World' };
|
|
1458
|
+
* sign.setText(helloWorldMessage);
|
|
1446
1459
|
*
|
|
1447
|
-
*
|
|
1448
|
-
*
|
|
1449
|
-
*
|
|
1460
|
+
* // Sign text will be saved as a RawText
|
|
1461
|
+
* const result: RawText = sign.getRawText();
|
|
1462
|
+
* JSON.stringify(result); // { rawtext: [{ text: 'Hello World' }] };
|
|
1450
1463
|
* ```
|
|
1451
1464
|
* @example SetRawText.ts
|
|
1452
1465
|
* ```typescript
|
|
1453
|
-
*
|
|
1454
|
-
*
|
|
1466
|
+
* const helloWorldText: RawText = { rawtext: [{ text: 'Hello World' }] };
|
|
1467
|
+
* sign.setText(helloWorldText);
|
|
1455
1468
|
*
|
|
1456
|
-
*
|
|
1457
|
-
*
|
|
1458
|
-
*
|
|
1469
|
+
* // There will be no data transformation unlike calling setText with a RawMessage
|
|
1470
|
+
* const result: RawText = sign.getRawText();
|
|
1471
|
+
* JSON.stringify(result); // { rawtext: [{ text: 'Hello World' }] };
|
|
1459
1472
|
* ```
|
|
1460
1473
|
* @example SetString.ts
|
|
1461
1474
|
* ```typescript
|
|
1462
|
-
*
|
|
1463
|
-
*
|
|
1464
|
-
*
|
|
1475
|
+
* // Set sign to say 'Hello'
|
|
1476
|
+
* sign.setText('Hello');
|
|
1477
|
+
* sign.getText(); // 'Hello'
|
|
1465
1478
|
* ```
|
|
1466
1479
|
*/
|
|
1467
1480
|
setText(message: RawMessage | RawText | string, side?: SignSide): void;
|
|
@@ -1575,79 +1588,139 @@ export class BlockType {
|
|
|
1575
1588
|
|
|
1576
1589
|
/**
|
|
1577
1590
|
* @beta
|
|
1591
|
+
* Block Volume Utils is a utility class that provides a number
|
|
1592
|
+
* of useful functions for the creation and utility of {@link
|
|
1593
|
+
* @minecraft-server.BlockVolume} objects
|
|
1578
1594
|
*/
|
|
1579
1595
|
export class BlockVolumeUtils {
|
|
1580
1596
|
protected constructor();
|
|
1581
1597
|
/**
|
|
1582
1598
|
* @remarks
|
|
1599
|
+
* Check to see if the given location is directly adjacent to
|
|
1600
|
+
* the outer surface of a BlockVolume.
|
|
1601
|
+
*
|
|
1602
|
+
*
|
|
1583
1603
|
* This function can't be called in read-only mode.
|
|
1584
1604
|
*
|
|
1605
|
+
* @param volume
|
|
1606
|
+
* The volume to test against
|
|
1607
|
+
* @param pos
|
|
1608
|
+
* The world block location to test
|
|
1609
|
+
* @returns
|
|
1610
|
+
* If the location is either inside or more than 0 blocks away,
|
|
1611
|
+
* the function will return false.
|
|
1612
|
+
* If the location is directly contacting the outer surface of
|
|
1613
|
+
* the BlockVolume, the function will return true.
|
|
1585
1614
|
*/
|
|
1586
1615
|
static doesLocationTouchFaces(volume: BlockVolume, pos: Vector3): boolean;
|
|
1587
1616
|
/**
|
|
1588
1617
|
* @remarks
|
|
1618
|
+
* Check to see if a two block volumes are directly adjacent
|
|
1619
|
+
* and two faces touch.
|
|
1620
|
+
*
|
|
1589
1621
|
* This function can't be called in read-only mode.
|
|
1590
1622
|
*
|
|
1623
|
+
* @param volume
|
|
1624
|
+
* The volume to test against
|
|
1625
|
+
* @param other
|
|
1626
|
+
* The volume to test
|
|
1627
|
+
* @returns
|
|
1628
|
+
* If the outer faces of both block volumes touch and are
|
|
1629
|
+
* directly adjacent at any point, return true.
|
|
1591
1630
|
*/
|
|
1592
1631
|
static doesVolumeTouchFaces(volume: BlockVolume, other: BlockVolume): boolean;
|
|
1593
1632
|
/**
|
|
1594
1633
|
* @remarks
|
|
1634
|
+
* Test the equality of two block volumes
|
|
1635
|
+
*
|
|
1595
1636
|
* This function can't be called in read-only mode.
|
|
1596
1637
|
*
|
|
1638
|
+
* @returns
|
|
1639
|
+
* Return true if two block volumes are identical
|
|
1597
1640
|
*/
|
|
1598
1641
|
static equals(volume: BlockVolume, other: BlockVolume): boolean;
|
|
1599
1642
|
/**
|
|
1600
1643
|
* @remarks
|
|
1644
|
+
* Fetch a {@link BlockLocationIterator} that represents all of
|
|
1645
|
+
* the block world locations within the specified volume
|
|
1646
|
+
*
|
|
1601
1647
|
* This function can't be called in read-only mode.
|
|
1602
1648
|
*
|
|
1603
1649
|
*/
|
|
1604
1650
|
static getBlockLocationIterator(volume: BlockVolume): BlockLocationIterator;
|
|
1605
1651
|
/**
|
|
1606
1652
|
* @remarks
|
|
1653
|
+
* Return a {@link BoundingBox} object which represents the
|
|
1654
|
+
* validated min and max coordinates of the volume
|
|
1655
|
+
*
|
|
1607
1656
|
* This function can't be called in read-only mode.
|
|
1608
1657
|
*
|
|
1609
1658
|
*/
|
|
1610
1659
|
static getBoundingBox(volume: BlockVolume): BoundingBox;
|
|
1611
1660
|
/**
|
|
1612
1661
|
* @remarks
|
|
1662
|
+
* Return the capacity (volume) of the BlockVolume (W*D*H)
|
|
1663
|
+
*
|
|
1613
1664
|
* This function can't be called in read-only mode.
|
|
1614
1665
|
*
|
|
1615
1666
|
*/
|
|
1616
1667
|
static getCapacity(volume: BlockVolume): number;
|
|
1617
1668
|
/**
|
|
1618
1669
|
* @remarks
|
|
1670
|
+
* Get the largest corner position of the volume (guaranteed to
|
|
1671
|
+
* be >= min)
|
|
1672
|
+
*
|
|
1619
1673
|
* This function can't be called in read-only mode.
|
|
1620
1674
|
*
|
|
1621
1675
|
*/
|
|
1622
1676
|
static getMax(volume: BlockVolume): Vector3;
|
|
1623
1677
|
/**
|
|
1624
1678
|
* @remarks
|
|
1679
|
+
* Get the smallest corner position of the volume (guaranteed
|
|
1680
|
+
* to be <= max)
|
|
1681
|
+
*
|
|
1625
1682
|
* This function can't be called in read-only mode.
|
|
1626
1683
|
*
|
|
1627
1684
|
*/
|
|
1628
1685
|
static getMin(volume: BlockVolume): Vector3;
|
|
1629
1686
|
/**
|
|
1630
1687
|
* @remarks
|
|
1688
|
+
* Get a {@link Vector3} object where each component represents
|
|
1689
|
+
* the number of blocks along that axis
|
|
1690
|
+
*
|
|
1631
1691
|
* This function can't be called in read-only mode.
|
|
1632
1692
|
*
|
|
1633
1693
|
*/
|
|
1634
1694
|
static getSpan(volume: BlockVolume): Vector3;
|
|
1635
1695
|
/**
|
|
1636
1696
|
* @remarks
|
|
1697
|
+
* Return an enumeration which represents the intersection
|
|
1698
|
+
* between two BlockVolume objects
|
|
1699
|
+
*
|
|
1637
1700
|
* This function can't be called in read-only mode.
|
|
1638
1701
|
*
|
|
1639
1702
|
*/
|
|
1640
1703
|
static intersects(volume: BlockVolume, other: BlockVolume): BlockVolumeIntersection;
|
|
1641
1704
|
/**
|
|
1642
1705
|
* @remarks
|
|
1706
|
+
* Check to see if a given world block location is inside a
|
|
1707
|
+
* BlockVolume
|
|
1708
|
+
*
|
|
1643
1709
|
* This function can't be called in read-only mode.
|
|
1644
1710
|
*
|
|
1645
1711
|
*/
|
|
1646
1712
|
static isInside(volume: BlockVolume, pos: Vector3): number;
|
|
1647
1713
|
/**
|
|
1648
1714
|
* @remarks
|
|
1715
|
+
* Move a BlockVolume by a specified amount
|
|
1716
|
+
*
|
|
1649
1717
|
* This function can't be called in read-only mode.
|
|
1650
1718
|
*
|
|
1719
|
+
* @param delta
|
|
1720
|
+
* Amount of blocks to move by
|
|
1721
|
+
* @returns
|
|
1722
|
+
* Returns a new BlockVolume object which represents the new
|
|
1723
|
+
* volume
|
|
1651
1724
|
*/
|
|
1652
1725
|
static translate(volume: BlockVolume, delta: Vector3): BlockVolume;
|
|
1653
1726
|
}
|
|
@@ -1697,41 +1770,86 @@ export class BlockWaterContainerComponent extends BlockLiquidContainerComponent
|
|
|
1697
1770
|
|
|
1698
1771
|
/**
|
|
1699
1772
|
* @beta
|
|
1773
|
+
* Bounding Box Utils is a utility class that provides a number
|
|
1774
|
+
* of useful functions for the creation and utility of {@link
|
|
1775
|
+
* @minecraft-server.BoundingBox} objects
|
|
1700
1776
|
*/
|
|
1701
1777
|
export class BoundingBoxUtils {
|
|
1702
1778
|
protected constructor();
|
|
1703
1779
|
/**
|
|
1704
1780
|
* @remarks
|
|
1781
|
+
* Create a validated instance of a {@link
|
|
1782
|
+
* @minecraft-server.BoundingBox} where the min and max
|
|
1783
|
+
* components are guaranteed to be (min <= max)
|
|
1784
|
+
*
|
|
1705
1785
|
* This function can't be called in read-only mode.
|
|
1706
1786
|
*
|
|
1787
|
+
* @param min
|
|
1788
|
+
* A corner world location
|
|
1789
|
+
* @param max
|
|
1790
|
+
* A corner world location diametrically opposite
|
|
1707
1791
|
*/
|
|
1708
1792
|
static createValid(min: Vector3, max: Vector3): BoundingBox;
|
|
1709
1793
|
/**
|
|
1710
1794
|
* @remarks
|
|
1795
|
+
* Expand a {@link @minecraft-server.BoundingBox} by a given
|
|
1796
|
+
* amount along each axis.
|
|
1797
|
+
* Sizes can be negative to perform contraction.
|
|
1798
|
+
* Note: corners can be inverted if the contraction size is
|
|
1799
|
+
* greater than the span, but the min/max relationship will
|
|
1800
|
+
* remain correct
|
|
1801
|
+
*
|
|
1711
1802
|
* This function can't be called in read-only mode.
|
|
1712
1803
|
*
|
|
1804
|
+
* @returns
|
|
1805
|
+
* Return a new {@link @minecraft-server.BoundingBox} object
|
|
1806
|
+
* representing the changes
|
|
1713
1807
|
*/
|
|
1714
1808
|
static dilate(box: BoundingBox, size: Vector3): BoundingBox;
|
|
1715
1809
|
/**
|
|
1716
1810
|
* @remarks
|
|
1811
|
+
* Check if two {@link @minecraft-server.BoundingBox} objects
|
|
1812
|
+
* are identical
|
|
1813
|
+
*
|
|
1717
1814
|
* This function can't be called in read-only mode.
|
|
1718
1815
|
*
|
|
1719
1816
|
*/
|
|
1720
1817
|
static equals(box: BoundingBox, other: BoundingBox): boolean;
|
|
1721
1818
|
/**
|
|
1722
1819
|
* @remarks
|
|
1820
|
+
* Expand the initial box object bounds to include the 2nd box
|
|
1821
|
+
* argument. The resultant {@link
|
|
1822
|
+
* @minecraft-server.BoundingBox} object will be a BoundingBox
|
|
1823
|
+
* which exactly encompasses the two boxes.
|
|
1824
|
+
*
|
|
1723
1825
|
* This function can't be called in read-only mode.
|
|
1724
1826
|
*
|
|
1827
|
+
* @returns
|
|
1828
|
+
* A new {@link @minecraft-server.BoundingBox} instance
|
|
1829
|
+
* representing the smallest possible bounding box which can
|
|
1830
|
+
* encompass both
|
|
1725
1831
|
*/
|
|
1726
1832
|
static expand(box: BoundingBox, other: BoundingBox): BoundingBox;
|
|
1727
1833
|
/**
|
|
1728
1834
|
* @remarks
|
|
1835
|
+
* Calculate the center block of a given {@link
|
|
1836
|
+
* @minecraft-server.BoundingBox} object.
|
|
1837
|
+
*
|
|
1729
1838
|
* This function can't be called in read-only mode.
|
|
1730
1839
|
*
|
|
1840
|
+
* @returns
|
|
1841
|
+
* Note that {@link @minecraft-server.BoundingBox} objects
|
|
1842
|
+
* represent whole blocks, so the center of boxes which have
|
|
1843
|
+
* odd numbered bounds are not mathematically centered...
|
|
1844
|
+
* i.e. a BoundingBox( 0,0,0 -> 3,3,3 ) would have a center of
|
|
1845
|
+
* (1,1,1) (not (1.5, 1.5, 1.5) as expected)
|
|
1731
1846
|
*/
|
|
1732
1847
|
static getCenter(box: BoundingBox): Vector3;
|
|
1733
1848
|
/**
|
|
1734
1849
|
* @remarks
|
|
1850
|
+
* Calculate the BoundingBox which represents the union area of
|
|
1851
|
+
* two intersecting BoundingBoxes
|
|
1852
|
+
*
|
|
1735
1853
|
* This function can't be called in read-only mode.
|
|
1736
1854
|
*
|
|
1737
1855
|
* @throws This function can throw errors.
|
|
@@ -1739,32 +1857,44 @@ export class BoundingBoxUtils {
|
|
|
1739
1857
|
static getIntersection(box: BoundingBox, other: BoundingBox): BoundingBox;
|
|
1740
1858
|
/**
|
|
1741
1859
|
* @remarks
|
|
1860
|
+
* Get the Span of each of the BoundingBox Axis components
|
|
1861
|
+
*
|
|
1742
1862
|
* This function can't be called in read-only mode.
|
|
1743
1863
|
*
|
|
1744
1864
|
*/
|
|
1745
1865
|
static getSpan(box: BoundingBox): Vector3;
|
|
1746
1866
|
/**
|
|
1747
1867
|
* @remarks
|
|
1868
|
+
* Check to see if two BoundingBox objects intersect
|
|
1869
|
+
*
|
|
1748
1870
|
* This function can't be called in read-only mode.
|
|
1749
1871
|
*
|
|
1750
1872
|
*/
|
|
1751
1873
|
static intersects(box: BoundingBox, other: BoundingBox): boolean;
|
|
1752
1874
|
/**
|
|
1753
1875
|
* @remarks
|
|
1876
|
+
* Check to see if a given coordinate is inside a BoundingBox
|
|
1877
|
+
*
|
|
1754
1878
|
* This function can't be called in read-only mode.
|
|
1755
1879
|
*
|
|
1756
1880
|
*/
|
|
1757
1881
|
static isInside(box: BoundingBox, pos: Vector3): boolean;
|
|
1758
1882
|
/**
|
|
1759
1883
|
* @remarks
|
|
1884
|
+
* Check to see if a BoundingBox is valid (i.e. (min <= max))
|
|
1885
|
+
*
|
|
1760
1886
|
* This function can't be called in read-only mode.
|
|
1761
1887
|
*
|
|
1762
1888
|
*/
|
|
1763
1889
|
static isValid(box: BoundingBox): boolean;
|
|
1764
1890
|
/**
|
|
1765
1891
|
* @remarks
|
|
1892
|
+
* Move a BoundingBox by a given amount
|
|
1893
|
+
*
|
|
1766
1894
|
* This function can't be called in read-only mode.
|
|
1767
1895
|
*
|
|
1896
|
+
* @returns
|
|
1897
|
+
* Return a new BoundingBox object which represents the change
|
|
1768
1898
|
*/
|
|
1769
1899
|
static translate(box: BoundingBox, delta: Vector3): BoundingBox;
|
|
1770
1900
|
}
|
|
@@ -1902,74 +2032,164 @@ export class Component {
|
|
|
1902
2032
|
|
|
1903
2033
|
/**
|
|
1904
2034
|
* @beta
|
|
2035
|
+
* The Compound Block Volume is a collection of individual
|
|
2036
|
+
* block volume definitions which, as a collection, define a
|
|
2037
|
+
* larger volume of (sometimes non-contiguous) irregular
|
|
2038
|
+
* shapes.
|
|
2039
|
+
* This class is loosely based on the concept of CSG
|
|
2040
|
+
* (Computational Solid Geometry) and allows a user to create
|
|
2041
|
+
* complex volumes by building a stack of volumes and voids to
|
|
2042
|
+
* make a larger single volume.
|
|
2043
|
+
* For example - normally a creator would create a hollow cube
|
|
2044
|
+
* by creating 6 "wall" surfaces for each face.
|
|
2045
|
+
* With a Compound Block Volume, a creator can define a hollow
|
|
2046
|
+
* cube by creating a single outer solid cube, and then
|
|
2047
|
+
* defining a further single 'void' cube inside the larger one.
|
|
2048
|
+
* Similarly, the Compound Block Volume can represent irregular
|
|
2049
|
+
* shaped volumes (e.g. a tree consists of a trunk and lots of
|
|
2050
|
+
* leaf cubes which are not necessarily contiguously placed)
|
|
1905
2051
|
*/
|
|
1906
2052
|
export class CompoundBlockVolume {
|
|
2053
|
+
/**
|
|
2054
|
+
* @remarks
|
|
2055
|
+
* Return the 'capacity' of the bounding rectangle which
|
|
2056
|
+
* represents the collection of volumes in the stack
|
|
2057
|
+
*
|
|
2058
|
+
*/
|
|
1907
2059
|
readonly capacity: number;
|
|
2060
|
+
/**
|
|
2061
|
+
* @remarks
|
|
2062
|
+
* Return the number of volumes (positive and negative) in the
|
|
2063
|
+
* volume stack
|
|
2064
|
+
*
|
|
2065
|
+
*/
|
|
1908
2066
|
readonly volumeCount: number;
|
|
1909
2067
|
/**
|
|
1910
2068
|
* @remarks
|
|
2069
|
+
* Clear the contents of the volume stack
|
|
2070
|
+
*
|
|
1911
2071
|
* This function can't be called in read-only mode.
|
|
1912
2072
|
*
|
|
1913
2073
|
*/
|
|
1914
2074
|
clear(): void;
|
|
1915
2075
|
/**
|
|
1916
2076
|
* @remarks
|
|
2077
|
+
* Fetch a Block Location Iterator for the Compound Block
|
|
2078
|
+
* Volume. This iterator will allow a creator to iterate
|
|
2079
|
+
* across all of the selected volumes within the larger
|
|
2080
|
+
* bounding area.
|
|
2081
|
+
* Areas of a volume which have been overridden by a
|
|
2082
|
+
* subtractive volume will not be included in the iterator
|
|
2083
|
+
* step.
|
|
2084
|
+
* (i.e. if you push a cube to the stack, and then push a
|
|
2085
|
+
* subtractive volume to the same location, then the iterator
|
|
2086
|
+
* will step over the initial volume because it is considered
|
|
2087
|
+
* negative space)
|
|
2088
|
+
*
|
|
2089
|
+
*
|
|
1917
2090
|
* This function can't be called in read-only mode.
|
|
1918
2091
|
*
|
|
1919
2092
|
*/
|
|
1920
2093
|
getBlockLocationIterator(): BlockLocationIterator;
|
|
1921
2094
|
/**
|
|
1922
2095
|
* @remarks
|
|
2096
|
+
* Get the largest bounding box that represents a container for
|
|
2097
|
+
* all of the volumes on the stack
|
|
2098
|
+
*
|
|
1923
2099
|
* This function can't be called in read-only mode.
|
|
1924
2100
|
*
|
|
1925
2101
|
*/
|
|
1926
2102
|
getBoundingBox(): BoundingBox;
|
|
1927
2103
|
/**
|
|
1928
2104
|
* @remarks
|
|
2105
|
+
* Get the max block location of the outermost bounding
|
|
2106
|
+
* rectangle which represents the volumes on the stack
|
|
2107
|
+
*
|
|
1929
2108
|
* This function can't be called in read-only mode.
|
|
1930
2109
|
*
|
|
1931
2110
|
*/
|
|
1932
2111
|
getMax(): Vector3;
|
|
1933
2112
|
/**
|
|
1934
2113
|
* @remarks
|
|
2114
|
+
* Get the min block location of the outermost bounding
|
|
2115
|
+
* rectangle which represents the volumes on the stack
|
|
2116
|
+
*
|
|
1935
2117
|
* This function can't be called in read-only mode.
|
|
1936
2118
|
*
|
|
1937
2119
|
*/
|
|
1938
2120
|
getMin(): Vector3;
|
|
1939
2121
|
/**
|
|
1940
2122
|
* @remarks
|
|
2123
|
+
* Return a boolean representing whether or not a given block
|
|
2124
|
+
* location is inside a positive block volume.
|
|
2125
|
+
* E.g. if the stack contains a large cube followed by a
|
|
2126
|
+
* slightly smaller negative cube, and the test location is
|
|
2127
|
+
* within the negative cube - the function will return false
|
|
2128
|
+
* because it's not 'inside' a volume (it IS inside the
|
|
2129
|
+
* bounding rectangle, but it is not inside a positively
|
|
2130
|
+
* defined location)
|
|
2131
|
+
*
|
|
1941
2132
|
* This function can't be called in read-only mode.
|
|
1942
2133
|
*
|
|
2134
|
+
* @param delta
|
|
2135
|
+
* block location to test
|
|
1943
2136
|
*/
|
|
1944
2137
|
isInside(delta: Vector3): boolean;
|
|
1945
2138
|
/**
|
|
1946
2139
|
* @remarks
|
|
2140
|
+
* Inspect the last entry pushed to the volume stack without
|
|
2141
|
+
* affecting the stack contents
|
|
2142
|
+
*
|
|
1947
2143
|
* This function can't be called in read-only mode.
|
|
1948
2144
|
*
|
|
2145
|
+
* @returns
|
|
2146
|
+
* Returns undefined if the stack is empty
|
|
1949
2147
|
*/
|
|
1950
2148
|
peekLastVolume(): CompoundBlockVolumeItem | undefined;
|
|
1951
2149
|
/**
|
|
1952
2150
|
* @remarks
|
|
2151
|
+
* Remove the last entry from the volume stack. This will
|
|
2152
|
+
* reduce the stack size by one
|
|
2153
|
+
*
|
|
1953
2154
|
* This function can't be called in read-only mode.
|
|
1954
2155
|
*
|
|
1955
2156
|
*/
|
|
1956
2157
|
popVolume(): boolean;
|
|
1957
2158
|
/**
|
|
1958
2159
|
* @remarks
|
|
2160
|
+
* Push a volume item to the stack. The volume item contains
|
|
2161
|
+
* an 'action' parameter which determines whether this volume
|
|
2162
|
+
* is a positive or negative space
|
|
2163
|
+
*
|
|
1959
2164
|
* This function can't be called in read-only mode.
|
|
1960
2165
|
*
|
|
2166
|
+
* @param item
|
|
2167
|
+
* Item to push to the end of the stack
|
|
1961
2168
|
*/
|
|
1962
2169
|
pushVolume(item: CompoundBlockVolumeItem): void;
|
|
1963
2170
|
/**
|
|
1964
2171
|
* @remarks
|
|
2172
|
+
* If the volume stack is empty, this function will push the
|
|
2173
|
+
* specified item to the stack.
|
|
2174
|
+
* If the volume stack is NOT empty, this function will replace
|
|
2175
|
+
* the last item on the stack with the new item.
|
|
2176
|
+
*
|
|
1965
2177
|
* This function can't be called in read-only mode.
|
|
1966
2178
|
*
|
|
2179
|
+
* @param item
|
|
2180
|
+
* Item to add or replace
|
|
1967
2181
|
*/
|
|
1968
2182
|
replaceOrAddLastVolume(item: CompoundBlockVolumeItem): boolean;
|
|
1969
2183
|
/**
|
|
1970
2184
|
* @remarks
|
|
2185
|
+
* Move the root block location of the volume by a given
|
|
2186
|
+
* amount. This effectively adds the specified delta to the
|
|
2187
|
+
* block location of all of the volumes in the stack
|
|
2188
|
+
*
|
|
1971
2189
|
* This function can't be called in read-only mode.
|
|
1972
2190
|
*
|
|
2191
|
+
* @param delta
|
|
2192
|
+
* Amount to move
|
|
1973
2193
|
*/
|
|
1974
2194
|
translate(delta: Vector3): void;
|
|
1975
2195
|
}
|
|
@@ -2040,10 +2260,9 @@ export class Container {
|
|
|
2040
2260
|
* out of bounds.
|
|
2041
2261
|
* @example getItem.ts
|
|
2042
2262
|
* ```typescript
|
|
2043
|
-
*
|
|
2044
|
-
*
|
|
2045
|
-
*
|
|
2046
|
-
*
|
|
2263
|
+
* // Get a copy of the first item in the player's hotbar
|
|
2264
|
+
* const inventory = player.getComponent("inventory") as EntityInventoryComponent;
|
|
2265
|
+
* const itemStack = inventory.container.getItem(0);
|
|
2047
2266
|
* ```
|
|
2048
2267
|
*/
|
|
2049
2268
|
getItem(slot: number): ItemStack | undefined;
|
|
@@ -2082,11 +2301,10 @@ export class Container {
|
|
|
2082
2301
|
* or if the `fromSlot` or `toSlot` indices out of bounds.
|
|
2083
2302
|
* @example moveItem.ts
|
|
2084
2303
|
* ```typescript
|
|
2085
|
-
*
|
|
2086
|
-
*
|
|
2087
|
-
*
|
|
2088
|
-
*
|
|
2089
|
-
*
|
|
2304
|
+
* // Move an item from the first slot of fromPlayer's inventory to the fifth slot of toPlayer's inventory
|
|
2305
|
+
* const fromInventory = fromPlayer.getComponent('inventory') as EntityInventoryComponent;
|
|
2306
|
+
* const toInventory = toPlayer.getComponent('inventory') as EntityInventoryComponent;
|
|
2307
|
+
* fromInventory.container.moveItem(0, 4, toInventory.container);
|
|
2090
2308
|
* ```
|
|
2091
2309
|
*/
|
|
2092
2310
|
moveItem(fromSlot: number, toSlot: number, toContainer: Container): void;
|
|
@@ -2124,10 +2342,9 @@ export class Container {
|
|
|
2124
2342
|
* invalid or if the `slot` or `otherSlot` are out of bounds.
|
|
2125
2343
|
* @example swapItems.ts
|
|
2126
2344
|
* ```typescript
|
|
2127
|
-
*
|
|
2128
|
-
*
|
|
2129
|
-
*
|
|
2130
|
-
*
|
|
2345
|
+
* // Swaps an item between slots 0 and 4 in the player's inventory
|
|
2346
|
+
* const inventory = fromPlayer.getComponent('inventory') as EntityInventoryComponent;
|
|
2347
|
+
* inventory.container.swapItems(0, 4, inventory);
|
|
2131
2348
|
* ```
|
|
2132
2349
|
*/
|
|
2133
2350
|
swapItems(slot: number, otherSlot: number, otherContainer: Container): void;
|
|
@@ -2149,11 +2366,10 @@ export class Container {
|
|
|
2149
2366
|
* or if the `fromSlot` or `toSlot` indices out of bounds.
|
|
2150
2367
|
* @example transferItem.ts
|
|
2151
2368
|
* ```typescript
|
|
2152
|
-
*
|
|
2153
|
-
*
|
|
2154
|
-
*
|
|
2155
|
-
*
|
|
2156
|
-
*
|
|
2369
|
+
* // Transfer an item from the first slot of fromPlayer's inventory to toPlayer's inventory
|
|
2370
|
+
* const fromInventory = fromPlayer.getComponent('inventory') as EntityInventoryComponent;
|
|
2371
|
+
* const toInventory = toPlayer.getComponent('inventory') as EntityInventoryComponent;
|
|
2372
|
+
* fromInventory.container.transferItem(0, toInventory.container);
|
|
2157
2373
|
* ```
|
|
2158
2374
|
*/
|
|
2159
2375
|
transferItem(fromSlot: number, toContainer: Container): ItemStack;
|
|
@@ -2188,6 +2404,13 @@ export class ContainerSlot {
|
|
|
2188
2404
|
* Throws if the slot's container is invalid.
|
|
2189
2405
|
*/
|
|
2190
2406
|
readonly isStackable: boolean;
|
|
2407
|
+
/**
|
|
2408
|
+
* @remarks
|
|
2409
|
+
* Returns whether the ContainerSlot is valid. The container
|
|
2410
|
+
* slot is valid if the container exists and is loaded, and the
|
|
2411
|
+
* slot index is valid.
|
|
2412
|
+
*
|
|
2413
|
+
*/
|
|
2191
2414
|
readonly isValid: boolean;
|
|
2192
2415
|
/**
|
|
2193
2416
|
* @remarks
|
|
@@ -2258,10 +2481,23 @@ export class ContainerSlot {
|
|
|
2258
2481
|
*
|
|
2259
2482
|
* This function can't be called in read-only mode.
|
|
2260
2483
|
*
|
|
2484
|
+
* @returns
|
|
2485
|
+
* Returns a copy of the item in the slot. Returns undefined if
|
|
2486
|
+
* the slot is empty.
|
|
2261
2487
|
* @throws
|
|
2262
2488
|
* Throws if the slot's container is invalid.
|
|
2263
2489
|
*/
|
|
2264
2490
|
clone(): ItemStack;
|
|
2491
|
+
/**
|
|
2492
|
+
* @remarks
|
|
2493
|
+
* Creates an exact copy of the item stack, including any
|
|
2494
|
+
* custom data or properties.
|
|
2495
|
+
*
|
|
2496
|
+
* @returns
|
|
2497
|
+
* Returns a copy of the item in the slot. Returns undefined if
|
|
2498
|
+
* the slot is empty.
|
|
2499
|
+
* @throws This function can throw errors.
|
|
2500
|
+
*/
|
|
2265
2501
|
getItem(): ItemStack | undefined;
|
|
2266
2502
|
/**
|
|
2267
2503
|
* @remarks
|
|
@@ -2275,7 +2511,27 @@ export class ContainerSlot {
|
|
|
2275
2511
|
* Throws if the slot's container is invalid.
|
|
2276
2512
|
*/
|
|
2277
2513
|
getLore(): string[];
|
|
2514
|
+
/**
|
|
2515
|
+
* @remarks
|
|
2516
|
+
* Returns all tags for the item in the slot.
|
|
2517
|
+
*
|
|
2518
|
+
* @returns
|
|
2519
|
+
* Returns all tags for the item in the slot. Return an empty
|
|
2520
|
+
* array if the the slot is empty.
|
|
2521
|
+
* @throws This function can throw errors.
|
|
2522
|
+
*/
|
|
2278
2523
|
getTags(): string[];
|
|
2524
|
+
/**
|
|
2525
|
+
* @remarks
|
|
2526
|
+
* Returns whether the item in the slot slot has the given tag.
|
|
2527
|
+
*
|
|
2528
|
+
* @param tag
|
|
2529
|
+
* The item tag.
|
|
2530
|
+
* @returns
|
|
2531
|
+
* Returns false when the slot is empty or the item in the slot
|
|
2532
|
+
* does not have the given tag.
|
|
2533
|
+
* @throws This function can throw errors.
|
|
2534
|
+
*/
|
|
2279
2535
|
hasTag(tag: string): boolean;
|
|
2280
2536
|
/**
|
|
2281
2537
|
* @remarks
|
|
@@ -2285,6 +2541,11 @@ export class ContainerSlot {
|
|
|
2285
2541
|
* item stacks. The amount of each item stack is not taken into
|
|
2286
2542
|
* consideration.
|
|
2287
2543
|
*
|
|
2544
|
+
* @param itemStack
|
|
2545
|
+
* The ItemStack that is being compared.
|
|
2546
|
+
* @returns
|
|
2547
|
+
* Returns whether this item stack can be stacked with the
|
|
2548
|
+
* given `itemStack`.
|
|
2288
2549
|
* @throws
|
|
2289
2550
|
* Throws if the slot's container is invalid.
|
|
2290
2551
|
*/
|
|
@@ -2297,6 +2558,8 @@ export class ContainerSlot {
|
|
|
2297
2558
|
*
|
|
2298
2559
|
* This function can't be called in read-only mode.
|
|
2299
2560
|
*
|
|
2561
|
+
* @param blockIdentifiers
|
|
2562
|
+
* The list of blocks, given by their identifiers.
|
|
2300
2563
|
* @throws
|
|
2301
2564
|
* Throws if the slot's container is invalid. Also throws if
|
|
2302
2565
|
* any of the provided block identifiers are invalid.
|
|
@@ -2311,6 +2574,8 @@ export class ContainerSlot {
|
|
|
2311
2574
|
*
|
|
2312
2575
|
* This function can't be called in read-only mode.
|
|
2313
2576
|
*
|
|
2577
|
+
* @param blockIdentifiers
|
|
2578
|
+
* The list of blocks, given by their identifiers.
|
|
2314
2579
|
* @throws
|
|
2315
2580
|
* Throws if the slot's container is invalid. Also throws if
|
|
2316
2581
|
* any of the provided block identifiers are invalid.
|
|
@@ -2318,8 +2583,13 @@ export class ContainerSlot {
|
|
|
2318
2583
|
setCanPlaceOn(blockIdentifiers?: string[]): void;
|
|
2319
2584
|
/**
|
|
2320
2585
|
* @remarks
|
|
2586
|
+
* Sets the given ItemStack in the slot, replacing any existing
|
|
2587
|
+
* item.
|
|
2588
|
+
*
|
|
2321
2589
|
* This function can't be called in read-only mode.
|
|
2322
2590
|
*
|
|
2591
|
+
* @param itemStack
|
|
2592
|
+
* The ItemStack to be placed in the slot.
|
|
2323
2593
|
* @throws This function can throw errors.
|
|
2324
2594
|
*/
|
|
2325
2595
|
setItem(itemStack?: ItemStack): void;
|
|
@@ -2330,6 +2600,9 @@ export class ContainerSlot {
|
|
|
2330
2600
|
*
|
|
2331
2601
|
* This function can't be called in read-only mode.
|
|
2332
2602
|
*
|
|
2603
|
+
* @param loreList
|
|
2604
|
+
* A list of lore strings. Setting this argument to undefined
|
|
2605
|
+
* will clear the lore.
|
|
2333
2606
|
* @throws
|
|
2334
2607
|
* Throws if the slot's container is invalid.
|
|
2335
2608
|
*/
|
|
@@ -2510,43 +2783,41 @@ export class Dimension {
|
|
|
2510
2783
|
* @throws This function can throw errors.
|
|
2511
2784
|
* @example createExplosion.ts
|
|
2512
2785
|
* ```typescript
|
|
2513
|
-
*
|
|
2786
|
+
* overworld.createExplosion(targetLocation, 10, new mc.ExplosionOptions());
|
|
2514
2787
|
* ```
|
|
2515
2788
|
* @example createFireAndWaterExplosions.ts
|
|
2516
2789
|
* ```typescript
|
|
2517
|
-
*
|
|
2518
|
-
*
|
|
2519
|
-
* const fireExplosionOptions = new mc.ExplosionOptions();
|
|
2790
|
+
* const explosionLoc: mc.Vector3 = { x: targetLocation.x + 0.5, y: targetLocation.y + 0.5, z: targetLocation.z + 0.5 };
|
|
2520
2791
|
*
|
|
2521
|
-
*
|
|
2522
|
-
* fireExplosionOptions.causesFire = true;
|
|
2792
|
+
* const fireExplosionOptions = new mc.ExplosionOptions();
|
|
2523
2793
|
*
|
|
2524
|
-
*
|
|
2525
|
-
*
|
|
2794
|
+
* // Explode with fire
|
|
2795
|
+
* fireExplosionOptions.causesFire = true;
|
|
2526
2796
|
*
|
|
2527
|
-
*
|
|
2528
|
-
*
|
|
2797
|
+
* overworld.createExplosion(explosionLoc, 15, fireExplosionOptions);
|
|
2798
|
+
* const waterExplosionOptions = new mc.ExplosionOptions();
|
|
2529
2799
|
*
|
|
2530
|
-
*
|
|
2800
|
+
* // Explode in water
|
|
2801
|
+
* waterExplosionOptions.allowUnderwater = true;
|
|
2531
2802
|
*
|
|
2532
|
-
*
|
|
2803
|
+
* const belowWaterLoc: mc.Vector3 = { x: targetLocation.x + 3, y: targetLocation.y + 1, z: targetLocation.z + 3 };
|
|
2533
2804
|
*
|
|
2805
|
+
* overworld.createExplosion(belowWaterLoc, 10, waterExplosionOptions);
|
|
2534
2806
|
* ```
|
|
2535
2807
|
* @example createNoBlockExplosion.ts
|
|
2536
2808
|
* ```typescript
|
|
2537
|
-
*
|
|
2809
|
+
* const explosionOptions = new mc.ExplosionOptions();
|
|
2538
2810
|
*
|
|
2539
|
-
*
|
|
2540
|
-
*
|
|
2811
|
+
* // Start by exploding without breaking blocks
|
|
2812
|
+
* explosionOptions.breaksBlocks = false;
|
|
2541
2813
|
*
|
|
2542
|
-
*
|
|
2543
|
-
*
|
|
2544
|
-
*
|
|
2545
|
-
*
|
|
2546
|
-
*
|
|
2547
|
-
*
|
|
2548
|
-
* overworld.createExplosion(explodeNoBlocksLoc, 15, explosionOptions);
|
|
2814
|
+
* const explodeNoBlocksLoc: mc.Vector3 = {
|
|
2815
|
+
* x: Math.floor(targetLocation.x + 1),
|
|
2816
|
+
* y: Math.floor(targetLocation.y + 2),
|
|
2817
|
+
* z: Math.floor(targetLocation.z + 1),
|
|
2818
|
+
* };
|
|
2549
2819
|
*
|
|
2820
|
+
* overworld.createExplosion(explodeNoBlocksLoc, 15, explosionOptions);
|
|
2550
2821
|
* ```
|
|
2551
2822
|
*/
|
|
2552
2823
|
createExplosion(location: Vector3, radius: number, explosionOptions?: ExplosionOptions): void;
|
|
@@ -2613,22 +2884,21 @@ export class Dimension {
|
|
|
2613
2884
|
* @throws This function can throw errors.
|
|
2614
2885
|
* @example testThatEntityIsFeatherItem.ts
|
|
2615
2886
|
* ```typescript
|
|
2616
|
-
*
|
|
2617
|
-
*
|
|
2618
|
-
*
|
|
2619
|
-
*
|
|
2620
|
-
*
|
|
2621
|
-
*
|
|
2622
|
-
*
|
|
2623
|
-
*
|
|
2624
|
-
*
|
|
2625
|
-
*
|
|
2626
|
-
*
|
|
2627
|
-
*
|
|
2628
|
-
*
|
|
2629
|
-
*
|
|
2630
|
-
*
|
|
2631
|
-
*
|
|
2887
|
+
* const query = {
|
|
2888
|
+
* type: "item",
|
|
2889
|
+
* location: targetLocation,
|
|
2890
|
+
* };
|
|
2891
|
+
* const items = overworld.getEntities(query);
|
|
2892
|
+
*
|
|
2893
|
+
* for (const item of items) {
|
|
2894
|
+
* const itemComp = item.getComponent("item") as any;
|
|
2895
|
+
*
|
|
2896
|
+
* if (itemComp) {
|
|
2897
|
+
* if (itemComp.itemStack.id.endsWith("feather")) {
|
|
2898
|
+
* console.log("Success! Found a feather", 1);
|
|
2899
|
+
* }
|
|
2900
|
+
* }
|
|
2901
|
+
* }
|
|
2632
2902
|
* ```
|
|
2633
2903
|
*/
|
|
2634
2904
|
getEntities(options?: EntityQueryOptions): Entity[];
|
|
@@ -2717,41 +2987,40 @@ export class Dimension {
|
|
|
2717
2987
|
* @throws This function can throw errors.
|
|
2718
2988
|
* @example createOldHorse.ts
|
|
2719
2989
|
* ```typescript
|
|
2720
|
-
*
|
|
2721
|
-
*
|
|
2990
|
+
* // create a horse and trigger the 'ageable_grow_up' event, ensuring the horse is created as an adult
|
|
2991
|
+
* overworld.spawnEntity("minecraft:horse<minecraft:ageable_grow_up>", targetLocation);
|
|
2722
2992
|
* ```
|
|
2723
2993
|
* @example quickFoxLazyDog.ts
|
|
2724
2994
|
* ```typescript
|
|
2725
|
-
*
|
|
2726
|
-
*
|
|
2727
|
-
*
|
|
2728
|
-
*
|
|
2729
|
-
*
|
|
2730
|
-
*
|
|
2731
|
-
*
|
|
2732
|
-
*
|
|
2733
|
-
*
|
|
2734
|
-
*
|
|
2735
|
-
*
|
|
2736
|
-
*
|
|
2737
|
-
*
|
|
2738
|
-
*
|
|
2739
|
-
*
|
|
2740
|
-
*
|
|
2741
|
-
*
|
|
2995
|
+
* const fox = overworld.spawnEntity("minecraft:fox", {
|
|
2996
|
+
* x: targetLocation.x + 1,
|
|
2997
|
+
* y: targetLocation.y + 2,
|
|
2998
|
+
* z: targetLocation.z + 3,
|
|
2999
|
+
* });
|
|
3000
|
+
* fox.addEffect(mc.MinecraftEffectTypes.speed, 10, 20);
|
|
3001
|
+
* log("Created a fox.");
|
|
3002
|
+
*
|
|
3003
|
+
* const wolf = overworld.spawnEntity("minecraft:wolf", {
|
|
3004
|
+
* x: targetLocation.x + 4,
|
|
3005
|
+
* y: targetLocation.y + 2,
|
|
3006
|
+
* z: targetLocation.z + 3,
|
|
3007
|
+
* });
|
|
3008
|
+
* wolf.addEffect(mc.MinecraftEffectTypes.slowness, 10, 20);
|
|
3009
|
+
* wolf.isSneaking = true;
|
|
3010
|
+
* log("Created a sneaking wolf.", 1);
|
|
2742
3011
|
* ```
|
|
2743
3012
|
* @example trapTick.ts
|
|
2744
3013
|
* ```typescript
|
|
2745
|
-
*
|
|
3014
|
+
* let ticks = 0;
|
|
2746
3015
|
*
|
|
2747
|
-
*
|
|
2748
|
-
*
|
|
3016
|
+
* mc.world.events.tick.subscribe((event: mc.TickEvent) => {
|
|
3017
|
+
* ticks++;
|
|
2749
3018
|
*
|
|
2750
|
-
*
|
|
2751
|
-
*
|
|
2752
|
-
*
|
|
2753
|
-
*
|
|
2754
|
-
*
|
|
3019
|
+
* // Minecraft runs at 20 ticks per second
|
|
3020
|
+
* if (ticks % 1200 === 0) {
|
|
3021
|
+
* overworld.runCommand("say Another minute passes...");
|
|
3022
|
+
* }
|
|
3023
|
+
* });
|
|
2755
3024
|
* ```
|
|
2756
3025
|
*/
|
|
2757
3026
|
spawnEntity(identifier: string, location: Vector3): Entity;
|
|
@@ -2770,25 +3039,24 @@ export class Dimension {
|
|
|
2770
3039
|
* @throws This function can throw errors.
|
|
2771
3040
|
* @example itemStacks.ts
|
|
2772
3041
|
* ```typescript
|
|
2773
|
-
*
|
|
2774
|
-
*
|
|
2775
|
-
*
|
|
2776
|
-
*
|
|
2777
|
-
* const oneEmerald = new mc.ItemStack(mc.MinecraftItemTypes.emerald, 1, 0);
|
|
2778
|
-
* const onePickaxe = new mc.ItemStack(mc.MinecraftItemTypes.diamondPickaxe, 1, 0);
|
|
2779
|
-
* const fiveEmeralds = new mc.ItemStack(mc.MinecraftItemTypes.emerald, 5, 0);
|
|
3042
|
+
* const oneItemLoc: mc.Vector3 = { x: 3, y: 2, z: 1 };
|
|
3043
|
+
* const fiveItemsLoc: mc.Vector3 = { x: 1, y: 2, z: 1 };
|
|
3044
|
+
* const diamondPickaxeLoc: mc.Vector3 = { x: 2, y: 2, z: 4 };
|
|
2780
3045
|
*
|
|
2781
|
-
*
|
|
2782
|
-
*
|
|
2783
|
-
*
|
|
3046
|
+
* const oneEmerald = new mc.ItemStack(mc.MinecraftItemTypes.emerald, 1, 0);
|
|
3047
|
+
* const onePickaxe = new mc.ItemStack(mc.MinecraftItemTypes.diamondPickaxe, 1, 0);
|
|
3048
|
+
* const fiveEmeralds = new mc.ItemStack(mc.MinecraftItemTypes.emerald, 5, 0);
|
|
2784
3049
|
*
|
|
3050
|
+
* overworld.spawnItem(oneEmerald, oneItemLoc);
|
|
3051
|
+
* overworld.spawnItem(fiveEmeralds, fiveItemsLoc);
|
|
3052
|
+
* overworld.spawnItem(onePickaxe, diamondPickaxeLoc);
|
|
2785
3053
|
* ```
|
|
2786
3054
|
* @example spawnItem.ts
|
|
2787
3055
|
* ```typescript
|
|
2788
|
-
*
|
|
3056
|
+
* const featherItem = new mc.ItemStack(mc.MinecraftItemTypes.feather, 1, 0);
|
|
2789
3057
|
*
|
|
2790
|
-
*
|
|
2791
|
-
*
|
|
3058
|
+
* overworld.spawnItem(featherItem, targetLocation);
|
|
3059
|
+
* log("New feather created!");
|
|
2792
3060
|
* ```
|
|
2793
3061
|
*/
|
|
2794
3062
|
spawnItem(itemStack: ItemStack, location: Vector3): Entity;
|
|
@@ -3247,7 +3515,7 @@ export class Entity {
|
|
|
3247
3515
|
/**
|
|
3248
3516
|
* @beta
|
|
3249
3517
|
* @remarks
|
|
3250
|
-
* Adds an effect, like poison, to the entity.
|
|
3518
|
+
* Adds or updates an effect, like poison, to the entity.
|
|
3251
3519
|
*
|
|
3252
3520
|
* This function can't be called in read-only mode.
|
|
3253
3521
|
*
|
|
@@ -3256,39 +3524,43 @@ export class Entity {
|
|
|
3256
3524
|
* @param duration
|
|
3257
3525
|
* Amount of time, in ticks, for the effect to apply. There are
|
|
3258
3526
|
* 20 ticks per second. Use {@link TicksPerSecond} constant to
|
|
3259
|
-
* convert between ticks and seconds.
|
|
3527
|
+
* convert between ticks and seconds. The value must be within
|
|
3528
|
+
* the range [0, 20000000].
|
|
3260
3529
|
* @param options
|
|
3261
3530
|
* Additional options for the effect.
|
|
3531
|
+
* @returns
|
|
3532
|
+
* Returns nothing if the effect was added or updated
|
|
3533
|
+
* successfully. This can throw an error if the duration or
|
|
3534
|
+
* amplifier are outside of the valid ranges, or if the effect
|
|
3535
|
+
* does not exist.
|
|
3262
3536
|
* @throws This function can throw errors.
|
|
3263
3537
|
* @example addEffect.js
|
|
3264
3538
|
* ```typescript
|
|
3265
|
-
*
|
|
3266
|
-
*
|
|
3267
|
-
*
|
|
3268
|
-
*
|
|
3269
|
-
*
|
|
3270
|
-
* villager.addEffect(EffectTypes.get('poison'), duration, { amplifier: 1 });
|
|
3539
|
+
* const villagerId = 'minecraft:villager_v2<minecraft:ageable_grow_up>';
|
|
3540
|
+
* const villagerLoc: mc.Vector3 = { x: 1, y: 2, z: 1 };
|
|
3541
|
+
* const villager = test.spawn(villagerId, villagerLoc);
|
|
3542
|
+
* const duration = 20;
|
|
3271
3543
|
*
|
|
3544
|
+
* villager.addEffect(EffectTypes.get('poison'), duration, { amplifier: 1 });
|
|
3272
3545
|
* ```
|
|
3273
3546
|
* @example quickFoxLazyDog.ts
|
|
3274
3547
|
* ```typescript
|
|
3275
|
-
*
|
|
3276
|
-
*
|
|
3277
|
-
*
|
|
3278
|
-
*
|
|
3279
|
-
*
|
|
3280
|
-
*
|
|
3281
|
-
*
|
|
3282
|
-
*
|
|
3283
|
-
*
|
|
3284
|
-
*
|
|
3285
|
-
*
|
|
3286
|
-
*
|
|
3287
|
-
*
|
|
3288
|
-
*
|
|
3289
|
-
*
|
|
3290
|
-
*
|
|
3291
|
-
*
|
|
3548
|
+
* const fox = overworld.spawnEntity('minecraft:fox', {
|
|
3549
|
+
* x: targetLocation.x + 1,
|
|
3550
|
+
* y: targetLocation.y + 2,
|
|
3551
|
+
* z: targetLocation.z + 3,
|
|
3552
|
+
* });
|
|
3553
|
+
* fox.addEffect(mc.MinecraftEffectTypes.speed, 10, { amplifier: 20 });
|
|
3554
|
+
* log('Created a fox.');
|
|
3555
|
+
*
|
|
3556
|
+
* const wolf = overworld.spawnEntity('minecraft:wolf', {
|
|
3557
|
+
* x: targetLocation.x + 4,
|
|
3558
|
+
* y: targetLocation.y + 2,
|
|
3559
|
+
* z: targetLocation.z + 3,
|
|
3560
|
+
* });
|
|
3561
|
+
* wolf.addEffect(mc.MinecraftEffectTypes.slowness, 10, { amplifier: 20 });
|
|
3562
|
+
* wolf.isSneaking = true;
|
|
3563
|
+
* log('Created a sneaking wolf.', 1);
|
|
3292
3564
|
* ```
|
|
3293
3565
|
*/
|
|
3294
3566
|
addEffect(effectType: EffectType | string, duration: number, options?: EntityEffectOptions): boolean;
|
|
@@ -3301,6 +3573,9 @@ export class Entity {
|
|
|
3301
3573
|
*
|
|
3302
3574
|
* @param tag
|
|
3303
3575
|
* Content of the tag to add.
|
|
3576
|
+
* @returns
|
|
3577
|
+
* Returns true if the tag was added successfully. This can
|
|
3578
|
+
* fail if the tag already exists on the entity.
|
|
3304
3579
|
* @throws This function can throw errors.
|
|
3305
3580
|
*/
|
|
3306
3581
|
addTag(tag: string): boolean;
|
|
@@ -3317,6 +3592,10 @@ export class Entity {
|
|
|
3317
3592
|
* Additional options about the source of damage, which may add
|
|
3318
3593
|
* additional effects or spur additional behaviors on this
|
|
3319
3594
|
* entity.
|
|
3595
|
+
* @returns
|
|
3596
|
+
* Whether the entity takes any damage. This can return false
|
|
3597
|
+
* if the entity is invulnerable or if the damage applied is
|
|
3598
|
+
* less than or equal to 0.
|
|
3320
3599
|
* @throws This function can throw errors.
|
|
3321
3600
|
*/
|
|
3322
3601
|
applyDamage(amount: number, options?: EntityApplyDamageByProjectileOptions | EntityApplyDamageOptions): boolean;
|
|
@@ -3375,6 +3654,8 @@ export class Entity {
|
|
|
3375
3654
|
* @param useEffects
|
|
3376
3655
|
* Whether to show any visual effects connected to the
|
|
3377
3656
|
* extinguishing.
|
|
3657
|
+
* @returns
|
|
3658
|
+
* Returns whether the entity was on fire.
|
|
3378
3659
|
* @throws This function can throw errors.
|
|
3379
3660
|
*/
|
|
3380
3661
|
extinguishFire(useEffects?: boolean): boolean;
|
|
@@ -3384,6 +3665,11 @@ export class Entity {
|
|
|
3384
3665
|
* Returns the first intersecting block from the direction that
|
|
3385
3666
|
* this entity is looking at.
|
|
3386
3667
|
*
|
|
3668
|
+
* @param options
|
|
3669
|
+
* Additional configuration options for the ray cast.
|
|
3670
|
+
* @returns
|
|
3671
|
+
* Returns the first intersecting block from the direction that
|
|
3672
|
+
* this entity is looking at.
|
|
3387
3673
|
* @throws This function can throw errors.
|
|
3388
3674
|
*/
|
|
3389
3675
|
getBlockFromViewDirection(options?: BlockRaycastOptions): Block;
|
|
@@ -3398,6 +3684,9 @@ export class Entity {
|
|
|
3398
3684
|
* to retrieve. If no namespace prefix is specified,
|
|
3399
3685
|
* 'minecraft:' is assumed. If the component is not present on
|
|
3400
3686
|
* the entity, undefined is returned.
|
|
3687
|
+
* @returns
|
|
3688
|
+
* Returns the component if it exists on the entity, otherwise
|
|
3689
|
+
* undefined.
|
|
3401
3690
|
*/
|
|
3402
3691
|
getComponent(componentId: string): EntityComponent | undefined;
|
|
3403
3692
|
/**
|
|
@@ -3406,6 +3695,9 @@ export class Entity {
|
|
|
3406
3695
|
* Returns all components that are both present on this entity
|
|
3407
3696
|
* and supported by the API.
|
|
3408
3697
|
*
|
|
3698
|
+
* @returns
|
|
3699
|
+
* Returns all components that are both present on this entity
|
|
3700
|
+
* and supported by the API.
|
|
3409
3701
|
*/
|
|
3410
3702
|
getComponents(): EntityComponent[];
|
|
3411
3703
|
/**
|
|
@@ -3413,6 +3705,8 @@ export class Entity {
|
|
|
3413
3705
|
* @remarks
|
|
3414
3706
|
* Returns a property value.
|
|
3415
3707
|
*
|
|
3708
|
+
* @param identifier
|
|
3709
|
+
* The property identifier.
|
|
3416
3710
|
* @returns
|
|
3417
3711
|
* Returns the value for the property, or undefined if the
|
|
3418
3712
|
* property has not been set.
|
|
@@ -3423,11 +3717,15 @@ export class Entity {
|
|
|
3423
3717
|
* @beta
|
|
3424
3718
|
* @remarks
|
|
3425
3719
|
* Returns the effect for the specified EffectType on the
|
|
3426
|
-
* entity,
|
|
3720
|
+
* entity, undefined if the effect is not present, or throws an
|
|
3721
|
+
* error if the effect does not exist.
|
|
3427
3722
|
*
|
|
3723
|
+
* @param effectType
|
|
3724
|
+
* The effect identifier.
|
|
3428
3725
|
* @returns
|
|
3429
|
-
* Effect object for the specified effect,
|
|
3430
|
-
* effect is not present
|
|
3726
|
+
* Effect object for the specified effect, undefined if the
|
|
3727
|
+
* effect is not present, or throws an error if the effect does
|
|
3728
|
+
* not exist.
|
|
3431
3729
|
* @throws This function can throw errors.
|
|
3432
3730
|
*/
|
|
3433
3731
|
getEffect(effectType: EffectType | string): Effect | undefined;
|
|
@@ -3444,9 +3742,14 @@ export class Entity {
|
|
|
3444
3742
|
/**
|
|
3445
3743
|
* @beta
|
|
3446
3744
|
* @remarks
|
|
3447
|
-
*
|
|
3448
|
-
*
|
|
3745
|
+
* Gets the entities that this entity is looking at by
|
|
3746
|
+
* performing a ray cast from the view of this entity.
|
|
3449
3747
|
*
|
|
3748
|
+
* @param options
|
|
3749
|
+
* Additional configuration options for the ray cast.
|
|
3750
|
+
* @returns
|
|
3751
|
+
* Returns a set of entities from the direction that this
|
|
3752
|
+
* entity is looking at.
|
|
3450
3753
|
* @throws This function can throw errors.
|
|
3451
3754
|
*/
|
|
3452
3755
|
getEntitiesFromViewDirection(options?: EntityRaycastOptions): Entity[];
|
|
@@ -3456,6 +3759,9 @@ export class Entity {
|
|
|
3456
3759
|
* Returns the current location of the head component of this
|
|
3457
3760
|
* entity.
|
|
3458
3761
|
*
|
|
3762
|
+
* @returns
|
|
3763
|
+
* Returns the current location of the head component of this
|
|
3764
|
+
* entity.
|
|
3459
3765
|
* @throws This function can throw errors.
|
|
3460
3766
|
*/
|
|
3461
3767
|
getHeadLocation(): Vector3;
|
|
@@ -3464,6 +3770,8 @@ export class Entity {
|
|
|
3464
3770
|
* @remarks
|
|
3465
3771
|
* Returns the current rotation component of this entity.
|
|
3466
3772
|
*
|
|
3773
|
+
* @returns
|
|
3774
|
+
* Returns the current rotation component of this entity.
|
|
3467
3775
|
* @throws This function can throw errors.
|
|
3468
3776
|
*/
|
|
3469
3777
|
getRotation(): Vector2;
|
|
@@ -3472,6 +3780,8 @@ export class Entity {
|
|
|
3472
3780
|
* @remarks
|
|
3473
3781
|
* Returns all tags associated with an entity.
|
|
3474
3782
|
*
|
|
3783
|
+
* @returns
|
|
3784
|
+
* Returns the current rotation component of this entity.
|
|
3475
3785
|
* @throws This function can throw errors.
|
|
3476
3786
|
*/
|
|
3477
3787
|
getTags(): string[];
|
|
@@ -3480,6 +3790,8 @@ export class Entity {
|
|
|
3480
3790
|
* @remarks
|
|
3481
3791
|
* Returns the current velocity vector of the entity.
|
|
3482
3792
|
*
|
|
3793
|
+
* @returns
|
|
3794
|
+
* Returns the current velocity vector of the entity.
|
|
3483
3795
|
* @throws This function can throw errors.
|
|
3484
3796
|
*/
|
|
3485
3797
|
getVelocity(): Vector3;
|
|
@@ -3488,6 +3800,8 @@ export class Entity {
|
|
|
3488
3800
|
* @remarks
|
|
3489
3801
|
* Returns the current view direction of the entity.
|
|
3490
3802
|
*
|
|
3803
|
+
* @returns
|
|
3804
|
+
* Returns the current view direction of the entity.
|
|
3491
3805
|
* @throws This function can throw errors.
|
|
3492
3806
|
*/
|
|
3493
3807
|
getViewDirection(): Vector3;
|
|
@@ -3501,15 +3815,20 @@ export class Entity {
|
|
|
3501
3815
|
* The identifier of the component (e.g., 'minecraft:rideable')
|
|
3502
3816
|
* to retrieve. If no namespace prefix is specified,
|
|
3503
3817
|
* 'minecraft:' is assumed.
|
|
3818
|
+
* @returns
|
|
3819
|
+
* Returns true if the specified component is present on this
|
|
3820
|
+
* entity.
|
|
3504
3821
|
*/
|
|
3505
3822
|
hasComponent(componentId: string): boolean;
|
|
3506
3823
|
/**
|
|
3507
3824
|
* @beta
|
|
3508
3825
|
* @remarks
|
|
3509
|
-
*
|
|
3826
|
+
* Returns whether an entity has a particular tag.
|
|
3510
3827
|
*
|
|
3511
3828
|
* @param tag
|
|
3512
3829
|
* Identifier of the tag to test for.
|
|
3830
|
+
* @returns
|
|
3831
|
+
* Returns whether an entity has a particular tag.
|
|
3513
3832
|
* @throws This function can throw errors.
|
|
3514
3833
|
*/
|
|
3515
3834
|
hasTag(tag: string): boolean;
|
|
@@ -3529,8 +3848,15 @@ export class Entity {
|
|
|
3529
3848
|
/**
|
|
3530
3849
|
* @beta
|
|
3531
3850
|
* @remarks
|
|
3851
|
+
* Cause the entity to play the given animation.
|
|
3852
|
+
*
|
|
3532
3853
|
* This function can't be called in read-only mode.
|
|
3533
3854
|
*
|
|
3855
|
+
* @param animationName
|
|
3856
|
+
* The animation identifier. e.g. animation.creeper.swelling
|
|
3857
|
+
* @param options
|
|
3858
|
+
* Additional options to control the playback and transitions
|
|
3859
|
+
* of the animation.
|
|
3534
3860
|
* @throws This function can throw errors.
|
|
3535
3861
|
*/
|
|
3536
3862
|
playAnimation(animationName: string, options?: PlayAnimationOptions): void;
|
|
@@ -3539,6 +3865,10 @@ export class Entity {
|
|
|
3539
3865
|
* @remarks
|
|
3540
3866
|
* Removes a specified property.
|
|
3541
3867
|
*
|
|
3868
|
+
* @param identifier
|
|
3869
|
+
* The property identifier.
|
|
3870
|
+
* @returns
|
|
3871
|
+
* Returns whether the given property existed on the entity.
|
|
3542
3872
|
* @throws This function can throw errors.
|
|
3543
3873
|
*/
|
|
3544
3874
|
removeDynamicProperty(identifier: string): boolean;
|
|
@@ -3550,9 +3880,12 @@ export class Entity {
|
|
|
3550
3880
|
*
|
|
3551
3881
|
* This function can't be called in read-only mode.
|
|
3552
3882
|
*
|
|
3883
|
+
* @param effectType
|
|
3884
|
+
* The effect identifier.
|
|
3553
3885
|
* @returns
|
|
3554
|
-
* Returns true if the effect has been removed
|
|
3555
|
-
* effect is not present
|
|
3886
|
+
* Returns true if the effect has been removed, false if the
|
|
3887
|
+
* effect is not present, or will throw an error if the effect
|
|
3888
|
+
* does not exist.
|
|
3556
3889
|
* @throws This function can throw errors.
|
|
3557
3890
|
*/
|
|
3558
3891
|
removeEffect(effectType: EffectType | string): boolean;
|
|
@@ -3565,6 +3898,8 @@ export class Entity {
|
|
|
3565
3898
|
*
|
|
3566
3899
|
* @param tag
|
|
3567
3900
|
* Content of the tag to remove.
|
|
3901
|
+
* @returns
|
|
3902
|
+
* Returns whether the tag existed on the entity.
|
|
3568
3903
|
* @throws This function can throw errors.
|
|
3569
3904
|
*/
|
|
3570
3905
|
removeTag(tag: string): boolean;
|
|
@@ -3575,6 +3910,12 @@ export class Entity {
|
|
|
3575
3910
|
*
|
|
3576
3911
|
* This function can't be called in read-only mode.
|
|
3577
3912
|
*
|
|
3913
|
+
* @param commandString
|
|
3914
|
+
* The command string. Note: This should not include a leading
|
|
3915
|
+
* forward slash.
|
|
3916
|
+
* @returns
|
|
3917
|
+
* A command result containing whether the command was
|
|
3918
|
+
* successful.
|
|
3578
3919
|
* @throws This function can throw errors.
|
|
3579
3920
|
*/
|
|
3580
3921
|
runCommand(commandString: string): CommandResult;
|
|
@@ -3598,6 +3939,8 @@ export class Entity {
|
|
|
3598
3939
|
* @remarks
|
|
3599
3940
|
* Sets a specified property to a value.
|
|
3600
3941
|
*
|
|
3942
|
+
* @param identifier
|
|
3943
|
+
* The property identifier.
|
|
3601
3944
|
* @param value
|
|
3602
3945
|
* Data value of the property to set.
|
|
3603
3946
|
* @throws This function can throw errors.
|
|
@@ -3614,6 +3957,14 @@ export class Entity {
|
|
|
3614
3957
|
*
|
|
3615
3958
|
* @param seconds
|
|
3616
3959
|
* Length of time to set the entity on fire.
|
|
3960
|
+
* @param useEffects
|
|
3961
|
+
* Whether side-effects should be applied (e.g. thawing freeze)
|
|
3962
|
+
* and other conditions such as rain or fire protection should
|
|
3963
|
+
* be taken into consideration.
|
|
3964
|
+
* @returns
|
|
3965
|
+
* Whether the entity was set on fire. This can fail if seconds
|
|
3966
|
+
* is less than or equal to zero, the entity is wet or the
|
|
3967
|
+
* entity is immune to fire.
|
|
3617
3968
|
* @throws This function can throw errors.
|
|
3618
3969
|
*/
|
|
3619
3970
|
setOnFire(seconds: number, useEffects?: boolean): boolean;
|
|
@@ -3624,6 +3975,10 @@ export class Entity {
|
|
|
3624
3975
|
*
|
|
3625
3976
|
* This function can't be called in read-only mode.
|
|
3626
3977
|
*
|
|
3978
|
+
* @param rotation
|
|
3979
|
+
* The x and y rotation of the entity. For most mobs, the x
|
|
3980
|
+
* rotation controls the head tilt and the y rotation controls
|
|
3981
|
+
* the body rotation.
|
|
3627
3982
|
* @throws This function can throw errors.
|
|
3628
3983
|
*/
|
|
3629
3984
|
setRotation(rotation: Vector2): void;
|
|
@@ -3636,6 +3991,8 @@ export class Entity {
|
|
|
3636
3991
|
*
|
|
3637
3992
|
* @param location
|
|
3638
3993
|
* New location for the entity.
|
|
3994
|
+
* @param teleportOptions
|
|
3995
|
+
* Options regarding the teleport operation.
|
|
3639
3996
|
* @throws This function can throw errors.
|
|
3640
3997
|
*/
|
|
3641
3998
|
teleport(location: Vector3, teleportOptions?: TeleportOptions): void;
|
|
@@ -3668,6 +4025,10 @@ export class Entity {
|
|
|
3668
4025
|
* Location to teleport the entity to.
|
|
3669
4026
|
* @param teleportOptions
|
|
3670
4027
|
* Options regarding the teleport operation.
|
|
4028
|
+
* @returns
|
|
4029
|
+
* Returns whether the teleport succeeded. This can fail if the
|
|
4030
|
+
* destination chunk is unloaded or if the teleport would
|
|
4031
|
+
* result in intersecting with blocks.
|
|
3671
4032
|
* @throws This function can throw errors.
|
|
3672
4033
|
*/
|
|
3673
4034
|
tryTeleport(location: Vector3, teleportOptions?: TeleportOptions): boolean;
|
|
@@ -4025,28 +4386,51 @@ export class EntityDieAfterEventSignal extends IEntityDieAfterEventSignal {
|
|
|
4025
4386
|
|
|
4026
4387
|
/**
|
|
4027
4388
|
* @beta
|
|
4389
|
+
* Provides access to a mob's equipment slots. This component
|
|
4390
|
+
* exists for all mob entities.
|
|
4028
4391
|
*/
|
|
4029
4392
|
export class EntityEquipmentInventoryComponent extends EntityComponent {
|
|
4030
4393
|
protected constructor();
|
|
4031
4394
|
static readonly componentId = 'minecraft:equipment_inventory';
|
|
4032
4395
|
/**
|
|
4033
4396
|
* @remarks
|
|
4397
|
+
* Gets the equipped item for the given EquipmentSlot.
|
|
4398
|
+
*
|
|
4034
4399
|
* This function can't be called in read-only mode.
|
|
4035
4400
|
*
|
|
4401
|
+
* @param equipmentSlot
|
|
4402
|
+
* The equipment slot. e.g. "head", "chest", "offhand"
|
|
4403
|
+
* @returns
|
|
4404
|
+
* Returns the item equipped to the given EquipmentSlot. If
|
|
4405
|
+
* empty, returns undefined.
|
|
4036
4406
|
* @throws This function can throw errors.
|
|
4037
4407
|
*/
|
|
4038
4408
|
getEquipment(equipmentSlot: EquipmentSlot): ItemStack | undefined;
|
|
4039
4409
|
/**
|
|
4040
4410
|
* @remarks
|
|
4411
|
+
* Gets the ContainerSlot corresponding to the given
|
|
4412
|
+
* EquipmentSlot.
|
|
4413
|
+
*
|
|
4041
4414
|
* This function can't be called in read-only mode.
|
|
4042
4415
|
*
|
|
4416
|
+
* @param equipmentSlot
|
|
4417
|
+
* The equipment slot. e.g. "head", "chest", "offhand".
|
|
4418
|
+
* @returns
|
|
4419
|
+
* Returns the ContainerSlot corresponding to the given
|
|
4420
|
+
* EquipmentSlot.
|
|
4043
4421
|
* @throws This function can throw errors.
|
|
4044
4422
|
*/
|
|
4045
4423
|
getEquipmentSlot(equipmentSlot: EquipmentSlot): ContainerSlot;
|
|
4046
4424
|
/**
|
|
4047
4425
|
* @remarks
|
|
4426
|
+
* Replaces the item in the given EquipmentSlot.
|
|
4427
|
+
*
|
|
4048
4428
|
* This function can't be called in read-only mode.
|
|
4049
4429
|
*
|
|
4430
|
+
* @param equipmentSlot
|
|
4431
|
+
* The equipment slot. e.g. "head", "chest", "offhand".
|
|
4432
|
+
* @param itemStack
|
|
4433
|
+
* The item to equip. If undefined, clears the slot.
|
|
4050
4434
|
* @throws This function can throw errors.
|
|
4051
4435
|
*/
|
|
4052
4436
|
setEquipment(equipmentSlot: EquipmentSlot, itemStack?: ItemStack): void;
|
|
@@ -6603,36 +6987,16 @@ export class IServerMessageAfterEventSignal {
|
|
|
6603
6987
|
|
|
6604
6988
|
/**
|
|
6605
6989
|
* @beta
|
|
6606
|
-
* Contains information related to a chargeable item completing
|
|
6607
|
-
* being charged.
|
|
6608
6990
|
*/
|
|
6609
6991
|
export class ItemCompleteChargeAfterEvent {
|
|
6610
6992
|
protected constructor();
|
|
6611
|
-
/**
|
|
6612
|
-
* @remarks
|
|
6613
|
-
* Returns the item stack that has completed charging.
|
|
6614
|
-
*
|
|
6615
|
-
*/
|
|
6616
6993
|
readonly itemStack: ItemStack;
|
|
6617
|
-
/**
|
|
6618
|
-
* @remarks
|
|
6619
|
-
* Returns the source entity that triggered this item event.
|
|
6620
|
-
*
|
|
6621
|
-
*/
|
|
6622
6994
|
readonly source: Entity;
|
|
6623
|
-
/**
|
|
6624
|
-
* @remarks
|
|
6625
|
-
* Returns the time, in ticks, for the remaining duration left
|
|
6626
|
-
* before the charge completes its cycle.
|
|
6627
|
-
*
|
|
6628
|
-
*/
|
|
6629
6995
|
readonly useDuration: number;
|
|
6630
6996
|
}
|
|
6631
6997
|
|
|
6632
6998
|
/**
|
|
6633
6999
|
* @beta
|
|
6634
|
-
* Manages callbacks that are connected to the completion of
|
|
6635
|
-
* charging for a chargeable item.
|
|
6636
7000
|
*/
|
|
6637
7001
|
export class ItemCompleteChargeAfterEventSignal extends IItemCompleteChargeAfterEventSignal {
|
|
6638
7002
|
protected constructor();
|
|
@@ -6887,37 +7251,16 @@ export class ItemFoodComponent extends ItemComponent {
|
|
|
6887
7251
|
|
|
6888
7252
|
/**
|
|
6889
7253
|
* @beta
|
|
6890
|
-
* Contains information related to a chargeable item when the
|
|
6891
|
-
* player has finished using the item and released the build
|
|
6892
|
-
* action.
|
|
6893
7254
|
*/
|
|
6894
7255
|
export class ItemReleaseChargeAfterEvent {
|
|
6895
7256
|
protected constructor();
|
|
6896
|
-
/**
|
|
6897
|
-
* @remarks
|
|
6898
|
-
* Returns the item stack that triggered this item event.
|
|
6899
|
-
*
|
|
6900
|
-
*/
|
|
6901
7257
|
readonly itemStack: ItemStack;
|
|
6902
|
-
/**
|
|
6903
|
-
* @remarks
|
|
6904
|
-
* Returns the source entity that triggered this item event.
|
|
6905
|
-
*
|
|
6906
|
-
*/
|
|
6907
7258
|
readonly source: Entity;
|
|
6908
|
-
/**
|
|
6909
|
-
* @remarks
|
|
6910
|
-
* Returns the time, in ticks, for the remaining duration left
|
|
6911
|
-
* before the charge completes its cycle.
|
|
6912
|
-
*
|
|
6913
|
-
*/
|
|
6914
7259
|
readonly useDuration: number;
|
|
6915
7260
|
}
|
|
6916
7261
|
|
|
6917
7262
|
/**
|
|
6918
7263
|
* @beta
|
|
6919
|
-
* Manages callbacks that are connected to the releasing of
|
|
6920
|
-
* charging for a chargeable item.
|
|
6921
7264
|
*/
|
|
6922
7265
|
export class ItemReleaseChargeAfterEventSignal extends IItemReleaseChargeAfterEventSignal {
|
|
6923
7266
|
protected constructor();
|
|
@@ -7040,11 +7383,10 @@ export class ItemStack {
|
|
|
7040
7383
|
* stack, undefined is returned.
|
|
7041
7384
|
* @example durability.ts
|
|
7042
7385
|
* ```typescript
|
|
7043
|
-
*
|
|
7044
|
-
*
|
|
7045
|
-
*
|
|
7046
|
-
*
|
|
7047
|
-
*
|
|
7386
|
+
* // Get the maximum durability of a custom sword item
|
|
7387
|
+
* const itemStack = new ItemStack("custom:sword");
|
|
7388
|
+
* const durability = itemStack.getComponent("minecraft:durability") as ItemDurabilityComponent;
|
|
7389
|
+
* const maxDurability = durability.maxDurability;
|
|
7048
7390
|
* ```
|
|
7049
7391
|
*/
|
|
7050
7392
|
getComponent(componentId: string): ItemComponent | undefined;
|
|
@@ -7120,10 +7462,9 @@ export class ItemStack {
|
|
|
7120
7462
|
* Throws if any of the provided block identifiers are invalid.
|
|
7121
7463
|
* @example example.ts
|
|
7122
7464
|
* ```typescript
|
|
7123
|
-
*
|
|
7124
|
-
*
|
|
7125
|
-
*
|
|
7126
|
-
*
|
|
7465
|
+
* // Creates a diamond pickaxe that can destroy cobblestone and obsidian
|
|
7466
|
+
* const specialPickaxe = new ItemStack("minecraft:diamond_pickaxe");
|
|
7467
|
+
* specialPickaxe.setCanDestroy(["minecraft:cobblestone", "minecraft:obsidian"]);
|
|
7127
7468
|
* ```
|
|
7128
7469
|
*/
|
|
7129
7470
|
setCanDestroy(blockIdentifiers?: string[]): void;
|
|
@@ -7141,10 +7482,9 @@ export class ItemStack {
|
|
|
7141
7482
|
* Throws if any of the provided block identifiers are invalid.
|
|
7142
7483
|
* @example example.ts
|
|
7143
7484
|
* ```typescript
|
|
7144
|
-
*
|
|
7145
|
-
*
|
|
7146
|
-
*
|
|
7147
|
-
*
|
|
7485
|
+
* // Creates a gold block that can be placed on grass and dirt
|
|
7486
|
+
* const specialGoldBlock = new ItemStack("minecraft:gold_block");
|
|
7487
|
+
* specialPickaxe.setCanPlaceOn(["minecraft:grass", "minecraft:dirt"]);
|
|
7148
7488
|
* ```
|
|
7149
7489
|
*/
|
|
7150
7490
|
setCanPlaceOn(blockIdentifiers?: string[]): void;
|
|
@@ -7158,10 +7498,9 @@ export class ItemStack {
|
|
|
7158
7498
|
*
|
|
7159
7499
|
* @example multilineLore.ts
|
|
7160
7500
|
* ```typescript
|
|
7161
|
-
*
|
|
7162
|
-
*
|
|
7163
|
-
*
|
|
7164
|
-
*
|
|
7501
|
+
* // Set the lore of an item to multiple lines of text
|
|
7502
|
+
* const itemStack = new ItemStack("minecraft:diamond_sword");
|
|
7503
|
+
* itemStack.setLore(["Line 1", "Line 2", "Line 3"]);
|
|
7165
7504
|
* ```
|
|
7166
7505
|
*/
|
|
7167
7506
|
setLore(loreList?: string[]): void;
|
|
@@ -7183,36 +7522,16 @@ export class ItemStack {
|
|
|
7183
7522
|
|
|
7184
7523
|
/**
|
|
7185
7524
|
* @beta
|
|
7186
|
-
* Contains information related to a chargeable item starting
|
|
7187
|
-
* to be charged.
|
|
7188
7525
|
*/
|
|
7189
7526
|
export class ItemStartChargeAfterEvent {
|
|
7190
7527
|
protected constructor();
|
|
7191
|
-
/**
|
|
7192
|
-
* @remarks
|
|
7193
|
-
* The impacted item stack that is starting to be charged.
|
|
7194
|
-
*
|
|
7195
|
-
*/
|
|
7196
7528
|
readonly itemStack: ItemStack;
|
|
7197
|
-
/**
|
|
7198
|
-
* @remarks
|
|
7199
|
-
* Returns the source entity that triggered this item event.
|
|
7200
|
-
*
|
|
7201
|
-
*/
|
|
7202
7529
|
readonly source: Entity;
|
|
7203
|
-
/**
|
|
7204
|
-
* @remarks
|
|
7205
|
-
* Returns the time, in ticks, for the remaining duration left
|
|
7206
|
-
* before the charge completes its cycle.
|
|
7207
|
-
*
|
|
7208
|
-
*/
|
|
7209
7530
|
readonly useDuration: number;
|
|
7210
7531
|
}
|
|
7211
7532
|
|
|
7212
7533
|
/**
|
|
7213
7534
|
* @beta
|
|
7214
|
-
* Manages callbacks that are connected to the start of
|
|
7215
|
-
* charging for a chargeable item.
|
|
7216
7535
|
*/
|
|
7217
7536
|
export class ItemStartChargeAfterEventSignal extends IItemStartChargeAfterEventSignal {
|
|
7218
7537
|
protected constructor();
|
|
@@ -7265,38 +7584,16 @@ export class ItemStartUseOnAfterEventSignal extends IItemStartUseOnAfterEventSig
|
|
|
7265
7584
|
|
|
7266
7585
|
/**
|
|
7267
7586
|
* @beta
|
|
7268
|
-
* Contains information related to a chargeable item has
|
|
7269
|
-
* finished an items use cycle, or when the player has released
|
|
7270
|
-
* the use action with the item.
|
|
7271
7587
|
*/
|
|
7272
7588
|
export class ItemStopChargeAfterEvent {
|
|
7273
7589
|
protected constructor();
|
|
7274
|
-
/**
|
|
7275
|
-
* @remarks
|
|
7276
|
-
* The impacted item stack that is stopping being charged.
|
|
7277
|
-
*
|
|
7278
|
-
*/
|
|
7279
7590
|
readonly itemStack: ItemStack;
|
|
7280
|
-
/**
|
|
7281
|
-
* @remarks
|
|
7282
|
-
* Returns the source entity that triggered this item event.
|
|
7283
|
-
*
|
|
7284
|
-
*/
|
|
7285
7591
|
readonly source: Entity;
|
|
7286
|
-
/**
|
|
7287
|
-
* @remarks
|
|
7288
|
-
* Returns the time, in ticks, for the remaining duration left
|
|
7289
|
-
* before the charge completes its cycle.
|
|
7290
|
-
*
|
|
7291
|
-
*/
|
|
7292
7592
|
readonly useDuration: number;
|
|
7293
7593
|
}
|
|
7294
7594
|
|
|
7295
7595
|
/**
|
|
7296
7596
|
* @beta
|
|
7297
|
-
* Manages callbacks that are connected to the stopping of
|
|
7298
|
-
* charging for an item that has a registered
|
|
7299
|
-
* minecraft:chargeable component.
|
|
7300
7597
|
*/
|
|
7301
7598
|
export class ItemStopChargeAfterEventSignal extends IItemStopChargeAfterEventSignal {
|
|
7302
7599
|
protected constructor();
|
|
@@ -16395,33 +16692,29 @@ export class Player extends Entity {
|
|
|
16395
16692
|
* is provided to `score`.
|
|
16396
16693
|
* @example nestedTranslation.ts
|
|
16397
16694
|
* ```typescript
|
|
16398
|
-
*
|
|
16399
|
-
*
|
|
16400
|
-
*
|
|
16401
|
-
*
|
|
16402
|
-
*
|
|
16403
|
-
*
|
|
16404
|
-
*
|
|
16695
|
+
* // Displays "Apple or Coal"
|
|
16696
|
+
* let rawMessage = {
|
|
16697
|
+
* translate: "accessibility.list.or.two",
|
|
16698
|
+
* with: { rawtext: [{ translate: "item.apple.name" }, { translate: "item.coal.name" }] },
|
|
16699
|
+
* };
|
|
16700
|
+
* player.sendMessage(rawMessage);
|
|
16405
16701
|
* ```
|
|
16406
16702
|
* @example scoreWildcard.ts
|
|
16407
16703
|
* ```typescript
|
|
16408
|
-
*
|
|
16409
|
-
*
|
|
16410
|
-
*
|
|
16411
|
-
*
|
|
16704
|
+
* // Displays the player's score for objective "obj". Each player will see their own score.
|
|
16705
|
+
* const rawMessage = { score: { name: "*", objective: "obj" } };
|
|
16706
|
+
* world.sendMessage(rawMessage);
|
|
16412
16707
|
* ```
|
|
16413
16708
|
* @example simpleString.ts
|
|
16414
16709
|
* ```typescript
|
|
16415
|
-
*
|
|
16416
|
-
*
|
|
16417
|
-
*
|
|
16710
|
+
* // Displays "Hello, world!"
|
|
16711
|
+
* world.sendMessage("Hello, world!");
|
|
16418
16712
|
* ```
|
|
16419
16713
|
* @example translation.ts
|
|
16420
16714
|
* ```typescript
|
|
16421
|
-
*
|
|
16422
|
-
*
|
|
16423
|
-
*
|
|
16424
|
-
*
|
|
16715
|
+
* // Displays "First or Second"
|
|
16716
|
+
* const rawMessage = { translate: "accessibility.list.or.two", with: ["First", "Second"] };
|
|
16717
|
+
* player.sendMessage(rawMessage);
|
|
16425
16718
|
* ```
|
|
16426
16719
|
*/
|
|
16427
16720
|
sendMessage(message: (RawMessage | string)[] | RawMessage | string): void;
|
|
@@ -17660,33 +17953,29 @@ export class World {
|
|
|
17660
17953
|
* is provided to `score`.
|
|
17661
17954
|
* @example nestedTranslation.ts
|
|
17662
17955
|
* ```typescript
|
|
17663
|
-
*
|
|
17664
|
-
*
|
|
17665
|
-
*
|
|
17666
|
-
*
|
|
17667
|
-
*
|
|
17668
|
-
*
|
|
17669
|
-
*
|
|
17956
|
+
* // Displays "Apple or Coal"
|
|
17957
|
+
* let rawMessage = {
|
|
17958
|
+
* translate: "accessibility.list.or.two",
|
|
17959
|
+
* with: { rawtext: [{ translate: "item.apple.name" }, { translate: "item.coal.name" }] },
|
|
17960
|
+
* };
|
|
17961
|
+
* world.sendMessage(rawMessage);
|
|
17670
17962
|
* ```
|
|
17671
17963
|
* @example scoreWildcard.ts
|
|
17672
17964
|
* ```typescript
|
|
17673
|
-
*
|
|
17674
|
-
*
|
|
17675
|
-
*
|
|
17676
|
-
*
|
|
17965
|
+
* // Displays the player's score for objective "obj". Each player will see their own score.
|
|
17966
|
+
* const rawMessage = { score: { name: "*", objective: "obj" } };
|
|
17967
|
+
* world.sendMessage(rawMessage);
|
|
17677
17968
|
* ```
|
|
17678
17969
|
* @example simpleString.ts
|
|
17679
17970
|
* ```typescript
|
|
17680
|
-
*
|
|
17681
|
-
*
|
|
17682
|
-
*
|
|
17971
|
+
* // Displays "Hello, world!"
|
|
17972
|
+
* world.sendMessage("Hello, world!");
|
|
17683
17973
|
* ```
|
|
17684
17974
|
* @example translation.ts
|
|
17685
17975
|
* ```typescript
|
|
17686
|
-
*
|
|
17687
|
-
*
|
|
17688
|
-
*
|
|
17689
|
-
*
|
|
17976
|
+
* // Displays "First or Second"
|
|
17977
|
+
* const rawMessage = { translate: "accessibility.list.or.two", with: ["First", "Second"] };
|
|
17978
|
+
* world.sendMessage(rawMessage);
|
|
17690
17979
|
* ```
|
|
17691
17980
|
*/
|
|
17692
17981
|
sendMessage(message: (RawMessage | string)[] | RawMessage | string): void;
|
|
@@ -17754,18 +18043,17 @@ export class WorldInitializeAfterEvent {
|
|
|
17754
18043
|
*
|
|
17755
18044
|
* @example propertyRegistration.js
|
|
17756
18045
|
* ```typescript
|
|
17757
|
-
*
|
|
18046
|
+
* import { DynamicPropertiesDefinition, MinecraftEntityTypes, world } from "@minecraft/server";
|
|
17758
18047
|
*
|
|
17759
|
-
*
|
|
17760
|
-
*
|
|
18048
|
+
* world.afterEvents.worldInitialize.subscribe((e) => {
|
|
18049
|
+
* let def = new DynamicPropertiesDefinition();
|
|
17761
18050
|
*
|
|
17762
|
-
*
|
|
17763
|
-
*
|
|
17764
|
-
*
|
|
17765
|
-
*
|
|
17766
|
-
* e.propertyRegistry.registerEntityTypeDynamicProperties(def, MinecraftEntityTypes.skeleton);
|
|
17767
|
-
* });
|
|
18051
|
+
* def.defineNumber("rpgStrength");
|
|
18052
|
+
* def.defineString("rpgRole", 16);
|
|
18053
|
+
* def.defineBoolean("rpgIsHero");
|
|
17768
18054
|
*
|
|
18055
|
+
* e.propertyRegistry.registerEntityTypeDynamicProperties(def, MinecraftEntityTypes.skeleton);
|
|
18056
|
+
* });
|
|
17769
18057
|
* ```
|
|
17770
18058
|
*/
|
|
17771
18059
|
readonly propertyRegistry: PropertyRegistry;
|
|
@@ -17852,17 +18140,83 @@ export interface BlockRaycastOptions {
|
|
|
17852
18140
|
|
|
17853
18141
|
/**
|
|
17854
18142
|
* @beta
|
|
18143
|
+
* A BlockVolume is a simple interface to an object which
|
|
18144
|
+
* represents a 3D rectangle of a given size (in blocks) at a
|
|
18145
|
+
* world block location.
|
|
18146
|
+
* Note that these are not analogous to "min" and "max" values,
|
|
18147
|
+
* in that the vector components are not guaranteed to be in
|
|
18148
|
+
* any order.
|
|
18149
|
+
* In addition, these vector positions are not interchangeable
|
|
18150
|
+
* with BlockLocation.
|
|
18151
|
+
* If you want to get this volume represented as range of of
|
|
18152
|
+
* BlockLocations, you can use the getBoundingBox utility
|
|
18153
|
+
* function.
|
|
18154
|
+
* This volume class will maintain the ordering of the corner
|
|
18155
|
+
* indexes as initially set. imagine that each corner is
|
|
18156
|
+
* assigned in Editor - as you move the corner around
|
|
18157
|
+
* (potentially inverting the min/max relationship of the
|
|
18158
|
+
* bounds) - what
|
|
18159
|
+
* you had originally selected as the top/left corner would
|
|
18160
|
+
* traditionally become the bottom/right.
|
|
18161
|
+
* When manually editing these kinds of volumes, you need to
|
|
18162
|
+
* maintain the identity of the corner as you edit - the
|
|
18163
|
+
* BlockVolume utility functions do this.
|
|
18164
|
+
*
|
|
18165
|
+
* Important to note that this measures block sizes (to/from) -
|
|
18166
|
+
* a normal AABB (0,0,0) to (0,0,0) would traditionally be of
|
|
18167
|
+
* size (0,0,0)
|
|
18168
|
+
* However, because we're measuring blocks - the size or span
|
|
18169
|
+
* of a BlockVolume would actually be (1,1,1)
|
|
18170
|
+
*
|
|
17855
18171
|
*/
|
|
17856
18172
|
export interface BlockVolume {
|
|
18173
|
+
/**
|
|
18174
|
+
* @remarks
|
|
18175
|
+
* A world block location that represents a corner in a 3D
|
|
18176
|
+
* rectangle
|
|
18177
|
+
*
|
|
18178
|
+
*/
|
|
17857
18179
|
from: Vector3;
|
|
18180
|
+
/**
|
|
18181
|
+
* @remarks
|
|
18182
|
+
* A world block location that represents the opposite corner
|
|
18183
|
+
* in a 3D rectangle
|
|
18184
|
+
*
|
|
18185
|
+
*/
|
|
17858
18186
|
to: Vector3;
|
|
17859
18187
|
}
|
|
17860
18188
|
|
|
17861
18189
|
/**
|
|
17862
18190
|
* @beta
|
|
18191
|
+
* A BoundingBox is an interface to an object which represents
|
|
18192
|
+
* an AABB aligned rectangle.
|
|
18193
|
+
* The BoundingBox assumes that it was created in a valid state
|
|
18194
|
+
* (min <= max) but cannot guarantee it (unless it was created
|
|
18195
|
+
* using the associated {@link
|
|
18196
|
+
* @minecraft-server.BoundingBoxUtils} utility functions.
|
|
18197
|
+
* The min/max coordinates represent the diametrically opposite
|
|
18198
|
+
* corners of the rectangle.
|
|
18199
|
+
* The BoundingBox is not a representation of blocks - it has
|
|
18200
|
+
* no association with any type, it is just a mathematical
|
|
18201
|
+
* construct - so a rectangle with
|
|
18202
|
+
* ( 0,0,0 ) -> ( 0,0,0 )
|
|
18203
|
+
* has a size of ( 0,0,0 ) (unlike the very similar {@link
|
|
18204
|
+
* BlockVolume} object)
|
|
17863
18205
|
*/
|
|
17864
18206
|
export interface BoundingBox {
|
|
18207
|
+
/**
|
|
18208
|
+
* @remarks
|
|
18209
|
+
* A {@link @minecraft-server.Vector3} that represents the
|
|
18210
|
+
* largest corner of the rectangle
|
|
18211
|
+
*
|
|
18212
|
+
*/
|
|
17865
18213
|
max: Vector3;
|
|
18214
|
+
/**
|
|
18215
|
+
* @remarks
|
|
18216
|
+
* A {@link @minecraft-server.Vector3} that represents the
|
|
18217
|
+
* smallest corner of the rectangle
|
|
18218
|
+
*
|
|
18219
|
+
*/
|
|
17866
18220
|
min: Vector3;
|
|
17867
18221
|
}
|
|
17868
18222
|
|
|
@@ -17903,9 +18257,27 @@ export interface Color {
|
|
|
17903
18257
|
|
|
17904
18258
|
/**
|
|
17905
18259
|
* @beta
|
|
18260
|
+
* This interface defines an entry into the {@link
|
|
18261
|
+
* @minecraft-server/CompoundBlockVolume} which represents a
|
|
18262
|
+
* volume of positive or negative space.
|
|
18263
|
+
*
|
|
17906
18264
|
*/
|
|
17907
18265
|
export interface CompoundBlockVolumeItem {
|
|
18266
|
+
/**
|
|
18267
|
+
* @remarks
|
|
18268
|
+
* The 'action' defines how the block volume is represented in
|
|
18269
|
+
* the compound block volume stack.
|
|
18270
|
+
* 'Add' creates a block volume which is positively selected
|
|
18271
|
+
* 'Subtract' creates a block volume which represents a hole or
|
|
18272
|
+
* negative space in the overall compound block volume.
|
|
18273
|
+
*
|
|
18274
|
+
*/
|
|
17908
18275
|
action: CompoundBlockVolumeAction;
|
|
18276
|
+
/**
|
|
18277
|
+
* @remarks
|
|
18278
|
+
* The volume of space
|
|
18279
|
+
*
|
|
18280
|
+
*/
|
|
17909
18281
|
volume: BlockVolume;
|
|
17910
18282
|
}
|
|
17911
18283
|
|