How do I pre-generate a Minecraft world?
I want to create a new world on our Minecraft server, but exploring a new map and generating terrain causes massive lag.
Is there a way to pre generate the chunks (with the default map generator) in a specific radius around the spawn?
I'm looking for a Bukkit plugin or tool I can use on our Linux machine. An offline tool I can run on my local machine is ok, too.
Solution 1:
In this thread on Reddit, I found a command line script that will generate terrain by repeatedly restarting a server with varying spawn points until the area you specify is filled. This seems like just what you're looking for.
There's also a Bukkit plugin named WorldGenerationControl which can do it on a live server.
Solution 2:
It's slow, but you can automatically teleport yourself across all the chunks in a specific area of the map to have them generated using Python and the pexpect module (which I've used to send the teleport commands).
First, make a copy of your game data for testing purposes, then open a command prompt at that directory and do the following:
$ virtualenv venv
$ source venv/bin/activate
$ pip install pexpect
Paste this code into teleport-expect.py (adjust playername and the xcoord and zcoord ranges):
#!/usr/bin/python
import sys
import pexpect
import time
# set this to your minecraft username
playername='yourplayername'
child = pexpect.spawn('java -Xms2048M -Xmx2048M -jar minecraft_server.jar nogui')
child.logfile = sys.stdout
child.expect('%s joined the game' % playername)
child.sendline('gamemode 1 %s' % playername)
for xcoord in range(1000000, 1005000, 16):
for zcoord in range(1000000, 1005000, 16):
child.sendline('tp %s %i 255 %i' % (playername, xcoord, zcoord))
child.expect('Teleported %s' % playername)
# Time between teleports. Smaller value means more stress for the server.
time.sleep(0.5)
child.sendline('say all done!')
$ python teleport-expect.py
Once the server starts, login to the game. You should see your player automatically being teleported one chunk at a time across the area of interest. Visiting a 5000x5000 area will take multiple hours to run.
It's not a fast way to generate a map, but neat to see the scenery fly by. I mainly wanted to test running the Minecraft server inside a pexpect session. Lots of potential for other automation (say, watching for user-created commands on a vanilla server)!