File Exchange

image thumbnail


version 2.1 (77.1 KB) by Brendan Cashman
Command Minecraft (TM) from MATLAB using this Toolbox and Minecrat Forge modding software. Contains tools to allow easy modding setup.


Updated 27 Sep 2018

View License

This Add-On exposes static methods to allow MATLAB to send commands to the game. By default, this Add-On will send messages to a Minecraft (running our mod) on localhost at port 57777. The address and port of the running Minecraft can be modified by setting the following environment variables before starting MATLAB:
MW_MINECRAFT_ADDRESS - IP address or hostname where the modded Minecraft is running.
MW_MINECRAFT_LISTENING_PORT - Port to send commands to.

Similarly, before starting the modded Minecraft, the following environment variables can be used to specify the appropriate MATLAB to communicate with:
MW_MATLAB_LISTENING_ADDRESS - IP address or hostname where MATLAB is running.
MW_MATLAB_LISTENING_PORT - Port MATLAB will listen to (defaults to 58777).

The Setup.installForge function can be used to initiate the mod installation. Be sure to install Minecraft before running Setup.installForge.

Cite As

Brendan Cashman (2020). MinecraftToolbox (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

An undiscovered MATLAB gem - hats off to the hack team! I was hoping to use this to exploit the Minecraft graphics engine to create complex and dynamic virtual environments (e.g., entire castles & dungeons respawning in real-time). Alas, it was not to be - the world is re-rendered after the placement of each single block (if you have another hack let me know!). I set it up to create a large maze, but it took all night to run - I guess the result was worthwhile but cannot be updated in real-time. I got it to run using Minecraft forge v1.10.2.

Here's some example code you may wish to try:

im = imread('68fc5593b75bababacb716091c6224c2.jpg');
im = im(:,:,1);

close all

Minecraft.send('/gamerule doMobSpawning false') % disable new animals
Minecraft.send('/gamemode sp')
Minecraft.send('/gamerule doDaylightCycle false')
Minecraft.send('/kill @e[type=!Player]') % kill animals
Minecraft.send('/kill @e[type=Item]') % kill items
Minecraft.send('/tp @a 0 4 0'); % Teleport all players below the cavern
Minecraft.send('/setblock ~ ~-1 ~ diamond_block')

Minecraft.send('/setblock 0 5 0 diamond_block')
Minecraft.send('/setblock 0 4 0 diamond_block')
Minecraft.send('/time set 1000')
Minecraft.send('/weather clear 1000000')

for X = 1:size(im,1)

for Y = 1:size(im,2)

if im(X,Y) == 1

for Z = 4:6 % 0 is bedrock; 4 is 1 above ground
c = ['/setblock ' num2str(X) ' ' num2str(Z) ' ' num2str(Y) ' stone' ];
%c = ['/setblock 0 ' num2str(BLOCK) ' 0 air'];




Updated copyrights.

Addressed reviewer feedback.

MATLAB Release Compatibility
Created with R2018a
Compatible with any release
Platform Compatibility
Windows macOS Linux