Script API - v1.21.40

Minecraft Script API (known as Creator API), lets you easily interact your Minecraft world using Add-Ons with JavaScript. The most common use case is to control many things and add complex behavior in a Minecraft world.

The Script API reference provides a list of functionalities Minecraft provides through Script API. If you are new to JavaScript or Minecraft Add-On, start with the guide. Once you have learned the fundamentals, you can use the reference to get more details on individual APIs each script module provides.

Minecraft Bedrock and Minecraft Preview exposes different versions of each script module in Script API, with newer features are introduced in newer versions.

Each set of Script API reference are connected to the overall Minecraft version numbering scheme (for example, 1.21.50), with each reference provides the documentation of all latest Minecraft API modules.

You should choose a version of reference documentation that matches your Minecraft version.

Script API contains multiple modules with separate releases, with each module provides specific functionalities.

  • @minecraft/server (docs) - A module which is essential for managing and interacting with a Minecraft world.

  • @minecraft/server-ui (docs) - A module for creating simple pop-up forms that allow users to provide you with formatted inputs through submissions.

  • @minecraft/server-gametest (docs) - A module for building your own tests in GameTest Framework.

  • @minecraft/server-editor (docs) - A module for interacting with the Minecraft Editor API, and building an Editor extension.

  • @minecraft/server-net (docs) - A module which allows for server-based HTTP request handling, and manages server packets handling within a Bedrock Dedicated Server.

  • @minecraft/server-admin (docs) - A module to manage the administration in a Bedrock Dedicated Server.

  • @minecraft/debug-utilities (docs) - An utility module that is used for debugging purposes.

  • @minecraft/common (docs) - A wrapper around core components of script modules.

Learn about different features Script API provides and explore the reference documentation to bring your idea to life.

Control many things in your Minecraft world

A script plugin can access and modify the state of a Minecraft world. From changing weather and game rules for an in-game world, to modifying attributes of a block, entity, or a player.

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.

Modify Component

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

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

A script plugins to store data using the following APIs in @minecraft/server module.

The three 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.

Block / Item Custom Components

Use the scripting APIs to handle the custom block or item event scenarios that were originally part of "Holiday Creator Features".

MMNEPVFCICPMFPCPTTAAATR