Syndicate
Site (RSS, Atom)
Contact
Weblog status
Total entries: 78
Last entry: 2022-10-16 13:52:24
Last updated: 2022-10-16 14:12:58
powered by vim, bash, cat, grep, sed, and nb 3.4.2

2018-03-27 11:13:27

Python with Minecraft on Fedora

This small tutorial is mostly based on the great tutorial at maciej.lasyk.info.

It has a relation to the book "Learn to program with minecraft" by Craig Richardson (german title: "Python programmieren lernen mit Minecraft"). In this book only Windows, OS X and Raspberry Pi are covered but not a "plain Linux system". This tutorial shows a way of how to do it on "common Linux".

I replayed Maciej's tutorial and did some things differently. It was a pre-work to create a repository holding all the packages required for "Python with Minecraft".

The differences in this/my tutorial are:

  • use relative paths
  • use sub dirs for different spigot versions
  • don't care about pollution of Python's global space

OK, let's go. Create a new directory where you like and go into that directory. Then execute following commands:

1.) Update packages from repo and install required packages (maven is optional):

dnf update
dnf install python3-pip python3-tools git #maven

2.) Install Java: IBM or Oracle is recommended. Alternatively:

dnf install java java-devel java-headless

3.) Spigot including Raspberryjuice (two versions for Spigot, 1.8.8 and 1.12.2):

wget -N http://ngtx.de/BuildTools.jar # redirect 301
git config --global --unset core.autocrlf

# spigot 1.8.8
mkdir spigot-1.8.8
cd spigot-1.8.8
ln -s ../BuildTools.jar
java -jar BuildTools.jar --rev 1.8.8
cd ..
cp spigot-1.8.8/spigot-1.8.8.jar .
echo '#!/bin/bash
java -Xms2048M -Xmx2048M -jar spigot-1.8.8.jar
' >start-1.8.8.sh
chmod 755 start-1.8.8.sh 
# you might want to delete spigot-1.8.8 directory

# spigot 1.12.2
mkdir spigot-1.12.2
cd spigot-1.12.2
ln -s ../BuildTools.jar
java -jar BuildTools.jar --rev 1.12.2
cd ..
cp spigot-1.12.2/spigot-1.12.2.jar .
echo '#!/bin/bash
java -Xms2048M -Xmx2048M -jar spigot-1.12.2.jar
' >start-1.12.2.sh
chmod 755 start-1.12.2.sh 
# you might want to delete spigot-1.12.2 directory

git clone https://github.com/zhuowei/RaspberryJuice
cd RaspberryJuice
mvn package  # optionally! checkout comes w/ jars
cd ..
mkdir plugins
cp -af */target/*.jar plugins/ ||\
  cp -af */jars/*-1.11.jar plugins/

# nasty legal stuff
echo "eula=true" >eula.txt
# you must maybe re-execute it after first
# start of spigot server

# start server
./start-1.8.8.sh
# or: ./start-1.12.2.sh

4.) py3minepi the Python API which connects to the socket provided by Raspberryjuice, install command require root/sudo permissions:

wget --no-check-certificate -c -m \
  https://github.com/py3minepi/py3minepi/archive/master.zip
unzip github.com/py3minepi/*/*/master.zip
pip3 install ./py3minepi-master  # use sudo

5.) first test:

echo '
from mcpi.minecraft import Minecraft
mc = Minecraft.create()
mc.postToChat("Hello server!")
' >test.py
python3 test.py

Posted by Frank W. Bergmann | Permanent link | File under: fedora, minecraft, python