@minecraft/server 2.1.0-beta.1.21.90-preview.21 → 2.1.0-beta.1.21.90-preview.23

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.
Files changed (2) hide show
  1. package/index.d.ts +239 -52
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -227,6 +227,51 @@ export enum CompoundBlockVolumePositionRelativity {
227
227
  Absolute = 1,
228
228
  }
229
229
 
230
+ /**
231
+ * @beta
232
+ * Reasons that the {@link
233
+ * @minecraft/server.ContainerRulesError} was thrown.
234
+ */
235
+ export enum ContainerRulesErrorReason {
236
+ /**
237
+ * @remarks
238
+ * Thrown when trying to add item that was defined in {@link
239
+ * ContainerRules.bannedItems}.
240
+ *
241
+ */
242
+ BannedItem = 'BannedItem',
243
+ /**
244
+ * @remarks
245
+ * Thrown when trying to add item with `Storage Item` component
246
+ * to container with {@link
247
+ * ContainerRules.allowNestedStorageItems} set to false.
248
+ *
249
+ */
250
+ NestedStorageItem = 'NestedStorageItem',
251
+ /**
252
+ * @remarks
253
+ * Thrown when trying to add item not defined in non-empty
254
+ * {@link ContainerRules.allowedItems}.
255
+ *
256
+ */
257
+ NotAllowedItem = 'NotAllowedItem',
258
+ /**
259
+ * @remarks
260
+ * Thrown when trying to add item that pushed the containers
261
+ * weight over the {@link ContainerRules.weightLimit}.
262
+ *
263
+ */
264
+ OverWeightLimit = 'OverWeightLimit',
265
+ /**
266
+ * @remarks
267
+ * Thrown when trying to add item with zero weight defined by
268
+ * the `Storage Weight Modifier` component to container with a
269
+ * defined {@link ContainerRules.weightLimit}
270
+ *
271
+ */
272
+ ZeroWeightItem = 'ZeroWeightItem',
273
+ }
274
+
230
275
  /**
231
276
  * @beta
232
277
  * Reason why custom command registration failed.
@@ -281,64 +326,71 @@ export enum CustomCommandErrorReason {
281
326
  export enum CustomCommandParamType {
282
327
  /**
283
328
  * @remarks
284
- * Command boolean parameter expecting true or false as input.
329
+ * Block type parameter provides a {@link BlockType}.
285
330
  *
286
331
  */
287
- Boolean = 0,
332
+ BlockType = 'BlockType',
288
333
  /**
289
334
  * @remarks
290
- * Command integer parameter.
335
+ * Boolean parameter.
291
336
  *
292
337
  */
293
- Integer = 1,
338
+ Boolean = 'Boolean',
294
339
  /**
295
340
  * @remarks
296
- * Command float parameter.
341
+ * Entity selector parameter provides an {@link Entity}.
297
342
  *
298
343
  */
299
- Float = 2,
344
+ EntitySelector = 'EntitySelector',
300
345
  /**
301
346
  * @remarks
302
- * Command string parameter.
347
+ * Entity type parameter provides an {@link EntityType}.
303
348
  *
304
349
  */
305
- String = 3,
350
+ EntityType = 'EntityType',
306
351
  /**
307
352
  * @remarks
308
- * Command entity selector parameter.
353
+ * Command enum parameter.
309
354
  *
310
355
  */
311
- EntitySelector = 4,
356
+ Enum = 'Enum',
312
357
  /**
313
358
  * @remarks
314
- * Command player selector parameter.
359
+ * Float parameter.
315
360
  *
316
361
  */
317
- PlayerSelector = 5,
362
+ Float = 'Float',
318
363
  /**
319
364
  * @remarks
320
- * Command location parameter.
365
+ * Integer parameter.
321
366
  *
322
367
  */
323
- Location = 6,
368
+ Integer = 'Integer',
324
369
  /**
325
370
  * @remarks
326
- * Command block type parameter expecting a Minecraft block.
371
+ * Item type parameter provides an {@link ItemType}.
327
372
  *
328
373
  */
329
- BlockType = 7,
374
+ ItemType = 'ItemType',
330
375
  /**
331
376
  * @remarks
332
- * Command item name parameter.
377
+ * Location parameter provides a {@link
378
+ * @minecraft/server.Location}.
333
379
  *
334
380
  */
335
- ItemType = 8,
381
+ Location = 'Location',
336
382
  /**
337
383
  * @remarks
338
- * Command enum parameter.
384
+ * Player selector parameter provides a {@link Player}.
385
+ *
386
+ */
387
+ PlayerSelector = 'PlayerSelector',
388
+ /**
389
+ * @remarks
390
+ * String parameter.
339
391
  *
340
392
  */
341
- Enum = 9,
393
+ String = 'String',
342
394
  }
343
395
 
344
396
  /**
@@ -381,7 +433,6 @@ export enum CustomComponentNameErrorReason {
381
433
  }
382
434
 
383
435
  /**
384
- * @rc
385
436
  * An enumeration for the various difficulty levels of
386
437
  * Minecraft.
387
438
  */
@@ -2008,6 +2059,10 @@ export enum ItemComponentTypes {
2008
2059
  *
2009
2060
  */
2010
2061
  Food = 'minecraft:food',
2062
+ /**
2063
+ * @beta
2064
+ */
2065
+ Inventory = 'minecraft:inventory',
2011
2066
  /**
2012
2067
  * @beta
2013
2068
  */
@@ -2899,8 +2954,8 @@ export type EntityComponentTypeMap = {
2899
2954
  export type EntityIdentifierType<T> = [T] extends [never]
2900
2955
  ? VanillaEntityIdentifier
2901
2956
  : T extends string
2902
- ? VanillaEntityIdentifier | T
2903
- : never;
2957
+ ? VanillaEntityIdentifier | T
2958
+ : never;
2904
2959
 
2905
2960
  export type ItemComponentReturnType<T extends string> = T extends keyof ItemComponentTypeMap
2906
2961
  ? ItemComponentTypeMap[T]
@@ -2913,12 +2968,14 @@ export type ItemComponentTypeMap = {
2913
2968
  dyeable: ItemDyeableComponent;
2914
2969
  enchantable: ItemEnchantableComponent;
2915
2970
  food: ItemFoodComponent;
2971
+ inventory: ItemInventoryComponent;
2916
2972
  'minecraft:compostable': ItemCompostableComponent;
2917
2973
  'minecraft:cooldown': ItemCooldownComponent;
2918
2974
  'minecraft:durability': ItemDurabilityComponent;
2919
2975
  'minecraft:dyeable': ItemDyeableComponent;
2920
2976
  'minecraft:enchantable': ItemEnchantableComponent;
2921
2977
  'minecraft:food': ItemFoodComponent;
2978
+ 'minecraft:inventory': ItemInventoryComponent;
2922
2979
  'minecraft:potion': ItemPotionComponent;
2923
2980
  potion: ItemPotionComponent;
2924
2981
  };
@@ -5550,7 +5607,6 @@ export class Camera {
5550
5607
  setCamera(
5551
5608
  cameraPreset: string,
5552
5609
  setOptions?:
5553
- | CameraDefaultOptions
5554
5610
  | CameraFixedBoomOptions
5555
5611
  | CameraSetFacingOptions
5556
5612
  | CameraSetLocationOptions
@@ -5558,6 +5614,23 @@ export class Camera {
5558
5614
  | CameraSetRotOptions
5559
5615
  | CameraTargetOptions,
5560
5616
  ): void;
5617
+ /**
5618
+ * @rc
5619
+ * @remarks
5620
+ * Sets the current active camera for the specified player and
5621
+ * resets the position and rotation to the values defined in
5622
+ * the JSON.
5623
+ *
5624
+ * This function can't be called in read-only mode.
5625
+ *
5626
+ * @param cameraPreset
5627
+ * Identifier of a camera preset file defined within JSON.
5628
+ * @param easeOptions
5629
+ * Options to ease the camera back to its original position and
5630
+ * rotation.
5631
+ * @throws This function can throw errors.
5632
+ */
5633
+ setDefaultCamera(cameraPreset: string, easeOptions?: CameraEaseOptions): void;
5561
5634
  }
5562
5635
 
5563
5636
  /**
@@ -6104,6 +6177,10 @@ export class CompoundBlockVolume {
6104
6177
  */
6105
6178
  export class Container {
6106
6179
  private constructor();
6180
+ /**
6181
+ * @beta
6182
+ */
6183
+ readonly containerRules?: ContainerRules;
6107
6184
  /**
6108
6185
  * @remarks
6109
6186
  * Count of the slots in the container that are empty.
@@ -6132,6 +6209,16 @@ export class Container {
6132
6209
  * Throws if the container is invalid.
6133
6210
  */
6134
6211
  readonly size: number;
6212
+ /**
6213
+ * @beta
6214
+ * @remarks
6215
+ * The combined weight of all items in the container.
6216
+ *
6217
+ * @throws This property can throw when used.
6218
+ *
6219
+ * {@link InvalidContainerError}
6220
+ */
6221
+ readonly weight: number;
6135
6222
  /**
6136
6223
  * @remarks
6137
6224
  * Adds an item to the container. The item is placed in the
@@ -6143,7 +6230,13 @@ export class Container {
6143
6230
  *
6144
6231
  * @param itemStack
6145
6232
  * The stack of items to add.
6146
- * @throws This function can throw errors.
6233
+ * @throws
6234
+ * Won't throw {@link ContainerRules} error for over weight
6235
+ * limit but will instead add items up to the weight limit.
6236
+ *
6237
+ * {@link ContainerRulesError}
6238
+ *
6239
+ * {@link Error}
6147
6240
  */
6148
6241
  addItem(itemStack: ItemStack): ItemStack | undefined;
6149
6242
  /**
@@ -6281,6 +6374,10 @@ export class Container {
6281
6374
  * @throws
6282
6375
  * Throws if either this container or `toContainer` are invalid
6283
6376
  * or if the `fromSlot` or `toSlot` indices out of bounds.
6377
+ *
6378
+ * {@link ContainerRulesError}
6379
+ *
6380
+ * {@link Error}
6284
6381
  * @example moveBetweenContainers.ts
6285
6382
  * ```typescript
6286
6383
  * import { world, EntityInventoryComponent, EntityComponentTypes, DimensionLocation } from "@minecraft/server";
@@ -6325,6 +6422,10 @@ export class Container {
6325
6422
  * @throws
6326
6423
  * Throws if the container is invalid or if the `slot` index is
6327
6424
  * out of bounds.
6425
+ *
6426
+ * {@link ContainerRulesError}
6427
+ *
6428
+ * {@link Error}
6328
6429
  */
6329
6430
  setItem(slot: number, itemStack?: ItemStack): void;
6330
6431
  /**
@@ -6343,6 +6444,10 @@ export class Container {
6343
6444
  * @throws
6344
6445
  * Throws if either this container or `otherContainer` are
6345
6446
  * invalid or if the `slot` or `otherSlot` are out of bounds.
6447
+ *
6448
+ * {@link ContainerRulesError}
6449
+ *
6450
+ * {@link Error}
6346
6451
  */
6347
6452
  swapItems(slot: number, otherSlot: number, otherContainer: Container): void;
6348
6453
  /**
@@ -6364,6 +6469,12 @@ export class Container {
6364
6469
  * @throws
6365
6470
  * Throws if either this container or `toContainer` are invalid
6366
6471
  * or if the `fromSlot` or `toSlot` indices out of bounds.
6472
+ * Won't throw {@link ContainerRules} error for over weight
6473
+ * limit but will instead add items up to the weight limit.
6474
+ *
6475
+ * {@link ContainerRulesError}
6476
+ *
6477
+ * {@link Error}
6367
6478
  * @example transferBetweenContainers.ts
6368
6479
  * ```typescript
6369
6480
  * import { world, EntityInventoryComponent, EntityComponentTypes, DimensionLocation } from "@minecraft/server";
@@ -6744,6 +6855,8 @@ export class ContainerSlot {
6744
6855
  * @throws
6745
6856
  * Throws if the slot's container is invalid.
6746
6857
  *
6858
+ * {@link ContainerRulesError}
6859
+ *
6747
6860
  * {@link InvalidContainerSlotError}
6748
6861
  */
6749
6862
  setItem(itemStack?: ItemStack): void;
@@ -7113,18 +7226,34 @@ export class Dimension {
7113
7226
  */
7114
7227
  getBlock(location: Vector3): Block | undefined;
7115
7228
  /**
7116
- * @beta
7229
+ * @rc
7117
7230
  * @remarks
7231
+ * Gets the first block found above a given block location
7232
+ * based on the given options (by default will find the first
7233
+ * solid block above).
7234
+ *
7118
7235
  * This function can't be called in read-only mode.
7119
7236
  *
7237
+ * @param location
7238
+ * Location to retrieve the block above from.
7239
+ * @param options
7240
+ * The options to decide if a block is a valid result.
7120
7241
  * @throws This function can throw errors.
7121
7242
  */
7122
7243
  getBlockAbove(location: Vector3, options?: BlockRaycastOptions): Block | undefined;
7123
7244
  /**
7124
- * @beta
7245
+ * @rc
7125
7246
  * @remarks
7247
+ * Gets the first block found below a given block location
7248
+ * based on the given options (by default will find the first
7249
+ * solid block below).
7250
+ *
7126
7251
  * This function can't be called in read-only mode.
7127
7252
  *
7253
+ * @param location
7254
+ * Location to retrieve the block below from.
7255
+ * @param options
7256
+ * The options to decide if a block is a valid result.
7128
7257
  * @throws This function can throw errors.
7129
7258
  */
7130
7259
  getBlockBelow(location: Vector3, options?: BlockRaycastOptions): Block | undefined;
@@ -7308,7 +7437,6 @@ export class Dimension {
7308
7437
  */
7309
7438
  getWeather(): WeatherType;
7310
7439
  /**
7311
- * @rc
7312
7440
  * @remarks
7313
7441
  * Places the given feature into the dimension at the specified
7314
7442
  * location.
@@ -7339,7 +7467,6 @@ export class Dimension {
7339
7467
  */
7340
7468
  placeFeature(featureName: string, location: Vector3, shouldThrow?: boolean): boolean;
7341
7469
  /**
7342
- * @rc
7343
7470
  * @remarks
7344
7471
  * Places the given feature rule into the dimension at the
7345
7472
  * specified location.
@@ -12729,6 +12856,24 @@ export class ItemFoodComponent extends ItemComponent {
12729
12856
  static readonly componentId = 'minecraft:food';
12730
12857
  }
12731
12858
 
12859
+ /**
12860
+ * @beta
12861
+ * This component is added to items with the `Storage Item`
12862
+ * component. Can access and modify this items inventory
12863
+ * container.
12864
+ */
12865
+ // @ts-ignore Class inheritance allowed for native defined classes
12866
+ export class ItemInventoryComponent extends ItemComponent {
12867
+ private constructor();
12868
+ /**
12869
+ * @throws This property can throw when used.
12870
+ *
12871
+ * {@link InvalidContainerError}
12872
+ */
12873
+ readonly container: Container;
12874
+ static readonly componentId = 'minecraft:inventory';
12875
+ }
12876
+
12732
12877
  /**
12733
12878
  * @beta
12734
12879
  * When present on an item, this item is a potion item.
@@ -12974,6 +13119,16 @@ export class ItemStack {
12974
13119
  *
12975
13120
  */
12976
13121
  readonly typeId: string;
13122
+ /**
13123
+ * @beta
13124
+ * @remarks
13125
+ * The total weight of all items in the stack plus the weight
13126
+ * of all items in the items container which is defined with
13127
+ * the `Storage Item` component. The weight per item can be
13128
+ * modified by the `Storage Weight Modifier` component.
13129
+ *
13130
+ */
13131
+ readonly weight: number;
12977
13132
  /**
12978
13133
  * @remarks
12979
13134
  * Creates a new instance of a stack of items for use in the
@@ -14256,7 +14411,6 @@ export class Player extends Entity {
14256
14411
  */
14257
14412
  addLevels(amount: number): number;
14258
14413
  /**
14259
- * @rc
14260
14414
  * @remarks
14261
14415
  * For this player, removes all overrides of any Entity
14262
14416
  * Properties on the target Entity. This change is not applied
@@ -14407,7 +14561,6 @@ export class Player extends Entity {
14407
14561
  */
14408
14562
  queueMusic(trackId: string, musicOptions?: MusicOptions): void;
14409
14563
  /**
14410
- * @rc
14411
14564
  * @remarks
14412
14565
  * For this player, removes the override on an Entity Property.
14413
14566
  * This change is not applied until the next tick and will not
@@ -14537,7 +14690,6 @@ export class Player extends Entity {
14537
14690
  */
14538
14691
  setGameMode(gameMode?: GameMode): void;
14539
14692
  /**
14540
- * @rc
14541
14693
  * @remarks
14542
14694
  * For this player, overrides an Entity Property on the target
14543
14695
  * Entity to the provided value. This property must be client
@@ -17503,7 +17655,6 @@ export class StructureManager {
17503
17655
  options?: StructurePlaceOptions,
17504
17656
  ): void;
17505
17657
  /**
17506
- * @rc
17507
17658
  * @remarks
17508
17659
  * Places a partial jigsaw structure in the world. This is
17509
17660
  * useful for debugging connections between jigsaw blocks.
@@ -17547,7 +17698,6 @@ export class StructureManager {
17547
17698
  options?: JigsawPlaceOptions,
17548
17699
  ): BlockBoundingBox;
17549
17700
  /**
17550
- * @rc
17551
17701
  * @remarks
17552
17702
  * Places a jigsaw structure in the world.
17553
17703
  *
@@ -18396,7 +18546,6 @@ export class World {
18396
18546
  */
18397
18547
  getDefaultSpawnLocation(): Vector3;
18398
18548
  /**
18399
- * @rc
18400
18549
  * @remarks
18401
18550
  * Gets the difficulty from the world.
18402
18551
  *
@@ -18648,7 +18797,6 @@ export class World {
18648
18797
  */
18649
18798
  setDefaultSpawnLocation(spawnLocation: Vector3): void;
18650
18799
  /**
18651
- * @rc
18652
18800
  * @remarks
18653
18801
  * Sets the worlds difficulty.
18654
18802
  *
@@ -19366,7 +19514,6 @@ export interface BiomeSearchOptions {
19366
19514
  }
19367
19515
 
19368
19516
  /**
19369
- * @rc
19370
19517
  * A BlockBoundingBox is an interface to an object which
19371
19518
  * represents an AABB aligned rectangle.
19372
19519
  * The BlockBoundingBox assumes that it was created in a valid
@@ -19637,15 +19784,6 @@ export interface BlockRaycastOptions extends BlockFilter {
19637
19784
  maxDistance?: number;
19638
19785
  }
19639
19786
 
19640
- export interface CameraDefaultOptions {
19641
- /**
19642
- * @remarks
19643
- * Sets a set of easing options for the camera.
19644
- *
19645
- */
19646
- easeOptions: CameraEaseOptions;
19647
- }
19648
-
19649
19787
  /**
19650
19788
  * Contains options associated with a camera ease operation.
19651
19789
  */
@@ -19801,6 +19939,42 @@ export interface CompoundBlockVolumeItem {
19801
19939
  volume: BlockVolume;
19802
19940
  }
19803
19941
 
19942
+ /**
19943
+ * @beta
19944
+ * Rules that if broken on container operations will throw an
19945
+ * error.
19946
+ */
19947
+ export interface ContainerRules {
19948
+ /**
19949
+ * @remarks
19950
+ * Defines the items that are exclusively allowed in the
19951
+ * container. If empty all items are allowed in the container.
19952
+ *
19953
+ */
19954
+ allowedItems: string[];
19955
+ /**
19956
+ * @remarks
19957
+ * Determines whether other storage items can be placed into
19958
+ * the container.
19959
+ *
19960
+ */
19961
+ allowNestedStorageItems: boolean;
19962
+ /**
19963
+ * @remarks
19964
+ * Defines the items that are not allowed in the container.
19965
+ *
19966
+ */
19967
+ bannedItems: string[];
19968
+ /**
19969
+ * @remarks
19970
+ * Defines the maximum allowed total weight of all items in the
19971
+ * storage item container. If undefined container has no weight
19972
+ * limit.
19973
+ *
19974
+ */
19975
+ weightLimit?: number;
19976
+ }
19977
+
19804
19978
  /**
19805
19979
  * @beta
19806
19980
  * Define the custom command, including name, permissions, and
@@ -20806,7 +20980,6 @@ export interface ItemCustomComponent {
20806
20980
  }
20807
20981
 
20808
20982
  /**
20809
- * @rc
20810
20983
  * Provides additional options for {@link
20811
20984
  * StructureManager.placeJigsaw}.
20812
20985
  */
@@ -20836,7 +21009,6 @@ export interface JigsawPlaceOptions {
20836
21009
  }
20837
21010
 
20838
21011
  /**
20839
- * @rc
20840
21012
  * Provides additional options for {@link
20841
21013
  * StructureManager.placeJigsawStructure}.
20842
21014
  */
@@ -20962,7 +21134,7 @@ export interface PlayAnimationOptions {
20962
21134
  * A list of players the animation will be visible to.
20963
21135
  *
20964
21136
  */
20965
- players?: string[];
21137
+ players?: Player[];
20966
21138
  /**
20967
21139
  * @remarks
20968
21140
  * Specifies a Molang expression for when this animation should
@@ -21670,6 +21842,24 @@ export class CommandError extends Error {
21670
21842
  private constructor();
21671
21843
  }
21672
21844
 
21845
+ /**
21846
+ * Error thrown if {@link ContainerRules} are broken on
21847
+ * container operations.
21848
+ */
21849
+ // @ts-ignore Class inheritance allowed for native defined classes
21850
+ export class ContainerRulesError extends Error {
21851
+ private constructor();
21852
+ /**
21853
+ * @beta
21854
+ * @remarks
21855
+ * The specific reason the error was thrown.
21856
+ *
21857
+ * This property can be read in early-execution mode.
21858
+ *
21859
+ */
21860
+ reason: ContainerRulesErrorReason;
21861
+ }
21862
+
21673
21863
  /**
21674
21864
  * @beta
21675
21865
  * Error object thrown when CustomCommandRegistry errors occur.
@@ -21845,9 +22035,6 @@ export class NamespaceNameError extends Error {
21845
22035
  reason: NamespaceNameErrorReason;
21846
22036
  }
21847
22037
 
21848
- /**
21849
- * @rc
21850
- */
21851
22038
  // @ts-ignore Class inheritance allowed for native defined classes
21852
22039
  export class PlaceJigsawError extends Error {
21853
22040
  private constructor();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minecraft/server",
3
- "version": "2.1.0-beta.1.21.90-preview.21",
3
+ "version": "2.1.0-beta.1.21.90-preview.23",
4
4
  "description": "",
5
5
  "contributors": [
6
6
  {