Bitmand

Gaming


Drivers

Minecraft Java Server

Minecraft Python API

Minecraft Java edition with Python API on Ubuntu 18.04

Install Java and Python:

$ sudo apt install software-properties-common openjdk-8-jdk-headless python3

Prepare working directory:

$ mkdir pycraft pycraft/server
$ cd pycraft/server/

Download latest Minecraft server version from minecraft.net download server:

$ wget https://launcher.mojang.com/v1/objects/35139deedbd5182953cf1caa23835da59ca3d7cd/server.jar

WRITEME: Build spigot using BuildTools.jar

Agree to EULA:

$ echo "eula=true" > eula.txt

Download RaspberryJuice plugin:

$ mkdir plugins
$ wget -O plugins/raspberryjuice-1.11.jar https://media.forgecdn.net/files/2496/319/raspberryjuice-1.11.jar

Start Minecraft server (with 1G memory limit):

$ java -Xmx1G -Xms1G -jar spigot.jar nogui

While the server is running, open a new terminal and download MCPI libraries:

# IN A NEW TERMINAL!
$ cd pycraft
$ git clone https://github.com/zhuowei/RaspberryJuice.git
$ ln -s RaspberryJuice/src/main/resources/mcpi/api/python/modded/mcpi mcpi

Create test python script - this one creates a bunch of glass blocks on top of each other:

$ echo "import mcpi.minecraft as minecraft" > test.py
$ echo "import mcpi.block as block" >> test.py
$ echo "mc = minecraft.Minecraft.create()" >> test.py
$ echo "for y in range(0, 64):" >> test.py
$ echo "    mc.setBlock(0, y, 4, block.GLASS.id)" >> test.py

Run script:

$ python3 test.py

Join the server and you should see the glass blocks - modify the scripts and run it again to see the changes.


Bitmand - a self-proclaimed Internet Enthusiast!