1
- // Type definition for @minecraft /server-editor 0.3.1
1
+ // Type definition for @minecraft /server-editor 0.3
2
2
/**
3
3
* Manifest details
4
4
* ```json
@@ -77,7 +77,14 @@ declare class ClientEventDispatcher {
77
77
constructor ( _system : System ) ;
78
78
private _system : System ;
79
79
initialize ( ) : Player ;
80
+ /**
81
+ * Dispatches and event of type T with the appropriate payload. See ServerEventPayloadMapping for the
82
+ * correct mapping of payload to server event type
83
+ */
80
84
dispatchEvent ( type : any , payload : any , replacer : any ) : void ;
85
+ /**
86
+ * Fires off all payloads in event queue and removes any tick registration
87
+ */
81
88
flush ( ) : void ;
82
89
}
83
90
declare class ModalToolContainer extends BaseControl {
@@ -312,7 +319,9 @@ declare class BaseInputManager {
312
319
eventDispatcher : ClientEventDispatcher ;
313
320
unregisterAllBindings ( ) : void ;
314
321
}
315
-
322
+ /**
323
+ * @beta
324
+ */
316
325
export class GlobalInputManager extends BaseInputManager {
317
326
registerKeyBinding (
318
327
inputContextId : EditorInputContext ,
@@ -323,10 +332,25 @@ export class GlobalInputManager extends BaseInputManager {
323
332
}
324
333
325
334
declare class BuiltInUIManagerImpl {
335
+ /**
336
+ * Updates the visibility of the control demo
337
+ */
326
338
updateUISettingsPanelVisibility ( visibility : boolean ) : void ;
339
+ /**
340
+ * Updates the visibility of the welcome panel
341
+ */
327
342
updateWelcomePanelVisibility ( visibility : boolean ) : void ;
343
+ /**
344
+ * Navigates to the pause screen
345
+ */
328
346
navigateToPauseScreen ( ) : void ;
347
+ /**
348
+ * Navigates to the documentation site
349
+ */
329
350
navigateToDocumentation ( ) : void ;
351
+ /**
352
+ * Navigates to the feedback site
353
+ */
330
354
navigateToFeedback ( ) : void ;
331
355
}
332
356
@@ -387,18 +411,40 @@ declare class PlayerUISession {
387
411
get builtInUIManager ( ) : BuiltInUIManagerImpl ;
388
412
get eventSubscriptionCache ( ) : BedrockEventSubscriptionCache ;
389
413
}
390
-
414
+ /**
415
+ * The types of actions that are supported. This type corresponds to the expected arguments
416
+ * passed by the onExecute handler of an action.
417
+ * @beta
418
+ */
391
419
export enum ActionTypes {
392
420
NoArgsAction = "NoArgsAction" ,
393
421
MouseRayCastAction = "MouseRayCastAction" ,
394
422
}
395
-
423
+ /**
424
+ * A cache for bedrock event subscriptions. Stores off a subscription by event key, and upon
425
+ * teardown unregisters all subscriptions.
426
+ * @beta
427
+ */
396
428
export class BedrockEventSubscriptionCache {
397
429
constructor ( mEvents : Events ) ;
398
- subscribeToBedrockEvent ( event : string , ...params : any [ ] ) : Function ;
430
+ /**
431
+ * Subcribes to a bedrock event using the key of the desired event. When subscribed, the event handler
432
+ * is both returned, but also cached internally for unsubscription. This means the caller of the subscription
433
+ * does not need to worry about unsubscription since the cache will automatically unsubscribe handlers
434
+ * on overall teardown.
435
+ *
436
+ * @param event - The event on the bedrock APIs to which to subscribe
437
+ * @param params - The parameters to the subscription method for the event. Auto complete will display this for you
438
+ */
439
+ subscribeToBedrockEvent < T extends keyof Events > ( event : T , ...params : Parameters < Events [ T ] [ 'subscribe' ] > ) : ReturnType < Events [ T ] [ 'subscribe' ] > ;
399
440
teardown ( ) : void ;
441
+ private mEvents : Events ;
442
+ private subscribedEvents : object ;
400
443
}
401
-
444
+ /**
445
+ * Type of item that can be added to the property pane
446
+ * @beta
447
+ */
402
448
export enum EDITOR_PANE_PROPERTY_ITEM_TYPE {
403
449
Number = "editorUI:Number" ,
404
450
String = "editorUI:String" ,
@@ -410,24 +456,37 @@ export enum EDITOR_PANE_PROPERTY_ITEM_TYPE {
410
456
Action = "editorUI:Action" ,
411
457
Vec3 = "editorUI:Vec3" ,
412
458
}
413
-
459
+ /**
460
+ * @beta Global editor input contexts
461
+ */
414
462
export enum EditorInputContext {
415
463
GlobalEditor = "global.editor" ,
416
464
GlobalToolMode = "global.toolMode" ,
417
465
Viewport = "local.toolMode.viewport" ,
418
466
}
419
-
467
+ /**
468
+ * Types of events that may be sent by the server to the client side UX. These events each have their own
469
+ * independent set of payloads in the message that may have a wide set of types of operations. This allows messages to
470
+ * be sent with an EventType and Payload, but with easy type safe deduction of the payload type leveraging
471
+ * discriminated unions and type fields.
472
+ * @internal
473
+ */
420
474
export enum EditorServerEventType {
421
475
ServerActionEvents = "Editor::ServerActionEvents" ,
422
476
ServerInputBindingEvents = "Editor::ServerInputBindingEvents" ,
423
477
ServerUXEvents = "Editor::ServerUXEvents" ,
424
478
}
425
-
479
+ /**
480
+ * @beta
481
+ */
426
482
export enum EditorStatusBarAlignment {
427
483
Right = 0 ,
428
484
Left = 1 ,
429
485
}
430
-
486
+ /**
487
+ * Input modifier flags to create chorded bindings
488
+ * @beta
489
+ */
431
490
export enum InputModifier {
432
491
Unused = 0 ,
433
492
None = 1 ,
@@ -436,11 +495,18 @@ export enum InputModifier {
436
495
Shift = 8 ,
437
496
Any = 15 ,
438
497
}
498
+ /**
499
+ * Keyboard Key Actions
500
+ * @beta
501
+ */
439
502
export enum KeyInputType {
440
503
Press = 1 ,
441
504
Release = 2 ,
442
505
}
443
-
506
+ /**
507
+ * Keyboard key - Reference: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode#constants_for_keycode_value
508
+ * @beta
509
+ */
444
510
export enum KeyboardKey {
445
511
BACKSPACE = 8 ,
446
512
TAB = 9 ,
@@ -535,20 +601,29 @@ export enum KeyboardKey {
535
601
BRACKET_CLOSE = 221 ,
536
602
QUOTE = 222 ,
537
603
}
538
-
604
+ /**
605
+ * Mouse device action categories
606
+ * @beta
607
+ */
539
608
export enum MouseActionCategory {
540
609
Button = 1 ,
541
610
Wheel = 2 ,
542
611
Drag = 3 ,
543
612
}
544
-
613
+ /**
614
+ * Detailed mouse device actions
615
+ * @beta
616
+ */
545
617
export enum MouseActionType {
546
618
LeftButton = 1 ,
547
619
MiddleButton = 2 ,
548
620
RightButton = 3 ,
549
621
Wheel = 4 ,
550
622
}
551
-
623
+ /**
624
+ * Input event information about mouse actions
625
+ * @beta
626
+ */
552
627
export enum MouseInputType {
553
628
ButtonDown = 1 ,
554
629
ButtonUp = 2 ,
@@ -558,7 +633,10 @@ export enum MouseInputType {
558
633
Drag = 6 ,
559
634
DragEnd = 7 ,
560
635
}
561
-
636
+ /**
637
+ * The set of events that may be sent by the server side UI pertaining to actions
638
+ * @internal
639
+ */
562
640
export enum ServerUXEventType {
563
641
UpdatePropertyPane = 1 ,
564
642
DestroyPropertyPane = 2 ,
@@ -579,19 +657,40 @@ export enum ServerUXEventType {
579
657
UpdateWelcomePanelVisibility_deprecated = 17 ,
580
658
UpdateClientPanelVisibility = 18 ,
581
659
}
582
-
660
+ /**
661
+ * Takes the input object and bind it to the pane.
662
+ * @beta
663
+ */
583
664
export function createPaneBindingObject < T > (
584
665
propertyPane : PropertyPane ,
585
666
target : T
586
667
) : T ;
587
-
668
+ /**
669
+ * Executes an operation over a selection via chunks to allow splitting operation over multiple game ticks
670
+ * @param selection - the selection to iterator over
671
+ * @param operation - the operation to apply over each block location
672
+ * @beta
673
+ */
588
674
export function executeLargeOperation (
589
675
selection : Selection ,
590
676
operation : ( blockLocation : Vector3 ) => void
591
677
) : Promise < void > ;
592
-
678
+ /**
679
+ * Adds the resource pack editor prefix and returns the full localization ID
680
+ * @beta
681
+ */
593
682
export function getLocalizationId ( locId : string ) : string ;
594
-
683
+ /**
684
+ * Registers an editor extension into Minecraft. This function calls underlying functionality to register an extension but provides
685
+ * helpful and contextual wrappers for individual client lifetimes. The onActivation function is called whenever a client
686
+ * joins a session, while the shutdown is called when a client leaves. There may be other circumstances in which these are
687
+ * called as well based on client state that is an implementation detail of the system.
688
+ *
689
+ * The generic type parameter exists as a mechanism for provide generic player contextual storage of data on the IPlayerUISession
690
+ * object returned during activation. See IPlayerUISession for more information.
691
+ *
692
+ * @beta
693
+ */
595
694
export function registerEditorExtension (
596
695
extensionName : string ,
597
696
activationFunction ?: ( uiSession : PlayerUISession ) => void ,
0 commit comments