Terrain Generation Guide

It is possible to use your own custom terrain generation in your server using Lua.

The default terrain generator uses several noise generation modules which are linked together to describe the terrain features. They're based on the Joise library.

The resulting output values should correspond to block ID's.

Using the Lua Joise Terrain Generator

  1. Launch the terrain generator from the server: java -jar server.jar terrainGenerator terrainGenerator.png
  2. Press L to load your custom Lua terrain. A sample Lua terrain file will automatically be generated and loaded.
  3. Edit your Lua terrain.
    View the Joise docs for a list of modules you can use.
    View the Lua Reference for detailed module API usage.

    Note: The filename is shown in the UI.
    Press L to reload the terrain.

  4. Load the terrain into the game in your gamemode script when finished:
    local terrainGenerator, module = require("scripts/modules/custom_terrain_generator").generate("terrain_generator_module")
    

Tip: You can run your server while editing the terrain using the terrain generator to quickly test your map! Just open another command window and start your server at the same time.

Exporting / Importing JSON Terrain

You can also export and import terrain generators as JSON.

To do this, we'll get a copy of the default terrain generator, then set our Lua script to use it.

  1. Launch a server
  2. Run this command in chat: /saveterraingeneratorjson This will save the terrain JSON file in your server folder.
  3. Open the Lua script for your gamemode.
  4. Add Level:setTerrainGeneratorJoiseJSONFile("terrain-generator.json") somewhere in your Lua script.

That's all, once you reload the map it will use your json config to generate the terrain!