Skip to content

Instantly share code, notes, and snippets.

@noahcoad
Last active March 2, 2024 22:02
Show Gist options
  • Star 37 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save noahcoad/fc9d3984a5d4d61648269c0a9477c622 to your computer and use it in GitHub Desktop.
Save noahcoad/fc9d3984a5d4d61648269c0a9477c622 to your computer and use it in GitHub Desktop.
Code Minecraft with Python on Mac OSX

Code Minecraft with Python on Mac OSX

Here's a step-by-step to get started scripting Minecraft with Python on Mac OSX

Overview

There was a special build of Minecraft for the Raspberry Pi called Minecraft Pi that had a Python interface and library. You could code in Python to manipulate your Minecraft world! But you'd have to code on a Raspberry Pi computer. However thanks to using the RaspberryJuice plugin with a Spigot server, you can do this locally on a Mac. Probably in Linux or Windows too, but I'll leave that up to you.

Here we have a rainbow created by the rainbox script. rainbow

Step-by-step

# guide for Minecraft v1.13.1 server
# update minecraft server and spigot links for latest versions
 
# get started
mkdir minecraft_py; cd minecraft_py; mkdir spigot; cd spigot
 
# download minecraft server from https://minecraft.net/en-us/download/server/
wget https://launcher.mojang.com/v1/objects/fe123682e9cb30031eae351764f653500b7396c9/server.jar
 
# download spigot server from https://getbukkit.org/download/spigot
wget -O spigot.jar https://cdn.getbukkit.org/spigot/spigot-1.13.1.jar
 
# agree to eula
echo eula=true > eula.txt
 
# get RaspberryJuice from https://dev.bukkit.org/projects/raspberryjuice
mkdir plugins; cd plugins
wget -O raspberryjuice-1.11.jar https://dev.bukkit.org/projects/raspberryjuice/files/2496319/download
 
# get the mcpi libraries from https://github.com/zhuowei/RaspberryJuice
cd ../..
git clone https://github.com/zhuowei/RaspberryJuice.git
mkdir py
cp -r RaspberryJuice/src/main/resources/mcpi/api/python/modded/mcpi py/
 
# download an example python script from https://www.dropbox.com/s/k29ms42nzvgehjk/rainbow.py?dl=0
# alternatively see example here https://dev.bukkit.org/projects/raspberryjuice
cd py
wget -O rainbow.py https://www.dropbox.com/s/k29ms42nzvgehjk/rainbow.py\?dl\=1
 
# run spigot
cd ../spigot; java -jar spigot.jar
 
# in a new terminal under the minecraft_py/py folder
python2 rainbow.py

You're Running!

Start minecraft making sure the version matches (1.13.1 in this case), go into multiplayer mode, add a server with address: localhost

Connect, look around you, and you'll see the rainbow!

Want a first challenge? try making the rainbow thicker =)

Also

@redsnapper73
Copy link

When I tried to do the first teleportations I stumbled about a mismatch in the coordinates between the ones shown in the Minecraft window and the ones entered in Python script (mc.setPos(x,y,z)). Just enter 'setworldspawn 0 0 0' in the server console, then everything works fine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment