@minecraft/server 1.10.0-beta.1.20.70-preview.21 → 1.10.0-beta.1.20.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.
- package/index.d.ts +2335 -886
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* ```json
|
|
16
16
|
* {
|
|
17
17
|
* "module_name": "@minecraft/server",
|
|
18
|
-
* "version": "1.
|
|
18
|
+
* "version": "1.8.0"
|
|
19
19
|
* }
|
|
20
20
|
* ```
|
|
21
21
|
*
|
|
@@ -804,34 +804,29 @@ export enum EquipmentSlot {
|
|
|
804
804
|
}
|
|
805
805
|
|
|
806
806
|
/**
|
|
807
|
-
* @beta
|
|
808
807
|
* Represents the type of fluid for use within a fluid
|
|
809
808
|
* containing block, like a cauldron.
|
|
810
809
|
*/
|
|
811
810
|
export enum FluidType {
|
|
812
811
|
/**
|
|
813
|
-
* @beta
|
|
814
812
|
* @remarks
|
|
815
813
|
* Represents lava as a type of fluid.
|
|
816
814
|
*
|
|
817
815
|
*/
|
|
818
816
|
Lava = 'Lava',
|
|
819
817
|
/**
|
|
820
|
-
* @beta
|
|
821
818
|
* @remarks
|
|
822
819
|
* Represents a potion as a type of fluid.
|
|
823
820
|
*
|
|
824
821
|
*/
|
|
825
822
|
Potion = 'Potion',
|
|
826
823
|
/**
|
|
827
|
-
* @beta
|
|
828
824
|
* @remarks
|
|
829
825
|
* Represents powder snow as a type of fluid.
|
|
830
826
|
*
|
|
831
827
|
*/
|
|
832
828
|
PowderSnow = 'PowderSnow',
|
|
833
829
|
/**
|
|
834
|
-
* @beta
|
|
835
830
|
* @remarks
|
|
836
831
|
* Represents water as a type of fluida.
|
|
837
832
|
*
|
|
@@ -886,6 +881,283 @@ export enum GameMode {
|
|
|
886
881
|
survival = 'survival',
|
|
887
882
|
}
|
|
888
883
|
|
|
884
|
+
/**
|
|
885
|
+
* @beta
|
|
886
|
+
*/
|
|
887
|
+
export enum GameRule {
|
|
888
|
+
/**
|
|
889
|
+
* @beta
|
|
890
|
+
* @remarks
|
|
891
|
+
* Whether command blocks should notify admins when they
|
|
892
|
+
* perform commands.
|
|
893
|
+
*
|
|
894
|
+
*/
|
|
895
|
+
CommandBlockOutput = 'commandBlockOutput',
|
|
896
|
+
/**
|
|
897
|
+
* @beta
|
|
898
|
+
* @remarks
|
|
899
|
+
* Controls whether command blocks can execute commands.
|
|
900
|
+
*
|
|
901
|
+
*/
|
|
902
|
+
CommandBlocksEnabled = 'commandBlocksEnabled',
|
|
903
|
+
/**
|
|
904
|
+
* @beta
|
|
905
|
+
* @remarks
|
|
906
|
+
* Controls whether the day and night cycles progress.
|
|
907
|
+
*
|
|
908
|
+
*/
|
|
909
|
+
DoDayLightCycle = 'doDayLightCycle',
|
|
910
|
+
/**
|
|
911
|
+
* @beta
|
|
912
|
+
* @remarks
|
|
913
|
+
* Controls whether non-mob entities do drops. ie. Item Frame
|
|
914
|
+
*
|
|
915
|
+
*/
|
|
916
|
+
DoEntityDrops = 'doEntityDrops',
|
|
917
|
+
/**
|
|
918
|
+
* @beta
|
|
919
|
+
* @remarks
|
|
920
|
+
* Controls whether fire spreads.
|
|
921
|
+
*
|
|
922
|
+
*/
|
|
923
|
+
DoFireTick = 'doFireTick',
|
|
924
|
+
/**
|
|
925
|
+
* @beta
|
|
926
|
+
* @remarks
|
|
927
|
+
* Controls whether players immediately respawn or are shown
|
|
928
|
+
* the death screen.
|
|
929
|
+
*
|
|
930
|
+
*/
|
|
931
|
+
DoImmediateRespawn = 'doImmediateRespawn',
|
|
932
|
+
/**
|
|
933
|
+
* @beta
|
|
934
|
+
* @remarks
|
|
935
|
+
* Controls whether players deal with the effects of not
|
|
936
|
+
* sleeping (such as Phantom spawning).
|
|
937
|
+
*
|
|
938
|
+
*/
|
|
939
|
+
DoInsomnia = 'doInsomnia',
|
|
940
|
+
/**
|
|
941
|
+
* @beta
|
|
942
|
+
* @remarks
|
|
943
|
+
* Determines whether players should be able to craft only
|
|
944
|
+
* those recipes that they've unlocked first - when
|
|
945
|
+
* dolimitedcrafting is set to true.
|
|
946
|
+
*
|
|
947
|
+
*/
|
|
948
|
+
DoLimitedCrafting = 'doLimitedCrafting',
|
|
949
|
+
/**
|
|
950
|
+
* @beta
|
|
951
|
+
* @remarks
|
|
952
|
+
* Controls whether mobs drop loot.
|
|
953
|
+
*
|
|
954
|
+
*/
|
|
955
|
+
DoMobLoot = 'doMobLoot',
|
|
956
|
+
/**
|
|
957
|
+
* @beta
|
|
958
|
+
* @remarks
|
|
959
|
+
* Controls whether mobs spawn naturally in the world.
|
|
960
|
+
*
|
|
961
|
+
*/
|
|
962
|
+
DoMobSpawning = 'doMobSpawning',
|
|
963
|
+
/**
|
|
964
|
+
* @beta
|
|
965
|
+
* @remarks
|
|
966
|
+
* Controls whether blocks drop items when destroyed.
|
|
967
|
+
*
|
|
968
|
+
*/
|
|
969
|
+
DoTileDrops = 'doTileDrops',
|
|
970
|
+
/**
|
|
971
|
+
* @beta
|
|
972
|
+
* @remarks
|
|
973
|
+
* Controls whether the weather can change naturally.
|
|
974
|
+
*
|
|
975
|
+
*/
|
|
976
|
+
DoWeatherCycle = 'doWeatherCycle',
|
|
977
|
+
/**
|
|
978
|
+
* @beta
|
|
979
|
+
* @remarks
|
|
980
|
+
* Controls whether entities take damage from drowning.
|
|
981
|
+
*
|
|
982
|
+
*/
|
|
983
|
+
DrowningDamage = 'drowningDamage',
|
|
984
|
+
/**
|
|
985
|
+
* @beta
|
|
986
|
+
* @remarks
|
|
987
|
+
* Controls whether entities take damage from falling.
|
|
988
|
+
*
|
|
989
|
+
*/
|
|
990
|
+
FallDamage = 'fallDamage',
|
|
991
|
+
/**
|
|
992
|
+
* @beta
|
|
993
|
+
* @remarks
|
|
994
|
+
* Controls whether entities take damage from fire.
|
|
995
|
+
*
|
|
996
|
+
*/
|
|
997
|
+
FireDamage = 'fireDamage',
|
|
998
|
+
/**
|
|
999
|
+
* @beta
|
|
1000
|
+
* @remarks
|
|
1001
|
+
* Controls whether there is damage from freezing.
|
|
1002
|
+
*
|
|
1003
|
+
*/
|
|
1004
|
+
FreezeDamage = 'freezeDamage',
|
|
1005
|
+
/**
|
|
1006
|
+
* @beta
|
|
1007
|
+
* @remarks
|
|
1008
|
+
* The maximum number of commands that can be executed
|
|
1009
|
+
* simultaneously by the /function command.
|
|
1010
|
+
*
|
|
1011
|
+
*/
|
|
1012
|
+
FunctionCommandLimit = 'functionCommandLimit',
|
|
1013
|
+
/**
|
|
1014
|
+
* @beta
|
|
1015
|
+
* @remarks
|
|
1016
|
+
* Controls whether players keep their inventories when they
|
|
1017
|
+
* die.
|
|
1018
|
+
*
|
|
1019
|
+
*/
|
|
1020
|
+
KeepInventory = 'keepInventory',
|
|
1021
|
+
/**
|
|
1022
|
+
* @beta
|
|
1023
|
+
* @remarks
|
|
1024
|
+
* The maximum number of chained commands that can execute per
|
|
1025
|
+
* tick.
|
|
1026
|
+
*
|
|
1027
|
+
*/
|
|
1028
|
+
MaxCommandChainLength = 'maxCommandChainLength',
|
|
1029
|
+
/**
|
|
1030
|
+
* @beta
|
|
1031
|
+
* @remarks
|
|
1032
|
+
* Controls whether mob griefing can happen in the world.
|
|
1033
|
+
* Example: A Creeper explosion destroying blocks.
|
|
1034
|
+
*
|
|
1035
|
+
*/
|
|
1036
|
+
MobGriefing = 'mobGriefing',
|
|
1037
|
+
/**
|
|
1038
|
+
* @beta
|
|
1039
|
+
* @remarks
|
|
1040
|
+
* Controls whether players can regenerate health.
|
|
1041
|
+
*
|
|
1042
|
+
*/
|
|
1043
|
+
NaturalRegeneration = 'naturalRegeneration',
|
|
1044
|
+
/**
|
|
1045
|
+
* @beta
|
|
1046
|
+
* @remarks
|
|
1047
|
+
* The percentage of players required to be sleeping in order
|
|
1048
|
+
* to advance to the next day.
|
|
1049
|
+
*
|
|
1050
|
+
*/
|
|
1051
|
+
PlayersSleepingPercentage = 'playersSleepingPercentage',
|
|
1052
|
+
/**
|
|
1053
|
+
* @beta
|
|
1054
|
+
* @remarks
|
|
1055
|
+
* Controls whether projectiles (entities with a projectile
|
|
1056
|
+
* component, like Arrows, thrown Tridents or Fireworks) can
|
|
1057
|
+
* destroy certain blocks that support this interaction (such
|
|
1058
|
+
* as Chorus Fruit, Dripstone or Decorated Pots). Restrictions
|
|
1059
|
+
* on which projectiles can destroy certain blocks apply.
|
|
1060
|
+
*
|
|
1061
|
+
*/
|
|
1062
|
+
ProjectilesCanBreakBlocks = 'projectilesCanBreakBlocks',
|
|
1063
|
+
/**
|
|
1064
|
+
* @beta
|
|
1065
|
+
* @remarks
|
|
1066
|
+
* Controls whether players can damage each other.
|
|
1067
|
+
*
|
|
1068
|
+
*/
|
|
1069
|
+
Pvp = 'pvp',
|
|
1070
|
+
/**
|
|
1071
|
+
* @beta
|
|
1072
|
+
* @remarks
|
|
1073
|
+
* Controls how frequently random ticks occur. A value of 0 or
|
|
1074
|
+
* less will disable random ticks. The default value is 1.
|
|
1075
|
+
*
|
|
1076
|
+
*/
|
|
1077
|
+
RandomTickSpeed = 'randomTickSpeed',
|
|
1078
|
+
/**
|
|
1079
|
+
* @beta
|
|
1080
|
+
* @remarks
|
|
1081
|
+
* Controls whether built-in (vanilla) recipes automatically
|
|
1082
|
+
* unlock as the player progresses through the game (one
|
|
1083
|
+
* alternative to this is to use the /recipe command based on
|
|
1084
|
+
* custom gameplay logic.)
|
|
1085
|
+
*
|
|
1086
|
+
*/
|
|
1087
|
+
RecipesUnlock = 'recipesUnlock',
|
|
1088
|
+
/**
|
|
1089
|
+
* @beta
|
|
1090
|
+
* @remarks
|
|
1091
|
+
* Controls whether respawn blocks (e.g. Bed, Respawn Anchor)
|
|
1092
|
+
* explode in other dimensions.
|
|
1093
|
+
*
|
|
1094
|
+
*/
|
|
1095
|
+
RespawnBlocksExplode = 'respawnBlocksExplode',
|
|
1096
|
+
/**
|
|
1097
|
+
* @beta
|
|
1098
|
+
* @remarks
|
|
1099
|
+
* Controls whether command output is displayed to players.
|
|
1100
|
+
* Also controls whether Command Block output is stored by
|
|
1101
|
+
* default.
|
|
1102
|
+
*
|
|
1103
|
+
*/
|
|
1104
|
+
SendCommandFeedback = 'sendCommandFeedback',
|
|
1105
|
+
/**
|
|
1106
|
+
* @beta
|
|
1107
|
+
* @remarks
|
|
1108
|
+
* Controls whether Border Block effects are shown.
|
|
1109
|
+
*
|
|
1110
|
+
*/
|
|
1111
|
+
ShowBorderEffect = 'showBorderEffect',
|
|
1112
|
+
/**
|
|
1113
|
+
* @beta
|
|
1114
|
+
* @remarks
|
|
1115
|
+
* Controls whether player coordinates are displayed.
|
|
1116
|
+
*
|
|
1117
|
+
*/
|
|
1118
|
+
ShowCoordinates = 'showCoordinates',
|
|
1119
|
+
/**
|
|
1120
|
+
* @beta
|
|
1121
|
+
* @remarks
|
|
1122
|
+
* Controls whether death messages are displayed in chat.
|
|
1123
|
+
*
|
|
1124
|
+
*/
|
|
1125
|
+
ShowDeathMessages = 'showDeathMessages',
|
|
1126
|
+
/**
|
|
1127
|
+
* @beta
|
|
1128
|
+
* @remarks
|
|
1129
|
+
* Controls whether standard player notifications for recipes
|
|
1130
|
+
* will show. When set to false, 'player unlocked recipes' are
|
|
1131
|
+
* no longer sent as player notifications.
|
|
1132
|
+
*
|
|
1133
|
+
*/
|
|
1134
|
+
ShowRecipeMessages = 'showRecipeMessages',
|
|
1135
|
+
/**
|
|
1136
|
+
* @beta
|
|
1137
|
+
* @remarks
|
|
1138
|
+
* Controls whether item tags are shown. E.g. 'Can Place On',
|
|
1139
|
+
* 'Can Destroy', item lock icons, etc.
|
|
1140
|
+
*
|
|
1141
|
+
*/
|
|
1142
|
+
ShowTags = 'showTags',
|
|
1143
|
+
/**
|
|
1144
|
+
* @beta
|
|
1145
|
+
* @remarks
|
|
1146
|
+
* The block radius from world spawn that a player is allowed
|
|
1147
|
+
* to spawn in. Does not affect Adventure mode. The default
|
|
1148
|
+
* value is 10 blocks.
|
|
1149
|
+
*
|
|
1150
|
+
*/
|
|
1151
|
+
SpawnRadius = 'spawnRadius',
|
|
1152
|
+
/**
|
|
1153
|
+
* @beta
|
|
1154
|
+
* @remarks
|
|
1155
|
+
* Affects whether TNT blocks can be lit.
|
|
1156
|
+
*
|
|
1157
|
+
*/
|
|
1158
|
+
TntExplodes = 'tntExplodes',
|
|
1159
|
+
}
|
|
1160
|
+
|
|
889
1161
|
/**
|
|
890
1162
|
* @beta
|
|
891
1163
|
*/
|
|
@@ -1136,6 +1408,43 @@ export enum SignSide {
|
|
|
1136
1408
|
Front = 'Front',
|
|
1137
1409
|
}
|
|
1138
1410
|
|
|
1411
|
+
/**
|
|
1412
|
+
* @beta
|
|
1413
|
+
*/
|
|
1414
|
+
export enum StructureAnimationMode {
|
|
1415
|
+
Blocks = 'Blocks',
|
|
1416
|
+
Layers = 'Layers',
|
|
1417
|
+
None = 'None',
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
/**
|
|
1421
|
+
* @beta
|
|
1422
|
+
*/
|
|
1423
|
+
export enum StructureMirrorAxis {
|
|
1424
|
+
None = 'None',
|
|
1425
|
+
X = 'X',
|
|
1426
|
+
XZ = 'XZ',
|
|
1427
|
+
Z = 'Z',
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
/**
|
|
1431
|
+
* @beta
|
|
1432
|
+
*/
|
|
1433
|
+
export enum StructureRotation {
|
|
1434
|
+
None = 'None',
|
|
1435
|
+
Rotate180 = 'Rotate180',
|
|
1436
|
+
Rotate270 = 'Rotate270',
|
|
1437
|
+
Rotate90 = 'Rotate90',
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
/**
|
|
1441
|
+
* @beta
|
|
1442
|
+
*/
|
|
1443
|
+
export enum StructureSaveMode {
|
|
1444
|
+
Memory = 'Memory',
|
|
1445
|
+
World = 'World',
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1139
1448
|
/**
|
|
1140
1449
|
* Provides numeric values for common periods in the Minecraft
|
|
1141
1450
|
* day.
|
|
@@ -1407,18 +1716,42 @@ export type ItemComponentTypeMap = {
|
|
|
1407
1716
|
|
|
1408
1717
|
/**
|
|
1409
1718
|
* @beta
|
|
1719
|
+
* Describes a type of biome.
|
|
1410
1720
|
*/
|
|
1411
1721
|
export class BiomeType {
|
|
1412
1722
|
private constructor();
|
|
1723
|
+
/**
|
|
1724
|
+
* @remarks
|
|
1725
|
+
* Identifier of the biome type.
|
|
1726
|
+
*
|
|
1727
|
+
*/
|
|
1413
1728
|
readonly id: string;
|
|
1414
1729
|
}
|
|
1415
1730
|
|
|
1416
1731
|
/**
|
|
1417
1732
|
* @beta
|
|
1733
|
+
* Supports a catalog of available biome types registered
|
|
1734
|
+
* within Minecraft.
|
|
1418
1735
|
*/
|
|
1419
1736
|
export class BiomeTypes {
|
|
1420
1737
|
private constructor();
|
|
1738
|
+
/**
|
|
1739
|
+
* @remarks
|
|
1740
|
+
* Returns a specific biome type.
|
|
1741
|
+
*
|
|
1742
|
+
* @param typeName
|
|
1743
|
+
* Identifier of the biome. Generally, namespaced identifiers
|
|
1744
|
+
* (e.g., minecraft:frozen_peaks) should be used.
|
|
1745
|
+
* @returns
|
|
1746
|
+
* If the biome exists, a BiomeType object is returned. If not,
|
|
1747
|
+
* undefined is returned.
|
|
1748
|
+
*/
|
|
1421
1749
|
static get(typeName: string): BiomeType | undefined;
|
|
1750
|
+
/**
|
|
1751
|
+
* @remarks
|
|
1752
|
+
* Returns all registered biome types within Minecraft
|
|
1753
|
+
*
|
|
1754
|
+
*/
|
|
1422
1755
|
static getAll(): BiomeType[];
|
|
1423
1756
|
}
|
|
1424
1757
|
|
|
@@ -1688,7 +2021,6 @@ export class Block {
|
|
|
1688
2021
|
*/
|
|
1689
2022
|
getRedstonePower(): number | undefined;
|
|
1690
2023
|
/**
|
|
1691
|
-
* @beta
|
|
1692
2024
|
* @remarks
|
|
1693
2025
|
* Returns a set of tags for a block.
|
|
1694
2026
|
*
|
|
@@ -1702,7 +2034,6 @@ export class Block {
|
|
|
1702
2034
|
*/
|
|
1703
2035
|
getTags(): string[];
|
|
1704
2036
|
/**
|
|
1705
|
-
* @beta
|
|
1706
2037
|
* @remarks
|
|
1707
2038
|
* Checks to see if the permutation of this block has a
|
|
1708
2039
|
* specific tag.
|
|
@@ -1742,6 +2073,15 @@ export class Block {
|
|
|
1742
2073
|
isValid(): boolean;
|
|
1743
2074
|
/**
|
|
1744
2075
|
* @beta
|
|
2076
|
+
* @remarks
|
|
2077
|
+
* Tests whether this block matches a specific criteria.
|
|
2078
|
+
*
|
|
2079
|
+
* @param blockName
|
|
2080
|
+
* Block type identifier to match this API against.
|
|
2081
|
+
* @param states
|
|
2082
|
+
* Optional set of block states to test this block against.
|
|
2083
|
+
* @returns
|
|
2084
|
+
* Returns true if the block matches the specified criteria.
|
|
1745
2085
|
* @throws This function can throw errors.
|
|
1746
2086
|
*
|
|
1747
2087
|
* {@link Error}
|
|
@@ -1822,8 +2162,13 @@ export class Block {
|
|
|
1822
2162
|
/**
|
|
1823
2163
|
* @beta
|
|
1824
2164
|
* @remarks
|
|
2165
|
+
* Sets whether this block has a water logged state - for
|
|
2166
|
+
* example, whether stairs are submerged within water.
|
|
2167
|
+
*
|
|
1825
2168
|
* This function can't be called in read-only mode.
|
|
1826
2169
|
*
|
|
2170
|
+
* @param isWaterlogged
|
|
2171
|
+
* true if the block should have water within it.
|
|
1827
2172
|
* @throws This function can throw errors.
|
|
1828
2173
|
*
|
|
1829
2174
|
* {@link Error}
|
|
@@ -2011,6 +2356,24 @@ export class BlockExplodeAfterEventSignal {
|
|
|
2011
2356
|
/**
|
|
2012
2357
|
* Represents the inventory of a block in the world. Used with
|
|
2013
2358
|
* blocks like chests.
|
|
2359
|
+
* @example place_items_in_chest.js
|
|
2360
|
+
* ```typescript
|
|
2361
|
+
* import { world, MinecraftBlockTypes, Items, ItemStack } from "@minecraft/server";
|
|
2362
|
+
*
|
|
2363
|
+
* // Fetch block
|
|
2364
|
+
* const block = world.getDimension("overworld").getBlock({ x: 1, y: 2, z: 3 });
|
|
2365
|
+
*
|
|
2366
|
+
* // Make it a chest
|
|
2367
|
+
* block.setType(MinecraftBlockTypes.chest);
|
|
2368
|
+
*
|
|
2369
|
+
* // Get the inventory
|
|
2370
|
+
* const inventoryComponent = block.getComponent("inventory");
|
|
2371
|
+
* const inventoryContainer = inventoryComponent.container;
|
|
2372
|
+
*
|
|
2373
|
+
* // Set slot 0 to a stack of 10 apples
|
|
2374
|
+
* inventoryContainer.setItem(0, new ItemStack(Items.apple, 10, 0));
|
|
2375
|
+
*
|
|
2376
|
+
* ```
|
|
2014
2377
|
*/
|
|
2015
2378
|
// @ts-ignore Class inheritance allowed for native defined classes
|
|
2016
2379
|
export class BlockInventoryComponent extends BlockComponent {
|
|
@@ -2106,6 +2469,31 @@ export class BlockLocationIterator implements Iterable<Vector3> {
|
|
|
2106
2469
|
* properties (also sometimes called block state) which
|
|
2107
2470
|
* describe a block (but does not belong to a specific {@link
|
|
2108
2471
|
* Block}).
|
|
2472
|
+
* @example createTranslatedSign.ts
|
|
2473
|
+
* ```typescript
|
|
2474
|
+
* // A function the creates a sign at the specified location with the specified text
|
|
2475
|
+
* import { DimensionLocation, BlockPermutation, BlockComponentTypes } from '@minecraft/server';
|
|
2476
|
+
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
|
|
2477
|
+
*
|
|
2478
|
+
* function createSignAt(location: DimensionLocation) {
|
|
2479
|
+
* const signBlock = location.dimension.getBlock(location);
|
|
2480
|
+
*
|
|
2481
|
+
* if (!signBlock) {
|
|
2482
|
+
* console.warn('Could not find a block at specified location.');
|
|
2483
|
+
* return;
|
|
2484
|
+
* }
|
|
2485
|
+
*
|
|
2486
|
+
* const signPerm = BlockPermutation.resolve(MinecraftBlockTypes.StandingSign, { ground_sign_direction: 8 });
|
|
2487
|
+
* signBlock.setPermutation(signPerm); // Update block to be a sign
|
|
2488
|
+
*
|
|
2489
|
+
* // Update the sign block's text
|
|
2490
|
+
* // with "Steve's Head"
|
|
2491
|
+
* const signComponent = signBlock.getComponent(BlockComponentTypes.Sign);
|
|
2492
|
+
* if (signComponent) {
|
|
2493
|
+
* signComponent.setText({ translate: 'item.skull.player.name', with: ['Steve'] });
|
|
2494
|
+
* }
|
|
2495
|
+
* }
|
|
2496
|
+
* ```
|
|
2109
2497
|
*/
|
|
2110
2498
|
export class BlockPermutation {
|
|
2111
2499
|
private constructor();
|
|
@@ -2149,7 +2537,6 @@ export class BlockPermutation {
|
|
|
2149
2537
|
*/
|
|
2150
2538
|
getItemStack(amount?: number): ItemStack | undefined;
|
|
2151
2539
|
/**
|
|
2152
|
-
* @beta
|
|
2153
2540
|
* @remarks
|
|
2154
2541
|
* Gets a state for the permutation.
|
|
2155
2542
|
*
|
|
@@ -2199,7 +2586,6 @@ export class BlockPermutation {
|
|
|
2199
2586
|
*/
|
|
2200
2587
|
matches(blockName: string, states?: Record<string, boolean | number | string>): boolean;
|
|
2201
2588
|
/**
|
|
2202
|
-
* @beta
|
|
2203
2589
|
* @remarks
|
|
2204
2590
|
* Returns a derived BlockPermutation with a specific property
|
|
2205
2591
|
* set.
|
|
@@ -2222,43 +2608,43 @@ export class BlockPermutation {
|
|
|
2222
2608
|
* @throws This function can throw errors.
|
|
2223
2609
|
* @example addBlockColorCube.ts
|
|
2224
2610
|
* ```typescript
|
|
2225
|
-
*
|
|
2226
|
-
*
|
|
2227
|
-
*
|
|
2228
|
-
*
|
|
2229
|
-
*
|
|
2230
|
-
*
|
|
2231
|
-
*
|
|
2232
|
-
*
|
|
2233
|
-
*
|
|
2234
|
-
*
|
|
2235
|
-
*
|
|
2236
|
-
*
|
|
2237
|
-
*
|
|
2238
|
-
*
|
|
2239
|
-
*
|
|
2240
|
-
*
|
|
2241
|
-
*
|
|
2242
|
-
*
|
|
2243
|
-
*
|
|
2244
|
-
*
|
|
2245
|
-
*
|
|
2246
|
-
*
|
|
2247
|
-
*
|
|
2248
|
-
*
|
|
2249
|
-
*
|
|
2250
|
-
*
|
|
2251
|
-
*
|
|
2252
|
-
*
|
|
2253
|
-
*
|
|
2254
|
-
*
|
|
2255
|
-
*
|
|
2256
|
-
*
|
|
2257
|
-
*
|
|
2258
|
-
*
|
|
2259
|
-
*
|
|
2611
|
+
* import { DimensionLocation, BlockPermutation } from '@minecraft/server';
|
|
2612
|
+
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
|
|
2613
|
+
*
|
|
2614
|
+
* const allWoolBlocks: string[] = [
|
|
2615
|
+
* MinecraftBlockTypes.WhiteWool,
|
|
2616
|
+
* MinecraftBlockTypes.OrangeWool,
|
|
2617
|
+
* MinecraftBlockTypes.MagentaWool,
|
|
2618
|
+
* MinecraftBlockTypes.LightBlueWool,
|
|
2619
|
+
* MinecraftBlockTypes.YellowWool,
|
|
2620
|
+
* MinecraftBlockTypes.LimeWool,
|
|
2621
|
+
* MinecraftBlockTypes.PinkWool,
|
|
2622
|
+
* MinecraftBlockTypes.GrayWool,
|
|
2623
|
+
* MinecraftBlockTypes.LightGrayWool,
|
|
2624
|
+
* MinecraftBlockTypes.CyanWool,
|
|
2625
|
+
* MinecraftBlockTypes.PurpleWool,
|
|
2626
|
+
* MinecraftBlockTypes.BlueWool,
|
|
2627
|
+
* MinecraftBlockTypes.BrownWool,
|
|
2628
|
+
* MinecraftBlockTypes.GreenWool,
|
|
2629
|
+
* MinecraftBlockTypes.RedWool,
|
|
2630
|
+
* MinecraftBlockTypes.BlackWool,
|
|
2631
|
+
* ];
|
|
2632
|
+
*
|
|
2633
|
+
* const cubeDim = 7;
|
|
2634
|
+
*
|
|
2635
|
+
* function placeRainbowCube(location: DimensionLocation) {
|
|
2636
|
+
* let colorIndex = 0;
|
|
2637
|
+
* for (let x = 0; x <= cubeDim; x++) {
|
|
2638
|
+
* for (let y = 0; y <= cubeDim; y++) {
|
|
2639
|
+
* for (let z = 0; z <= cubeDim; z++) {
|
|
2640
|
+
* colorIndex++;
|
|
2641
|
+
* location.dimension
|
|
2642
|
+
* .getBlock({ x: location.x + x, y: location.y + y, z: location.z + z })
|
|
2643
|
+
* ?.setPermutation(BlockPermutation.resolve(allWoolBlocks[colorIndex % allWoolBlocks.length]));
|
|
2644
|
+
* }
|
|
2645
|
+
* }
|
|
2260
2646
|
* }
|
|
2261
|
-
*
|
|
2647
|
+
* }
|
|
2262
2648
|
* ```
|
|
2263
2649
|
*/
|
|
2264
2650
|
static resolve(blockName: string, states?: Record<string, boolean | number | string>): BlockPermutation;
|
|
@@ -2366,6 +2752,103 @@ export class BlockRecordPlayerComponent extends BlockComponent {
|
|
|
2366
2752
|
/**
|
|
2367
2753
|
* @beta
|
|
2368
2754
|
* Represents a block that can display text on it.
|
|
2755
|
+
* @example addTwoSidedSign.ts
|
|
2756
|
+
* ```typescript
|
|
2757
|
+
* // A function the creates a sign at the specified location with text on both sides and dye colors
|
|
2758
|
+
* import {
|
|
2759
|
+
* DimensionLocation,
|
|
2760
|
+
* BlockPermutation,
|
|
2761
|
+
* BlockSignComponent,
|
|
2762
|
+
* BlockComponentTypes,
|
|
2763
|
+
* DyeColor,
|
|
2764
|
+
* SignSide,
|
|
2765
|
+
* } from '@minecraft/server';
|
|
2766
|
+
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
|
|
2767
|
+
*
|
|
2768
|
+
* function createSignAt(location: DimensionLocation) {
|
|
2769
|
+
* const block = location.dimension.getBlock(location);
|
|
2770
|
+
* if (!block) {
|
|
2771
|
+
* console.warn('Could not find a block at specified location.');
|
|
2772
|
+
* return;
|
|
2773
|
+
* }
|
|
2774
|
+
* const signPerm = BlockPermutation.resolve(MinecraftBlockTypes.StandingSign, {
|
|
2775
|
+
* ground_sign_direction: 8,
|
|
2776
|
+
* });
|
|
2777
|
+
* block.setPermutation(signPerm);
|
|
2778
|
+
* const sign = block.getComponent(BlockComponentTypes.Sign);
|
|
2779
|
+
*
|
|
2780
|
+
* if (sign !== undefined) {
|
|
2781
|
+
* sign.setText(`Party Sign!\nThis is green on the front.`);
|
|
2782
|
+
* sign.setText(`Party Sign!\nThis is red on the back.`, SignSide.Back);
|
|
2783
|
+
* sign.setTextDyeColor(DyeColor.Green);
|
|
2784
|
+
* sign.setTextDyeColor(DyeColor.Red, SignSide.Back);
|
|
2785
|
+
*
|
|
2786
|
+
* // players cannot edit sign!
|
|
2787
|
+
* sign.setWaxed(true);
|
|
2788
|
+
* } else {
|
|
2789
|
+
* console.warn('Could not find a sign component on the block.');
|
|
2790
|
+
* }
|
|
2791
|
+
* }
|
|
2792
|
+
* ```
|
|
2793
|
+
* @example setSignText.ts
|
|
2794
|
+
* ```typescript
|
|
2795
|
+
* import {
|
|
2796
|
+
* BlockComponentTypes,
|
|
2797
|
+
* DimensionLocation,
|
|
2798
|
+
* RawMessage,
|
|
2799
|
+
* RawText,
|
|
2800
|
+
* } from '@minecraft/server';
|
|
2801
|
+
*
|
|
2802
|
+
* // Function which updates a sign blocks text to raw text
|
|
2803
|
+
* function updateSignText(signLocation: DimensionLocation) {
|
|
2804
|
+
* const block = signLocation.dimension.getBlock(signLocation);
|
|
2805
|
+
* if (!block) {
|
|
2806
|
+
* console.warn('Could not find a block at specified location.');
|
|
2807
|
+
* return;
|
|
2808
|
+
* }
|
|
2809
|
+
*
|
|
2810
|
+
* const sign = block.getComponent(BlockComponentTypes.Sign);
|
|
2811
|
+
* if (sign) {
|
|
2812
|
+
* // RawMessage
|
|
2813
|
+
* const helloWorldMessage: RawMessage = { text: 'Hello World' };
|
|
2814
|
+
* sign.setText(helloWorldMessage);
|
|
2815
|
+
*
|
|
2816
|
+
* // RawText
|
|
2817
|
+
* const helloWorldText: RawText = { rawtext: [{ text: 'Hello World' }] };
|
|
2818
|
+
* sign.setText(helloWorldText);
|
|
2819
|
+
*
|
|
2820
|
+
* // Regular string
|
|
2821
|
+
* sign.setText('Hello World');
|
|
2822
|
+
* } else {
|
|
2823
|
+
* console.warn('Could not find a sign component on the block.');
|
|
2824
|
+
* }
|
|
2825
|
+
* }
|
|
2826
|
+
* ```
|
|
2827
|
+
* @example createTranslatedSign.ts
|
|
2828
|
+
* ```typescript
|
|
2829
|
+
* // A function the creates a sign at the specified location with the specified text
|
|
2830
|
+
* import { DimensionLocation, BlockPermutation, BlockComponentTypes } from '@minecraft/server';
|
|
2831
|
+
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
|
|
2832
|
+
*
|
|
2833
|
+
* function createSignAt(location: DimensionLocation) {
|
|
2834
|
+
* const signBlock = location.dimension.getBlock(location);
|
|
2835
|
+
*
|
|
2836
|
+
* if (!signBlock) {
|
|
2837
|
+
* console.warn('Could not find a block at specified location.');
|
|
2838
|
+
* return;
|
|
2839
|
+
* }
|
|
2840
|
+
*
|
|
2841
|
+
* const signPerm = BlockPermutation.resolve(MinecraftBlockTypes.StandingSign, { ground_sign_direction: 8 });
|
|
2842
|
+
* signBlock.setPermutation(signPerm); // Update block to be a sign
|
|
2843
|
+
*
|
|
2844
|
+
* // Update the sign block's text
|
|
2845
|
+
* // with "Steve's Head"
|
|
2846
|
+
* const signComponent = signBlock.getComponent(BlockComponentTypes.Sign);
|
|
2847
|
+
* if (signComponent) {
|
|
2848
|
+
* signComponent.setText({ translate: 'item.skull.player.name', with: ['Steve'] });
|
|
2849
|
+
* }
|
|
2850
|
+
* }
|
|
2851
|
+
* ```
|
|
2369
2852
|
*/
|
|
2370
2853
|
// @ts-ignore Class inheritance allowed for native defined classes
|
|
2371
2854
|
export class BlockSignComponent extends BlockComponent {
|
|
@@ -2435,50 +2918,39 @@ export class BlockSignComponent extends BlockComponent {
|
|
|
2435
2918
|
* @throws
|
|
2436
2919
|
* Throws if the provided message is greater than 512
|
|
2437
2920
|
* characters in length.
|
|
2438
|
-
* @example
|
|
2921
|
+
* @example setSignText.ts
|
|
2439
2922
|
* ```typescript
|
|
2440
|
-
*
|
|
2441
|
-
*
|
|
2442
|
-
*
|
|
2443
|
-
*
|
|
2444
|
-
*
|
|
2445
|
-
* }
|
|
2446
|
-
*
|
|
2447
|
-
*
|
|
2448
|
-
*
|
|
2923
|
+
* import {
|
|
2924
|
+
* BlockComponentTypes,
|
|
2925
|
+
* DimensionLocation,
|
|
2926
|
+
* RawMessage,
|
|
2927
|
+
* RawText,
|
|
2928
|
+
* } from '@minecraft/server';
|
|
2929
|
+
*
|
|
2930
|
+
* // Function which updates a sign blocks text to raw text
|
|
2931
|
+
* function updateSignText(signLocation: DimensionLocation) {
|
|
2932
|
+
* const block = signLocation.dimension.getBlock(signLocation);
|
|
2933
|
+
* if (!block) {
|
|
2934
|
+
* console.warn('Could not find a block at specified location.');
|
|
2935
|
+
* return;
|
|
2936
|
+
* }
|
|
2449
2937
|
*
|
|
2450
|
-
*
|
|
2451
|
-
*
|
|
2452
|
-
*
|
|
2453
|
-
*
|
|
2454
|
-
*
|
|
2455
|
-
* ```typescript
|
|
2456
|
-
* const signLocation: Vector3 = { x: 0, y: -60, z: 0 }; // Replace with your sign's coordinates
|
|
2457
|
-
* const block = world.getDimension("overworld").getBlock(signLocation);
|
|
2458
|
-
* if (!block) {
|
|
2459
|
-
* world.sendMessage("Could not find a block at specified location.");
|
|
2460
|
-
* return;
|
|
2461
|
-
* }
|
|
2462
|
-
* const sign = block.getComponent("minecraft:sign") as BlockSignComponent;
|
|
2463
|
-
* const helloWorldText: RawText = { rawtext: [{ text: "Hello World" }] };
|
|
2464
|
-
* sign.setText(helloWorldText);
|
|
2938
|
+
* const sign = block.getComponent(BlockComponentTypes.Sign);
|
|
2939
|
+
* if (sign) {
|
|
2940
|
+
* // RawMessage
|
|
2941
|
+
* const helloWorldMessage: RawMessage = { text: 'Hello World' };
|
|
2942
|
+
* sign.setText(helloWorldMessage);
|
|
2465
2943
|
*
|
|
2466
|
-
*
|
|
2467
|
-
*
|
|
2468
|
-
*
|
|
2469
|
-
*
|
|
2470
|
-
*
|
|
2471
|
-
*
|
|
2472
|
-
*
|
|
2473
|
-
*
|
|
2474
|
-
*
|
|
2475
|
-
* world.sendMessage("Could not find a block at specified location.");
|
|
2476
|
-
* return;
|
|
2944
|
+
* // RawText
|
|
2945
|
+
* const helloWorldText: RawText = { rawtext: [{ text: 'Hello World' }] };
|
|
2946
|
+
* sign.setText(helloWorldText);
|
|
2947
|
+
*
|
|
2948
|
+
* // Regular string
|
|
2949
|
+
* sign.setText('Hello World');
|
|
2950
|
+
* } else {
|
|
2951
|
+
* console.warn('Could not find a sign component on the block.');
|
|
2952
|
+
* }
|
|
2477
2953
|
* }
|
|
2478
|
-
* const sign = block.getComponent("minecraft:sign") as BlockSignComponent;
|
|
2479
|
-
* // Set sign to say 'Hello'
|
|
2480
|
-
* sign.setText("Hello World");
|
|
2481
|
-
* world.sendMessage(sign.getText() ?? "undefined"); // 'Hello World'
|
|
2482
2954
|
* ```
|
|
2483
2955
|
*/
|
|
2484
2956
|
setText(message: RawMessage | RawText | string, side?: SignSide): void;
|
|
@@ -2566,7 +3038,6 @@ export class BlockStateType {
|
|
|
2566
3038
|
}
|
|
2567
3039
|
|
|
2568
3040
|
/**
|
|
2569
|
-
* @beta
|
|
2570
3041
|
* The type (or template) of a block. Does not contain
|
|
2571
3042
|
* permutation data (state) other than the type of block it
|
|
2572
3043
|
* represents. This type was introduced as of version
|
|
@@ -2671,18 +3142,40 @@ export class BlockVolume extends BlockVolumeBase {
|
|
|
2671
3142
|
constructor(from: Vector3, to: Vector3);
|
|
2672
3143
|
/**
|
|
2673
3144
|
* @remarks
|
|
3145
|
+
* Check to see if the given location is directly adjacent to
|
|
3146
|
+
* the outer surface of a BlockVolume.
|
|
3147
|
+
*
|
|
3148
|
+
*
|
|
2674
3149
|
* This function can't be called in read-only mode.
|
|
2675
3150
|
*
|
|
3151
|
+
* @param pos
|
|
3152
|
+
* The world block location to test
|
|
3153
|
+
* @returns
|
|
3154
|
+
* If the location is either inside or more than 0 blocks away,
|
|
3155
|
+
* the function will return false.
|
|
3156
|
+
* If the location is directly contacting the outer surface of
|
|
3157
|
+
* the BlockVolume, the function will return true.
|
|
2676
3158
|
*/
|
|
2677
3159
|
doesLocationTouchFaces(pos: Vector3): boolean;
|
|
2678
3160
|
/**
|
|
2679
3161
|
* @remarks
|
|
3162
|
+
* Check to see if a two block volumes are directly adjacent
|
|
3163
|
+
* and two faces touch.
|
|
3164
|
+
*
|
|
2680
3165
|
* This function can't be called in read-only mode.
|
|
2681
3166
|
*
|
|
3167
|
+
* @param other
|
|
3168
|
+
* The volume to test
|
|
3169
|
+
* @returns
|
|
3170
|
+
* If the outer faces of both block volumes touch and are
|
|
3171
|
+
* directly adjacent at any point, return true.
|
|
2682
3172
|
*/
|
|
2683
3173
|
doesVolumeTouchFaces(other: BlockVolume): boolean;
|
|
2684
3174
|
/**
|
|
2685
3175
|
* @remarks
|
|
3176
|
+
* Return an enumeration which represents the intersection
|
|
3177
|
+
* between two BlockVolume objects
|
|
3178
|
+
*
|
|
2686
3179
|
* This function can't be called in read-only mode.
|
|
2687
3180
|
*
|
|
2688
3181
|
*/
|
|
@@ -2691,55 +3184,80 @@ export class BlockVolume extends BlockVolumeBase {
|
|
|
2691
3184
|
|
|
2692
3185
|
/**
|
|
2693
3186
|
* @beta
|
|
3187
|
+
* Base type for BlockVolumes.
|
|
2694
3188
|
*/
|
|
2695
3189
|
export class BlockVolumeBase {
|
|
2696
3190
|
private constructor();
|
|
2697
3191
|
/**
|
|
2698
3192
|
* @remarks
|
|
3193
|
+
* Fetch a {@link BlockLocationIterator} that represents all of
|
|
3194
|
+
* the block world locations within the specified volume
|
|
3195
|
+
*
|
|
2699
3196
|
* This function can't be called in read-only mode.
|
|
2700
3197
|
*
|
|
2701
3198
|
*/
|
|
2702
3199
|
getBlockLocationIterator(): BlockLocationIterator;
|
|
2703
3200
|
/**
|
|
2704
3201
|
* @remarks
|
|
3202
|
+
* Return a {@link BoundingBox} object which represents the
|
|
3203
|
+
* validated min and max coordinates of the volume
|
|
3204
|
+
*
|
|
2705
3205
|
* This function can't be called in read-only mode.
|
|
2706
3206
|
*
|
|
2707
3207
|
*/
|
|
2708
3208
|
getBoundingBox(): BoundingBox;
|
|
2709
3209
|
/**
|
|
2710
3210
|
* @remarks
|
|
3211
|
+
* Return the capacity (volume) of the BlockVolume (W*D*H)
|
|
3212
|
+
*
|
|
2711
3213
|
* This function can't be called in read-only mode.
|
|
2712
3214
|
*
|
|
2713
3215
|
*/
|
|
2714
3216
|
getCapacity(): number;
|
|
2715
3217
|
/**
|
|
2716
3218
|
* @remarks
|
|
3219
|
+
* Get the largest corner position of the volume (guaranteed to
|
|
3220
|
+
* be >= min)
|
|
3221
|
+
*
|
|
2717
3222
|
* This function can't be called in read-only mode.
|
|
2718
3223
|
*
|
|
2719
3224
|
*/
|
|
2720
3225
|
getMax(): Vector3;
|
|
2721
3226
|
/**
|
|
2722
3227
|
* @remarks
|
|
3228
|
+
* Get the smallest corner position of the volume (guaranteed
|
|
3229
|
+
* to be <= max)
|
|
3230
|
+
*
|
|
2723
3231
|
* This function can't be called in read-only mode.
|
|
2724
3232
|
*
|
|
2725
3233
|
*/
|
|
2726
3234
|
getMin(): Vector3;
|
|
2727
3235
|
/**
|
|
2728
3236
|
* @remarks
|
|
3237
|
+
* Get a {@link Vector3} object where each component represents
|
|
3238
|
+
* the number of blocks along that axis
|
|
3239
|
+
*
|
|
2729
3240
|
* This function can't be called in read-only mode.
|
|
2730
3241
|
*
|
|
2731
3242
|
*/
|
|
2732
3243
|
getSpan(): Vector3;
|
|
2733
3244
|
/**
|
|
2734
3245
|
* @remarks
|
|
3246
|
+
* Check to see if a given world block location is inside a
|
|
3247
|
+
* BlockVolume
|
|
3248
|
+
*
|
|
2735
3249
|
* This function can't be called in read-only mode.
|
|
2736
3250
|
*
|
|
2737
3251
|
*/
|
|
2738
3252
|
isInside(pos: Vector3): boolean;
|
|
2739
3253
|
/**
|
|
2740
3254
|
* @remarks
|
|
3255
|
+
* Move a BlockVolume by a specified amount
|
|
3256
|
+
*
|
|
2741
3257
|
* This function can't be called in read-only mode.
|
|
2742
3258
|
*
|
|
3259
|
+
* @param delta
|
|
3260
|
+
* Amount of blocks to move by
|
|
2743
3261
|
*/
|
|
2744
3262
|
translate(delta: Vector3): void;
|
|
2745
3263
|
}
|
|
@@ -2914,6 +3432,18 @@ export class BoundingBoxUtils {
|
|
|
2914
3432
|
|
|
2915
3433
|
/**
|
|
2916
3434
|
* Contains information related to changes to a button push.
|
|
3435
|
+
* @example buttonPushEvent.ts
|
|
3436
|
+
* ```typescript
|
|
3437
|
+
* import { world, ButtonPushAfterEvent, system } from '@minecraft/server';
|
|
3438
|
+
*
|
|
3439
|
+
* world.afterEvents.buttonPush.subscribe((buttonPushEvent: ButtonPushAfterEvent) => {
|
|
3440
|
+
* const eventLoc = buttonPushEvent.block.location;
|
|
3441
|
+
*
|
|
3442
|
+
* world.sendMessage(
|
|
3443
|
+
* `Button push event at tick ${system.currentTick} Power:${buttonPushEvent.block.getRedstonePower()}`,
|
|
3444
|
+
* );
|
|
3445
|
+
* });
|
|
3446
|
+
* ```
|
|
2917
3447
|
*/
|
|
2918
3448
|
// @ts-ignore Class inheritance allowed for native defined classes
|
|
2919
3449
|
export class ButtonPushAfterEvent extends BlockEvent {
|
|
@@ -2929,6 +3459,18 @@ export class ButtonPushAfterEvent extends BlockEvent {
|
|
|
2929
3459
|
/**
|
|
2930
3460
|
* Manages callbacks that are connected to when a button is
|
|
2931
3461
|
* pushed.
|
|
3462
|
+
* @example buttonPushEvent.ts
|
|
3463
|
+
* ```typescript
|
|
3464
|
+
* import { world, ButtonPushAfterEvent, system } from '@minecraft/server';
|
|
3465
|
+
*
|
|
3466
|
+
* world.afterEvents.buttonPush.subscribe((buttonPushEvent: ButtonPushAfterEvent) => {
|
|
3467
|
+
* const eventLoc = buttonPushEvent.block.location;
|
|
3468
|
+
*
|
|
3469
|
+
* world.sendMessage(
|
|
3470
|
+
* `Button push event at tick ${system.currentTick} Power:${buttonPushEvent.block.getRedstonePower()}`,
|
|
3471
|
+
* );
|
|
3472
|
+
* });
|
|
3473
|
+
* ```
|
|
2932
3474
|
*/
|
|
2933
3475
|
// @ts-ignore Class inheritance allowed for native defined classes
|
|
2934
3476
|
export class ButtonPushAfterEventSignal extends IButtonPushAfterEventSignal {
|
|
@@ -3413,6 +3955,54 @@ export class CompoundBlockVolume {
|
|
|
3413
3955
|
* Represents a container that can hold sets of items. Used
|
|
3414
3956
|
* with entities such as Players, Chest Minecarts, Llamas, and
|
|
3415
3957
|
* more.
|
|
3958
|
+
* @example containers.js
|
|
3959
|
+
* ```typescript
|
|
3960
|
+
* let leftLocation = test.worldLocation({ x: 2, y: 2, z: 2 }); // left chest location
|
|
3961
|
+
* let rightLocation = test.worldLocation({ x: 4, y: 2, z: 2 }); // right chest location
|
|
3962
|
+
*
|
|
3963
|
+
* const chestCart = test.spawn("chest_minecart", { x: 6, y: 2, z: 2 });
|
|
3964
|
+
*
|
|
3965
|
+
* let leftChestBlock = defaultDimension.getBlock(leftLocation);
|
|
3966
|
+
* let rightChestBlock = defaultDimension.getBlock(rightLocation);
|
|
3967
|
+
*
|
|
3968
|
+
* leftChestBlock.setType(MinecraftBlockTypes.chest);
|
|
3969
|
+
* rightChestBlock.setType(MinecraftBlockTypes.chest);
|
|
3970
|
+
*
|
|
3971
|
+
* const rightChestInventoryComp = rightChestBlock.getComponent("inventory");
|
|
3972
|
+
* const leftChestInventoryComp = leftChestBlock.getComponent("inventory");
|
|
3973
|
+
* const chestCartInventoryComp = chestCart.getComponent("inventory");
|
|
3974
|
+
*
|
|
3975
|
+
* const rightChestContainer = rightChestInventoryComp.container;
|
|
3976
|
+
* const leftChestContainer = leftChestInventoryComp.container;
|
|
3977
|
+
* const chestCartContainer = chestCartInventoryComp.container;
|
|
3978
|
+
*
|
|
3979
|
+
* rightChestContainer.setItem(0, new ItemStack(Items.apple, 10, 0));
|
|
3980
|
+
* test.assert(rightChestContainer.getItem(0).id === "apple", "Expected apple in right container slot index 0");
|
|
3981
|
+
*
|
|
3982
|
+
* rightChestContainer.setItem(1, new ItemStack(Items.emerald, 10, 0));
|
|
3983
|
+
* test.assert(rightChestContainer.getItem(1).id === "emerald", "Expected emerald in right container slot index 1");
|
|
3984
|
+
*
|
|
3985
|
+
* test.assert(rightChestContainer.size === 27, "Unexpected size: " + rightChestContainer.size);
|
|
3986
|
+
* test.assert(
|
|
3987
|
+
* rightChestContainer.emptySlotsCount === 25,
|
|
3988
|
+
* "Unexpected emptySlotsCount: " + rightChestContainer.emptySlotsCount
|
|
3989
|
+
* );
|
|
3990
|
+
*
|
|
3991
|
+
* const itemStack = rightChestContainer.getItem(0);
|
|
3992
|
+
* test.assert(itemStack.id === "apple", "Expected apple");
|
|
3993
|
+
* test.assert(itemStack.amount === 10, "Expected 10 apples");
|
|
3994
|
+
* test.assert(itemStack.data === 0, "Expected 0 data");
|
|
3995
|
+
*
|
|
3996
|
+
* leftChestContainer.setItem(0, new ItemStack(Items.cake, 10, 0));
|
|
3997
|
+
*
|
|
3998
|
+
* rightChestContainer.transferItem(0, 4, chestCartContainer); // transfer the apple from the right chest to a chest cart
|
|
3999
|
+
* rightChestContainer.swapItems(1, 0, leftChestContainer); // swap the cake and emerald
|
|
4000
|
+
*
|
|
4001
|
+
* test.assert(chestCartContainer.getItem(4).id === "apple", "Expected apple in left container slot index 4");
|
|
4002
|
+
* test.assert(leftChestContainer.getItem(0).id === "emerald", "Expected emerald in left container slot index 0");
|
|
4003
|
+
* test.assert(rightChestContainer.getItem(1).id === "cake", "Expected cake in right container slot index 1");
|
|
4004
|
+
*
|
|
4005
|
+
* ```
|
|
3416
4006
|
*/
|
|
3417
4007
|
export class Container {
|
|
3418
4008
|
private constructor();
|
|
@@ -3474,9 +4064,16 @@ export class Container {
|
|
|
3474
4064
|
* out of bounds.
|
|
3475
4065
|
* @example getItem.ts
|
|
3476
4066
|
* ```typescript
|
|
3477
|
-
* //
|
|
3478
|
-
*
|
|
3479
|
-
*
|
|
4067
|
+
* // A function that gets a copy of the first item in the player's hotbar
|
|
4068
|
+
* import { Player, EntityInventoryComponent, ItemStack } from '@minecraft/server';
|
|
4069
|
+
*
|
|
4070
|
+
* function getFirstHotbarItem(player: Player): ItemStack | undefined {
|
|
4071
|
+
* const inventory = player.getComponent(EntityInventoryComponent.componentId);
|
|
4072
|
+
* if (inventory && inventory.container) {
|
|
4073
|
+
* return inventory.container.getItem(0);
|
|
4074
|
+
* }
|
|
4075
|
+
* return undefined;
|
|
4076
|
+
* }
|
|
3480
4077
|
* ```
|
|
3481
4078
|
*/
|
|
3482
4079
|
getItem(slot: number): ItemStack | undefined;
|
|
@@ -3523,10 +4120,17 @@ export class Container {
|
|
|
3523
4120
|
* or if the `fromSlot` or `toSlot` indices out of bounds.
|
|
3524
4121
|
* @example moveItem.ts
|
|
3525
4122
|
* ```typescript
|
|
3526
|
-
* //
|
|
3527
|
-
*
|
|
3528
|
-
*
|
|
3529
|
-
*
|
|
4123
|
+
* // A function that moves an item from one slot of the player's inventory to another player's inventory
|
|
4124
|
+
* import { Player, EntityComponentTypes } from '@minecraft/server';
|
|
4125
|
+
*
|
|
4126
|
+
* function moveBetweenPlayers(slotId: number, fromPlayer: Player, toPlayer: Player) {
|
|
4127
|
+
* const fromInventory = fromPlayer.getComponent(EntityComponentTypes.Inventory);
|
|
4128
|
+
* const toInventory = toPlayer.getComponent(EntityComponentTypes.Inventory);
|
|
4129
|
+
*
|
|
4130
|
+
* if (fromInventory && toInventory && fromInventory.container && toInventory.container) {
|
|
4131
|
+
* fromInventory.container.moveItem(slotId, slotId, toInventory.container);
|
|
4132
|
+
* }
|
|
4133
|
+
* }
|
|
3530
4134
|
* ```
|
|
3531
4135
|
*/
|
|
3532
4136
|
moveItem(fromSlot: number, toSlot: number, toContainer: Container): void;
|
|
@@ -3564,9 +4168,17 @@ export class Container {
|
|
|
3564
4168
|
* invalid or if the `slot` or `otherSlot` are out of bounds.
|
|
3565
4169
|
* @example swapItems.ts
|
|
3566
4170
|
* ```typescript
|
|
3567
|
-
* //
|
|
3568
|
-
*
|
|
3569
|
-
*
|
|
4171
|
+
* // A function that swaps an item from one slot of the player's inventory to another player's inventory
|
|
4172
|
+
* import { Player, EntityComponentTypes } from '@minecraft/server';
|
|
4173
|
+
*
|
|
4174
|
+
* function swapBetweenPlayers(slotId: number, fromPlayer: Player, toPlayer: Player) {
|
|
4175
|
+
* const fromInventory = fromPlayer.getComponent(EntityComponentTypes.Inventory);
|
|
4176
|
+
* const toInventory = toPlayer.getComponent(EntityComponentTypes.Inventory);
|
|
4177
|
+
*
|
|
4178
|
+
* if (fromInventory && toInventory && fromInventory.container && toInventory.container) {
|
|
4179
|
+
* fromInventory.container.swapItems(slotId, slotId, toInventory.container);
|
|
4180
|
+
* }
|
|
4181
|
+
* }
|
|
3570
4182
|
* ```
|
|
3571
4183
|
*/
|
|
3572
4184
|
swapItems(slot: number, otherSlot: number, otherContainer: Container): void;
|
|
@@ -3591,10 +4203,17 @@ export class Container {
|
|
|
3591
4203
|
* or if the `fromSlot` or `toSlot` indices out of bounds.
|
|
3592
4204
|
* @example transferItem.ts
|
|
3593
4205
|
* ```typescript
|
|
3594
|
-
* //
|
|
3595
|
-
*
|
|
3596
|
-
*
|
|
3597
|
-
*
|
|
4206
|
+
* // A function that moves an item from one slot of the player's inventory to another player's inventory
|
|
4207
|
+
* import { Player, EntityComponentTypes } from '@minecraft/server';
|
|
4208
|
+
*
|
|
4209
|
+
* function moveBetweenPlayers(slotId: number, fromPlayer: Player, toPlayer: Player) {
|
|
4210
|
+
* const fromInventory = fromPlayer.getComponent(EntityComponentTypes.Inventory);
|
|
4211
|
+
* const toInventory = toPlayer.getComponent(EntityComponentTypes.Inventory);
|
|
4212
|
+
*
|
|
4213
|
+
* if (fromInventory && toInventory && fromInventory.container && toInventory.container) {
|
|
4214
|
+
* fromInventory.container.transferItem(slotId, toInventory.container);
|
|
4215
|
+
* }
|
|
4216
|
+
* }
|
|
3598
4217
|
* ```
|
|
3599
4218
|
*/
|
|
3600
4219
|
transferItem(fromSlot: number, toContainer: Container): ItemStack | undefined;
|
|
@@ -3947,7 +4566,6 @@ export class ContainerSlot {
|
|
|
3947
4566
|
}
|
|
3948
4567
|
|
|
3949
4568
|
/**
|
|
3950
|
-
* @beta
|
|
3951
4569
|
* Contains information related to firing of a data driven
|
|
3952
4570
|
* entity event - for example, the minecraft:ageable_grow_up
|
|
3953
4571
|
* event on a chicken.
|
|
@@ -3976,7 +4594,6 @@ export class DataDrivenEntityTriggerAfterEvent {
|
|
|
3976
4594
|
}
|
|
3977
4595
|
|
|
3978
4596
|
/**
|
|
3979
|
-
* @beta
|
|
3980
4597
|
* Contains event registration related to firing of a data
|
|
3981
4598
|
* driven entity event - for example, the
|
|
3982
4599
|
* minecraft:ageable_grow_up event on a chicken.
|
|
@@ -4120,39 +4737,21 @@ export class Dimension {
|
|
|
4120
4737
|
* {@link LocationInUnloadedChunkError}
|
|
4121
4738
|
*
|
|
4122
4739
|
* {@link LocationOutOfWorldBoundariesError}
|
|
4123
|
-
* @example
|
|
4124
|
-
* ```typescript
|
|
4125
|
-
* const overworld = mc.world.getDimension("overworld");
|
|
4126
|
-
*
|
|
4127
|
-
* log("Creating an explosion of radius 10.");
|
|
4128
|
-
* overworld.createExplosion(targetLocation, 10);
|
|
4129
|
-
* ```
|
|
4130
|
-
* @example createFireAndWaterExplosions.ts
|
|
4740
|
+
* @example createExplosions.ts
|
|
4131
4741
|
* ```typescript
|
|
4132
|
-
*
|
|
4133
|
-
*
|
|
4134
|
-
* const explosionLoc = { x: targetLocation.x + 0.5, y: targetLocation.y + 0.5, z: targetLocation.z + 0.5};
|
|
4135
|
-
*
|
|
4136
|
-
* log("Creating an explosion of radius 15 that causes fire.");
|
|
4137
|
-
* overworld.createExplosion(explosionLoc, 15, { causesFire: true });
|
|
4138
|
-
*
|
|
4139
|
-
* const belowWaterLoc = { x: targetLocation.x + 3, y: targetLocation.y + 1,z: targetLocation.z + 3};
|
|
4742
|
+
* // Creates an explosion of radius 15 that does not break blocks
|
|
4743
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
4140
4744
|
*
|
|
4141
|
-
*
|
|
4142
|
-
*
|
|
4143
|
-
*
|
|
4144
|
-
* @example createNoBlockExplosion.ts
|
|
4145
|
-
* ```typescript
|
|
4146
|
-
* const overworld = mc.world.getDimension("overworld");
|
|
4745
|
+
* function createExplosions(location: DimensionLocation) {
|
|
4746
|
+
* // Creates an explosion of radius 15 that does not break blocks
|
|
4747
|
+
* location.dimension.createExplosion(location, 15, { breaksBlocks: false });
|
|
4147
4748
|
*
|
|
4148
|
-
*
|
|
4149
|
-
*
|
|
4150
|
-
* y: Math.floor(targetLocation.y + 2),
|
|
4151
|
-
* z: Math.floor(targetLocation.z + 1)
|
|
4152
|
-
* };
|
|
4749
|
+
* // Creates an explosion of radius 15 that does not cause fire
|
|
4750
|
+
* location.dimension.createExplosion(location, 15, { causesFire: true });
|
|
4153
4751
|
*
|
|
4154
|
-
*
|
|
4155
|
-
*
|
|
4752
|
+
* // Creates an explosion of radius 10 that can go underwater
|
|
4753
|
+
* location.dimension.createExplosion(location, 10, { allowUnderwater: true });
|
|
4754
|
+
* }
|
|
4156
4755
|
* ```
|
|
4157
4756
|
*/
|
|
4158
4757
|
createExplosion(location: Vector3, radius: number, explosionOptions?: ExplosionOptions): boolean;
|
|
@@ -4186,8 +4785,22 @@ export class Dimension {
|
|
|
4186
4785
|
/**
|
|
4187
4786
|
* @beta
|
|
4188
4787
|
* @remarks
|
|
4788
|
+
* Finds the location of the closest biome of a particular
|
|
4789
|
+
* type. Note that the findClosestBiome operation can take some
|
|
4790
|
+
* time to complete, so avoid using many of these calls within
|
|
4791
|
+
* a particular tick.
|
|
4792
|
+
*
|
|
4189
4793
|
* This function can't be called in read-only mode.
|
|
4190
4794
|
*
|
|
4795
|
+
* @param pos
|
|
4796
|
+
* Starting location to look for a biome to find.
|
|
4797
|
+
* @param biomeToFind
|
|
4798
|
+
* Identifier of the biome to look for.
|
|
4799
|
+
* @param options
|
|
4800
|
+
* Additional selection criteria for a biome search.
|
|
4801
|
+
* @returns
|
|
4802
|
+
* Returns a location of the biome, or undefined if a biome
|
|
4803
|
+
* could not be found.
|
|
4191
4804
|
* @throws This function can throw errors.
|
|
4192
4805
|
*
|
|
4193
4806
|
* {@link minecraftcommon.EngineError}
|
|
@@ -4244,60 +4857,52 @@ export class Dimension {
|
|
|
4244
4857
|
* @returns
|
|
4245
4858
|
* An entity array.
|
|
4246
4859
|
* @throws This function can throw errors.
|
|
4247
|
-
* @example
|
|
4860
|
+
* @example checkFeatherNearby.ts
|
|
4248
4861
|
* ```typescript
|
|
4249
|
-
*
|
|
4250
|
-
*
|
|
4251
|
-
*
|
|
4252
|
-
*
|
|
4253
|
-
*
|
|
4254
|
-
*
|
|
4255
|
-
*
|
|
4256
|
-
*
|
|
4257
|
-
*
|
|
4258
|
-
*
|
|
4862
|
+
* import { DimensionLocation, EntityComponentTypes } from "@minecraft/server";
|
|
4863
|
+
*
|
|
4864
|
+
* // Returns true if a feather item entity is within 'distance' blocks of 'location'.
|
|
4865
|
+
* function isFeatherNear(location: DimensionLocation, distance: number): boolean {
|
|
4866
|
+
* const items = location.dimension.getEntities({
|
|
4867
|
+
* location: location,
|
|
4868
|
+
* maxDistance: 20,
|
|
4869
|
+
* });
|
|
4870
|
+
*
|
|
4871
|
+
* for (const item of items) {
|
|
4872
|
+
* const itemComp = item.getComponent(EntityComponentTypes.Item);
|
|
4873
|
+
*
|
|
4874
|
+
* if (itemComp) {
|
|
4875
|
+
* if (itemComp.itemStack.typeId.endsWith('feather')) {
|
|
4876
|
+
* return true;
|
|
4877
|
+
* }
|
|
4878
|
+
* }
|
|
4879
|
+
* }
|
|
4259
4880
|
*
|
|
4260
|
-
*
|
|
4261
|
-
*
|
|
4262
|
-
* }
|
|
4881
|
+
* return false;
|
|
4882
|
+
* }
|
|
4263
4883
|
* ```
|
|
4264
4884
|
* @example tagsQuery.ts
|
|
4265
4885
|
* ```typescript
|
|
4266
|
-
*
|
|
4267
|
-
*
|
|
4268
|
-
* // create some sample mob data
|
|
4269
|
-
* for (let i = 0; i < 10; i++) {
|
|
4270
|
-
* let mobTypeId = mobs[i % mobs.length];
|
|
4271
|
-
* let entity = overworld.spawnEntity(mobTypeId, targetLocation);
|
|
4272
|
-
* entity.addTag("mobparty." + mobTypeId);
|
|
4273
|
-
* }
|
|
4274
|
-
*
|
|
4275
|
-
* let eqo: mc.EntityQueryOptions = {
|
|
4276
|
-
* tags: ["mobparty.skeleton"],
|
|
4277
|
-
* };
|
|
4886
|
+
* import { EntityQueryOptions, DimensionLocation } from '@minecraft/server';
|
|
4278
4887
|
*
|
|
4279
|
-
*
|
|
4280
|
-
*
|
|
4281
|
-
* }
|
|
4282
|
-
* ```
|
|
4283
|
-
* @example testThatEntityIsFeatherItem.ts
|
|
4284
|
-
* ```typescript
|
|
4285
|
-
* const overworld = mc.world.getDimension("overworld");
|
|
4888
|
+
* function mobParty(targetLocation: DimensionLocation) {
|
|
4889
|
+
* const mobs = ['creeper', 'skeleton', 'sheep'];
|
|
4286
4890
|
*
|
|
4287
|
-
*
|
|
4288
|
-
*
|
|
4289
|
-
*
|
|
4290
|
-
*
|
|
4891
|
+
* // create some sample mob data
|
|
4892
|
+
* for (let i = 0; i < 10; i++) {
|
|
4893
|
+
* const mobTypeId = mobs[i % mobs.length];
|
|
4894
|
+
* const entity = targetLocation.dimension.spawnEntity(mobTypeId, targetLocation);
|
|
4895
|
+
* entity.addTag('mobparty.' + mobTypeId);
|
|
4896
|
+
* }
|
|
4291
4897
|
*
|
|
4292
|
-
*
|
|
4293
|
-
*
|
|
4898
|
+
* const eqo: EntityQueryOptions = {
|
|
4899
|
+
* tags: ['mobparty.skeleton'],
|
|
4900
|
+
* };
|
|
4294
4901
|
*
|
|
4295
|
-
*
|
|
4296
|
-
*
|
|
4297
|
-
* log("Success! Found a feather", 1);
|
|
4298
|
-
* }
|
|
4902
|
+
* for (const entity of targetLocation.dimension.getEntities(eqo)) {
|
|
4903
|
+
* entity.kill();
|
|
4299
4904
|
* }
|
|
4300
|
-
*
|
|
4905
|
+
* }
|
|
4301
4906
|
* ```
|
|
4302
4907
|
*/
|
|
4303
4908
|
getEntities(options?: EntityQueryOptions): Entity[];
|
|
@@ -4433,42 +5038,39 @@ export class Dimension {
|
|
|
4433
5038
|
* {@link LocationOutOfWorldBoundariesError}
|
|
4434
5039
|
* @example createOldHorse.ts
|
|
4435
5040
|
* ```typescript
|
|
4436
|
-
*
|
|
5041
|
+
* // Spawns an adult horse
|
|
5042
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
4437
5043
|
*
|
|
4438
|
-
*
|
|
4439
|
-
*
|
|
5044
|
+
* function spawnAdultHorse(location: DimensionLocation) {
|
|
5045
|
+
* // Create a horse and triggering the 'ageable_grow_up' event, ensuring the horse is created as an adult
|
|
5046
|
+
* location.dimension.spawnEntity('minecraft:horse<minecraft:ageable_grow_up>', location);
|
|
5047
|
+
* }
|
|
4440
5048
|
* ```
|
|
4441
5049
|
* @example quickFoxLazyDog.ts
|
|
4442
5050
|
* ```typescript
|
|
4443
|
-
*
|
|
4444
|
-
*
|
|
4445
|
-
*
|
|
4446
|
-
*
|
|
4447
|
-
*
|
|
4448
|
-
*
|
|
4449
|
-
*
|
|
4450
|
-
*
|
|
4451
|
-
*
|
|
4452
|
-
*
|
|
4453
|
-
*
|
|
4454
|
-
*
|
|
4455
|
-
*
|
|
4456
|
-
*
|
|
4457
|
-
*
|
|
4458
|
-
*
|
|
4459
|
-
*
|
|
4460
|
-
*
|
|
4461
|
-
*
|
|
4462
|
-
*
|
|
4463
|
-
*
|
|
4464
|
-
*
|
|
4465
|
-
*
|
|
4466
|
-
* ```
|
|
4467
|
-
* @example triggerEvent.ts
|
|
4468
|
-
* ```typescript
|
|
4469
|
-
* const creeper = overworld.spawnEntity("minecraft:creeper", targetLocation);
|
|
4470
|
-
*
|
|
4471
|
-
* creeper.triggerEvent("minecraft:start_exploding_forced");
|
|
5051
|
+
* // Spawns a fox over a dog
|
|
5052
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
5053
|
+
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
5054
|
+
*
|
|
5055
|
+
* function spawnAdultHorse(location: DimensionLocation) {
|
|
5056
|
+
* // Create fox (our quick brown fox)
|
|
5057
|
+
* const fox = location.dimension.spawnEntity(MinecraftEntityTypes.Fox, {
|
|
5058
|
+
* x: location.x,
|
|
5059
|
+
* y: location.y + 2,
|
|
5060
|
+
* z: location.z,
|
|
5061
|
+
* });
|
|
5062
|
+
*
|
|
5063
|
+
* fox.addEffect('speed', 10, {
|
|
5064
|
+
* amplifier: 2,
|
|
5065
|
+
* });
|
|
5066
|
+
*
|
|
5067
|
+
* // Create wolf (our lazy dog)
|
|
5068
|
+
* const wolf = location.dimension.spawnEntity(MinecraftEntityTypes.Wolf, location);
|
|
5069
|
+
* wolf.addEffect('slowness', 10, {
|
|
5070
|
+
* amplifier: 2,
|
|
5071
|
+
* });
|
|
5072
|
+
* wolf.isSneaking = true;
|
|
5073
|
+
* }
|
|
4472
5074
|
* ```
|
|
4473
5075
|
*/
|
|
4474
5076
|
spawnEntity(identifier: string, location: Vector3): Entity;
|
|
@@ -4488,33 +5090,16 @@ export class Dimension {
|
|
|
4488
5090
|
* {@link LocationInUnloadedChunkError}
|
|
4489
5091
|
*
|
|
4490
5092
|
* {@link LocationOutOfWorldBoundariesError}
|
|
4491
|
-
* @example
|
|
4492
|
-
* ```typescript
|
|
4493
|
-
* const overworld = mc.world.getDimension('overworld');
|
|
4494
|
-
*
|
|
4495
|
-
* const oneItemLoc = { x: targetLocation.x + targetLocation.y + 3, y: 2, z: targetLocation.z + 1 };
|
|
4496
|
-
* const fiveItemsLoc = { x: targetLocation.x + 1, y: targetLocation.y + 2, z: targetLocation.z + 1 };
|
|
4497
|
-
* const diamondPickaxeLoc = { x: targetLocation.x + 2, y: targetLocation.y + 2, z: targetLocation.z + 4 };
|
|
4498
|
-
*
|
|
4499
|
-
* const oneEmerald = new mc.ItemStack(mc.MinecraftItemTypes.Emerald, 1);
|
|
4500
|
-
* const onePickaxe = new mc.ItemStack(mc.MinecraftItemTypes.DiamondPickaxe, 1);
|
|
4501
|
-
* const fiveEmeralds = new mc.ItemStack(mc.MinecraftItemTypes.Emerald, 5);
|
|
4502
|
-
*
|
|
4503
|
-
* log(`Spawning an emerald at (${oneItemLoc.x}, ${oneItemLoc.y}, ${oneItemLoc.z})`);
|
|
4504
|
-
* overworld.spawnItem(oneEmerald, oneItemLoc);
|
|
4505
|
-
*
|
|
4506
|
-
* log(`Spawning five emeralds at (${fiveItemsLoc.x}, ${fiveItemsLoc.y}, ${fiveItemsLoc.z})`);
|
|
4507
|
-
* overworld.spawnItem(fiveEmeralds, fiveItemsLoc);
|
|
4508
|
-
*
|
|
4509
|
-
* log(`Spawning a diamond pickaxe at (${diamondPickaxeLoc.x}, ${diamondPickaxeLoc.y}, ${diamondPickaxeLoc.z})`);
|
|
4510
|
-
* overworld.spawnItem(onePickaxe, diamondPickaxeLoc);
|
|
4511
|
-
* ```
|
|
4512
|
-
* @example spawnItem.ts
|
|
5093
|
+
* @example spawnFeatherItem.ts
|
|
4513
5094
|
* ```typescript
|
|
4514
|
-
*
|
|
5095
|
+
* // Spawns a feather at a location
|
|
5096
|
+
* import { ItemStack, DimensionLocation } from '@minecraft/server';
|
|
5097
|
+
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
|
|
4515
5098
|
*
|
|
4516
|
-
*
|
|
4517
|
-
*
|
|
5099
|
+
* function spawnFeather(location: DimensionLocation) {
|
|
5100
|
+
* const featherItem = new ItemStack(MinecraftItemTypes.Feather, 1);
|
|
5101
|
+
* location.dimension.spawnItem(featherItem, location);
|
|
5102
|
+
* }
|
|
4518
5103
|
* ```
|
|
4519
5104
|
*/
|
|
4520
5105
|
spawnItem(itemStack: ItemStack, location: Vector3): Entity;
|
|
@@ -4539,18 +5124,27 @@ export class Dimension {
|
|
|
4539
5124
|
* {@link LocationOutOfWorldBoundariesError}
|
|
4540
5125
|
* @example spawnParticle.ts
|
|
4541
5126
|
* ```typescript
|
|
4542
|
-
*
|
|
4543
|
-
*
|
|
4544
|
-
*
|
|
4545
|
-
*
|
|
4546
|
-
*
|
|
4547
|
-
*
|
|
4548
|
-
*
|
|
4549
|
-
*
|
|
4550
|
-
*
|
|
4551
|
-
*
|
|
4552
|
-
*
|
|
4553
|
-
*
|
|
5127
|
+
* // A function that spawns a particle at a random location near the target location for all players in the server
|
|
5128
|
+
* import { world, MolangVariableMap, DimensionLocation, Vector3 } from '@minecraft/server';
|
|
5129
|
+
*
|
|
5130
|
+
* function spawnConfetti(location: DimensionLocation) {
|
|
5131
|
+
* for (let i = 0; i < 100; i++) {
|
|
5132
|
+
* const molang = new MolangVariableMap();
|
|
5133
|
+
*
|
|
5134
|
+
* molang.setColorRGB('variable.color', {
|
|
5135
|
+
* red: Math.random(),
|
|
5136
|
+
* green: Math.random(),
|
|
5137
|
+
* blue: Math.random()
|
|
5138
|
+
* });
|
|
5139
|
+
*
|
|
5140
|
+
* const newLocation: Vector3 = {
|
|
5141
|
+
* x: location.x + Math.floor(Math.random() * 8) - 4,
|
|
5142
|
+
* y: location.y + Math.floor(Math.random() * 8) - 4,
|
|
5143
|
+
* z: location.z + Math.floor(Math.random() * 8) - 4,
|
|
5144
|
+
* };
|
|
5145
|
+
* location.dimension.spawnParticle('minecraft:colored_flame_particle', newLocation, molang);
|
|
5146
|
+
* }
|
|
5147
|
+
* }
|
|
4554
5148
|
* ```
|
|
4555
5149
|
*/
|
|
4556
5150
|
spawnParticle(effectName: string, location: Vector3, molangVariables?: MolangVariableMap): void;
|
|
@@ -4639,7 +5233,6 @@ export class Effect {
|
|
|
4639
5233
|
}
|
|
4640
5234
|
|
|
4641
5235
|
/**
|
|
4642
|
-
* @beta
|
|
4643
5236
|
* Contains information related to changes to an effect - like
|
|
4644
5237
|
* poison - being added to an entity.
|
|
4645
5238
|
*/
|
|
@@ -4660,7 +5253,6 @@ export class EffectAddAfterEvent {
|
|
|
4660
5253
|
}
|
|
4661
5254
|
|
|
4662
5255
|
/**
|
|
4663
|
-
* @beta
|
|
4664
5256
|
* Manages callbacks that are connected to when an effect is
|
|
4665
5257
|
* added to an entity.
|
|
4666
5258
|
*/
|
|
@@ -4691,7 +5283,6 @@ export class EffectAddAfterEventSignal {
|
|
|
4691
5283
|
}
|
|
4692
5284
|
|
|
4693
5285
|
/**
|
|
4694
|
-
* @beta
|
|
4695
5286
|
* Contains information related to changes to an effect - like
|
|
4696
5287
|
* poison - being added to an entity.
|
|
4697
5288
|
*/
|
|
@@ -4724,7 +5315,6 @@ export class EffectAddBeforeEvent {
|
|
|
4724
5315
|
}
|
|
4725
5316
|
|
|
4726
5317
|
/**
|
|
4727
|
-
* @beta
|
|
4728
5318
|
* Manages callbacks that are connected to when an effect is
|
|
4729
5319
|
* added to an entity.
|
|
4730
5320
|
*/
|
|
@@ -4898,7 +5488,10 @@ export class Entity {
|
|
|
4898
5488
|
readonly isInWater: boolean;
|
|
4899
5489
|
/**
|
|
4900
5490
|
* @remarks
|
|
4901
|
-
* Whether the entity is on top of a solid block.
|
|
5491
|
+
* Whether the entity is on top of a solid block. This property
|
|
5492
|
+
* may behave in unexpected ways. This property will always be
|
|
5493
|
+
* true when an Entity is first spawned, and if the Entity has
|
|
5494
|
+
* no gravity this property may be incorrect.
|
|
4902
5495
|
*
|
|
4903
5496
|
* @throws This property can throw when used.
|
|
4904
5497
|
*/
|
|
@@ -5007,40 +5600,48 @@ export class Entity {
|
|
|
5007
5600
|
* amplifier are outside of the valid ranges, or if the effect
|
|
5008
5601
|
* does not exist.
|
|
5009
5602
|
* @throws This function can throw errors.
|
|
5010
|
-
* @example
|
|
5603
|
+
* @example poisonVillager.ts
|
|
5011
5604
|
* ```typescript
|
|
5012
|
-
*
|
|
5013
|
-
*
|
|
5014
|
-
*
|
|
5015
|
-
*
|
|
5605
|
+
* // Spawns a villager and gives it the poison effect
|
|
5606
|
+
* import {
|
|
5607
|
+
* DimensionLocation,
|
|
5608
|
+
* } from '@minecraft/server';
|
|
5609
|
+
* import { MinecraftEffectTypes } from '@minecraft/vanilla-data';
|
|
5610
|
+
*
|
|
5611
|
+
* function spawnPoisonedVillager(location: DimensionLocation) {
|
|
5612
|
+
* const villagerType = 'minecraft:villager_v2<minecraft:ageable_grow_up>';
|
|
5613
|
+
* const villager = location.dimension.spawnEntity(villagerType, location);
|
|
5614
|
+
* const duration = 20;
|
|
5615
|
+
*
|
|
5616
|
+
* villager.addEffect(MinecraftEffectTypes.Poison, duration, { amplifier: 1 });
|
|
5617
|
+
* }
|
|
5016
5618
|
*
|
|
5017
|
-
* villager.addEffect(EffectTypes.get('poison'), duration, { amplifier: 1 });
|
|
5018
5619
|
* ```
|
|
5019
5620
|
* @example quickFoxLazyDog.ts
|
|
5020
5621
|
* ```typescript
|
|
5021
|
-
*
|
|
5022
|
-
*
|
|
5023
|
-
*
|
|
5024
|
-
*
|
|
5025
|
-
*
|
|
5026
|
-
*
|
|
5027
|
-
*
|
|
5028
|
-
*
|
|
5029
|
-
*
|
|
5030
|
-
*
|
|
5031
|
-
*
|
|
5032
|
-
*
|
|
5033
|
-
*
|
|
5034
|
-
*
|
|
5035
|
-
*
|
|
5036
|
-
*
|
|
5037
|
-
*
|
|
5038
|
-
*
|
|
5039
|
-
*
|
|
5040
|
-
*
|
|
5041
|
-
*
|
|
5042
|
-
*
|
|
5043
|
-
*
|
|
5622
|
+
* // Spawns a fox over a dog
|
|
5623
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
5624
|
+
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
5625
|
+
*
|
|
5626
|
+
* function spawnAdultHorse(location: DimensionLocation) {
|
|
5627
|
+
* // Create fox (our quick brown fox)
|
|
5628
|
+
* const fox = location.dimension.spawnEntity(MinecraftEntityTypes.Fox, {
|
|
5629
|
+
* x: location.x,
|
|
5630
|
+
* y: location.y + 2,
|
|
5631
|
+
* z: location.z,
|
|
5632
|
+
* });
|
|
5633
|
+
*
|
|
5634
|
+
* fox.addEffect('speed', 10, {
|
|
5635
|
+
* amplifier: 2,
|
|
5636
|
+
* });
|
|
5637
|
+
*
|
|
5638
|
+
* // Create wolf (our lazy dog)
|
|
5639
|
+
* const wolf = location.dimension.spawnEntity(MinecraftEntityTypes.Wolf, location);
|
|
5640
|
+
* wolf.addEffect('slowness', 10, {
|
|
5641
|
+
* amplifier: 2,
|
|
5642
|
+
* });
|
|
5643
|
+
* wolf.isSneaking = true;
|
|
5644
|
+
* }
|
|
5044
5645
|
* ```
|
|
5045
5646
|
*/
|
|
5046
5647
|
addEffect(effectType: EffectType | string, duration: number, options?: EntityEffectOptions): Effect | undefined;
|
|
@@ -5057,25 +5658,6 @@ export class Entity {
|
|
|
5057
5658
|
* Returns true if the tag was added successfully. This can
|
|
5058
5659
|
* fail if the tag already exists on the entity.
|
|
5059
5660
|
* @throws This function can throw errors.
|
|
5060
|
-
* @example tagsQuery.ts
|
|
5061
|
-
* ```typescript
|
|
5062
|
-
* let mobs = ["creeper", "skeleton", "sheep"];
|
|
5063
|
-
*
|
|
5064
|
-
* // create some sample mob data
|
|
5065
|
-
* for (let i = 0; i < 10; i++) {
|
|
5066
|
-
* let mobTypeId = mobs[i % mobs.length];
|
|
5067
|
-
* let entity = overworld.spawnEntity(mobTypeId, targetLocation);
|
|
5068
|
-
* entity.addTag("mobparty." + mobTypeId);
|
|
5069
|
-
* }
|
|
5070
|
-
*
|
|
5071
|
-
* let eqo: mc.EntityQueryOptions = {
|
|
5072
|
-
* tags: ["mobparty.skeleton"],
|
|
5073
|
-
* };
|
|
5074
|
-
*
|
|
5075
|
-
* for (let entity of overworld.getEntities(eqo)) {
|
|
5076
|
-
* entity.kill();
|
|
5077
|
-
* }
|
|
5078
|
-
* ```
|
|
5079
5661
|
*/
|
|
5080
5662
|
addTag(tag: string): boolean;
|
|
5081
5663
|
/**
|
|
@@ -5097,16 +5679,25 @@ export class Entity {
|
|
|
5097
5679
|
* @throws This function can throw errors.
|
|
5098
5680
|
* @example applyDamageThenHeal.ts
|
|
5099
5681
|
* ```typescript
|
|
5100
|
-
*
|
|
5682
|
+
* // A function that applies damage and then heals the entity
|
|
5683
|
+
* import { Entity, EntityComponentTypes, system, world } from '@minecraft/server';
|
|
5684
|
+
*
|
|
5685
|
+
* function applyDamageAndHeal(entity: Entity) {
|
|
5686
|
+
* entity.applyDamage(19); // Many mobs have max damage of 20 so this is a near-death mob
|
|
5101
5687
|
*
|
|
5102
|
-
*
|
|
5688
|
+
* system.runTimeout(() => {
|
|
5689
|
+
* const health = entity.getComponent(EntityComponentTypes.Health);
|
|
5690
|
+
* if (health) {
|
|
5691
|
+
* world.sendMessage(`Entity health before heal: ${health.currentValue}`);
|
|
5103
5692
|
*
|
|
5104
|
-
*
|
|
5105
|
-
*
|
|
5106
|
-
*
|
|
5107
|
-
*
|
|
5108
|
-
*
|
|
5109
|
-
*
|
|
5693
|
+
* health.resetToMaxValue();
|
|
5694
|
+
*
|
|
5695
|
+
* world.sendMessage(`Entity after before heal: ${health.currentValue}`);
|
|
5696
|
+
* } else {
|
|
5697
|
+
* console.warn('Entity does not have health component');
|
|
5698
|
+
* }
|
|
5699
|
+
* }, 40); // Run in a few seconds (40 ticks)
|
|
5700
|
+
* }
|
|
5110
5701
|
* ```
|
|
5111
5702
|
*/
|
|
5112
5703
|
applyDamage(amount: number, options?: EntityApplyDamageByProjectileOptions | EntityApplyDamageOptions): boolean;
|
|
@@ -5120,14 +5711,19 @@ export class Entity {
|
|
|
5120
5711
|
* @param vector
|
|
5121
5712
|
* Impulse vector.
|
|
5122
5713
|
* @throws This function can throw errors.
|
|
5123
|
-
* @example
|
|
5714
|
+
* @example yeetEntity.ts
|
|
5124
5715
|
* ```typescript
|
|
5125
|
-
*
|
|
5716
|
+
* // A function that throws entities up in the air
|
|
5717
|
+
* import { Entity } from '@minecraft/server';
|
|
5126
5718
|
*
|
|
5127
|
-
*
|
|
5719
|
+
* function yeetEntity(entity: Entity) {
|
|
5128
5720
|
*
|
|
5129
|
-
*
|
|
5130
|
-
*
|
|
5721
|
+
* // Zero out the entity's velocity before applying impulse
|
|
5722
|
+
* entity.clearVelocity();
|
|
5723
|
+
*
|
|
5724
|
+
* // throw the zombie up in the air
|
|
5725
|
+
* entity.applyImpulse({ x: 0, y: 15, z: 0 });
|
|
5726
|
+
* }
|
|
5131
5727
|
* ```
|
|
5132
5728
|
*/
|
|
5133
5729
|
applyImpulse(vector: Vector3): void;
|
|
@@ -5149,20 +5745,24 @@ export class Entity {
|
|
|
5149
5745
|
* @throws This function can throw errors.
|
|
5150
5746
|
* @example bounceSkeletons.ts
|
|
5151
5747
|
* ```typescript
|
|
5152
|
-
*
|
|
5748
|
+
* import { EntityQueryOptions, DimensionLocation } from '@minecraft/server';
|
|
5153
5749
|
*
|
|
5154
|
-
*
|
|
5155
|
-
*
|
|
5156
|
-
*
|
|
5157
|
-
*
|
|
5750
|
+
* function mobParty(targetLocation: DimensionLocation) {
|
|
5751
|
+
* const mobs = ['creeper', 'skeleton', 'sheep'];
|
|
5752
|
+
*
|
|
5753
|
+
* // create some sample mob data
|
|
5754
|
+
* for (let i = 0; i < 10; i++) {
|
|
5755
|
+
* targetLocation.dimension.spawnEntity(mobs[i % mobs.length], targetLocation);
|
|
5756
|
+
* }
|
|
5158
5757
|
*
|
|
5159
|
-
*
|
|
5160
|
-
*
|
|
5161
|
-
*
|
|
5758
|
+
* const eqo: EntityQueryOptions = {
|
|
5759
|
+
* type: 'skeleton',
|
|
5760
|
+
* };
|
|
5162
5761
|
*
|
|
5163
|
-
*
|
|
5164
|
-
*
|
|
5165
|
-
*
|
|
5762
|
+
* for (const entity of targetLocation.dimension.getEntities(eqo)) {
|
|
5763
|
+
* entity.applyKnockback(0, 0, 0, 1);
|
|
5764
|
+
* }
|
|
5765
|
+
* }
|
|
5166
5766
|
* ```
|
|
5167
5767
|
*/
|
|
5168
5768
|
applyKnockback(directionX: number, directionZ: number, horizontalStrength: number, verticalStrength: number): void;
|
|
@@ -5182,14 +5782,19 @@ export class Entity {
|
|
|
5182
5782
|
* This function can't be called in read-only mode.
|
|
5183
5783
|
*
|
|
5184
5784
|
* @throws This function can throw errors.
|
|
5185
|
-
* @example
|
|
5785
|
+
* @example yeetEntity.ts
|
|
5186
5786
|
* ```typescript
|
|
5187
|
-
*
|
|
5787
|
+
* // A function that throws entities up in the air
|
|
5788
|
+
* import { Entity } from '@minecraft/server';
|
|
5789
|
+
*
|
|
5790
|
+
* function yeetEntity(entity: Entity) {
|
|
5188
5791
|
*
|
|
5189
|
-
*
|
|
5792
|
+
* // Zero out the entity's velocity before applying impulse
|
|
5793
|
+
* entity.clearVelocity();
|
|
5190
5794
|
*
|
|
5191
|
-
*
|
|
5192
|
-
*
|
|
5795
|
+
* // throw the zombie up in the air
|
|
5796
|
+
* entity.applyImpulse({ x: 0, y: 15, z: 0 });
|
|
5797
|
+
* }
|
|
5193
5798
|
* ```
|
|
5194
5799
|
*/
|
|
5195
5800
|
clearVelocity(): void;
|
|
@@ -5208,32 +5813,23 @@ export class Entity {
|
|
|
5208
5813
|
* @returns
|
|
5209
5814
|
* Returns whether the entity was on fire.
|
|
5210
5815
|
* @throws This function can throw errors.
|
|
5211
|
-
* @example
|
|
5816
|
+
* @example setEntityOnFire.ts
|
|
5212
5817
|
* ```typescript
|
|
5213
|
-
*
|
|
5818
|
+
* import { world, Entity, EntityComponentTypes, system } from "@minecraft/server";
|
|
5214
5819
|
*
|
|
5215
|
-
*
|
|
5820
|
+
* function setAblaze(entity: Entity) {
|
|
5821
|
+
* entity.setOnFire(20, true);
|
|
5216
5822
|
*
|
|
5217
|
-
*
|
|
5218
|
-
*
|
|
5219
|
-
*
|
|
5823
|
+
* system.runTimeout(() => {
|
|
5824
|
+
* const onfire = entity.getComponent(EntityComponentTypes.OnFire);
|
|
5825
|
+
* if (onfire) {
|
|
5826
|
+
* world.sendMessage(`${onfire.onFireTicksRemaining} fire ticks remaining, extinguishing the entity.`);
|
|
5827
|
+
* }
|
|
5828
|
+
* // This will extinguish the entity
|
|
5829
|
+
* entity.extinguishFire(true);
|
|
5830
|
+
* }, 30); // Run in 30 ticks or ~1.5 seconds
|
|
5220
5831
|
*
|
|
5221
|
-
*
|
|
5222
|
-
* log("Never mind. Fire extinguished.");
|
|
5223
|
-
* }, 20);
|
|
5224
|
-
* ```
|
|
5225
|
-
* @example teleport.ts
|
|
5226
|
-
* ```typescript
|
|
5227
|
-
* const cow = overworld.spawnEntity("minecraft:cow", targetLocation);
|
|
5228
|
-
*
|
|
5229
|
-
* mc.system.runTimeout(() => {
|
|
5230
|
-
* cow.teleport(
|
|
5231
|
-
* { x: targetLocation.x + 2, y: targetLocation.y + 2, z: targetLocation.z + 2 },
|
|
5232
|
-
* {
|
|
5233
|
-
* facingLocation: targetLocation,
|
|
5234
|
-
* }
|
|
5235
|
-
* );
|
|
5236
|
-
* }, 20);
|
|
5832
|
+
* }
|
|
5237
5833
|
* ```
|
|
5238
5834
|
*/
|
|
5239
5835
|
extinguishFire(useEffects?: boolean): boolean;
|
|
@@ -5402,13 +5998,19 @@ export class Entity {
|
|
|
5402
5998
|
* @throws This function can throw errors.
|
|
5403
5999
|
* @example getFireworkVelocity.ts
|
|
5404
6000
|
* ```typescript
|
|
5405
|
-
*
|
|
6001
|
+
* // A function that spawns fireworks and logs their velocity after 5 ticks
|
|
6002
|
+
* import { DimensionLocation, system, world } from '@minecraft/server';
|
|
6003
|
+
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
6004
|
+
*
|
|
6005
|
+
* function spawnFireworks(location: DimensionLocation) {
|
|
6006
|
+
* const fireworkRocket = location.dimension.spawnEntity(MinecraftEntityTypes.FireworksRocket, location);
|
|
5406
6007
|
*
|
|
5407
|
-
*
|
|
5408
|
-
*
|
|
6008
|
+
* system.runTimeout(() => {
|
|
6009
|
+
* const velocity = fireworkRocket.getVelocity();
|
|
5409
6010
|
*
|
|
5410
|
-
*
|
|
5411
|
-
*
|
|
6011
|
+
* world.sendMessage(`Velocity of firework is: ${velocity.x}, ${velocity.y}, ${velocity.z}`);
|
|
6012
|
+
* }, 5);
|
|
6013
|
+
* }
|
|
5412
6014
|
* ```
|
|
5413
6015
|
*/
|
|
5414
6016
|
getVelocity(): Vector3;
|
|
@@ -5468,22 +6070,26 @@ export class Entity {
|
|
|
5468
6070
|
* @throws This function can throw errors.
|
|
5469
6071
|
* @example tagsQuery.ts
|
|
5470
6072
|
* ```typescript
|
|
5471
|
-
*
|
|
6073
|
+
* import { EntityQueryOptions, DimensionLocation } from '@minecraft/server';
|
|
5472
6074
|
*
|
|
5473
|
-
*
|
|
5474
|
-
*
|
|
5475
|
-
* let mobTypeId = mobs[i % mobs.length];
|
|
5476
|
-
* let entity = overworld.spawnEntity(mobTypeId, targetLocation);
|
|
5477
|
-
* entity.addTag("mobparty." + mobTypeId);
|
|
5478
|
-
* }
|
|
6075
|
+
* function mobParty(targetLocation: DimensionLocation) {
|
|
6076
|
+
* const mobs = ['creeper', 'skeleton', 'sheep'];
|
|
5479
6077
|
*
|
|
5480
|
-
*
|
|
5481
|
-
*
|
|
5482
|
-
*
|
|
6078
|
+
* // create some sample mob data
|
|
6079
|
+
* for (let i = 0; i < 10; i++) {
|
|
6080
|
+
* const mobTypeId = mobs[i % mobs.length];
|
|
6081
|
+
* const entity = targetLocation.dimension.spawnEntity(mobTypeId, targetLocation);
|
|
6082
|
+
* entity.addTag('mobparty.' + mobTypeId);
|
|
6083
|
+
* }
|
|
5483
6084
|
*
|
|
5484
|
-
*
|
|
5485
|
-
*
|
|
5486
|
-
*
|
|
6085
|
+
* const eqo: EntityQueryOptions = {
|
|
6086
|
+
* tags: ['mobparty.skeleton'],
|
|
6087
|
+
* };
|
|
6088
|
+
*
|
|
6089
|
+
* for (const entity of targetLocation.dimension.getEntities(eqo)) {
|
|
6090
|
+
* entity.kill();
|
|
6091
|
+
* }
|
|
6092
|
+
* }
|
|
5487
6093
|
* ```
|
|
5488
6094
|
*/
|
|
5489
6095
|
kill(): boolean;
|
|
@@ -5644,32 +6250,23 @@ export class Entity {
|
|
|
5644
6250
|
* is less than or equal to zero, the entity is wet or the
|
|
5645
6251
|
* entity is immune to fire.
|
|
5646
6252
|
* @throws This function can throw errors.
|
|
5647
|
-
* @example
|
|
6253
|
+
* @example setEntityOnFire.ts
|
|
5648
6254
|
* ```typescript
|
|
5649
|
-
*
|
|
6255
|
+
* import { world, Entity, EntityComponentTypes, system } from "@minecraft/server";
|
|
5650
6256
|
*
|
|
5651
|
-
*
|
|
6257
|
+
* function setAblaze(entity: Entity) {
|
|
6258
|
+
* entity.setOnFire(20, true);
|
|
5652
6259
|
*
|
|
5653
|
-
*
|
|
5654
|
-
*
|
|
5655
|
-
*
|
|
6260
|
+
* system.runTimeout(() => {
|
|
6261
|
+
* const onfire = entity.getComponent(EntityComponentTypes.OnFire);
|
|
6262
|
+
* if (onfire) {
|
|
6263
|
+
* world.sendMessage(`${onfire.onFireTicksRemaining} fire ticks remaining, extinguishing the entity.`);
|
|
6264
|
+
* }
|
|
6265
|
+
* // This will extinguish the entity
|
|
6266
|
+
* entity.extinguishFire(true);
|
|
6267
|
+
* }, 30); // Run in 30 ticks or ~1.5 seconds
|
|
5656
6268
|
*
|
|
5657
|
-
*
|
|
5658
|
-
* log("Never mind. Fire extinguished.");
|
|
5659
|
-
* }, 20);
|
|
5660
|
-
* ```
|
|
5661
|
-
* @example teleport.ts
|
|
5662
|
-
* ```typescript
|
|
5663
|
-
* const cow = overworld.spawnEntity("minecraft:cow", targetLocation);
|
|
5664
|
-
*
|
|
5665
|
-
* mc.system.runTimeout(() => {
|
|
5666
|
-
* cow.teleport(
|
|
5667
|
-
* { x: targetLocation.x + 2, y: targetLocation.y + 2, z: targetLocation.z + 2 },
|
|
5668
|
-
* {
|
|
5669
|
-
* facingLocation: targetLocation,
|
|
5670
|
-
* }
|
|
5671
|
-
* );
|
|
5672
|
-
* }, 20);
|
|
6269
|
+
* }
|
|
5673
6270
|
* ```
|
|
5674
6271
|
*/
|
|
5675
6272
|
setOnFire(seconds: number, useEffects?: boolean): boolean;
|
|
@@ -5722,22 +6319,27 @@ export class Entity {
|
|
|
5722
6319
|
* @throws This function can throw errors.
|
|
5723
6320
|
* @example teleportMovement.ts
|
|
5724
6321
|
* ```typescript
|
|
5725
|
-
*
|
|
6322
|
+
* import { world, system } from '@minecraft/server';
|
|
5726
6323
|
*
|
|
5727
|
-
*
|
|
5728
|
-
*
|
|
6324
|
+
* const overworld = world.getDimension('overworld');
|
|
6325
|
+
* const targetLocation = { x: 0, y: 0, z: 0 };
|
|
6326
|
+
*
|
|
6327
|
+
* const pig = overworld.spawnEntity('minecraft:pig', targetLocation);
|
|
6328
|
+
*
|
|
6329
|
+
* let inc = 1;
|
|
6330
|
+
* const runId = system.runInterval(() => {
|
|
5729
6331
|
* pig.teleport(
|
|
5730
|
-
*
|
|
5731
|
-
*
|
|
5732
|
-
*
|
|
5733
|
-
*
|
|
6332
|
+
* { x: targetLocation.x + inc / 4, y: targetLocation.y + inc / 4, z: targetLocation.z + inc / 4 },
|
|
6333
|
+
* {
|
|
6334
|
+
* facingLocation: targetLocation,
|
|
6335
|
+
* },
|
|
5734
6336
|
* );
|
|
5735
6337
|
*
|
|
5736
6338
|
* if (inc > 100) {
|
|
5737
|
-
*
|
|
6339
|
+
* system.clearRun(runId);
|
|
5738
6340
|
* }
|
|
5739
6341
|
* inc++;
|
|
5740
|
-
*
|
|
6342
|
+
* }, 4);
|
|
5741
6343
|
* ```
|
|
5742
6344
|
*/
|
|
5743
6345
|
teleport(location: Vector3, teleportOptions?: TeleportOptions): void;
|
|
@@ -5758,9 +6360,15 @@ export class Entity {
|
|
|
5758
6360
|
* an error will be thrown.
|
|
5759
6361
|
* @example triggerEvent.ts
|
|
5760
6362
|
* ```typescript
|
|
5761
|
-
*
|
|
6363
|
+
* // A function that spawns a creeper and triggers it to explode immediately
|
|
6364
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
6365
|
+
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
5762
6366
|
*
|
|
5763
|
-
*
|
|
6367
|
+
* function spawnExplodingCreeper(location: DimensionLocation) {
|
|
6368
|
+
* const creeper = location.dimension.spawnEntity(MinecraftEntityTypes.Creeper, location);
|
|
6369
|
+
*
|
|
6370
|
+
* creeper.triggerEvent('minecraft:start_exploding_forced');
|
|
6371
|
+
* }
|
|
5764
6372
|
* ```
|
|
5765
6373
|
*/
|
|
5766
6374
|
triggerEvent(eventName: string): void;
|
|
@@ -6192,6 +6800,39 @@ export class EntityDieAfterEventSignal {
|
|
|
6192
6800
|
/**
|
|
6193
6801
|
* Provides access to a mob's equipment slots. This component
|
|
6194
6802
|
* exists for all mob entities.
|
|
6803
|
+
* @example givePlayerElytra.ts
|
|
6804
|
+
* ```typescript
|
|
6805
|
+
* // Gives the player Elytra
|
|
6806
|
+
* import { EquipmentSlot, ItemStack, Player, EntityComponentTypes } from '@minecraft/server';
|
|
6807
|
+
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
|
|
6808
|
+
*
|
|
6809
|
+
* function giveEquipment(player: Player) {
|
|
6810
|
+
* const equipmentCompPlayer = player.getComponent(EntityComponentTypes.Equippable);
|
|
6811
|
+
* if (equipmentCompPlayer) {
|
|
6812
|
+
* equipmentCompPlayer.setEquipment(EquipmentSlot.Chest, new ItemStack(MinecraftItemTypes.Elytra));
|
|
6813
|
+
* }
|
|
6814
|
+
* }
|
|
6815
|
+
* ```
|
|
6816
|
+
* @example givePlayerEquipment.ts
|
|
6817
|
+
* ```typescript
|
|
6818
|
+
* // Gives the player some equipment
|
|
6819
|
+
* import { EquipmentSlot, ItemStack, Player, EntityComponentTypes } from '@minecraft/server';
|
|
6820
|
+
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
|
|
6821
|
+
*
|
|
6822
|
+
* function giveEquipment(player: Player) {
|
|
6823
|
+
* const equipmentCompPlayer = player.getComponent(EntityComponentTypes.Equippable);
|
|
6824
|
+
* if (equipmentCompPlayer) {
|
|
6825
|
+
* equipmentCompPlayer.setEquipment(EquipmentSlot.Head, new ItemStack(MinecraftItemTypes.GoldenHelmet));
|
|
6826
|
+
* equipmentCompPlayer.setEquipment(EquipmentSlot.Chest, new ItemStack(MinecraftItemTypes.IronChestplate));
|
|
6827
|
+
* equipmentCompPlayer.setEquipment(EquipmentSlot.Legs, new ItemStack(MinecraftItemTypes.DiamondLeggings));
|
|
6828
|
+
* equipmentCompPlayer.setEquipment(EquipmentSlot.Feet, new ItemStack(MinecraftItemTypes.NetheriteBoots));
|
|
6829
|
+
* equipmentCompPlayer.setEquipment(EquipmentSlot.Mainhand, new ItemStack(MinecraftItemTypes.WoodenSword));
|
|
6830
|
+
* equipmentCompPlayer.setEquipment(EquipmentSlot.Offhand, new ItemStack(MinecraftItemTypes.Shield));
|
|
6831
|
+
* } else {
|
|
6832
|
+
* console.warn('No equipment component found on player');
|
|
6833
|
+
* }
|
|
6834
|
+
* }
|
|
6835
|
+
* ```
|
|
6195
6836
|
*/
|
|
6196
6837
|
// @ts-ignore Class inheritance allowed for native defined classes
|
|
6197
6838
|
export class EntityEquippableComponent extends EntityComponent {
|
|
@@ -6407,6 +7048,28 @@ export class EntityHealthChangedAfterEventSignal {
|
|
|
6407
7048
|
|
|
6408
7049
|
/**
|
|
6409
7050
|
* Defines the health properties of an entity.
|
|
7051
|
+
* @example applyDamageThenHeal.ts
|
|
7052
|
+
* ```typescript
|
|
7053
|
+
* // A function that applies damage and then heals the entity
|
|
7054
|
+
* import { Entity, EntityComponentTypes, system, world } from '@minecraft/server';
|
|
7055
|
+
*
|
|
7056
|
+
* function applyDamageAndHeal(entity: Entity) {
|
|
7057
|
+
* entity.applyDamage(19); // Many mobs have max damage of 20 so this is a near-death mob
|
|
7058
|
+
*
|
|
7059
|
+
* system.runTimeout(() => {
|
|
7060
|
+
* const health = entity.getComponent(EntityComponentTypes.Health);
|
|
7061
|
+
* if (health) {
|
|
7062
|
+
* world.sendMessage(`Entity health before heal: ${health.currentValue}`);
|
|
7063
|
+
*
|
|
7064
|
+
* health.resetToMaxValue();
|
|
7065
|
+
*
|
|
7066
|
+
* world.sendMessage(`Entity after before heal: ${health.currentValue}`);
|
|
7067
|
+
* } else {
|
|
7068
|
+
* console.warn('Entity does not have health component');
|
|
7069
|
+
* }
|
|
7070
|
+
* }, 40); // Run in a few seconds (40 ticks)
|
|
7071
|
+
* }
|
|
7072
|
+
* ```
|
|
6410
7073
|
*/
|
|
6411
7074
|
// @ts-ignore Class inheritance allowed for native defined classes
|
|
6412
7075
|
export class EntityHealthComponent extends EntityAttributeComponent {
|
|
@@ -6770,6 +7433,30 @@ export class EntityIsTamedComponent extends EntityComponent {
|
|
|
6770
7433
|
* represents a free-floating item in the world. Lets you
|
|
6771
7434
|
* retrieve the actual item stack contents via the itemStack
|
|
6772
7435
|
* property.
|
|
7436
|
+
* @example checkFeatherNearby.ts
|
|
7437
|
+
* ```typescript
|
|
7438
|
+
* import { DimensionLocation, EntityComponentTypes } from "@minecraft/server";
|
|
7439
|
+
*
|
|
7440
|
+
* // Returns true if a feather item entity is within 'distance' blocks of 'location'.
|
|
7441
|
+
* function isFeatherNear(location: DimensionLocation, distance: number): boolean {
|
|
7442
|
+
* const items = location.dimension.getEntities({
|
|
7443
|
+
* location: location,
|
|
7444
|
+
* maxDistance: 20,
|
|
7445
|
+
* });
|
|
7446
|
+
*
|
|
7447
|
+
* for (const item of items) {
|
|
7448
|
+
* const itemComp = item.getComponent(EntityComponentTypes.Item);
|
|
7449
|
+
*
|
|
7450
|
+
* if (itemComp) {
|
|
7451
|
+
* if (itemComp.itemStack.typeId.endsWith('feather')) {
|
|
7452
|
+
* return true;
|
|
7453
|
+
* }
|
|
7454
|
+
* }
|
|
7455
|
+
* }
|
|
7456
|
+
*
|
|
7457
|
+
* return false;
|
|
7458
|
+
* }
|
|
7459
|
+
* ```
|
|
6773
7460
|
*/
|
|
6774
7461
|
// @ts-ignore Class inheritance allowed for native defined classes
|
|
6775
7462
|
export class EntityItemComponent extends EntityComponent {
|
|
@@ -7340,6 +8027,24 @@ export class EntityNpcComponent extends EntityComponent {
|
|
|
7340
8027
|
/**
|
|
7341
8028
|
* @beta
|
|
7342
8029
|
* When present on an entity, this entity is on fire.
|
|
8030
|
+
* @example setEntityOnFire.ts
|
|
8031
|
+
* ```typescript
|
|
8032
|
+
* import { world, Entity, EntityComponentTypes, system } from "@minecraft/server";
|
|
8033
|
+
*
|
|
8034
|
+
* function setAblaze(entity: Entity) {
|
|
8035
|
+
* entity.setOnFire(20, true);
|
|
8036
|
+
*
|
|
8037
|
+
* system.runTimeout(() => {
|
|
8038
|
+
* const onfire = entity.getComponent(EntityComponentTypes.OnFire);
|
|
8039
|
+
* if (onfire) {
|
|
8040
|
+
* world.sendMessage(`${onfire.onFireTicksRemaining} fire ticks remaining, extinguishing the entity.`);
|
|
8041
|
+
* }
|
|
8042
|
+
* // This will extinguish the entity
|
|
8043
|
+
* entity.extinguishFire(true);
|
|
8044
|
+
* }, 30); // Run in 30 ticks or ~1.5 seconds
|
|
8045
|
+
*
|
|
8046
|
+
* }
|
|
8047
|
+
* ```
|
|
7343
8048
|
*/
|
|
7344
8049
|
// @ts-ignore Class inheritance allowed for native defined classes
|
|
7345
8050
|
export class EntityOnFireComponent extends EntityComponent {
|
|
@@ -7360,6 +8065,16 @@ export class EntityOnFireComponent extends EntityComponent {
|
|
|
7360
8065
|
* direction.
|
|
7361
8066
|
* This component is present when the entity has the
|
|
7362
8067
|
* minecraft:projectile component.
|
|
8068
|
+
* @example shootArrow.ts
|
|
8069
|
+
* ```typescript
|
|
8070
|
+
* import { world, Vector3 } from '@minecraft/server';
|
|
8071
|
+
*
|
|
8072
|
+
* const location: Vector3 = { x: 0, y: -59, z: 0 }; // Replace with the coordinates of where you want to spawn the arrow
|
|
8073
|
+
* const velocity: Vector3 = { x: 0, y: 0, z: 5 };
|
|
8074
|
+
* const arrow = world.getDimension('overworld').spawnEntity('minecraft:arrow', location);
|
|
8075
|
+
* const projectileComp = arrow.getComponent('minecraft:projectile');
|
|
8076
|
+
* projectileComp?.shoot(velocity);
|
|
8077
|
+
* ```
|
|
7363
8078
|
*/
|
|
7364
8079
|
// @ts-ignore Class inheritance allowed for native defined classes
|
|
7365
8080
|
export class EntityProjectileComponent extends EntityComponent {
|
|
@@ -7812,6 +8527,18 @@ export class EntitySkinIdComponent extends EntityComponent {
|
|
|
7812
8527
|
/**
|
|
7813
8528
|
* Contains data related to an entity spawning within the
|
|
7814
8529
|
* world.
|
|
8530
|
+
* @example logEntitySpawnEvents.ts
|
|
8531
|
+
* ```typescript
|
|
8532
|
+
* // Register a new function that is called when a new entity is created.
|
|
8533
|
+
* import { world, EntitySpawnAfterEvent } from '@minecraft/server';
|
|
8534
|
+
*
|
|
8535
|
+
* world.afterEvents.entitySpawn.subscribe((entityEvent: EntitySpawnAfterEvent) => {
|
|
8536
|
+
* const spawnLocation = entityEvent.entity.location;
|
|
8537
|
+
* world.sendMessage(
|
|
8538
|
+
* `New entity of type '${entityEvent.entity.typeId}' spawned at ${spawnLocation.x}, ${spawnLocation.y}, ${spawnLocation.z}!`,
|
|
8539
|
+
* );
|
|
8540
|
+
* });
|
|
8541
|
+
* ```
|
|
7815
8542
|
*/
|
|
7816
8543
|
export class EntitySpawnAfterEvent {
|
|
7817
8544
|
private constructor();
|
|
@@ -7834,6 +8561,18 @@ export class EntitySpawnAfterEvent {
|
|
|
7834
8561
|
/**
|
|
7835
8562
|
* Registers a script-based event handler for handling what
|
|
7836
8563
|
* happens when an entity spawns.
|
|
8564
|
+
* @example logEntitySpawnEvents.ts
|
|
8565
|
+
* ```typescript
|
|
8566
|
+
* // Register a new function that is called when a new entity is created.
|
|
8567
|
+
* import { world, EntitySpawnAfterEvent } from '@minecraft/server';
|
|
8568
|
+
*
|
|
8569
|
+
* world.afterEvents.entitySpawn.subscribe((entityEvent: EntitySpawnAfterEvent) => {
|
|
8570
|
+
* const spawnLocation = entityEvent.entity.location;
|
|
8571
|
+
* world.sendMessage(
|
|
8572
|
+
* `New entity of type '${entityEvent.entity.typeId}' spawned at ${spawnLocation.x}, ${spawnLocation.y}, ${spawnLocation.z}!`,
|
|
8573
|
+
* );
|
|
8574
|
+
* });
|
|
8575
|
+
* ```
|
|
7837
8576
|
*/
|
|
7838
8577
|
export class EntitySpawnAfterEventSignal {
|
|
7839
8578
|
private constructor();
|
|
@@ -7846,21 +8585,6 @@ export class EntitySpawnAfterEventSignal {
|
|
|
7846
8585
|
*
|
|
7847
8586
|
* @param callback
|
|
7848
8587
|
* Function that handles the spawn event.
|
|
7849
|
-
* @example runEntitySpawnEvent.ts
|
|
7850
|
-
* ```typescript
|
|
7851
|
-
* // register a new function that is called when a new entity is created.
|
|
7852
|
-
* mc.world.afterEvents.entitySpawn.subscribe((entityEvent: mc.EntitySpawnAfterEvent) => {
|
|
7853
|
-
* if (entityEvent && entityEvent.entity) {
|
|
7854
|
-
* log(`New entity of type '${entityEvent.entity.typeId}' created!`, 1);
|
|
7855
|
-
* } else {
|
|
7856
|
-
* log(`The entity event didn't work as expected.`, -1);
|
|
7857
|
-
* }
|
|
7858
|
-
* });
|
|
7859
|
-
*
|
|
7860
|
-
* mc.system.runTimeout(() => {
|
|
7861
|
-
* createOldHorse(log, targetLocation);
|
|
7862
|
-
* }, 20);
|
|
7863
|
-
* ```
|
|
7864
8588
|
*/
|
|
7865
8589
|
subscribe(callback: (arg: EntitySpawnAfterEvent) => void): (arg: EntitySpawnAfterEvent) => void;
|
|
7866
8590
|
/**
|
|
@@ -8256,6 +8980,58 @@ export class FluidContainer {
|
|
|
8256
8980
|
|
|
8257
8981
|
/**
|
|
8258
8982
|
* @beta
|
|
8983
|
+
* Contains information regarding a changed world.gameRules
|
|
8984
|
+
* property.
|
|
8985
|
+
*/
|
|
8986
|
+
export class GameRuleChangeAfterEvent {
|
|
8987
|
+
private constructor();
|
|
8988
|
+
/**
|
|
8989
|
+
* @remarks
|
|
8990
|
+
* The rule identifier pertaining to the changed
|
|
8991
|
+
* world.gameRules property.
|
|
8992
|
+
*
|
|
8993
|
+
*/
|
|
8994
|
+
readonly rule: GameRule;
|
|
8995
|
+
/**
|
|
8996
|
+
* @remarks
|
|
8997
|
+
* The value of the world.gameRules property after being
|
|
8998
|
+
* changed.
|
|
8999
|
+
*
|
|
9000
|
+
*/
|
|
9001
|
+
readonly value: boolean | number;
|
|
9002
|
+
}
|
|
9003
|
+
|
|
9004
|
+
/**
|
|
9005
|
+
* @beta
|
|
9006
|
+
* Manages callbacks that are connected to when a
|
|
9007
|
+
* world.gameRules property has changed.
|
|
9008
|
+
*/
|
|
9009
|
+
export class GameRuleChangeAfterEventSignal {
|
|
9010
|
+
private constructor();
|
|
9011
|
+
/**
|
|
9012
|
+
* @remarks
|
|
9013
|
+
* Adds a callback that will be called when a world.gameRules
|
|
9014
|
+
* property is changed.
|
|
9015
|
+
*
|
|
9016
|
+
* This function can't be called in read-only mode.
|
|
9017
|
+
*
|
|
9018
|
+
*/
|
|
9019
|
+
subscribe(callback: (arg: GameRuleChangeAfterEvent) => void): (arg: GameRuleChangeAfterEvent) => void;
|
|
9020
|
+
/**
|
|
9021
|
+
* @remarks
|
|
9022
|
+
* Removes a callback from being called when a world.gameRules
|
|
9023
|
+
* property is changed.
|
|
9024
|
+
*
|
|
9025
|
+
* This function can't be called in read-only mode.
|
|
9026
|
+
*
|
|
9027
|
+
* @throws This function can throw errors.
|
|
9028
|
+
*/
|
|
9029
|
+
unsubscribe(callback: (arg: GameRuleChangeAfterEvent) => void): void;
|
|
9030
|
+
}
|
|
9031
|
+
|
|
9032
|
+
/**
|
|
9033
|
+
* @beta
|
|
9034
|
+
* Represents the game rules for a world experience.
|
|
8259
9035
|
*/
|
|
8260
9036
|
export class GameRules {
|
|
8261
9037
|
private constructor();
|
|
@@ -8713,113 +9489,7 @@ export class ItemCooldownComponent extends ItemComponent {
|
|
|
8713
9489
|
*
|
|
8714
9490
|
* @throws This function can throw errors.
|
|
8715
9491
|
*/
|
|
8716
|
-
startCooldown(player: Player): void;
|
|
8717
|
-
}
|
|
8718
|
-
|
|
8719
|
-
/**
|
|
8720
|
-
* @beta
|
|
8721
|
-
* Manages callbacks that are connected to an item's definition
|
|
8722
|
-
* and components changing.
|
|
8723
|
-
*/
|
|
8724
|
-
export class ItemDefinitionAfterEventSignal {
|
|
8725
|
-
private constructor();
|
|
8726
|
-
/**
|
|
8727
|
-
* @remarks
|
|
8728
|
-
* Adds a callback that will be called when an item's
|
|
8729
|
-
* definition and components change.
|
|
8730
|
-
*
|
|
8731
|
-
* This function can't be called in read-only mode.
|
|
8732
|
-
*
|
|
8733
|
-
*/
|
|
8734
|
-
subscribe(
|
|
8735
|
-
callback: (arg: ItemDefinitionTriggeredAfterEvent) => void,
|
|
8736
|
-
): (arg: ItemDefinitionTriggeredAfterEvent) => void;
|
|
8737
|
-
/**
|
|
8738
|
-
* @remarks
|
|
8739
|
-
* Removes a callback from being called when an item's
|
|
8740
|
-
* definition and components change.
|
|
8741
|
-
*
|
|
8742
|
-
* This function can't be called in read-only mode.
|
|
8743
|
-
*
|
|
8744
|
-
* @throws This function can throw errors.
|
|
8745
|
-
*/
|
|
8746
|
-
unsubscribe(callback: (arg: ItemDefinitionTriggeredAfterEvent) => void): void;
|
|
8747
|
-
}
|
|
8748
|
-
|
|
8749
|
-
/**
|
|
8750
|
-
* @beta
|
|
8751
|
-
* Manages callbacks that are connected to an item's definition
|
|
8752
|
-
* and components changing.
|
|
8753
|
-
*/
|
|
8754
|
-
export class ItemDefinitionBeforeEventSignal {
|
|
8755
|
-
private constructor();
|
|
8756
|
-
/**
|
|
8757
|
-
* @remarks
|
|
8758
|
-
* Adds a callback that will be called when an item's
|
|
8759
|
-
* definition and components change.
|
|
8760
|
-
*
|
|
8761
|
-
* This function can't be called in read-only mode.
|
|
8762
|
-
*
|
|
8763
|
-
*/
|
|
8764
|
-
subscribe(
|
|
8765
|
-
callback: (arg: ItemDefinitionTriggeredBeforeEvent) => void,
|
|
8766
|
-
): (arg: ItemDefinitionTriggeredBeforeEvent) => void;
|
|
8767
|
-
/**
|
|
8768
|
-
* @remarks
|
|
8769
|
-
* Removes a callback from being called when an item's
|
|
8770
|
-
* definition and components change.
|
|
8771
|
-
*
|
|
8772
|
-
* This function can't be called in read-only mode.
|
|
8773
|
-
*
|
|
8774
|
-
* @throws This function can throw errors.
|
|
8775
|
-
*/
|
|
8776
|
-
unsubscribe(callback: (arg: ItemDefinitionTriggeredBeforeEvent) => void): void;
|
|
8777
|
-
}
|
|
8778
|
-
|
|
8779
|
-
/**
|
|
8780
|
-
* @beta
|
|
8781
|
-
* Contains information related to a custom item having a data
|
|
8782
|
-
* definition change being triggered.
|
|
8783
|
-
*/
|
|
8784
|
-
export class ItemDefinitionTriggeredAfterEvent {
|
|
8785
|
-
private constructor();
|
|
8786
|
-
/**
|
|
8787
|
-
* @remarks
|
|
8788
|
-
* Name of the data-driven item event that is triggering this
|
|
8789
|
-
* change.
|
|
8790
|
-
*
|
|
8791
|
-
*/
|
|
8792
|
-
readonly eventName: string;
|
|
8793
|
-
/**
|
|
8794
|
-
* @remarks
|
|
8795
|
-
* Related item stack that the definitional change has been
|
|
8796
|
-
* triggered upon.
|
|
8797
|
-
*
|
|
8798
|
-
*/
|
|
8799
|
-
itemStack: ItemStack;
|
|
8800
|
-
/**
|
|
8801
|
-
* @remarks
|
|
8802
|
-
* Returns the source entity that triggered this item event.
|
|
8803
|
-
*
|
|
8804
|
-
*/
|
|
8805
|
-
readonly source?: Player;
|
|
8806
|
-
}
|
|
8807
|
-
|
|
8808
|
-
/**
|
|
8809
|
-
* @beta
|
|
8810
|
-
* Contains information related to a triggering of a custom
|
|
8811
|
-
* item definition change.
|
|
8812
|
-
*/
|
|
8813
|
-
// @ts-ignore Class inheritance allowed for native defined classes
|
|
8814
|
-
export class ItemDefinitionTriggeredBeforeEvent extends ItemDefinitionTriggeredAfterEvent {
|
|
8815
|
-
private constructor();
|
|
8816
|
-
/**
|
|
8817
|
-
* @remarks
|
|
8818
|
-
* If set to true, will cancel the application of this item
|
|
8819
|
-
* definition change.
|
|
8820
|
-
*
|
|
8821
|
-
*/
|
|
8822
|
-
cancel: boolean;
|
|
9492
|
+
startCooldown(player: Player): void;
|
|
8823
9493
|
}
|
|
8824
9494
|
|
|
8825
9495
|
/**
|
|
@@ -8851,19 +9521,23 @@ export class ItemDurabilityComponent extends ItemComponent {
|
|
|
8851
9521
|
/**
|
|
8852
9522
|
* @remarks
|
|
8853
9523
|
* Returns the maximum chance that this item would be damaged
|
|
8854
|
-
* using the damageRange property, given an unbreaking
|
|
9524
|
+
* using the damageRange property, given an unbreaking
|
|
9525
|
+
* enchantment level.
|
|
8855
9526
|
*
|
|
8856
9527
|
* This function can't be called in read-only mode.
|
|
8857
9528
|
*
|
|
9529
|
+
* @param unbreakingEnchantmentLevel
|
|
9530
|
+
* Unbreaking factor to consider in factoring the damage
|
|
9531
|
+
* chance. Incoming unbreaking parameter must be within the
|
|
9532
|
+
* range [0, 3].
|
|
8858
9533
|
* @throws This function can throw errors.
|
|
8859
9534
|
*/
|
|
8860
9535
|
getDamageChance(unbreakingEnchantmentLevel?: number): number;
|
|
8861
9536
|
/**
|
|
8862
9537
|
* @remarks
|
|
8863
|
-
*
|
|
8864
|
-
*
|
|
8865
|
-
*
|
|
8866
|
-
*
|
|
9538
|
+
* A range of numbers that is used to calculate the damage
|
|
9539
|
+
* chance for an item. The damage chance will fall within this
|
|
9540
|
+
* range.
|
|
8867
9541
|
*
|
|
8868
9542
|
* This function can't be called in read-only mode.
|
|
8869
9543
|
*
|
|
@@ -8876,6 +9550,27 @@ export class ItemDurabilityComponent extends ItemComponent {
|
|
|
8876
9550
|
* @beta
|
|
8877
9551
|
* When present on an item, this item can have enchantments
|
|
8878
9552
|
* applied to it.
|
|
9553
|
+
* @example givePlayerIronFireSword.ts
|
|
9554
|
+
* ```typescript
|
|
9555
|
+
* // Spawns a bunch of item stacks
|
|
9556
|
+
* import { ItemComponentTypes, ItemStack, Player } from '@minecraft/server';
|
|
9557
|
+
* import { MinecraftItemTypes, MinecraftEnchantmentTypes } from '@minecraft/vanilla-data';
|
|
9558
|
+
*
|
|
9559
|
+
* function giveFireSword(player: Player) {
|
|
9560
|
+
* const ironFireSword = new ItemStack(MinecraftItemTypes.DiamondSword, 1);
|
|
9561
|
+
*
|
|
9562
|
+
* const enchantments = ironFireSword?.getComponent(ItemComponentTypes.Enchantable);
|
|
9563
|
+
* if (enchantments) {
|
|
9564
|
+
* enchantments.addEnchantment({ type: MinecraftEnchantmentTypes.FireAspect, level: 1 });
|
|
9565
|
+
* }
|
|
9566
|
+
*
|
|
9567
|
+
* const inventory = player.getComponent('minecraft:inventory');
|
|
9568
|
+
* if (inventory === undefined || inventory.container === undefined) {
|
|
9569
|
+
* return;
|
|
9570
|
+
* }
|
|
9571
|
+
* inventory.container.setItem(0, ironFireSword);
|
|
9572
|
+
* }
|
|
9573
|
+
* ```
|
|
8879
9574
|
*/
|
|
8880
9575
|
// @ts-ignore Class inheritance allowed for native defined classes
|
|
8881
9576
|
export class ItemEnchantableComponent extends ItemComponent {
|
|
@@ -9137,6 +9832,58 @@ export class ItemReleaseUseAfterEventSignal {
|
|
|
9137
9832
|
|
|
9138
9833
|
/**
|
|
9139
9834
|
* Defines a collection of items.
|
|
9835
|
+
* @example givePlayerIronFireSword.ts
|
|
9836
|
+
* ```typescript
|
|
9837
|
+
* // Spawns a bunch of item stacks
|
|
9838
|
+
* import { ItemComponentTypes, ItemStack, Player } from '@minecraft/server';
|
|
9839
|
+
* import { MinecraftItemTypes, MinecraftEnchantmentTypes } from '@minecraft/vanilla-data';
|
|
9840
|
+
*
|
|
9841
|
+
* function giveFireSword(player: Player) {
|
|
9842
|
+
* const ironFireSword = new ItemStack(MinecraftItemTypes.DiamondSword, 1);
|
|
9843
|
+
*
|
|
9844
|
+
* const enchantments = ironFireSword?.getComponent(ItemComponentTypes.Enchantable);
|
|
9845
|
+
* if (enchantments) {
|
|
9846
|
+
* enchantments.addEnchantment({ type: MinecraftEnchantmentTypes.FireAspect, level: 1 });
|
|
9847
|
+
* }
|
|
9848
|
+
*
|
|
9849
|
+
* const inventory = player.getComponent('minecraft:inventory');
|
|
9850
|
+
* if (inventory === undefined || inventory.container === undefined) {
|
|
9851
|
+
* return;
|
|
9852
|
+
* }
|
|
9853
|
+
* inventory.container.setItem(0, ironFireSword);
|
|
9854
|
+
* }
|
|
9855
|
+
* ```
|
|
9856
|
+
* @example givePlayerEquipment.ts
|
|
9857
|
+
* ```typescript
|
|
9858
|
+
* // Gives the player some equipment
|
|
9859
|
+
* import { EquipmentSlot, ItemStack, Player, EntityComponentTypes } from '@minecraft/server';
|
|
9860
|
+
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
|
|
9861
|
+
*
|
|
9862
|
+
* function giveEquipment(player: Player) {
|
|
9863
|
+
* const equipmentCompPlayer = player.getComponent(EntityComponentTypes.Equippable);
|
|
9864
|
+
* if (equipmentCompPlayer) {
|
|
9865
|
+
* equipmentCompPlayer.setEquipment(EquipmentSlot.Head, new ItemStack(MinecraftItemTypes.GoldenHelmet));
|
|
9866
|
+
* equipmentCompPlayer.setEquipment(EquipmentSlot.Chest, new ItemStack(MinecraftItemTypes.IronChestplate));
|
|
9867
|
+
* equipmentCompPlayer.setEquipment(EquipmentSlot.Legs, new ItemStack(MinecraftItemTypes.DiamondLeggings));
|
|
9868
|
+
* equipmentCompPlayer.setEquipment(EquipmentSlot.Feet, new ItemStack(MinecraftItemTypes.NetheriteBoots));
|
|
9869
|
+
* equipmentCompPlayer.setEquipment(EquipmentSlot.Mainhand, new ItemStack(MinecraftItemTypes.WoodenSword));
|
|
9870
|
+
* equipmentCompPlayer.setEquipment(EquipmentSlot.Offhand, new ItemStack(MinecraftItemTypes.Shield));
|
|
9871
|
+
* } else {
|
|
9872
|
+
* console.warn('No equipment component found on player');
|
|
9873
|
+
* }
|
|
9874
|
+
* }
|
|
9875
|
+
* ```
|
|
9876
|
+
* @example spawnFeatherItem.ts
|
|
9877
|
+
* ```typescript
|
|
9878
|
+
* // Spawns a feather at a location
|
|
9879
|
+
* import { ItemStack, DimensionLocation } from '@minecraft/server';
|
|
9880
|
+
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
|
|
9881
|
+
*
|
|
9882
|
+
* function spawnFeather(location: DimensionLocation) {
|
|
9883
|
+
* const featherItem = new ItemStack(MinecraftItemTypes.Feather, 1);
|
|
9884
|
+
* location.dimension.spawnItem(featherItem, location);
|
|
9885
|
+
* }
|
|
9886
|
+
* ```
|
|
9140
9887
|
*/
|
|
9141
9888
|
export class ItemStack {
|
|
9142
9889
|
/**
|
|
@@ -9279,10 +10026,24 @@ export class ItemStack {
|
|
|
9279
10026
|
* otherwise undefined.
|
|
9280
10027
|
* @example durability.ts
|
|
9281
10028
|
* ```typescript
|
|
9282
|
-
* //
|
|
9283
|
-
*
|
|
9284
|
-
*
|
|
9285
|
-
*
|
|
10029
|
+
* // Gives a player a half-damaged diamond sword
|
|
10030
|
+
* import { ItemStack, Player, ItemComponentTypes, EntityComponentTypes } from '@minecraft/server';
|
|
10031
|
+
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
|
|
10032
|
+
*
|
|
10033
|
+
* function giveHurtDiamondSword(player: Player) {
|
|
10034
|
+
* const hurtDiamondSword = new ItemStack(MinecraftItemTypes.DiamondSword);
|
|
10035
|
+
* const durabilityComponent = hurtDiamondSword.getComponent(ItemComponentTypes.Durability);
|
|
10036
|
+
* if (durabilityComponent !== undefined) {
|
|
10037
|
+
* durabilityComponent.damage = durabilityComponent.maxDurability / 2;
|
|
10038
|
+
* }
|
|
10039
|
+
*
|
|
10040
|
+
* const inventory = player.getComponent(EntityComponentTypes.Inventory);
|
|
10041
|
+
* if (inventory === undefined || inventory.container === undefined) {
|
|
10042
|
+
* return;
|
|
10043
|
+
* }
|
|
10044
|
+
*
|
|
10045
|
+
* inventory.container.addItem(hurtDiamondSword);
|
|
10046
|
+
* }
|
|
9286
10047
|
* ```
|
|
9287
10048
|
*/
|
|
9288
10049
|
getComponent<T extends keyof ItemComponentTypeMap>(componentId: T): ItemComponentTypeMap[T] | undefined;
|
|
@@ -9383,6 +10144,17 @@ export class ItemStack {
|
|
|
9383
10144
|
isStackableWith(itemStack: ItemStack): boolean;
|
|
9384
10145
|
/**
|
|
9385
10146
|
* @beta
|
|
10147
|
+
* @remarks
|
|
10148
|
+
* Version safe way of checking if an item matches.
|
|
10149
|
+
*
|
|
10150
|
+
* @param itemName
|
|
10151
|
+
* Identifier of the item.
|
|
10152
|
+
* @param states
|
|
10153
|
+
* Applicable only for blocks. An optional set of states to
|
|
10154
|
+
* compare against. If states is not specified, matches checks
|
|
10155
|
+
* against the set of types more broadly.
|
|
10156
|
+
* @returns
|
|
10157
|
+
* Returns a boolean whether the specified item matches.
|
|
9386
10158
|
*/
|
|
9387
10159
|
matches(itemName: string, states?: Record<string, boolean | number | string>): boolean;
|
|
9388
10160
|
/**
|
|
@@ -9399,9 +10171,24 @@ export class ItemStack {
|
|
|
9399
10171
|
* Throws if any of the provided block identifiers are invalid.
|
|
9400
10172
|
* @example example.ts
|
|
9401
10173
|
* ```typescript
|
|
10174
|
+
* const specialPickaxe = new ItemStack('minecraft:diamond_pickaxe');
|
|
10175
|
+
* specialPickaxe.setCanDestroy(['minecraft:cobblestone', 'minecraft:obsidian']);
|
|
10176
|
+
*
|
|
9402
10177
|
* // Creates a diamond pickaxe that can destroy cobblestone and obsidian
|
|
9403
|
-
*
|
|
9404
|
-
*
|
|
10178
|
+
* import { ItemStack, Player } from '@minecraft/server';
|
|
10179
|
+
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
|
|
10180
|
+
*
|
|
10181
|
+
* function giveRestrictedPickaxe(player: Player) {
|
|
10182
|
+
* const specialPickaxe = new ItemStack(MinecraftItemTypes.DiamondPickaxe);
|
|
10183
|
+
* specialPickaxe.setCanPlaceOn([MinecraftItemTypes.Cobblestone, MinecraftItemTypes.Obsidian]);
|
|
10184
|
+
*
|
|
10185
|
+
* const inventory = player.getComponent('inventory');
|
|
10186
|
+
* if (inventory === undefined || inventory.container === undefined) {
|
|
10187
|
+
* return;
|
|
10188
|
+
* }
|
|
10189
|
+
*
|
|
10190
|
+
* inventory.container.addItem(specialPickaxe);
|
|
10191
|
+
* }
|
|
9405
10192
|
* ```
|
|
9406
10193
|
*/
|
|
9407
10194
|
setCanDestroy(blockIdentifiers?: string[]): void;
|
|
@@ -9421,8 +10208,20 @@ export class ItemStack {
|
|
|
9421
10208
|
* @example example.ts
|
|
9422
10209
|
* ```typescript
|
|
9423
10210
|
* // Creates a gold block that can be placed on grass and dirt
|
|
9424
|
-
*
|
|
9425
|
-
*
|
|
10211
|
+
* import { ItemStack, Player, EntityComponentTypes } from '@minecraft/server';
|
|
10212
|
+
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
|
|
10213
|
+
*
|
|
10214
|
+
* function giveRestrictedGoldBlock(player: Player) {
|
|
10215
|
+
* const specialGoldBlock = new ItemStack(MinecraftItemTypes.GoldBlock);
|
|
10216
|
+
* specialGoldBlock.setCanPlaceOn([MinecraftItemTypes.Grass, MinecraftItemTypes.Dirt]);
|
|
10217
|
+
*
|
|
10218
|
+
* const inventory = player.getComponent(EntityComponentTypes.Inventory);
|
|
10219
|
+
* if (inventory === undefined || inventory.container === undefined) {
|
|
10220
|
+
* return;
|
|
10221
|
+
* }
|
|
10222
|
+
*
|
|
10223
|
+
* inventory.container.addItem(specialGoldBlock);
|
|
10224
|
+
* }
|
|
9426
10225
|
* ```
|
|
9427
10226
|
*/
|
|
9428
10227
|
setCanPlaceOn(blockIdentifiers?: string[]): void;
|
|
@@ -9455,45 +10254,27 @@ export class ItemStack {
|
|
|
9455
10254
|
* @throws This function can throw errors.
|
|
9456
10255
|
* @example diamondAwesomeSword.ts
|
|
9457
10256
|
* ```typescript
|
|
9458
|
-
*
|
|
9459
|
-
*
|
|
9460
|
-
*
|
|
9461
|
-
*
|
|
9462
|
-
*
|
|
9463
|
-
*
|
|
9464
|
-
*
|
|
9465
|
-
*
|
|
9466
|
-
*
|
|
9467
|
-
*
|
|
10257
|
+
* import { EntityComponentTypes, ItemStack, Player } from '@minecraft/server';
|
|
10258
|
+
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
|
|
10259
|
+
*
|
|
10260
|
+
* function giveAwesomeSword(player: Player) {
|
|
10261
|
+
* const diamondAwesomeSword = new ItemStack(MinecraftItemTypes.DiamondSword, 1);
|
|
10262
|
+
* diamondAwesomeSword.setLore([
|
|
10263
|
+
* '§c§lDiamond Sword of Awesome§r',
|
|
10264
|
+
* '+10 coolness', '§p+4 shiny§r'
|
|
10265
|
+
* ]);
|
|
10266
|
+
*
|
|
10267
|
+
* // hover over/select the item in your inventory to see the lore.
|
|
10268
|
+
* const inventory = player.getComponent(EntityComponentTypes.Inventory);
|
|
10269
|
+
* if (inventory === undefined || inventory.container === undefined) {
|
|
10270
|
+
* return;
|
|
10271
|
+
* }
|
|
9468
10272
|
*
|
|
9469
|
-
*
|
|
9470
|
-
*
|
|
9471
|
-
* let knockbackEnchant = new mc.Enchantment("knockback", 3);
|
|
9472
|
-
* enchants.enchantments.addEnchantment(knockbackEnchant);
|
|
9473
|
-
* }
|
|
9474
|
-
* ```
|
|
9475
|
-
* @example multilineLore.ts
|
|
9476
|
-
* ```typescript
|
|
9477
|
-
* // Set the lore of an item to multiple lines of text
|
|
9478
|
-
* const itemStack = new ItemStack("minecraft:diamond_sword");
|
|
9479
|
-
* itemStack.setLore(["Line 1", "Line 2", "Line 3"]);
|
|
10273
|
+
* inventory.container.setItem(0, diamondAwesomeSword);
|
|
10274
|
+
* }
|
|
9480
10275
|
* ```
|
|
9481
10276
|
*/
|
|
9482
10277
|
setLore(loreList?: string[]): void;
|
|
9483
|
-
/**
|
|
9484
|
-
* @beta
|
|
9485
|
-
* @remarks
|
|
9486
|
-
* Triggers an item type event. For custom items, a number of
|
|
9487
|
-
* events are defined in an items' definition for key item
|
|
9488
|
-
* behaviors.
|
|
9489
|
-
*
|
|
9490
|
-
* This function can't be called in read-only mode.
|
|
9491
|
-
*
|
|
9492
|
-
* @param eventName
|
|
9493
|
-
* Name of the item type event to trigger. If a namespace is
|
|
9494
|
-
* not specified, minecraft: is assumed.
|
|
9495
|
-
*/
|
|
9496
|
-
triggerEvent(eventName: string): void;
|
|
9497
10278
|
}
|
|
9498
10279
|
|
|
9499
10280
|
/**
|
|
@@ -9961,6 +10742,17 @@ export class ItemUseOnBeforeEventSignal {
|
|
|
9961
10742
|
/**
|
|
9962
10743
|
* Contains information related to changes to a lever
|
|
9963
10744
|
* activating or deactivating.
|
|
10745
|
+
* @example leverActionEvent.ts
|
|
10746
|
+
* ```typescript
|
|
10747
|
+
* import { world, system, LeverActionAfterEvent } from '@minecraft/server';
|
|
10748
|
+
*
|
|
10749
|
+
* world.afterEvents.leverAction.subscribe((leverActivateEvent: LeverActionAfterEvent) => {
|
|
10750
|
+
* console.warn(
|
|
10751
|
+
* `Lever event at ${system.currentTick} with power: ${leverActivateEvent.block.getRedstonePower()}`,
|
|
10752
|
+
* );
|
|
10753
|
+
* });
|
|
10754
|
+
*
|
|
10755
|
+
* ```
|
|
9964
10756
|
*/
|
|
9965
10757
|
// @ts-ignore Class inheritance allowed for native defined classes
|
|
9966
10758
|
export class LeverActionAfterEvent extends BlockEvent {
|
|
@@ -9983,6 +10775,17 @@ export class LeverActionAfterEvent extends BlockEvent {
|
|
|
9983
10775
|
/**
|
|
9984
10776
|
* Manages callbacks that are connected to lever moves
|
|
9985
10777
|
* (activates or deactivates).
|
|
10778
|
+
* @example leverActionEvent.ts
|
|
10779
|
+
* ```typescript
|
|
10780
|
+
* import { world, system, LeverActionAfterEvent } from '@minecraft/server';
|
|
10781
|
+
*
|
|
10782
|
+
* world.afterEvents.leverAction.subscribe((leverActivateEvent: LeverActionAfterEvent) => {
|
|
10783
|
+
* console.warn(
|
|
10784
|
+
* `Lever event at ${system.currentTick} with power: ${leverActivateEvent.block.getRedstonePower()}`,
|
|
10785
|
+
* );
|
|
10786
|
+
* });
|
|
10787
|
+
*
|
|
10788
|
+
* ```
|
|
9986
10789
|
*/
|
|
9987
10790
|
// @ts-ignore Class inheritance allowed for native defined classes
|
|
9988
10791
|
export class LeverActionAfterEventSignal extends ILeverActionAfterEventSignal {
|
|
@@ -10130,6 +10933,16 @@ export class MolangVariableMap {
|
|
|
10130
10933
|
* @beta
|
|
10131
10934
|
* Contains information related to changes to a piston
|
|
10132
10935
|
* expanding or retracting.
|
|
10936
|
+
* @example pistonAfterEvent.ts
|
|
10937
|
+
* ```typescript
|
|
10938
|
+
* import { world, system, PistonActivateAfterEvent } from '@minecraft/server';
|
|
10939
|
+
*
|
|
10940
|
+
* world.afterEvents.pistonActivate.subscribe((pistonEvent: PistonActivateAfterEvent) => {
|
|
10941
|
+
* console.warn(
|
|
10942
|
+
* `Piston event at ${system.currentTick} ${(pistonEvent.piston.isMoving ? ' Moving' : 'Not moving')} with state: ${pistonEvent.piston.state}`,
|
|
10943
|
+
* );
|
|
10944
|
+
* });
|
|
10945
|
+
* ```
|
|
10133
10946
|
*/
|
|
10134
10947
|
// @ts-ignore Class inheritance allowed for native defined classes
|
|
10135
10948
|
export class PistonActivateAfterEvent extends BlockEvent {
|
|
@@ -10151,58 +10964,23 @@ export class PistonActivateAfterEvent extends BlockEvent {
|
|
|
10151
10964
|
/**
|
|
10152
10965
|
* @beta
|
|
10153
10966
|
* Manages callbacks that are connected to piston activations.
|
|
10967
|
+
* @example pistonAfterEvent.ts
|
|
10968
|
+
* ```typescript
|
|
10969
|
+
* import { world, system, PistonActivateAfterEvent } from '@minecraft/server';
|
|
10970
|
+
*
|
|
10971
|
+
* world.afterEvents.pistonActivate.subscribe((pistonEvent: PistonActivateAfterEvent) => {
|
|
10972
|
+
* console.warn(
|
|
10973
|
+
* `Piston event at ${system.currentTick} ${(pistonEvent.piston.isMoving ? ' Moving' : 'Not moving')} with state: ${pistonEvent.piston.state}`,
|
|
10974
|
+
* );
|
|
10975
|
+
* });
|
|
10976
|
+
* ```
|
|
10154
10977
|
*/
|
|
10155
10978
|
export class PistonActivateAfterEventSignal {
|
|
10156
10979
|
private constructor();
|
|
10157
10980
|
/**
|
|
10158
10981
|
* @remarks
|
|
10159
|
-
* Adds a callback that will be called when a piston expands or
|
|
10160
|
-
* retracts.
|
|
10161
|
-
*
|
|
10162
10982
|
* This function can't be called in read-only mode.
|
|
10163
10983
|
*
|
|
10164
|
-
* @example pistonAfterEvent.ts
|
|
10165
|
-
* ```typescript
|
|
10166
|
-
* // set up a couple of piston blocks
|
|
10167
|
-
* let piston = overworld.getBlock(targetLocation);
|
|
10168
|
-
* let button = overworld.getBlock({
|
|
10169
|
-
* x: targetLocation.x,
|
|
10170
|
-
* y: targetLocation.y + 1,
|
|
10171
|
-
* z: targetLocation.z,
|
|
10172
|
-
* });
|
|
10173
|
-
*
|
|
10174
|
-
* if (piston === undefined || button === undefined) {
|
|
10175
|
-
* log("Could not find block at location.");
|
|
10176
|
-
* return -1;
|
|
10177
|
-
* }
|
|
10178
|
-
*
|
|
10179
|
-
* piston.setPermutation(
|
|
10180
|
-
* mc.BlockPermutation.resolve("piston").withState("facing_direction", 3)
|
|
10181
|
-
* );
|
|
10182
|
-
* button.setPermutation(
|
|
10183
|
-
* mc.BlockPermutation.resolve("acacia_button").withState("facing_direction", 1)
|
|
10184
|
-
* );
|
|
10185
|
-
*
|
|
10186
|
-
* mc.world.afterEvents.pistonActivate.subscribe(
|
|
10187
|
-
* (pistonEvent: mc.PistonActivateAfterEvent) => {
|
|
10188
|
-
* let eventLoc = pistonEvent.piston.block.location;
|
|
10189
|
-
*
|
|
10190
|
-
* if (
|
|
10191
|
-
* eventLoc.x === targetLocation.x &&
|
|
10192
|
-
* eventLoc.y === targetLocation.y &&
|
|
10193
|
-
* eventLoc.z === targetLocation.z
|
|
10194
|
-
* ) {
|
|
10195
|
-
* log(
|
|
10196
|
-
* "Piston event at " +
|
|
10197
|
-
* mc.system.currentTick +
|
|
10198
|
-
* (pistonEvent.piston.isMoving ? " Moving" : "") +
|
|
10199
|
-
* " State: " +
|
|
10200
|
-
* pistonEvent.piston.state
|
|
10201
|
-
* );
|
|
10202
|
-
* }
|
|
10203
|
-
* }
|
|
10204
|
-
* );
|
|
10205
|
-
* ```
|
|
10206
10984
|
*/
|
|
10207
10985
|
subscribe(callback: (arg: PistonActivateAfterEvent) => void): (arg: PistonActivateAfterEvent) => void;
|
|
10208
10986
|
/**
|
|
@@ -10350,6 +11128,11 @@ export class Player extends Entity {
|
|
|
10350
11128
|
* Throws if the item is not a food item.
|
|
10351
11129
|
*/
|
|
10352
11130
|
eatItem(itemStack: ItemStack): void;
|
|
11131
|
+
/**
|
|
11132
|
+
* @beta
|
|
11133
|
+
* @throws This function can throw errors.
|
|
11134
|
+
*/
|
|
11135
|
+
getGameMode(): GameMode;
|
|
10353
11136
|
/**
|
|
10354
11137
|
* @beta
|
|
10355
11138
|
* @remarks
|
|
@@ -10408,30 +11191,6 @@ export class Player extends Entity {
|
|
|
10408
11191
|
* @param soundOptions
|
|
10409
11192
|
* Additional optional options for the sound.
|
|
10410
11193
|
* @throws This function can throw errors.
|
|
10411
|
-
* @example playMusicAndSound.ts
|
|
10412
|
-
* ```typescript
|
|
10413
|
-
* let players = mc.world.getPlayers();
|
|
10414
|
-
*
|
|
10415
|
-
* const musicOptions: mc.MusicOptions = {
|
|
10416
|
-
* fade: 0.5,
|
|
10417
|
-
* loop: true,
|
|
10418
|
-
* volume: 1.0,
|
|
10419
|
-
* };
|
|
10420
|
-
* mc.world.playMusic("music.menu", musicOptions);
|
|
10421
|
-
*
|
|
10422
|
-
* const worldSoundOptions: mc.WorldSoundOptions = {
|
|
10423
|
-
* pitch: 0.5,
|
|
10424
|
-
* volume: 4.0,
|
|
10425
|
-
* };
|
|
10426
|
-
* mc.world.playSound("ambient.weather.thunder", targetLocation, worldSoundOptions);
|
|
10427
|
-
*
|
|
10428
|
-
* const playerSoundOptions: mc.PlayerSoundOptions = {
|
|
10429
|
-
* pitch: 1.0,
|
|
10430
|
-
* volume: 1.0,
|
|
10431
|
-
* };
|
|
10432
|
-
*
|
|
10433
|
-
* players[0].playSound("bucket.fill_water", playerSoundOptions);
|
|
10434
|
-
* ```
|
|
10435
11194
|
*/
|
|
10436
11195
|
playSound(soundId: string, soundOptions?: PlayerSoundOptions): void;
|
|
10437
11196
|
/**
|
|
@@ -10483,46 +11242,43 @@ export class Player extends Entity {
|
|
|
10483
11242
|
* This method can throw if the provided {@link RawMessage} is
|
|
10484
11243
|
* in an invalid format. For example, if an empty `name` string
|
|
10485
11244
|
* is provided to `score`.
|
|
10486
|
-
* @example
|
|
11245
|
+
* @example sendMessagesToPlayer.ts
|
|
10487
11246
|
* ```typescript
|
|
10488
|
-
*
|
|
10489
|
-
* let rawMessage = {
|
|
10490
|
-
* translate: "accessibility.list.or.two",
|
|
10491
|
-
* with: { rawtext: [{ translate: "item.apple.name" }, { translate: "item.coal.name" }] },
|
|
10492
|
-
* };
|
|
10493
|
-
* player.sendMessage(rawMessage);
|
|
10494
|
-
* ```
|
|
10495
|
-
* @example scoreWildcard.ts
|
|
10496
|
-
* ```typescript
|
|
10497
|
-
* // Displays the player's score for objective "obj". Each player will see their own score.
|
|
10498
|
-
* const rawMessage = { score: { name: "*", objective: "obj" } };
|
|
10499
|
-
* world.sendMessage(rawMessage);
|
|
10500
|
-
* ```
|
|
10501
|
-
* @example sendBasicMessage.ts
|
|
10502
|
-
* ```typescript
|
|
10503
|
-
* let players = mc.world.getPlayers();
|
|
11247
|
+
* import { Player } from "@minecraft/server";
|
|
10504
11248
|
*
|
|
10505
|
-
*
|
|
10506
|
-
*
|
|
10507
|
-
*
|
|
10508
|
-
*
|
|
10509
|
-
* let players = mc.world.getPlayers();
|
|
11249
|
+
* function sendPlayerMessages(player: Player) {
|
|
11250
|
+
* // Displays "First or Second"
|
|
11251
|
+
* const rawMessage = { translate: 'accessibility.list.or.two', with: ['First', 'Second'] };
|
|
11252
|
+
* player.sendMessage(rawMessage);
|
|
10510
11253
|
*
|
|
10511
|
-
*
|
|
10512
|
-
*
|
|
10513
|
-
*
|
|
10514
|
-
*
|
|
10515
|
-
*
|
|
10516
|
-
*
|
|
10517
|
-
*
|
|
10518
|
-
*
|
|
10519
|
-
*
|
|
10520
|
-
*
|
|
10521
|
-
*
|
|
10522
|
-
*
|
|
11254
|
+
* // Displays "Hello, world!"
|
|
11255
|
+
* player.sendMessage('Hello, world!');
|
|
11256
|
+
*
|
|
11257
|
+
* // Displays "Welcome, Amazing Player 1!"
|
|
11258
|
+
* player.sendMessage({ translate: 'authentication.welcome', with: ['Amazing Player 1'] });
|
|
11259
|
+
*
|
|
11260
|
+
* // Displays the player's score for objective "obj". Each player will see their own score.
|
|
11261
|
+
* const rawMessageWithScore = { score: { name: '*', objective: 'obj' } };
|
|
11262
|
+
* player.sendMessage(rawMessageWithScore);
|
|
11263
|
+
*
|
|
11264
|
+
* // Displays "Apple or Coal"
|
|
11265
|
+
* const rawMessageWithNestedTranslations = {
|
|
11266
|
+
* translate: 'accessibility.list.or.two',
|
|
11267
|
+
* with: { rawtext: [{ translate: 'item.apple.name' }, { translate: 'item.coal.name' }] },
|
|
11268
|
+
* };
|
|
11269
|
+
* player.sendMessage(rawMessageWithNestedTranslations);
|
|
11270
|
+
* }
|
|
10523
11271
|
* ```
|
|
10524
11272
|
*/
|
|
10525
11273
|
sendMessage(message: (RawMessage | string)[] | RawMessage | string): void;
|
|
11274
|
+
/**
|
|
11275
|
+
* @beta
|
|
11276
|
+
* @remarks
|
|
11277
|
+
* This function can't be called in read-only mode.
|
|
11278
|
+
*
|
|
11279
|
+
* @throws This function can throw errors.
|
|
11280
|
+
*/
|
|
11281
|
+
setGameMode(gameMode?: GameMode): void;
|
|
10526
11282
|
/**
|
|
10527
11283
|
* @beta
|
|
10528
11284
|
* @remarks
|
|
@@ -10572,23 +11328,27 @@ export class Player extends Entity {
|
|
|
10572
11328
|
* {@link LocationOutOfWorldBoundariesError}
|
|
10573
11329
|
* @example spawnParticle.ts
|
|
10574
11330
|
* ```typescript
|
|
10575
|
-
*
|
|
10576
|
-
*
|
|
10577
|
-
*
|
|
10578
|
-
*
|
|
10579
|
-
*
|
|
10580
|
-
*
|
|
10581
|
-
*
|
|
10582
|
-
*
|
|
10583
|
-
*
|
|
10584
|
-
*
|
|
10585
|
-
*
|
|
10586
|
-
*
|
|
10587
|
-
*
|
|
10588
|
-
*
|
|
10589
|
-
*
|
|
10590
|
-
*
|
|
10591
|
-
*
|
|
11331
|
+
* import { world, MolangVariableMap, Vector3 } from '@minecraft/server';
|
|
11332
|
+
*
|
|
11333
|
+
* world.afterEvents.playerSpawn.subscribe(event => {
|
|
11334
|
+
* const targetLocation = event.player.location;
|
|
11335
|
+
* for (let i = 0; i < 100; i++) {
|
|
11336
|
+
* const molang = new MolangVariableMap();
|
|
11337
|
+
*
|
|
11338
|
+
* molang.setColorRGB('variable.color', {
|
|
11339
|
+
* red: Math.random(),
|
|
11340
|
+
* green: Math.random(),
|
|
11341
|
+
* blue: Math.random()
|
|
11342
|
+
* });
|
|
11343
|
+
*
|
|
11344
|
+
* const newLocation: Vector3 = {
|
|
11345
|
+
* x: targetLocation.x + Math.floor(Math.random() * 8) - 4,
|
|
11346
|
+
* y: targetLocation.y + Math.floor(Math.random() * 8) - 4,
|
|
11347
|
+
* z: targetLocation.z + Math.floor(Math.random() * 8) - 4,
|
|
11348
|
+
* };
|
|
11349
|
+
* event.player.spawnParticle('minecraft:colored_flame_particle', newLocation, molang);
|
|
11350
|
+
* }
|
|
11351
|
+
* });
|
|
10592
11352
|
* ```
|
|
10593
11353
|
*/
|
|
10594
11354
|
spawnParticle(effectName: string, location: Vector3, molangVariables?: MolangVariableMap): void;
|
|
@@ -10811,6 +11571,67 @@ export class PlayerDimensionChangeAfterEventSignal {
|
|
|
10811
11571
|
unsubscribe(callback: (arg: PlayerDimensionChangeAfterEvent) => void): void;
|
|
10812
11572
|
}
|
|
10813
11573
|
|
|
11574
|
+
/**
|
|
11575
|
+
* @beta
|
|
11576
|
+
*/
|
|
11577
|
+
export class PlayerGameModeChangeAfterEvent {
|
|
11578
|
+
private constructor();
|
|
11579
|
+
readonly fromGameMode: GameMode;
|
|
11580
|
+
readonly player: Player;
|
|
11581
|
+
readonly toGameMode: GameMode;
|
|
11582
|
+
}
|
|
11583
|
+
|
|
11584
|
+
/**
|
|
11585
|
+
* @beta
|
|
11586
|
+
*/
|
|
11587
|
+
export class PlayerGameModeChangeAfterEventSignal {
|
|
11588
|
+
private constructor();
|
|
11589
|
+
/**
|
|
11590
|
+
* @remarks
|
|
11591
|
+
* This function can't be called in read-only mode.
|
|
11592
|
+
*
|
|
11593
|
+
*/
|
|
11594
|
+
subscribe(callback: (arg: PlayerGameModeChangeAfterEvent) => void): (arg: PlayerGameModeChangeAfterEvent) => void;
|
|
11595
|
+
/**
|
|
11596
|
+
* @remarks
|
|
11597
|
+
* This function can't be called in read-only mode.
|
|
11598
|
+
*
|
|
11599
|
+
* @throws This function can throw errors.
|
|
11600
|
+
*/
|
|
11601
|
+
unsubscribe(callback: (arg: PlayerGameModeChangeAfterEvent) => void): void;
|
|
11602
|
+
}
|
|
11603
|
+
|
|
11604
|
+
/**
|
|
11605
|
+
* @beta
|
|
11606
|
+
*/
|
|
11607
|
+
export class PlayerGameModeChangeBeforeEvent {
|
|
11608
|
+
private constructor();
|
|
11609
|
+
cancel: boolean;
|
|
11610
|
+
readonly fromGameMode: GameMode;
|
|
11611
|
+
readonly player: Player;
|
|
11612
|
+
toGameMode: GameMode;
|
|
11613
|
+
}
|
|
11614
|
+
|
|
11615
|
+
/**
|
|
11616
|
+
* @beta
|
|
11617
|
+
*/
|
|
11618
|
+
export class PlayerGameModeChangeBeforeEventSignal {
|
|
11619
|
+
private constructor();
|
|
11620
|
+
/**
|
|
11621
|
+
* @remarks
|
|
11622
|
+
* This function can't be called in read-only mode.
|
|
11623
|
+
*
|
|
11624
|
+
*/
|
|
11625
|
+
subscribe(callback: (arg: PlayerGameModeChangeBeforeEvent) => void): (arg: PlayerGameModeChangeBeforeEvent) => void;
|
|
11626
|
+
/**
|
|
11627
|
+
* @remarks
|
|
11628
|
+
* This function can't be called in read-only mode.
|
|
11629
|
+
*
|
|
11630
|
+
* @throws This function can throw errors.
|
|
11631
|
+
*/
|
|
11632
|
+
unsubscribe(callback: (arg: PlayerGameModeChangeBeforeEvent) => void): void;
|
|
11633
|
+
}
|
|
11634
|
+
|
|
10814
11635
|
/**
|
|
10815
11636
|
* Contains information regarding an event after a player
|
|
10816
11637
|
* interacts with a block.
|
|
@@ -11843,6 +12664,51 @@ export class ScoreboardScoreInfo {
|
|
|
11843
12664
|
/**
|
|
11844
12665
|
* Contains information about user interface elements that are
|
|
11845
12666
|
* showing up on the screen.
|
|
12667
|
+
* @example setTitle.ts
|
|
12668
|
+
* ```typescript
|
|
12669
|
+
* import { world } from '@minecraft/server';
|
|
12670
|
+
*
|
|
12671
|
+
* world.afterEvents.playerSpawn.subscribe((event) => {
|
|
12672
|
+
* event.player.onScreenDisplay.setTitle('§o§6You respawned!§r');
|
|
12673
|
+
* });
|
|
12674
|
+
* ```
|
|
12675
|
+
* @example setTitleAndSubtitle.ts
|
|
12676
|
+
* ```typescript
|
|
12677
|
+
* import { world } from '@minecraft/server';
|
|
12678
|
+
*
|
|
12679
|
+
* world.afterEvents.playerSpawn.subscribe((event) => {
|
|
12680
|
+
* event.player.onScreenDisplay.setTitle('You respawned', {
|
|
12681
|
+
* stayDuration: 100,
|
|
12682
|
+
* fadeInDuration: 2,
|
|
12683
|
+
* fadeOutDuration: 4,
|
|
12684
|
+
* subtitle: 'Try not to die next time!',
|
|
12685
|
+
* });
|
|
12686
|
+
* });
|
|
12687
|
+
* ```
|
|
12688
|
+
* @example titleCountdown.ts
|
|
12689
|
+
* ```typescript
|
|
12690
|
+
* import { world, system } from '@minecraft/server';
|
|
12691
|
+
*
|
|
12692
|
+
* world.afterEvents.playerSpawn.subscribe(event => {
|
|
12693
|
+
* event.player.onScreenDisplay.setTitle('Get ready!', {
|
|
12694
|
+
* stayDuration: 220,
|
|
12695
|
+
* fadeInDuration: 2,
|
|
12696
|
+
* fadeOutDuration: 4,
|
|
12697
|
+
* subtitle: '10',
|
|
12698
|
+
* });
|
|
12699
|
+
*
|
|
12700
|
+
* let countdown = 10;
|
|
12701
|
+
*
|
|
12702
|
+
* const intervalId = system.runInterval(() => {
|
|
12703
|
+
* countdown--;
|
|
12704
|
+
* event.player.onScreenDisplay.updateSubtitle(countdown.toString());
|
|
12705
|
+
*
|
|
12706
|
+
* if (countdown == 0) {
|
|
12707
|
+
* system.clearRun(intervalId);
|
|
12708
|
+
* }
|
|
12709
|
+
* }, 20);
|
|
12710
|
+
* });
|
|
12711
|
+
* ```
|
|
11846
12712
|
*/
|
|
11847
12713
|
export class ScreenDisplay {
|
|
11848
12714
|
private constructor();
|
|
@@ -11915,44 +12781,50 @@ export class ScreenDisplay {
|
|
|
11915
12781
|
* This function can't be called in read-only mode.
|
|
11916
12782
|
*
|
|
11917
12783
|
* @throws This function can throw errors.
|
|
11918
|
-
* @example countdown.ts
|
|
11919
|
-
* ```typescript
|
|
11920
|
-
* let players = mc.world.getPlayers();
|
|
11921
|
-
*
|
|
11922
|
-
* players[0].onScreenDisplay.setTitle("Get ready!", {
|
|
11923
|
-
* stayDuration: 220,
|
|
11924
|
-
* fadeInDuration: 2,
|
|
11925
|
-
* fadeOutDuration: 4,
|
|
11926
|
-
* subtitle: "10",
|
|
11927
|
-
* });
|
|
11928
|
-
*
|
|
11929
|
-
* let countdown = 10;
|
|
11930
|
-
*
|
|
11931
|
-
* let intervalId = mc.system.runInterval(() => {
|
|
11932
|
-
* countdown--;
|
|
11933
|
-
* players[0].onScreenDisplay.updateSubtitle(countdown.toString());
|
|
11934
|
-
*
|
|
11935
|
-
* if (countdown == 0) {
|
|
11936
|
-
* mc.system.clearRun(intervalId);
|
|
11937
|
-
* }
|
|
11938
|
-
* }, 20);
|
|
11939
|
-
* ```
|
|
11940
12784
|
* @example setTitle.ts
|
|
11941
12785
|
* ```typescript
|
|
11942
|
-
*
|
|
12786
|
+
* import { world } from '@minecraft/server';
|
|
11943
12787
|
*
|
|
11944
|
-
*
|
|
12788
|
+
* world.afterEvents.playerSpawn.subscribe((event) => {
|
|
12789
|
+
* event.player.onScreenDisplay.setTitle('§o§6You respawned!§r');
|
|
12790
|
+
* });
|
|
11945
12791
|
* ```
|
|
11946
12792
|
* @example setTitleAndSubtitle.ts
|
|
11947
12793
|
* ```typescript
|
|
11948
|
-
*
|
|
11949
|
-
*
|
|
11950
|
-
*
|
|
11951
|
-
*
|
|
11952
|
-
*
|
|
11953
|
-
*
|
|
11954
|
-
*
|
|
11955
|
-
*
|
|
12794
|
+
* import { world } from '@minecraft/server';
|
|
12795
|
+
*
|
|
12796
|
+
* world.afterEvents.playerSpawn.subscribe((event) => {
|
|
12797
|
+
* event.player.onScreenDisplay.setTitle('You respawned', {
|
|
12798
|
+
* stayDuration: 100,
|
|
12799
|
+
* fadeInDuration: 2,
|
|
12800
|
+
* fadeOutDuration: 4,
|
|
12801
|
+
* subtitle: 'Try not to die next time!',
|
|
12802
|
+
* });
|
|
12803
|
+
* });
|
|
12804
|
+
* ```
|
|
12805
|
+
* @example titleCountdown.ts
|
|
12806
|
+
* ```typescript
|
|
12807
|
+
* import { world, system } from '@minecraft/server';
|
|
12808
|
+
*
|
|
12809
|
+
* world.afterEvents.playerSpawn.subscribe(event => {
|
|
12810
|
+
* event.player.onScreenDisplay.setTitle('Get ready!', {
|
|
12811
|
+
* stayDuration: 220,
|
|
12812
|
+
* fadeInDuration: 2,
|
|
12813
|
+
* fadeOutDuration: 4,
|
|
12814
|
+
* subtitle: '10',
|
|
12815
|
+
* });
|
|
12816
|
+
*
|
|
12817
|
+
* let countdown = 10;
|
|
12818
|
+
*
|
|
12819
|
+
* const intervalId = system.runInterval(() => {
|
|
12820
|
+
* countdown--;
|
|
12821
|
+
* event.player.onScreenDisplay.updateSubtitle(countdown.toString());
|
|
12822
|
+
*
|
|
12823
|
+
* if (countdown == 0) {
|
|
12824
|
+
* system.clearRun(intervalId);
|
|
12825
|
+
* }
|
|
12826
|
+
* }, 20);
|
|
12827
|
+
* });
|
|
11956
12828
|
* ```
|
|
11957
12829
|
*/
|
|
11958
12830
|
setTitle(title: (RawMessage | string)[] | RawMessage | string, options?: TitleDisplayOptions): void;
|
|
@@ -12070,43 +12942,116 @@ export class Seat {
|
|
|
12070
12942
|
* position, if this seat is to be filled.
|
|
12071
12943
|
*
|
|
12072
12944
|
*/
|
|
12073
|
-
readonly minRiderCount: number;
|
|
12945
|
+
readonly minRiderCount: number;
|
|
12946
|
+
/**
|
|
12947
|
+
* @remarks
|
|
12948
|
+
* Physical location of this seat, relative to the entity's
|
|
12949
|
+
* location.
|
|
12950
|
+
*
|
|
12951
|
+
*/
|
|
12952
|
+
readonly position: Vector3;
|
|
12953
|
+
}
|
|
12954
|
+
|
|
12955
|
+
/**
|
|
12956
|
+
* @beta
|
|
12957
|
+
* Manages callbacks that are message passing to a server. This
|
|
12958
|
+
* event is not currently fully implemented, and should not be
|
|
12959
|
+
* used.
|
|
12960
|
+
*/
|
|
12961
|
+
export class ServerMessageAfterEventSignal {
|
|
12962
|
+
private constructor();
|
|
12963
|
+
/**
|
|
12964
|
+
* @remarks
|
|
12965
|
+
* Adds a callback that will be called when an internal message
|
|
12966
|
+
* is passed.
|
|
12967
|
+
*
|
|
12968
|
+
* This function can't be called in read-only mode.
|
|
12969
|
+
*
|
|
12970
|
+
*/
|
|
12971
|
+
subscribe(callback: (arg: MessageReceiveAfterEvent) => void): (arg: MessageReceiveAfterEvent) => void;
|
|
12972
|
+
/**
|
|
12973
|
+
* @remarks
|
|
12974
|
+
* Removes a callback from being called when an internal
|
|
12975
|
+
* message is passed.
|
|
12976
|
+
*
|
|
12977
|
+
* This function can't be called in read-only mode.
|
|
12978
|
+
*
|
|
12979
|
+
* @throws This function can throw errors.
|
|
12980
|
+
*/
|
|
12981
|
+
unsubscribe(callback: (arg: MessageReceiveAfterEvent) => void): void;
|
|
12982
|
+
}
|
|
12983
|
+
|
|
12984
|
+
/**
|
|
12985
|
+
* @beta
|
|
12986
|
+
*/
|
|
12987
|
+
export class StructureManager {
|
|
12988
|
+
private constructor();
|
|
12989
|
+
/**
|
|
12990
|
+
* @remarks
|
|
12991
|
+
* This function can't be called in read-only mode.
|
|
12992
|
+
*
|
|
12993
|
+
* @throws This function can throw errors.
|
|
12994
|
+
*
|
|
12995
|
+
* {@link minecraftcommon.EngineError}
|
|
12996
|
+
*
|
|
12997
|
+
* {@link minecraftcommon.InvalidArgumentError}
|
|
12998
|
+
*/
|
|
12999
|
+
createEmpty(identifier: string, size: Vector3, saveMode?: StructureSaveMode): StructureTemplate;
|
|
13000
|
+
/**
|
|
13001
|
+
* @remarks
|
|
13002
|
+
* This function can't be called in read-only mode.
|
|
13003
|
+
*
|
|
13004
|
+
* @throws This function can throw errors.
|
|
13005
|
+
*
|
|
13006
|
+
* {@link minecraftcommon.InvalidArgumentError}
|
|
13007
|
+
*/
|
|
13008
|
+
createFromWorld(
|
|
13009
|
+
identifier: string,
|
|
13010
|
+
dimension: Dimension,
|
|
13011
|
+
blockVolume: BlockVolume,
|
|
13012
|
+
options?: StructureCreateOptions,
|
|
13013
|
+
): StructureTemplate;
|
|
12074
13014
|
/**
|
|
12075
13015
|
* @remarks
|
|
12076
|
-
*
|
|
12077
|
-
*
|
|
13016
|
+
* This function can't be called in read-only mode.
|
|
13017
|
+
*
|
|
13018
|
+
* @throws This function can throw errors.
|
|
12078
13019
|
*
|
|
13020
|
+
* {@link minecraftcommon.InvalidArgumentError}
|
|
12079
13021
|
*/
|
|
12080
|
-
|
|
12081
|
-
}
|
|
12082
|
-
|
|
12083
|
-
/**
|
|
12084
|
-
* @beta
|
|
12085
|
-
* Manages callbacks that are message passing to a server. This
|
|
12086
|
-
* event is not currently fully implemented, and should not be
|
|
12087
|
-
* used.
|
|
12088
|
-
*/
|
|
12089
|
-
export class ServerMessageAfterEventSignal {
|
|
12090
|
-
private constructor();
|
|
13022
|
+
delete(structure: string | StructureTemplate): boolean;
|
|
12091
13023
|
/**
|
|
12092
13024
|
* @remarks
|
|
12093
|
-
* Adds a callback that will be called when an internal message
|
|
12094
|
-
* is passed.
|
|
12095
|
-
*
|
|
12096
13025
|
* This function can't be called in read-only mode.
|
|
12097
13026
|
*
|
|
12098
13027
|
*/
|
|
12099
|
-
|
|
13028
|
+
get(identifier: string): StructureTemplate | undefined;
|
|
12100
13029
|
/**
|
|
12101
13030
|
* @remarks
|
|
12102
|
-
* Removes a callback from being called when an internal
|
|
12103
|
-
* message is passed.
|
|
12104
|
-
*
|
|
12105
13031
|
* This function can't be called in read-only mode.
|
|
12106
13032
|
*
|
|
12107
13033
|
* @throws This function can throw errors.
|
|
13034
|
+
*
|
|
13035
|
+
* {@link minecraftcommon.ArgumentOutOfBoundsError}
|
|
13036
|
+
*
|
|
13037
|
+
* {@link minecraftcommon.InvalidArgumentError}
|
|
13038
|
+
*
|
|
13039
|
+
* {@link InvalidStructureError}
|
|
12108
13040
|
*/
|
|
12109
|
-
|
|
13041
|
+
place(
|
|
13042
|
+
structure: string | StructureTemplate,
|
|
13043
|
+
dimension: Dimension,
|
|
13044
|
+
location: Vector3,
|
|
13045
|
+
options?: StructurePlaceOptions,
|
|
13046
|
+
): void;
|
|
13047
|
+
}
|
|
13048
|
+
|
|
13049
|
+
/**
|
|
13050
|
+
* @beta
|
|
13051
|
+
*/
|
|
13052
|
+
export class StructureTemplate {
|
|
13053
|
+
private constructor();
|
|
13054
|
+
readonly id: string;
|
|
12110
13055
|
}
|
|
12111
13056
|
|
|
12112
13057
|
/**
|
|
@@ -12137,12 +13082,18 @@ export class System {
|
|
|
12137
13082
|
readonly currentTick: number;
|
|
12138
13083
|
/**
|
|
12139
13084
|
* @beta
|
|
13085
|
+
* @remarks
|
|
13086
|
+
* Cancels the execution of a job queued via {@link
|
|
13087
|
+
* System.runJob}.
|
|
13088
|
+
*
|
|
13089
|
+
* @param jobId
|
|
13090
|
+
* The job ID returned from {@link System.runJob}.
|
|
12140
13091
|
*/
|
|
12141
13092
|
clearJob(jobId: number): void;
|
|
12142
13093
|
/**
|
|
12143
13094
|
* @remarks
|
|
12144
13095
|
* Cancels the execution of a function run that was previously
|
|
12145
|
-
* scheduled via
|
|
13096
|
+
* scheduled via {@link System.run}.
|
|
12146
13097
|
*
|
|
12147
13098
|
*/
|
|
12148
13099
|
clearRun(runId: number): void;
|
|
@@ -12160,18 +13111,22 @@ export class System {
|
|
|
12160
13111
|
* function to cancel the execution of this run.
|
|
12161
13112
|
* @example trapTick.ts
|
|
12162
13113
|
* ```typescript
|
|
12163
|
-
*
|
|
13114
|
+
* import { system, world } from '@minecraft/server';
|
|
12164
13115
|
*
|
|
12165
|
-
*
|
|
12166
|
-
*
|
|
12167
|
-
*
|
|
12168
|
-
*
|
|
13116
|
+
* function printEveryMinute() {
|
|
13117
|
+
* try {
|
|
13118
|
+
* // Minecraft runs at 20 ticks per second.
|
|
13119
|
+
* if (system.currentTick % 1200 === 0) {
|
|
13120
|
+
* world.sendMessage('Another minute passes...');
|
|
13121
|
+
* }
|
|
13122
|
+
* } catch (e) {
|
|
13123
|
+
* console.warn('Error: ' + e);
|
|
12169
13124
|
* }
|
|
12170
|
-
* } catch (e) {
|
|
12171
|
-
* console.warn("Error: " + e);
|
|
12172
|
-
* }
|
|
12173
13125
|
*
|
|
12174
|
-
*
|
|
13126
|
+
* system.run(printEveryMinute);
|
|
13127
|
+
* }
|
|
13128
|
+
*
|
|
13129
|
+
* printEveryMinute();
|
|
12175
13130
|
* ```
|
|
12176
13131
|
*/
|
|
12177
13132
|
run(callback: () => void): number;
|
|
@@ -12189,16 +13144,58 @@ export class System {
|
|
|
12189
13144
|
* to stop the run of this function on an interval.
|
|
12190
13145
|
* @example every30Seconds.ts
|
|
12191
13146
|
* ```typescript
|
|
12192
|
-
*
|
|
13147
|
+
* import { system, world } from '@minecraft/server';
|
|
12193
13148
|
*
|
|
12194
|
-
*
|
|
12195
|
-
*
|
|
12196
|
-
*
|
|
13149
|
+
* const intervalRunIdentifier = Math.floor(Math.random() * 10000);
|
|
13150
|
+
*
|
|
13151
|
+
* system.runInterval(() => {
|
|
13152
|
+
* world.sendMessage('This is an interval run ' + intervalRunIdentifier + ' sending a message every 30 seconds.');
|
|
13153
|
+
* }, 600);
|
|
12197
13154
|
* ```
|
|
12198
13155
|
*/
|
|
12199
13156
|
runInterval(callback: () => void, tickInterval?: number): number;
|
|
12200
13157
|
/**
|
|
12201
13158
|
* @beta
|
|
13159
|
+
* @remarks
|
|
13160
|
+
* Queues a generator to run until completion. The generator
|
|
13161
|
+
* will be given a time slice each tick, and will be run until
|
|
13162
|
+
* it yields or completes.
|
|
13163
|
+
*
|
|
13164
|
+
* @param generator
|
|
13165
|
+
* The instance of the generator to run.
|
|
13166
|
+
* @returns
|
|
13167
|
+
* An opaque handle that can be used with {@link
|
|
13168
|
+
* System.clearJob} to stop the run of this generator.
|
|
13169
|
+
* @example cubeGenerator.ts
|
|
13170
|
+
* ```typescript
|
|
13171
|
+
* import { BlockPermutation, DimensionLocation, world, ButtonPushAfterEvent, system } from '@minecraft/server';
|
|
13172
|
+
*
|
|
13173
|
+
* // A simple generator that places blocks in a cube at a specific location
|
|
13174
|
+
* // with a specific size, yielding after every block place.
|
|
13175
|
+
* function* blockPlacingGenerator(blockPerm: BlockPermutation, startingLocation: DimensionLocation, size: number) {
|
|
13176
|
+
* for (let x = startingLocation.x; x < startingLocation.x + size; x++) {
|
|
13177
|
+
* for (let y = startingLocation.y; y < startingLocation.y + size; y++) {
|
|
13178
|
+
* for (let z = startingLocation.z; z < startingLocation.z + size; z++) {
|
|
13179
|
+
* const block = startingLocation.dimension.getBlock({ x: x, y: y, z: z });
|
|
13180
|
+
* if (block) {
|
|
13181
|
+
* block.setPermutation(blockPerm);
|
|
13182
|
+
* }
|
|
13183
|
+
* yield;
|
|
13184
|
+
* }
|
|
13185
|
+
* }
|
|
13186
|
+
* }
|
|
13187
|
+
* }
|
|
13188
|
+
*
|
|
13189
|
+
* // When a button is pushed, we will place a 15x15x15 cube of cobblestone 10 blocks above it
|
|
13190
|
+
* world.afterEvents.buttonPush.subscribe((buttonPushEvent: ButtonPushAfterEvent) => {
|
|
13191
|
+
* const cubePos = buttonPushEvent.block.location;
|
|
13192
|
+
* cubePos.y += 10;
|
|
13193
|
+
*
|
|
13194
|
+
* const blockPerm = BlockPermutation.resolve('minecraft:cobblestone');
|
|
13195
|
+
*
|
|
13196
|
+
* system.runJob(blockPlacingGenerator(blockPerm, { dimension: buttonPushEvent.dimension, ...cubePos }, 15));
|
|
13197
|
+
* });
|
|
13198
|
+
* ```
|
|
12202
13199
|
*/
|
|
12203
13200
|
runJob(generator: Generator<void, void, void>): number;
|
|
12204
13201
|
/**
|
|
@@ -12336,6 +13333,37 @@ export class Trigger {
|
|
|
12336
13333
|
|
|
12337
13334
|
/**
|
|
12338
13335
|
* Contains information related to changes to a trip wire trip.
|
|
13336
|
+
* @example tripWireTripEvent.ts
|
|
13337
|
+
* ```typescript
|
|
13338
|
+
* import { Vector3, world, BlockPermutation, TripWireTripAfterEvent, system } from '@minecraft/server';
|
|
13339
|
+
*
|
|
13340
|
+
* const overworld = world.getDimension('overworld');
|
|
13341
|
+
* const targetLocation: Vector3 = { x: 0, y: 0, z: 0 };
|
|
13342
|
+
*
|
|
13343
|
+
* // set up a tripwire
|
|
13344
|
+
* const redstone = overworld.getBlock({ x: targetLocation.x, y: targetLocation.y - 1, z: targetLocation.z });
|
|
13345
|
+
* const tripwire = overworld.getBlock(targetLocation);
|
|
13346
|
+
*
|
|
13347
|
+
* if (redstone === undefined || tripwire === undefined) {
|
|
13348
|
+
* console.warn('Could not find block at location.');
|
|
13349
|
+
* } else {
|
|
13350
|
+
*
|
|
13351
|
+
* redstone.setPermutation(BlockPermutation.resolve('redstone_block'));
|
|
13352
|
+
* tripwire.setPermutation(BlockPermutation.resolve('tripwire'));
|
|
13353
|
+
*
|
|
13354
|
+
* world.afterEvents.tripWireTrip.subscribe((tripWireTripEvent: TripWireTripAfterEvent) => {
|
|
13355
|
+
* const eventLoc = tripWireTripEvent.block.location;
|
|
13356
|
+
*
|
|
13357
|
+
* if (eventLoc.x === targetLocation.x && eventLoc.y === targetLocation.y && eventLoc.z === targetLocation.z) {
|
|
13358
|
+
* console.warn(
|
|
13359
|
+
* 'Tripwire trip event at tick ' +
|
|
13360
|
+
* system.currentTick +
|
|
13361
|
+
* (tripWireTripEvent.sources.length > 0 ? ' by entity ' + tripWireTripEvent.sources[0].id : ''),
|
|
13362
|
+
* );
|
|
13363
|
+
* }
|
|
13364
|
+
* });
|
|
13365
|
+
* }
|
|
13366
|
+
* ```
|
|
12339
13367
|
*/
|
|
12340
13368
|
// @ts-ignore Class inheritance allowed for native defined classes
|
|
12341
13369
|
export class TripWireTripAfterEvent extends BlockEvent {
|
|
@@ -12357,6 +13385,37 @@ export class TripWireTripAfterEvent extends BlockEvent {
|
|
|
12357
13385
|
/**
|
|
12358
13386
|
* Manages callbacks that are connected to when a trip wire is
|
|
12359
13387
|
* tripped.
|
|
13388
|
+
* @example tripWireTripEvent.ts
|
|
13389
|
+
* ```typescript
|
|
13390
|
+
* import { Vector3, world, BlockPermutation, TripWireTripAfterEvent, system } from '@minecraft/server';
|
|
13391
|
+
*
|
|
13392
|
+
* const overworld = world.getDimension('overworld');
|
|
13393
|
+
* const targetLocation: Vector3 = { x: 0, y: 0, z: 0 };
|
|
13394
|
+
*
|
|
13395
|
+
* // set up a tripwire
|
|
13396
|
+
* const redstone = overworld.getBlock({ x: targetLocation.x, y: targetLocation.y - 1, z: targetLocation.z });
|
|
13397
|
+
* const tripwire = overworld.getBlock(targetLocation);
|
|
13398
|
+
*
|
|
13399
|
+
* if (redstone === undefined || tripwire === undefined) {
|
|
13400
|
+
* console.warn('Could not find block at location.');
|
|
13401
|
+
* } else {
|
|
13402
|
+
*
|
|
13403
|
+
* redstone.setPermutation(BlockPermutation.resolve('redstone_block'));
|
|
13404
|
+
* tripwire.setPermutation(BlockPermutation.resolve('tripwire'));
|
|
13405
|
+
*
|
|
13406
|
+
* world.afterEvents.tripWireTrip.subscribe((tripWireTripEvent: TripWireTripAfterEvent) => {
|
|
13407
|
+
* const eventLoc = tripWireTripEvent.block.location;
|
|
13408
|
+
*
|
|
13409
|
+
* if (eventLoc.x === targetLocation.x && eventLoc.y === targetLocation.y && eventLoc.z === targetLocation.z) {
|
|
13410
|
+
* console.warn(
|
|
13411
|
+
* 'Tripwire trip event at tick ' +
|
|
13412
|
+
* system.currentTick +
|
|
13413
|
+
* (tripWireTripEvent.sources.length > 0 ? ' by entity ' + tripWireTripEvent.sources[0].id : ''),
|
|
13414
|
+
* );
|
|
13415
|
+
* }
|
|
13416
|
+
* });
|
|
13417
|
+
* }
|
|
13418
|
+
* ```
|
|
12360
13419
|
*/
|
|
12361
13420
|
export class TripWireTripAfterEventSignal {
|
|
12362
13421
|
private constructor();
|
|
@@ -12628,7 +13687,17 @@ export class WeatherChangeAfterEvent {
|
|
|
12628
13687
|
*
|
|
12629
13688
|
*/
|
|
12630
13689
|
readonly dimension: string;
|
|
13690
|
+
/**
|
|
13691
|
+
* @remarks
|
|
13692
|
+
* The weather type after the weather was changed.
|
|
13693
|
+
*
|
|
13694
|
+
*/
|
|
12631
13695
|
readonly newWeather: WeatherType;
|
|
13696
|
+
/**
|
|
13697
|
+
* @remarks
|
|
13698
|
+
* The weather type before the weather was changed.
|
|
13699
|
+
*
|
|
13700
|
+
*/
|
|
12632
13701
|
readonly previousWeather: WeatherType;
|
|
12633
13702
|
}
|
|
12634
13703
|
|
|
@@ -12659,28 +13728,57 @@ export class WeatherChangeAfterEventSignal {
|
|
|
12659
13728
|
|
|
12660
13729
|
/**
|
|
12661
13730
|
* @beta
|
|
13731
|
+
* Contains information related to changes in weather in the
|
|
13732
|
+
* environment.
|
|
12662
13733
|
*/
|
|
12663
13734
|
export class WeatherChangeBeforeEvent {
|
|
12664
13735
|
private constructor();
|
|
13736
|
+
/**
|
|
13737
|
+
* @remarks
|
|
13738
|
+
* If set to true the weather change will be cancelled.
|
|
13739
|
+
*
|
|
13740
|
+
*/
|
|
12665
13741
|
cancel: boolean;
|
|
13742
|
+
/**
|
|
13743
|
+
* @remarks
|
|
13744
|
+
* Sets the duration of the new weather (in ticks).
|
|
13745
|
+
*
|
|
13746
|
+
*/
|
|
12666
13747
|
duration: number;
|
|
13748
|
+
/**
|
|
13749
|
+
* @remarks
|
|
13750
|
+
* The type of weather that will be applied.
|
|
13751
|
+
*
|
|
13752
|
+
*/
|
|
12667
13753
|
newWeather: WeatherType;
|
|
13754
|
+
/**
|
|
13755
|
+
* @remarks
|
|
13756
|
+
* The type of weather that it was prior to the event being
|
|
13757
|
+
* fired.
|
|
13758
|
+
*
|
|
13759
|
+
*/
|
|
12668
13760
|
readonly previousWeather: WeatherType;
|
|
12669
13761
|
}
|
|
12670
13762
|
|
|
12671
13763
|
/**
|
|
12672
13764
|
* @beta
|
|
13765
|
+
* Manages callbacks that are connected to before weather
|
|
13766
|
+
* changing.
|
|
12673
13767
|
*/
|
|
12674
13768
|
export class WeatherChangeBeforeEventSignal {
|
|
12675
13769
|
private constructor();
|
|
12676
13770
|
/**
|
|
12677
13771
|
* @remarks
|
|
13772
|
+
* Adds a callback that will be called before weather changes.
|
|
13773
|
+
*
|
|
12678
13774
|
* This function can't be called in read-only mode.
|
|
12679
13775
|
*
|
|
12680
13776
|
*/
|
|
12681
13777
|
subscribe(callback: (arg: WeatherChangeBeforeEvent) => void): (arg: WeatherChangeBeforeEvent) => void;
|
|
12682
13778
|
/**
|
|
12683
13779
|
* @remarks
|
|
13780
|
+
* Removes a callback from being called before weather changes.
|
|
13781
|
+
*
|
|
12684
13782
|
* This function can't be called in read-only mode.
|
|
12685
13783
|
*
|
|
12686
13784
|
* @throws This function can throw errors.
|
|
@@ -12712,6 +13810,9 @@ export class World {
|
|
|
12712
13810
|
readonly beforeEvents: WorldBeforeEvents;
|
|
12713
13811
|
/**
|
|
12714
13812
|
* @beta
|
|
13813
|
+
* @remarks
|
|
13814
|
+
* The game rules that apply to the world.
|
|
13815
|
+
*
|
|
12715
13816
|
*/
|
|
12716
13817
|
readonly gameRules: GameRules;
|
|
12717
13818
|
/**
|
|
@@ -12721,6 +13822,10 @@ export class World {
|
|
|
12721
13822
|
*
|
|
12722
13823
|
*/
|
|
12723
13824
|
readonly scoreboard: Scoreboard;
|
|
13825
|
+
/**
|
|
13826
|
+
* @beta
|
|
13827
|
+
*/
|
|
13828
|
+
readonly structureManager: StructureManager;
|
|
12724
13829
|
/**
|
|
12725
13830
|
* @beta
|
|
12726
13831
|
* @remarks
|
|
@@ -12799,57 +13904,72 @@ export class World {
|
|
|
12799
13904
|
* @throws
|
|
12800
13905
|
* Throws if the given dynamic property identifier is not
|
|
12801
13906
|
* defined.
|
|
12802
|
-
* @example
|
|
13907
|
+
* @example incrementDynamicProperty.ts
|
|
12803
13908
|
* ```typescript
|
|
12804
|
-
*
|
|
13909
|
+
* import * as mc from '@minecraft/server';
|
|
12805
13910
|
*
|
|
12806
|
-
*
|
|
13911
|
+
* function incrementProperty(propertyName: string): boolean {
|
|
13912
|
+
* let number = mc.world.getDynamicProperty(propertyName);
|
|
12807
13913
|
*
|
|
12808
|
-
*
|
|
12809
|
-
* number = 0;
|
|
12810
|
-
* }
|
|
13914
|
+
* console.warn('Current value is: ' + number);
|
|
12811
13915
|
*
|
|
12812
|
-
*
|
|
12813
|
-
*
|
|
12814
|
-
*
|
|
12815
|
-
*
|
|
13916
|
+
* if (number === undefined) {
|
|
13917
|
+
* number = 0;
|
|
13918
|
+
* }
|
|
13919
|
+
*
|
|
13920
|
+
* if (typeof number !== 'number') {
|
|
13921
|
+
* console.warn('Number is of an unexpected type.');
|
|
13922
|
+
* return false;
|
|
13923
|
+
* }
|
|
12816
13924
|
*
|
|
12817
|
-
*
|
|
13925
|
+
* mc.world.setDynamicProperty(propertyName, number + 1);
|
|
13926
|
+
* return true;
|
|
13927
|
+
* }
|
|
13928
|
+
*
|
|
13929
|
+
* incrementProperty('samplelibrary:number');
|
|
12818
13930
|
* ```
|
|
12819
|
-
* @example
|
|
13931
|
+
* @example incrementDynamicPropertyInJsonBlob.ts
|
|
12820
13932
|
* ```typescript
|
|
12821
|
-
*
|
|
12822
|
-
* let paint: { color: string; intensity: number } | undefined = undefined;
|
|
13933
|
+
* import * as mc from '@minecraft/server';
|
|
12823
13934
|
*
|
|
12824
|
-
*
|
|
13935
|
+
* function updateWorldProperty(propertyName: string): boolean {
|
|
13936
|
+
* let paintStr = mc.world.getDynamicProperty(propertyName);
|
|
13937
|
+
* let paint: { color: string; intensity: number } | undefined = undefined;
|
|
12825
13938
|
*
|
|
12826
|
-
*
|
|
12827
|
-
*
|
|
12828
|
-
*
|
|
12829
|
-
*
|
|
12830
|
-
*
|
|
12831
|
-
*
|
|
12832
|
-
*
|
|
12833
|
-
*
|
|
12834
|
-
*
|
|
13939
|
+
* console.log('Current value is: ' + paintStr);
|
|
13940
|
+
*
|
|
13941
|
+
* if (paintStr === undefined) {
|
|
13942
|
+
* paint = {
|
|
13943
|
+
* color: 'purple',
|
|
13944
|
+
* intensity: 0,
|
|
13945
|
+
* };
|
|
13946
|
+
* } else {
|
|
13947
|
+
* if (typeof paintStr !== 'string') {
|
|
13948
|
+
* console.warn('Paint is of an unexpected type.');
|
|
13949
|
+
* return false;
|
|
13950
|
+
* }
|
|
13951
|
+
*
|
|
13952
|
+
* try {
|
|
13953
|
+
* paint = JSON.parse(paintStr);
|
|
13954
|
+
* } catch (e) {
|
|
13955
|
+
* console.warn('Error parsing serialized struct.');
|
|
13956
|
+
* return false;
|
|
13957
|
+
* }
|
|
12835
13958
|
* }
|
|
12836
13959
|
*
|
|
12837
|
-
*
|
|
12838
|
-
*
|
|
12839
|
-
*
|
|
12840
|
-
* log("Error parsing serialized struct.");
|
|
12841
|
-
* return -1;
|
|
13960
|
+
* if (!paint) {
|
|
13961
|
+
* console.warn('Error parsing serialized struct.');
|
|
13962
|
+
* return false;
|
|
12842
13963
|
* }
|
|
12843
|
-
* }
|
|
12844
13964
|
*
|
|
12845
|
-
*
|
|
12846
|
-
*
|
|
12847
|
-
*
|
|
12848
|
-
*
|
|
13965
|
+
* paint.intensity++;
|
|
13966
|
+
* paintStr = JSON.stringify(paint); // be very careful to ensure your serialized JSON str cannot exceed limits
|
|
13967
|
+
* mc.world.setDynamicProperty(propertyName, paintStr);
|
|
13968
|
+
*
|
|
13969
|
+
* return true;
|
|
13970
|
+
* }
|
|
12849
13971
|
*
|
|
12850
|
-
*
|
|
12851
|
-
* paintStr = JSON.stringify(paint); // be very careful to ensure your serialized JSON str cannot exceed limits
|
|
12852
|
-
* mc.world.setDynamicProperty("samplelibrary:longerjson", paintStr);
|
|
13972
|
+
* updateWorldProperty('samplelibrary:longerjson');
|
|
12853
13973
|
* ```
|
|
12854
13974
|
*/
|
|
12855
13975
|
getDynamicProperty(identifier: string): boolean | number | string | Vector3 | undefined;
|
|
@@ -12919,27 +14039,34 @@ export class World {
|
|
|
12919
14039
|
* @throws This function can throw errors.
|
|
12920
14040
|
* @example playMusicAndSound.ts
|
|
12921
14041
|
* ```typescript
|
|
12922
|
-
*
|
|
14042
|
+
* import { world, MusicOptions, WorldSoundOptions, PlayerSoundOptions, Vector3 } from '@minecraft/server';
|
|
12923
14043
|
*
|
|
12924
|
-
*
|
|
14044
|
+
* const players = world.getPlayers();
|
|
14045
|
+
* const targetLocation: Vector3 = {
|
|
14046
|
+
* x: 0,
|
|
14047
|
+
* y: 0,
|
|
14048
|
+
* z: 0,
|
|
14049
|
+
* };
|
|
14050
|
+
*
|
|
14051
|
+
* const musicOptions: MusicOptions = {
|
|
12925
14052
|
* fade: 0.5,
|
|
12926
14053
|
* loop: true,
|
|
12927
14054
|
* volume: 1.0,
|
|
12928
|
-
*
|
|
12929
|
-
*
|
|
14055
|
+
* };
|
|
14056
|
+
* world.playMusic('music.menu', musicOptions);
|
|
12930
14057
|
*
|
|
12931
|
-
*
|
|
14058
|
+
* const worldSoundOptions: WorldSoundOptions = {
|
|
12932
14059
|
* pitch: 0.5,
|
|
12933
14060
|
* volume: 4.0,
|
|
12934
|
-
*
|
|
12935
|
-
*
|
|
14061
|
+
* };
|
|
14062
|
+
* world.playSound('ambient.weather.thunder', targetLocation, worldSoundOptions);
|
|
12936
14063
|
*
|
|
12937
|
-
*
|
|
14064
|
+
* const playerSoundOptions: PlayerSoundOptions = {
|
|
12938
14065
|
* pitch: 1.0,
|
|
12939
14066
|
* volume: 1.0,
|
|
12940
|
-
*
|
|
14067
|
+
* };
|
|
12941
14068
|
*
|
|
12942
|
-
*
|
|
14069
|
+
* players[0].playSound('bucket.fill_water', playerSoundOptions);
|
|
12943
14070
|
* ```
|
|
12944
14071
|
*/
|
|
12945
14072
|
playMusic(trackId: string, musicOptions?: MusicOptions): void;
|
|
@@ -12956,27 +14083,34 @@ export class World {
|
|
|
12956
14083
|
* An error will be thrown if volume is less than 0.0.
|
|
12957
14084
|
* @example playMusicAndSound.ts
|
|
12958
14085
|
* ```typescript
|
|
12959
|
-
*
|
|
14086
|
+
* import { world, MusicOptions, WorldSoundOptions, PlayerSoundOptions, Vector3 } from '@minecraft/server';
|
|
14087
|
+
*
|
|
14088
|
+
* const players = world.getPlayers();
|
|
14089
|
+
* const targetLocation: Vector3 = {
|
|
14090
|
+
* x: 0,
|
|
14091
|
+
* y: 0,
|
|
14092
|
+
* z: 0,
|
|
14093
|
+
* };
|
|
12960
14094
|
*
|
|
12961
|
-
*
|
|
14095
|
+
* const musicOptions: MusicOptions = {
|
|
12962
14096
|
* fade: 0.5,
|
|
12963
14097
|
* loop: true,
|
|
12964
14098
|
* volume: 1.0,
|
|
12965
|
-
*
|
|
12966
|
-
*
|
|
14099
|
+
* };
|
|
14100
|
+
* world.playMusic('music.menu', musicOptions);
|
|
12967
14101
|
*
|
|
12968
|
-
*
|
|
14102
|
+
* const worldSoundOptions: WorldSoundOptions = {
|
|
12969
14103
|
* pitch: 0.5,
|
|
12970
14104
|
* volume: 4.0,
|
|
12971
|
-
*
|
|
12972
|
-
*
|
|
14105
|
+
* };
|
|
14106
|
+
* world.playSound('ambient.weather.thunder', targetLocation, worldSoundOptions);
|
|
12973
14107
|
*
|
|
12974
|
-
*
|
|
14108
|
+
* const playerSoundOptions: PlayerSoundOptions = {
|
|
12975
14109
|
* pitch: 1.0,
|
|
12976
14110
|
* volume: 1.0,
|
|
12977
|
-
*
|
|
14111
|
+
* };
|
|
12978
14112
|
*
|
|
12979
|
-
*
|
|
14113
|
+
* players[0].playSound('bucket.fill_water', playerSoundOptions);
|
|
12980
14114
|
* ```
|
|
12981
14115
|
*/
|
|
12982
14116
|
playSound(soundId: string, location: Vector3, soundOptions?: WorldSoundOptions): void;
|
|
@@ -13009,28 +14143,36 @@ export class World {
|
|
|
13009
14143
|
* is provided to `score`.
|
|
13010
14144
|
* @example nestedTranslation.ts
|
|
13011
14145
|
* ```typescript
|
|
14146
|
+
* import { world } from '@minecraft/server';
|
|
14147
|
+
*
|
|
13012
14148
|
* // Displays "Apple or Coal"
|
|
13013
|
-
*
|
|
13014
|
-
*
|
|
13015
|
-
*
|
|
14149
|
+
* const rawMessage = {
|
|
14150
|
+
* translate: 'accessibility.list.or.two',
|
|
14151
|
+
* with: { rawtext: [{ translate: 'item.apple.name' }, { translate: 'item.coal.name' }] },
|
|
13016
14152
|
* };
|
|
13017
14153
|
* world.sendMessage(rawMessage);
|
|
13018
14154
|
* ```
|
|
13019
14155
|
* @example scoreWildcard.ts
|
|
13020
14156
|
* ```typescript
|
|
14157
|
+
* import { world } from '@minecraft/server';
|
|
14158
|
+
*
|
|
13021
14159
|
* // Displays the player's score for objective "obj". Each player will see their own score.
|
|
13022
|
-
* const rawMessage = { score: { name:
|
|
14160
|
+
* const rawMessage = { score: { name: '*', objective: 'obj' } };
|
|
13023
14161
|
* world.sendMessage(rawMessage);
|
|
13024
14162
|
* ```
|
|
13025
14163
|
* @example simpleString.ts
|
|
13026
14164
|
* ```typescript
|
|
14165
|
+
* import { world } from '@minecraft/server';
|
|
14166
|
+
*
|
|
13027
14167
|
* // Displays "Hello, world!"
|
|
13028
|
-
* world.sendMessage(
|
|
14168
|
+
* world.sendMessage('Hello, world!');
|
|
13029
14169
|
* ```
|
|
13030
14170
|
* @example translation.ts
|
|
13031
14171
|
* ```typescript
|
|
14172
|
+
* import { world } from '@minecraft/server';
|
|
14173
|
+
*
|
|
13032
14174
|
* // Displays "First or Second"
|
|
13033
|
-
* const rawMessage = { translate:
|
|
14175
|
+
* const rawMessage = { translate: 'accessibility.list.or.two', with: ['First', 'Second'] };
|
|
13034
14176
|
* world.sendMessage(rawMessage);
|
|
13035
14177
|
* ```
|
|
13036
14178
|
*/
|
|
@@ -13073,57 +14215,72 @@ export class World {
|
|
|
13073
14215
|
* @throws
|
|
13074
14216
|
* Throws if the given dynamic property identifier is not
|
|
13075
14217
|
* defined.
|
|
13076
|
-
* @example
|
|
14218
|
+
* @example incrementDynamicProperty.ts
|
|
13077
14219
|
* ```typescript
|
|
13078
|
-
*
|
|
14220
|
+
* import * as mc from '@minecraft/server';
|
|
13079
14221
|
*
|
|
13080
|
-
*
|
|
14222
|
+
* function incrementProperty(propertyName: string): boolean {
|
|
14223
|
+
* let number = mc.world.getDynamicProperty(propertyName);
|
|
13081
14224
|
*
|
|
13082
|
-
*
|
|
13083
|
-
* number = 0;
|
|
13084
|
-
* }
|
|
14225
|
+
* console.warn('Current value is: ' + number);
|
|
13085
14226
|
*
|
|
13086
|
-
*
|
|
13087
|
-
*
|
|
13088
|
-
*
|
|
13089
|
-
*
|
|
14227
|
+
* if (number === undefined) {
|
|
14228
|
+
* number = 0;
|
|
14229
|
+
* }
|
|
14230
|
+
*
|
|
14231
|
+
* if (typeof number !== 'number') {
|
|
14232
|
+
* console.warn('Number is of an unexpected type.');
|
|
14233
|
+
* return false;
|
|
14234
|
+
* }
|
|
14235
|
+
*
|
|
14236
|
+
* mc.world.setDynamicProperty(propertyName, number + 1);
|
|
14237
|
+
* return true;
|
|
14238
|
+
* }
|
|
13090
14239
|
*
|
|
13091
|
-
*
|
|
14240
|
+
* incrementProperty('samplelibrary:number');
|
|
13092
14241
|
* ```
|
|
13093
|
-
* @example
|
|
14242
|
+
* @example incrementDynamicPropertyInJsonBlob.ts
|
|
13094
14243
|
* ```typescript
|
|
13095
|
-
*
|
|
13096
|
-
* let paint: { color: string; intensity: number } | undefined = undefined;
|
|
14244
|
+
* import * as mc from '@minecraft/server';
|
|
13097
14245
|
*
|
|
13098
|
-
*
|
|
14246
|
+
* function updateWorldProperty(propertyName: string): boolean {
|
|
14247
|
+
* let paintStr = mc.world.getDynamicProperty(propertyName);
|
|
14248
|
+
* let paint: { color: string; intensity: number } | undefined = undefined;
|
|
13099
14249
|
*
|
|
13100
|
-
*
|
|
13101
|
-
*
|
|
13102
|
-
*
|
|
13103
|
-
*
|
|
13104
|
-
*
|
|
13105
|
-
*
|
|
13106
|
-
*
|
|
13107
|
-
*
|
|
13108
|
-
*
|
|
14250
|
+
* console.log('Current value is: ' + paintStr);
|
|
14251
|
+
*
|
|
14252
|
+
* if (paintStr === undefined) {
|
|
14253
|
+
* paint = {
|
|
14254
|
+
* color: 'purple',
|
|
14255
|
+
* intensity: 0,
|
|
14256
|
+
* };
|
|
14257
|
+
* } else {
|
|
14258
|
+
* if (typeof paintStr !== 'string') {
|
|
14259
|
+
* console.warn('Paint is of an unexpected type.');
|
|
14260
|
+
* return false;
|
|
14261
|
+
* }
|
|
14262
|
+
*
|
|
14263
|
+
* try {
|
|
14264
|
+
* paint = JSON.parse(paintStr);
|
|
14265
|
+
* } catch (e) {
|
|
14266
|
+
* console.warn('Error parsing serialized struct.');
|
|
14267
|
+
* return false;
|
|
14268
|
+
* }
|
|
13109
14269
|
* }
|
|
13110
14270
|
*
|
|
13111
|
-
*
|
|
13112
|
-
*
|
|
13113
|
-
*
|
|
13114
|
-
* log("Error parsing serialized struct.");
|
|
13115
|
-
* return -1;
|
|
14271
|
+
* if (!paint) {
|
|
14272
|
+
* console.warn('Error parsing serialized struct.');
|
|
14273
|
+
* return false;
|
|
13116
14274
|
* }
|
|
13117
|
-
* }
|
|
13118
14275
|
*
|
|
13119
|
-
*
|
|
13120
|
-
*
|
|
13121
|
-
*
|
|
13122
|
-
*
|
|
14276
|
+
* paint.intensity++;
|
|
14277
|
+
* paintStr = JSON.stringify(paint); // be very careful to ensure your serialized JSON str cannot exceed limits
|
|
14278
|
+
* mc.world.setDynamicProperty(propertyName, paintStr);
|
|
14279
|
+
*
|
|
14280
|
+
* return true;
|
|
14281
|
+
* }
|
|
13123
14282
|
*
|
|
13124
|
-
*
|
|
13125
|
-
* paintStr = JSON.stringify(paint); // be very careful to ensure your serialized JSON str cannot exceed limits
|
|
13126
|
-
* mc.world.setDynamicProperty("samplelibrary:longerjson", paintStr);
|
|
14283
|
+
* updateWorldProperty('samplelibrary:longerjson');
|
|
13127
14284
|
* ```
|
|
13128
14285
|
*/
|
|
13129
14286
|
setDynamicProperty(identifier: string, value?: boolean | number | string | Vector3): void;
|
|
@@ -13180,7 +14337,6 @@ export class WorldAfterEvents {
|
|
|
13180
14337
|
*/
|
|
13181
14338
|
readonly chatSend: ChatSendAfterEventSignal;
|
|
13182
14339
|
/**
|
|
13183
|
-
* @beta
|
|
13184
14340
|
* @remarks
|
|
13185
14341
|
* This event is fired when an entity event has been triggered
|
|
13186
14342
|
* that will update the component definition state of an
|
|
@@ -13255,21 +14411,19 @@ export class WorldAfterEvents {
|
|
|
13255
14411
|
*/
|
|
13256
14412
|
readonly explosion: ExplosionAfterEventSignal;
|
|
13257
14413
|
/**
|
|
14414
|
+
* @beta
|
|
13258
14415
|
* @remarks
|
|
13259
|
-
* This event fires when a
|
|
14416
|
+
* This event fires when a world.gameRules property has
|
|
14417
|
+
* changed.
|
|
13260
14418
|
*
|
|
13261
14419
|
*/
|
|
13262
|
-
readonly
|
|
14420
|
+
readonly gameRuleChange: GameRuleChangeAfterEventSignal;
|
|
13263
14421
|
/**
|
|
13264
|
-
* @beta
|
|
13265
14422
|
* @remarks
|
|
13266
|
-
*
|
|
13267
|
-
* fundamental set of defined components for the item change.
|
|
13268
|
-
* Note that this event is only fired for custom data-driven
|
|
13269
|
-
* items.
|
|
14423
|
+
* This event fires when a chargeable item completes charging.
|
|
13270
14424
|
*
|
|
13271
14425
|
*/
|
|
13272
|
-
readonly
|
|
14426
|
+
readonly itemCompleteUse: ItemCompleteUseAfterEventSignal;
|
|
13273
14427
|
/**
|
|
13274
14428
|
* @remarks
|
|
13275
14429
|
* This event fires when a chargeable item is released from
|
|
@@ -13354,6 +14508,10 @@ export class WorldAfterEvents {
|
|
|
13354
14508
|
*
|
|
13355
14509
|
*/
|
|
13356
14510
|
readonly playerDimensionChange: PlayerDimensionChangeAfterEventSignal;
|
|
14511
|
+
/**
|
|
14512
|
+
* @beta
|
|
14513
|
+
*/
|
|
14514
|
+
readonly playerGameModeChange: PlayerGameModeChangeAfterEventSignal;
|
|
13357
14515
|
/**
|
|
13358
14516
|
* @beta
|
|
13359
14517
|
* @remarks
|
|
@@ -13501,16 +14659,6 @@ export class WorldBeforeEvents {
|
|
|
13501
14659
|
*
|
|
13502
14660
|
*/
|
|
13503
14661
|
readonly explosion: ExplosionBeforeEventSignal;
|
|
13504
|
-
/**
|
|
13505
|
-
* @beta
|
|
13506
|
-
* @remarks
|
|
13507
|
-
* For custom items, this event is triggered when the
|
|
13508
|
-
* fundamental set of defined components for the item change.
|
|
13509
|
-
* Note that this event is only fired for custom data-driven
|
|
13510
|
-
* items.
|
|
13511
|
-
*
|
|
13512
|
-
*/
|
|
13513
|
-
readonly itemDefinitionEvent: ItemDefinitionBeforeEventSignal;
|
|
13514
14662
|
/**
|
|
13515
14663
|
* @remarks
|
|
13516
14664
|
* This event fires when an item is successfully used by a
|
|
@@ -13531,6 +14679,10 @@ export class WorldBeforeEvents {
|
|
|
13531
14679
|
*
|
|
13532
14680
|
*/
|
|
13533
14681
|
readonly playerBreakBlock: PlayerBreakBlockBeforeEventSignal;
|
|
14682
|
+
/**
|
|
14683
|
+
* @beta
|
|
14684
|
+
*/
|
|
14685
|
+
readonly playerGameModeChange: PlayerGameModeChangeBeforeEventSignal;
|
|
13534
14686
|
/**
|
|
13535
14687
|
* @beta
|
|
13536
14688
|
* @remarks
|
|
@@ -13568,9 +14720,6 @@ export class WorldBeforeEvents {
|
|
|
13568
14720
|
* @beta
|
|
13569
14721
|
* Contains information and methods that can be used at the
|
|
13570
14722
|
* initialization of the scripting environment for a World.
|
|
13571
|
-
* Also, use the supplied propertyRegistry object to register
|
|
13572
|
-
* any dynamic properties, within the scope of the World
|
|
13573
|
-
* Initialize execution.
|
|
13574
14723
|
*/
|
|
13575
14724
|
export class WorldInitializeAfterEvent {
|
|
13576
14725
|
private constructor();
|
|
@@ -13578,10 +14727,9 @@ export class WorldInitializeAfterEvent {
|
|
|
13578
14727
|
|
|
13579
14728
|
/**
|
|
13580
14729
|
* @beta
|
|
13581
|
-
* Manages callbacks that are run
|
|
13582
|
-
*
|
|
13583
|
-
*
|
|
13584
|
-
* /reload command is used.
|
|
14730
|
+
* Manages callbacks that are run on the first tick of the
|
|
14731
|
+
* World. Do note that this event may run multiple times within
|
|
14732
|
+
* a session in the case that the /reload command is used.
|
|
13585
14733
|
*/
|
|
13586
14734
|
export class WorldInitializeAfterEventSignal {
|
|
13587
14735
|
private constructor();
|
|
@@ -13608,8 +14756,15 @@ export class WorldInitializeAfterEventSignal {
|
|
|
13608
14756
|
|
|
13609
14757
|
/**
|
|
13610
14758
|
* @beta
|
|
14759
|
+
* Contains additional options for searches for the
|
|
14760
|
+
* dimension.findNearestBiome API.
|
|
13611
14761
|
*/
|
|
13612
14762
|
export interface BiomeSearchOptions {
|
|
14763
|
+
/**
|
|
14764
|
+
* @remarks
|
|
14765
|
+
* Bounding volume size to look within.
|
|
14766
|
+
*
|
|
14767
|
+
*/
|
|
13613
14768
|
boundingSize?: Vector3;
|
|
13614
14769
|
}
|
|
13615
14770
|
|
|
@@ -13901,7 +15056,6 @@ export interface CompoundBlockVolumeItem {
|
|
|
13901
15056
|
}
|
|
13902
15057
|
|
|
13903
15058
|
/**
|
|
13904
|
-
* @beta
|
|
13905
15059
|
* Contains a set of updates to the component definition state
|
|
13906
15060
|
* of an entity.
|
|
13907
15061
|
*/
|
|
@@ -14044,7 +15198,6 @@ export interface EntityDamageSource {
|
|
|
14044
15198
|
}
|
|
14045
15199
|
|
|
14046
15200
|
/**
|
|
14047
|
-
* @beta
|
|
14048
15201
|
* Specifies additional filters that are used in registering a
|
|
14049
15202
|
* data driven trigger event for entities.
|
|
14050
15203
|
*/
|
|
@@ -14127,6 +15280,161 @@ export interface EntityHitInformation {
|
|
|
14127
15280
|
|
|
14128
15281
|
/**
|
|
14129
15282
|
* Contains options for selecting entities within an area.
|
|
15283
|
+
* @example testBlockConditional.ts
|
|
15284
|
+
* ```typescript
|
|
15285
|
+
* import { Dimension } from '@minecraft/server';
|
|
15286
|
+
*
|
|
15287
|
+
* // Having this command:
|
|
15288
|
+
*
|
|
15289
|
+
* // execute as @e[type=fox] positioned as @s if block ^ ^-1 ^ stone run summon salmon
|
|
15290
|
+
*
|
|
15291
|
+
* // Equivalent scripting code would be:
|
|
15292
|
+
* function spawnFish(dimension: Dimension) {
|
|
15293
|
+
* dimension
|
|
15294
|
+
* .getEntities({
|
|
15295
|
+
* type: 'fox',
|
|
15296
|
+
* })
|
|
15297
|
+
* .filter(entity => {
|
|
15298
|
+
* const block = dimension.getBlock({
|
|
15299
|
+
* x: entity.location.x,
|
|
15300
|
+
* y: entity.location.y - 1,
|
|
15301
|
+
* z: entity.location.z,
|
|
15302
|
+
* });
|
|
15303
|
+
*
|
|
15304
|
+
* return block !== undefined && block.matches('minecraft:stone');
|
|
15305
|
+
* })
|
|
15306
|
+
* .forEach(entity => {
|
|
15307
|
+
* dimension.spawnEntity('salmon', entity.location);
|
|
15308
|
+
* });
|
|
15309
|
+
* }
|
|
15310
|
+
* ```
|
|
15311
|
+
* @example testPlaySoundChained.ts
|
|
15312
|
+
* ```typescript
|
|
15313
|
+
* import { Dimension } from '@minecraft/server';
|
|
15314
|
+
*
|
|
15315
|
+
* // Having this command:
|
|
15316
|
+
*
|
|
15317
|
+
* // execute as @e[type=armor_stand,name=myArmorStand,tag=dummyTag1,tag=!dummyTag2] run playsound raid.horn @a
|
|
15318
|
+
*
|
|
15319
|
+
* // Equivalent scripting code would be:
|
|
15320
|
+
* function playSounds(dimension: Dimension) {
|
|
15321
|
+
* const targetPlayers = dimension.getPlayers();
|
|
15322
|
+
* const originEntities = dimension.getEntities({
|
|
15323
|
+
* type: 'armor_stand',
|
|
15324
|
+
* name: 'myArmorStand',
|
|
15325
|
+
* tags: ['dummyTag1'],
|
|
15326
|
+
* excludeTags: ['dummyTag2'],
|
|
15327
|
+
* });
|
|
15328
|
+
*
|
|
15329
|
+
* originEntities.forEach(entity => {
|
|
15330
|
+
* targetPlayers.forEach(player => {
|
|
15331
|
+
* player.playSound('raid.horn');
|
|
15332
|
+
* });
|
|
15333
|
+
* });
|
|
15334
|
+
* }
|
|
15335
|
+
* ```
|
|
15336
|
+
* @example testSendMessageAllPlayers.ts
|
|
15337
|
+
* ```typescript
|
|
15338
|
+
* import { Dimension } from '@minecraft/server';
|
|
15339
|
+
*
|
|
15340
|
+
* // Having this command:
|
|
15341
|
+
*
|
|
15342
|
+
* // execute as @e[type=armor_stand,name=myArmorStand,tag=dummyTag1,tag=!dummyTag2] run tellraw @a { "rawtext": [{"translate": "hello.world" }] }
|
|
15343
|
+
*
|
|
15344
|
+
* // Equivalent scripting code would be:
|
|
15345
|
+
* function sendMessagesToPlayers(dimension: Dimension) {
|
|
15346
|
+
* const targetPlayers = dimension.getPlayers();
|
|
15347
|
+
* const originEntities = dimension.getEntities({
|
|
15348
|
+
* type: 'armor_stand',
|
|
15349
|
+
* name: 'myArmorStand',
|
|
15350
|
+
* tags: ['dummyTag1'],
|
|
15351
|
+
* excludeTags: ['dummyTag2'],
|
|
15352
|
+
* });
|
|
15353
|
+
*
|
|
15354
|
+
* originEntities.forEach(entity => {
|
|
15355
|
+
* targetPlayers.forEach(player => {
|
|
15356
|
+
* player.sendMessage({ rawtext: [{ translate: 'hello.world' }] });
|
|
15357
|
+
* });
|
|
15358
|
+
* });
|
|
15359
|
+
* }
|
|
15360
|
+
* ```
|
|
15361
|
+
* @example testSetScoreBoardChained.ts
|
|
15362
|
+
* ```typescript
|
|
15363
|
+
* import { Dimension, world } from '@minecraft/server';
|
|
15364
|
+
*
|
|
15365
|
+
* // Having these commands:
|
|
15366
|
+
*
|
|
15367
|
+
* // scoreboard objectives add scoreObjective1 dummy
|
|
15368
|
+
* // scoreboard players set @e[type=armor_stand,name=myArmorStand] scoreObjective1 -1
|
|
15369
|
+
*
|
|
15370
|
+
* // Equivalent scripting code would be:
|
|
15371
|
+
* function setScores(dimension: Dimension) {
|
|
15372
|
+
* const objective = world.scoreboard.addObjective('scoreObjective1', 'dummy');
|
|
15373
|
+
* dimension
|
|
15374
|
+
* .getEntities({
|
|
15375
|
+
* type: 'armor_stand',
|
|
15376
|
+
* name: 'myArmorStand',
|
|
15377
|
+
* })
|
|
15378
|
+
* .forEach(entity => {
|
|
15379
|
+
* if (entity.scoreboardIdentity !== undefined) {
|
|
15380
|
+
* objective.setScore(entity.scoreboardIdentity, -1);
|
|
15381
|
+
* }
|
|
15382
|
+
* });
|
|
15383
|
+
* }
|
|
15384
|
+
* ```
|
|
15385
|
+
* @example testSummonMobChained.ts
|
|
15386
|
+
* ```typescript
|
|
15387
|
+
* import { Dimension } from '@minecraft/server';
|
|
15388
|
+
*
|
|
15389
|
+
* // Having this command:
|
|
15390
|
+
*
|
|
15391
|
+
* // execute as @e[type=armor_stand] run execute as @a[x=0,y=-60,z=0,c=4,r=15] run summon pig ~1 ~ ~
|
|
15392
|
+
*
|
|
15393
|
+
* // Equivalent scripting code would be:
|
|
15394
|
+
* function spawnPigs(dimension: Dimension) {
|
|
15395
|
+
* const armorStandArray = dimension.getEntities({
|
|
15396
|
+
* type: 'armor_stand',
|
|
15397
|
+
* });
|
|
15398
|
+
* const playerArray = dimension.getPlayers({
|
|
15399
|
+
* location: { x: 0, y: -60, z: 0 },
|
|
15400
|
+
* closest: 4,
|
|
15401
|
+
* maxDistance: 15,
|
|
15402
|
+
* });
|
|
15403
|
+
* armorStandArray.forEach(entity => {
|
|
15404
|
+
* playerArray.forEach(player => {
|
|
15405
|
+
* dimension.spawnEntity('pig', {
|
|
15406
|
+
* x: player.location.x + 1,
|
|
15407
|
+
* y: player.location.y,
|
|
15408
|
+
* z: player.location.z,
|
|
15409
|
+
* });
|
|
15410
|
+
* });
|
|
15411
|
+
* });
|
|
15412
|
+
* }
|
|
15413
|
+
* ```
|
|
15414
|
+
* @example checkFeatherNearby.ts
|
|
15415
|
+
* ```typescript
|
|
15416
|
+
* import { DimensionLocation, EntityComponentTypes } from "@minecraft/server";
|
|
15417
|
+
*
|
|
15418
|
+
* // Returns true if a feather item entity is within 'distance' blocks of 'location'.
|
|
15419
|
+
* function isFeatherNear(location: DimensionLocation, distance: number): boolean {
|
|
15420
|
+
* const items = location.dimension.getEntities({
|
|
15421
|
+
* location: location,
|
|
15422
|
+
* maxDistance: 20,
|
|
15423
|
+
* });
|
|
15424
|
+
*
|
|
15425
|
+
* for (const item of items) {
|
|
15426
|
+
* const itemComp = item.getComponent(EntityComponentTypes.Item);
|
|
15427
|
+
*
|
|
15428
|
+
* if (itemComp) {
|
|
15429
|
+
* if (itemComp.itemStack.typeId.endsWith('feather')) {
|
|
15430
|
+
* return true;
|
|
15431
|
+
* }
|
|
15432
|
+
* }
|
|
15433
|
+
* }
|
|
15434
|
+
*
|
|
15435
|
+
* return false;
|
|
15436
|
+
* }
|
|
15437
|
+
* ```
|
|
14130
15438
|
*/
|
|
14131
15439
|
export interface EntityQueryOptions {
|
|
14132
15440
|
/**
|
|
@@ -14363,6 +15671,22 @@ export interface EntityRaycastOptions {
|
|
|
14363
15671
|
* @beta
|
|
14364
15672
|
* Additional configuration options for the {@link
|
|
14365
15673
|
* Dimension.createExplosion} method.
|
|
15674
|
+
* @example createExplosions.ts
|
|
15675
|
+
* ```typescript
|
|
15676
|
+
* // Creates an explosion of radius 15 that does not break blocks
|
|
15677
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
15678
|
+
*
|
|
15679
|
+
* function createExplosions(location: DimensionLocation) {
|
|
15680
|
+
* // Creates an explosion of radius 15 that does not break blocks
|
|
15681
|
+
* location.dimension.createExplosion(location, 15, { breaksBlocks: false });
|
|
15682
|
+
*
|
|
15683
|
+
* // Creates an explosion of radius 15 that does not cause fire
|
|
15684
|
+
* location.dimension.createExplosion(location, 15, { causesFire: true });
|
|
15685
|
+
*
|
|
15686
|
+
* // Creates an explosion of radius 10 that can go underwater
|
|
15687
|
+
* location.dimension.createExplosion(location, 10, { allowUnderwater: true });
|
|
15688
|
+
* }
|
|
15689
|
+
* ```
|
|
14366
15690
|
*/
|
|
14367
15691
|
export interface ExplosionOptions {
|
|
14368
15692
|
/**
|
|
@@ -14491,6 +15815,67 @@ export interface ProjectileShootOptions {
|
|
|
14491
15815
|
|
|
14492
15816
|
/**
|
|
14493
15817
|
* Defines a JSON structure that is used for more flexible.
|
|
15818
|
+
* @example addTranslatedSign.ts
|
|
15819
|
+
* ```typescript
|
|
15820
|
+
* import { DimensionLocation, world, BlockPermutation, BlockComponentTypes } from '@minecraft/server';
|
|
15821
|
+
*
|
|
15822
|
+
* function placeTranslatedSign(location: DimensionLocation, text: string) {
|
|
15823
|
+
* const signBlock = location.dimension.getBlock(location);
|
|
15824
|
+
*
|
|
15825
|
+
* if (!signBlock) {
|
|
15826
|
+
* console.warn('Could not find a block at specified location.');
|
|
15827
|
+
* return;
|
|
15828
|
+
* }
|
|
15829
|
+
* const signPerm = BlockPermutation.resolve('minecraft:standing_sign', { ground_sign_direction: 8 });
|
|
15830
|
+
* signBlock.setPermutation(signPerm);
|
|
15831
|
+
*
|
|
15832
|
+
* const signComponent = signBlock.getComponent(BlockComponentTypes.Sign);
|
|
15833
|
+
* if (signComponent) {
|
|
15834
|
+
* signComponent.setText({ translate: 'item.skull.player.name', with: [text] });
|
|
15835
|
+
* } else {
|
|
15836
|
+
* console.error('Could not find a sign component on the block.');
|
|
15837
|
+
* }
|
|
15838
|
+
* }
|
|
15839
|
+
*
|
|
15840
|
+
* placeTranslatedSign(
|
|
15841
|
+
* {
|
|
15842
|
+
* dimension: world.getDimension('overworld'),
|
|
15843
|
+
* x: 0,
|
|
15844
|
+
* y: 0,
|
|
15845
|
+
* z: 0,
|
|
15846
|
+
* },
|
|
15847
|
+
* 'Steve',
|
|
15848
|
+
* );
|
|
15849
|
+
* ```
|
|
15850
|
+
* @example showTranslatedMessageForm.ts
|
|
15851
|
+
* ```typescript
|
|
15852
|
+
* import { world, Player } from '@minecraft/server';
|
|
15853
|
+
* import { MessageFormData, MessageFormResponse } from '@minecraft/server-ui';
|
|
15854
|
+
*
|
|
15855
|
+
* function showMessage(player: Player) {
|
|
15856
|
+
* const messageForm = new MessageFormData()
|
|
15857
|
+
* .title({ translate: 'permissions.removeplayer' })
|
|
15858
|
+
* .body({ translate: 'accessibility.list.or.two', with: ['Player 1', 'Player 2'] })
|
|
15859
|
+
* .button1('Player 1')
|
|
15860
|
+
* .button2('Player 2');
|
|
15861
|
+
*
|
|
15862
|
+
* messageForm
|
|
15863
|
+
* .show(player)
|
|
15864
|
+
* .then((formData: MessageFormResponse) => {
|
|
15865
|
+
* // player canceled the form, or another dialog was up and open.
|
|
15866
|
+
* if (formData.canceled || formData.selection === undefined) {
|
|
15867
|
+
* return;
|
|
15868
|
+
* }
|
|
15869
|
+
*
|
|
15870
|
+
* console.warn(`You selected ${formData.selection === 0 ? 'Player 1' : 'Player 2'}`);
|
|
15871
|
+
* })
|
|
15872
|
+
* .catch((error: Error) => {
|
|
15873
|
+
* console.warn('Failed to show form: ' + error);
|
|
15874
|
+
* });
|
|
15875
|
+
* };
|
|
15876
|
+
*
|
|
15877
|
+
* showMessage(world.getAllPlayers()[0]);
|
|
15878
|
+
* ```
|
|
14494
15879
|
*/
|
|
14495
15880
|
export interface RawMessage {
|
|
14496
15881
|
/**
|
|
@@ -14640,8 +16025,64 @@ export interface ScriptEventMessageFilterOptions {
|
|
|
14640
16025
|
namespaces: string[];
|
|
14641
16026
|
}
|
|
14642
16027
|
|
|
16028
|
+
/**
|
|
16029
|
+
* @beta
|
|
16030
|
+
*/
|
|
16031
|
+
export interface StructureCreateOptions {
|
|
16032
|
+
includeBlocks?: boolean;
|
|
16033
|
+
includeEntities?: boolean;
|
|
16034
|
+
saveMode?: StructureSaveMode;
|
|
16035
|
+
}
|
|
16036
|
+
|
|
16037
|
+
/**
|
|
16038
|
+
* @beta
|
|
16039
|
+
*/
|
|
16040
|
+
export interface StructurePlaceOptions {
|
|
16041
|
+
animationMode?: StructureAnimationMode;
|
|
16042
|
+
animationSeconds?: number;
|
|
16043
|
+
includeBlocks?: boolean;
|
|
16044
|
+
includeEntities?: boolean;
|
|
16045
|
+
integrity?: number;
|
|
16046
|
+
integritySeed?: string;
|
|
16047
|
+
mirror?: StructureMirrorAxis;
|
|
16048
|
+
rotation?: StructureRotation;
|
|
16049
|
+
waterlogged?: boolean;
|
|
16050
|
+
}
|
|
16051
|
+
|
|
16052
|
+
/**
|
|
16053
|
+
* @beta
|
|
16054
|
+
*/
|
|
16055
|
+
export interface StructureReadOptions {
|
|
16056
|
+
includeBlocks?: boolean;
|
|
16057
|
+
includeEntities?: boolean;
|
|
16058
|
+
}
|
|
16059
|
+
|
|
14643
16060
|
/**
|
|
14644
16061
|
* Contains additional options for teleporting an entity.
|
|
16062
|
+
* @example teleportMovement.ts
|
|
16063
|
+
* ```typescript
|
|
16064
|
+
* import { world, system } from '@minecraft/server';
|
|
16065
|
+
*
|
|
16066
|
+
* const overworld = world.getDimension('overworld');
|
|
16067
|
+
* const targetLocation = { x: 0, y: 0, z: 0 };
|
|
16068
|
+
*
|
|
16069
|
+
* const pig = overworld.spawnEntity('minecraft:pig', targetLocation);
|
|
16070
|
+
*
|
|
16071
|
+
* let inc = 1;
|
|
16072
|
+
* const runId = system.runInterval(() => {
|
|
16073
|
+
* pig.teleport(
|
|
16074
|
+
* { x: targetLocation.x + inc / 4, y: targetLocation.y + inc / 4, z: targetLocation.z + inc / 4 },
|
|
16075
|
+
* {
|
|
16076
|
+
* facingLocation: targetLocation,
|
|
16077
|
+
* },
|
|
16078
|
+
* );
|
|
16079
|
+
*
|
|
16080
|
+
* if (inc > 100) {
|
|
16081
|
+
* system.clearRun(runId);
|
|
16082
|
+
* }
|
|
16083
|
+
* inc++;
|
|
16084
|
+
* }, 4);
|
|
16085
|
+
* ```
|
|
14645
16086
|
*/
|
|
14646
16087
|
export interface TeleportOptions {
|
|
14647
16088
|
/**
|
|
@@ -14815,6 +16256,14 @@ export class InvalidContainerSlotError extends Error {
|
|
|
14815
16256
|
private constructor();
|
|
14816
16257
|
}
|
|
14817
16258
|
|
|
16259
|
+
/**
|
|
16260
|
+
* @beta
|
|
16261
|
+
*/
|
|
16262
|
+
// @ts-ignore Class inheritance allowed for native defined classes
|
|
16263
|
+
export class InvalidStructureError extends Error {
|
|
16264
|
+
private constructor();
|
|
16265
|
+
}
|
|
16266
|
+
|
|
14818
16267
|
// @ts-ignore Class inheritance allowed for native defined classes
|
|
14819
16268
|
export class LocationInUnloadedChunkError extends Error {
|
|
14820
16269
|
private constructor();
|