3 Minecraft Pi
Geoff Bourne edited this page 2021-03-21 17:31:55 -05:00

Minecraft-Pi Spigot Server

Background

I recently got Richardson's Learn to Program with Minecraft (Amazon) for my kid to try to interest him in playing with our Raspberry Pi.

Raspbian comes bundled with a version of Minecraft that exposes a programming API, and a Python bridge library. The Raspberry Pi site has documentation for getting started with this setup. The Python bridge is described at http://mcpipy.wordpress.com and https://github.com/py3minepi/py3minepi.

Richardson's book also points out that a Spigot server with the RaspberryJuice plugin provides similar functionality on non-Pi hardware.

Always interested in disposable development environments, I found that it was quick and easy to setup a Minecraft-Pi Spigot Server as a container using the base itzg/minecraft-server image.

Sever Side

RaspberryJuice

$ mkdir plugins
$ curl https://github.com/zhuowei/RaspberryJuice/raw/master/jars/raspberryjuice-1.8.jar -o plugins/raspberryjuice-1.8.jar

Docker-Compose

Docker compose setup is done with file docker-compose.yml:

minecraft-server:
  image: "itzg/minecraft-server:multiarch"
  container_name: "mc-pi"

  ports:
    - "25565:25565"
    - "4711:4711"

  volumes:
    - "./data:/data"
    - "./plugins:/plugins"

  environment:
    EULA: "TRUE"
    TYPE: "SPIGOT"
    VERSION: "1.10.2"

  tty: true
  stdin_open: true
  restart: always
$ docker pull itzg/minecraft-server  # Get the latest image
$ docker-compose up

Client Side

$ pip install py3minepi
$ python -c 'from mcpi.minecraft import Minecraft; mc = Minecraft.create("my-docker-server.local"); mc.postToChat("Hello World!")'

Apologies, my Anaconda Python is not setting the environment correctly, so I can't test the client instructions on a fresh machine right now, but it's something quite like that.

Submitted by Derek Merck