How to code Python in Minecraft Java Edition on Mac

Bot Kampa
4 min readApr 5, 2021

--

It’s my dream to use python to interact with minecraft. I found this blog from the author arpruss give me just what I want. At the end of this tutorial you will be able to type /py <module_name> in minecraft to build something fun, like the screenshot below. This tutorial walks you through the installation process step-by-step and end-to-end. There are 3 steps here. Enjoy!

You can type /py to run python script, as shown at the bottom left corner of the screen.

Step 1: Install forge

Visit Minecraft Forge website and download the proper forge version. The author of Raspberry Jam Mod recommended the version 1.12.2. I’d suggest that you use the recommended version, as it will be more stable. Click “Installer” to download the installer file to your computer.

You may need to wait a few seconds before the download link is enabled. Double click on the downloaded .jar file and check ‘Install Client’ and click OK button

After a few minutes it will be done. Congratulations you have forge and ready to install mods!!

You can verify this when opening Minecraft and you should see this version of Forge there.

Select the forge version you installed, click Play. You will see the text at the bottom-left corner indicating it’s using version 1.12.2.

Step 2: Install mod

In this case, we will install Raspberry Jam Mod, but this process is pretty much the same for all the mods you wish to install in the future. First, we need to download the mod from arpruss’s github release.

Download the mod file mods.zip, extract the file and you should see the file structure like this.

~/Downloads/mods├── 1.10│   └── RaspberryJamMod.jar├── 1.10.2│   └── RaspberryJamMod.jar├── 1.11│   └── RaspberryJamMod.jar├── 1.11.2│   └── RaspberryJamMod.jar├── 1.12│   └── RaspberryJamMod.jar├── 1.12.1│   └── RaspberryJamMod.jar├── 1.12.2│   └── RaspberryJamMod.jar├── 1.8│   └── RaspberryJamMod.jar├── 1.8.8│   └── RaspberryJamMod.jar├── 1.8.9│   └── RaspberryJamMod.jar├── 1.9│   └── RaspberryJamMod.jar└── 1.9.4└── RaspberryJamMod.jar

We will only use the most recent version, matched with the forge version 1.12.2 above
~/Downloads/mods/1.12.2/RaspberryJamMod.jar

Copy the most recent directory 1.12.2/RaspberryJamMod.jar to the minecraft “mod directory”, usually located at ~/Library/Application Support/minecraft/mods. When completed, you should see the file structured like below.

~/Library/Application Support/minecraft/mods/1.12.2/RaspberryJamMod.jar

At this point, quit and reopen minecraft so that the mods are picked up by the minecraft program, which can be verified by clicking the Mods button on the screen below and you should see the new mod listed on the left menu.

Step 3: Install python package mcpi

mcpi is a python package to enable you to interface with the minecraft program. The package provides you with a set of python APIs. We don’t need to pip-install the library (I guess that the mod did that for us implicitly when loading the program). Just download the library from arpruss’s github release.

Download python-scripts.zip, extract the file and you should see a new folder mcpipy that stores many python modules. Copy the entire folder and paste it in the minecraft folder, so that, at the end, you will have this structure

~/Library/Application Support/minecraft/mcpipy

Note that this folder provides minecraft with all the python scripts it needs when we call /py <module>. For me, I’m using the mcpi version 1.2.0 that the author arpruss recommended on the blog.

Let’s give it a test

I will go for Single Player, and config the world like this

Now, when you spawn in this new world, type /py donutand you should see a big donut surrounding you like below.

You can type /py to run python script, as shown at the bottom left corner of the screen.

Congratulations! Now you can use python script to change the world in minecraft. You can put your own script, my_awesome_script.py, inside the mcpipy folder, and it should work.

~/Library/Application Support/minecraft/mcpipy/my_awesome_script.py

And Big thanks to arpruss for creating this awesome work for us!

--

--