@minecraft/server 2.8.0-beta.1.26.20-preview.20 → 2.8.0-beta.1.26.20-preview.22
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 +623 -610
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -25,7 +25,6 @@ import * as minecraftcommon from '@minecraft/common';
|
|
|
25
25
|
// @ts-ignore Optional types-only package, will decay to any if @minecraft/vanilla-data isn't installed
|
|
26
26
|
import type * as minecraftvanilladata from '@minecraft/vanilla-data';
|
|
27
27
|
/**
|
|
28
|
-
* @rc
|
|
29
28
|
* Specifies different targeting modes for use in aim-assist.
|
|
30
29
|
*/
|
|
31
30
|
export enum AimAssistTargetMode {
|
|
@@ -756,7 +755,6 @@ export enum EnchantmentSlot {
|
|
|
756
755
|
}
|
|
757
756
|
|
|
758
757
|
/**
|
|
759
|
-
* @rc
|
|
760
758
|
* The entity's attach location point. Contains points such as
|
|
761
759
|
* head, body, leg, etc to attach the camera to.
|
|
762
760
|
*/
|
|
@@ -1483,7 +1481,6 @@ export enum EntityDamageCause {
|
|
|
1483
1481
|
}
|
|
1484
1482
|
|
|
1485
1483
|
/**
|
|
1486
|
-
* @rc
|
|
1487
1484
|
* Describes the source of healing of an Entity.
|
|
1488
1485
|
*/
|
|
1489
1486
|
export enum EntityHealCause {
|
|
@@ -2877,7 +2874,6 @@ export enum StructureSaveMode {
|
|
|
2877
2874
|
}
|
|
2878
2875
|
|
|
2879
2876
|
/**
|
|
2880
|
-
* @rc
|
|
2881
2877
|
* The reason that the {@link
|
|
2882
2878
|
* @minecraft/server.TickingAreaError} was thrown.
|
|
2883
2879
|
*/
|
|
@@ -3316,7 +3312,6 @@ export type VanillaEntityIdentifier =
|
|
|
3316
3312
|
| `${minecraftvanilladata.MinecraftEntityTypes}<${string}>`;
|
|
3317
3313
|
|
|
3318
3314
|
/**
|
|
3319
|
-
* @rc
|
|
3320
3315
|
* Handle to an aim-assist category that exists in the
|
|
3321
3316
|
* world.aimAssist registry.
|
|
3322
3317
|
*/
|
|
@@ -3391,7 +3386,6 @@ export class AimAssistCategory {
|
|
|
3391
3386
|
}
|
|
3392
3387
|
|
|
3393
3388
|
/**
|
|
3394
|
-
* @rc
|
|
3395
3389
|
* Settings used with AimAssistRegistry.addCategory for
|
|
3396
3390
|
* creation of the AimAssistCategory.
|
|
3397
3391
|
*/
|
|
@@ -3509,7 +3503,6 @@ export class AimAssistCategorySettings {
|
|
|
3509
3503
|
}
|
|
3510
3504
|
|
|
3511
3505
|
/**
|
|
3512
|
-
* @rc
|
|
3513
3506
|
* Handle to an aim-assist preset that exists in the
|
|
3514
3507
|
* world.aimAssist registry.
|
|
3515
3508
|
*/
|
|
@@ -3602,7 +3595,6 @@ export class AimAssistPreset {
|
|
|
3602
3595
|
}
|
|
3603
3596
|
|
|
3604
3597
|
/**
|
|
3605
|
-
* @rc
|
|
3606
3598
|
* Settings used with AimAssistRegistry.addPreset for creation
|
|
3607
3599
|
* of the AimAssistPreset.
|
|
3608
3600
|
*/
|
|
@@ -3760,7 +3752,6 @@ export class AimAssistPresetSettings {
|
|
|
3760
3752
|
}
|
|
3761
3753
|
|
|
3762
3754
|
/**
|
|
3763
|
-
* @rc
|
|
3764
3755
|
* A container for APIs related to the world's aim-assist
|
|
3765
3756
|
* settings.
|
|
3766
3757
|
*/
|
|
@@ -3897,14 +3888,14 @@ export class BiomeType {
|
|
|
3897
3888
|
*/
|
|
3898
3889
|
readonly id: string;
|
|
3899
3890
|
/**
|
|
3900
|
-
* @
|
|
3891
|
+
* @rc
|
|
3901
3892
|
* @remarks
|
|
3902
3893
|
* Returns a list of the biome's tags.
|
|
3903
3894
|
*
|
|
3904
3895
|
*/
|
|
3905
3896
|
getTags(): string[];
|
|
3906
3897
|
/**
|
|
3907
|
-
* @
|
|
3898
|
+
* @rc
|
|
3908
3899
|
* @remarks
|
|
3909
3900
|
* Checks if the biome has all of the provided tags.
|
|
3910
3901
|
*
|
|
@@ -3915,7 +3906,7 @@ export class BiomeType {
|
|
|
3915
3906
|
}
|
|
3916
3907
|
|
|
3917
3908
|
/**
|
|
3918
|
-
* @
|
|
3909
|
+
* @rc
|
|
3919
3910
|
* Supports a catalog of available biome types registered
|
|
3920
3911
|
* within Minecraft.
|
|
3921
3912
|
*/
|
|
@@ -4229,7 +4220,6 @@ export class Block {
|
|
|
4229
4220
|
*/
|
|
4230
4221
|
getComponent<T extends string>(componentId: T): BlockComponentReturnType<T> | undefined;
|
|
4231
4222
|
/**
|
|
4232
|
-
* @rc
|
|
4233
4223
|
* @remarks
|
|
4234
4224
|
* Returns all scripting components that are present on this
|
|
4235
4225
|
* block.
|
|
@@ -4348,7 +4338,6 @@ export class Block {
|
|
|
4348
4338
|
*/
|
|
4349
4339
|
getTags(): string[];
|
|
4350
4340
|
/**
|
|
4351
|
-
* @rc
|
|
4352
4341
|
* @remarks
|
|
4353
4342
|
* Returns true if the specified component is present on this
|
|
4354
4343
|
* block.
|
|
@@ -4381,7 +4370,7 @@ export class Block {
|
|
|
4381
4370
|
* {@link LocationOutOfWorldBoundariesError}
|
|
4382
4371
|
* @example checkBlockTags.ts
|
|
4383
4372
|
* ```typescript
|
|
4384
|
-
* import { DimensionLocation } from
|
|
4373
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
4385
4374
|
*
|
|
4386
4375
|
* function checkBlockTags(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
4387
4376
|
* // Fetch the block
|
|
@@ -4389,9 +4378,9 @@ export class Block {
|
|
|
4389
4378
|
*
|
|
4390
4379
|
* // check that the block is loaded
|
|
4391
4380
|
* if (block) {
|
|
4392
|
-
* log(`Block is dirt: ${block.hasTag(
|
|
4393
|
-
* log(`Block is wood: ${block.hasTag(
|
|
4394
|
-
* log(`Block is stone: ${block.hasTag(
|
|
4381
|
+
* log(`Block is dirt: ${block.hasTag('dirt')}`);
|
|
4382
|
+
* log(`Block is wood: ${block.hasTag('wood')}`);
|
|
4383
|
+
* log(`Block is stone: ${block.hasTag('stone')}`);
|
|
4395
4384
|
* }
|
|
4396
4385
|
* }
|
|
4397
4386
|
* ```
|
|
@@ -4784,7 +4773,6 @@ export class BlockComponentBlockBreakEvent extends BlockEvent {
|
|
|
4784
4773
|
}
|
|
4785
4774
|
|
|
4786
4775
|
/**
|
|
4787
|
-
* @rc
|
|
4788
4776
|
* Contains information regarding an event sent by an entity to
|
|
4789
4777
|
* this block in the world.
|
|
4790
4778
|
*/
|
|
@@ -4958,7 +4946,6 @@ export class BlockComponentRedstoneUpdateEvent extends BlockEvent {
|
|
|
4958
4946
|
*/
|
|
4959
4947
|
readonly powerLevel: number;
|
|
4960
4948
|
/**
|
|
4961
|
-
* @rc
|
|
4962
4949
|
* @remarks
|
|
4963
4950
|
* The redstone signal strength from the last tick that was
|
|
4964
4951
|
* passing through this block. It is guaranteed to be >= the
|
|
@@ -5286,15 +5273,15 @@ export class BlockFluidContainerComponent extends BlockComponent {
|
|
|
5286
5273
|
* blocks like chests.
|
|
5287
5274
|
* @example placeItemsInChest.ts
|
|
5288
5275
|
* ```typescript
|
|
5289
|
-
* import { ItemStack, BlockInventoryComponent, DimensionLocation } from
|
|
5290
|
-
* import { MinecraftBlockTypes, MinecraftItemTypes } from
|
|
5276
|
+
* import { ItemStack, BlockInventoryComponent, DimensionLocation } from '@minecraft/server';
|
|
5277
|
+
* import { MinecraftBlockTypes, MinecraftItemTypes } from '@minecraft/vanilla-data';
|
|
5291
5278
|
*
|
|
5292
5279
|
* function placeItemsInChest(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
5293
5280
|
* // Fetch block
|
|
5294
5281
|
* const block = targetLocation.dimension.getBlock(targetLocation);
|
|
5295
5282
|
*
|
|
5296
5283
|
* if (!block) {
|
|
5297
|
-
* log(
|
|
5284
|
+
* log('Could not find block. Maybe it is not loaded?', -1);
|
|
5298
5285
|
* return;
|
|
5299
5286
|
* }
|
|
5300
5287
|
*
|
|
@@ -5302,10 +5289,10 @@ export class BlockFluidContainerComponent extends BlockComponent {
|
|
|
5302
5289
|
* block.setType(MinecraftBlockTypes.Chest);
|
|
5303
5290
|
*
|
|
5304
5291
|
* // Get the inventory
|
|
5305
|
-
* const inventoryComponent = block.getComponent(
|
|
5292
|
+
* const inventoryComponent = block.getComponent('inventory') as BlockInventoryComponent;
|
|
5306
5293
|
*
|
|
5307
5294
|
* if (!inventoryComponent || !inventoryComponent.container) {
|
|
5308
|
-
* log(
|
|
5295
|
+
* log('Could not find inventory component.', -1);
|
|
5309
5296
|
* return;
|
|
5310
5297
|
* }
|
|
5311
5298
|
*
|
|
@@ -5436,8 +5423,8 @@ export class BlockMovableComponent extends BlockComponent {
|
|
|
5436
5423
|
* Block}).
|
|
5437
5424
|
* @example addTranslatedSign.ts
|
|
5438
5425
|
* ```typescript
|
|
5439
|
-
* import { world, BlockPermutation, BlockSignComponent, BlockComponentTypes, DimensionLocation } from
|
|
5440
|
-
* import { MinecraftBlockTypes } from
|
|
5426
|
+
* import { world, BlockPermutation, BlockSignComponent, BlockComponentTypes, DimensionLocation } from '@minecraft/server';
|
|
5427
|
+
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
|
|
5441
5428
|
*
|
|
5442
5429
|
* function addTranslatedSign(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
5443
5430
|
* const players = world.getPlayers();
|
|
@@ -5447,7 +5434,7 @@ export class BlockMovableComponent extends BlockComponent {
|
|
|
5447
5434
|
* const signBlock = dim.getBlock(targetLocation);
|
|
5448
5435
|
*
|
|
5449
5436
|
* if (!signBlock) {
|
|
5450
|
-
* log(
|
|
5437
|
+
* log('Could not find a block at specified location.');
|
|
5451
5438
|
* return -1;
|
|
5452
5439
|
* }
|
|
5453
5440
|
* const signPerm = BlockPermutation.resolve(MinecraftBlockTypes.StandingSign, { ground_sign_direction: 8 });
|
|
@@ -5456,14 +5443,13 @@ export class BlockMovableComponent extends BlockComponent {
|
|
|
5456
5443
|
*
|
|
5457
5444
|
* const signComponent = signBlock.getComponent(BlockComponentTypes.Sign) as BlockSignComponent;
|
|
5458
5445
|
*
|
|
5459
|
-
* signComponent?.setText({ translate:
|
|
5446
|
+
* signComponent?.setText({ translate: 'item.skull.player.name', with: [players[0].name] });
|
|
5460
5447
|
* }
|
|
5461
5448
|
* ```
|
|
5462
5449
|
*/
|
|
5463
5450
|
export class BlockPermutation {
|
|
5464
5451
|
private constructor();
|
|
5465
5452
|
/**
|
|
5466
|
-
* @rc
|
|
5467
5453
|
* @remarks
|
|
5468
5454
|
* Key for the localization of this BlockPermutation's name
|
|
5469
5455
|
* used in .lang files.
|
|
@@ -5550,7 +5536,7 @@ export class BlockPermutation {
|
|
|
5550
5536
|
* Returns `true` if the permutation has the tag, else `false`.
|
|
5551
5537
|
* @example checkBlockTags.ts
|
|
5552
5538
|
* ```typescript
|
|
5553
|
-
* import { DimensionLocation } from
|
|
5539
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
5554
5540
|
*
|
|
5555
5541
|
* function checkBlockTags(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
5556
5542
|
* // Fetch the block
|
|
@@ -5558,9 +5544,9 @@ export class BlockPermutation {
|
|
|
5558
5544
|
*
|
|
5559
5545
|
* // check that the block is loaded
|
|
5560
5546
|
* if (block) {
|
|
5561
|
-
* log(`Block is dirt: ${block.hasTag(
|
|
5562
|
-
* log(`Block is wood: ${block.hasTag(
|
|
5563
|
-
* log(`Block is stone: ${block.hasTag(
|
|
5547
|
+
* log(`Block is dirt: ${block.hasTag('dirt')}`);
|
|
5548
|
+
* log(`Block is wood: ${block.hasTag('wood')}`);
|
|
5549
|
+
* log(`Block is stone: ${block.hasTag('stone')}`);
|
|
5564
5550
|
* }
|
|
5565
5551
|
* }
|
|
5566
5552
|
* ```
|
|
@@ -5629,9 +5615,9 @@ export class BlockPermutation {
|
|
|
5629
5615
|
* @throws This function can throw errors.
|
|
5630
5616
|
* @example addBlockColorCube.ts
|
|
5631
5617
|
* ```typescript
|
|
5632
|
-
* import { BlockPermutation, DimensionLocation } from
|
|
5633
|
-
* import { Vector3Utils } from
|
|
5634
|
-
* import { MinecraftBlockTypes } from
|
|
5618
|
+
* import { BlockPermutation, DimensionLocation } from '@minecraft/server';
|
|
5619
|
+
* import { Vector3Utils } from '@minecraft/math';
|
|
5620
|
+
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
|
|
5635
5621
|
*
|
|
5636
5622
|
* function addBlockColorCube(targetLocation: DimensionLocation) {
|
|
5637
5623
|
* const allWoolBlocks: string[] = [
|
|
@@ -5866,8 +5852,8 @@ export class BlockRedstoneProducerComponent extends BlockComponent {
|
|
|
5866
5852
|
* Represents a block that can display text on it.
|
|
5867
5853
|
* @example addSign.ts
|
|
5868
5854
|
* ```typescript
|
|
5869
|
-
* import { world, BlockPermutation, BlockSignComponent, BlockComponentTypes, DimensionLocation } from
|
|
5870
|
-
* import { MinecraftBlockTypes } from
|
|
5855
|
+
* import { world, BlockPermutation, BlockSignComponent, BlockComponentTypes, DimensionLocation } from '@minecraft/server';
|
|
5856
|
+
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
|
|
5871
5857
|
*
|
|
5872
5858
|
* function addSign(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
5873
5859
|
* const players = world.getPlayers();
|
|
@@ -5877,7 +5863,7 @@ export class BlockRedstoneProducerComponent extends BlockComponent {
|
|
|
5877
5863
|
* const signBlock = dim.getBlock(targetLocation);
|
|
5878
5864
|
*
|
|
5879
5865
|
* if (!signBlock) {
|
|
5880
|
-
* log(
|
|
5866
|
+
* log('Could not find a block at specified location.');
|
|
5881
5867
|
* return -1;
|
|
5882
5868
|
* }
|
|
5883
5869
|
* const signPerm = BlockPermutation.resolve(MinecraftBlockTypes.StandingSign, { ground_sign_direction: 8 });
|
|
@@ -5891,14 +5877,21 @@ export class BlockRedstoneProducerComponent extends BlockComponent {
|
|
|
5891
5877
|
* ```
|
|
5892
5878
|
* @example addTwoSidedSign.ts
|
|
5893
5879
|
* ```typescript
|
|
5894
|
-
* import {
|
|
5895
|
-
*
|
|
5880
|
+
* import {
|
|
5881
|
+
* BlockPermutation,
|
|
5882
|
+
* BlockSignComponent,
|
|
5883
|
+
* SignSide,
|
|
5884
|
+
* DyeColor,
|
|
5885
|
+
* BlockComponentTypes,
|
|
5886
|
+
* DimensionLocation,
|
|
5887
|
+
* } from '@minecraft/server';
|
|
5888
|
+
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
|
|
5896
5889
|
*
|
|
5897
5890
|
* function addTwoSidedSign(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
5898
5891
|
* const signBlock = targetLocation.dimension.getBlock(targetLocation);
|
|
5899
5892
|
*
|
|
5900
5893
|
* if (!signBlock) {
|
|
5901
|
-
* log(
|
|
5894
|
+
* log('Could not find a block at specified location.');
|
|
5902
5895
|
* return -1;
|
|
5903
5896
|
* }
|
|
5904
5897
|
* const signPerm = BlockPermutation.resolve(MinecraftBlockTypes.StandingSign, { ground_sign_direction: 8 });
|
|
@@ -5916,42 +5909,42 @@ export class BlockRedstoneProducerComponent extends BlockComponent {
|
|
|
5916
5909
|
* // players cannot edit sign!
|
|
5917
5910
|
* signComponent.setWaxed(true);
|
|
5918
5911
|
* } else {
|
|
5919
|
-
* log(
|
|
5912
|
+
* log('Could not find sign component.');
|
|
5920
5913
|
* }
|
|
5921
5914
|
* }
|
|
5922
5915
|
* ```
|
|
5923
5916
|
* @example updateSignText.ts
|
|
5924
5917
|
* ```typescript
|
|
5925
|
-
* import { BlockSignComponent, BlockComponentTypes, DimensionLocation, RawMessage, RawText } from
|
|
5918
|
+
* import { BlockSignComponent, BlockComponentTypes, DimensionLocation, RawMessage, RawText } from '@minecraft/server';
|
|
5926
5919
|
*
|
|
5927
5920
|
* function updateSignText(targetLocation: DimensionLocation) {
|
|
5928
5921
|
* const block = targetLocation.dimension.getBlock(targetLocation);
|
|
5929
5922
|
* if (!block) {
|
|
5930
|
-
* console.warn(
|
|
5923
|
+
* console.warn('Could not find a block at specified location.');
|
|
5931
5924
|
* return;
|
|
5932
5925
|
* }
|
|
5933
5926
|
*
|
|
5934
5927
|
* const sign = block.getComponent(BlockComponentTypes.Sign) as BlockSignComponent;
|
|
5935
5928
|
* if (sign) {
|
|
5936
5929
|
* // RawMessage
|
|
5937
|
-
* const helloWorldMessage: RawMessage = { text:
|
|
5930
|
+
* const helloWorldMessage: RawMessage = { text: 'Hello World' };
|
|
5938
5931
|
* sign.setText(helloWorldMessage);
|
|
5939
5932
|
*
|
|
5940
5933
|
* // RawText
|
|
5941
|
-
* const helloWorldText: RawText = { rawtext: [{ text:
|
|
5934
|
+
* const helloWorldText: RawText = { rawtext: [{ text: 'Hello World' }] };
|
|
5942
5935
|
* sign.setText(helloWorldText);
|
|
5943
5936
|
*
|
|
5944
5937
|
* // Regular string
|
|
5945
|
-
* sign.setText(
|
|
5938
|
+
* sign.setText('Hello World');
|
|
5946
5939
|
* } else {
|
|
5947
|
-
* console.warn(
|
|
5940
|
+
* console.warn('Could not find a sign component on the block.');
|
|
5948
5941
|
* }
|
|
5949
5942
|
* }
|
|
5950
5943
|
* ```
|
|
5951
5944
|
* @example addTranslatedSign.ts
|
|
5952
5945
|
* ```typescript
|
|
5953
|
-
* import { world, BlockPermutation, BlockSignComponent, BlockComponentTypes, DimensionLocation } from
|
|
5954
|
-
* import { MinecraftBlockTypes } from
|
|
5946
|
+
* import { world, BlockPermutation, BlockSignComponent, BlockComponentTypes, DimensionLocation } from '@minecraft/server';
|
|
5947
|
+
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
|
|
5955
5948
|
*
|
|
5956
5949
|
* function addTranslatedSign(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
5957
5950
|
* const players = world.getPlayers();
|
|
@@ -5961,7 +5954,7 @@ export class BlockRedstoneProducerComponent extends BlockComponent {
|
|
|
5961
5954
|
* const signBlock = dim.getBlock(targetLocation);
|
|
5962
5955
|
*
|
|
5963
5956
|
* if (!signBlock) {
|
|
5964
|
-
* log(
|
|
5957
|
+
* log('Could not find a block at specified location.');
|
|
5965
5958
|
* return -1;
|
|
5966
5959
|
* }
|
|
5967
5960
|
* const signPerm = BlockPermutation.resolve(MinecraftBlockTypes.StandingSign, { ground_sign_direction: 8 });
|
|
@@ -5970,7 +5963,7 @@ export class BlockRedstoneProducerComponent extends BlockComponent {
|
|
|
5970
5963
|
*
|
|
5971
5964
|
* const signComponent = signBlock.getComponent(BlockComponentTypes.Sign) as BlockSignComponent;
|
|
5972
5965
|
*
|
|
5973
|
-
* signComponent?.setText({ translate:
|
|
5966
|
+
* signComponent?.setText({ translate: 'item.skull.player.name', with: [players[0].name] });
|
|
5974
5967
|
* }
|
|
5975
5968
|
* ```
|
|
5976
5969
|
*/
|
|
@@ -6133,7 +6126,6 @@ export class BlockType {
|
|
|
6133
6126
|
*/
|
|
6134
6127
|
readonly id: string;
|
|
6135
6128
|
/**
|
|
6136
|
-
* @rc
|
|
6137
6129
|
* @remarks
|
|
6138
6130
|
* Key for the localization of this BlockType's name used in
|
|
6139
6131
|
* .lang files.
|
|
@@ -6322,8 +6314,8 @@ export class BlockVolumeBase {
|
|
|
6322
6314
|
* Contains information related to changes to a button push.
|
|
6323
6315
|
* @example buttonPushEvent.ts
|
|
6324
6316
|
* ```typescript
|
|
6325
|
-
* import { world, system, BlockPermutation, ButtonPushAfterEvent, DimensionLocation } from
|
|
6326
|
-
* import { MinecraftBlockTypes } from
|
|
6317
|
+
* import { world, system, BlockPermutation, ButtonPushAfterEvent, DimensionLocation } from '@minecraft/server';
|
|
6318
|
+
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
|
|
6327
6319
|
*
|
|
6328
6320
|
* function buttonPushEvent(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
6329
6321
|
* // set up a button on cobblestone
|
|
@@ -6335,18 +6327,18 @@ export class BlockVolumeBase {
|
|
|
6335
6327
|
* });
|
|
6336
6328
|
*
|
|
6337
6329
|
* if (cobblestone === undefined || button === undefined) {
|
|
6338
|
-
* log(
|
|
6330
|
+
* log('Could not find block at location.');
|
|
6339
6331
|
* return -1;
|
|
6340
6332
|
* }
|
|
6341
6333
|
*
|
|
6342
6334
|
* cobblestone.setPermutation(BlockPermutation.resolve(MinecraftBlockTypes.Cobblestone));
|
|
6343
|
-
* button.setPermutation(BlockPermutation.resolve(MinecraftBlockTypes.AcaciaButton).withState(
|
|
6335
|
+
* button.setPermutation(BlockPermutation.resolve(MinecraftBlockTypes.AcaciaButton).withState('facing_direction', 1));
|
|
6344
6336
|
*
|
|
6345
6337
|
* world.afterEvents.buttonPush.subscribe((buttonPushEvent: ButtonPushAfterEvent) => {
|
|
6346
6338
|
* const eventLoc = buttonPushEvent.block.location;
|
|
6347
6339
|
*
|
|
6348
6340
|
* if (eventLoc.x === targetLocation.x && eventLoc.y === targetLocation.y + 1 && eventLoc.z === targetLocation.z) {
|
|
6349
|
-
* log(
|
|
6341
|
+
* log('Button push event at tick ' + system.currentTick);
|
|
6350
6342
|
* }
|
|
6351
6343
|
* });
|
|
6352
6344
|
* }
|
|
@@ -6368,8 +6360,8 @@ export class ButtonPushAfterEvent extends BlockEvent {
|
|
|
6368
6360
|
* pushed.
|
|
6369
6361
|
* @example buttonPushEvent.ts
|
|
6370
6362
|
* ```typescript
|
|
6371
|
-
* import { world, system, BlockPermutation, ButtonPushAfterEvent, DimensionLocation } from
|
|
6372
|
-
* import { MinecraftBlockTypes } from
|
|
6363
|
+
* import { world, system, BlockPermutation, ButtonPushAfterEvent, DimensionLocation } from '@minecraft/server';
|
|
6364
|
+
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
|
|
6373
6365
|
*
|
|
6374
6366
|
* function buttonPushEvent(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
6375
6367
|
* // set up a button on cobblestone
|
|
@@ -6381,18 +6373,18 @@ export class ButtonPushAfterEvent extends BlockEvent {
|
|
|
6381
6373
|
* });
|
|
6382
6374
|
*
|
|
6383
6375
|
* if (cobblestone === undefined || button === undefined) {
|
|
6384
|
-
* log(
|
|
6376
|
+
* log('Could not find block at location.');
|
|
6385
6377
|
* return -1;
|
|
6386
6378
|
* }
|
|
6387
6379
|
*
|
|
6388
6380
|
* cobblestone.setPermutation(BlockPermutation.resolve(MinecraftBlockTypes.Cobblestone));
|
|
6389
|
-
* button.setPermutation(BlockPermutation.resolve(MinecraftBlockTypes.AcaciaButton).withState(
|
|
6381
|
+
* button.setPermutation(BlockPermutation.resolve(MinecraftBlockTypes.AcaciaButton).withState('facing_direction', 1));
|
|
6390
6382
|
*
|
|
6391
6383
|
* world.afterEvents.buttonPush.subscribe((buttonPushEvent: ButtonPushAfterEvent) => {
|
|
6392
6384
|
* const eventLoc = buttonPushEvent.block.location;
|
|
6393
6385
|
*
|
|
6394
6386
|
* if (eventLoc.x === targetLocation.x && eventLoc.y === targetLocation.y + 1 && eventLoc.z === targetLocation.z) {
|
|
6395
|
-
* log(
|
|
6387
|
+
* log('Button push event at tick ' + system.currentTick);
|
|
6396
6388
|
* }
|
|
6397
6389
|
* });
|
|
6398
6390
|
* }
|
|
@@ -6438,7 +6430,6 @@ export class Camera {
|
|
|
6438
6430
|
*/
|
|
6439
6431
|
readonly isValid: boolean;
|
|
6440
6432
|
/**
|
|
6441
|
-
* @rc
|
|
6442
6433
|
* @remarks
|
|
6443
6434
|
* Attaches the camera to a non-player entity.
|
|
6444
6435
|
*
|
|
@@ -6475,7 +6466,6 @@ export class Camera {
|
|
|
6475
6466
|
*/
|
|
6476
6467
|
fade(fadeCameraOptions?: CameraFadeOptions): void;
|
|
6477
6468
|
/**
|
|
6478
|
-
* @rc
|
|
6479
6469
|
* @remarks
|
|
6480
6470
|
* This function can't be called in restricted-execution mode.
|
|
6481
6471
|
*
|
|
@@ -6547,7 +6537,6 @@ export class Camera {
|
|
|
6547
6537
|
}
|
|
6548
6538
|
|
|
6549
6539
|
/**
|
|
6550
|
-
* @rc
|
|
6551
6540
|
* CatmullRom spline creation.
|
|
6552
6541
|
*/
|
|
6553
6542
|
export class CatmullRomSpline {
|
|
@@ -6661,23 +6650,23 @@ export class ChatSendBeforeEvent {
|
|
|
6661
6650
|
* before chat messages are sent.
|
|
6662
6651
|
* @example customCommand.ts
|
|
6663
6652
|
* ```typescript
|
|
6664
|
-
* import { world, DimensionLocation } from
|
|
6653
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
6665
6654
|
*
|
|
6666
6655
|
* function customCommand(targetLocation: DimensionLocation) {
|
|
6667
|
-
* const chatCallback = world.beforeEvents.chatSend.subscribe(
|
|
6668
|
-
* if (eventData.message.includes(
|
|
6656
|
+
* const chatCallback = world.beforeEvents.chatSend.subscribe(eventData => {
|
|
6657
|
+
* if (eventData.message.includes('cancel')) {
|
|
6669
6658
|
* // Cancel event if the message contains "cancel"
|
|
6670
6659
|
* eventData.cancel = true;
|
|
6671
6660
|
* } else {
|
|
6672
|
-
* const args = eventData.message.split(
|
|
6661
|
+
* const args = eventData.message.split(' ');
|
|
6673
6662
|
*
|
|
6674
6663
|
* if (args.length > 0) {
|
|
6675
6664
|
* switch (args[0].toLowerCase()) {
|
|
6676
|
-
* case
|
|
6665
|
+
* case 'echo':
|
|
6677
6666
|
* // Send a modified version of chat message
|
|
6678
6667
|
* world.sendMessage(`Echo '${eventData.message.substring(4).trim()}'`);
|
|
6679
6668
|
* break;
|
|
6680
|
-
* case
|
|
6669
|
+
* case 'help':
|
|
6681
6670
|
* world.sendMessage(`Available commands: echo <message>`);
|
|
6682
6671
|
* break;
|
|
6683
6672
|
* }
|
|
@@ -6725,6 +6714,21 @@ export class ChatSendBeforeEventSignal {
|
|
|
6725
6714
|
// @ts-ignore Class inheritance allowed for native defined classes
|
|
6726
6715
|
export class ClientSystemInfo extends SystemInfo {
|
|
6727
6716
|
private constructor();
|
|
6717
|
+
/**
|
|
6718
|
+
* @beta
|
|
6719
|
+
* @remarks
|
|
6720
|
+
* The locale selected by the client (e.g., en_US, fr_FR,
|
|
6721
|
+
* ja_JP). Note that in most cases, server scripts should not
|
|
6722
|
+
* use this property to manually localize text. Instead, use
|
|
6723
|
+
* {@link RawMessage} with a translate field to send
|
|
6724
|
+
* localization keys, allowing each client to resolve them in
|
|
6725
|
+
* their own language automatically. Direct use of locale for
|
|
6726
|
+
* localization is fragile and may produce unexpected results
|
|
6727
|
+
* when players with different languages are on the same
|
|
6728
|
+
* server.
|
|
6729
|
+
*
|
|
6730
|
+
*/
|
|
6731
|
+
readonly locale: string;
|
|
6728
6732
|
/**
|
|
6729
6733
|
* @remarks
|
|
6730
6734
|
* The max render distance for the device in chunks.
|
|
@@ -7034,8 +7038,8 @@ export class CompoundBlockVolume {
|
|
|
7034
7038
|
* more.
|
|
7035
7039
|
* @example containers.ts
|
|
7036
7040
|
* ```typescript
|
|
7037
|
-
* import { ItemStack, EntityInventoryComponent, BlockInventoryComponent, DimensionLocation } from
|
|
7038
|
-
* import { MinecraftBlockTypes, MinecraftItemTypes, MinecraftEntityTypes } from
|
|
7041
|
+
* import { ItemStack, EntityInventoryComponent, BlockInventoryComponent, DimensionLocation } from '@minecraft/server';
|
|
7042
|
+
* import { MinecraftBlockTypes, MinecraftItemTypes, MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
7039
7043
|
*
|
|
7040
7044
|
* function containers(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
7041
7045
|
* const xLocation = targetLocation; // left chest location
|
|
@@ -7051,42 +7055,42 @@ export class CompoundBlockVolume {
|
|
|
7051
7055
|
* const xPlusTwoChestBlock = targetLocation.dimension.getBlock(xPlusTwoLocation);
|
|
7052
7056
|
*
|
|
7053
7057
|
* if (!xChestBlock || !xPlusTwoChestBlock) {
|
|
7054
|
-
* log(
|
|
7058
|
+
* log('Could not retrieve chest blocks.');
|
|
7055
7059
|
* return;
|
|
7056
7060
|
* }
|
|
7057
7061
|
*
|
|
7058
7062
|
* xChestBlock.setType(MinecraftBlockTypes.Chest);
|
|
7059
7063
|
* xPlusTwoChestBlock.setType(MinecraftBlockTypes.Chest);
|
|
7060
7064
|
*
|
|
7061
|
-
* const xPlusTwoChestInventoryComp = xPlusTwoChestBlock.getComponent(
|
|
7062
|
-
* const xChestInventoryComponent = xChestBlock.getComponent(
|
|
7063
|
-
* const chestCartInventoryComp = chestCart.getComponent(
|
|
7065
|
+
* const xPlusTwoChestInventoryComp = xPlusTwoChestBlock.getComponent('inventory') as BlockInventoryComponent;
|
|
7066
|
+
* const xChestInventoryComponent = xChestBlock.getComponent('inventory') as BlockInventoryComponent;
|
|
7067
|
+
* const chestCartInventoryComp = chestCart.getComponent('inventory') as EntityInventoryComponent;
|
|
7064
7068
|
*
|
|
7065
7069
|
* const xPlusTwoChestContainer = xPlusTwoChestInventoryComp.container;
|
|
7066
7070
|
* const xChestContainer = xChestInventoryComponent.container;
|
|
7067
7071
|
* const chestCartContainer = chestCartInventoryComp.container;
|
|
7068
7072
|
*
|
|
7069
7073
|
* if (!xPlusTwoChestContainer || !xChestContainer || !chestCartContainer) {
|
|
7070
|
-
* log(
|
|
7074
|
+
* log('Could not retrieve chest containers.');
|
|
7071
7075
|
* return;
|
|
7072
7076
|
* }
|
|
7073
7077
|
*
|
|
7074
7078
|
* xPlusTwoChestContainer.setItem(0, new ItemStack(MinecraftItemTypes.Apple, 10));
|
|
7075
7079
|
* if (xPlusTwoChestContainer.getItem(0)?.typeId !== MinecraftItemTypes.Apple) {
|
|
7076
|
-
* log(
|
|
7080
|
+
* log('Expected apple in x+2 container slot index 0', -1);
|
|
7077
7081
|
* }
|
|
7078
7082
|
*
|
|
7079
7083
|
* xPlusTwoChestContainer.setItem(1, new ItemStack(MinecraftItemTypes.Emerald, 10));
|
|
7080
7084
|
* if (xPlusTwoChestContainer.getItem(1)?.typeId !== MinecraftItemTypes.Emerald) {
|
|
7081
|
-
* log(
|
|
7085
|
+
* log('Expected emerald in x+2 container slot index 1', -1);
|
|
7082
7086
|
* }
|
|
7083
7087
|
*
|
|
7084
7088
|
* if (xPlusTwoChestContainer.size !== 27) {
|
|
7085
|
-
* log(
|
|
7089
|
+
* log('Unexpected size: ' + xPlusTwoChestContainer.size, -1);
|
|
7086
7090
|
* }
|
|
7087
7091
|
*
|
|
7088
7092
|
* if (xPlusTwoChestContainer.emptySlotsCount !== 25) {
|
|
7089
|
-
* log(
|
|
7093
|
+
* log('Unexpected emptySlotsCount: ' + xPlusTwoChestContainer.emptySlotsCount, -1);
|
|
7090
7094
|
* }
|
|
7091
7095
|
*
|
|
7092
7096
|
* xChestContainer.setItem(0, new ItemStack(MinecraftItemTypes.Cake, 10));
|
|
@@ -7095,15 +7099,15 @@ export class CompoundBlockVolume {
|
|
|
7095
7099
|
* xPlusTwoChestContainer.swapItems(1, 0, xChestContainer); // swap the cake from x and the emerald from xPlusTwo
|
|
7096
7100
|
*
|
|
7097
7101
|
* if (chestCartContainer.getItem(0)?.typeId !== MinecraftItemTypes.Apple) {
|
|
7098
|
-
* log(
|
|
7102
|
+
* log('Expected apple in minecraft chest container slot index 0', -1);
|
|
7099
7103
|
* }
|
|
7100
7104
|
*
|
|
7101
7105
|
* if (xChestContainer.getItem(0)?.typeId === MinecraftItemTypes.Emerald) {
|
|
7102
|
-
* log(
|
|
7106
|
+
* log('Expected emerald in x container slot index 0', -1);
|
|
7103
7107
|
* }
|
|
7104
7108
|
*
|
|
7105
7109
|
* if (xPlusTwoChestContainer.getItem(1)?.typeId === MinecraftItemTypes.Cake) {
|
|
7106
|
-
* log(
|
|
7110
|
+
* log('Expected cake in x+2 container slot index 1', -1);
|
|
7107
7111
|
* }
|
|
7108
7112
|
* }
|
|
7109
7113
|
* ```
|
|
@@ -7253,7 +7257,7 @@ export class Container {
|
|
|
7253
7257
|
* out of bounds.
|
|
7254
7258
|
* @example getFirstHotbarItem.ts
|
|
7255
7259
|
* ```typescript
|
|
7256
|
-
* import { world, EntityInventoryComponent, DimensionLocation } from
|
|
7260
|
+
* import { world, EntityInventoryComponent, DimensionLocation } from '@minecraft/server';
|
|
7257
7261
|
*
|
|
7258
7262
|
* function getFirstHotbarItem(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
7259
7263
|
* for (const player of world.getAllPlayers()) {
|
|
@@ -7262,7 +7266,7 @@ export class Container {
|
|
|
7262
7266
|
* const firstItem = inventory.container.getItem(0);
|
|
7263
7267
|
*
|
|
7264
7268
|
* if (firstItem) {
|
|
7265
|
-
* log(
|
|
7269
|
+
* log('First item in hotbar is: ' + firstItem.typeId);
|
|
7266
7270
|
* }
|
|
7267
7271
|
*
|
|
7268
7272
|
* return inventory.container.getItem(0);
|
|
@@ -7314,12 +7318,10 @@ export class Container {
|
|
|
7314
7318
|
* {@link Error}
|
|
7315
7319
|
* @example moveBetweenContainers.ts
|
|
7316
7320
|
* ```typescript
|
|
7317
|
-
* import { world, EntityInventoryComponent, EntityComponentTypes, DimensionLocation } from
|
|
7318
|
-
* import { MinecraftEntityTypes } from
|
|
7321
|
+
* import { world, EntityInventoryComponent, EntityComponentTypes, DimensionLocation } from '@minecraft/server';
|
|
7322
|
+
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
7319
7323
|
*
|
|
7320
|
-
* function moveBetweenContainers(
|
|
7321
|
-
* targetLocation: DimensionLocation
|
|
7322
|
-
* ) {
|
|
7324
|
+
* function moveBetweenContainers(targetLocation: DimensionLocation) {
|
|
7323
7325
|
* const players = world.getAllPlayers();
|
|
7324
7326
|
*
|
|
7325
7327
|
* const chestCart = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.ChestMinecart, {
|
|
@@ -7415,12 +7417,10 @@ export class Container {
|
|
|
7415
7417
|
* {@link Error}
|
|
7416
7418
|
* @example transferBetweenContainers.ts
|
|
7417
7419
|
* ```typescript
|
|
7418
|
-
* import { world, EntityInventoryComponent, EntityComponentTypes, DimensionLocation } from
|
|
7419
|
-
* import { MinecraftEntityTypes } from
|
|
7420
|
+
* import { world, EntityInventoryComponent, EntityComponentTypes, DimensionLocation } from '@minecraft/server';
|
|
7421
|
+
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
7420
7422
|
*
|
|
7421
|
-
* function transferBetweenContainers(
|
|
7422
|
-
* targetLocation: DimensionLocation
|
|
7423
|
-
* ) {
|
|
7423
|
+
* function transferBetweenContainers(targetLocation: DimensionLocation) {
|
|
7424
7424
|
* const players = world.getAllPlayers();
|
|
7425
7425
|
*
|
|
7426
7426
|
* const chestCart = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.ChestMinecart, {
|
|
@@ -8038,7 +8038,6 @@ export class Dimension {
|
|
|
8038
8038
|
*/
|
|
8039
8039
|
readonly localizationKey: string;
|
|
8040
8040
|
/**
|
|
8041
|
-
* @rc
|
|
8042
8041
|
* @remarks
|
|
8043
8042
|
* Checks if an area contains the specified biomes. If the area
|
|
8044
8043
|
* is partially inside world boundaries, only the area that is
|
|
@@ -8126,42 +8125,39 @@ export class Dimension {
|
|
|
8126
8125
|
* {@link LocationOutOfWorldBoundariesError}
|
|
8127
8126
|
* @example createExplosion.ts
|
|
8128
8127
|
* ```typescript
|
|
8129
|
-
* import { DimensionLocation } from
|
|
8128
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
8130
8129
|
*
|
|
8131
8130
|
* function createExplosion(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
8132
|
-
* log(
|
|
8131
|
+
* log('Creating an explosion of radius 10.');
|
|
8133
8132
|
* targetLocation.dimension.createExplosion(targetLocation, 10);
|
|
8134
8133
|
* }
|
|
8135
8134
|
* ```
|
|
8136
8135
|
* @example createNoBlockExplosion.ts
|
|
8137
8136
|
* ```typescript
|
|
8138
|
-
* import { DimensionLocation } from
|
|
8139
|
-
* import { Vector3Utils } from
|
|
8137
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
8138
|
+
* import { Vector3Utils } from '@minecraft/math';
|
|
8140
8139
|
*
|
|
8141
|
-
* function createNoBlockExplosion(
|
|
8142
|
-
* log: (message: string, status?: number) => void,
|
|
8143
|
-
* targetLocation: DimensionLocation
|
|
8144
|
-
* ) {
|
|
8140
|
+
* function createNoBlockExplosion(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
8145
8141
|
* const explodeNoBlocksLoc = Vector3Utils.floor(Vector3Utils.add(targetLocation, { x: 1, y: 2, z: 1 }));
|
|
8146
8142
|
*
|
|
8147
|
-
* log(
|
|
8143
|
+
* log('Creating an explosion of radius 15 that does not break blocks.');
|
|
8148
8144
|
* targetLocation.dimension.createExplosion(explodeNoBlocksLoc, 15, { breaksBlocks: false });
|
|
8149
8145
|
* }
|
|
8150
8146
|
* ```
|
|
8151
8147
|
* @example createExplosions.ts
|
|
8152
8148
|
* ```typescript
|
|
8153
|
-
* import { DimensionLocation } from
|
|
8154
|
-
* import { Vector3Utils } from
|
|
8149
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
8150
|
+
* import { Vector3Utils } from '@minecraft/math';
|
|
8155
8151
|
*
|
|
8156
8152
|
* function createExplosions(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
8157
8153
|
* const explosionLoc = Vector3Utils.add(targetLocation, { x: 0.5, y: 0.5, z: 0.5 });
|
|
8158
8154
|
*
|
|
8159
|
-
* log(
|
|
8155
|
+
* log('Creating an explosion of radius 15 that causes fire.');
|
|
8160
8156
|
* targetLocation.dimension.createExplosion(explosionLoc, 15, { causesFire: true });
|
|
8161
8157
|
*
|
|
8162
8158
|
* const belowWaterLoc = Vector3Utils.add(targetLocation, { x: 3, y: 1, z: 3 });
|
|
8163
8159
|
*
|
|
8164
|
-
* log(
|
|
8160
|
+
* log('Creating an explosion of radius 10 that can go underwater.');
|
|
8165
8161
|
* targetLocation.dimension.createExplosion(belowWaterLoc, 10, { allowUnderwater: true });
|
|
8166
8162
|
* }
|
|
8167
8163
|
* ```
|
|
@@ -8344,10 +8340,10 @@ export class Dimension {
|
|
|
8344
8340
|
* {@link minecraftcommon.InvalidArgumentError}
|
|
8345
8341
|
* @example bounceSkeletons.ts
|
|
8346
8342
|
* ```typescript
|
|
8347
|
-
* import { EntityQueryOptions, DimensionLocation } from
|
|
8343
|
+
* import { EntityQueryOptions, DimensionLocation } from '@minecraft/server';
|
|
8348
8344
|
*
|
|
8349
8345
|
* function bounceSkeletons(targetLocation: DimensionLocation) {
|
|
8350
|
-
* const mobs = [
|
|
8346
|
+
* const mobs = ['creeper', 'skeleton', 'sheep'];
|
|
8351
8347
|
*
|
|
8352
8348
|
* // create some sample mob data
|
|
8353
8349
|
* for (let i = 0; i < 10; i++) {
|
|
@@ -8355,7 +8351,7 @@ export class Dimension {
|
|
|
8355
8351
|
* }
|
|
8356
8352
|
*
|
|
8357
8353
|
* const eqo: EntityQueryOptions = {
|
|
8358
|
-
* type:
|
|
8354
|
+
* type: 'skeleton',
|
|
8359
8355
|
* };
|
|
8360
8356
|
*
|
|
8361
8357
|
* for (const entity of targetLocation.dimension.getEntities(eqo)) {
|
|
@@ -8365,20 +8361,20 @@ export class Dimension {
|
|
|
8365
8361
|
* ```
|
|
8366
8362
|
* @example tagsQuery.ts
|
|
8367
8363
|
* ```typescript
|
|
8368
|
-
* import { EntityQueryOptions, DimensionLocation } from
|
|
8364
|
+
* import { EntityQueryOptions, DimensionLocation } from '@minecraft/server';
|
|
8369
8365
|
*
|
|
8370
8366
|
* function tagsQuery(targetLocation: DimensionLocation) {
|
|
8371
|
-
* const mobs = [
|
|
8367
|
+
* const mobs = ['creeper', 'skeleton', 'sheep'];
|
|
8372
8368
|
*
|
|
8373
8369
|
* // create some sample mob data
|
|
8374
8370
|
* for (let i = 0; i < 10; i++) {
|
|
8375
8371
|
* const mobTypeId = mobs[i % mobs.length];
|
|
8376
8372
|
* const entity = targetLocation.dimension.spawnEntity(mobTypeId, targetLocation);
|
|
8377
|
-
* entity.addTag(
|
|
8373
|
+
* entity.addTag('mobparty.' + mobTypeId);
|
|
8378
8374
|
* }
|
|
8379
8375
|
*
|
|
8380
8376
|
* const eqo: EntityQueryOptions = {
|
|
8381
|
-
* tags: [
|
|
8377
|
+
* tags: ['mobparty.skeleton'],
|
|
8382
8378
|
* };
|
|
8383
8379
|
*
|
|
8384
8380
|
* for (const entity of targetLocation.dimension.getEntities(eqo)) {
|
|
@@ -8388,7 +8384,7 @@ export class Dimension {
|
|
|
8388
8384
|
* ```
|
|
8389
8385
|
* @example testThatEntityIsFeatherItem.ts
|
|
8390
8386
|
* ```typescript
|
|
8391
|
-
* import { EntityItemComponent, EntityComponentTypes, DimensionLocation } from
|
|
8387
|
+
* import { EntityItemComponent, EntityComponentTypes, DimensionLocation } from '@minecraft/server';
|
|
8392
8388
|
*
|
|
8393
8389
|
* function testThatEntityIsFeatherItem(
|
|
8394
8390
|
* log: (message: string, status?: number) => void,
|
|
@@ -8403,8 +8399,8 @@ export class Dimension {
|
|
|
8403
8399
|
* const itemComp = item.getComponent(EntityComponentTypes.Item) as EntityItemComponent;
|
|
8404
8400
|
*
|
|
8405
8401
|
* if (itemComp) {
|
|
8406
|
-
* if (itemComp.itemStack.typeId.endsWith(
|
|
8407
|
-
* log(
|
|
8402
|
+
* if (itemComp.itemStack.typeId.endsWith('feather')) {
|
|
8403
|
+
* log('Success! Found a feather', 1);
|
|
8408
8404
|
* }
|
|
8409
8405
|
* }
|
|
8410
8406
|
* }
|
|
@@ -8726,17 +8722,17 @@ export class Dimension {
|
|
|
8726
8722
|
* import { Vector3Utils } from '@minecraft/math';
|
|
8727
8723
|
*
|
|
8728
8724
|
* function spawnAdultHorse(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
8729
|
-
*
|
|
8730
|
-
*
|
|
8731
|
-
*
|
|
8732
|
-
*
|
|
8733
|
-
*
|
|
8725
|
+
* log('Create a horse and triggering the ageable_grow_up event, ensuring the horse is created as an adult');
|
|
8726
|
+
* targetLocation.dimension.spawnEntity(
|
|
8727
|
+
* 'minecraft:horse<minecraft:ageable_grow_up>',
|
|
8728
|
+
* Vector3Utils.add(targetLocation, { x: 0, y: 1, z: 0 })
|
|
8729
|
+
* );
|
|
8734
8730
|
* }
|
|
8735
8731
|
* ```
|
|
8736
8732
|
* @example quickFoxLazyDog.ts
|
|
8737
8733
|
* ```typescript
|
|
8738
|
-
* import { DimensionLocation } from
|
|
8739
|
-
* import { MinecraftEntityTypes, MinecraftEffectTypes } from
|
|
8734
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
8735
|
+
* import { MinecraftEntityTypes, MinecraftEffectTypes } from '@minecraft/vanilla-data';
|
|
8740
8736
|
*
|
|
8741
8737
|
* function quickFoxLazyDog(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
8742
8738
|
* const fox = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Fox, {
|
|
@@ -8748,7 +8744,7 @@ export class Dimension {
|
|
|
8748
8744
|
* fox.addEffect(MinecraftEffectTypes.Speed, 10, {
|
|
8749
8745
|
* amplifier: 2,
|
|
8750
8746
|
* });
|
|
8751
|
-
* log(
|
|
8747
|
+
* log('Created a fox.');
|
|
8752
8748
|
*
|
|
8753
8749
|
* const wolf = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Wolf, {
|
|
8754
8750
|
* x: targetLocation.x + 4,
|
|
@@ -8759,18 +8755,18 @@ export class Dimension {
|
|
|
8759
8755
|
* amplifier: 2,
|
|
8760
8756
|
* });
|
|
8761
8757
|
* wolf.isSneaking = true;
|
|
8762
|
-
* log(
|
|
8758
|
+
* log('Created a sneaking wolf.', 1);
|
|
8763
8759
|
* }
|
|
8764
8760
|
* ```
|
|
8765
8761
|
* @example triggerEvent.ts
|
|
8766
8762
|
* ```typescript
|
|
8767
|
-
* import { DimensionLocation } from
|
|
8768
|
-
* import { MinecraftEntityTypes } from
|
|
8763
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
8764
|
+
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
8769
8765
|
*
|
|
8770
8766
|
* function triggerEvent(targetLocation: DimensionLocation) {
|
|
8771
8767
|
* const creeper = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Creeper, targetLocation);
|
|
8772
8768
|
*
|
|
8773
|
-
* creeper.triggerEvent(
|
|
8769
|
+
* creeper.triggerEvent('minecraft:start_exploding_forced');
|
|
8774
8770
|
* }
|
|
8775
8771
|
* ```
|
|
8776
8772
|
*/
|
|
@@ -8797,8 +8793,8 @@ export class Dimension {
|
|
|
8797
8793
|
* {@link LocationOutOfWorldBoundariesError}
|
|
8798
8794
|
* @example itemStacks.ts
|
|
8799
8795
|
* ```typescript
|
|
8800
|
-
* import { ItemStack, DimensionLocation } from
|
|
8801
|
-
* import { MinecraftItemTypes } from
|
|
8796
|
+
* import { ItemStack, DimensionLocation } from '@minecraft/server';
|
|
8797
|
+
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
|
|
8802
8798
|
*
|
|
8803
8799
|
* function itemStacks(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
8804
8800
|
* const oneItemLoc = { x: targetLocation.x + targetLocation.y + 3, y: 2, z: targetLocation.z + 1 };
|
|
@@ -8821,8 +8817,8 @@ export class Dimension {
|
|
|
8821
8817
|
* ```
|
|
8822
8818
|
* @example spawnFeatherItem.ts
|
|
8823
8819
|
* ```typescript
|
|
8824
|
-
* import { ItemStack, DimensionLocation } from
|
|
8825
|
-
* import { MinecraftItemTypes } from
|
|
8820
|
+
* import { ItemStack, DimensionLocation } from '@minecraft/server';
|
|
8821
|
+
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
|
|
8826
8822
|
*
|
|
8827
8823
|
* function spawnFeatherItem(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
8828
8824
|
* const featherItem = new ItemStack(MinecraftItemTypes.Feather, 1);
|
|
@@ -8854,20 +8850,20 @@ export class Dimension {
|
|
|
8854
8850
|
* {@link LocationOutOfWorldBoundariesError}
|
|
8855
8851
|
* @example spawnParticle.ts
|
|
8856
8852
|
* ```typescript
|
|
8857
|
-
* import { MolangVariableMap, DimensionLocation } from
|
|
8853
|
+
* import { MolangVariableMap, DimensionLocation } from '@minecraft/server';
|
|
8858
8854
|
*
|
|
8859
8855
|
* function spawnParticle(targetLocation: DimensionLocation) {
|
|
8860
8856
|
* for (let i = 0; i < 100; i++) {
|
|
8861
8857
|
* const molang = new MolangVariableMap();
|
|
8862
8858
|
*
|
|
8863
|
-
* molang.setColorRGB(
|
|
8859
|
+
* molang.setColorRGB('variable.color', { red: Math.random(), green: Math.random(), blue: Math.random() });
|
|
8864
8860
|
*
|
|
8865
8861
|
* const newLocation = {
|
|
8866
8862
|
* x: targetLocation.x + Math.floor(Math.random() * 8) - 4,
|
|
8867
8863
|
* y: targetLocation.y + Math.floor(Math.random() * 8) - 4,
|
|
8868
8864
|
* z: targetLocation.z + Math.floor(Math.random() * 8) - 4,
|
|
8869
8865
|
* };
|
|
8870
|
-
* targetLocation.dimension.spawnParticle(
|
|
8866
|
+
* targetLocation.dimension.spawnParticle('minecraft:colored_flame_particle', newLocation, molang);
|
|
8871
8867
|
* }
|
|
8872
8868
|
* }
|
|
8873
8869
|
* ```
|
|
@@ -9467,13 +9463,11 @@ export class Entity {
|
|
|
9467
9463
|
* {@link InvalidEntityError}
|
|
9468
9464
|
* @example spawnPoisonedVillager.ts
|
|
9469
9465
|
* ```typescript
|
|
9470
|
-
* import { DimensionLocation } from
|
|
9471
|
-
* import { MinecraftEffectTypes } from
|
|
9466
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
9467
|
+
* import { MinecraftEffectTypes } from '@minecraft/vanilla-data';
|
|
9472
9468
|
*
|
|
9473
|
-
* function spawnPoisonedVillager(
|
|
9474
|
-
*
|
|
9475
|
-
* ) {
|
|
9476
|
-
* const villagerType = "minecraft:villager_v2<minecraft:ageable_grow_up>";
|
|
9469
|
+
* function spawnPoisonedVillager(targetLocation: DimensionLocation) {
|
|
9470
|
+
* const villagerType = 'minecraft:villager_v2<minecraft:ageable_grow_up>';
|
|
9477
9471
|
* const villager = targetLocation.dimension.spawnEntity(villagerType, targetLocation);
|
|
9478
9472
|
* const duration = 20;
|
|
9479
9473
|
*
|
|
@@ -9482,8 +9476,8 @@ export class Entity {
|
|
|
9482
9476
|
* ```
|
|
9483
9477
|
* @example quickFoxLazyDog.ts
|
|
9484
9478
|
* ```typescript
|
|
9485
|
-
* import { DimensionLocation } from
|
|
9486
|
-
* import { MinecraftEntityTypes, MinecraftEffectTypes } from
|
|
9479
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
9480
|
+
* import { MinecraftEntityTypes, MinecraftEffectTypes } from '@minecraft/vanilla-data';
|
|
9487
9481
|
*
|
|
9488
9482
|
* function quickFoxLazyDog(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
9489
9483
|
* const fox = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Fox, {
|
|
@@ -9495,7 +9489,7 @@ export class Entity {
|
|
|
9495
9489
|
* fox.addEffect(MinecraftEffectTypes.Speed, 10, {
|
|
9496
9490
|
* amplifier: 2,
|
|
9497
9491
|
* });
|
|
9498
|
-
* log(
|
|
9492
|
+
* log('Created a fox.');
|
|
9499
9493
|
*
|
|
9500
9494
|
* const wolf = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Wolf, {
|
|
9501
9495
|
* x: targetLocation.x + 4,
|
|
@@ -9506,7 +9500,7 @@ export class Entity {
|
|
|
9506
9500
|
* amplifier: 2,
|
|
9507
9501
|
* });
|
|
9508
9502
|
* wolf.isSneaking = true;
|
|
9509
|
-
* log(
|
|
9503
|
+
* log('Created a sneaking wolf.', 1);
|
|
9510
9504
|
* }
|
|
9511
9505
|
* ```
|
|
9512
9506
|
*/
|
|
@@ -9551,20 +9545,20 @@ export class Entity {
|
|
|
9551
9545
|
* {@link InvalidEntityError}
|
|
9552
9546
|
* @example tagsQuery.ts
|
|
9553
9547
|
* ```typescript
|
|
9554
|
-
* import { EntityQueryOptions, DimensionLocation } from
|
|
9548
|
+
* import { EntityQueryOptions, DimensionLocation } from '@minecraft/server';
|
|
9555
9549
|
*
|
|
9556
9550
|
* function tagsQuery(targetLocation: DimensionLocation) {
|
|
9557
|
-
* const mobs = [
|
|
9551
|
+
* const mobs = ['creeper', 'skeleton', 'sheep'];
|
|
9558
9552
|
*
|
|
9559
9553
|
* // create some sample mob data
|
|
9560
9554
|
* for (let i = 0; i < 10; i++) {
|
|
9561
9555
|
* const mobTypeId = mobs[i % mobs.length];
|
|
9562
9556
|
* const entity = targetLocation.dimension.spawnEntity(mobTypeId, targetLocation);
|
|
9563
|
-
* entity.addTag(
|
|
9557
|
+
* entity.addTag('mobparty.' + mobTypeId);
|
|
9564
9558
|
* }
|
|
9565
9559
|
*
|
|
9566
9560
|
* const eqo: EntityQueryOptions = {
|
|
9567
|
-
* tags: [
|
|
9561
|
+
* tags: ['mobparty.skeleton'],
|
|
9568
9562
|
* };
|
|
9569
9563
|
*
|
|
9570
9564
|
* for (const entity of targetLocation.dimension.getEntities(eqo)) {
|
|
@@ -9599,22 +9593,19 @@ export class Entity {
|
|
|
9599
9593
|
* {@link minecraftcommon.UnsupportedFunctionalityError}
|
|
9600
9594
|
* @example applyDamageThenHeal.ts
|
|
9601
9595
|
* ```typescript
|
|
9602
|
-
* import { system, EntityHealthComponent, EntityComponentTypes, DimensionLocation } from
|
|
9603
|
-
* import { MinecraftEntityTypes } from
|
|
9596
|
+
* import { system, EntityHealthComponent, EntityComponentTypes, DimensionLocation } from '@minecraft/server';
|
|
9597
|
+
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
9604
9598
|
*
|
|
9605
|
-
* function applyDamageThenHeal(
|
|
9606
|
-
* log: (message: string, status?: number) => void,
|
|
9607
|
-
* targetLocation: DimensionLocation
|
|
9608
|
-
* ) {
|
|
9599
|
+
* function applyDamageThenHeal(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
9609
9600
|
* const skelly = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Skeleton, targetLocation);
|
|
9610
9601
|
*
|
|
9611
9602
|
* skelly.applyDamage(19); // skeletons have max damage of 20 so this is a near-death skeleton
|
|
9612
9603
|
*
|
|
9613
9604
|
* system.runTimeout(() => {
|
|
9614
9605
|
* const health = skelly.getComponent(EntityComponentTypes.Health) as EntityHealthComponent;
|
|
9615
|
-
* log(
|
|
9606
|
+
* log('Skeleton health before heal: ' + health?.currentValue);
|
|
9616
9607
|
* health?.resetToMaxValue();
|
|
9617
|
-
* log(
|
|
9608
|
+
* log('Skeleton health after heal: ' + health?.currentValue);
|
|
9618
9609
|
* }, 20);
|
|
9619
9610
|
* }
|
|
9620
9611
|
* ```
|
|
@@ -9636,8 +9627,8 @@ export class Entity {
|
|
|
9636
9627
|
* {@link InvalidEntityError}
|
|
9637
9628
|
* @example applyImpulse.ts
|
|
9638
9629
|
* ```typescript
|
|
9639
|
-
* import { DimensionLocation } from
|
|
9640
|
-
* import { MinecraftEntityTypes } from
|
|
9630
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
9631
|
+
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
9641
9632
|
*
|
|
9642
9633
|
* function applyImpulse(targetLocation: DimensionLocation) {
|
|
9643
9634
|
* const zombie = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Zombie, targetLocation);
|
|
@@ -9666,10 +9657,10 @@ export class Entity {
|
|
|
9666
9657
|
* {@link minecraftcommon.UnsupportedFunctionalityError}
|
|
9667
9658
|
* @example bounceSkeletons.ts
|
|
9668
9659
|
* ```typescript
|
|
9669
|
-
* import { EntityQueryOptions, DimensionLocation } from
|
|
9660
|
+
* import { EntityQueryOptions, DimensionLocation } from '@minecraft/server';
|
|
9670
9661
|
*
|
|
9671
9662
|
* function bounceSkeletons(targetLocation: DimensionLocation) {
|
|
9672
|
-
* const mobs = [
|
|
9663
|
+
* const mobs = ['creeper', 'skeleton', 'sheep'];
|
|
9673
9664
|
*
|
|
9674
9665
|
* // create some sample mob data
|
|
9675
9666
|
* for (let i = 0; i < 10; i++) {
|
|
@@ -9677,7 +9668,7 @@ export class Entity {
|
|
|
9677
9668
|
* }
|
|
9678
9669
|
*
|
|
9679
9670
|
* const eqo: EntityQueryOptions = {
|
|
9680
|
-
* type:
|
|
9671
|
+
* type: 'skeleton',
|
|
9681
9672
|
* };
|
|
9682
9673
|
*
|
|
9683
9674
|
* for (const entity of targetLocation.dimension.getEntities(eqo)) {
|
|
@@ -9708,8 +9699,8 @@ export class Entity {
|
|
|
9708
9699
|
* {@link InvalidEntityError}
|
|
9709
9700
|
* @example applyImpulse.ts
|
|
9710
9701
|
* ```typescript
|
|
9711
|
-
* import { DimensionLocation } from
|
|
9712
|
-
* import { MinecraftEntityTypes } from
|
|
9702
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
9703
|
+
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
9713
9704
|
*
|
|
9714
9705
|
* function applyImpulse(targetLocation: DimensionLocation) {
|
|
9715
9706
|
* const zombie = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Zombie, targetLocation);
|
|
@@ -9741,8 +9732,8 @@ export class Entity {
|
|
|
9741
9732
|
* {@link InvalidEntityError}
|
|
9742
9733
|
* @example setOnFire.ts
|
|
9743
9734
|
* ```typescript
|
|
9744
|
-
* import { system, EntityOnFireComponent, EntityComponentTypes, DimensionLocation } from
|
|
9745
|
-
* import { MinecraftEntityTypes } from
|
|
9735
|
+
* import { system, EntityOnFireComponent, EntityComponentTypes, DimensionLocation } from '@minecraft/server';
|
|
9736
|
+
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
9746
9737
|
*
|
|
9747
9738
|
* function setOnFire(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
9748
9739
|
* const skelly = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Skeleton, targetLocation);
|
|
@@ -9751,10 +9742,10 @@ export class Entity {
|
|
|
9751
9742
|
*
|
|
9752
9743
|
* system.runTimeout(() => {
|
|
9753
9744
|
* const onfire = skelly.getComponent(EntityComponentTypes.OnFire) as EntityOnFireComponent;
|
|
9754
|
-
* log(onfire?.onFireTicksRemaining +
|
|
9745
|
+
* log(onfire?.onFireTicksRemaining + ' fire ticks remaining.');
|
|
9755
9746
|
*
|
|
9756
9747
|
* skelly.extinguishFire(true);
|
|
9757
|
-
* log(
|
|
9748
|
+
* log('Never mind. Fire extinguished.');
|
|
9758
9749
|
* }, 20);
|
|
9759
9750
|
* }
|
|
9760
9751
|
* ```
|
|
@@ -10004,19 +9995,16 @@ export class Entity {
|
|
|
10004
9995
|
* {@link InvalidEntityError}
|
|
10005
9996
|
* @example getFireworkVelocity.ts
|
|
10006
9997
|
* ```typescript
|
|
10007
|
-
* import { system, DimensionLocation } from
|
|
10008
|
-
* import { MinecraftEntityTypes } from
|
|
9998
|
+
* import { system, DimensionLocation } from '@minecraft/server';
|
|
9999
|
+
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
10009
10000
|
*
|
|
10010
|
-
* function getFireworkVelocity(
|
|
10011
|
-
* log: (message: string, status?: number) => void,
|
|
10012
|
-
* targetLocation: DimensionLocation
|
|
10013
|
-
* ) {
|
|
10001
|
+
* function getFireworkVelocity(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
10014
10002
|
* const fireworkRocket = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.FireworksRocket, targetLocation);
|
|
10015
10003
|
*
|
|
10016
10004
|
* system.runTimeout(() => {
|
|
10017
10005
|
* const velocity = fireworkRocket.getVelocity();
|
|
10018
10006
|
*
|
|
10019
|
-
* log(
|
|
10007
|
+
* log('Velocity of firework is: (x: ' + velocity.x + ', y:' + velocity.y + ', z:' + velocity.z + ')');
|
|
10020
10008
|
* }, 5);
|
|
10021
10009
|
* }
|
|
10022
10010
|
* ```
|
|
@@ -10077,20 +10065,20 @@ export class Entity {
|
|
|
10077
10065
|
* {@link InvalidEntityError}
|
|
10078
10066
|
* @example tagsQuery.ts
|
|
10079
10067
|
* ```typescript
|
|
10080
|
-
* import { EntityQueryOptions, DimensionLocation } from
|
|
10068
|
+
* import { EntityQueryOptions, DimensionLocation } from '@minecraft/server';
|
|
10081
10069
|
*
|
|
10082
10070
|
* function tagsQuery(targetLocation: DimensionLocation) {
|
|
10083
|
-
* const mobs = [
|
|
10071
|
+
* const mobs = ['creeper', 'skeleton', 'sheep'];
|
|
10084
10072
|
*
|
|
10085
10073
|
* // create some sample mob data
|
|
10086
10074
|
* for (let i = 0; i < 10; i++) {
|
|
10087
10075
|
* const mobTypeId = mobs[i % mobs.length];
|
|
10088
10076
|
* const entity = targetLocation.dimension.spawnEntity(mobTypeId, targetLocation);
|
|
10089
|
-
* entity.addTag(
|
|
10077
|
+
* entity.addTag('mobparty.' + mobTypeId);
|
|
10090
10078
|
* }
|
|
10091
10079
|
*
|
|
10092
10080
|
* const eqo: EntityQueryOptions = {
|
|
10093
|
-
* tags: [
|
|
10081
|
+
* tags: ['mobparty.skeleton'],
|
|
10094
10082
|
* };
|
|
10095
10083
|
*
|
|
10096
10084
|
* for (const entity of targetLocation.dimension.getEntities(eqo)) {
|
|
@@ -10304,8 +10292,8 @@ export class Entity {
|
|
|
10304
10292
|
* {@link InvalidEntityError}
|
|
10305
10293
|
* @example setOnFire.ts
|
|
10306
10294
|
* ```typescript
|
|
10307
|
-
* import { system, EntityOnFireComponent, EntityComponentTypes, DimensionLocation } from
|
|
10308
|
-
* import { MinecraftEntityTypes } from
|
|
10295
|
+
* import { system, EntityOnFireComponent, EntityComponentTypes, DimensionLocation } from '@minecraft/server';
|
|
10296
|
+
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
10309
10297
|
*
|
|
10310
10298
|
* function setOnFire(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
10311
10299
|
* const skelly = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Skeleton, targetLocation);
|
|
@@ -10314,10 +10302,10 @@ export class Entity {
|
|
|
10314
10302
|
*
|
|
10315
10303
|
* system.runTimeout(() => {
|
|
10316
10304
|
* const onfire = skelly.getComponent(EntityComponentTypes.OnFire) as EntityOnFireComponent;
|
|
10317
|
-
* log(onfire?.onFireTicksRemaining +
|
|
10305
|
+
* log(onfire?.onFireTicksRemaining + ' fire ticks remaining.');
|
|
10318
10306
|
*
|
|
10319
10307
|
* skelly.extinguishFire(true);
|
|
10320
|
-
* log(
|
|
10308
|
+
* log('Never mind. Fire extinguished.');
|
|
10321
10309
|
* }, 20);
|
|
10322
10310
|
* }
|
|
10323
10311
|
* ```
|
|
@@ -10384,8 +10372,8 @@ export class Entity {
|
|
|
10384
10372
|
* {@link minecraftcommon.UnsupportedFunctionalityError}
|
|
10385
10373
|
* @example teleport.ts
|
|
10386
10374
|
* ```typescript
|
|
10387
|
-
* import { system, DimensionLocation } from
|
|
10388
|
-
* import { MinecraftEntityTypes } from
|
|
10375
|
+
* import { system, DimensionLocation } from '@minecraft/server';
|
|
10376
|
+
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
10389
10377
|
*
|
|
10390
10378
|
* function teleport(targetLocation: DimensionLocation) {
|
|
10391
10379
|
* const cow = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Cow, targetLocation);
|
|
@@ -10402,8 +10390,8 @@ export class Entity {
|
|
|
10402
10390
|
* ```
|
|
10403
10391
|
* @example teleportMovement.ts
|
|
10404
10392
|
* ```typescript
|
|
10405
|
-
* import { system, DimensionLocation } from
|
|
10406
|
-
* import { MinecraftEntityTypes } from
|
|
10393
|
+
* import { system, DimensionLocation } from '@minecraft/server';
|
|
10394
|
+
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
10407
10395
|
*
|
|
10408
10396
|
* function teleportMovement(targetLocation: DimensionLocation) {
|
|
10409
10397
|
* const pig = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Pig, targetLocation);
|
|
@@ -10452,20 +10440,20 @@ export class Entity {
|
|
|
10452
10440
|
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
10453
10441
|
*
|
|
10454
10442
|
* function spawnExplodingCreeper(location: DimensionLocation) {
|
|
10455
|
-
*
|
|
10443
|
+
* const creeper = location.dimension.spawnEntity(MinecraftEntityTypes.Creeper, location);
|
|
10456
10444
|
*
|
|
10457
|
-
*
|
|
10445
|
+
* creeper.triggerEvent('minecraft:start_exploding_forced');
|
|
10458
10446
|
* }
|
|
10459
10447
|
* ```
|
|
10460
10448
|
* @example triggerEvent.ts
|
|
10461
10449
|
* ```typescript
|
|
10462
|
-
* import { DimensionLocation } from
|
|
10463
|
-
* import { MinecraftEntityTypes } from
|
|
10450
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
10451
|
+
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
10464
10452
|
*
|
|
10465
10453
|
* function triggerEvent(targetLocation: DimensionLocation) {
|
|
10466
10454
|
* const creeper = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Creeper, targetLocation);
|
|
10467
10455
|
*
|
|
10468
|
-
* creeper.triggerEvent(
|
|
10456
|
+
* creeper.triggerEvent('minecraft:start_exploding_forced');
|
|
10469
10457
|
* }
|
|
10470
10458
|
* ```
|
|
10471
10459
|
*/
|
|
@@ -10982,7 +10970,6 @@ export class EntityDefinitionFeedItem {
|
|
|
10982
10970
|
*/
|
|
10983
10971
|
readonly item: string;
|
|
10984
10972
|
/**
|
|
10985
|
-
* @rc
|
|
10986
10973
|
* @remarks
|
|
10987
10974
|
* Type ID of the resulting item after feeding has occurred.
|
|
10988
10975
|
* This will usually be empty but is used for scenarios such as
|
|
@@ -11086,10 +11073,10 @@ export class EntityEnderInventoryComponent extends EntityComponent {
|
|
|
11086
11073
|
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
|
|
11087
11074
|
*
|
|
11088
11075
|
* function giveEquipment(player: Player) {
|
|
11089
|
-
*
|
|
11090
|
-
*
|
|
11091
|
-
*
|
|
11092
|
-
*
|
|
11076
|
+
* const equipmentCompPlayer = player.getComponent(EntityComponentTypes.Equippable);
|
|
11077
|
+
* if (equipmentCompPlayer) {
|
|
11078
|
+
* equipmentCompPlayer.setEquipment(EquipmentSlot.Chest, new ItemStack(MinecraftItemTypes.Elytra));
|
|
11079
|
+
* }
|
|
11093
11080
|
* }
|
|
11094
11081
|
* ```
|
|
11095
11082
|
*/
|
|
@@ -11278,7 +11265,6 @@ export class EntityHealableComponent extends EntityComponent {
|
|
|
11278
11265
|
}
|
|
11279
11266
|
|
|
11280
11267
|
/**
|
|
11281
|
-
* @rc
|
|
11282
11268
|
* Contains information related to an entity having been
|
|
11283
11269
|
* healed.
|
|
11284
11270
|
*/
|
|
@@ -11305,7 +11291,6 @@ export class EntityHealAfterEvent {
|
|
|
11305
11291
|
}
|
|
11306
11292
|
|
|
11307
11293
|
/**
|
|
11308
|
-
* @rc
|
|
11309
11294
|
* Manages callbacks that are connected to when an entity is
|
|
11310
11295
|
* healed.
|
|
11311
11296
|
*/
|
|
@@ -11339,7 +11324,6 @@ export class EntityHealAfterEventSignal {
|
|
|
11339
11324
|
}
|
|
11340
11325
|
|
|
11341
11326
|
/**
|
|
11342
|
-
* @rc
|
|
11343
11327
|
* Contains information related to an entity that will be
|
|
11344
11328
|
* healed.
|
|
11345
11329
|
*/
|
|
@@ -11367,7 +11351,6 @@ export class EntityHealBeforeEvent {
|
|
|
11367
11351
|
}
|
|
11368
11352
|
|
|
11369
11353
|
/**
|
|
11370
|
-
* @rc
|
|
11371
11354
|
* Manages callbacks that are connected to when an entity will
|
|
11372
11355
|
* be healed.
|
|
11373
11356
|
*/
|
|
@@ -11407,7 +11390,6 @@ export class EntityHealBeforeEventSignal {
|
|
|
11407
11390
|
}
|
|
11408
11391
|
|
|
11409
11392
|
/**
|
|
11410
|
-
* @rc
|
|
11411
11393
|
* Provides information about how healing has been applied to
|
|
11412
11394
|
* an entity.
|
|
11413
11395
|
*/
|
|
@@ -11485,22 +11467,19 @@ export class EntityHealthChangedAfterEventSignal {
|
|
|
11485
11467
|
* Defines the health properties of an entity.
|
|
11486
11468
|
* @example applyDamageThenHeal.ts
|
|
11487
11469
|
* ```typescript
|
|
11488
|
-
* import { system, EntityHealthComponent, EntityComponentTypes, DimensionLocation } from
|
|
11489
|
-
* import { MinecraftEntityTypes } from
|
|
11470
|
+
* import { system, EntityHealthComponent, EntityComponentTypes, DimensionLocation } from '@minecraft/server';
|
|
11471
|
+
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
11490
11472
|
*
|
|
11491
|
-
* function applyDamageThenHeal(
|
|
11492
|
-
* log: (message: string, status?: number) => void,
|
|
11493
|
-
* targetLocation: DimensionLocation
|
|
11494
|
-
* ) {
|
|
11473
|
+
* function applyDamageThenHeal(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
11495
11474
|
* const skelly = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Skeleton, targetLocation);
|
|
11496
11475
|
*
|
|
11497
11476
|
* skelly.applyDamage(19); // skeletons have max damage of 20 so this is a near-death skeleton
|
|
11498
11477
|
*
|
|
11499
11478
|
* system.runTimeout(() => {
|
|
11500
11479
|
* const health = skelly.getComponent(EntityComponentTypes.Health) as EntityHealthComponent;
|
|
11501
|
-
* log(
|
|
11480
|
+
* log('Skeleton health before heal: ' + health?.currentValue);
|
|
11502
11481
|
* health?.resetToMaxValue();
|
|
11503
|
-
* log(
|
|
11482
|
+
* log('Skeleton health after heal: ' + health?.currentValue);
|
|
11504
11483
|
* }, 20);
|
|
11505
11484
|
* }
|
|
11506
11485
|
* ```
|
|
@@ -11665,7 +11644,6 @@ export class EntityHurtAfterEvent {
|
|
|
11665
11644
|
}
|
|
11666
11645
|
|
|
11667
11646
|
/**
|
|
11668
|
-
* @rc
|
|
11669
11647
|
* Manages callbacks that are connected to when an entity is
|
|
11670
11648
|
* hurt.
|
|
11671
11649
|
*/
|
|
@@ -11697,7 +11675,6 @@ export class EntityHurtAfterEventSignal {
|
|
|
11697
11675
|
}
|
|
11698
11676
|
|
|
11699
11677
|
/**
|
|
11700
|
-
* @rc
|
|
11701
11678
|
* Contains information related to an entity that will be hurt.
|
|
11702
11679
|
*/
|
|
11703
11680
|
export class EntityHurtBeforeEvent {
|
|
@@ -11725,7 +11702,6 @@ export class EntityHurtBeforeEvent {
|
|
|
11725
11702
|
}
|
|
11726
11703
|
|
|
11727
11704
|
/**
|
|
11728
|
-
* @rc
|
|
11729
11705
|
* Manages callbacks that are connected to when an entity will
|
|
11730
11706
|
* be hurt.
|
|
11731
11707
|
*/
|
|
@@ -11965,7 +11941,7 @@ export class EntityIsTamedComponent extends EntityComponent {
|
|
|
11965
11941
|
* property.
|
|
11966
11942
|
* @example testThatEntityIsFeatherItem.ts
|
|
11967
11943
|
* ```typescript
|
|
11968
|
-
* import { EntityItemComponent, EntityComponentTypes, DimensionLocation } from
|
|
11944
|
+
* import { EntityItemComponent, EntityComponentTypes, DimensionLocation } from '@minecraft/server';
|
|
11969
11945
|
*
|
|
11970
11946
|
* function testThatEntityIsFeatherItem(
|
|
11971
11947
|
* log: (message: string, status?: number) => void,
|
|
@@ -11980,8 +11956,8 @@ export class EntityIsTamedComponent extends EntityComponent {
|
|
|
11980
11956
|
* const itemComp = item.getComponent(EntityComponentTypes.Item) as EntityItemComponent;
|
|
11981
11957
|
*
|
|
11982
11958
|
* if (itemComp) {
|
|
11983
|
-
* if (itemComp.itemStack.typeId.endsWith(
|
|
11984
|
-
* log(
|
|
11959
|
+
* if (itemComp.itemStack.typeId.endsWith('feather')) {
|
|
11960
|
+
* log('Success! Found a feather', 1);
|
|
11985
11961
|
* }
|
|
11986
11962
|
* }
|
|
11987
11963
|
* }
|
|
@@ -12002,7 +11978,6 @@ export class EntityItemComponent extends EntityComponent {
|
|
|
12002
11978
|
}
|
|
12003
11979
|
|
|
12004
11980
|
/**
|
|
12005
|
-
* @rc
|
|
12006
11981
|
* Contains information related to an entity having dropped
|
|
12007
11982
|
* items.
|
|
12008
11983
|
*/
|
|
@@ -12023,7 +11998,6 @@ export class EntityItemDropAfterEvent {
|
|
|
12023
11998
|
}
|
|
12024
11999
|
|
|
12025
12000
|
/**
|
|
12026
|
-
* @rc
|
|
12027
12001
|
* Manages callbacks that are connected to when an entity has
|
|
12028
12002
|
* dropped items.
|
|
12029
12003
|
*/
|
|
@@ -12057,7 +12031,6 @@ export class EntityItemDropAfterEventSignal {
|
|
|
12057
12031
|
}
|
|
12058
12032
|
|
|
12059
12033
|
/**
|
|
12060
|
-
* @rc
|
|
12061
12034
|
* Contains information related to an entity having picked up
|
|
12062
12035
|
* items.
|
|
12063
12036
|
*/
|
|
@@ -12078,7 +12051,6 @@ export class EntityItemPickupAfterEvent {
|
|
|
12078
12051
|
}
|
|
12079
12052
|
|
|
12080
12053
|
/**
|
|
12081
|
-
* @rc
|
|
12082
12054
|
* Manages callbacks that are connected to when an entity has
|
|
12083
12055
|
* picked up items.
|
|
12084
12056
|
*/
|
|
@@ -12112,7 +12084,6 @@ export class EntityItemPickupAfterEventSignal {
|
|
|
12112
12084
|
}
|
|
12113
12085
|
|
|
12114
12086
|
/**
|
|
12115
|
-
* @rc
|
|
12116
12087
|
* Contains information related to an entity picking up an
|
|
12117
12088
|
* item.
|
|
12118
12089
|
*/
|
|
@@ -12139,7 +12110,6 @@ export class EntityItemPickupBeforeEvent {
|
|
|
12139
12110
|
}
|
|
12140
12111
|
|
|
12141
12112
|
/**
|
|
12142
|
-
* @rc
|
|
12143
12113
|
* Manages callbacks that are connected to when an entity will
|
|
12144
12114
|
* pick up an item.
|
|
12145
12115
|
*/
|
|
@@ -12739,8 +12709,8 @@ export class EntityNpcComponent extends EntityComponent {
|
|
|
12739
12709
|
* When present on an entity, this entity is on fire.
|
|
12740
12710
|
* @example setOnFire.ts
|
|
12741
12711
|
* ```typescript
|
|
12742
|
-
* import { system, EntityOnFireComponent, EntityComponentTypes, DimensionLocation } from
|
|
12743
|
-
* import { MinecraftEntityTypes } from
|
|
12712
|
+
* import { system, EntityOnFireComponent, EntityComponentTypes, DimensionLocation } from '@minecraft/server';
|
|
12713
|
+
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
12744
12714
|
*
|
|
12745
12715
|
* function setOnFire(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
12746
12716
|
* const skelly = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Skeleton, targetLocation);
|
|
@@ -12749,10 +12719,10 @@ export class EntityNpcComponent extends EntityComponent {
|
|
|
12749
12719
|
*
|
|
12750
12720
|
* system.runTimeout(() => {
|
|
12751
12721
|
* const onfire = skelly.getComponent(EntityComponentTypes.OnFire) as EntityOnFireComponent;
|
|
12752
|
-
* log(onfire?.onFireTicksRemaining +
|
|
12722
|
+
* log(onfire?.onFireTicksRemaining + ' fire ticks remaining.');
|
|
12753
12723
|
*
|
|
12754
12724
|
* skelly.extinguishFire(true);
|
|
12755
|
-
* log(
|
|
12725
|
+
* log('Never mind. Fire extinguished.');
|
|
12756
12726
|
* }, 20);
|
|
12757
12727
|
* }
|
|
12758
12728
|
* ```
|
|
@@ -12777,18 +12747,18 @@ export class EntityOnFireComponent extends EntityComponent {
|
|
|
12777
12747
|
* minecraft:projectile component.
|
|
12778
12748
|
* @example shootArrow.ts
|
|
12779
12749
|
* ```typescript
|
|
12780
|
-
* import { DimensionLocation, EntityProjectileComponent } from
|
|
12750
|
+
* import { DimensionLocation, EntityProjectileComponent } from '@minecraft/server';
|
|
12781
12751
|
*
|
|
12782
12752
|
* function shootArrow(targetLocation: DimensionLocation) {
|
|
12783
12753
|
* const velocity = { x: 0, y: 1, z: 5 };
|
|
12784
12754
|
*
|
|
12785
|
-
* const arrow = targetLocation.dimension.spawnEntity(
|
|
12755
|
+
* const arrow = targetLocation.dimension.spawnEntity('minecraft:arrow', {
|
|
12786
12756
|
* x: targetLocation.x,
|
|
12787
12757
|
* y: targetLocation.y + 2,
|
|
12788
12758
|
* z: targetLocation.z,
|
|
12789
12759
|
* });
|
|
12790
12760
|
*
|
|
12791
|
-
* const projectileComp = arrow.getComponent(
|
|
12761
|
+
* const projectileComp = arrow.getComponent('minecraft:projectile') as EntityProjectileComponent;
|
|
12792
12762
|
*
|
|
12793
12763
|
* projectileComp?.shoot(velocity);
|
|
12794
12764
|
* }
|
|
@@ -13087,9 +13057,9 @@ export class EntityRemoveBeforeEventSignal {
|
|
|
13087
13057
|
* entity can be ridden by another entity.
|
|
13088
13058
|
* @example minibiomes.ts
|
|
13089
13059
|
* ```typescript
|
|
13090
|
-
* import { EntityComponentTypes } from
|
|
13091
|
-
* import { Test, register } from
|
|
13092
|
-
* import { MinecraftBlockTypes, MinecraftEntityTypes } from
|
|
13060
|
+
* import { EntityComponentTypes } from '@minecraft/server';
|
|
13061
|
+
* import { Test, register } from '@minecraft/server-gametest';
|
|
13062
|
+
* import { MinecraftBlockTypes, MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
13093
13063
|
*
|
|
13094
13064
|
* function minibiomes(test: Test) {
|
|
13095
13065
|
* const minecart = test.spawn(MinecraftEntityTypes.Minecart, { x: 9, y: 7, z: 7 });
|
|
@@ -13103,7 +13073,7 @@ export class EntityRemoveBeforeEventSignal {
|
|
|
13103
13073
|
*
|
|
13104
13074
|
* test.succeedWhenEntityPresent(MinecraftEntityTypes.Pig, { x: 8, y: 3, z: 1 }, true);
|
|
13105
13075
|
* }
|
|
13106
|
-
* register(
|
|
13076
|
+
* register('ChallengeTests', 'minibiomes', minibiomes).structureName('gametests:minibiomes').maxTicks(160);
|
|
13107
13077
|
* ```
|
|
13108
13078
|
*/
|
|
13109
13079
|
// @ts-ignore Class inheritance allowed for native defined classes
|
|
@@ -13178,9 +13148,9 @@ export class EntityRideableComponent extends EntityComponent {
|
|
|
13178
13148
|
* @throws This function can throw errors.
|
|
13179
13149
|
* @example minibiomes.ts
|
|
13180
13150
|
* ```typescript
|
|
13181
|
-
* import { EntityComponentTypes } from
|
|
13182
|
-
* import { Test, register } from
|
|
13183
|
-
* import { MinecraftBlockTypes, MinecraftEntityTypes } from
|
|
13151
|
+
* import { EntityComponentTypes } from '@minecraft/server';
|
|
13152
|
+
* import { Test, register } from '@minecraft/server-gametest';
|
|
13153
|
+
* import { MinecraftBlockTypes, MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
13184
13154
|
*
|
|
13185
13155
|
* function minibiomes(test: Test) {
|
|
13186
13156
|
* const minecart = test.spawn(MinecraftEntityTypes.Minecart, { x: 9, y: 7, z: 7 });
|
|
@@ -13194,7 +13164,7 @@ export class EntityRideableComponent extends EntityComponent {
|
|
|
13194
13164
|
*
|
|
13195
13165
|
* test.succeedWhenEntityPresent(MinecraftEntityTypes.Pig, { x: 8, y: 3, z: 1 }, true);
|
|
13196
13166
|
* }
|
|
13197
|
-
* register(
|
|
13167
|
+
* register('ChallengeTests', 'minibiomes', minibiomes).structureName('gametests:minibiomes').maxTicks(160);
|
|
13198
13168
|
* ```
|
|
13199
13169
|
*/
|
|
13200
13170
|
addRider(rider: Entity): boolean;
|
|
@@ -13309,13 +13279,10 @@ export class EntitySkinIdComponent extends EntityComponent {
|
|
|
13309
13279
|
* world.
|
|
13310
13280
|
* @example logEntitySpawnEvent.ts
|
|
13311
13281
|
* ```typescript
|
|
13312
|
-
* import { world, system, EntitySpawnAfterEvent, DimensionLocation } from
|
|
13313
|
-
* import { Vector3Utils } from
|
|
13282
|
+
* import { world, system, EntitySpawnAfterEvent, DimensionLocation } from '@minecraft/server';
|
|
13283
|
+
* import { Vector3Utils } from '@minecraft/math';
|
|
13314
13284
|
*
|
|
13315
|
-
* function logEntitySpawnEvent(
|
|
13316
|
-
* log: (message: string, status?: number) => void,
|
|
13317
|
-
* targetLocation: DimensionLocation
|
|
13318
|
-
* ) {
|
|
13285
|
+
* function logEntitySpawnEvent(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
13319
13286
|
* // register a new function that is called when a new entity is created.
|
|
13320
13287
|
* world.afterEvents.entitySpawn.subscribe((entityEvent: EntitySpawnAfterEvent) => {
|
|
13321
13288
|
* if (entityEvent && entityEvent.entity) {
|
|
@@ -13327,7 +13294,7 @@ export class EntitySkinIdComponent extends EntityComponent {
|
|
|
13327
13294
|
*
|
|
13328
13295
|
* system.runTimeout(() => {
|
|
13329
13296
|
* targetLocation.dimension.spawnEntity(
|
|
13330
|
-
*
|
|
13297
|
+
* 'minecraft:horse<minecraft:ageable_grow_up>',
|
|
13331
13298
|
* Vector3Utils.add(targetLocation, { x: 0, y: 1, z: 0 })
|
|
13332
13299
|
* );
|
|
13333
13300
|
* }, 20);
|
|
@@ -13371,13 +13338,10 @@ export class EntitySpawnAfterEventSignal {
|
|
|
13371
13338
|
* Function that handles the spawn event.
|
|
13372
13339
|
* @example logEntitySpawnEvent.ts
|
|
13373
13340
|
* ```typescript
|
|
13374
|
-
* import { world, system, EntitySpawnAfterEvent, DimensionLocation } from
|
|
13375
|
-
* import { Vector3Utils } from
|
|
13341
|
+
* import { world, system, EntitySpawnAfterEvent, DimensionLocation } from '@minecraft/server';
|
|
13342
|
+
* import { Vector3Utils } from '@minecraft/math';
|
|
13376
13343
|
*
|
|
13377
|
-
* function logEntitySpawnEvent(
|
|
13378
|
-
* log: (message: string, status?: number) => void,
|
|
13379
|
-
* targetLocation: DimensionLocation
|
|
13380
|
-
* ) {
|
|
13344
|
+
* function logEntitySpawnEvent(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
13381
13345
|
* // register a new function that is called when a new entity is created.
|
|
13382
13346
|
* world.afterEvents.entitySpawn.subscribe((entityEvent: EntitySpawnAfterEvent) => {
|
|
13383
13347
|
* if (entityEvent && entityEvent.entity) {
|
|
@@ -13389,7 +13353,7 @@ export class EntitySpawnAfterEventSignal {
|
|
|
13389
13353
|
*
|
|
13390
13354
|
* system.runTimeout(() => {
|
|
13391
13355
|
* targetLocation.dimension.spawnEntity(
|
|
13392
|
-
*
|
|
13356
|
+
* 'minecraft:horse<minecraft:ageable_grow_up>',
|
|
13393
13357
|
* Vector3Utils.add(targetLocation, { x: 0, y: 1, z: 0 })
|
|
13394
13358
|
* );
|
|
13395
13359
|
* }, 20);
|
|
@@ -13579,7 +13543,6 @@ export class EntityType {
|
|
|
13579
13543
|
*/
|
|
13580
13544
|
readonly id: string;
|
|
13581
13545
|
/**
|
|
13582
|
-
* @rc
|
|
13583
13546
|
* @remarks
|
|
13584
13547
|
* Key for the localization of this EntityType's name used in
|
|
13585
13548
|
* .lang files.
|
|
@@ -13869,7 +13832,6 @@ export class FeedItem {
|
|
|
13869
13832
|
*/
|
|
13870
13833
|
readonly item: string;
|
|
13871
13834
|
/**
|
|
13872
|
-
* @rc
|
|
13873
13835
|
* @remarks
|
|
13874
13836
|
* Type ID of the resulting item after feeding has occurred.
|
|
13875
13837
|
* This will usually be empty but is used for scenarios such as
|
|
@@ -14890,12 +14852,18 @@ export class ItemCustomComponentInstance extends ItemComponent {
|
|
|
14890
14852
|
* to data-driven items.
|
|
14891
14853
|
* @example giveHurtDiamondSword.ts
|
|
14892
14854
|
* ```typescript
|
|
14893
|
-
* import {
|
|
14894
|
-
*
|
|
14855
|
+
* import {
|
|
14856
|
+
* world,
|
|
14857
|
+
* ItemStack,
|
|
14858
|
+
* EntityInventoryComponent,
|
|
14859
|
+
* EntityComponentTypes,
|
|
14860
|
+
* ItemComponentTypes,
|
|
14861
|
+
* ItemDurabilityComponent,
|
|
14862
|
+
* DimensionLocation,
|
|
14863
|
+
* } from '@minecraft/server';
|
|
14864
|
+
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
|
|
14895
14865
|
*
|
|
14896
|
-
* function giveHurtDiamondSword(
|
|
14897
|
-
* targetLocation: DimensionLocation
|
|
14898
|
-
* ) {
|
|
14866
|
+
* function giveHurtDiamondSword(targetLocation: DimensionLocation) {
|
|
14899
14867
|
* const hurtDiamondSword = new ItemStack(MinecraftItemTypes.DiamondSword);
|
|
14900
14868
|
*
|
|
14901
14869
|
* const durabilityComponent = hurtDiamondSword.getComponent(ItemComponentTypes.Durability) as ItemDurabilityComponent;
|
|
@@ -14933,7 +14901,6 @@ export class ItemDurabilityComponent extends ItemComponent {
|
|
|
14933
14901
|
*/
|
|
14934
14902
|
readonly maxDurability: number;
|
|
14935
14903
|
/**
|
|
14936
|
-
* @rc
|
|
14937
14904
|
* @remarks
|
|
14938
14905
|
* Whether an item breaks or loses durability. Setting to true
|
|
14939
14906
|
* temporarily removes item's durability HUD, and freezes
|
|
@@ -15318,8 +15285,8 @@ export class ItemReleaseUseAfterEventSignal {
|
|
|
15318
15285
|
* Defines a collection of items.
|
|
15319
15286
|
* @example itemStacks.ts
|
|
15320
15287
|
* ```typescript
|
|
15321
|
-
* import { ItemStack, DimensionLocation } from
|
|
15322
|
-
* import { MinecraftItemTypes } from
|
|
15288
|
+
* import { ItemStack, DimensionLocation } from '@minecraft/server';
|
|
15289
|
+
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
|
|
15323
15290
|
*
|
|
15324
15291
|
* function itemStacks(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
15325
15292
|
* const oneItemLoc = { x: targetLocation.x + targetLocation.y + 3, y: 2, z: targetLocation.z + 1 };
|
|
@@ -15342,12 +15309,17 @@ export class ItemReleaseUseAfterEventSignal {
|
|
|
15342
15309
|
* ```
|
|
15343
15310
|
* @example givePlayerEquipment.ts
|
|
15344
15311
|
* ```typescript
|
|
15345
|
-
* import {
|
|
15346
|
-
*
|
|
15312
|
+
* import {
|
|
15313
|
+
* world,
|
|
15314
|
+
* ItemStack,
|
|
15315
|
+
* EntityEquippableComponent,
|
|
15316
|
+
* EquipmentSlot,
|
|
15317
|
+
* EntityComponentTypes,
|
|
15318
|
+
* DimensionLocation,
|
|
15319
|
+
* } from '@minecraft/server';
|
|
15320
|
+
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
|
|
15347
15321
|
*
|
|
15348
|
-
* function givePlayerEquipment(
|
|
15349
|
-
* targetLocation: DimensionLocation
|
|
15350
|
-
* ) {
|
|
15322
|
+
* function givePlayerEquipment(targetLocation: DimensionLocation) {
|
|
15351
15323
|
* const players = world.getAllPlayers();
|
|
15352
15324
|
*
|
|
15353
15325
|
* const armorStandLoc = { x: targetLocation.x, y: targetLocation.y, z: targetLocation.z + 4 };
|
|
@@ -15376,8 +15348,8 @@ export class ItemReleaseUseAfterEventSignal {
|
|
|
15376
15348
|
* ```
|
|
15377
15349
|
* @example spawnFeatherItem.ts
|
|
15378
15350
|
* ```typescript
|
|
15379
|
-
* import { ItemStack, DimensionLocation } from
|
|
15380
|
-
* import { MinecraftItemTypes } from
|
|
15351
|
+
* import { ItemStack, DimensionLocation } from '@minecraft/server';
|
|
15352
|
+
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
|
|
15381
15353
|
*
|
|
15382
15354
|
* function spawnFeatherItem(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
15383
15355
|
* const featherItem = new ItemStack(MinecraftItemTypes.Feather, 1);
|
|
@@ -15550,12 +15522,18 @@ export class ItemStack {
|
|
|
15550
15522
|
* otherwise undefined.
|
|
15551
15523
|
* @example giveHurtDiamondSword.ts
|
|
15552
15524
|
* ```typescript
|
|
15553
|
-
* import {
|
|
15554
|
-
*
|
|
15525
|
+
* import {
|
|
15526
|
+
* world,
|
|
15527
|
+
* ItemStack,
|
|
15528
|
+
* EntityInventoryComponent,
|
|
15529
|
+
* EntityComponentTypes,
|
|
15530
|
+
* ItemComponentTypes,
|
|
15531
|
+
* ItemDurabilityComponent,
|
|
15532
|
+
* DimensionLocation,
|
|
15533
|
+
* } from '@minecraft/server';
|
|
15534
|
+
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
|
|
15555
15535
|
*
|
|
15556
|
-
* function giveHurtDiamondSword(
|
|
15557
|
-
* targetLocation: DimensionLocation
|
|
15558
|
-
* ) {
|
|
15536
|
+
* function giveHurtDiamondSword(targetLocation: DimensionLocation) {
|
|
15559
15537
|
* const hurtDiamondSword = new ItemStack(MinecraftItemTypes.DiamondSword);
|
|
15560
15538
|
*
|
|
15561
15539
|
* const durabilityComponent = hurtDiamondSword.getComponent(ItemComponentTypes.Durability) as ItemDurabilityComponent;
|
|
@@ -15706,17 +15684,15 @@ export class ItemStack {
|
|
|
15706
15684
|
* Throws if any of the provided block identifiers are invalid.
|
|
15707
15685
|
* @example giveDestroyRestrictedPickaxe.ts
|
|
15708
15686
|
* ```typescript
|
|
15709
|
-
* import { world, ItemStack, EntityInventoryComponent, DimensionLocation } from
|
|
15710
|
-
* import { MinecraftItemTypes } from
|
|
15687
|
+
* import { world, ItemStack, EntityInventoryComponent, DimensionLocation } from '@minecraft/server';
|
|
15688
|
+
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
|
|
15711
15689
|
*
|
|
15712
|
-
* function giveDestroyRestrictedPickaxe(
|
|
15713
|
-
* targetLocation: DimensionLocation
|
|
15714
|
-
* ) {
|
|
15690
|
+
* function giveDestroyRestrictedPickaxe(targetLocation: DimensionLocation) {
|
|
15715
15691
|
* for (const player of world.getAllPlayers()) {
|
|
15716
15692
|
* const specialPickaxe = new ItemStack(MinecraftItemTypes.DiamondPickaxe);
|
|
15717
15693
|
* specialPickaxe.setCanDestroy([MinecraftItemTypes.Cobblestone, MinecraftItemTypes.Obsidian]);
|
|
15718
15694
|
*
|
|
15719
|
-
* const inventory = player.getComponent(
|
|
15695
|
+
* const inventory = player.getComponent('inventory') as EntityInventoryComponent;
|
|
15720
15696
|
* if (inventory === undefined || inventory.container === undefined) {
|
|
15721
15697
|
* return;
|
|
15722
15698
|
* }
|
|
@@ -15742,12 +15718,10 @@ export class ItemStack {
|
|
|
15742
15718
|
* Throws if any of the provided block identifiers are invalid.
|
|
15743
15719
|
* @example givePlaceRestrictedGoldBlock.ts
|
|
15744
15720
|
* ```typescript
|
|
15745
|
-
* import { world, ItemStack, EntityInventoryComponent, EntityComponentTypes, DimensionLocation } from
|
|
15746
|
-
* import { MinecraftItemTypes } from
|
|
15721
|
+
* import { world, ItemStack, EntityInventoryComponent, EntityComponentTypes, DimensionLocation } from '@minecraft/server';
|
|
15722
|
+
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
|
|
15747
15723
|
*
|
|
15748
|
-
* function givePlaceRestrictedGoldBlock(
|
|
15749
|
-
* targetLocation: DimensionLocation
|
|
15750
|
-
* ) {
|
|
15724
|
+
* function givePlaceRestrictedGoldBlock(targetLocation: DimensionLocation) {
|
|
15751
15725
|
* for (const player of world.getAllPlayers()) {
|
|
15752
15726
|
* const specialGoldBlock = new ItemStack(MinecraftItemTypes.GoldBlock);
|
|
15753
15727
|
* specialGoldBlock.setCanPlaceOn([MinecraftItemTypes.GrassBlock, MinecraftItemTypes.Dirt]);
|
|
@@ -15819,19 +15793,16 @@ export class ItemStack {
|
|
|
15819
15793
|
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
|
|
15820
15794
|
*
|
|
15821
15795
|
* function giveAwesomeSword(player: Player) {
|
|
15822
|
-
*
|
|
15823
|
-
*
|
|
15824
|
-
*
|
|
15825
|
-
*
|
|
15826
|
-
*
|
|
15827
|
-
*
|
|
15828
|
-
*
|
|
15829
|
-
*
|
|
15830
|
-
* if (inventory === undefined || inventory.container === undefined) {
|
|
15831
|
-
* return;
|
|
15832
|
-
* }
|
|
15796
|
+
* const diamondAwesomeSword = new ItemStack(MinecraftItemTypes.DiamondSword, 1);
|
|
15797
|
+
* diamondAwesomeSword.setLore(['§c§lDiamond Sword of Awesome§r', '+10 coolness', '§p+4 shiny§r']);
|
|
15798
|
+
*
|
|
15799
|
+
* // hover over/select the item in your inventory to see the lore.
|
|
15800
|
+
* const inventory = player.getComponent(EntityComponentTypes.Inventory);
|
|
15801
|
+
* if (inventory === undefined || inventory.container === undefined) {
|
|
15802
|
+
* return;
|
|
15803
|
+
* }
|
|
15833
15804
|
*
|
|
15834
|
-
*
|
|
15805
|
+
* inventory.container.setItem(0, diamondAwesomeSword);
|
|
15835
15806
|
* }
|
|
15836
15807
|
* ```
|
|
15837
15808
|
*/
|
|
@@ -16098,7 +16069,6 @@ export class ItemType {
|
|
|
16098
16069
|
*/
|
|
16099
16070
|
readonly id: string;
|
|
16100
16071
|
/**
|
|
16101
|
-
* @rc
|
|
16102
16072
|
* @remarks
|
|
16103
16073
|
* Key for the localization of this ItemType's name used in
|
|
16104
16074
|
* .lang files.
|
|
@@ -16295,8 +16265,8 @@ export class KilledByPlayerOrPetsCondition extends LootItemCondition {
|
|
|
16295
16265
|
* activating or deactivating.
|
|
16296
16266
|
* @example leverActionEvent.ts
|
|
16297
16267
|
* ```typescript
|
|
16298
|
-
* import { world, system, BlockPermutation, LeverActionAfterEvent, DimensionLocation } from
|
|
16299
|
-
* import { MinecraftBlockTypes } from
|
|
16268
|
+
* import { world, system, BlockPermutation, LeverActionAfterEvent, DimensionLocation } from '@minecraft/server';
|
|
16269
|
+
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
|
|
16300
16270
|
*
|
|
16301
16271
|
* function leverActionEvent(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
16302
16272
|
* // set up a lever
|
|
@@ -16308,20 +16278,20 @@ export class KilledByPlayerOrPetsCondition extends LootItemCondition {
|
|
|
16308
16278
|
* });
|
|
16309
16279
|
*
|
|
16310
16280
|
* if (cobblestone === undefined || lever === undefined) {
|
|
16311
|
-
* log(
|
|
16281
|
+
* log('Could not find block at location.');
|
|
16312
16282
|
* return -1;
|
|
16313
16283
|
* }
|
|
16314
16284
|
*
|
|
16315
16285
|
* cobblestone.setPermutation(BlockPermutation.resolve(MinecraftBlockTypes.Cobblestone));
|
|
16316
16286
|
* lever.setPermutation(
|
|
16317
|
-
* BlockPermutation.resolve(MinecraftBlockTypes.Lever).withState(
|
|
16287
|
+
* BlockPermutation.resolve(MinecraftBlockTypes.Lever).withState('lever_direction', 'up_north_south')
|
|
16318
16288
|
* );
|
|
16319
16289
|
*
|
|
16320
16290
|
* world.afterEvents.leverAction.subscribe((leverActionEvent: LeverActionAfterEvent) => {
|
|
16321
16291
|
* const eventLoc = leverActionEvent.block.location;
|
|
16322
16292
|
*
|
|
16323
16293
|
* if (eventLoc.x === targetLocation.x && eventLoc.y === targetLocation.y + 1 && eventLoc.z === targetLocation.z) {
|
|
16324
|
-
* log(
|
|
16294
|
+
* log('Lever activate event at tick ' + system.currentTick);
|
|
16325
16295
|
* }
|
|
16326
16296
|
* });
|
|
16327
16297
|
* }
|
|
@@ -16350,8 +16320,8 @@ export class LeverActionAfterEvent extends BlockEvent {
|
|
|
16350
16320
|
* (activates or deactivates).
|
|
16351
16321
|
* @example leverActionEvent.ts
|
|
16352
16322
|
* ```typescript
|
|
16353
|
-
* import { world, system, BlockPermutation, LeverActionAfterEvent, DimensionLocation } from
|
|
16354
|
-
* import { MinecraftBlockTypes } from
|
|
16323
|
+
* import { world, system, BlockPermutation, LeverActionAfterEvent, DimensionLocation } from '@minecraft/server';
|
|
16324
|
+
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
|
|
16355
16325
|
*
|
|
16356
16326
|
* function leverActionEvent(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
16357
16327
|
* // set up a lever
|
|
@@ -16363,20 +16333,20 @@ export class LeverActionAfterEvent extends BlockEvent {
|
|
|
16363
16333
|
* });
|
|
16364
16334
|
*
|
|
16365
16335
|
* if (cobblestone === undefined || lever === undefined) {
|
|
16366
|
-
* log(
|
|
16336
|
+
* log('Could not find block at location.');
|
|
16367
16337
|
* return -1;
|
|
16368
16338
|
* }
|
|
16369
16339
|
*
|
|
16370
16340
|
* cobblestone.setPermutation(BlockPermutation.resolve(MinecraftBlockTypes.Cobblestone));
|
|
16371
16341
|
* lever.setPermutation(
|
|
16372
|
-
* BlockPermutation.resolve(MinecraftBlockTypes.Lever).withState(
|
|
16342
|
+
* BlockPermutation.resolve(MinecraftBlockTypes.Lever).withState('lever_direction', 'up_north_south')
|
|
16373
16343
|
* );
|
|
16374
16344
|
*
|
|
16375
16345
|
* world.afterEvents.leverAction.subscribe((leverActionEvent: LeverActionAfterEvent) => {
|
|
16376
16346
|
* const eventLoc = leverActionEvent.block.location;
|
|
16377
16347
|
*
|
|
16378
16348
|
* if (eventLoc.x === targetLocation.x && eventLoc.y === targetLocation.y + 1 && eventLoc.z === targetLocation.z) {
|
|
16379
|
-
* log(
|
|
16349
|
+
* log('Lever activate event at tick ' + system.currentTick);
|
|
16380
16350
|
* }
|
|
16381
16351
|
* });
|
|
16382
16352
|
* }
|
|
@@ -16409,7 +16379,6 @@ export class LeverActionAfterEventSignal {
|
|
|
16409
16379
|
}
|
|
16410
16380
|
|
|
16411
16381
|
/**
|
|
16412
|
-
* @rc
|
|
16413
16382
|
* A spline that linearly interpolates between points.
|
|
16414
16383
|
*/
|
|
16415
16384
|
export class LinearSpline {
|
|
@@ -17161,8 +17130,15 @@ export class PassengerOfEntityCondition extends LootItemCondition {
|
|
|
17161
17130
|
* expanding or retracting.
|
|
17162
17131
|
* @example pistonAfterEvent.ts
|
|
17163
17132
|
* ```typescript
|
|
17164
|
-
* import {
|
|
17165
|
-
*
|
|
17133
|
+
* import {
|
|
17134
|
+
* world,
|
|
17135
|
+
* system,
|
|
17136
|
+
* BlockPermutation,
|
|
17137
|
+
* BlockPistonState,
|
|
17138
|
+
* PistonActivateAfterEvent,
|
|
17139
|
+
* DimensionLocation,
|
|
17140
|
+
* } from '@minecraft/server';
|
|
17141
|
+
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
|
|
17166
17142
|
*
|
|
17167
17143
|
* function pistonAfterEvent(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
17168
17144
|
* // set up a couple of piston blocks
|
|
@@ -17174,25 +17150,25 @@ export class PassengerOfEntityCondition extends LootItemCondition {
|
|
|
17174
17150
|
* });
|
|
17175
17151
|
*
|
|
17176
17152
|
* if (piston === undefined || button === undefined) {
|
|
17177
|
-
* log(
|
|
17153
|
+
* log('Could not find block at location.');
|
|
17178
17154
|
* return -1;
|
|
17179
17155
|
* }
|
|
17180
17156
|
*
|
|
17181
|
-
* piston.setPermutation(BlockPermutation.resolve(MinecraftBlockTypes.Piston).withState(
|
|
17182
|
-
* button.setPermutation(BlockPermutation.resolve(MinecraftBlockTypes.AcaciaButton).withState(
|
|
17157
|
+
* piston.setPermutation(BlockPermutation.resolve(MinecraftBlockTypes.Piston).withState('facing_direction', 3));
|
|
17158
|
+
* button.setPermutation(BlockPermutation.resolve(MinecraftBlockTypes.AcaciaButton).withState('facing_direction', 1));
|
|
17183
17159
|
*
|
|
17184
17160
|
* world.afterEvents.pistonActivate.subscribe((pistonEvent: PistonActivateAfterEvent) => {
|
|
17185
17161
|
* const eventLoc = pistonEvent.piston.block.location;
|
|
17186
17162
|
*
|
|
17187
17163
|
* if (eventLoc.x === targetLocation.x && eventLoc.y === targetLocation.y && eventLoc.z === targetLocation.z) {
|
|
17188
17164
|
* log(
|
|
17189
|
-
*
|
|
17165
|
+
* 'Piston event at ' +
|
|
17190
17166
|
* system.currentTick +
|
|
17191
|
-
* (pistonEvent.piston.isMoving ?
|
|
17192
|
-
* (pistonEvent.piston.state === BlockPistonState.Expanding ?
|
|
17193
|
-
* (pistonEvent.piston.state === BlockPistonState.Expanded ?
|
|
17194
|
-
* (pistonEvent.piston.state === BlockPistonState.Retracting ?
|
|
17195
|
-
* (pistonEvent.piston.state === BlockPistonState.Retracted ?
|
|
17167
|
+
* (pistonEvent.piston.isMoving ? ' Moving' : '') +
|
|
17168
|
+
* (pistonEvent.piston.state === BlockPistonState.Expanding ? ' Expanding' : '') +
|
|
17169
|
+
* (pistonEvent.piston.state === BlockPistonState.Expanded ? ' Expanded' : '') +
|
|
17170
|
+
* (pistonEvent.piston.state === BlockPistonState.Retracting ? ' Retracting' : '') +
|
|
17171
|
+
* (pistonEvent.piston.state === BlockPistonState.Retracted ? ' Retracted' : '')
|
|
17196
17172
|
* );
|
|
17197
17173
|
* }
|
|
17198
17174
|
* });
|
|
@@ -17229,8 +17205,15 @@ export class PistonActivateAfterEventSignal {
|
|
|
17229
17205
|
*
|
|
17230
17206
|
* @example pistonAfterEvent.ts
|
|
17231
17207
|
* ```typescript
|
|
17232
|
-
* import {
|
|
17233
|
-
*
|
|
17208
|
+
* import {
|
|
17209
|
+
* world,
|
|
17210
|
+
* system,
|
|
17211
|
+
* BlockPermutation,
|
|
17212
|
+
* BlockPistonState,
|
|
17213
|
+
* PistonActivateAfterEvent,
|
|
17214
|
+
* DimensionLocation,
|
|
17215
|
+
* } from '@minecraft/server';
|
|
17216
|
+
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
|
|
17234
17217
|
*
|
|
17235
17218
|
* function pistonAfterEvent(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
17236
17219
|
* // set up a couple of piston blocks
|
|
@@ -17242,25 +17225,25 @@ export class PistonActivateAfterEventSignal {
|
|
|
17242
17225
|
* });
|
|
17243
17226
|
*
|
|
17244
17227
|
* if (piston === undefined || button === undefined) {
|
|
17245
|
-
* log(
|
|
17228
|
+
* log('Could not find block at location.');
|
|
17246
17229
|
* return -1;
|
|
17247
17230
|
* }
|
|
17248
17231
|
*
|
|
17249
|
-
* piston.setPermutation(BlockPermutation.resolve(MinecraftBlockTypes.Piston).withState(
|
|
17250
|
-
* button.setPermutation(BlockPermutation.resolve(MinecraftBlockTypes.AcaciaButton).withState(
|
|
17232
|
+
* piston.setPermutation(BlockPermutation.resolve(MinecraftBlockTypes.Piston).withState('facing_direction', 3));
|
|
17233
|
+
* button.setPermutation(BlockPermutation.resolve(MinecraftBlockTypes.AcaciaButton).withState('facing_direction', 1));
|
|
17251
17234
|
*
|
|
17252
17235
|
* world.afterEvents.pistonActivate.subscribe((pistonEvent: PistonActivateAfterEvent) => {
|
|
17253
17236
|
* const eventLoc = pistonEvent.piston.block.location;
|
|
17254
17237
|
*
|
|
17255
17238
|
* if (eventLoc.x === targetLocation.x && eventLoc.y === targetLocation.y && eventLoc.z === targetLocation.z) {
|
|
17256
17239
|
* log(
|
|
17257
|
-
*
|
|
17240
|
+
* 'Piston event at ' +
|
|
17258
17241
|
* system.currentTick +
|
|
17259
|
-
* (pistonEvent.piston.isMoving ?
|
|
17260
|
-
* (pistonEvent.piston.state === BlockPistonState.Expanding ?
|
|
17261
|
-
* (pistonEvent.piston.state === BlockPistonState.Expanded ?
|
|
17262
|
-
* (pistonEvent.piston.state === BlockPistonState.Retracting ?
|
|
17263
|
-
* (pistonEvent.piston.state === BlockPistonState.Retracted ?
|
|
17242
|
+
* (pistonEvent.piston.isMoving ? ' Moving' : '') +
|
|
17243
|
+
* (pistonEvent.piston.state === BlockPistonState.Expanding ? ' Expanding' : '') +
|
|
17244
|
+
* (pistonEvent.piston.state === BlockPistonState.Expanded ? ' Expanded' : '') +
|
|
17245
|
+
* (pistonEvent.piston.state === BlockPistonState.Retracting ? ' Retracting' : '') +
|
|
17246
|
+
* (pistonEvent.piston.state === BlockPistonState.Retracted ? ' Retracted' : '')
|
|
17264
17247
|
* );
|
|
17265
17248
|
* }
|
|
17266
17249
|
* });
|
|
@@ -17486,7 +17469,6 @@ export class Player extends Entity {
|
|
|
17486
17469
|
*/
|
|
17487
17470
|
eatItem(itemStack: ItemStack): void;
|
|
17488
17471
|
/**
|
|
17489
|
-
* @rc
|
|
17490
17472
|
* @remarks
|
|
17491
17473
|
* The player's aim-assist settings.
|
|
17492
17474
|
*
|
|
@@ -17558,7 +17540,7 @@ export class Player extends Entity {
|
|
|
17558
17540
|
* @throws This function can throw errors.
|
|
17559
17541
|
* @example playMusicAndSound.ts
|
|
17560
17542
|
* ```typescript
|
|
17561
|
-
* import { world, MusicOptions, WorldSoundOptions, PlayerSoundOptions, DimensionLocation } from
|
|
17543
|
+
* import { world, MusicOptions, WorldSoundOptions, PlayerSoundOptions, DimensionLocation } from '@minecraft/server';
|
|
17562
17544
|
*
|
|
17563
17545
|
* function playMusicAndSound(targetLocation: DimensionLocation) {
|
|
17564
17546
|
* const players = world.getPlayers();
|
|
@@ -17568,20 +17550,20 @@ export class Player extends Entity {
|
|
|
17568
17550
|
* loop: true,
|
|
17569
17551
|
* volume: 1.0,
|
|
17570
17552
|
* };
|
|
17571
|
-
* world.playMusic(
|
|
17553
|
+
* world.playMusic('music.menu', musicOptions);
|
|
17572
17554
|
*
|
|
17573
17555
|
* const worldSoundOptions: WorldSoundOptions = {
|
|
17574
17556
|
* pitch: 0.5,
|
|
17575
17557
|
* volume: 4.0,
|
|
17576
17558
|
* };
|
|
17577
|
-
* world.playSound(
|
|
17559
|
+
* world.playSound('ambient.weather.thunder', targetLocation, worldSoundOptions);
|
|
17578
17560
|
*
|
|
17579
17561
|
* const playerSoundOptions: PlayerSoundOptions = {
|
|
17580
17562
|
* pitch: 1.0,
|
|
17581
17563
|
* volume: 1.0,
|
|
17582
17564
|
* };
|
|
17583
17565
|
*
|
|
17584
|
-
* players[0].playSound(
|
|
17566
|
+
* players[0].playSound('bucket.fill_water', playerSoundOptions);
|
|
17585
17567
|
* }
|
|
17586
17568
|
* ```
|
|
17587
17569
|
*/
|
|
@@ -17659,61 +17641,61 @@ export class Player extends Entity {
|
|
|
17659
17641
|
* {@link RawMessageError}
|
|
17660
17642
|
* @example nestedTranslation.ts
|
|
17661
17643
|
* ```typescript
|
|
17662
|
-
* import { world, DimensionLocation } from
|
|
17644
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
17663
17645
|
*
|
|
17664
17646
|
* function nestedTranslation(targetLocation: DimensionLocation) {
|
|
17665
17647
|
* // Displays "Apple or Coal"
|
|
17666
17648
|
* const rawMessage = {
|
|
17667
|
-
* translate:
|
|
17668
|
-
* with: { rawtext: [{ translate:
|
|
17649
|
+
* translate: 'accessibility.list.or.two',
|
|
17650
|
+
* with: { rawtext: [{ translate: 'item.apple.name' }, { translate: 'item.coal.name' }] },
|
|
17669
17651
|
* };
|
|
17670
17652
|
* world.sendMessage(rawMessage);
|
|
17671
17653
|
* }
|
|
17672
17654
|
* ```
|
|
17673
17655
|
* @example scoreWildcard.ts
|
|
17674
17656
|
* ```typescript
|
|
17675
|
-
* import { world, DimensionLocation } from
|
|
17657
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
17676
17658
|
*
|
|
17677
17659
|
* function scoreWildcard(targetLocation: DimensionLocation) {
|
|
17678
17660
|
* // Displays the player's score for objective "obj". Each player will see their own score.
|
|
17679
|
-
* const rawMessage = { score: { name:
|
|
17661
|
+
* const rawMessage = { score: { name: '*', objective: 'obj' } };
|
|
17680
17662
|
* world.sendMessage(rawMessage);
|
|
17681
17663
|
* }
|
|
17682
17664
|
* ```
|
|
17683
17665
|
* @example sendBasicMessage.ts
|
|
17684
17666
|
* ```typescript
|
|
17685
|
-
* import { world, DimensionLocation } from
|
|
17667
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
17686
17668
|
*
|
|
17687
17669
|
* function sendBasicMessage(targetLocation: DimensionLocation) {
|
|
17688
17670
|
* const players = world.getPlayers();
|
|
17689
17671
|
*
|
|
17690
|
-
* players[0].sendMessage(
|
|
17672
|
+
* players[0].sendMessage('Hello World!');
|
|
17691
17673
|
* }
|
|
17692
17674
|
* ```
|
|
17693
17675
|
* @example sendPlayerMessages.ts
|
|
17694
17676
|
* ```typescript
|
|
17695
|
-
* import { world, DimensionLocation } from
|
|
17677
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
17696
17678
|
*
|
|
17697
17679
|
* function sendPlayerMessages(targetLocation: DimensionLocation) {
|
|
17698
17680
|
* for (const player of world.getAllPlayers()) {
|
|
17699
17681
|
* // Displays "First or Second"
|
|
17700
|
-
* const rawMessage = { translate:
|
|
17682
|
+
* const rawMessage = { translate: 'accessibility.list.or.two', with: ['First', 'Second'] };
|
|
17701
17683
|
* player.sendMessage(rawMessage);
|
|
17702
17684
|
*
|
|
17703
17685
|
* // Displays "Hello, world!"
|
|
17704
|
-
* player.sendMessage(
|
|
17686
|
+
* player.sendMessage('Hello, world!');
|
|
17705
17687
|
*
|
|
17706
17688
|
* // Displays "Welcome, Amazing Player 1!"
|
|
17707
|
-
* player.sendMessage({ translate:
|
|
17689
|
+
* player.sendMessage({ translate: 'authentication.welcome', with: ['Amazing Player 1'] });
|
|
17708
17690
|
*
|
|
17709
17691
|
* // Displays the player's score for objective "obj". Each player will see their own score.
|
|
17710
|
-
* const rawMessageWithScore = { score: { name:
|
|
17692
|
+
* const rawMessageWithScore = { score: { name: '*', objective: 'obj' } };
|
|
17711
17693
|
* player.sendMessage(rawMessageWithScore);
|
|
17712
17694
|
*
|
|
17713
17695
|
* // Displays "Apple or Coal"
|
|
17714
17696
|
* const rawMessageWithNestedTranslations = {
|
|
17715
|
-
* translate:
|
|
17716
|
-
* with: { rawtext: [{ translate:
|
|
17697
|
+
* translate: 'accessibility.list.or.two',
|
|
17698
|
+
* with: { rawtext: [{ translate: 'item.apple.name' }, { translate: 'item.coal.name' }] },
|
|
17717
17699
|
* };
|
|
17718
17700
|
* player.sendMessage(rawMessageWithNestedTranslations);
|
|
17719
17701
|
* }
|
|
@@ -17721,14 +17703,12 @@ export class Player extends Entity {
|
|
|
17721
17703
|
* ```
|
|
17722
17704
|
* @example sendTranslatedMessage.ts
|
|
17723
17705
|
* ```typescript
|
|
17724
|
-
* import { world, DimensionLocation } from
|
|
17706
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
17725
17707
|
*
|
|
17726
|
-
* function sendTranslatedMessage(
|
|
17727
|
-
* targetLocation: DimensionLocation
|
|
17728
|
-
* ) {
|
|
17708
|
+
* function sendTranslatedMessage(targetLocation: DimensionLocation) {
|
|
17729
17709
|
* const players = world.getPlayers();
|
|
17730
17710
|
*
|
|
17731
|
-
* players[0].sendMessage({ translate:
|
|
17711
|
+
* players[0].sendMessage({ translate: 'authentication.welcome', with: ['Amazing Player 1'] });
|
|
17732
17712
|
* }
|
|
17733
17713
|
* ```
|
|
17734
17714
|
*/
|
|
@@ -17837,23 +17817,23 @@ export class Player extends Entity {
|
|
|
17837
17817
|
* import { world, MolangVariableMap, Vector3 } from '@minecraft/server';
|
|
17838
17818
|
*
|
|
17839
17819
|
* world.afterEvents.playerSpawn.subscribe(event => {
|
|
17840
|
-
*
|
|
17841
|
-
*
|
|
17842
|
-
*
|
|
17843
|
-
*
|
|
17844
|
-
*
|
|
17845
|
-
*
|
|
17846
|
-
*
|
|
17847
|
-
*
|
|
17848
|
-
*
|
|
17849
|
-
*
|
|
17850
|
-
*
|
|
17851
|
-
*
|
|
17852
|
-
*
|
|
17853
|
-
*
|
|
17854
|
-
*
|
|
17855
|
-
*
|
|
17856
|
-
*
|
|
17820
|
+
* const targetLocation = event.player.location;
|
|
17821
|
+
* for (let i = 0; i < 100; i++) {
|
|
17822
|
+
* const molang = new MolangVariableMap();
|
|
17823
|
+
*
|
|
17824
|
+
* molang.setColorRGB('variable.color', {
|
|
17825
|
+
* red: Math.random(),
|
|
17826
|
+
* green: Math.random(),
|
|
17827
|
+
* blue: Math.random(),
|
|
17828
|
+
* });
|
|
17829
|
+
*
|
|
17830
|
+
* const newLocation: Vector3 = {
|
|
17831
|
+
* x: targetLocation.x + Math.floor(Math.random() * 8) - 4,
|
|
17832
|
+
* y: targetLocation.y + Math.floor(Math.random() * 8) - 4,
|
|
17833
|
+
* z: targetLocation.z + Math.floor(Math.random() * 8) - 4,
|
|
17834
|
+
* };
|
|
17835
|
+
* event.player.spawnParticle('minecraft:colored_flame_particle', newLocation, molang);
|
|
17836
|
+
* }
|
|
17857
17837
|
* });
|
|
17858
17838
|
* ```
|
|
17859
17839
|
*/
|
|
@@ -17913,7 +17893,6 @@ export class Player extends Entity {
|
|
|
17913
17893
|
}
|
|
17914
17894
|
|
|
17915
17895
|
/**
|
|
17916
|
-
* @rc
|
|
17917
17896
|
* A container for APIs related to player aim-assist.
|
|
17918
17897
|
*/
|
|
17919
17898
|
export class PlayerAimAssist {
|
|
@@ -19744,6 +19723,16 @@ export class PrimitiveShape {
|
|
|
19744
19723
|
*
|
|
19745
19724
|
*/
|
|
19746
19725
|
readonly location: Vector3;
|
|
19726
|
+
/**
|
|
19727
|
+
* @remarks
|
|
19728
|
+
* If defined, this distance will be used to determine how far
|
|
19729
|
+
* away this primitive will be rendered for each client. By
|
|
19730
|
+
* default the distance will match the client's render distance
|
|
19731
|
+
* setting.
|
|
19732
|
+
*
|
|
19733
|
+
* Minimum Value: 0
|
|
19734
|
+
*/
|
|
19735
|
+
maximumRenderDistance?: number;
|
|
19747
19736
|
/**
|
|
19748
19737
|
* @remarks
|
|
19749
19738
|
* The rotation of the shape (Euler angles - [Pitch, Yaw,
|
|
@@ -19755,6 +19744,7 @@ export class PrimitiveShape {
|
|
|
19755
19744
|
* @remarks
|
|
19756
19745
|
* The scale of the shape.
|
|
19757
19746
|
*
|
|
19747
|
+
* Bounds: [-1000, 1000]
|
|
19758
19748
|
*/
|
|
19759
19749
|
scale: number;
|
|
19760
19750
|
/**
|
|
@@ -19803,12 +19793,23 @@ export class PrimitiveShape {
|
|
|
19803
19793
|
*/
|
|
19804
19794
|
export class PrimitiveShapesManager {
|
|
19805
19795
|
private constructor();
|
|
19796
|
+
/**
|
|
19797
|
+
* @remarks
|
|
19798
|
+
* This is the maximum number of allowed primitive shapes.
|
|
19799
|
+
*
|
|
19800
|
+
*/
|
|
19801
|
+
readonly maxShapes: number;
|
|
19806
19802
|
/**
|
|
19807
19803
|
* @remarks
|
|
19808
19804
|
* Adds a new text primitive to the world.
|
|
19809
19805
|
*
|
|
19810
19806
|
* @param text
|
|
19811
19807
|
* The text primitive to be added.
|
|
19808
|
+
* @throws This function can throw errors.
|
|
19809
|
+
*
|
|
19810
|
+
* {@link minecraftcommon.EngineError}
|
|
19811
|
+
*
|
|
19812
|
+
* {@link PrimitiveShapeError}
|
|
19812
19813
|
*/
|
|
19813
19814
|
addText(text: TextPrimitive, dimension?: Dimension): void;
|
|
19814
19815
|
/**
|
|
@@ -20099,11 +20100,11 @@ export class RandomRegionalDifficultyChanceCondition extends LootItemCondition {
|
|
|
20099
20100
|
* Contains objectives and participants for the scoreboard.
|
|
20100
20101
|
* @example updateScoreboard.ts
|
|
20101
20102
|
* ```typescript
|
|
20102
|
-
* import { world, DisplaySlotId, ObjectiveSortOrder, DimensionLocation } from
|
|
20103
|
+
* import { world, DisplaySlotId, ObjectiveSortOrder, DimensionLocation } from '@minecraft/server';
|
|
20103
20104
|
*
|
|
20104
20105
|
* function updateScoreboard(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
20105
|
-
* const scoreboardObjectiveId =
|
|
20106
|
-
* const scoreboardObjectiveDisplayName =
|
|
20106
|
+
* const scoreboardObjectiveId = 'scoreboard_demo_objective';
|
|
20107
|
+
* const scoreboardObjectiveDisplayName = 'Demo Objective';
|
|
20107
20108
|
*
|
|
20108
20109
|
* const players = world.getPlayers();
|
|
20109
20110
|
*
|
|
@@ -20118,7 +20119,7 @@ export class RandomRegionalDifficultyChanceCondition extends LootItemCondition {
|
|
|
20118
20119
|
* const player0Identity = players[0].scoreboardIdentity;
|
|
20119
20120
|
*
|
|
20120
20121
|
* if (player0Identity === undefined) {
|
|
20121
|
-
* log(
|
|
20122
|
+
* log('Could not get a scoreboard identity for player 0.');
|
|
20122
20123
|
* return -1;
|
|
20123
20124
|
* }
|
|
20124
20125
|
*
|
|
@@ -20148,11 +20149,11 @@ export class Scoreboard {
|
|
|
20148
20149
|
* @throws This function can throw errors.
|
|
20149
20150
|
* @example updateScoreboard.ts
|
|
20150
20151
|
* ```typescript
|
|
20151
|
-
* import { world, DisplaySlotId, ObjectiveSortOrder, DimensionLocation } from
|
|
20152
|
+
* import { world, DisplaySlotId, ObjectiveSortOrder, DimensionLocation } from '@minecraft/server';
|
|
20152
20153
|
*
|
|
20153
20154
|
* function updateScoreboard(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
20154
|
-
* const scoreboardObjectiveId =
|
|
20155
|
-
* const scoreboardObjectiveDisplayName =
|
|
20155
|
+
* const scoreboardObjectiveId = 'scoreboard_demo_objective';
|
|
20156
|
+
* const scoreboardObjectiveDisplayName = 'Demo Objective';
|
|
20156
20157
|
*
|
|
20157
20158
|
* const players = world.getPlayers();
|
|
20158
20159
|
*
|
|
@@ -20167,7 +20168,7 @@ export class Scoreboard {
|
|
|
20167
20168
|
* const player0Identity = players[0].scoreboardIdentity;
|
|
20168
20169
|
*
|
|
20169
20170
|
* if (player0Identity === undefined) {
|
|
20170
|
-
* log(
|
|
20171
|
+
* log('Could not get a scoreboard identity for player 0.');
|
|
20171
20172
|
* return -1;
|
|
20172
20173
|
* }
|
|
20173
20174
|
*
|
|
@@ -20412,45 +20413,43 @@ export class ScoreboardScoreInfo {
|
|
|
20412
20413
|
* showing up on the screen.
|
|
20413
20414
|
* @example setTitle.ts
|
|
20414
20415
|
* ```typescript
|
|
20415
|
-
* import { world, DimensionLocation } from
|
|
20416
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
20416
20417
|
*
|
|
20417
20418
|
* function setTitle(targetLocation: DimensionLocation) {
|
|
20418
20419
|
* const players = world.getPlayers();
|
|
20419
20420
|
*
|
|
20420
20421
|
* if (players.length > 0) {
|
|
20421
|
-
* players[0].onScreenDisplay.setTitle(
|
|
20422
|
+
* players[0].onScreenDisplay.setTitle('§o§6Fancy Title§r');
|
|
20422
20423
|
* }
|
|
20423
20424
|
* }
|
|
20424
20425
|
* ```
|
|
20425
20426
|
* @example setTitleAndSubtitle.ts
|
|
20426
20427
|
* ```typescript
|
|
20427
|
-
* import { world, DimensionLocation } from
|
|
20428
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
20428
20429
|
*
|
|
20429
|
-
* function setTitleAndSubtitle(
|
|
20430
|
-
* targetLocation: DimensionLocation
|
|
20431
|
-
* ) {
|
|
20430
|
+
* function setTitleAndSubtitle(targetLocation: DimensionLocation) {
|
|
20432
20431
|
* const players = world.getPlayers();
|
|
20433
20432
|
*
|
|
20434
|
-
* players[0].onScreenDisplay.setTitle(
|
|
20433
|
+
* players[0].onScreenDisplay.setTitle('Chapter 1', {
|
|
20435
20434
|
* stayDuration: 100,
|
|
20436
20435
|
* fadeInDuration: 2,
|
|
20437
20436
|
* fadeOutDuration: 4,
|
|
20438
|
-
* subtitle:
|
|
20437
|
+
* subtitle: 'Trouble in Block Town',
|
|
20439
20438
|
* });
|
|
20440
20439
|
* }
|
|
20441
20440
|
* ```
|
|
20442
20441
|
* @example countdown.ts
|
|
20443
20442
|
* ```typescript
|
|
20444
|
-
* import { world, system, DimensionLocation } from
|
|
20443
|
+
* import { world, system, DimensionLocation } from '@minecraft/server';
|
|
20445
20444
|
*
|
|
20446
20445
|
* function countdown(targetLocation: DimensionLocation) {
|
|
20447
20446
|
* const players = world.getPlayers();
|
|
20448
20447
|
*
|
|
20449
|
-
* players[0].onScreenDisplay.setTitle(
|
|
20448
|
+
* players[0].onScreenDisplay.setTitle('Get ready!', {
|
|
20450
20449
|
* stayDuration: 220,
|
|
20451
20450
|
* fadeInDuration: 2,
|
|
20452
20451
|
* fadeOutDuration: 4,
|
|
20453
|
-
* subtitle:
|
|
20452
|
+
* subtitle: '10',
|
|
20454
20453
|
* });
|
|
20455
20454
|
*
|
|
20456
20455
|
* let countdown = 10;
|
|
@@ -20562,45 +20561,43 @@ export class ScreenDisplay {
|
|
|
20562
20561
|
* {@link RawMessageError}
|
|
20563
20562
|
* @example setTitle.ts
|
|
20564
20563
|
* ```typescript
|
|
20565
|
-
* import { world, DimensionLocation } from
|
|
20564
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
20566
20565
|
*
|
|
20567
20566
|
* function setTitle(targetLocation: DimensionLocation) {
|
|
20568
20567
|
* const players = world.getPlayers();
|
|
20569
20568
|
*
|
|
20570
20569
|
* if (players.length > 0) {
|
|
20571
|
-
* players[0].onScreenDisplay.setTitle(
|
|
20570
|
+
* players[0].onScreenDisplay.setTitle('§o§6Fancy Title§r');
|
|
20572
20571
|
* }
|
|
20573
20572
|
* }
|
|
20574
20573
|
* ```
|
|
20575
20574
|
* @example setTitleAndSubtitle.ts
|
|
20576
20575
|
* ```typescript
|
|
20577
|
-
* import { world, DimensionLocation } from
|
|
20576
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
20578
20577
|
*
|
|
20579
|
-
* function setTitleAndSubtitle(
|
|
20580
|
-
* targetLocation: DimensionLocation
|
|
20581
|
-
* ) {
|
|
20578
|
+
* function setTitleAndSubtitle(targetLocation: DimensionLocation) {
|
|
20582
20579
|
* const players = world.getPlayers();
|
|
20583
20580
|
*
|
|
20584
|
-
* players[0].onScreenDisplay.setTitle(
|
|
20581
|
+
* players[0].onScreenDisplay.setTitle('Chapter 1', {
|
|
20585
20582
|
* stayDuration: 100,
|
|
20586
20583
|
* fadeInDuration: 2,
|
|
20587
20584
|
* fadeOutDuration: 4,
|
|
20588
|
-
* subtitle:
|
|
20585
|
+
* subtitle: 'Trouble in Block Town',
|
|
20589
20586
|
* });
|
|
20590
20587
|
* }
|
|
20591
20588
|
* ```
|
|
20592
20589
|
* @example countdown.ts
|
|
20593
20590
|
* ```typescript
|
|
20594
|
-
* import { world, system, DimensionLocation } from
|
|
20591
|
+
* import { world, system, DimensionLocation } from '@minecraft/server';
|
|
20595
20592
|
*
|
|
20596
20593
|
* function countdown(targetLocation: DimensionLocation) {
|
|
20597
20594
|
* const players = world.getPlayers();
|
|
20598
20595
|
*
|
|
20599
|
-
* players[0].onScreenDisplay.setTitle(
|
|
20596
|
+
* players[0].onScreenDisplay.setTitle('Get ready!', {
|
|
20600
20597
|
* stayDuration: 220,
|
|
20601
20598
|
* fadeInDuration: 2,
|
|
20602
20599
|
* fadeOutDuration: 4,
|
|
20603
|
-
* subtitle:
|
|
20600
|
+
* subtitle: '10',
|
|
20604
20601
|
* });
|
|
20605
20602
|
*
|
|
20606
20603
|
* let countdown = 10;
|
|
@@ -20631,16 +20628,16 @@ export class ScreenDisplay {
|
|
|
20631
20628
|
* {@link RawMessageError}
|
|
20632
20629
|
* @example countdown.ts
|
|
20633
20630
|
* ```typescript
|
|
20634
|
-
* import { world, system, DimensionLocation } from
|
|
20631
|
+
* import { world, system, DimensionLocation } from '@minecraft/server';
|
|
20635
20632
|
*
|
|
20636
20633
|
* function countdown(targetLocation: DimensionLocation) {
|
|
20637
20634
|
* const players = world.getPlayers();
|
|
20638
20635
|
*
|
|
20639
|
-
* players[0].onScreenDisplay.setTitle(
|
|
20636
|
+
* players[0].onScreenDisplay.setTitle('Get ready!', {
|
|
20640
20637
|
* stayDuration: 220,
|
|
20641
20638
|
* fadeInDuration: 2,
|
|
20642
20639
|
* fadeOutDuration: 4,
|
|
20643
|
-
* subtitle:
|
|
20640
|
+
* subtitle: '10',
|
|
20644
20641
|
* });
|
|
20645
20642
|
*
|
|
20646
20643
|
* let countdown = 10;
|
|
@@ -21625,16 +21622,16 @@ export class System {
|
|
|
21625
21622
|
* function to cancel the execution of this run.
|
|
21626
21623
|
* @example trapTick.ts
|
|
21627
21624
|
* ```typescript
|
|
21628
|
-
* import { world, system } from
|
|
21625
|
+
* import { world, system } from '@minecraft/server';
|
|
21629
21626
|
*
|
|
21630
21627
|
* function trapTick() {
|
|
21631
21628
|
* try {
|
|
21632
21629
|
* // Minecraft runs at 20 ticks per second.
|
|
21633
21630
|
* if (system.currentTick % 1200 === 0) {
|
|
21634
|
-
* world.sendMessage(
|
|
21631
|
+
* world.sendMessage('Another minute passes...');
|
|
21635
21632
|
* }
|
|
21636
21633
|
* } catch (e) {
|
|
21637
|
-
* console.warn(
|
|
21634
|
+
* console.warn('Error: ' + e);
|
|
21638
21635
|
* }
|
|
21639
21636
|
*
|
|
21640
21637
|
* system.run(trapTick);
|
|
@@ -21658,13 +21655,13 @@ export class System {
|
|
|
21658
21655
|
* to stop the run of this function on an interval.
|
|
21659
21656
|
* @example every30Seconds.ts
|
|
21660
21657
|
* ```typescript
|
|
21661
|
-
* import { world, system, DimensionLocation } from
|
|
21658
|
+
* import { world, system, DimensionLocation } from '@minecraft/server';
|
|
21662
21659
|
*
|
|
21663
21660
|
* function every30Seconds(targetLocation: DimensionLocation) {
|
|
21664
21661
|
* const intervalRunIdentifier = Math.floor(Math.random() * 10000);
|
|
21665
21662
|
*
|
|
21666
21663
|
* system.runInterval(() => {
|
|
21667
|
-
* world.sendMessage(
|
|
21664
|
+
* world.sendMessage('This is an interval run ' + intervalRunIdentifier + ' sending a message every 30 seconds.');
|
|
21668
21665
|
* }, 600);
|
|
21669
21666
|
* }
|
|
21670
21667
|
* ```
|
|
@@ -21685,10 +21682,10 @@ export class System {
|
|
|
21685
21682
|
* System.clearJob} to stop the run of this generator.
|
|
21686
21683
|
* @example cubeGenerator.ts
|
|
21687
21684
|
* ```typescript
|
|
21688
|
-
* import { system, BlockPermutation, DimensionLocation } from
|
|
21685
|
+
* import { system, BlockPermutation, DimensionLocation } from '@minecraft/server';
|
|
21689
21686
|
*
|
|
21690
21687
|
* function cubeGenerator(targetLocation: DimensionLocation) {
|
|
21691
|
-
* const blockPerm = BlockPermutation.resolve(
|
|
21688
|
+
* const blockPerm = BlockPermutation.resolve('minecraft:cobblestone');
|
|
21692
21689
|
*
|
|
21693
21690
|
* system.runJob(blockPlacingGenerator(blockPerm, targetLocation, 15));
|
|
21694
21691
|
* }
|
|
@@ -21903,6 +21900,14 @@ export class TargetBlockHitAfterEventSignal {
|
|
|
21903
21900
|
*/
|
|
21904
21901
|
// @ts-ignore Class inheritance allowed for native defined classes
|
|
21905
21902
|
export class TextPrimitive extends PrimitiveShape {
|
|
21903
|
+
/**
|
|
21904
|
+
* @remarks
|
|
21905
|
+
* If set to true, the text primitive will render the back-face
|
|
21906
|
+
* of the background. Defaults to true but will always be false
|
|
21907
|
+
* if 'useRotation' is set to false.
|
|
21908
|
+
*
|
|
21909
|
+
*/
|
|
21910
|
+
backfaceVisible: boolean;
|
|
21906
21911
|
/**
|
|
21907
21912
|
* @remarks
|
|
21908
21913
|
* The color of the background plate of the text. If set to
|
|
@@ -21926,6 +21931,14 @@ export class TextPrimitive extends PrimitiveShape {
|
|
|
21926
21931
|
*
|
|
21927
21932
|
*/
|
|
21928
21933
|
readonly text: RawMessage | string;
|
|
21934
|
+
/**
|
|
21935
|
+
* @remarks
|
|
21936
|
+
* If set to true, the text primitive will render the back-face
|
|
21937
|
+
* of the text. Defaults to true but will always be false if
|
|
21938
|
+
* 'useRotation' is set to false.
|
|
21939
|
+
*
|
|
21940
|
+
*/
|
|
21941
|
+
textBackfaceVisible: boolean;
|
|
21929
21942
|
/**
|
|
21930
21943
|
* @remarks
|
|
21931
21944
|
* If set to true, the text will not face the camera and
|
|
@@ -21946,7 +21959,6 @@ export class TextPrimitive extends PrimitiveShape {
|
|
|
21946
21959
|
}
|
|
21947
21960
|
|
|
21948
21961
|
/**
|
|
21949
|
-
* @rc
|
|
21950
21962
|
* This manager is used to add, remove or query temporary
|
|
21951
21963
|
* ticking areas to a dimension. These ticking areas are
|
|
21952
21964
|
* limited by a fixed amount of ticking chunks per pack
|
|
@@ -22071,8 +22083,8 @@ export class Trigger {
|
|
|
22071
22083
|
* Contains information related to changes to a trip wire trip.
|
|
22072
22084
|
* @example tripWireTripEvent.ts
|
|
22073
22085
|
* ```typescript
|
|
22074
|
-
* import { world, system, BlockPermutation, TripWireTripAfterEvent, DimensionLocation } from
|
|
22075
|
-
* import { MinecraftBlockTypes } from
|
|
22086
|
+
* import { world, system, BlockPermutation, TripWireTripAfterEvent, DimensionLocation } from '@minecraft/server';
|
|
22087
|
+
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
|
|
22076
22088
|
*
|
|
22077
22089
|
* function tripWireTripEvent(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
22078
22090
|
* // set up a tripwire
|
|
@@ -22084,7 +22096,7 @@ export class Trigger {
|
|
|
22084
22096
|
* const tripwire = targetLocation.dimension.getBlock(targetLocation);
|
|
22085
22097
|
*
|
|
22086
22098
|
* if (redstone === undefined || tripwire === undefined) {
|
|
22087
|
-
* log(
|
|
22099
|
+
* log('Could not find block at location.');
|
|
22088
22100
|
* return -1;
|
|
22089
22101
|
* }
|
|
22090
22102
|
*
|
|
@@ -22096,9 +22108,9 @@ export class Trigger {
|
|
|
22096
22108
|
*
|
|
22097
22109
|
* if (eventLoc.x === targetLocation.x && eventLoc.y === targetLocation.y && eventLoc.z === targetLocation.z) {
|
|
22098
22110
|
* log(
|
|
22099
|
-
*
|
|
22111
|
+
* 'Tripwire trip event at tick ' +
|
|
22100
22112
|
* system.currentTick +
|
|
22101
|
-
* (tripWireTripEvent.sources.length > 0 ?
|
|
22113
|
+
* (tripWireTripEvent.sources.length > 0 ? ' by entity ' + tripWireTripEvent.sources[0].id : '')
|
|
22102
22114
|
* );
|
|
22103
22115
|
* }
|
|
22104
22116
|
* });
|
|
@@ -22127,8 +22139,8 @@ export class TripWireTripAfterEvent extends BlockEvent {
|
|
|
22127
22139
|
* tripped.
|
|
22128
22140
|
* @example tripWireTripEvent.ts
|
|
22129
22141
|
* ```typescript
|
|
22130
|
-
* import { world, system, BlockPermutation, TripWireTripAfterEvent, DimensionLocation } from
|
|
22131
|
-
* import { MinecraftBlockTypes } from
|
|
22142
|
+
* import { world, system, BlockPermutation, TripWireTripAfterEvent, DimensionLocation } from '@minecraft/server';
|
|
22143
|
+
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
|
|
22132
22144
|
*
|
|
22133
22145
|
* function tripWireTripEvent(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
22134
22146
|
* // set up a tripwire
|
|
@@ -22140,7 +22152,7 @@ export class TripWireTripAfterEvent extends BlockEvent {
|
|
|
22140
22152
|
* const tripwire = targetLocation.dimension.getBlock(targetLocation);
|
|
22141
22153
|
*
|
|
22142
22154
|
* if (redstone === undefined || tripwire === undefined) {
|
|
22143
|
-
* log(
|
|
22155
|
+
* log('Could not find block at location.');
|
|
22144
22156
|
* return -1;
|
|
22145
22157
|
* }
|
|
22146
22158
|
*
|
|
@@ -22152,9 +22164,9 @@ export class TripWireTripAfterEvent extends BlockEvent {
|
|
|
22152
22164
|
*
|
|
22153
22165
|
* if (eventLoc.x === targetLocation.x && eventLoc.y === targetLocation.y && eventLoc.z === targetLocation.z) {
|
|
22154
22166
|
* log(
|
|
22155
|
-
*
|
|
22167
|
+
* 'Tripwire trip event at tick ' +
|
|
22156
22168
|
* system.currentTick +
|
|
22157
|
-
* (tripWireTripEvent.sources.length > 0 ?
|
|
22169
|
+
* (tripWireTripEvent.sources.length > 0 ? ' by entity ' + tripWireTripEvent.sources[0].id : '')
|
|
22158
22170
|
* );
|
|
22159
22171
|
* }
|
|
22160
22172
|
* });
|
|
@@ -22468,6 +22480,15 @@ export class World {
|
|
|
22468
22480
|
*
|
|
22469
22481
|
*/
|
|
22470
22482
|
readonly afterEvents: WorldAfterEvents;
|
|
22483
|
+
/**
|
|
22484
|
+
* @beta
|
|
22485
|
+
* @remarks
|
|
22486
|
+
* Enables or disables cheats.
|
|
22487
|
+
*
|
|
22488
|
+
* This property can't be edited in restricted-execution mode.
|
|
22489
|
+
*
|
|
22490
|
+
*/
|
|
22491
|
+
allowCheats: boolean;
|
|
22471
22492
|
/**
|
|
22472
22493
|
* @remarks
|
|
22473
22494
|
* Contains a set of events that are applicable to the entirety
|
|
@@ -22478,23 +22499,23 @@ export class World {
|
|
|
22478
22499
|
*
|
|
22479
22500
|
* @example customCommand.ts
|
|
22480
22501
|
* ```typescript
|
|
22481
|
-
* import { world, DimensionLocation } from
|
|
22502
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
22482
22503
|
*
|
|
22483
22504
|
* function customCommand(targetLocation: DimensionLocation) {
|
|
22484
|
-
* const chatCallback = world.beforeEvents.chatSend.subscribe(
|
|
22485
|
-
* if (eventData.message.includes(
|
|
22505
|
+
* const chatCallback = world.beforeEvents.chatSend.subscribe(eventData => {
|
|
22506
|
+
* if (eventData.message.includes('cancel')) {
|
|
22486
22507
|
* // Cancel event if the message contains "cancel"
|
|
22487
22508
|
* eventData.cancel = true;
|
|
22488
22509
|
* } else {
|
|
22489
|
-
* const args = eventData.message.split(
|
|
22510
|
+
* const args = eventData.message.split(' ');
|
|
22490
22511
|
*
|
|
22491
22512
|
* if (args.length > 0) {
|
|
22492
22513
|
* switch (args[0].toLowerCase()) {
|
|
22493
|
-
* case
|
|
22514
|
+
* case 'echo':
|
|
22494
22515
|
* // Send a modified version of chat message
|
|
22495
22516
|
* world.sendMessage(`Echo '${eventData.message.substring(4).trim()}'`);
|
|
22496
22517
|
* break;
|
|
22497
|
-
* case
|
|
22518
|
+
* case 'help':
|
|
22498
22519
|
* world.sendMessage(`Available commands: echo <message>`);
|
|
22499
22520
|
* break;
|
|
22500
22521
|
* }
|
|
@@ -22528,7 +22549,6 @@ export class World {
|
|
|
22528
22549
|
*/
|
|
22529
22550
|
readonly scoreboard: Scoreboard;
|
|
22530
22551
|
/**
|
|
22531
|
-
* @rc
|
|
22532
22552
|
* @remarks
|
|
22533
22553
|
* The world seed.
|
|
22534
22554
|
*
|
|
@@ -22541,7 +22561,6 @@ export class World {
|
|
|
22541
22561
|
*/
|
|
22542
22562
|
readonly structureManager: StructureManager;
|
|
22543
22563
|
/**
|
|
22544
|
-
* @rc
|
|
22545
22564
|
* @remarks
|
|
22546
22565
|
* Manager for adding, removing and querying pack specific
|
|
22547
22566
|
* ticking areas.
|
|
@@ -22576,7 +22595,6 @@ export class World {
|
|
|
22576
22595
|
*/
|
|
22577
22596
|
getAbsoluteTime(): number;
|
|
22578
22597
|
/**
|
|
22579
|
-
* @rc
|
|
22580
22598
|
* @remarks
|
|
22581
22599
|
* The aim-assist presets and categories that can be used in
|
|
22582
22600
|
* the world.
|
|
@@ -22648,68 +22666,65 @@ export class World {
|
|
|
22648
22666
|
* defined.
|
|
22649
22667
|
* @example incrementDynamicProperty.ts
|
|
22650
22668
|
* ```typescript
|
|
22651
|
-
* import { world, DimensionLocation } from
|
|
22669
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
22652
22670
|
*
|
|
22653
|
-
* function incrementDynamicProperty(
|
|
22654
|
-
*
|
|
22655
|
-
* targetLocation: DimensionLocation
|
|
22656
|
-
* ) {
|
|
22657
|
-
* let number = world.getDynamicProperty("samplelibrary:number");
|
|
22671
|
+
* function incrementDynamicProperty(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
22672
|
+
* let number = world.getDynamicProperty('samplelibrary:number');
|
|
22658
22673
|
*
|
|
22659
|
-
* log(
|
|
22674
|
+
* log('Current value is: ' + number);
|
|
22660
22675
|
*
|
|
22661
22676
|
* if (number === undefined) {
|
|
22662
22677
|
* number = 0;
|
|
22663
22678
|
* }
|
|
22664
22679
|
*
|
|
22665
|
-
* if (typeof number !==
|
|
22666
|
-
* log(
|
|
22680
|
+
* if (typeof number !== 'number') {
|
|
22681
|
+
* log('Number is of an unexpected type.');
|
|
22667
22682
|
* return -1;
|
|
22668
22683
|
* }
|
|
22669
22684
|
*
|
|
22670
|
-
* world.setDynamicProperty(
|
|
22685
|
+
* world.setDynamicProperty('samplelibrary:number', number + 1);
|
|
22671
22686
|
* }
|
|
22672
22687
|
* ```
|
|
22673
22688
|
* @example incrementDynamicPropertyInJsonBlob.ts
|
|
22674
22689
|
* ```typescript
|
|
22675
|
-
* import { world, DimensionLocation } from
|
|
22690
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
22676
22691
|
*
|
|
22677
22692
|
* function incrementDynamicPropertyInJsonBlob(
|
|
22678
22693
|
* log: (message: string, status?: number) => void,
|
|
22679
22694
|
* targetLocation: DimensionLocation
|
|
22680
22695
|
* ) {
|
|
22681
|
-
* let paintStr = world.getDynamicProperty(
|
|
22696
|
+
* let paintStr = world.getDynamicProperty('samplelibrary:longerjson');
|
|
22682
22697
|
* let paint: { color: string; intensity: number } | undefined = undefined;
|
|
22683
22698
|
*
|
|
22684
|
-
* log(
|
|
22699
|
+
* log('Current value is: ' + paintStr);
|
|
22685
22700
|
*
|
|
22686
22701
|
* if (paintStr === undefined) {
|
|
22687
22702
|
* paint = {
|
|
22688
|
-
* color:
|
|
22703
|
+
* color: 'purple',
|
|
22689
22704
|
* intensity: 0,
|
|
22690
22705
|
* };
|
|
22691
22706
|
* } else {
|
|
22692
|
-
* if (typeof paintStr !==
|
|
22693
|
-
* log(
|
|
22707
|
+
* if (typeof paintStr !== 'string') {
|
|
22708
|
+
* log('Paint is of an unexpected type.');
|
|
22694
22709
|
* return -1;
|
|
22695
22710
|
* }
|
|
22696
22711
|
*
|
|
22697
22712
|
* try {
|
|
22698
22713
|
* paint = JSON.parse(paintStr);
|
|
22699
22714
|
* } catch (e) {
|
|
22700
|
-
* log(
|
|
22715
|
+
* log('Error parsing serialized struct.');
|
|
22701
22716
|
* return -1;
|
|
22702
22717
|
* }
|
|
22703
22718
|
* }
|
|
22704
22719
|
*
|
|
22705
22720
|
* if (!paint) {
|
|
22706
|
-
* log(
|
|
22721
|
+
* log('Error parsing serialized struct.');
|
|
22707
22722
|
* return -1;
|
|
22708
22723
|
* }
|
|
22709
22724
|
*
|
|
22710
22725
|
* paint.intensity++;
|
|
22711
22726
|
* paintStr = JSON.stringify(paint); // be very careful to ensure your serialized JSON str cannot exceed limits
|
|
22712
|
-
* world.setDynamicProperty(
|
|
22727
|
+
* world.setDynamicProperty('samplelibrary:longerjson', paintStr);
|
|
22713
22728
|
* }
|
|
22714
22729
|
* ```
|
|
22715
22730
|
*/
|
|
@@ -22805,7 +22820,7 @@ export class World {
|
|
|
22805
22820
|
* {@link minecraftcommon.PropertyOutOfBoundsError}
|
|
22806
22821
|
* @example playMusicAndSound.ts
|
|
22807
22822
|
* ```typescript
|
|
22808
|
-
* import { world, MusicOptions, WorldSoundOptions, PlayerSoundOptions, DimensionLocation } from
|
|
22823
|
+
* import { world, MusicOptions, WorldSoundOptions, PlayerSoundOptions, DimensionLocation } from '@minecraft/server';
|
|
22809
22824
|
*
|
|
22810
22825
|
* function playMusicAndSound(targetLocation: DimensionLocation) {
|
|
22811
22826
|
* const players = world.getPlayers();
|
|
@@ -22815,20 +22830,20 @@ export class World {
|
|
|
22815
22830
|
* loop: true,
|
|
22816
22831
|
* volume: 1.0,
|
|
22817
22832
|
* };
|
|
22818
|
-
* world.playMusic(
|
|
22833
|
+
* world.playMusic('music.menu', musicOptions);
|
|
22819
22834
|
*
|
|
22820
22835
|
* const worldSoundOptions: WorldSoundOptions = {
|
|
22821
22836
|
* pitch: 0.5,
|
|
22822
22837
|
* volume: 4.0,
|
|
22823
22838
|
* };
|
|
22824
|
-
* world.playSound(
|
|
22839
|
+
* world.playSound('ambient.weather.thunder', targetLocation, worldSoundOptions);
|
|
22825
22840
|
*
|
|
22826
22841
|
* const playerSoundOptions: PlayerSoundOptions = {
|
|
22827
22842
|
* pitch: 1.0,
|
|
22828
22843
|
* volume: 1.0,
|
|
22829
22844
|
* };
|
|
22830
22845
|
*
|
|
22831
|
-
* players[0].playSound(
|
|
22846
|
+
* players[0].playSound('bucket.fill_water', playerSoundOptions);
|
|
22832
22847
|
* }
|
|
22833
22848
|
* ```
|
|
22834
22849
|
*/
|
|
@@ -22930,68 +22945,65 @@ export class World {
|
|
|
22930
22945
|
* {@link minecraftcommon.ArgumentOutOfBoundsError}
|
|
22931
22946
|
* @example incrementDynamicProperty.ts
|
|
22932
22947
|
* ```typescript
|
|
22933
|
-
* import { world, DimensionLocation } from
|
|
22948
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
22934
22949
|
*
|
|
22935
|
-
* function incrementDynamicProperty(
|
|
22936
|
-
*
|
|
22937
|
-
* targetLocation: DimensionLocation
|
|
22938
|
-
* ) {
|
|
22939
|
-
* let number = world.getDynamicProperty("samplelibrary:number");
|
|
22950
|
+
* function incrementDynamicProperty(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
22951
|
+
* let number = world.getDynamicProperty('samplelibrary:number');
|
|
22940
22952
|
*
|
|
22941
|
-
* log(
|
|
22953
|
+
* log('Current value is: ' + number);
|
|
22942
22954
|
*
|
|
22943
22955
|
* if (number === undefined) {
|
|
22944
22956
|
* number = 0;
|
|
22945
22957
|
* }
|
|
22946
22958
|
*
|
|
22947
|
-
* if (typeof number !==
|
|
22948
|
-
* log(
|
|
22959
|
+
* if (typeof number !== 'number') {
|
|
22960
|
+
* log('Number is of an unexpected type.');
|
|
22949
22961
|
* return -1;
|
|
22950
22962
|
* }
|
|
22951
22963
|
*
|
|
22952
|
-
* world.setDynamicProperty(
|
|
22964
|
+
* world.setDynamicProperty('samplelibrary:number', number + 1);
|
|
22953
22965
|
* }
|
|
22954
22966
|
* ```
|
|
22955
22967
|
* @example incrementDynamicPropertyInJsonBlob.ts
|
|
22956
22968
|
* ```typescript
|
|
22957
|
-
* import { world, DimensionLocation } from
|
|
22969
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
22958
22970
|
*
|
|
22959
22971
|
* function incrementDynamicPropertyInJsonBlob(
|
|
22960
22972
|
* log: (message: string, status?: number) => void,
|
|
22961
22973
|
* targetLocation: DimensionLocation
|
|
22962
22974
|
* ) {
|
|
22963
|
-
* let paintStr = world.getDynamicProperty(
|
|
22975
|
+
* let paintStr = world.getDynamicProperty('samplelibrary:longerjson');
|
|
22964
22976
|
* let paint: { color: string; intensity: number } | undefined = undefined;
|
|
22965
22977
|
*
|
|
22966
|
-
* log(
|
|
22978
|
+
* log('Current value is: ' + paintStr);
|
|
22967
22979
|
*
|
|
22968
22980
|
* if (paintStr === undefined) {
|
|
22969
22981
|
* paint = {
|
|
22970
|
-
* color:
|
|
22982
|
+
* color: 'purple',
|
|
22971
22983
|
* intensity: 0,
|
|
22972
22984
|
* };
|
|
22973
22985
|
* } else {
|
|
22974
|
-
* if (typeof paintStr !==
|
|
22975
|
-
* log(
|
|
22986
|
+
* if (typeof paintStr !== 'string') {
|
|
22987
|
+
* log('Paint is of an unexpected type.');
|
|
22976
22988
|
* return -1;
|
|
22977
22989
|
* }
|
|
22978
22990
|
*
|
|
22979
22991
|
* try {
|
|
22980
22992
|
* paint = JSON.parse(paintStr);
|
|
22981
22993
|
* } catch (e) {
|
|
22982
|
-
* log(
|
|
22994
|
+
* log('Error parsing serialized struct.');
|
|
22983
22995
|
* return -1;
|
|
22984
22996
|
* }
|
|
22985
22997
|
* }
|
|
22986
22998
|
*
|
|
22987
22999
|
* if (!paint) {
|
|
22988
|
-
* log(
|
|
23000
|
+
* log('Error parsing serialized struct.');
|
|
22989
23001
|
* return -1;
|
|
22990
23002
|
* }
|
|
22991
23003
|
*
|
|
22992
23004
|
* paint.intensity++;
|
|
22993
23005
|
* paintStr = JSON.stringify(paint); // be very careful to ensure your serialized JSON str cannot exceed limits
|
|
22994
|
-
* world.setDynamicProperty(
|
|
23006
|
+
* world.setDynamicProperty('samplelibrary:longerjson', paintStr);
|
|
22995
23007
|
* }
|
|
22996
23008
|
* ```
|
|
22997
23009
|
*/
|
|
@@ -23117,7 +23129,6 @@ export class WorldAfterEvents {
|
|
|
23117
23129
|
*/
|
|
23118
23130
|
readonly entityDie: EntityDieAfterEventSignal;
|
|
23119
23131
|
/**
|
|
23120
|
-
* @rc
|
|
23121
23132
|
* @remarks
|
|
23122
23133
|
* This property can be read in early-execution mode.
|
|
23123
23134
|
*
|
|
@@ -23150,7 +23161,6 @@ export class WorldAfterEvents {
|
|
|
23150
23161
|
*/
|
|
23151
23162
|
readonly entityHitEntity: EntityHitEntityAfterEventSignal;
|
|
23152
23163
|
/**
|
|
23153
|
-
* @rc
|
|
23154
23164
|
* @remarks
|
|
23155
23165
|
* This event fires when an entity is hurt (takes damage).
|
|
23156
23166
|
*
|
|
@@ -23159,7 +23169,6 @@ export class WorldAfterEvents {
|
|
|
23159
23169
|
*/
|
|
23160
23170
|
readonly entityHurt: EntityHurtAfterEventSignal;
|
|
23161
23171
|
/**
|
|
23162
|
-
* @rc
|
|
23163
23172
|
* @remarks
|
|
23164
23173
|
* This event fires when an entity drops items.
|
|
23165
23174
|
*
|
|
@@ -23168,7 +23177,6 @@ export class WorldAfterEvents {
|
|
|
23168
23177
|
*/
|
|
23169
23178
|
readonly entityItemDrop: EntityItemDropAfterEventSignal;
|
|
23170
23179
|
/**
|
|
23171
|
-
* @rc
|
|
23172
23180
|
* @remarks
|
|
23173
23181
|
* This event fires when an entity picks up items.
|
|
23174
23182
|
*
|
|
@@ -23541,23 +23549,23 @@ export class WorldBeforeEvents {
|
|
|
23541
23549
|
*
|
|
23542
23550
|
* @example customCommand.ts
|
|
23543
23551
|
* ```typescript
|
|
23544
|
-
* import { world, DimensionLocation } from
|
|
23552
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
23545
23553
|
*
|
|
23546
23554
|
* function customCommand(targetLocation: DimensionLocation) {
|
|
23547
|
-
* const chatCallback = world.beforeEvents.chatSend.subscribe(
|
|
23548
|
-
* if (eventData.message.includes(
|
|
23555
|
+
* const chatCallback = world.beforeEvents.chatSend.subscribe(eventData => {
|
|
23556
|
+
* if (eventData.message.includes('cancel')) {
|
|
23549
23557
|
* // Cancel event if the message contains "cancel"
|
|
23550
23558
|
* eventData.cancel = true;
|
|
23551
23559
|
* } else {
|
|
23552
|
-
* const args = eventData.message.split(
|
|
23560
|
+
* const args = eventData.message.split(' ');
|
|
23553
23561
|
*
|
|
23554
23562
|
* if (args.length > 0) {
|
|
23555
23563
|
* switch (args[0].toLowerCase()) {
|
|
23556
|
-
* case
|
|
23564
|
+
* case 'echo':
|
|
23557
23565
|
* // Send a modified version of chat message
|
|
23558
23566
|
* world.sendMessage(`Echo '${eventData.message.substring(4).trim()}'`);
|
|
23559
23567
|
* break;
|
|
23560
|
-
* case
|
|
23568
|
+
* case 'help':
|
|
23561
23569
|
* world.sendMessage(`Available commands: echo <message>`);
|
|
23562
23570
|
* break;
|
|
23563
23571
|
* }
|
|
@@ -23578,21 +23586,18 @@ export class WorldBeforeEvents {
|
|
|
23578
23586
|
*/
|
|
23579
23587
|
readonly effectAdd: EffectAddBeforeEventSignal;
|
|
23580
23588
|
/**
|
|
23581
|
-
* @rc
|
|
23582
23589
|
* @remarks
|
|
23583
23590
|
* This property can be read in early-execution mode.
|
|
23584
23591
|
*
|
|
23585
23592
|
*/
|
|
23586
23593
|
readonly entityHeal: EntityHealBeforeEventSignal;
|
|
23587
23594
|
/**
|
|
23588
|
-
* @rc
|
|
23589
23595
|
* @remarks
|
|
23590
23596
|
* This property can be read in early-execution mode.
|
|
23591
23597
|
*
|
|
23592
23598
|
*/
|
|
23593
23599
|
readonly entityHurt: EntityHurtBeforeEventSignal;
|
|
23594
23600
|
/**
|
|
23595
|
-
* @rc
|
|
23596
23601
|
* @remarks
|
|
23597
23602
|
* This event fires before an entity picks up an item.
|
|
23598
23603
|
*
|
|
@@ -23726,7 +23731,6 @@ export interface AABB {
|
|
|
23726
23731
|
}
|
|
23727
23732
|
|
|
23728
23733
|
/**
|
|
23729
|
-
* @rc
|
|
23730
23734
|
* Used to create camera animations.
|
|
23731
23735
|
*/
|
|
23732
23736
|
export interface AnimationOptions {
|
|
@@ -23744,9 +23748,6 @@ export interface AnimationOptions {
|
|
|
23744
23748
|
totalTimeSeconds: number;
|
|
23745
23749
|
}
|
|
23746
23750
|
|
|
23747
|
-
/**
|
|
23748
|
-
* @rc
|
|
23749
|
-
*/
|
|
23750
23751
|
export interface BiomeFilter {
|
|
23751
23752
|
excludeBiomes?: string[];
|
|
23752
23753
|
excludeTags?: string[];
|
|
@@ -23848,7 +23849,6 @@ export interface BlockCustomComponent {
|
|
|
23848
23849
|
*/
|
|
23849
23850
|
onBreak?: (arg0: BlockComponentBlockBreakEvent, arg1: CustomComponentParameters) => void;
|
|
23850
23851
|
/**
|
|
23851
|
-
* @rc
|
|
23852
23852
|
* @remarks
|
|
23853
23853
|
* This function will be called when an entity fires an event
|
|
23854
23854
|
* to this block in the world.
|
|
@@ -24088,7 +24088,6 @@ export interface BlockRaycastOptions extends BlockFilter {
|
|
|
24088
24088
|
}
|
|
24089
24089
|
|
|
24090
24090
|
/**
|
|
24091
|
-
* @rc
|
|
24092
24091
|
* Used to attach the camera to a non player entity.
|
|
24093
24092
|
*/
|
|
24094
24093
|
export interface CameraAttachOptions {
|
|
@@ -24410,6 +24409,35 @@ export interface CustomCommandResult {
|
|
|
24410
24409
|
status: CustomCommandStatus;
|
|
24411
24410
|
}
|
|
24412
24411
|
|
|
24412
|
+
/**
|
|
24413
|
+
* @beta
|
|
24414
|
+
*/
|
|
24415
|
+
export interface CustomTexture {
|
|
24416
|
+
/**
|
|
24417
|
+
* @remarks
|
|
24418
|
+
* The height of the icon, in relative units. Value must be
|
|
24419
|
+
* between 0.0 and 1.0, inclusive.
|
|
24420
|
+
*
|
|
24421
|
+
* Bounds: [0, 1]
|
|
24422
|
+
*/
|
|
24423
|
+
iconHeight: number;
|
|
24424
|
+
/**
|
|
24425
|
+
* @remarks
|
|
24426
|
+
* The width of the icon, in relative units. Value must be
|
|
24427
|
+
* between 0.0 and 1.0, inclusive.
|
|
24428
|
+
*
|
|
24429
|
+
* Bounds: [0, 1]
|
|
24430
|
+
*/
|
|
24431
|
+
iconWidth: number;
|
|
24432
|
+
/**
|
|
24433
|
+
* @remarks
|
|
24434
|
+
* The resource path to the custom texture. This should be a
|
|
24435
|
+
* valid string path to a texture asset.
|
|
24436
|
+
*
|
|
24437
|
+
*/
|
|
24438
|
+
path: string;
|
|
24439
|
+
}
|
|
24440
|
+
|
|
24413
24441
|
/**
|
|
24414
24442
|
* Contains a set of updates to the component definition state
|
|
24415
24443
|
* of an entity.
|
|
@@ -24782,7 +24810,6 @@ export interface EntityFilter {
|
|
|
24782
24810
|
}
|
|
24783
24811
|
|
|
24784
24812
|
/**
|
|
24785
|
-
* @rc
|
|
24786
24813
|
* Contains optional parameters for registering an entity heal
|
|
24787
24814
|
* event.
|
|
24788
24815
|
*/
|
|
@@ -24817,7 +24844,6 @@ export interface EntityHitInformation {
|
|
|
24817
24844
|
}
|
|
24818
24845
|
|
|
24819
24846
|
/**
|
|
24820
|
-
* @rc
|
|
24821
24847
|
* Contains optional parameters for registering an entity hurt
|
|
24822
24848
|
* after event.
|
|
24823
24849
|
*/
|
|
@@ -24853,7 +24879,6 @@ export interface EntityHurtAfterEventOptions {
|
|
|
24853
24879
|
}
|
|
24854
24880
|
|
|
24855
24881
|
/**
|
|
24856
|
-
* @rc
|
|
24857
24882
|
* Contains optional parameters for registering an entity hurt
|
|
24858
24883
|
* before event.
|
|
24859
24884
|
*/
|
|
@@ -24875,7 +24900,6 @@ export interface EntityHurtBeforeEventOptions {
|
|
|
24875
24900
|
}
|
|
24876
24901
|
|
|
24877
24902
|
/**
|
|
24878
|
-
* @rc
|
|
24879
24903
|
* An interface that is passed into {@link
|
|
24880
24904
|
* @minecraft/Server.EntityItemDropAfterEventSignal.subscribe}
|
|
24881
24905
|
* that filters out which events are passed to the provided
|
|
@@ -24899,7 +24923,6 @@ export interface EntityItemDropEventOptions {
|
|
|
24899
24923
|
}
|
|
24900
24924
|
|
|
24901
24925
|
/**
|
|
24902
|
-
* @rc
|
|
24903
24926
|
* An interface that is passed into {@link
|
|
24904
24927
|
* @minecraft/Server.EntityItemPickupAfterEventSignal.subscribe}
|
|
24905
24928
|
* and {@link
|
|
@@ -24928,37 +24951,35 @@ export interface EntityItemPickupEventOptions {
|
|
|
24928
24951
|
* Contains options for selecting entities within an area.
|
|
24929
24952
|
* @example blockConditional.ts
|
|
24930
24953
|
* ```typescript
|
|
24931
|
-
* import { DimensionLocation } from
|
|
24954
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
24932
24955
|
*
|
|
24933
24956
|
* function blockConditional(targetLocation: DimensionLocation) {
|
|
24934
24957
|
* targetLocation.dimension
|
|
24935
24958
|
* .getEntities({
|
|
24936
|
-
* type:
|
|
24959
|
+
* type: 'fox',
|
|
24937
24960
|
* })
|
|
24938
|
-
* .filter(
|
|
24961
|
+
* .filter(entity => {
|
|
24939
24962
|
* const block = targetLocation.dimension.getBlock({
|
|
24940
24963
|
* x: entity.location.x,
|
|
24941
24964
|
* y: entity.location.y - 1,
|
|
24942
24965
|
* z: entity.location.z,
|
|
24943
24966
|
* });
|
|
24944
24967
|
*
|
|
24945
|
-
* return block !== undefined && block.matches(
|
|
24968
|
+
* return block !== undefined && block.matches('minecraft:stone');
|
|
24946
24969
|
* })
|
|
24947
|
-
* .forEach(
|
|
24948
|
-
* targetLocation.dimension.spawnEntity(
|
|
24970
|
+
* .forEach(entity => {
|
|
24971
|
+
* targetLocation.dimension.spawnEntity('salmon', entity.location);
|
|
24949
24972
|
* });
|
|
24950
24973
|
* }
|
|
24951
24974
|
* ```
|
|
24952
24975
|
* @example findEntitiesHavingPropertyEqualsTo.ts
|
|
24953
24976
|
* ```typescript
|
|
24954
|
-
* import { EntityQueryOptions, DimensionLocation } from
|
|
24977
|
+
* import { EntityQueryOptions, DimensionLocation } from '@minecraft/server';
|
|
24955
24978
|
*
|
|
24956
|
-
* function findEntitiesHavingPropertyEqualsTo(
|
|
24957
|
-
* targetLocation: DimensionLocation
|
|
24958
|
-
* ) {
|
|
24979
|
+
* function findEntitiesHavingPropertyEqualsTo(targetLocation: DimensionLocation) {
|
|
24959
24980
|
* // Minecraft bees have a has_nectar boolean property
|
|
24960
24981
|
* const queryOption: EntityQueryOptions = {
|
|
24961
|
-
* propertyOptions: [{ propertyId:
|
|
24982
|
+
* propertyOptions: [{ propertyId: 'minecraft:has_nectar', value: { equals: true } }],
|
|
24962
24983
|
* };
|
|
24963
24984
|
*
|
|
24964
24985
|
* const entities = targetLocation.dimension.getEntities(queryOption);
|
|
@@ -24966,38 +24987,36 @@ export interface EntityItemPickupEventOptions {
|
|
|
24966
24987
|
* ```
|
|
24967
24988
|
* @example playSoundChained.ts
|
|
24968
24989
|
* ```typescript
|
|
24969
|
-
* import { DimensionLocation } from
|
|
24990
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
24970
24991
|
*
|
|
24971
24992
|
* function playSoundChained(targetLocation: DimensionLocation) {
|
|
24972
24993
|
* const targetPlayers = targetLocation.dimension.getPlayers();
|
|
24973
24994
|
* const originEntities = targetLocation.dimension.getEntities({
|
|
24974
|
-
* type:
|
|
24975
|
-
* name:
|
|
24976
|
-
* tags: [
|
|
24977
|
-
* excludeTags: [
|
|
24995
|
+
* type: 'armor_stand',
|
|
24996
|
+
* name: 'myArmorStand',
|
|
24997
|
+
* tags: ['dummyTag1'],
|
|
24998
|
+
* excludeTags: ['dummyTag2'],
|
|
24978
24999
|
* });
|
|
24979
25000
|
*
|
|
24980
|
-
* originEntities.forEach(
|
|
24981
|
-
* targetPlayers.forEach(
|
|
24982
|
-
* player.playSound(
|
|
25001
|
+
* originEntities.forEach(entity => {
|
|
25002
|
+
* targetPlayers.forEach(player => {
|
|
25003
|
+
* player.playSound('raid.horn');
|
|
24983
25004
|
* });
|
|
24984
25005
|
* });
|
|
24985
25006
|
* }
|
|
24986
25007
|
* ```
|
|
24987
25008
|
* @example setScoreboardChained.ts
|
|
24988
25009
|
* ```typescript
|
|
24989
|
-
* import { world, DimensionLocation } from
|
|
25010
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
24990
25011
|
*
|
|
24991
|
-
* function setScoreboardChained(
|
|
24992
|
-
*
|
|
24993
|
-
* ) {
|
|
24994
|
-
* const objective = world.scoreboard.addObjective("scoreObjective1", "dummy");
|
|
25012
|
+
* function setScoreboardChained(targetLocation: DimensionLocation) {
|
|
25013
|
+
* const objective = world.scoreboard.addObjective('scoreObjective1', 'dummy');
|
|
24995
25014
|
* targetLocation.dimension
|
|
24996
25015
|
* .getEntities({
|
|
24997
|
-
* type:
|
|
24998
|
-
* name:
|
|
25016
|
+
* type: 'armor_stand',
|
|
25017
|
+
* name: 'myArmorStand',
|
|
24999
25018
|
* })
|
|
25000
|
-
* .forEach(
|
|
25019
|
+
* .forEach(entity => {
|
|
25001
25020
|
* if (entity.scoreboardIdentity !== undefined) {
|
|
25002
25021
|
* objective.setScore(entity.scoreboardIdentity, -1);
|
|
25003
25022
|
* }
|
|
@@ -25006,20 +25025,20 @@ export interface EntityItemPickupEventOptions {
|
|
|
25006
25025
|
* ```
|
|
25007
25026
|
* @example summonMobChained.ts
|
|
25008
25027
|
* ```typescript
|
|
25009
|
-
* import { DimensionLocation } from
|
|
25028
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
25010
25029
|
*
|
|
25011
25030
|
* function summonMobChained(targetLocation: DimensionLocation) {
|
|
25012
25031
|
* const armorStandArray = targetLocation.dimension.getEntities({
|
|
25013
|
-
* type:
|
|
25032
|
+
* type: 'armor_stand',
|
|
25014
25033
|
* });
|
|
25015
25034
|
* const playerArray = targetLocation.dimension.getPlayers({
|
|
25016
25035
|
* location: { x: 0, y: -60, z: 0 },
|
|
25017
25036
|
* closest: 4,
|
|
25018
25037
|
* maxDistance: 15,
|
|
25019
25038
|
* });
|
|
25020
|
-
* armorStandArray.forEach(
|
|
25021
|
-
* playerArray.forEach(
|
|
25022
|
-
* targetLocation.dimension.spawnEntity(
|
|
25039
|
+
* armorStandArray.forEach(entity => {
|
|
25040
|
+
* playerArray.forEach(player => {
|
|
25041
|
+
* targetLocation.dimension.spawnEntity('pig', {
|
|
25023
25042
|
* x: player.location.x + 1,
|
|
25024
25043
|
* y: player.location.y,
|
|
25025
25044
|
* z: player.location.z,
|
|
@@ -25030,10 +25049,10 @@ export interface EntityItemPickupEventOptions {
|
|
|
25030
25049
|
* ```
|
|
25031
25050
|
* @example bounceSkeletons.ts
|
|
25032
25051
|
* ```typescript
|
|
25033
|
-
* import { EntityQueryOptions, DimensionLocation } from
|
|
25052
|
+
* import { EntityQueryOptions, DimensionLocation } from '@minecraft/server';
|
|
25034
25053
|
*
|
|
25035
25054
|
* function bounceSkeletons(targetLocation: DimensionLocation) {
|
|
25036
|
-
* const mobs = [
|
|
25055
|
+
* const mobs = ['creeper', 'skeleton', 'sheep'];
|
|
25037
25056
|
*
|
|
25038
25057
|
* // create some sample mob data
|
|
25039
25058
|
* for (let i = 0; i < 10; i++) {
|
|
@@ -25041,7 +25060,7 @@ export interface EntityItemPickupEventOptions {
|
|
|
25041
25060
|
* }
|
|
25042
25061
|
*
|
|
25043
25062
|
* const eqo: EntityQueryOptions = {
|
|
25044
|
-
* type:
|
|
25063
|
+
* type: 'skeleton',
|
|
25045
25064
|
* };
|
|
25046
25065
|
*
|
|
25047
25066
|
* for (const entity of targetLocation.dimension.getEntities(eqo)) {
|
|
@@ -25051,20 +25070,20 @@ export interface EntityItemPickupEventOptions {
|
|
|
25051
25070
|
* ```
|
|
25052
25071
|
* @example tagsQuery.ts
|
|
25053
25072
|
* ```typescript
|
|
25054
|
-
* import { EntityQueryOptions, DimensionLocation } from
|
|
25073
|
+
* import { EntityQueryOptions, DimensionLocation } from '@minecraft/server';
|
|
25055
25074
|
*
|
|
25056
25075
|
* function tagsQuery(targetLocation: DimensionLocation) {
|
|
25057
|
-
* const mobs = [
|
|
25076
|
+
* const mobs = ['creeper', 'skeleton', 'sheep'];
|
|
25058
25077
|
*
|
|
25059
25078
|
* // create some sample mob data
|
|
25060
25079
|
* for (let i = 0; i < 10; i++) {
|
|
25061
25080
|
* const mobTypeId = mobs[i % mobs.length];
|
|
25062
25081
|
* const entity = targetLocation.dimension.spawnEntity(mobTypeId, targetLocation);
|
|
25063
|
-
* entity.addTag(
|
|
25082
|
+
* entity.addTag('mobparty.' + mobTypeId);
|
|
25064
25083
|
* }
|
|
25065
25084
|
*
|
|
25066
25085
|
* const eqo: EntityQueryOptions = {
|
|
25067
|
-
* tags: [
|
|
25086
|
+
* tags: ['mobparty.skeleton'],
|
|
25068
25087
|
* };
|
|
25069
25088
|
*
|
|
25070
25089
|
* for (const entity of targetLocation.dimension.getEntities(eqo)) {
|
|
@@ -25074,7 +25093,7 @@ export interface EntityItemPickupEventOptions {
|
|
|
25074
25093
|
* ```
|
|
25075
25094
|
* @example testThatEntityIsFeatherItem.ts
|
|
25076
25095
|
* ```typescript
|
|
25077
|
-
* import { EntityItemComponent, EntityComponentTypes, DimensionLocation } from
|
|
25096
|
+
* import { EntityItemComponent, EntityComponentTypes, DimensionLocation } from '@minecraft/server';
|
|
25078
25097
|
*
|
|
25079
25098
|
* function testThatEntityIsFeatherItem(
|
|
25080
25099
|
* log: (message: string, status?: number) => void,
|
|
@@ -25089,8 +25108,8 @@ export interface EntityItemPickupEventOptions {
|
|
|
25089
25108
|
* const itemComp = item.getComponent(EntityComponentTypes.Item) as EntityItemComponent;
|
|
25090
25109
|
*
|
|
25091
25110
|
* if (itemComp) {
|
|
25092
|
-
* if (itemComp.itemStack.typeId.endsWith(
|
|
25093
|
-
* log(
|
|
25111
|
+
* if (itemComp.itemStack.typeId.endsWith('feather')) {
|
|
25112
|
+
* log('Success! Found a feather', 1);
|
|
25094
25113
|
* }
|
|
25095
25114
|
* }
|
|
25096
25115
|
* }
|
|
@@ -25298,33 +25317,30 @@ export interface EqualsComparison {
|
|
|
25298
25317
|
* Dimension.createExplosion} method.
|
|
25299
25318
|
* @example createNoBlockExplosion.ts
|
|
25300
25319
|
* ```typescript
|
|
25301
|
-
* import { DimensionLocation } from
|
|
25302
|
-
* import { Vector3Utils } from
|
|
25320
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
25321
|
+
* import { Vector3Utils } from '@minecraft/math';
|
|
25303
25322
|
*
|
|
25304
|
-
* function createNoBlockExplosion(
|
|
25305
|
-
* log: (message: string, status?: number) => void,
|
|
25306
|
-
* targetLocation: DimensionLocation
|
|
25307
|
-
* ) {
|
|
25323
|
+
* function createNoBlockExplosion(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
25308
25324
|
* const explodeNoBlocksLoc = Vector3Utils.floor(Vector3Utils.add(targetLocation, { x: 1, y: 2, z: 1 }));
|
|
25309
25325
|
*
|
|
25310
|
-
* log(
|
|
25326
|
+
* log('Creating an explosion of radius 15 that does not break blocks.');
|
|
25311
25327
|
* targetLocation.dimension.createExplosion(explodeNoBlocksLoc, 15, { breaksBlocks: false });
|
|
25312
25328
|
* }
|
|
25313
25329
|
* ```
|
|
25314
25330
|
* @example createExplosions.ts
|
|
25315
25331
|
* ```typescript
|
|
25316
|
-
* import { DimensionLocation } from
|
|
25317
|
-
* import { Vector3Utils } from
|
|
25332
|
+
* import { DimensionLocation } from '@minecraft/server';
|
|
25333
|
+
* import { Vector3Utils } from '@minecraft/math';
|
|
25318
25334
|
*
|
|
25319
25335
|
* function createExplosions(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
25320
25336
|
* const explosionLoc = Vector3Utils.add(targetLocation, { x: 0.5, y: 0.5, z: 0.5 });
|
|
25321
25337
|
*
|
|
25322
|
-
* log(
|
|
25338
|
+
* log('Creating an explosion of radius 15 that causes fire.');
|
|
25323
25339
|
* targetLocation.dimension.createExplosion(explosionLoc, 15, { causesFire: true });
|
|
25324
25340
|
*
|
|
25325
25341
|
* const belowWaterLoc = Vector3Utils.add(targetLocation, { x: 3, y: 1, z: 3 });
|
|
25326
25342
|
*
|
|
25327
|
-
* log(
|
|
25343
|
+
* log('Creating an explosion of radius 10 that can go underwater.');
|
|
25328
25344
|
* targetLocation.dimension.createExplosion(belowWaterLoc, 10, { allowUnderwater: true });
|
|
25329
25345
|
* }
|
|
25330
25346
|
* ```
|
|
@@ -25555,7 +25571,6 @@ export interface ItemCustomComponent {
|
|
|
25555
25571
|
}
|
|
25556
25572
|
|
|
25557
25573
|
/**
|
|
25558
|
-
* @rc
|
|
25559
25574
|
* Contains options for filtering items.
|
|
25560
25575
|
*/
|
|
25561
25576
|
export interface ItemFilter {
|
|
@@ -25731,7 +25746,6 @@ export interface PlayAnimationOptions {
|
|
|
25731
25746
|
}
|
|
25732
25747
|
|
|
25733
25748
|
/**
|
|
25734
|
-
* @rc
|
|
25735
25749
|
* Settings relating to a player's aim-assist targeting.
|
|
25736
25750
|
*/
|
|
25737
25751
|
export interface PlayerAimAssistSettings {
|
|
@@ -25846,7 +25860,6 @@ export interface PlayerVisibilityRules extends EntityVisibilityRules {
|
|
|
25846
25860
|
}
|
|
25847
25861
|
|
|
25848
25862
|
/**
|
|
25849
|
-
* @rc
|
|
25850
25863
|
* Key frame that holds the progress of the camera animation.
|
|
25851
25864
|
*/
|
|
25852
25865
|
export interface ProgressKeyFrame {
|
|
@@ -25912,49 +25925,46 @@ export interface RangeComparison {
|
|
|
25912
25925
|
* import { DimensionLocation, world, BlockPermutation, BlockComponentTypes } from '@minecraft/server';
|
|
25913
25926
|
*
|
|
25914
25927
|
* function placeTranslatedSign(location: DimensionLocation, text: string) {
|
|
25915
|
-
*
|
|
25928
|
+
* const signBlock = location.dimension.getBlock(location);
|
|
25916
25929
|
*
|
|
25917
|
-
*
|
|
25918
|
-
*
|
|
25919
|
-
*
|
|
25920
|
-
*
|
|
25921
|
-
*
|
|
25922
|
-
*
|
|
25930
|
+
* if (!signBlock) {
|
|
25931
|
+
* console.warn('Could not find a block at specified location.');
|
|
25932
|
+
* return;
|
|
25933
|
+
* }
|
|
25934
|
+
* const signPerm = BlockPermutation.resolve('minecraft:standing_sign', { ground_sign_direction: 8 });
|
|
25935
|
+
* signBlock.setPermutation(signPerm);
|
|
25923
25936
|
*
|
|
25924
|
-
*
|
|
25925
|
-
*
|
|
25926
|
-
*
|
|
25927
|
-
*
|
|
25928
|
-
*
|
|
25929
|
-
*
|
|
25937
|
+
* const signComponent = signBlock.getComponent(BlockComponentTypes.Sign);
|
|
25938
|
+
* if (signComponent) {
|
|
25939
|
+
* signComponent.setText({ translate: 'item.skull.player.name', with: [text] });
|
|
25940
|
+
* } else {
|
|
25941
|
+
* console.error('Could not find a sign component on the block.');
|
|
25942
|
+
* }
|
|
25930
25943
|
* }
|
|
25931
25944
|
*
|
|
25932
25945
|
* placeTranslatedSign(
|
|
25933
|
-
*
|
|
25934
|
-
*
|
|
25935
|
-
*
|
|
25936
|
-
*
|
|
25937
|
-
*
|
|
25938
|
-
*
|
|
25939
|
-
*
|
|
25946
|
+
* {
|
|
25947
|
+
* dimension: world.getDimension('overworld'),
|
|
25948
|
+
* x: 0,
|
|
25949
|
+
* y: 0,
|
|
25950
|
+
* z: 0,
|
|
25951
|
+
* },
|
|
25952
|
+
* 'Steve'
|
|
25940
25953
|
* );
|
|
25941
25954
|
* ```
|
|
25942
25955
|
* @example showTranslatedMessageForm.ts
|
|
25943
25956
|
* ```typescript
|
|
25944
|
-
* import { world, DimensionLocation } from
|
|
25945
|
-
* import { MessageFormResponse, MessageFormData } from
|
|
25957
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
25958
|
+
* import { MessageFormResponse, MessageFormData } from '@minecraft/server-ui';
|
|
25946
25959
|
*
|
|
25947
|
-
* function showTranslatedMessageForm(
|
|
25948
|
-
* log: (message: string, status?: number) => void,
|
|
25949
|
-
* targetLocation: DimensionLocation
|
|
25950
|
-
* ) {
|
|
25960
|
+
* function showTranslatedMessageForm(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
25951
25961
|
* const players = world.getPlayers();
|
|
25952
25962
|
*
|
|
25953
25963
|
* const messageForm = new MessageFormData()
|
|
25954
|
-
* .title({ translate:
|
|
25955
|
-
* .body({ translate:
|
|
25956
|
-
* .button1(
|
|
25957
|
-
* .button2(
|
|
25964
|
+
* .title({ translate: 'permissions.removeplayer' })
|
|
25965
|
+
* .body({ translate: 'accessibility.list.or.two', with: ['Player 1', 'Player 2'] })
|
|
25966
|
+
* .button1('Player 1')
|
|
25967
|
+
* .button2('Player 2');
|
|
25958
25968
|
*
|
|
25959
25969
|
* messageForm
|
|
25960
25970
|
* .show(players[0])
|
|
@@ -25964,18 +25974,18 @@ export interface RangeComparison {
|
|
|
25964
25974
|
* return;
|
|
25965
25975
|
* }
|
|
25966
25976
|
*
|
|
25967
|
-
* log(`You selected ${formData.selection === 0 ?
|
|
25977
|
+
* log(`You selected ${formData.selection === 0 ? 'Player 1' : 'Player 2'}`);
|
|
25968
25978
|
* })
|
|
25969
25979
|
* .catch((error: Error) => {
|
|
25970
|
-
* log(
|
|
25980
|
+
* log('Failed to show form: ' + error);
|
|
25971
25981
|
* return -1;
|
|
25972
25982
|
* });
|
|
25973
25983
|
* }
|
|
25974
25984
|
* ```
|
|
25975
25985
|
* @example addTranslatedSign.ts
|
|
25976
25986
|
* ```typescript
|
|
25977
|
-
* import { world, BlockPermutation, BlockSignComponent, BlockComponentTypes, DimensionLocation } from
|
|
25978
|
-
* import { MinecraftBlockTypes } from
|
|
25987
|
+
* import { world, BlockPermutation, BlockSignComponent, BlockComponentTypes, DimensionLocation } from '@minecraft/server';
|
|
25988
|
+
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
|
|
25979
25989
|
*
|
|
25980
25990
|
* function addTranslatedSign(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
25981
25991
|
* const players = world.getPlayers();
|
|
@@ -25985,7 +25995,7 @@ export interface RangeComparison {
|
|
|
25985
25995
|
* const signBlock = dim.getBlock(targetLocation);
|
|
25986
25996
|
*
|
|
25987
25997
|
* if (!signBlock) {
|
|
25988
|
-
* log(
|
|
25998
|
+
* log('Could not find a block at specified location.');
|
|
25989
25999
|
* return -1;
|
|
25990
26000
|
* }
|
|
25991
26001
|
* const signPerm = BlockPermutation.resolve(MinecraftBlockTypes.StandingSign, { ground_sign_direction: 8 });
|
|
@@ -25994,7 +26004,7 @@ export interface RangeComparison {
|
|
|
25994
26004
|
*
|
|
25995
26005
|
* const signComponent = signBlock.getComponent(BlockComponentTypes.Sign) as BlockSignComponent;
|
|
25996
26006
|
*
|
|
25997
|
-
* signComponent?.setText({ translate:
|
|
26007
|
+
* signComponent?.setText({ translate: 'item.skull.player.name', with: [players[0].name] });
|
|
25998
26008
|
* }
|
|
25999
26009
|
* ```
|
|
26000
26010
|
*/
|
|
@@ -26113,7 +26123,6 @@ export interface RGBA extends RGB {
|
|
|
26113
26123
|
}
|
|
26114
26124
|
|
|
26115
26125
|
/**
|
|
26116
|
-
* @rc
|
|
26117
26126
|
* Key frame that holds the rotation of the camera animation.
|
|
26118
26127
|
*/
|
|
26119
26128
|
export interface RotationKeyFrame {
|
|
@@ -26200,7 +26209,6 @@ export interface SpawnEntityOptions {
|
|
|
26200
26209
|
}
|
|
26201
26210
|
|
|
26202
26211
|
/**
|
|
26203
|
-
* @rc
|
|
26204
26212
|
* Collection of key frames for camera animation.
|
|
26205
26213
|
*/
|
|
26206
26214
|
export interface SplineAnimation {
|
|
@@ -26321,8 +26329,8 @@ export interface StructurePlaceOptions {
|
|
|
26321
26329
|
* Contains additional options for teleporting an entity.
|
|
26322
26330
|
* @example teleport.ts
|
|
26323
26331
|
* ```typescript
|
|
26324
|
-
* import { system, DimensionLocation } from
|
|
26325
|
-
* import { MinecraftEntityTypes } from
|
|
26332
|
+
* import { system, DimensionLocation } from '@minecraft/server';
|
|
26333
|
+
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
26326
26334
|
*
|
|
26327
26335
|
* function teleport(targetLocation: DimensionLocation) {
|
|
26328
26336
|
* const cow = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Cow, targetLocation);
|
|
@@ -26339,8 +26347,8 @@ export interface StructurePlaceOptions {
|
|
|
26339
26347
|
* ```
|
|
26340
26348
|
* @example teleportMovement.ts
|
|
26341
26349
|
* ```typescript
|
|
26342
|
-
* import { system, DimensionLocation } from
|
|
26343
|
-
* import { MinecraftEntityTypes } from
|
|
26350
|
+
* import { system, DimensionLocation } from '@minecraft/server';
|
|
26351
|
+
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
|
|
26344
26352
|
*
|
|
26345
26353
|
* function teleportMovement(targetLocation: DimensionLocation) {
|
|
26346
26354
|
* const pig = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Pig, targetLocation);
|
|
@@ -26399,7 +26407,6 @@ export interface TeleportOptions {
|
|
|
26399
26407
|
}
|
|
26400
26408
|
|
|
26401
26409
|
/**
|
|
26402
|
-
* @rc
|
|
26403
26410
|
* A context which provides information about a specific
|
|
26404
26411
|
* ticking area.
|
|
26405
26412
|
*/
|
|
@@ -26439,7 +26446,6 @@ export interface TickingArea {
|
|
|
26439
26446
|
}
|
|
26440
26447
|
|
|
26441
26448
|
/**
|
|
26442
|
-
* @rc
|
|
26443
26449
|
* Options to create a ticking area using the {@link
|
|
26444
26450
|
* TickingAreaManager}.
|
|
26445
26451
|
*/
|
|
@@ -26567,11 +26573,11 @@ export interface WaypointTextureBounds {
|
|
|
26567
26573
|
lowerBound: number;
|
|
26568
26574
|
/**
|
|
26569
26575
|
* @remarks
|
|
26570
|
-
* The {@link WaypointTexture}
|
|
26571
|
-
* range.
|
|
26576
|
+
* The {@link WaypointTexture} or {@link CustomTexture} to
|
|
26577
|
+
* display within this distance range.
|
|
26572
26578
|
*
|
|
26573
26579
|
*/
|
|
26574
|
-
texture: WaypointTexture;
|
|
26580
|
+
texture: CustomTexture | WaypointTexture;
|
|
26575
26581
|
/**
|
|
26576
26582
|
* @remarks
|
|
26577
26583
|
* The upper distance bound for this texture. The texture is
|
|
@@ -26976,13 +26982,20 @@ export class PlaceJigsawError extends Error {
|
|
|
26976
26982
|
private constructor();
|
|
26977
26983
|
}
|
|
26978
26984
|
|
|
26985
|
+
/**
|
|
26986
|
+
* @beta
|
|
26987
|
+
*/
|
|
26988
|
+
// @ts-ignore Class inheritance allowed for native defined classes
|
|
26989
|
+
export class PrimitiveShapeError extends Error {
|
|
26990
|
+
private constructor();
|
|
26991
|
+
}
|
|
26992
|
+
|
|
26979
26993
|
// @ts-ignore Class inheritance allowed for native defined classes
|
|
26980
26994
|
export class RawMessageError extends Error {
|
|
26981
26995
|
private constructor();
|
|
26982
26996
|
}
|
|
26983
26997
|
|
|
26984
26998
|
/**
|
|
26985
|
-
* @rc
|
|
26986
26999
|
* The error returned from invalid {@link TickingAreaManager}
|
|
26987
27000
|
* method calls.
|
|
26988
27001
|
*/
|