@minecraft/server 1.3.0-beta.1.20.0-preview.24 → 1.3.0-beta.1.20.0-preview.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +197 -219
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* ```json
|
|
17
17
|
* {
|
|
18
18
|
* "module_name": "@minecraft/server",
|
|
19
|
-
* "version": "1.3.0-internal.1.20.0-preview.
|
|
19
|
+
* "version": "1.3.0-internal.1.20.0-preview.25"
|
|
20
20
|
* }
|
|
21
21
|
* ```
|
|
22
22
|
*
|
|
@@ -792,15 +792,14 @@ export class Block {
|
|
|
792
792
|
* @throws This function can throw errors.
|
|
793
793
|
* @example check_block_tags.js
|
|
794
794
|
* ```typescript
|
|
795
|
-
*
|
|
795
|
+
* import { world } from "@minecraft/server";
|
|
796
796
|
*
|
|
797
|
-
*
|
|
798
|
-
*
|
|
799
|
-
*
|
|
800
|
-
* console.log(`Block is dirt: ${block.hasTag("dirt")}`);
|
|
801
|
-
* console.log(`Block is wood: ${block.hasTag("wood")}`);
|
|
802
|
-
* console.log(`Block is stone: ${block.hasTag("stone")}`);
|
|
797
|
+
* // Fetch the block
|
|
798
|
+
* const block = world.getDimension("overworld").getBlock({ x: 1, y: 2, z: 3 });
|
|
803
799
|
*
|
|
800
|
+
* console.log(`Block is dirt: ${block.hasTag("dirt")}`);
|
|
801
|
+
* console.log(`Block is wood: ${block.hasTag("wood")}`);
|
|
802
|
+
* console.log(`Block is stone: ${block.hasTag("stone")}`);
|
|
804
803
|
* ```
|
|
805
804
|
*/
|
|
806
805
|
hasTag(tag: string): boolean;
|
|
@@ -1180,16 +1179,15 @@ export class BlockPermutation {
|
|
|
1180
1179
|
* Returns `true` if the permutation has the tag, else `false`.
|
|
1181
1180
|
* @example check_block_tags.js
|
|
1182
1181
|
* ```typescript
|
|
1183
|
-
*
|
|
1184
|
-
*
|
|
1185
|
-
* // Fetch the block
|
|
1186
|
-
* const block = world.getDimension("overworld").getBlock({ x: 1, y: 2, z: 3 });
|
|
1187
|
-
* const blockPerm = block.getPermutation();
|
|
1182
|
+
* import { world } from "@minecraft/server";
|
|
1188
1183
|
*
|
|
1189
|
-
*
|
|
1190
|
-
*
|
|
1191
|
-
*
|
|
1184
|
+
* // Fetch the block
|
|
1185
|
+
* const block = world.getDimension("overworld").getBlock({ x: 1, y: 2, z: 3 });
|
|
1186
|
+
* const blockPerm = block.getPermutation();
|
|
1192
1187
|
*
|
|
1188
|
+
* console.log(`Block is dirt: ${blockPerm.hasTag("dirt")}`);
|
|
1189
|
+
* console.log(`Block is wood: ${blockPerm.hasTag("wood")}`);
|
|
1190
|
+
* console.log(`Block is stone: ${blockPerm.hasTag("stone")}`);
|
|
1193
1191
|
* ```
|
|
1194
1192
|
*/
|
|
1195
1193
|
hasTag(tag: string): boolean;
|
|
@@ -1456,27 +1454,27 @@ export class BlockSignComponent extends BlockComponent {
|
|
|
1456
1454
|
* @throws This function can throw errors.
|
|
1457
1455
|
* @example SetRawMessage.ts
|
|
1458
1456
|
* ```typescript
|
|
1459
|
-
*
|
|
1460
|
-
*
|
|
1457
|
+
* const helloWorldMessage: RawMessage = { text: 'Hello World' };
|
|
1458
|
+
* sign.setText(helloWorldMessage);
|
|
1461
1459
|
*
|
|
1462
|
-
*
|
|
1463
|
-
*
|
|
1464
|
-
*
|
|
1460
|
+
* // Sign text will be saved as a RawText
|
|
1461
|
+
* const result: RawText = sign.getRawText();
|
|
1462
|
+
* JSON.stringify(result); // { rawtext: [{ text: 'Hello World' }] };
|
|
1465
1463
|
* ```
|
|
1466
1464
|
* @example SetRawText.ts
|
|
1467
1465
|
* ```typescript
|
|
1468
|
-
*
|
|
1469
|
-
*
|
|
1466
|
+
* const helloWorldText: RawText = { rawtext: [{ text: 'Hello World' }] };
|
|
1467
|
+
* sign.setText(helloWorldText);
|
|
1470
1468
|
*
|
|
1471
|
-
*
|
|
1472
|
-
*
|
|
1473
|
-
*
|
|
1469
|
+
* // There will be no data transformation unlike calling setText with a RawMessage
|
|
1470
|
+
* const result: RawText = sign.getRawText();
|
|
1471
|
+
* JSON.stringify(result); // { rawtext: [{ text: 'Hello World' }] };
|
|
1474
1472
|
* ```
|
|
1475
1473
|
* @example SetString.ts
|
|
1476
1474
|
* ```typescript
|
|
1477
|
-
*
|
|
1478
|
-
*
|
|
1479
|
-
*
|
|
1475
|
+
* // Set sign to say 'Hello'
|
|
1476
|
+
* sign.setText('Hello');
|
|
1477
|
+
* sign.getText(); // 'Hello'
|
|
1480
1478
|
* ```
|
|
1481
1479
|
*/
|
|
1482
1480
|
setText(message: RawMessage | RawText | string, side?: SignSide): void;
|
|
@@ -2262,10 +2260,9 @@ export class Container {
|
|
|
2262
2260
|
* out of bounds.
|
|
2263
2261
|
* @example getItem.ts
|
|
2264
2262
|
* ```typescript
|
|
2265
|
-
*
|
|
2266
|
-
*
|
|
2267
|
-
*
|
|
2268
|
-
*
|
|
2263
|
+
* // Get a copy of the first item in the player's hotbar
|
|
2264
|
+
* const inventory = player.getComponent("inventory") as EntityInventoryComponent;
|
|
2265
|
+
* const itemStack = inventory.container.getItem(0);
|
|
2269
2266
|
* ```
|
|
2270
2267
|
*/
|
|
2271
2268
|
getItem(slot: number): ItemStack | undefined;
|
|
@@ -2304,11 +2301,10 @@ export class Container {
|
|
|
2304
2301
|
* or if the `fromSlot` or `toSlot` indices out of bounds.
|
|
2305
2302
|
* @example moveItem.ts
|
|
2306
2303
|
* ```typescript
|
|
2307
|
-
*
|
|
2308
|
-
*
|
|
2309
|
-
*
|
|
2310
|
-
*
|
|
2311
|
-
*
|
|
2304
|
+
* // Move an item from the first slot of fromPlayer's inventory to the fifth slot of toPlayer's inventory
|
|
2305
|
+
* const fromInventory = fromPlayer.getComponent('inventory') as EntityInventoryComponent;
|
|
2306
|
+
* const toInventory = toPlayer.getComponent('inventory') as EntityInventoryComponent;
|
|
2307
|
+
* fromInventory.container.moveItem(0, 4, toInventory.container);
|
|
2312
2308
|
* ```
|
|
2313
2309
|
*/
|
|
2314
2310
|
moveItem(fromSlot: number, toSlot: number, toContainer: Container): void;
|
|
@@ -2346,10 +2342,9 @@ export class Container {
|
|
|
2346
2342
|
* invalid or if the `slot` or `otherSlot` are out of bounds.
|
|
2347
2343
|
* @example swapItems.ts
|
|
2348
2344
|
* ```typescript
|
|
2349
|
-
*
|
|
2350
|
-
*
|
|
2351
|
-
*
|
|
2352
|
-
*
|
|
2345
|
+
* // Swaps an item between slots 0 and 4 in the player's inventory
|
|
2346
|
+
* const inventory = fromPlayer.getComponent('inventory') as EntityInventoryComponent;
|
|
2347
|
+
* inventory.container.swapItems(0, 4, inventory);
|
|
2353
2348
|
* ```
|
|
2354
2349
|
*/
|
|
2355
2350
|
swapItems(slot: number, otherSlot: number, otherContainer: Container): void;
|
|
@@ -2371,11 +2366,10 @@ export class Container {
|
|
|
2371
2366
|
* or if the `fromSlot` or `toSlot` indices out of bounds.
|
|
2372
2367
|
* @example transferItem.ts
|
|
2373
2368
|
* ```typescript
|
|
2374
|
-
*
|
|
2375
|
-
*
|
|
2376
|
-
*
|
|
2377
|
-
*
|
|
2378
|
-
*
|
|
2369
|
+
* // Transfer an item from the first slot of fromPlayer's inventory to toPlayer's inventory
|
|
2370
|
+
* const fromInventory = fromPlayer.getComponent('inventory') as EntityInventoryComponent;
|
|
2371
|
+
* const toInventory = toPlayer.getComponent('inventory') as EntityInventoryComponent;
|
|
2372
|
+
* fromInventory.container.transferItem(0, toInventory.container);
|
|
2379
2373
|
* ```
|
|
2380
2374
|
*/
|
|
2381
2375
|
transferItem(fromSlot: number, toContainer: Container): ItemStack;
|
|
@@ -2789,43 +2783,41 @@ export class Dimension {
|
|
|
2789
2783
|
* @throws This function can throw errors.
|
|
2790
2784
|
* @example createExplosion.ts
|
|
2791
2785
|
* ```typescript
|
|
2792
|
-
*
|
|
2786
|
+
* overworld.createExplosion(targetLocation, 10, new mc.ExplosionOptions());
|
|
2793
2787
|
* ```
|
|
2794
2788
|
* @example createFireAndWaterExplosions.ts
|
|
2795
2789
|
* ```typescript
|
|
2796
|
-
*
|
|
2797
|
-
*
|
|
2798
|
-
* const fireExplosionOptions = new mc.ExplosionOptions();
|
|
2790
|
+
* const explosionLoc: mc.Vector3 = { x: targetLocation.x + 0.5, y: targetLocation.y + 0.5, z: targetLocation.z + 0.5 };
|
|
2799
2791
|
*
|
|
2800
|
-
*
|
|
2801
|
-
* fireExplosionOptions.causesFire = true;
|
|
2792
|
+
* const fireExplosionOptions = new mc.ExplosionOptions();
|
|
2802
2793
|
*
|
|
2803
|
-
*
|
|
2804
|
-
*
|
|
2794
|
+
* // Explode with fire
|
|
2795
|
+
* fireExplosionOptions.causesFire = true;
|
|
2805
2796
|
*
|
|
2806
|
-
*
|
|
2807
|
-
*
|
|
2797
|
+
* overworld.createExplosion(explosionLoc, 15, fireExplosionOptions);
|
|
2798
|
+
* const waterExplosionOptions = new mc.ExplosionOptions();
|
|
2808
2799
|
*
|
|
2809
|
-
*
|
|
2800
|
+
* // Explode in water
|
|
2801
|
+
* waterExplosionOptions.allowUnderwater = true;
|
|
2810
2802
|
*
|
|
2811
|
-
*
|
|
2803
|
+
* const belowWaterLoc: mc.Vector3 = { x: targetLocation.x + 3, y: targetLocation.y + 1, z: targetLocation.z + 3 };
|
|
2812
2804
|
*
|
|
2805
|
+
* overworld.createExplosion(belowWaterLoc, 10, waterExplosionOptions);
|
|
2813
2806
|
* ```
|
|
2814
2807
|
* @example createNoBlockExplosion.ts
|
|
2815
2808
|
* ```typescript
|
|
2816
|
-
*
|
|
2809
|
+
* const explosionOptions = new mc.ExplosionOptions();
|
|
2817
2810
|
*
|
|
2818
|
-
*
|
|
2819
|
-
*
|
|
2811
|
+
* // Start by exploding without breaking blocks
|
|
2812
|
+
* explosionOptions.breaksBlocks = false;
|
|
2820
2813
|
*
|
|
2821
|
-
*
|
|
2822
|
-
*
|
|
2823
|
-
*
|
|
2824
|
-
*
|
|
2825
|
-
*
|
|
2826
|
-
*
|
|
2827
|
-
* overworld.createExplosion(explodeNoBlocksLoc, 15, explosionOptions);
|
|
2814
|
+
* const explodeNoBlocksLoc: mc.Vector3 = {
|
|
2815
|
+
* x: Math.floor(targetLocation.x + 1),
|
|
2816
|
+
* y: Math.floor(targetLocation.y + 2),
|
|
2817
|
+
* z: Math.floor(targetLocation.z + 1),
|
|
2818
|
+
* };
|
|
2828
2819
|
*
|
|
2820
|
+
* overworld.createExplosion(explodeNoBlocksLoc, 15, explosionOptions);
|
|
2829
2821
|
* ```
|
|
2830
2822
|
*/
|
|
2831
2823
|
createExplosion(location: Vector3, radius: number, explosionOptions?: ExplosionOptions): void;
|
|
@@ -2892,22 +2884,21 @@ export class Dimension {
|
|
|
2892
2884
|
* @throws This function can throw errors.
|
|
2893
2885
|
* @example testThatEntityIsFeatherItem.ts
|
|
2894
2886
|
* ```typescript
|
|
2895
|
-
*
|
|
2896
|
-
*
|
|
2897
|
-
*
|
|
2898
|
-
*
|
|
2899
|
-
*
|
|
2900
|
-
*
|
|
2901
|
-
*
|
|
2902
|
-
*
|
|
2903
|
-
*
|
|
2904
|
-
*
|
|
2905
|
-
*
|
|
2906
|
-
*
|
|
2907
|
-
*
|
|
2908
|
-
*
|
|
2909
|
-
*
|
|
2910
|
-
*
|
|
2887
|
+
* const query = {
|
|
2888
|
+
* type: "item",
|
|
2889
|
+
* location: targetLocation,
|
|
2890
|
+
* };
|
|
2891
|
+
* const items = overworld.getEntities(query);
|
|
2892
|
+
*
|
|
2893
|
+
* for (const item of items) {
|
|
2894
|
+
* const itemComp = item.getComponent("item") as any;
|
|
2895
|
+
*
|
|
2896
|
+
* if (itemComp) {
|
|
2897
|
+
* if (itemComp.itemStack.id.endsWith("feather")) {
|
|
2898
|
+
* console.log("Success! Found a feather", 1);
|
|
2899
|
+
* }
|
|
2900
|
+
* }
|
|
2901
|
+
* }
|
|
2911
2902
|
* ```
|
|
2912
2903
|
*/
|
|
2913
2904
|
getEntities(options?: EntityQueryOptions): Entity[];
|
|
@@ -2996,41 +2987,40 @@ export class Dimension {
|
|
|
2996
2987
|
* @throws This function can throw errors.
|
|
2997
2988
|
* @example createOldHorse.ts
|
|
2998
2989
|
* ```typescript
|
|
2999
|
-
*
|
|
3000
|
-
*
|
|
2990
|
+
* // create a horse and trigger the 'ageable_grow_up' event, ensuring the horse is created as an adult
|
|
2991
|
+
* overworld.spawnEntity("minecraft:horse<minecraft:ageable_grow_up>", targetLocation);
|
|
3001
2992
|
* ```
|
|
3002
2993
|
* @example quickFoxLazyDog.ts
|
|
3003
2994
|
* ```typescript
|
|
3004
|
-
*
|
|
3005
|
-
*
|
|
3006
|
-
*
|
|
3007
|
-
*
|
|
3008
|
-
*
|
|
3009
|
-
*
|
|
3010
|
-
*
|
|
3011
|
-
*
|
|
3012
|
-
*
|
|
3013
|
-
*
|
|
3014
|
-
*
|
|
3015
|
-
*
|
|
3016
|
-
*
|
|
3017
|
-
*
|
|
3018
|
-
*
|
|
3019
|
-
*
|
|
3020
|
-
*
|
|
2995
|
+
* const fox = overworld.spawnEntity("minecraft:fox", {
|
|
2996
|
+
* x: targetLocation.x + 1,
|
|
2997
|
+
* y: targetLocation.y + 2,
|
|
2998
|
+
* z: targetLocation.z + 3,
|
|
2999
|
+
* });
|
|
3000
|
+
* fox.addEffect(mc.MinecraftEffectTypes.speed, 10, 20);
|
|
3001
|
+
* log("Created a fox.");
|
|
3002
|
+
*
|
|
3003
|
+
* const wolf = overworld.spawnEntity("minecraft:wolf", {
|
|
3004
|
+
* x: targetLocation.x + 4,
|
|
3005
|
+
* y: targetLocation.y + 2,
|
|
3006
|
+
* z: targetLocation.z + 3,
|
|
3007
|
+
* });
|
|
3008
|
+
* wolf.addEffect(mc.MinecraftEffectTypes.slowness, 10, 20);
|
|
3009
|
+
* wolf.isSneaking = true;
|
|
3010
|
+
* log("Created a sneaking wolf.", 1);
|
|
3021
3011
|
* ```
|
|
3022
3012
|
* @example trapTick.ts
|
|
3023
3013
|
* ```typescript
|
|
3024
|
-
*
|
|
3014
|
+
* let ticks = 0;
|
|
3025
3015
|
*
|
|
3026
|
-
*
|
|
3027
|
-
*
|
|
3016
|
+
* mc.world.events.tick.subscribe((event: mc.TickEvent) => {
|
|
3017
|
+
* ticks++;
|
|
3028
3018
|
*
|
|
3029
|
-
*
|
|
3030
|
-
*
|
|
3031
|
-
*
|
|
3032
|
-
*
|
|
3033
|
-
*
|
|
3019
|
+
* // Minecraft runs at 20 ticks per second
|
|
3020
|
+
* if (ticks % 1200 === 0) {
|
|
3021
|
+
* overworld.runCommand("say Another minute passes...");
|
|
3022
|
+
* }
|
|
3023
|
+
* });
|
|
3034
3024
|
* ```
|
|
3035
3025
|
*/
|
|
3036
3026
|
spawnEntity(identifier: string, location: Vector3): Entity;
|
|
@@ -3049,25 +3039,24 @@ export class Dimension {
|
|
|
3049
3039
|
* @throws This function can throw errors.
|
|
3050
3040
|
* @example itemStacks.ts
|
|
3051
3041
|
* ```typescript
|
|
3052
|
-
*
|
|
3053
|
-
*
|
|
3054
|
-
*
|
|
3042
|
+
* const oneItemLoc: mc.Vector3 = { x: 3, y: 2, z: 1 };
|
|
3043
|
+
* const fiveItemsLoc: mc.Vector3 = { x: 1, y: 2, z: 1 };
|
|
3044
|
+
* const diamondPickaxeLoc: mc.Vector3 = { x: 2, y: 2, z: 4 };
|
|
3055
3045
|
*
|
|
3056
|
-
*
|
|
3057
|
-
*
|
|
3058
|
-
*
|
|
3059
|
-
*
|
|
3060
|
-
* overworld.spawnItem(oneEmerald, oneItemLoc);
|
|
3061
|
-
* overworld.spawnItem(fiveEmeralds, fiveItemsLoc);
|
|
3062
|
-
* overworld.spawnItem(onePickaxe, diamondPickaxeLoc);
|
|
3046
|
+
* const oneEmerald = new mc.ItemStack(mc.MinecraftItemTypes.emerald, 1, 0);
|
|
3047
|
+
* const onePickaxe = new mc.ItemStack(mc.MinecraftItemTypes.diamondPickaxe, 1, 0);
|
|
3048
|
+
* const fiveEmeralds = new mc.ItemStack(mc.MinecraftItemTypes.emerald, 5, 0);
|
|
3063
3049
|
*
|
|
3050
|
+
* overworld.spawnItem(oneEmerald, oneItemLoc);
|
|
3051
|
+
* overworld.spawnItem(fiveEmeralds, fiveItemsLoc);
|
|
3052
|
+
* overworld.spawnItem(onePickaxe, diamondPickaxeLoc);
|
|
3064
3053
|
* ```
|
|
3065
3054
|
* @example spawnItem.ts
|
|
3066
3055
|
* ```typescript
|
|
3067
|
-
*
|
|
3056
|
+
* const featherItem = new mc.ItemStack(mc.MinecraftItemTypes.feather, 1, 0);
|
|
3068
3057
|
*
|
|
3069
|
-
*
|
|
3070
|
-
*
|
|
3058
|
+
* overworld.spawnItem(featherItem, targetLocation);
|
|
3059
|
+
* log("New feather created!");
|
|
3071
3060
|
* ```
|
|
3072
3061
|
*/
|
|
3073
3062
|
spawnItem(itemStack: ItemStack, location: Vector3): Entity;
|
|
@@ -3526,7 +3515,7 @@ export class Entity {
|
|
|
3526
3515
|
/**
|
|
3527
3516
|
* @beta
|
|
3528
3517
|
* @remarks
|
|
3529
|
-
* Adds an effect, like poison, to the entity.
|
|
3518
|
+
* Adds or updates an effect, like poison, to the entity.
|
|
3530
3519
|
*
|
|
3531
3520
|
* This function can't be called in read-only mode.
|
|
3532
3521
|
*
|
|
@@ -3540,39 +3529,38 @@ export class Entity {
|
|
|
3540
3529
|
* @param options
|
|
3541
3530
|
* Additional options for the effect.
|
|
3542
3531
|
* @returns
|
|
3543
|
-
* Returns
|
|
3544
|
-
*
|
|
3545
|
-
* ranges
|
|
3532
|
+
* Returns nothing if the effect was added or updated
|
|
3533
|
+
* successfully. This can throw an error if the duration or
|
|
3534
|
+
* amplifier are outside of the valid ranges, or if the effect
|
|
3535
|
+
* does not exist.
|
|
3546
3536
|
* @throws This function can throw errors.
|
|
3547
3537
|
* @example addEffect.js
|
|
3548
3538
|
* ```typescript
|
|
3549
|
-
*
|
|
3550
|
-
*
|
|
3551
|
-
*
|
|
3552
|
-
*
|
|
3553
|
-
*
|
|
3554
|
-
* villager.addEffect(EffectTypes.get('poison'), duration, { amplifier: 1 });
|
|
3539
|
+
* const villagerId = 'minecraft:villager_v2<minecraft:ageable_grow_up>';
|
|
3540
|
+
* const villagerLoc: mc.Vector3 = { x: 1, y: 2, z: 1 };
|
|
3541
|
+
* const villager = test.spawn(villagerId, villagerLoc);
|
|
3542
|
+
* const duration = 20;
|
|
3555
3543
|
*
|
|
3544
|
+
* villager.addEffect(EffectTypes.get('poison'), duration, { amplifier: 1 });
|
|
3556
3545
|
* ```
|
|
3557
3546
|
* @example quickFoxLazyDog.ts
|
|
3558
3547
|
* ```typescript
|
|
3559
|
-
*
|
|
3560
|
-
*
|
|
3561
|
-
*
|
|
3562
|
-
*
|
|
3563
|
-
*
|
|
3564
|
-
*
|
|
3565
|
-
*
|
|
3566
|
-
*
|
|
3567
|
-
*
|
|
3568
|
-
*
|
|
3569
|
-
*
|
|
3570
|
-
*
|
|
3571
|
-
*
|
|
3572
|
-
*
|
|
3573
|
-
*
|
|
3574
|
-
*
|
|
3575
|
-
*
|
|
3548
|
+
* const fox = overworld.spawnEntity('minecraft:fox', {
|
|
3549
|
+
* x: targetLocation.x + 1,
|
|
3550
|
+
* y: targetLocation.y + 2,
|
|
3551
|
+
* z: targetLocation.z + 3,
|
|
3552
|
+
* });
|
|
3553
|
+
* fox.addEffect(mc.MinecraftEffectTypes.speed, 10, { amplifier: 20 });
|
|
3554
|
+
* log('Created a fox.');
|
|
3555
|
+
*
|
|
3556
|
+
* const wolf = overworld.spawnEntity('minecraft:wolf', {
|
|
3557
|
+
* x: targetLocation.x + 4,
|
|
3558
|
+
* y: targetLocation.y + 2,
|
|
3559
|
+
* z: targetLocation.z + 3,
|
|
3560
|
+
* });
|
|
3561
|
+
* wolf.addEffect(mc.MinecraftEffectTypes.slowness, 10, { amplifier: 20 });
|
|
3562
|
+
* wolf.isSneaking = true;
|
|
3563
|
+
* log('Created a sneaking wolf.', 1);
|
|
3576
3564
|
* ```
|
|
3577
3565
|
*/
|
|
3578
3566
|
addEffect(effectType: EffectType | string, duration: number, options?: EntityEffectOptions): boolean;
|
|
@@ -3729,13 +3717,15 @@ export class Entity {
|
|
|
3729
3717
|
* @beta
|
|
3730
3718
|
* @remarks
|
|
3731
3719
|
* Returns the effect for the specified EffectType on the
|
|
3732
|
-
* entity,
|
|
3720
|
+
* entity, undefined if the effect is not present, or throws an
|
|
3721
|
+
* error if the effect does not exist.
|
|
3733
3722
|
*
|
|
3734
3723
|
* @param effectType
|
|
3735
3724
|
* The effect identifier.
|
|
3736
3725
|
* @returns
|
|
3737
|
-
* Effect object for the specified effect,
|
|
3738
|
-
* effect is not present
|
|
3726
|
+
* Effect object for the specified effect, undefined if the
|
|
3727
|
+
* effect is not present, or throws an error if the effect does
|
|
3728
|
+
* not exist.
|
|
3739
3729
|
* @throws This function can throw errors.
|
|
3740
3730
|
*/
|
|
3741
3731
|
getEffect(effectType: EffectType | string): Effect | undefined;
|
|
@@ -3893,8 +3883,9 @@ export class Entity {
|
|
|
3893
3883
|
* @param effectType
|
|
3894
3884
|
* The effect identifier.
|
|
3895
3885
|
* @returns
|
|
3896
|
-
* Returns true if the effect has been removed
|
|
3897
|
-
* effect is not present
|
|
3886
|
+
* Returns true if the effect has been removed, false if the
|
|
3887
|
+
* effect is not present, or will throw an error if the effect
|
|
3888
|
+
* does not exist.
|
|
3898
3889
|
* @throws This function can throw errors.
|
|
3899
3890
|
*/
|
|
3900
3891
|
removeEffect(effectType: EffectType | string): boolean;
|
|
@@ -7392,11 +7383,10 @@ export class ItemStack {
|
|
|
7392
7383
|
* stack, undefined is returned.
|
|
7393
7384
|
* @example durability.ts
|
|
7394
7385
|
* ```typescript
|
|
7395
|
-
*
|
|
7396
|
-
*
|
|
7397
|
-
*
|
|
7398
|
-
*
|
|
7399
|
-
*
|
|
7386
|
+
* // Get the maximum durability of a custom sword item
|
|
7387
|
+
* const itemStack = new ItemStack("custom:sword");
|
|
7388
|
+
* const durability = itemStack.getComponent("minecraft:durability") as ItemDurabilityComponent;
|
|
7389
|
+
* const maxDurability = durability.maxDurability;
|
|
7400
7390
|
* ```
|
|
7401
7391
|
*/
|
|
7402
7392
|
getComponent(componentId: string): ItemComponent | undefined;
|
|
@@ -7472,10 +7462,9 @@ export class ItemStack {
|
|
|
7472
7462
|
* Throws if any of the provided block identifiers are invalid.
|
|
7473
7463
|
* @example example.ts
|
|
7474
7464
|
* ```typescript
|
|
7475
|
-
*
|
|
7476
|
-
*
|
|
7477
|
-
*
|
|
7478
|
-
*
|
|
7465
|
+
* // Creates a diamond pickaxe that can destroy cobblestone and obsidian
|
|
7466
|
+
* const specialPickaxe = new ItemStack("minecraft:diamond_pickaxe");
|
|
7467
|
+
* specialPickaxe.setCanDestroy(["minecraft:cobblestone", "minecraft:obsidian"]);
|
|
7479
7468
|
* ```
|
|
7480
7469
|
*/
|
|
7481
7470
|
setCanDestroy(blockIdentifiers?: string[]): void;
|
|
@@ -7493,10 +7482,9 @@ export class ItemStack {
|
|
|
7493
7482
|
* Throws if any of the provided block identifiers are invalid.
|
|
7494
7483
|
* @example example.ts
|
|
7495
7484
|
* ```typescript
|
|
7496
|
-
*
|
|
7497
|
-
*
|
|
7498
|
-
*
|
|
7499
|
-
*
|
|
7485
|
+
* // Creates a gold block that can be placed on grass and dirt
|
|
7486
|
+
* const specialGoldBlock = new ItemStack("minecraft:gold_block");
|
|
7487
|
+
* specialPickaxe.setCanPlaceOn(["minecraft:grass", "minecraft:dirt"]);
|
|
7500
7488
|
* ```
|
|
7501
7489
|
*/
|
|
7502
7490
|
setCanPlaceOn(blockIdentifiers?: string[]): void;
|
|
@@ -7510,10 +7498,9 @@ export class ItemStack {
|
|
|
7510
7498
|
*
|
|
7511
7499
|
* @example multilineLore.ts
|
|
7512
7500
|
* ```typescript
|
|
7513
|
-
*
|
|
7514
|
-
*
|
|
7515
|
-
*
|
|
7516
|
-
*
|
|
7501
|
+
* // Set the lore of an item to multiple lines of text
|
|
7502
|
+
* const itemStack = new ItemStack("minecraft:diamond_sword");
|
|
7503
|
+
* itemStack.setLore(["Line 1", "Line 2", "Line 3"]);
|
|
7517
7504
|
* ```
|
|
7518
7505
|
*/
|
|
7519
7506
|
setLore(loreList?: string[]): void;
|
|
@@ -16705,33 +16692,29 @@ export class Player extends Entity {
|
|
|
16705
16692
|
* is provided to `score`.
|
|
16706
16693
|
* @example nestedTranslation.ts
|
|
16707
16694
|
* ```typescript
|
|
16708
|
-
*
|
|
16709
|
-
*
|
|
16710
|
-
*
|
|
16711
|
-
*
|
|
16712
|
-
*
|
|
16713
|
-
*
|
|
16714
|
-
*
|
|
16695
|
+
* // Displays "Apple or Coal"
|
|
16696
|
+
* let rawMessage = {
|
|
16697
|
+
* translate: "accessibility.list.or.two",
|
|
16698
|
+
* with: { rawtext: [{ translate: "item.apple.name" }, { translate: "item.coal.name" }] },
|
|
16699
|
+
* };
|
|
16700
|
+
* player.sendMessage(rawMessage);
|
|
16715
16701
|
* ```
|
|
16716
16702
|
* @example scoreWildcard.ts
|
|
16717
16703
|
* ```typescript
|
|
16718
|
-
*
|
|
16719
|
-
*
|
|
16720
|
-
*
|
|
16721
|
-
*
|
|
16704
|
+
* // Displays the player's score for objective "obj". Each player will see their own score.
|
|
16705
|
+
* const rawMessage = { score: { name: "*", objective: "obj" } };
|
|
16706
|
+
* world.sendMessage(rawMessage);
|
|
16722
16707
|
* ```
|
|
16723
16708
|
* @example simpleString.ts
|
|
16724
16709
|
* ```typescript
|
|
16725
|
-
*
|
|
16726
|
-
*
|
|
16727
|
-
*
|
|
16710
|
+
* // Displays "Hello, world!"
|
|
16711
|
+
* world.sendMessage("Hello, world!");
|
|
16728
16712
|
* ```
|
|
16729
16713
|
* @example translation.ts
|
|
16730
16714
|
* ```typescript
|
|
16731
|
-
*
|
|
16732
|
-
*
|
|
16733
|
-
*
|
|
16734
|
-
*
|
|
16715
|
+
* // Displays "First or Second"
|
|
16716
|
+
* const rawMessage = { translate: "accessibility.list.or.two", with: ["First", "Second"] };
|
|
16717
|
+
* player.sendMessage(rawMessage);
|
|
16735
16718
|
* ```
|
|
16736
16719
|
*/
|
|
16737
16720
|
sendMessage(message: (RawMessage | string)[] | RawMessage | string): void;
|
|
@@ -17970,33 +17953,29 @@ export class World {
|
|
|
17970
17953
|
* is provided to `score`.
|
|
17971
17954
|
* @example nestedTranslation.ts
|
|
17972
17955
|
* ```typescript
|
|
17973
|
-
*
|
|
17974
|
-
*
|
|
17975
|
-
*
|
|
17976
|
-
*
|
|
17977
|
-
*
|
|
17978
|
-
*
|
|
17979
|
-
*
|
|
17956
|
+
* // Displays "Apple or Coal"
|
|
17957
|
+
* let rawMessage = {
|
|
17958
|
+
* translate: "accessibility.list.or.two",
|
|
17959
|
+
* with: { rawtext: [{ translate: "item.apple.name" }, { translate: "item.coal.name" }] },
|
|
17960
|
+
* };
|
|
17961
|
+
* world.sendMessage(rawMessage);
|
|
17980
17962
|
* ```
|
|
17981
17963
|
* @example scoreWildcard.ts
|
|
17982
17964
|
* ```typescript
|
|
17983
|
-
*
|
|
17984
|
-
*
|
|
17985
|
-
*
|
|
17986
|
-
*
|
|
17965
|
+
* // Displays the player's score for objective "obj". Each player will see their own score.
|
|
17966
|
+
* const rawMessage = { score: { name: "*", objective: "obj" } };
|
|
17967
|
+
* world.sendMessage(rawMessage);
|
|
17987
17968
|
* ```
|
|
17988
17969
|
* @example simpleString.ts
|
|
17989
17970
|
* ```typescript
|
|
17990
|
-
*
|
|
17991
|
-
*
|
|
17992
|
-
*
|
|
17971
|
+
* // Displays "Hello, world!"
|
|
17972
|
+
* world.sendMessage("Hello, world!");
|
|
17993
17973
|
* ```
|
|
17994
17974
|
* @example translation.ts
|
|
17995
17975
|
* ```typescript
|
|
17996
|
-
*
|
|
17997
|
-
*
|
|
17998
|
-
*
|
|
17999
|
-
*
|
|
17976
|
+
* // Displays "First or Second"
|
|
17977
|
+
* const rawMessage = { translate: "accessibility.list.or.two", with: ["First", "Second"] };
|
|
17978
|
+
* world.sendMessage(rawMessage);
|
|
18000
17979
|
* ```
|
|
18001
17980
|
*/
|
|
18002
17981
|
sendMessage(message: (RawMessage | string)[] | RawMessage | string): void;
|
|
@@ -18064,18 +18043,17 @@ export class WorldInitializeAfterEvent {
|
|
|
18064
18043
|
*
|
|
18065
18044
|
* @example propertyRegistration.js
|
|
18066
18045
|
* ```typescript
|
|
18067
|
-
*
|
|
18068
|
-
*
|
|
18069
|
-
* world.afterEvents.worldInitialize.subscribe((e) => {
|
|
18070
|
-
* let def = new DynamicPropertiesDefinition();
|
|
18046
|
+
* import { DynamicPropertiesDefinition, MinecraftEntityTypes, world } from "@minecraft/server";
|
|
18071
18047
|
*
|
|
18072
|
-
*
|
|
18073
|
-
*
|
|
18074
|
-
* def.defineBoolean("rpgIsHero");
|
|
18048
|
+
* world.afterEvents.worldInitialize.subscribe((e) => {
|
|
18049
|
+
* let def = new DynamicPropertiesDefinition();
|
|
18075
18050
|
*
|
|
18076
|
-
*
|
|
18077
|
-
*
|
|
18051
|
+
* def.defineNumber("rpgStrength");
|
|
18052
|
+
* def.defineString("rpgRole", 16);
|
|
18053
|
+
* def.defineBoolean("rpgIsHero");
|
|
18078
18054
|
*
|
|
18055
|
+
* e.propertyRegistry.registerEntityTypeDynamicProperties(def, MinecraftEntityTypes.skeleton);
|
|
18056
|
+
* });
|
|
18079
18057
|
* ```
|
|
18080
18058
|
*/
|
|
18081
18059
|
readonly propertyRegistry: PropertyRegistry;
|