@minecraft/server-editor Module

Caution

This module is still in pre-release. It may change or it may be removed in future releases.

Changelog

Manifest Details

{
    "module_name": "@minecraft/server-editor",
    "version": "0.1.0-beta"
}

Available Versions

  • 0.1.0-beta

Enumerations

Type Aliases

Classes

Interfaces

Functions

bindDataSource

bindDataSource(propertyPane: IPropertyPane, target: T): T

Takes the input object (a property bag of values) and bind it to the pane as a data source. UI child elements of the pane will be updated when the values in the object change, and vice versa.

Parameters

  • propertyPane: IPropertyPane

    The property pane to bind the property bag to.

  • target: T

    The property bag to bind to the pane.

Returns T

executeLargeOperation

executeLargeOperation(selection: Selection, operation: (blockLocation: Vector3) => void): Promise<void>

Executes an operation over a selection via chunks to allow splitting operation over multiple game ticks

Parameters

  • selection: Selection

    the selection to iterator over

  • operation: (blockLocation: Vector3) => void

    the operation to apply over each block location

Returns Promise

executeLargeOperationFromIterator

executeLargeOperationFromIterator(blockLocationIterator: BlockLocationIterator, operation: (blockLocation: Vector3) => void): Promise<void>

Executes an operation over a BlockLocationIterator via chunks to allow splitting operation over multiple game ticks

Parameters

  • blockLocationIterator: BlockLocationIterator

    the selection to iterator over

  • operation: (blockLocation: Vector3) => void

    the operation to apply over each block location

Returns Promise

getBlockPickerDefaultAllowBlockList

getBlockPickerDefaultAllowBlockList(): string[]

Returns a string array of the default block types for the Block picker control. Can be used to further filter blocks from the Block picker.

Returns string[] - Default allowed block list

registerEditorExtension

registerEditorExtension(extensionName: string, activationFunction: ActivationFunctionType<PerPlayerStorageType>, shutdownFunction: ShutdownFunctionType<PerPlayerStorageType>, options: IRegisterExtensionOptionalParameters): Extension

Registers an editor extension into Minecraft. This function calls underlying functionality to register an extension but provides helpful and contextual wrappers for individual client lifetimes. The onActivation function is called whenever a client joins a session, while the shutdown is called when a client leaves. There may be other circumstances in which these are called as well based on client state that is an implementation detail of the system.

Parameters

  • extensionName: string
  • activationFunction: ActivationFunctionType
  • shutdownFunction: ShutdownFunctionType
  • options: IRegisterExtensionOptionalParameters

Returns Extension

registerUserDefinedTransactionHandler

registerUserDefinedTransactionHandler(transactionManager: TransactionManager, undoHandler: (payload: T) => void, redoHandler: (payload: T) => void): UserDefinedTransactionHandle<T>

Creates a strongly typed transaction handle to enforce type safety when adding user defined transactions. This function is a wrapper around the more generalized transaction manager API for script based transactions. Any Editor Extension that needs to insert data into the transaction log for undo/redo should use this function to create a handler for the specific type of data that needs to be inserted. When a transaction is undone/redone, the associated handler function will be invoked with a copy of the payload data that was inserted into the log. As a general rule, transaction data should contain 2 things:
1. The data that will be used to perform the operation we're trying to record
2. The data that will be used to restore the state of the program to what it was before the operation.
NOTE/WARNING:
The payload data is serialized to JSON before being inserted into the transaction log and the underlying implementation uses the JSON.stringify() function to serialize the data. Any non-primitive data, such as classes or minecraft native objects will not serialize to JSON properly, so you should avoid using them as payload data.

Parameters

  • transactionManager: TransactionManager

    A reference to the TransactionManager (from the extension context for your extension)

  • undoHandler: (payload: T) => void

    A function that will be invoked when the transaction is undone. The function will be passed a copy of the payload data that was inserted into the transaction log.

  • redoHandler: (payload: T) => void

    A function that will be invoked when the transaction is redone. The function will be passed a copy of the payload data that was inserted into the transaction log.

Returns UserDefinedTransactionHandle - - {@link UserDefinedTransactionHandle} - A strongly typed transaction handle that can be used to add transactions to the transaction manager.

stringFromException

stringFromException(e: unknown): string

Small utility for getting a string from an unknown exception type

Parameters

  • e: unknown

Returns string

Objects

editor

static read-only editor: MinecraftEditor;

Type: MinecraftEditor