How do I pre-generate a Minecraft world?

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.


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)!


Minecraft Land Generator:

expands your current vanilla (or modded if you have the server mods) world.

http://www.minecraftforum.net/topic/187737-minecraft-land-generator/