upd:
Copy link

Script Interpreter

Thumbnail: Script Interpreter Go to files

Script Interpreter is a debugging tool for Minecraft Scripting. It is a Bedrock add-on allows user to run JаvaScript code in Minecraft Bedrock. This is great to use for debugging, prototyping, and learning JаvaScript and Minecraft's scripting API.

What is Scripting / Script API

Minecraft scripting involves using the JаvaScript (or TypeScript) programming language to create interactive experiences and gameplay mechanics in Minecraft. It is one of the ways to mod Minecraft with Add-Ons.

If you're new to JаvaScript development, you are advised to learn JаvaScript free from online courses available online before writing scripts for Minecraft, such as the following:

You are also advised to learn how to write scripts using Minecraft's Script API before using this add-on, as this add-on is not a tutorial to Script API. Check out Introduction to Scripting in Minecraft for more information.

Script Interpreter Add-On

Script Interpreter Form

This add-on allows developers to debug JаvaScript code and reports an error condition immediately in Minecraft in-game using this interpreter. This reduces the amount of script errors happened in your code development and time, and allows developers to experiment with the new features available in Script API modules in Minecraft.

However you can only run JаvaScript code in this add-on, because the scripting engine only supports JаvaScript.

Here are some examples executing JаvaScript in-game:

  1. This script makes the world / script engine say "running"

Example 1 code

Example 1 result

  • This script shows the script has error.

Example 2 code

Example 2 result

Get it? Cause Aether dimension does not exist in Minecraft.

Script REPL Item

Script REPL Item

You can get the JаvaScript REPL [Use] item through the following methods:

  • Script event command: /scriptevent interpreter:js
  • Chat Command: !jаvascript

Important

This feature is only available behind beta versions of interpreter only.

  1. Use the enchantment book with the name JаvaScript REPL [Use] to open the interpreter.
  2. Type your JаvaScript code in the form. Best thing is that this form has multi-line supported, meaning you can write multiple lines of code here.
  3. Press Submit button to start executing your code.

In case you want to disable your code, you have to run /reload command which requires operator permission to execute the command.

Script Block

Script Block

The Script Block can store and execute JаvaScript code in a Minecraft world. It cannot be obtained or used in Survival mode without cheats.

Obtaining

The script blocks can either be obtained by using various commands, such as /give @s interpreter:script_block or /setblock ~ ~ ~ interpreter:script_block, or by pressing the pick block control on an existing script block.

Script blocks are not flammable, and have the same blast resistance as bedrock. They cannot cannot be mined in Survival mode, however they can be pushed with pistons and sticky pistons and the data inside the block persists.

Script Block Usage

A script block can execute JаvaScript code when activated by pressure plates and buttons currently. Script output is displayed when player activates the script block.

Modification

To enter command or modify the script block, players must interact with the script block. The scripts can be entered in the text input within the modal form. The text limit for scripts in a script block is 32,767 characters, you can scroll through lines of code just like the NPC text prompt UI.

Scripts in a script block do not need to be prefixed with imports (e.g. import { world } from "@minecraft/server") as they do in the actual JаvaScript files.

When finished inputing JаvaScript code, save the code into the script block by pressing 'Save' button. Upon pressing the button it will not immediately execute scripts unlike the Script REPL item.

Startup Scripts

Startup Script Form

This add-on allows you to add scripts to run automatically when Minecraft loads the add-on. Here's how:

  1. Open Startup Scripts form by typing /function repl/startup, and hitting Enter.
  2. Click on 'Create New' button on the form.
  3. A new form appears with an input field, give your task a name (e.g., "Run Block Filling Procedure") and check Add Script Code to write scripts for the task.
  4. press 'Add Script Code', which redirects you to write some scripts for the task.
  5. After writing the script, Click 'Save Scripts' to finish setting it up.

This should automatically launch the task when you load the add-on.

Chat Commands (Beta)

The add-on also provides chat commands that is locked behind Script REPL beta versions.

  • !help: Help Command
  • !interpreter: Opens Interpreter
    This command requires operator permission.
  • !jаvascript: Opens a JаvaScript REPL
    This command requires operator permission.
  • !version: Displays the version of the interpreter
    This command requires operator permission.

Shutdown Scripts (Beta)

Important: This feature is only available to interpreters v1.21.70-beta or above.

Shutdown Script Form

This add-on allows you to add scripts to run automatically when Minecraft is shutting down. Here's how:

  1. Open shutdown Scripts form by typing /function repl/shutdown, and hitting Enter.
  2. Click on 'Create New' button on the form.
  3. A new form appears with an input field, give your task a name (e.g., "Run Cleanup Procedure") and check Add Script Code to write scripts for the task.
  4. press 'Add Script Code', which redirects you to write some scripts for the task.
  5. After writing the script, Click 'Save Scripts' to finish setting it up.

This should automatically launch the task when the world shuts, or when before shutdown event is called.

Trailer

This is a very old showcase video of the add-on, fun fact the video includes the ability to run TypeScript code because this add-on used to be able to run TypeScript code.

Installation

First you go to the download section download Script Interpreter (with or without experimentals), then the add-on will be downloaded to your device.

Downloads for Minecraft Preview or Minecraft Education are available here.

Using Interpreter with Beta API features

Import the add-on to Minecraft.

Important

Enable Beta APIs experiments in world settings. These experiments are needed to run Script REPL with Beta API features.

Required Experiments

Using Interpreter without Beta API features

No experimental toggles needed to be enabled.

Enable Script Modules

Check this guide on Enabling Script Modules for more infomation.

Using Script Interpreter in Bedrock Dedicated Servers

The Bedrock Dedicated Server version of the Script Interpreter Add-On allows players to access higher levels of Script APIs. The following modules are exclusive to Bedrock Dedicated Servers:

  • @minecraft/server-net module - Can send HTTP requests from the Bedrock server, and inspect Bedrock server packets.
  • @minecraft/diagnostics module - Contains diagnostics functionality for reporting bugs to Sentry.
  • @minecraft/debug-utilities module - It's enabled on Minecraft clients but not Bedrock Dedicated Servers or Minecraft Realms by default.

Enable modules in Bedrock Dedicated Servers

Check this guide on Enabling modules in Bedrock Dedicated Servers for more infomation.

Updated on March 15

What's Changed:

  • Added support for Minecraft v1.21.60 and Minecraft Preview v1.21.70.
  • Removed internal debugging tools for Script Interpreter add-on.
  • Added Startup and Shutdown Scripts.
Changelog for October 26 / Old Update

What's Changed:

  • Added support for Minecraft Preview v1.21.50.
  • Removed early prototype code for internal debugging tools for Script REPL add-on.
  • Fixed a bug where stable version of Script REPL add-on uses Beta APIs.
  • Added another version of Script REPL add-on: Bedrock Dedicated Server build.
Changelog for September 24 / Old Update

What's Changed:

  • Updated the add-on to support Minecraft v1.21.30 and v1.21.40.
  • Fix a bug where !interpreter doesn't work as intended.
  • Performance improvements.
  • Using @minecraft/math v1.4.0.
  • Added the following chat command:
    • !help: Help command.
    • !interpreter: Opens interpreter.
    • !jаvascript: Opens a JаvaScript REPL.
    • !version: Displays the version of the interpreter.
Changelog for August 31 / Old Update

What's Changed:

  • Updated the add-on to support Minecraft v1.21.20.
  • Various bug fixes.
  • Added beta version of the add-on to content files section.
Changelog for August 22 / Old Update

What's Changed:

  • Updated the add-on to support Minecraft Education v1.21.0, and Minecraft Preview v1.21.30.
Changelog for July 07 / Old Update
  • Fix a bug where buttons and levers not properly firing JаvaScript code from script block.
  • Fix an issue with isOp()
  • Updated changes to v1.21.20 and v1.21.0 builds.
Download links
Download Minecraft Script Interpreter Add-On
Download Enable Experiments Resource Pack (for Minecraft Education only)
Support Discord Server
Supported versions
1.21.60 1.21.50
Tags
1 186
7 comments
Cancel
  1. Hi there, I absolutely love this add-on despite the complexity lol. I mostly use the Script Block in this add-on for complexifying the way on how vanilla Commands were executed in traditional Command Blocks. However, I would like to know if you could make it so that you could direct redstone power towards the Script Block or maybe even make it so that it could also execute the jаvascript from a full block that is also strong powered by a redstone component? You know what I mean, right? 😅
    That would be so cool to see that happen in the future updates since there is a block of this jаvascript programming add-on.
  2. No avatar image 尊者大帝 Guest
    6666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
  3. Update 1.21.30
  4. No avatar image guest ctabdul15 Guest
    Is there a limit to write?
  5. No entiendo este complemento
  6. Mevo profile avatar Mevo
    Really nice add-on
  7. Yo that's really cool (and useful 🙏), GG!
*}