Skip to content
Rutger Kok edited this page Oct 24, 2013 · 24 revisions

This page is made for plugin developers. It explains how to compile Terrain Control, as well as how to make plugins that work with custom biomes.

##Programming against Terrain Control ###Biome lookups If you use Bukkit's biome lookup API it won't recognize the custom biomes. If you want to support Terrain Control, add it as a dependency (just like you did with Bukkit) and use TerrainControl.getBiomeName().

Obviously, this won't work if Terrain Control isn't installed. So to support servers without Terrain Control, we need to make our own method:

public String getBiomeName(Location location)
{
    if (Bukkit.getServer().getPluginManager().getPlugin("TerrainControl") != null)
    {
        String biomeName = TerrainControl.getBiomeName(location.getWorld().getName(), location.getBlockX(), location.getBlockZ());
        if (biomeName != null)
        {
            return biomeName;
        }
    }
    return location.getWorld().getBiome(location.getBlockX(), location.getBlockZ()).toString();
}

#Compiling Terrain Control

Code structure

Terrain Control has been divided in five parts: terraincontrol, terraincontrol-common, terraincontrol-forge, terraincontrol-bukkit and terraincontrol-releases. terraincontrol-common contains almost all generation code. It doesn't depend on Bukkit and Forge. terraincontrol-bukkit uses the code from the Common part to generate a world on CraftBukkit. terraincontrol-forge does the same, but for Forge. This setup reduces the amount of duplicated code. terraincontrol-releases places the Bukkit and Forge version together in one jar file. It doesn't have any Java code. terraincontrol is the parent for all projects: when executing it you'll end up with a Bukkit-specific jar file, a Forge-specific one and a combined one.

##Setting up your workspace First of all, create a new workspace or use an existing one. Download the Terrain Control source from here and extract it. If you know how to use Git, you should of course use that, as it will make it easier to send your changes back. Import the folder as a Maven project, with the location pointing to the Terrain Control source. Maven should now download all dependencies.

##Compiling First slect the terraincontrol project and then use the Play button on the top of the screen. The option Maven install will compile the jars and place them in your local Maven repository.

##Code formatting Try to follow these guidelines. Only important if you want to send your code back to us.

  • In general, follow the Oracle code standards.
  • Opening brackets should be placed on a new line.
  • Use 4 spaces, not tabs.
  • LF (\n) line endings.
  • Variable names should be in camelCase (so it should start with a lowercase letter, however some places still use CamelCase), class names in CamelCase and constants (things that are static final) LIKE_THIS. Enum elements should also be formatted like constants, expect when they are used as a setting and thus cannot be changed (like TerrainMode in WorldConfig.java).
  • No line lenght limit. Just keep your code readable.
  • Each enum element on a new line.
  • Imports: group all java imports together and all other imports together. Place the other imports above the java imports. Feel free to use the * if the import list is becoming too long.

For Eclipse, you can download the settings here: the formatting settings and the settings for the imports.

Clone this wiki locally