Minescript mod
Download the latest Minescript mod for Fabric, Forge, and NeoForge at Modrinth or CurseForge.
Python scripts
Installation: Download and unzip the zip files below and move/copy the enclosed Python (.py) script to the minescript folder which is inside the minecraft folder.
Script for drawing screen-aligned text.
Customizations of the rendered text include:
- position (x, y)
- color (24-bit hex string, e.g.0xaabbcc)
- scale (default = 4)
Requires:
minescript v4.0
lib_java v2
Usage as standalone script:
draw_text TEXT [X Y [HEX_COLOR [SCALE]]]
Examples as commands:
draw_text "some text"
draw_text "Hello, world!" 10 10
draw_text "green text" 360 10 0x00ff00
draw_text "hello yellow" 190 100 0xffff00
draw_text "big red" 200 100 0xff0000 32
Example as imported library:
from draw_text import (draw_string, draw_centered_string)
import time
text = draw_string("some white text", x=20, y=20, color=0xffffff, scale=4)
time.sleep(5)
text.x.set_value(25) # Move text to the right.
time.sleep(1)
text.y.set_value(25) # Move text down.
time.sleep(1)
text.color.set_value(0xff0000) # Change text color to red.
text.string.set_value("now it's red") # Change text string.
time.sleep(2)
A Python REPL interpreter in the Minecraft chat with
Java reflection.
If a file is found in any of the directories of the config
variable command_path
from config.txt
with the filename
.interpreter_init.py
, that script is loaded during startup
of the interpreter.
When the interpreter launches, the prompt “>>>” appears
in the Minecraft chat. Enter Python statements or expressions
just as you would in a Python REPL in a terminal.
Put the interpreter in the background by hitting the escape
key or deleting the “>>>” prompt to enter a Minecraft command,
chat message, or Minescript command.
Bring the interpreter to the foreground by pressing “i” while
no GUI screens are visible.
Exit the interpreter by typing “.” at the “>>>” prompt.
Requires:
minescript v4.0
lib_java v2
Usage:
interpreter
Library for using Java reflection from Python, wrapping
the low-level Java API script functions (java_*
).
Requires:
minescript v4.0
Example:
from minescript import (echo, version_info)
from lib_java import (
JavaClass, java_class_map, java_member_map)
# If using a version of Minecraft with obfuscated
# symbols, populate these dictionaries with the
# appropriate mappings, for example:
mc_class_name = version_info().minecraft_class_name
if mc_class_name == "net.minecraft.class_310":
java_class_map.update({
"net.minecraft.client.Minecraft": "net.minecraft.class_310",
})
java_member_map.update({
"getInstance": "method_1551",
"getFps": "method_47599",
})
Minecraft = JavaClass("net.minecraft.client.Minecraft")
minecraft = Minecraft.getInstance()
echo("fps:", minecraft.getFps())
Builds the surface of a sphere out of blocks.
Requirements
Minescript v3.1
command execution: /setblock
, /fill
Usage
\sphere X Y Z RADIUS BLOCK_TYPE
Builds the surface of a sphere centered at location (X, Y, Z) with radius RADIUS made of BLOCK_TYPE.
Version 2 is significantly faster than version 1 due to the use of
BlockPacker and
BlockPack which were introduced in Minescript v3.1.
Example
Creates a sphere centered at the current player with radius 20 made of yellow concrete:
\sphere ~ ~ ~ 20 yellow_concrete
Author: maxuser
Get responses from an AI chatbot that’s aware of your Minecraft surroundings.
Requirements
Minescript v3.1 or higher
lib_nbt v1 or higher
OpenAI API key (run chatbot
and follow instructions for setting up your key)
Usage
Prompt chatbot to get a single response and exit:
\chatbot PROMPT
Run chatbot in “interactive mode” in the background and have it respond to messages that match the regular expression PATTERN, with options to ignore upper/lower case and give the chatbot a name:
\chatbot -i PATTERN [ignorecase] [name=NAME]
In interactive mode, chatbot output is prefixed with >>>
and the bot can be stopped by entering quitbot
into the chat.
Examples
Ask chatbot a question and get a single response:
\chatbot "What am I looking at? And how long until sunrise?"
Run chatbot interactively, responding to chat messages that include the phrase “bot,” with any combination of upper/lower case:
\chatbot -i ".*\bbot,\s" ignorecase
Author: maxuser
Places blocks in creative mode based on the specified PNG image.
Requirements
Minescript v3.1 or higher
pypng (run: pip install pypng
or pip3 install pypng
)
Usage
\image_to_blocks <x> <y> <z> <imagePngFile> \
[<depthPngFile> [dscale=<depthScale>]] <orientation>
\image_to_blocks <x> <y> <z> <imageSpecJsonFile> \
[<imagePngFile>] [<depthPngFile> [dscale=<depthScale>]] \
[<orientation>]
Loads the image at imagePngFile
and sets blocks for each
pixel in the image. If depthPngFile
is specified, its width and
height must match those of imagePngFile
, and must be
greyscale-only format.
depthScale
is an optional factor by which to divide
depth-image values. For example, a value of dscale=25.5
would map a depth-image value of 255 (where 0 is black and
255 is white) to 10.
orientation
must be a comma-delimited string of world
dimensions with optional +/- sign. 2D example: x,-y
maps
image x (first dimension) to world x and image y (second
dimension) to world -y; 3D example: x,-z,y
maps image x (first
dimension) to world x, image y (second dimension) to world -z,
and image depth (third dimension) to world y.
imageSpecJsonFile
can be used as a convenient way to
package a specification for converting an image to blocks.
The filename must end in “.json” and must contain a JSON
object with optional fields: orientation
, color_map
,
depth_map
, depth_scale
, and palette
. The orientation
field is formatted like the orientation
param (see above). The
color_map
and depth_map
fields refer to PNG filenames.
The depth_scale
field is a positive float in the range [0, 255]
for scaling down depth values. The palette
field must be an
array of JSON objects with fields min_alpha
(int in range [0,
255]) and blocks
; blocks
fields may be RGB values encoded
as strings with a leading #
, e.g. #15b215
, and values are
types of blocks, e.g. green_wool
or
oak_leaves[persistent=true]
. Params passed to the
image_to_blocks
command override corresponding entries
in the JSON file.
Author: maxuser
Create a PNG image file and depth map from the top-down view of a volume of blocks.
Requirements
Minescript v3.1 or higher
lib_blockpack_parser v1 or higher
pypng (run: pip install pypng
or pip3 install pypng
)
Usage
\blocks_to_image X1 Y1 Z1 X2 Y2 Z2 LABEL [dscale=DSCALE]
Generates a 2D image in X and Z corresponding to the
top-down view of the volume of blocks from (X1, Y1, Z1) to (X2,
Y2, Z2). The generated image is named <LABEL>.png
, along
with a depth map at <LABEL>-depth.png
and a metadata file
<LABEL>.json
containing a palette that reflects the mapping
between RGB color values and block types.
If dscale is provided, depth values in Y are scaled by <DSCALE>
.
Note: Unique colors are chosen randomly for each block type. In a future version, colors should be chosen to resemble the block color.
Author: maxuser
Library for parsing string-formatted NBT data as a Python dictionary.
Usage
Standalone (run from chat box):
\lib_nbt <nbtString>
Library (imported from another Python script):
import lib_nbt
python_dictionary = lib_nbt.parse_snbt(nbt_string)
Author: maxuser
Library for parsing BlockPack data.
Requirements
Minescript v3.1 or higher
Usage
Functions for creating a BlockPackParser:
BlockPackParser.parse_blockpack(blockpack: BlockPack)
BlockPackParser.parse_base64_data(base64_data: str)
BlockPackParser.parse_binary_data(binary_data: bytes)
Classes:
class BlockPackParser:
palette: List[str] # palette of block types
tiles: List[Tile]
class Tile:
offset: BlockPos # (x, y, z) offset of this tile
def iter_fill_params(self) -> Tuple[BlockPos, BlockPos, int]
def iter_setblock_params(self) -> Tuple[BlockPos, int]
Example
Read blocks from (0, 0, 0) to (100, 100, 100) and print them to
the chat as fill
and setblock
commands:
from minescript import BlockPack, echo
from lib_blockpack_parser import BlockPackParser
blockpack = BlockPack.read_world((0, 0, 0), (100, 100, 100))
parser = BlockPackParser.parse_blockpack(blockpack)
for tile in parser.tiles:
for pos1, pos2, block in tile.iter_fill_params():
echo(f"fill {pos1} {pos2} {parser.palette[block]}")
for pos, block in tile.iter_setblock_params():
echo(f"setblock {pos} {parser.palette[block]}")
Author: maxuser
Sends a message or executes a command at the specified time.
Requirements
- Minescript v2.0 or higher
eval
action requireseval.py
Usage
\timer <time> (chat|echo|execute|eval) <messageOrCommand>
<time>
can be a countdown in hours, minutes, or seconds or a time of day. Supported formats include: 1:23am
, 1:23 PM
, 13:23
, 10s
(seconds), 5m
(minutes), 2h
(hours). Add *
to countdown times to repeat, e.g. 5m*
repeats every 5 minutes. Add *
and a number to repeat that number of times at the given time interval.
Examples
Send a chat at 12 noon:
\timer 12pm chat "FYI: it is now noon"
Send a message to yourself at 12:30:
\timer 12:30pm echo "note to self: time to eat lunch"
Copy blocks labeled “timed_copy” in 2 minutes:
\timer 2m execute "\\copy ~ ~ ~ ~64 ~64 ~64 timed_copy"
(note the double backslash before copy
; this is needed to escape the
backslash within double quotes.)
Set game time to midday every hour:
\timer 1h* execute "/time set day"
Take 3 screenshots 5 seconds apart:
\timer 5s*3 eval "screenshot()"
(note: screenshot() added in Minescript v2.1)
Author: maxuser
Executes the contents of a book interpreted as Python code.
Requirements
Minescript v2.0 or higher
Usage
\execute_book
\execute_book - [<args>]
\execute_book <title> [<args>]
<args>
passed to the book-based script can be read as sys.argv
.
Examples
Executes the book in the player’s hand with no args:
\execute_book
Executes the book in the player’s hand with args foo
and bar
:
\execute_book - foo bar
Executes a book in the player’s inventory with the title
“my python code” passing no args:
\execute_book "my python code"
Executes a book in the player’s inventory with the title
“my python code” passing args foo
and bar
:
\execute_book "my python code" foo bar`
Author: maxuser
Builds the lateral surface of a cylinder out of blocks.
Requirements
command execution (setblock
)
Usage
∖cylinder X Y Z RADIUS HEIGHT BLOCK_TYPE
Builds the lateral surface of a cylinder with a base circle centered at location (X, Y, Z) with radius RADIUS, height HEIGHT, made of BLOCK_TYPE.
Example
Creates a cylinder centered at the player’s current location, with radius 20 blocks, 5 blocks high, made from blocks of yellow concrete:
∖cylinder ~ ~ ~ 20 5 yellow_concrete
Author: maxuser