Minetest on Raspberry Pi

After some previous projects, I had some spare raspi's laying around to work with. Minetest is a pretty fun game, so I decided to set up a server for me and my friends to play on. Minetest is also free (as in freedom, not as in beer). We'll install some mods to add more content to the base game such as hunger, more ores, bows, mobs, and signs.

Setting up the Raspberry Pi

This is the standard quick setup for any project. I don't have enough screens and keyboards for all of my projects, so I'll assume that a headless configuration is preferred. Follow the Raspberry Pi's official guide for an install. Make sure that you download the Lite image, since we won't be using a desktop and don't need any additional software on our system.

Setting up SSH access

Follow the documentation on SSH, specifically, enabling SSH on a headless Raspberry Pi. Then ssh into the pi to get started.

Updating

Make sure that you update all your packages.

sudo apt update -y && apt upgrade -y

Users

For good practice, it's a good idea to create a minetest user to keep things clean. We'll give the minetest user a home folder, the bash shell, and sudo privileges.

sudo useradd -m -s /bin/bash -G sudo minetest
sudo passwd minetest
su minetest
cd ~

Getting Minetest going

Now for the good stuff. The version of Minetest in the repos is generally out of date, so we'll be working with the latest revision from their Github.

Downloading

wget https://github.com/minetest/minetest/archive/master.tar.gz
tar xf master.tar.gz
cd minetest-master/

Minetest is only the engine for the game. To get the actual game files, we'll also need to get minetest_game.

cd games/
wget https://github.com/minetest/minetest_game/archive/master.tar.gz
tar xf master.tar.gz
mv minetest_game-master minetest_game
cd ..

Building

Finally, we need to build from source. Install all the required dependencies.

sudo apt install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev -y

Run cmake to compile it. We'll be running this as a bare server, so we'll use the flag -DBUILD_SERVER=TRUE when we create the make configuration. If you're using an older version of the Raspberry Pi (I'm using the Raspberry Pi 3 B+), you should check the output of lscpu to determine how many cores your CPU has. This is reflected in the value passed to make -j. More build flags are listed and described, but these are the only basic ones that we need to build a server.

cmake . -DRUN_IN_PLACE=TRUE -DBUILD_SERVER=TRUE
make -j 4

Like most compiles, it can take a while for make to finish. It took me about half an hour to compile. Your mileage may vary.

First time run

./bin/minetestserver

Connect to the server from another computer, walk around for a bit, and make sure that everything is running smoothly. The output of ./bin/minetestserver will print debug information to the terminal, so watch for errors and anything of note. You might run into issues with your client being older than your server. As of this writing, the Minetest package offered in the Debian repos was several versions behind. You may have to build the client from source on your workstation, too.

We'll need our terminal back, so kill the server with ^C.

Further steps

After a successful run, you're technically done. To truely complete your server, we'll need to cover systemd integration, server configuration, and mods.

Creating a systemd service

I wrote a minetest.service file for systemd after I wasn't able to find one online. Reminder! Don't trust everything you download off the internet (especially from bloggers).

wget https://blog.networked.space/minetest/minetest.service
sudo mv minetest.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable minetest.service
sudo systemctl start minetest.service

I didn't include logging or any complex features. If you want to write more to it, you can email me your revision and I'll add and credit you.

Configuration

There is a minetest.conf.example file at /home/minetest/minetest-master from which you can build off of.

Significant values to change are default_privs, server_name, server_description, server_address, server_url, server_announce, port, max_users, and enable_pvp. There are a lot more that can fine-tune the mechanics and play of your server, but these are all values that I recommend changing.

For the changes to the config to take effect, I had to delete the existing world and restart the server.

rm -rf worlds/world
sudo systemctl restart minetest.service

Mods

I decided to install a mod for mobs, ores, signs, hunger, and bows. The ores, signs, hunger, and bows were made by TenPlus1. The framework for the mobs was made by PilzAdam. You can find more mods on ContentDB. Just like packages, some mods have dependencies and conflicts, so do your research and test which ones work and which ones don't. To install mods, extract their source into the mods folder and edit the world.mt file in the worlds folder.

cd mods
wget https://github.com/PilzAdam/mobs/archive/master.zip
unzip master.zip && rm master.zip
mv mobs-master mobs

wget https://notabug.org/TenPlus1/moreores/archive/master.tar.gz
tar xf master.tar.gz && rm master.tar.gz

wget https://notabug.org/TenPlus1/signs_lib/archive/master.tar.gz
tar xf master.tar.gz && rm master.tar.gz

wget https://notabug.org/TenPlus1/hud_hunger/archive/master.tar.gz
tar xf master.tar.gz && rm master.tar.gz

wget https://notabug.org/TenPlus1/bows/archive/master.tar.gz
tar xf master.tar.gz && rm master.tar.gz

Conclusion

That's pretty much all there is to creating a Minetest server on the Raspberry Pi. If you want to connect to the server that I set up, point your client at minetest.networked.space:30000. All of the mods covered are installed.

This guide was over 6k characters, which means that I can flex even harder on my fellow bloggers.

:x