@minecraft/server 1.1.0-beta.1.19.60-preview.25 → 1.1.0-beta.1.19.60-stable
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/README.md +0 -2
- package/index.d.ts +125 -89
- package/package.json +1 -1
- package/tests.ts +47 -41
package/README.md
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Contains many types related to manipulating a Minecraft world, including entities, blocks, dimensions, and more.
|
|
4
4
|
|
|
5
|
-
## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.**
|
|
6
|
-
|
|
7
5
|
See full documentation for this module here:
|
|
8
6
|
|
|
9
7
|
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/@minecraft/server/@minecraft/server
|
package/index.d.ts
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
Copyright (c) Microsoft Corporation.
|
|
8
8
|
***************************************************************************** */
|
|
9
9
|
/**
|
|
10
|
-
* @beta
|
|
11
10
|
* @packageDocumentation
|
|
12
11
|
* Contains many types related to manipulating a Minecraft
|
|
13
12
|
* world, including entities, blocks, dimensions, and more.
|
|
@@ -16,7 +15,7 @@
|
|
|
16
15
|
* ```json
|
|
17
16
|
* {
|
|
18
17
|
* "module_name": "@minecraft/server",
|
|
19
|
-
* "version": "1.
|
|
18
|
+
* "version": "1.0.0"
|
|
20
19
|
* }
|
|
21
20
|
* ```
|
|
22
21
|
*
|
|
@@ -775,10 +774,10 @@ export class Block {
|
|
|
775
774
|
* @throws This function can throw errors.
|
|
776
775
|
* @example check_block_tags.js
|
|
777
776
|
* ```typescript
|
|
778
|
-
* import { world
|
|
777
|
+
* import { world } from "@minecraft/server";
|
|
779
778
|
*
|
|
780
779
|
* // Fetch the block
|
|
781
|
-
* const block = world.getDimension("overworld").getBlock(
|
|
780
|
+
* const block = world.getDimension("overworld").getBlock({ x: 1, y: 2, z: 3 });
|
|
782
781
|
*
|
|
783
782
|
* console.log(`Block is dirt: ${block.hasTag("dirt")}`);
|
|
784
783
|
* console.log(`Block is wood: ${block.hasTag("wood")}`);
|
|
@@ -1296,10 +1295,10 @@ export class BlockPermutation {
|
|
|
1296
1295
|
* Returns `true` if the permutation has the tag, else `false`.
|
|
1297
1296
|
* @example check_block_tags.js
|
|
1298
1297
|
* ```typescript
|
|
1299
|
-
* import { world
|
|
1298
|
+
* import { world } from "@minecraft/server";
|
|
1300
1299
|
*
|
|
1301
1300
|
* // Fetch the block
|
|
1302
|
-
* const block = world.getDimension("overworld").getBlock(
|
|
1301
|
+
* const block = world.getDimension("overworld").getBlock({ x: 1, y: 2, z: 3 });
|
|
1303
1302
|
* const blockPerm = block.getPermutation();
|
|
1304
1303
|
*
|
|
1305
1304
|
* console.log(`Block is dirt: ${blockPerm.hasTag("dirt")}`);
|
|
@@ -2670,37 +2669,39 @@ export class Dimension {
|
|
|
2670
2669
|
* ```
|
|
2671
2670
|
* @example createFireAndWaterExplosions.ts
|
|
2672
2671
|
* ```typescript
|
|
2673
|
-
*
|
|
2672
|
+
* const explosionLoc: mc.Vector3 = { x: targetLocation.x + 0.5, y: targetLocation.y + 0.5, z: targetLocation.z + 0.5 };
|
|
2673
|
+
*
|
|
2674
|
+
* const fireExplosionOptions = new mc.ExplosionOptions();
|
|
2674
2675
|
*
|
|
2675
|
-
*
|
|
2676
|
+
* // Explode with fire
|
|
2677
|
+
* fireExplosionOptions.causesFire = true;
|
|
2676
2678
|
*
|
|
2677
|
-
*
|
|
2678
|
-
*
|
|
2679
|
+
* overworld.createExplosion(explosionLoc, 15, fireExplosionOptions);
|
|
2680
|
+
* const waterExplosionOptions = new mc.ExplosionOptions();
|
|
2679
2681
|
*
|
|
2680
|
-
*
|
|
2681
|
-
*
|
|
2682
|
+
* // Explode in water
|
|
2683
|
+
* waterExplosionOptions.allowUnderwater = true;
|
|
2682
2684
|
*
|
|
2683
|
-
*
|
|
2684
|
-
* waterExplosionOptions.allowUnderwater = true;
|
|
2685
|
+
* const belowWaterLoc: mc.Vector3 = { x: targetLocation.x + 3, y: targetLocation.y + 1, z: targetLocation.z + 3 };
|
|
2685
2686
|
*
|
|
2686
|
-
*
|
|
2687
|
+
* overworld.createExplosion(belowWaterLoc, 10, waterExplosionOptions);
|
|
2687
2688
|
*
|
|
2688
|
-
* overworld.createExplosion(belowWaterLoc, 10, waterExplosionOptions);
|
|
2689
2689
|
* ```
|
|
2690
2690
|
* @example createNoBlockExplosion.ts
|
|
2691
2691
|
* ```typescript
|
|
2692
|
-
*
|
|
2692
|
+
* const explosionOptions = new mc.ExplosionOptions();
|
|
2693
2693
|
*
|
|
2694
|
-
*
|
|
2695
|
-
*
|
|
2694
|
+
* // Start by exploding without breaking blocks
|
|
2695
|
+
* explosionOptions.breaksBlocks = false;
|
|
2696
2696
|
*
|
|
2697
|
-
*
|
|
2698
|
-
*
|
|
2699
|
-
*
|
|
2700
|
-
*
|
|
2701
|
-
*
|
|
2697
|
+
* const explodeNoBlocksLoc: mc.Vector3 = {
|
|
2698
|
+
* x: Math.floor(targetLocation.x + 1),
|
|
2699
|
+
* y: Math.floor(targetLocation.y + 2),
|
|
2700
|
+
* z: Math.floor(targetLocation.z + 1),
|
|
2701
|
+
* };
|
|
2702
|
+
*
|
|
2703
|
+
* overworld.createExplosion(explodeNoBlocksLoc, 15, explosionOptions);
|
|
2702
2704
|
*
|
|
2703
|
-
* overworld.createExplosion(explodeNoBlocksLoc, 15, explosionOptions);
|
|
2704
2705
|
* ```
|
|
2705
2706
|
*/
|
|
2706
2707
|
createExplosion(location: Location, radius: number, explosionOptions?: ExplosionOptions): void;
|
|
@@ -2834,20 +2835,23 @@ export class Dimension {
|
|
|
2834
2835
|
* ```
|
|
2835
2836
|
* @example quickFoxLazyDog.ts
|
|
2836
2837
|
* ```typescript
|
|
2837
|
-
*
|
|
2838
|
-
*
|
|
2839
|
-
*
|
|
2840
|
-
*
|
|
2841
|
-
*
|
|
2842
|
-
*
|
|
2838
|
+
* const fox = overworld.spawnEntity("minecraft:fox", {
|
|
2839
|
+
* x: targetLocation.x + 1,
|
|
2840
|
+
* y: targetLocation.y + 2,
|
|
2841
|
+
* z: targetLocation.z + 3,
|
|
2842
|
+
* });
|
|
2843
|
+
* fox.addEffect(mc.MinecraftEffectTypes.speed, 10, 20);
|
|
2844
|
+
* log("Created a fox.");
|
|
2845
|
+
*
|
|
2846
|
+
* const wolf = overworld.spawnEntity("minecraft:wolf", {
|
|
2847
|
+
* x: targetLocation.x + 4,
|
|
2848
|
+
* y: targetLocation.y + 2,
|
|
2849
|
+
* z: targetLocation.z + 3,
|
|
2850
|
+
* });
|
|
2851
|
+
* wolf.addEffect(mc.MinecraftEffectTypes.slowness, 10, 20);
|
|
2852
|
+
* wolf.isSneaking = true;
|
|
2853
|
+
* log("Created a sneaking wolf.", 1);
|
|
2843
2854
|
*
|
|
2844
|
-
* const wolf = overworld.spawnEntity(
|
|
2845
|
-
* "minecraft:wolf",
|
|
2846
|
-
* new mc.BlockLocation(targetLocation.x + 4, targetLocation.y + 2, targetLocation.z + 3)
|
|
2847
|
-
* );
|
|
2848
|
-
* wolf.addEffect(mc.MinecraftEffectTypes.slowness, 10, 20);
|
|
2849
|
-
* wolf.isSneaking = true;
|
|
2850
|
-
* log("Created a sneaking wolf.", 1);
|
|
2851
2855
|
* ```
|
|
2852
2856
|
* @example trapTick.ts
|
|
2853
2857
|
* ```typescript
|
|
@@ -2877,17 +2881,18 @@ export class Dimension {
|
|
|
2877
2881
|
* @throws This function can throw errors.
|
|
2878
2882
|
* @example itemStacks.ts
|
|
2879
2883
|
* ```typescript
|
|
2880
|
-
*
|
|
2881
|
-
*
|
|
2882
|
-
*
|
|
2884
|
+
* const oneItemLoc: mc.Vector3 = { x: 3, y: 2, z: 1 };
|
|
2885
|
+
* const fiveItemsLoc: mc.Vector3 = { x: 1, y: 2, z: 1 };
|
|
2886
|
+
* const diamondPickaxeLoc: mc.Vector3 = { x: 2, y: 2, z: 4 };
|
|
2887
|
+
*
|
|
2888
|
+
* const oneEmerald = new mc.ItemStack(mc.MinecraftItemTypes.emerald, 1, 0);
|
|
2889
|
+
* const onePickaxe = new mc.ItemStack(mc.MinecraftItemTypes.diamondPickaxe, 1, 0);
|
|
2890
|
+
* const fiveEmeralds = new mc.ItemStack(mc.MinecraftItemTypes.emerald, 5, 0);
|
|
2883
2891
|
*
|
|
2884
|
-
*
|
|
2885
|
-
*
|
|
2886
|
-
*
|
|
2892
|
+
* overworld.spawnItem(oneEmerald, oneItemLoc);
|
|
2893
|
+
* overworld.spawnItem(fiveEmeralds, fiveItemsLoc);
|
|
2894
|
+
* overworld.spawnItem(onePickaxe, diamondPickaxeLoc);
|
|
2887
2895
|
*
|
|
2888
|
-
* overworld.spawnItem(oneEmerald, oneItemLoc);
|
|
2889
|
-
* overworld.spawnItem(fiveEmeralds, fiveItemsLoc);
|
|
2890
|
-
* overworld.spawnItem(onePickaxe, diamondPickaxeLoc);
|
|
2891
2896
|
* ```
|
|
2892
2897
|
* @example spawnItem.ts
|
|
2893
2898
|
* ```typescript
|
|
@@ -3267,29 +3272,34 @@ export class Entity {
|
|
|
3267
3272
|
* @example addEffect.js
|
|
3268
3273
|
* ```typescript
|
|
3269
3274
|
* const villagerId = "minecraft:villager_v2<minecraft:ageable_grow_up>";
|
|
3270
|
-
* const villagerLoc =
|
|
3275
|
+
* const villagerLoc: mc.Vector3 = { x: 1, y: 2, z: 1 };
|
|
3271
3276
|
* const villager = test.spawn(villagerId, villagerLoc);
|
|
3272
3277
|
* const duration = 20;
|
|
3273
3278
|
*
|
|
3274
3279
|
* villager.addEffect(MinecraftEffectTypes.poison, duration, 1);
|
|
3275
3280
|
*
|
|
3281
|
+
*
|
|
3276
3282
|
* ```
|
|
3277
3283
|
* @example quickFoxLazyDog.ts
|
|
3278
3284
|
* ```typescript
|
|
3279
|
-
*
|
|
3280
|
-
*
|
|
3281
|
-
*
|
|
3282
|
-
*
|
|
3283
|
-
*
|
|
3284
|
-
*
|
|
3285
|
+
* const fox = overworld.spawnEntity("minecraft:fox", {
|
|
3286
|
+
* x: targetLocation.x + 1,
|
|
3287
|
+
* y: targetLocation.y + 2,
|
|
3288
|
+
* z: targetLocation.z + 3,
|
|
3289
|
+
* });
|
|
3290
|
+
* fox.addEffect(mc.MinecraftEffectTypes.speed, 10, 20);
|
|
3291
|
+
* log("Created a fox.");
|
|
3292
|
+
*
|
|
3293
|
+
* const wolf = overworld.spawnEntity("minecraft:wolf", {
|
|
3294
|
+
* x: targetLocation.x + 4,
|
|
3295
|
+
* y: targetLocation.y + 2,
|
|
3296
|
+
* z: targetLocation.z + 3,
|
|
3297
|
+
* });
|
|
3298
|
+
* wolf.addEffect(mc.MinecraftEffectTypes.slowness, 10, 20);
|
|
3299
|
+
* wolf.isSneaking = true;
|
|
3300
|
+
* log("Created a sneaking wolf.", 1);
|
|
3301
|
+
*
|
|
3285
3302
|
*
|
|
3286
|
-
* const wolf = overworld.spawnEntity(
|
|
3287
|
-
* "minecraft:wolf",
|
|
3288
|
-
* new mc.BlockLocation(targetLocation.x + 4, targetLocation.y + 2, targetLocation.z + 3)
|
|
3289
|
-
* );
|
|
3290
|
-
* wolf.addEffect(mc.MinecraftEffectTypes.slowness, 10, 20);
|
|
3291
|
-
* wolf.isSneaking = true;
|
|
3292
|
-
* log("Created a sneaking wolf.", 1);
|
|
3293
3303
|
* ```
|
|
3294
3304
|
*/
|
|
3295
3305
|
addEffect(effectType: EffectType, duration: number, amplifier?: number, showParticles?: boolean): void;
|
|
@@ -3946,7 +3956,7 @@ export class EntityHealthComponent extends IEntityComponent {
|
|
|
3946
3956
|
* @param value
|
|
3947
3957
|
* @throws This function can throw errors.
|
|
3948
3958
|
*/
|
|
3949
|
-
setCurrent(value: number):
|
|
3959
|
+
setCurrent(value: number): boolean;
|
|
3950
3960
|
}
|
|
3951
3961
|
/**
|
|
3952
3962
|
* @beta
|
|
@@ -4434,7 +4444,7 @@ export class EntityLavaMovementComponent extends IEntityComponent {
|
|
|
4434
4444
|
* @param value
|
|
4435
4445
|
* @throws This function can throw errors.
|
|
4436
4446
|
*/
|
|
4437
|
-
setCurrent(value: number):
|
|
4447
|
+
setCurrent(value: number): boolean;
|
|
4438
4448
|
}
|
|
4439
4449
|
/**
|
|
4440
4450
|
* @beta
|
|
@@ -4624,7 +4634,7 @@ export class EntityMovementComponent extends IEntityComponent {
|
|
|
4624
4634
|
* @param value
|
|
4625
4635
|
* @throws This function can throw errors.
|
|
4626
4636
|
*/
|
|
4627
|
-
setCurrent(value: number):
|
|
4637
|
+
setCurrent(value: number): boolean;
|
|
4628
4638
|
}
|
|
4629
4639
|
/**
|
|
4630
4640
|
* @beta
|
|
@@ -5945,7 +5955,7 @@ export class EntityUnderwaterMovementComponent extends IEntityComponent {
|
|
|
5945
5955
|
* @param value
|
|
5946
5956
|
* @throws This function can throw errors.
|
|
5947
5957
|
*/
|
|
5948
|
-
setCurrent(value: number):
|
|
5958
|
+
setCurrent(value: number): boolean;
|
|
5949
5959
|
}
|
|
5950
5960
|
/**
|
|
5951
5961
|
* @beta
|
|
@@ -13242,24 +13252,36 @@ export class MinecraftItemTypes {
|
|
|
13242
13252
|
export class MolangVariableMap {
|
|
13243
13253
|
/**
|
|
13244
13254
|
* @remarks
|
|
13245
|
-
*
|
|
13246
|
-
*
|
|
13255
|
+
* Adds the following variables to Molang:
|
|
13256
|
+
* - `<variable_name>.r` - Red color value [0-1]
|
|
13257
|
+
* - `<variable_name>.g` - Green color value [0-1]
|
|
13258
|
+
* - `<variable_name>.b` - Blue color value [0-1]
|
|
13247
13259
|
* @param variableName
|
|
13248
13260
|
* @param color
|
|
13249
13261
|
*/
|
|
13250
13262
|
setColorRGB(variableName: string, color: Color): MolangVariableMap;
|
|
13251
13263
|
/**
|
|
13252
13264
|
* @remarks
|
|
13253
|
-
*
|
|
13254
|
-
*
|
|
13265
|
+
* Adds the following variables to Molang:
|
|
13266
|
+
* - `<variable_name>.r` - Red color value [0-1]
|
|
13267
|
+
* - `<variable_name>.g` - Green color value [0-1]
|
|
13268
|
+
* - `<variable_name>.b` - Blue color value [0-1]
|
|
13269
|
+
* - `<variable_name>.a` - Alpha (transparency) color value
|
|
13270
|
+
* [0-1]
|
|
13255
13271
|
* @param variableName
|
|
13256
13272
|
* @param color
|
|
13257
13273
|
*/
|
|
13258
13274
|
setColorRGBA(variableName: string, color: Color): MolangVariableMap;
|
|
13259
13275
|
/**
|
|
13260
13276
|
* @remarks
|
|
13261
|
-
*
|
|
13262
|
-
*
|
|
13277
|
+
* Adds the following variables to Molang:
|
|
13278
|
+
* - `<variable_name>.speed` - Speed number provided
|
|
13279
|
+
* - `<variable_name>.direction_x` - X value from the {@link
|
|
13280
|
+
* Vector3} provided
|
|
13281
|
+
* - `<variable_name>.direction_y` - Y value from the {@link
|
|
13282
|
+
* Vector3} provided
|
|
13283
|
+
* - `<variable_name>.direction_z` - Z value from the {@link
|
|
13284
|
+
* Vector3} provided
|
|
13263
13285
|
* @param variableName
|
|
13264
13286
|
* @param speed
|
|
13265
13287
|
* @param direction
|
|
@@ -13267,8 +13289,13 @@ export class MolangVariableMap {
|
|
|
13267
13289
|
setSpeedAndDirection(variableName: string, speed: number, direction: Vector): MolangVariableMap;
|
|
13268
13290
|
/**
|
|
13269
13291
|
* @remarks
|
|
13270
|
-
*
|
|
13271
|
-
*
|
|
13292
|
+
* Adds the following variables to Molang:
|
|
13293
|
+
* - `<variable_name>.x` - X value from the {@link Vector3}
|
|
13294
|
+
* provided
|
|
13295
|
+
* - `<variable_name>.y` - Y value from the {@link Vector3}
|
|
13296
|
+
* provided
|
|
13297
|
+
* - `<variable_name>.z` - Z value from the {@link Vector3}
|
|
13298
|
+
* provided
|
|
13272
13299
|
* @param variableName
|
|
13273
13300
|
* @param vector
|
|
13274
13301
|
*/
|
|
@@ -13352,21 +13379,23 @@ export class PistonActivateEventSignal {
|
|
|
13352
13379
|
* @param callback
|
|
13353
13380
|
* @example pistonEvent.ts
|
|
13354
13381
|
* ```typescript
|
|
13355
|
-
*
|
|
13382
|
+
* let canceled = false;
|
|
13383
|
+
*
|
|
13384
|
+
* const pistonLoc: mc.Vector3 = {
|
|
13385
|
+
* x: Math.floor(targetLocation.x) + 1,
|
|
13386
|
+
* y: Math.floor(targetLocation.y) + 2,
|
|
13387
|
+
* z: Math.floor(targetLocation.z) + 1,
|
|
13388
|
+
* };
|
|
13389
|
+
*
|
|
13390
|
+
* const pistonCallback = mc.world.events.beforePistonActivate.subscribe((pistonEvent: mc.BeforePistonActivateEvent) => {
|
|
13391
|
+
* if (pistonEvent.piston.location.equals(pistonLoc)) {
|
|
13392
|
+
* log("Cancelling piston event");
|
|
13393
|
+
* pistonEvent.cancel = true;
|
|
13394
|
+
* canceled = true;
|
|
13395
|
+
* }
|
|
13396
|
+
* });
|
|
13356
13397
|
*
|
|
13357
|
-
* const pistonLoc = new mc.BlockLocation(
|
|
13358
|
-
* Math.floor(targetLocation.x) + 1,
|
|
13359
|
-
* Math.floor(targetLocation.y) + 2,
|
|
13360
|
-
* Math.floor(targetLocation.z) + 1
|
|
13361
|
-
* );
|
|
13362
13398
|
*
|
|
13363
|
-
* const pistonCallback = mc.world.events.beforePistonActivate.subscribe((pistonEvent: mc.BeforePistonActivateEvent) => {
|
|
13364
|
-
* if (pistonEvent.piston.location.equals(pistonLoc)) {
|
|
13365
|
-
* log("Cancelling piston event");
|
|
13366
|
-
* pistonEvent.cancel = true;
|
|
13367
|
-
* canceled = true;
|
|
13368
|
-
* }
|
|
13369
|
-
* });
|
|
13370
13399
|
* ```
|
|
13371
13400
|
*/
|
|
13372
13401
|
subscribe(callback: (arg: PistonActivateEvent) => void): (arg: PistonActivateEvent) => void;
|
|
@@ -13768,7 +13797,7 @@ export class Player extends Entity {
|
|
|
13768
13797
|
* @param message
|
|
13769
13798
|
* @throws This function can throw errors.
|
|
13770
13799
|
*/
|
|
13771
|
-
tell(message: RawMessage | string): void;
|
|
13800
|
+
tell(message: (RawMessage | string)[] | RawMessage | string): void;
|
|
13772
13801
|
/**
|
|
13773
13802
|
* @beta
|
|
13774
13803
|
* @remarks
|
|
@@ -14153,6 +14182,7 @@ export class Scoreboard {
|
|
|
14153
14182
|
* @throws This function can throw errors.
|
|
14154
14183
|
*/
|
|
14155
14184
|
getParticipants(): ScoreboardIdentity[];
|
|
14185
|
+
getScore(objective: ScoreboardObjective, participant: ScoreboardIdentity): number;
|
|
14156
14186
|
/**
|
|
14157
14187
|
* @remarks
|
|
14158
14188
|
* Removes an objective from the scoreboard.
|
|
@@ -14172,6 +14202,7 @@ export class Scoreboard {
|
|
|
14172
14202
|
displaySlotId: string,
|
|
14173
14203
|
objectiveDisplaySetting: ScoreboardObjectiveDisplayOptions,
|
|
14174
14204
|
): ScoreboardObjective;
|
|
14205
|
+
setScore(objective: ScoreboardObjective, participant: ScoreboardIdentity, score: number): boolean;
|
|
14175
14206
|
}
|
|
14176
14207
|
/**
|
|
14177
14208
|
* @beta
|
|
@@ -14198,6 +14229,9 @@ export class ScoreboardIdentity {
|
|
|
14198
14229
|
* @throws This function can throw errors.
|
|
14199
14230
|
*/
|
|
14200
14231
|
getEntity(): Entity;
|
|
14232
|
+
getScore(objective: ScoreboardObjective): number;
|
|
14233
|
+
removeFromObjective(objective: ScoreboardObjective): boolean;
|
|
14234
|
+
setScore(objective: ScoreboardObjective, score: number): boolean;
|
|
14201
14235
|
}
|
|
14202
14236
|
/**
|
|
14203
14237
|
* @beta
|
|
@@ -14236,6 +14270,8 @@ export class ScoreboardObjective {
|
|
|
14236
14270
|
* @throws This function can throw errors.
|
|
14237
14271
|
*/
|
|
14238
14272
|
getScores(): ScoreboardScoreInfo[];
|
|
14273
|
+
removeParticipant(participant: ScoreboardIdentity): boolean;
|
|
14274
|
+
setScore(participant: ScoreboardIdentity, score: number): boolean;
|
|
14239
14275
|
}
|
|
14240
14276
|
/**
|
|
14241
14277
|
* @beta
|
|
@@ -14852,7 +14888,7 @@ export class World {
|
|
|
14852
14888
|
* @param message
|
|
14853
14889
|
* @throws This function can throw errors.
|
|
14854
14890
|
*/
|
|
14855
|
-
say(message: RawMessage | string): void;
|
|
14891
|
+
say(message: (RawMessage | string)[] | RawMessage | string): void;
|
|
14856
14892
|
/**
|
|
14857
14893
|
* @beta
|
|
14858
14894
|
* @remarks
|
|
@@ -15225,7 +15261,7 @@ export interface RawMessage {
|
|
|
15225
15261
|
rawtext?: (RawMessage | string)[];
|
|
15226
15262
|
text?: string;
|
|
15227
15263
|
translate?: string;
|
|
15228
|
-
with?:
|
|
15264
|
+
with?: string[] | RawMessage;
|
|
15229
15265
|
}
|
|
15230
15266
|
/**
|
|
15231
15267
|
* @beta
|
package/package.json
CHANGED
package/tests.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
import * as mc from '@minecraft/server';
|
|
3
3
|
|
|
4
|
-
export function createExplosion(log: (message: string, status?: number) => void, targetLocation: mc.
|
|
4
|
+
export function createExplosion(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) {
|
|
5
5
|
const overworld = mc.world.getDimension('overworld');
|
|
6
6
|
|
|
7
7
|
log('Creating an explosion of radius 10.');
|
|
8
8
|
overworld.createExplosion(targetLocation, 10);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export function createNoBlockExplosion(log: (message: string, status?: number) => void, targetLocation: mc.
|
|
11
|
+
export function createNoBlockExplosion(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) {
|
|
12
12
|
const overworld = mc.world.getDimension('overworld');
|
|
13
13
|
|
|
14
|
-
const explodeNoBlocksLoc =
|
|
15
|
-
Math.floor(targetLocation.x + 1),
|
|
16
|
-
Math.floor(targetLocation.y + 2),
|
|
17
|
-
Math.floor(targetLocation.z + 1),
|
|
18
|
-
|
|
14
|
+
const explodeNoBlocksLoc = {
|
|
15
|
+
x: Math.floor(targetLocation.x + 1),
|
|
16
|
+
y: Math.floor(targetLocation.y + 2),
|
|
17
|
+
z: Math.floor(targetLocation.z + 1),
|
|
18
|
+
};
|
|
19
19
|
|
|
20
20
|
log('Creating an explosion of radius 15 that does not break blocks.');
|
|
21
21
|
overworld.createExplosion(explodeNoBlocksLoc, 15, { breaksBlocks: false });
|
|
@@ -23,27 +23,31 @@ export function createNoBlockExplosion(log: (message: string, status?: number) =
|
|
|
23
23
|
|
|
24
24
|
export function createFireAndWaterExplosions(
|
|
25
25
|
log: (message: string, status?: number) => void,
|
|
26
|
-
targetLocation: mc.
|
|
26
|
+
targetLocation: mc.Vector3,
|
|
27
27
|
) {
|
|
28
28
|
const overworld = mc.world.getDimension('overworld');
|
|
29
29
|
|
|
30
|
-
const explosionLoc
|
|
30
|
+
const explosionLoc: mc.Vector3 = {
|
|
31
|
+
x: targetLocation.x + 0.5,
|
|
32
|
+
y: targetLocation.y + 0.5,
|
|
33
|
+
z: targetLocation.z + 0.5,
|
|
34
|
+
};
|
|
31
35
|
|
|
32
36
|
log('Creating an explosion of radius 15 that causes fire.');
|
|
33
37
|
overworld.createExplosion(explosionLoc, 15, { causesFire: true });
|
|
34
38
|
|
|
35
|
-
const belowWaterLoc =
|
|
39
|
+
const belowWaterLoc: mc.Vector3 = { x: targetLocation.x + 3, y: targetLocation.y + 1, z: targetLocation.z + 3 };
|
|
36
40
|
|
|
37
41
|
log('Creating an explosion of radius 10 that can go underwater.');
|
|
38
42
|
overworld.createExplosion(belowWaterLoc, 10, { allowUnderwater: true });
|
|
39
43
|
}
|
|
40
44
|
|
|
41
|
-
export function itemStacks(log: (message: string, status?: number) => void, targetLocation: mc.
|
|
45
|
+
export function itemStacks(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) {
|
|
42
46
|
const overworld = mc.world.getDimension('overworld');
|
|
43
47
|
|
|
44
|
-
const oneItemLoc =
|
|
45
|
-
const fiveItemsLoc =
|
|
46
|
-
const diamondPickaxeLoc =
|
|
48
|
+
const oneItemLoc: mc.Vector3 = { x: targetLocation.x + targetLocation.y + 3, y: 2, z: targetLocation.z + 1 };
|
|
49
|
+
const fiveItemsLoc: mc.Vector3 = { x: targetLocation.x + 1, y: targetLocation.y + 2, z: targetLocation.z + 1 };
|
|
50
|
+
const diamondPickaxeLoc: mc.Vector3 = { x: targetLocation.x + 2, y: targetLocation.y + 2, z: targetLocation.z + 4 };
|
|
47
51
|
|
|
48
52
|
const oneEmerald = new mc.ItemStack(mc.MinecraftItemTypes.emerald, 1, 0);
|
|
49
53
|
const onePickaxe = new mc.ItemStack(mc.MinecraftItemTypes.diamondPickaxe, 1, 0);
|
|
@@ -59,26 +63,28 @@ export function itemStacks(log: (message: string, status?: number) => void, targ
|
|
|
59
63
|
overworld.spawnItem(onePickaxe, diamondPickaxeLoc);
|
|
60
64
|
}
|
|
61
65
|
|
|
62
|
-
export function quickFoxLazyDog(log: (message: string, status?: number) => void, targetLocation: mc.
|
|
66
|
+
export function quickFoxLazyDog(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) {
|
|
63
67
|
const overworld = mc.world.getDimension('overworld');
|
|
64
68
|
|
|
65
|
-
const fox = overworld.spawnEntity(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
const fox = overworld.spawnEntity('minecraft:fox', {
|
|
70
|
+
x: targetLocation.x + 1,
|
|
71
|
+
y: targetLocation.y + 2,
|
|
72
|
+
z: targetLocation.z + 3,
|
|
73
|
+
});
|
|
69
74
|
fox.addEffect(mc.MinecraftEffectTypes.speed, 10, 20);
|
|
70
75
|
log('Created a fox.');
|
|
71
76
|
|
|
72
|
-
const wolf = overworld.spawnEntity(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
const wolf = overworld.spawnEntity('minecraft:wolf', {
|
|
78
|
+
x: targetLocation.x + 4,
|
|
79
|
+
y: targetLocation.y + 2,
|
|
80
|
+
z: targetLocation.z + 3,
|
|
81
|
+
});
|
|
76
82
|
wolf.addEffect(mc.MinecraftEffectTypes.slowness, 10, 20);
|
|
77
83
|
wolf.isSneaking = true;
|
|
78
84
|
log('Created a sneaking wolf.', 1);
|
|
79
85
|
}
|
|
80
86
|
|
|
81
|
-
export function runEntityCreatedEvent(log: (message: string, status?: number) => void, targetLocation: mc.
|
|
87
|
+
export function runEntityCreatedEvent(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) {
|
|
82
88
|
// register a new function that is called when a new entity is created.
|
|
83
89
|
mc.world.events.entityCreate.subscribe((entityEvent: mc.EntityCreateEvent) => {
|
|
84
90
|
if (entityEvent && entityEvent.entity) {
|
|
@@ -89,19 +95,19 @@ export function runEntityCreatedEvent(log: (message: string, status?: number) =>
|
|
|
89
95
|
});
|
|
90
96
|
}
|
|
91
97
|
|
|
92
|
-
export function createOldHorse(log: (message: string, status?: number) => void, targetLocation: mc.
|
|
98
|
+
export function createOldHorse(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) {
|
|
93
99
|
const overworld = mc.world.getDimension('overworld');
|
|
94
100
|
|
|
95
101
|
log("Create a horse and triggering the 'ageable_grow_up' event, ensuring the horse is created as an adult");
|
|
96
102
|
overworld.spawnEntity('minecraft:horse<minecraft:ageable_grow_up>', targetLocation);
|
|
97
103
|
}
|
|
98
104
|
|
|
99
|
-
export function pistonEvent(log: (message: string, status?: number) => void, targetLocation: mc.
|
|
100
|
-
const pistonLoc =
|
|
101
|
-
Math.floor(targetLocation.x) + 1,
|
|
102
|
-
Math.floor(targetLocation.y) + 2,
|
|
103
|
-
Math.floor(targetLocation.z) + 1,
|
|
104
|
-
|
|
105
|
+
export function pistonEvent(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) {
|
|
106
|
+
const pistonLoc: mc.Vector3 = {
|
|
107
|
+
x: Math.floor(targetLocation.x) + 1,
|
|
108
|
+
y: Math.floor(targetLocation.y) + 2,
|
|
109
|
+
z: Math.floor(targetLocation.z) + 1,
|
|
110
|
+
};
|
|
105
111
|
|
|
106
112
|
mc.world.events.beforePistonActivate.subscribe((pistonEvent: mc.BeforePistonActivateEvent) => {
|
|
107
113
|
if (pistonEvent.piston.location.equals(pistonLoc)) {
|
|
@@ -111,7 +117,7 @@ export function pistonEvent(log: (message: string, status?: number) => void, tar
|
|
|
111
117
|
});
|
|
112
118
|
}
|
|
113
119
|
|
|
114
|
-
export function spawnItem(log: (message: string, status?: number) => void, targetLocation: mc.
|
|
120
|
+
export function spawnItem(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) {
|
|
115
121
|
const featherItem = new mc.ItemStack(mc.MinecraftItemTypes.feather, 1, 0);
|
|
116
122
|
|
|
117
123
|
overworld.spawnItem(featherItem, targetLocation);
|
|
@@ -120,7 +126,7 @@ export function spawnItem(log: (message: string, status?: number) => void, targe
|
|
|
120
126
|
|
|
121
127
|
export function testThatEntityIsFeatherItem(
|
|
122
128
|
log: (message: string, status?: number) => void,
|
|
123
|
-
targetLocation: mc.
|
|
129
|
+
targetLocation: mc.Vector3,
|
|
124
130
|
) {
|
|
125
131
|
const overworld = mc.world.getDimension('overworld');
|
|
126
132
|
|
|
@@ -161,13 +167,13 @@ export default class SampleManager {
|
|
|
161
167
|
tickCount = 0;
|
|
162
168
|
|
|
163
169
|
_availableFuncs: {
|
|
164
|
-
[name: string]: Array<(log: (message: string, status?: number) => void, location: mc.
|
|
170
|
+
[name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>;
|
|
165
171
|
};
|
|
166
172
|
|
|
167
173
|
pendingFuncs: Array<{
|
|
168
174
|
name: string;
|
|
169
|
-
func: (log: (message: string, status?: number) => void, location: mc.
|
|
170
|
-
location: mc.
|
|
175
|
+
func: (log: (message: string, status?: number) => void, location: mc.Vector3) => void;
|
|
176
|
+
location: mc.Vector3;
|
|
171
177
|
}> = [];
|
|
172
178
|
|
|
173
179
|
gameplayLogger(message: string, status?: number) {
|
|
@@ -194,7 +200,7 @@ export default class SampleManager {
|
|
|
194
200
|
}
|
|
195
201
|
|
|
196
202
|
const nearbyBlockLoc = nearbyBlock.location;
|
|
197
|
-
const nearbyLoc =
|
|
203
|
+
const nearbyLoc: mc.Vector3 = { x: nearbyBlockLoc.x, y: nearbyBlockLoc.y + 1, z: nearbyBlockLoc.z };
|
|
198
204
|
|
|
199
205
|
const sampleId = message.substring(5).trim();
|
|
200
206
|
|
|
@@ -224,8 +230,8 @@ export default class SampleManager {
|
|
|
224
230
|
|
|
225
231
|
runSample(
|
|
226
232
|
sampleId: string,
|
|
227
|
-
snippetFunctions: Array<(log: (message: string, status?: number) => void, location: mc.
|
|
228
|
-
targetLocation: mc.
|
|
233
|
+
snippetFunctions: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>,
|
|
234
|
+
targetLocation: mc.Vector3,
|
|
229
235
|
) {
|
|
230
236
|
for (let i = snippetFunctions.length - 1; i >= 0; i--) {
|
|
231
237
|
this.pendingFuncs.push({ name: sampleId, func: snippetFunctions[i], location: targetLocation });
|
|
@@ -256,7 +262,7 @@ export default class SampleManager {
|
|
|
256
262
|
}
|
|
257
263
|
|
|
258
264
|
registerSamples(sampleSet: {
|
|
259
|
-
[name: string]: Array<(log: (message: string, status?: number) => void, location: mc.
|
|
265
|
+
[name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>;
|
|
260
266
|
}) {
|
|
261
267
|
for (const sampleKey in sampleSet) {
|
|
262
268
|
if (sampleKey.length > 1 && sampleSet[sampleKey]) {
|
|
@@ -267,7 +273,7 @@ export default class SampleManager {
|
|
|
267
273
|
}
|
|
268
274
|
|
|
269
275
|
const mojangMinecraftFuncs: {
|
|
270
|
-
[name: string]: Array<(log: (message: string, status?: number) => void, location: mc.
|
|
276
|
+
[name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>;
|
|
271
277
|
} = {
|
|
272
278
|
runEntityCreatedEvent: [runEntityCreatedEvent, createOldHorse],
|
|
273
279
|
createOldHorse: [createOldHorse],
|