Minetest

Access your worlds

All the worlds your create with Momod are accessible on the same IP address but on different ports. If you started with the myworld-template.yml it should be on port 30000.

Now:

  • Start your Minetest client
  • Go to the ‘Join Game’ tab
  • Set the server Address as the wg-easy container IP 10.10.0.1
  • Set the server Port as 30000
  • For and Admin login, set ‘Name’ to the Admin users name set in the mineworld.yml.
  • (Other users can set their player name.)
  • Click the ‘Register’ button
  • Enter a password, confirm it, and click Register.
  • Have fun!

See minetest.net for more information.

Running Multiple Worlds and Restricting Access

Momod makes it easy to run several Minetest worlds and to restrict access to your worlds via Wireguard. It’s important to remember however that once you give Wireguard access it is access to all the worlds you create.

In case you want to restrict access to individual worlds the mod Whitelist is included in all the provided example worlds. This will allow you to restrict access to named players on a per world basis.

About the Momod Minetest World templates

The Minetest world containers are based on the minetestserver container image by Ronoaldo Pereira. Momod automates the build of the world container based on a configuration file in host_vars/YOURSERVER/minetest-worlds.

  • The Postgresql database backend is enabled for all worlds.
  • Rollback recording is enabled for all worlds.

Three template worlds are provided. You can use these as is, just rename and change the settings as described in the preparation section.

Or you can use them as examples for creating your own worlds. Change the settings, install different mods or even install a different game.

Below you’ll find information on the three provided templates.

myworld-template.yml

This is the default Minetest game, the only mods added are Filter (to filter bad language by players) and Whitelist (to restrict players from joining).

The default privileges have been changed to allow easy exploration play. I think this is a good introduction to Minetest.

creative-template.yml

This is a world with creative mode enabled with a selection of mods by TenPlus1 enabled to enhance the experience.

It’s made for easy building and farming, not fighting. It also has more biomes than the default game.

More fun and less work.

mineclonia-template.yml

This is a template for a Mineclonia game world.

It provides an example of how to create a world with a Minetest game other than the default and how to pull in game code via git.

This is a more traditional Voxel game where you’ll have to fight monsters as well as mine and craft. You will likely be attacked and die a lot at the beginning (usually in the dark associated with scary noises, unless I just had particularly bad luck). It is best played with friends so you can work together to protect each other and build quickly!

I highly recommend reading the Getting started guide for Mineclonia before you start to play.

Updates to Minetest games & mods and changing world settings

There are situations where you may want to rebuild existing Minetest containers, for example:

  • you notice there are updates available for mods.
  • you changed a setting in a host_vars/YOURSERVER/minetest-worlds/WORLD.yml file and need to apply the change.
  • you noticed a game update, have changed the version in your host_vars/YOURSERVER/minetest-worlds/WORLD.yml file’s extra_commands and need to apply the update.

Instead of re-running the entire Wireguarded play you can re-run only the Minetest related tasks with the minetest_rebuild play:

ansible-playbook --ask-vault-pass --limit MYSERVER play/minetest_rebuild.yml

This will however rebuild _ALL your worlds and cause them to restart, players which are in game will be disconnected and need to manually reconnect.

Tip: You can get some idea of who may be connected by logging in to wg-easy and looking at the connection status for clients, and whether data is currently being transmitted.

Minetest world backups

Momod sets up a cron job thats stops the world containers at 4:04am every day and creates a backup of your worlds Postgres databases. The backups are kept for 7 days then deleted.

It will also be wise to backup the world directories by including /data/momod/wireguarded/minetest in a backup. It’s up to you how you do that, but take a look at the Momod’s Tarsnap for one solution (you’ll need to add the /data/momod/wireguarded/minetest directory to the Tarsnap directories in your host_vars/YOURSERVER/main.yml if you choose to use it).

You may consider the database backup too large to send to Tarsnap (mine are multiple Gigabytes). In which case it’s up to you to find a way to regularly copy those backups off the server.

Importing existing Minetest worlds to a Momod server

Prepare backend

Momod is built to use the Posgresql database backend for all worlds. If you’re not already using that backend you’ll need migrate your worlds backend data before attempting to migrate it to a Momod base.

Create a custom world.yml

Once the backend is ready you’ll need to create an appropriately named ‘world.yml’ in the host_vars/YOURSERVER/minetest-worlds folder based on one of the provided templates but adapted to match your worlds settings.

The process

There are three parts to migrating your world onto momod:

  • Firstly run the Wireguarded play to set up a fresh world on your server based on your custom ‘world.yml’.
  • Secondly create a Postgres database dump of your existing world.
  • Thirdly remove the fresh database the Wireguarded play created and restore your old world database dump in its place.

This should leave you with the old world on your new server ready to be used.

Detailed steps

See the preparation and Run the play sections and run the wireguarded play.

You should probably try accessing this fresh world to make sure it works.

These example commands call the existing world ‘myworld’ and the new world ‘mineworld’, you’ll need to change the names to match yours.

Create a Postgres database dump of your existing world. The specifics will vary depending hon how and where you are running the Postgres. This example is for Postgres running on a Linux based machine.

pg_dump -U postgres -h localhost myworld > myworld_backup.sql

The databases can get quite big, compress with gzip before transfer between servers:

gzip -9 myworld_backup.sql

Copy to the new server, to a user account with admin privileges that can copy the file to the wgeasy users account. Copy the file to wgeasy’s home folder and set permissions.

scp myworld_backup.sql.gz your_server:/home/admin
ssh your_server
sudo mv myworld_backup.sql.gz /home/wgeasy
sudo chown wgeasy:wgeasy /home/wgeasy/myworld_backup.sql.gz

Switch the the wgeasy user and unzip the file.

sudo su - wgeasy
gunzip myworld_backup.sql.gz

Copy into the freshly created container:

podman cp myworld_backup.sql postgres-minetest:myworld_backup.sql

Stop the fresh world container via systemd while we change the database:

systemctl --user stop mineworld
# substitute 'mineworld' for whatever your world is called in this
# and later commands.

Drop existing database, then recreate (it will be empty).

podman exec -i postgres-minetest dropdb -U postgres mineworld
podman exec -i postgres-minetest createdb -U postgres mineworld

Restore your existing worlds database in the newly created db:

podman exec -i postgres-minetest psql --set ON_ERROR_STOP=on -U postgres -d mineworld -f myworld_backup.sql

Reaffirm user permissions for mineworld user and database:

podman exec -i postgres-minetest psql -U postgres -d mineworld -c "GRANT ALL PRIVILEGES ON DATABASE mineworld TO mineworld; GRANT ALL ON SCHEMA public TO mineworld;"

Some mods store data in text files in the folder beside world.mt. These need to be copied to the world folder in the new container, it should be sufficient to copy them into the bind mount at /data/momod/wireguarded/minetest/mineworld/data/.minetest/worlds/world and set permissions to match the world.mt file.

Start container again.

systemctl --user start mineworld

Try accessing the world in Minetest to check everything is working as expected.

If all is working as expected clean up the database backup files.

rm -rf myworld_backup.sql
# and inside the database container
podman exec -ti postgres-minetest /bin/bash
rm -rf myworld_backup.sql
exit

All done!