Script API - v1.21.44

Script API References

The landing page for Minecraft Bedrock Script API Reference contains documentation related to experimental and stable Minecraft Script APIs that interact with a Minecraft world programmatically.

Visit one of the following links to view the full documentation that matches your Minecraft version.

Minecraft Module

The Minecraft module, or the @minecraft/server module, is the main script module to manipulate a Minecraft world, including entities, blocks, dimensions, and more. Here are some features that you can integrate with a script plugin.

Customize Gameplay

A script plugin can customize the experience of gameplay in Minecraft, through accessing and modifying the state of a Minecraft world. From changing weather and game rules for an in-game world to modifying a player's attributes.

Explore the World class to see all the features you can manipulate within the world.

Receiving Events

The Script API can receive events sent by Minecraft to script plugins. An event represents something that is happening inside of a Minecraft world, like a player interacting with an entity. They can be used to create more engaging experiences for players.

Minecraft Script API's events are broken down into the following categories:

  • System Events: Event handlers are triggered when a system-level operation is initiated.
  • World Events: Event handlers are triggered when an event happens within a Minecraft world.

Component Management

The API offers some control over components of an entity, a block, or an item. This includes modifying an inventory container, and player attributes.

A behavior pack can also use Custom Components on blocks and items to create an immersive experience for players. Script plugins can create their functionality across specific blocks and items.

Storing Data in a Minecraft World

The Minecraft module also provides mechanisms for script plugins to store data. The data are stored in a Minecraft world in key/value pairs.

The two mechanisms within Minecraft world storage (accessible through Script API) are as follows:

  • Dynamic Properties: Maintains a separate storage for entities, items and world, that is accessible with only script API per behavior pack.
  • Scoreboards: Stores the score of entities in objectives. An objective tracks a single statistic for entities.
  • Entity Properties: Save data or store values on entities that can be optionally read by Resource Packs.

And many more

There are a lot of features available in that script module for you to explore. You should probably start making your app.

Minecraft UI Module

The @minecraft/server-ui module helps you build simple forms or dialogs, and send them to players. This allows script plugins to collect form-like data in Minecraft.

Action Forms

A form with a list of buttons with captions and images for presenting a set of options to a player.

Message Forms

A form with two-button that are functional for Yes/No or OK/Cancel questions.

Modal Forms

A more flexible "questionnaire-style" list of controls in a form that can be used to take input.

GameTest Framework

One of the sample GameTests from Microsoft's sample GameTest repository on GitHub

GameTest Framework is a toolset available to creators to build and test any new content using the @minecraft/server-gametest script module and the /gametest command in Minecraft. Each GameTest is broken into the following:

  • Register a test: create an environment to conduct a test.
  • Setup a test: Setup the environment to run the test.
  • Validate a test: Evaluate whether a test passed or failed.

Minecraft Editor Module

Bedrock Editor with Editor Samples Add-On in Minecraft Preview v1.21.30 (August 2024)

The Minecraft Editor or the @minecraft/server-editor module is a built-in JavaScript library for Editor extensions to build complex tools to build, edit, and test worlds. Currently, this API is only accessible in Bedrock Preview on Windows.

An Editor extension is a set of resource pack and behavior packs, like .mcaddon files but for Editor, uses this API to perform most actions in the Bedrock Editor.

Here are some examples of what you can achieve with the Extension API:

  • Add built-in Ore UI components & views in the editor UI.
  • Create custom tools in the Editor panel.
  • Register custom actions and hotkeys to use a tool.
  • Export and playtest an Editor project as a playable world.

Minecraft net module

The @minecraft/server-net module in Minecraft Bedrock's Script API allows for server-based HTTP request handling and packet handling specifically within a Bedrock Dedicated Server.

Server Admin Module

The @minecraft/server-admin module manages the administration in a Bedrock Dedicated Server. Its current capabilities include:

  • Load configuration of variables and secrets in the Bedrock Dedicated Server folder.
  • Transfer a player to another Bedrock server.

Debug Utilities Module

A Script API module that is used for debugging purposes. Currently features:

  • Configure performance watchdog timing warnings for a plugin.
  • Provide access to performance-related information for script runtimes.