
Script Interpreter

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:
- Beginner's Series to JаvaScript from Microsoft
- MDN JаvaScript: JаvaScript language overview
- Codecademy: Introduction to JаvaScript
- freeCodeCamp.org: JаvaScript Algorithms and Data Structures
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
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:
- This script makes the world / script engine say "running"
- This script shows the script has error.
Get it? Cause Aether dimension does not exist in Minecraft.
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.
- Use the enchantment book with the name
JаvaScript REPL [Use]
to open the interpreter. - 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.
- 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
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
This add-on allows you to add scripts to run automatically when Minecraft loads the add-on. Here's how:
- Open Startup Scripts form by typing
/function repl/startup
, and hitting Enter. - Click on 'Create New' button on the form.
- 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.
- press 'Add Script Code', which redirects you to write some scripts for the task.
- 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.
This add-on allows you to add scripts to run automatically when Minecraft is shutting down. Here's how:
- Open shutdown Scripts form by typing
/function repl/shutdown
, and hitting Enter. - Click on 'Create New' button on the form.
- 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.
- press 'Add Script Code', which redirects you to write some scripts for the task.
- 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.
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.
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.
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.
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.
What's Changed:
- Updated the add-on to support Minecraft Education v1.21.0, and Minecraft Preview v1.21.30.
- 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.