Script REPL Add-On
Go to filesScript REPL (read–eval–print loop) add-on is a debugging tool for Minecraft Scripting, that allows user to run JаvaScript code in Minecraft: Bedrock Edition. This powerful add-on is great to use for debugging, prototyping, and learning JаvaScript and Minecraft's scripting API.
Currenly, JаvaScript is the only programming language that allow developers to use Script APIs from within their code.
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.
Learning Minecraft's Script API
You are advised to learn jаvascript free from online courses available online before learning how to use Minecraft's Scripting API. Check out the download page for more infomation.
There are somewhat decent amount of resources available online related to script API. Important links have a ⭐.
- ⭐ Official Script API Documentation - Microsoft's official documentation of high-level introduction of experimental Script API.
- Jayly's Script API Documentation - Jayly's Script API documentation with guides and easy to use and understand API references for programming beginners.
- Script API Examples - JаvaScript code snippets that uses Script API modules only.
Click here for a list of links related to resources for Minecraft Script API.
Add-On Usage Examples
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
Note
This feature is not available to Script REPL v1.21.0 without Beta APIs experiment.
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.
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.
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 and click "Download Script REPL" (with or without experimentals), then the add-on will be downloaded to your device.
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.
What APIs the REPL supports
Each invidiual version of Script REPL supports various fields of the APIs. Each version of script REPL have the latest version of script modules as the dependency on their channels:
- Script REPL (Latest + Beta APIs):
@minecraft/server
:1.16.0-beta
@minecraft/server-ui
:1.4.0-beta
@minecraft/server-gametest
:1.0.0-beta
@minecraft/debug-utilities
:1.0.0-beta
- Script REPL (Latest):
@minecraft/server
:1.15.0
@minecraft/server-ui
:1.3.0
- Script REPL (Preview + Beta APIs):
@minecraft/server
:1.17.0-beta
@minecraft/server-ui
:1.4.0-beta
@minecraft/server-gametest
:1.0.0-beta
@minecraft/debug-utilities
:1.0.0-beta
- Script REPL (Preview):
@minecraft/server
:1.16.0
@minecraft/server-ui
:1.3.0
- Script REPL (Preview, Bedrock Server build):
@minecraft/server
:1.17.0-beta
@minecraft/server-ui
:1.4.0-beta
@minecraft/server-gametest
:1.0.0-beta
@minecraft/debug-utilities
:1.0.0-beta
@minecraft/server-net
:1.0.0-beta
@minecraft/server-admin
:1.0.0-beta
Note
All versions of Script REPL also loads external npm packages such as
@minecraft/vanilla-data
and@minecraft/math
(using v1.4.0) when executing jаvascript code.
Bedrock Dedicated Server Build
Caution
The Script REPL Add-On support for using Bedrock Dedicated Server exclusive APIs are currently experimental.
Important
This version of the Script REPL add-on do not function within the Minecraft game client or within Minecraft Realms.
The Bedrock Dedicated Server version of the Script REPL Add-On allows players to access higher levels of Script APIs, specifically the @minecraft/server-net
module and the @minecraft/server-admin
module. These modules are exclusive to Bedrock Dedicated Servers.
The @minecraft/server-net
module can send HTTP requests from the Bedrock server, and inspect Bedrock server packets.
The @minecraft/server-admin
module can administe a Bedrock Dedicated Server, including transfer players to another Bedrock server.
Enable modules in BDS
To use this add-on, you would have to enable some modules in the Bedrock Dedicated Server folder. This allows this version of the add-on to be used.
Install Bedrock Dedicated Server:
- If you haven't already, download the Bedrock Dedicated Server package from the Minecraft website.
- Extract the zip file on a folder.
bedrock-server │ allowlist.json │ bedrock_server.exe │ bedrock_server_how_to.html │ permissions.json │ release-notes.txt │ server.properties │ ├─behavior_packs ├─config │ └─default │ permissions.json │ ├─definitions └─resource_packs
3. In the permissions.json file, which is located in config/<pack_id>/permissions.json
or config/default/permissions.json
, enable @minecraft/server-net
module, the @minecraft/server-admin
module and the @minecraft/debug-utilities
module by adding the following in the allowed_modules key. These module is not enabled by default in the server.
{ "allowed_modules": [ "@minecraft/server-gametest", "@minecraft/server", "@minecraft/server-ui", "@minecraft/server-admin", "@minecraft/server-net", "@minecraft/debug-utilities", "@minecraft/server-editor" ] }
Full file (config/default/permissions.json
):
{ "allowed_modules": [ "@minecraft/server-gametest", "@minecraft/server", "@minecraft/server-ui", "@minecraft/server-admin", "@minecraft/server-net", "@minecraft/debug-utilities", "@minecraft/server-editor" ] }
Important
- Modifying the files in the default config folder allows every add-on with the server-net module to have access to the @minecraft/server-net module.
- It is recommended to assign individual permissions for each script behavior pack.
4. Enable Beta APIs in world settings. It's recommended to enable this setting in Minecraft clients.
Updated on October 26
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.