Skip to content

Instantly share code, notes, and snippets.

@bendavis78
Last active April 4, 2023 15:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save bendavis78/37a2e8006c430dcd9b1194f63a62046d to your computer and use it in GitHub Desktop.
Save bendavis78/37a2e8006c430dcd9b1194f63a62046d to your computer and use it in GitHub Desktop.

Using Python w/ Minecraft on Ubuntu

These instructions should work on any Ubuntu-based OS, but have only been tested on GalliumOS.

Install required packages

Copy and paste the following line into a terminal and press enter to install all the dependencies (you might already have some installed):

sudo apt update
sudo apt install python-software-properties python3 python3-pip idle3 git
sudo apt install openjdk-8-jre-headless openjdk-8-jdk maven

Install minecraft

sudo add-apt-repository ppa:flexiondotorg/minecraft
sudo apt update
sudo apt install minecraft

At this point, you can run the "minecraft" command to see if you can run and play the game.

Install Spigot and RaspberryJuice

Spigot is a popular minecraft server that allows modding. RaspberryJuice is a Spigot plugin that allows modding with Python.

Make note of your current minecraft version (you can check it in the game launcher) and use it for the --rev argument when building Spigot.

mkdir ~/spigot
cd ~/spigot
wget "https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar"
git config --global --unset core.autocrlf
java -jar BuildTools.jar --rev 1.12.2

This will take a while to build.

Download and build RaspberryJuice and install it into the spigot plugins dir:

git clone https://github.com/zhuowei/RaspberryJuice ~/spigot/RaspberryJuice
cd ~/spigot/RaspberryJuice
mvn package
mkdir ~/spigot/plugins
cp ~/spigot/RaspberryJuice/jars/raspberryjuice-1.11.jar ~/spigot/plugins/
echo "eula=true" > ~/spigot/eula.txt

Create the following startup shell script in ~/spigot/start.sh

#!/bin/sh
java -Xms512M -Xmx1024M -jar /home/spigot/spigot-1.12.2.jar

Install the py3minepi library

Install the latest version of py3minepi from github:

sudo pip3 install git+https://github.com/py3minepi/py3minepi/

Test everything out

  1. Start your spigot server in a terminal window: ~/spigot/start.sh
  2. Start the minecraft launcher, log in, and press Play.
  3. Select "Multiplayer"
  4. Select "Direct Connect"
  5. Type in "localhost" and Select "Join Server"

Then, run idle3 (python shell) and test out a simple "Hello World" message:

>>> from mcpi.minecraft import Minecraft
>>> mc = Minecraft.create()
>>> mc.postToChat('Hello World!')

Quickly switch back to your game, and you should see "Hello World!" pop up in a chat message.

@evanwsun
Copy link

You need to set online-mode=false in Spigot's server.properties file to avoid pinging the Mojang login servers.

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