
This post is for all of you Minecraft fanatics out there that run a server and are looking for a web based map that automatically updates itself. If you don’t know what Minecraft is you’ve probably been sleeping under a rock. It’s the best selling indie game of all time, with over 7 million copies sold! You can learn all about Minecraft at http://www.minecraft.net/
I chose to use Overviewer because it generates the highest quality render out of all the map rendering programs for Minecraft. Just check out the map for my server! http://map.craft.cat/#/193/64/191/-3/0/0
Requirements
- A linux operating system
- Python 2.6 or 2.7
- PIL (Python Imaging Library)
- Numpy
- Overviewer Minecraft map renderer
- A minecraft texture pack
- A minecraft world
For brevity’s sake I will assume you’ve met all the requirements. A detailed guide for installing Overviewer can be found at http://docs.overviewer.org/en/latest/installing/ I also make use of the overviewer config file for this example; follow this guide for help configuring yours http://docs.overviewer.org/en/latest/config/
At this point you should have your config file set up and overviewer installed. The easiest way to automate your map rendering is to make use of a bash script and cron. Here’s the script I’ve written that I use on my own server:
#!/bin/bash
pid="$$"
pidfile="/var/run/overviewer.pid"
# If /var/run/overviewer.pid exisis
if [ -f $pidfile ]
then
# Email details of the overviewer process that's still running.
echo -e "$(date)\nOverviewer is still running \n
$( echo PID: $(cat $pidfile)) exists from previous cron\n
$(ps -p $(cat $pidfile) -o lstart,etime)\n" | mail -s ‘Render is still processing’ your@emailaddress.com
exit 1
else
# Otherwise create /var/run/overviewer.pid which contains the current PID
echo $pid > $pidfile
# Then run overviewer.py. I choose to start overviewer with a niceness of 19
# this helps alleviate lag when rendering the map on the same machine
# as your minecraft server.
nice -n 19 /usr/bin/overviewer.py --config=/path/to/your/overviewer.conf
# Once overviewer.py completes chown the output directory to www user and
# delete the pid file.
chown -R www-user. /path/to/your/web/directory
rm $pidfile
fi
Simply copy and paste this script into your text editor of choice and save it as “render.sh” Note that you will have to update the path to your config file and your email if you want to receive notices that your render hasn’t finished yet. Then make the script executable:
chmod u+x /path/to/render.sh
Now that your script is executable the last thing to do is set it up to run automatically. The user that will be running this script must have the ability to modify files in the webroot as well as read the Minecraft world directory. To keep things simple I will use root as an example. Open up crontab with the following:
crontab -eu root
Once in crontab hit “i” for insert mode and paste the following line:
*/20 * * * * /your/path/to/render.sh 2>&1 /dev/null
After updating your path to render.sh press escape then type “:wq” and thats it! Your map should start rendering every 20 minutes on the hour. You may have to mess around with the frequency of the render to fit the needs of your server. Wikipedia has a great page explaining cron in depth at http://en.wikipedia.org/wiki/Cron
That’s all folks, come check out my minecraft server sometime at http://nobullcraft.com/
If you have any questions regarding this blog post feel free to email me at nick@nobullcraft.com
Happy Minecrafting!
