Der Header: Enauts Thinking!
created:Mon 27 Aug 2018
edited:Mon 27 Aug 2018

Creating a minecraft map with overviewer

Minecraft-Overviewer is a minecraft mapcreator and viewer for webpages.

In this guide we setup an automatic rendering server based on:

Preparing the operating system

First we add a dedicated overviewer user and group:

root# groupadd -r overviewer
root# useradd -r -g overviewer -d "/var/overviewer" -s "/bin/bash" overviewer -m

I like to set up the bash prompt so that I quickly see where this terminal is at.

My /var/overviewer/.bashrc looks like this:

if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
cd
PS1='\[\e[36m\]overviewer \W>\[\e[0m\] '

Installing overviewer

First enable the copr repos, then install minecraft-overviewer:

root# dnf copr enable enaut/minecraft-overviewer-weekly
root# dnf install minecraft-overviewer

Of course you have to answer the yes/no questions correctly ;).

Creation of the systemd service file

The init System of linux is mostly systemd. It is responsible for launching and supervising services. Since we want to make the rendering process an automatically launched service we have to tell systemd about our endeavor.

So we create the file: /etc/systemd/system/minecraft-maprender.service You can also name it /etc/systemd/system/overviwere.service but then you have to name the timer at the end of the article overviewer.timer.

[Unit]
Description=Render the Minecraftmap using Overviewer
After=network.target

[Service]
Type=simple
User=overviewer
Group=overviewer
SupplementaryGroups=minecraft
Nice=19
ExecStart=/usr/bin/overviewer --config=/var/overviewer/render_config.py

Line by line explanations:

  • line 2: A description of the service enter anything you like.
  • line 3: This service is launched after the network is up.
  • line 6: This is a simple service
  • line 7-9: Setting the user and groups so that everything is acessable and everything is contained in users
  • line 10: Make it very low priority. As rendering takes a lot of IO and CPU for quite some time we want to make sure that the rendering is not stealing resources from other processes like the minecraft-server or the webserver.
  • line 11: finally starting the rendering with a customized config.

The overviewer config file:

Configure minecraft-overviewer as you like. See Docs

My configuration file looks like this:

worlds = {}
# Define the path to your world here.
worlds['My World'] = "/var/minecraft/server/world"

# Define where to put the output here.
outputdir = "/var/www/minecraftmap"

# This is an item usually specified in a renders dictionary below, but if you
# set it here like this, it becomes the default for all renders that don't
# define it.
# Try "smooth_lighting" for even better looking maps!
rendermode = "smooth_lighting"

# Daylight
renders["OurWorld"] = {
        'world': 'My World',
        'title': 'Daylight',
}

# Nighttime
renders["OurWorldNight"] = {
        'world': 'My World',
        'title': 'Nighttime',
        # Notice how this overrides the rendermode default specified above
        'rendermode': 'smooth_night',
}

# Railoverlay
renders['over_rail'] = {
    'world': 'My World',
    'title': 'Subway (rail on cobble)',
    'rendermode': [ClearBase(),
            StructureOverlay(structures=[
                    (((0, 0, 0, 66), (0, -1, 0, 4)), (255, 0,   0, 255)),
                    (((0, 0, 0, 27), (0, -1, 0, 4)), (0,   255, 0, 255)),
                    (((0, 0, 0, 28), (0, -1, 0, 4)), (255, 255, 0, 255))
            ]), EdgeLines()],
    'overlay': ['OurWorld', 'OurWorldNight']
}

Getting the textures

Overviewer needs the original textures to render its map get them with the following command:

root# su overviewer
overviewer ~> wget https://s3.amazonaws.com/Minecraft.Download/versions/1.12/1.12.jar -P ~/.minecraft/versions/1.12/

Don't forget to adjust the versions or get the most recent command from: installing-the-textures

creating the output directory and adjusting permissions

root# mkdir -P /var/www/minecraftmap
root# chgrp overviewer /var/www/minecraftmap
root# chmod g+rw /var/www/minecraftmap

Running the first render

Finally you can run your render:

root# systemctl start minecraft-maprender

You can check if everything is running smoothly with:

root# journalctl -u minecraft-maprender
root# journalctl -fu minecraft-maprender

The first command is writing everything that the unit minecraft-maprender has written to journal (ever) so you might have to scroll a little to the end.

The second command prints the last 10 log lines and then waits and prints every following line as soon as they are logged... So to monitor the progress of some rendering the second command is way cooler. Exit this mode with [ctrl]+[c].

If you have permission errors or something similar resolv them with chmod and such... sometimes it is helpful to replace the ExecStart line of the minecraft-maprender.service with ls or some other analytical tool:

ExecStart=/usr/bin/ls -la /var/minecraft/server/world

In the journal output you can then analyze the problem.

Creating a timer

When the first render is done you can create a timer that starts the render daily hourly or weekly as you like. My example is a dayly render allways during very early morning:

[Unit]
Description=Trigger the rendering of the minecraft map every day at 4:00 am.

[Timer]
OnCalendar=*-*-* 04:00:00

[Install]
WantedBy=timers.target

Store your timer in the file /etc/systemd/system/minecraft-maprender.timer

To activate your timer do:

root# systemctl enable minecraft-maprender.timer

Comments

Add a new comment

Note that all comments are moderated - so your post will not appear till I find time to accept it.

The comments do use markup syntax.

Name:
Email:
Confirm Email: leave the above line empty!
Comment: