Skip to content
Rutger Kok edited this page Jul 3, 2014 · 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 Terrain Control uses Gradle.

You don't need to have Gradle installed, as Terrain Control contains a small wrapper (Gradle Wrapper, gradlew) that automatically downloads Gradle. If you are using the wrapper, use ./gradlew instead of gradle on Unix/Mac and use gradlew.bat on Windows.

Building

The following command will build Terrain Control: (Execute it in the project root)

gradle

There will now be a file for CraftBukkit in platforms/bukkit/build/distributions. If you run the command again, there will be a file for Forge too in platforms/forge/build/distributions/. (A file for Forge is never created the first time you compile, because of some incompatibility between two Gradle plugins, ForgeGradle and Shadow. See here.)

Eclipse (without Gradle plugin)

Importing

Run the following command to create the necessary config files:

gradle setupDecompWorkspace eclipse

Now you can import the projects in Eclipse using File --> Import --> General --> Exising Projects into Workspace. Press Next. In the next screen, make sure that the checkbox Search for nested projects is checked. Now select the project directory as the root directory and import the three projects.

Running

It is possible to run the Forge version directly from Eclipse. It requires a small amount of work to get this working. We are going the create two configurations, one for the client and one for the Forge server.

Open the Run Configurations screen (Run --> Run Configurations...). Right-click on Java Application and select New. Give the configuration a name, for example TerrainControl Client. Use the following settings in the Main and Arguments tabs:

Main class:       net.minecraft.launchwrapper.Launch
VM options:       -Xmx1G -Xms512M -Dfml.ignoreInvalidMinecraftCertificates=true -Dorg.lwjgl.librarypath="path/to/TerrainControl/platforms/forge/build/natives"
Program args:     --version 1.6 --tweakClass cpw.mods.fml.common.launcher.FMLTweaker --accessToken foo --userProperties []

Now repeat these steps for the server, with the following settings:

Main class:       cpw.mods.fml.relauncher.ServerLaunchWrapper
VM options:       -Xmx1G -Xms512M -Dfml.ignoreInvalidMinecraftCertificates=true

Updating

When the dependencies of Terrain Control have changed (new Bukkit/Forge version), you need to close Eclipse and run the following command:

gradlew clean cleanEclipseClasspath setupDecompWorkspace eclipse

Eclipse (with Gradle plugin)

Importing

The Gradle plugin by Nodeclipse cannot import the dynamic dependencies added by ForgeGradle. There's a workaround: run

gradle cleanEclipse setupDecompWorkspace

manually before importing the project, and then import the project as a Gradle project. Make sure that the bukkit, forge and common projects are selected. platforms, TerrainControl and releases can be left out.

Running

See the instructions for Eclipse without the Gradle plugin.

Updating

For the Bukkit and Common parts: right-click one of the projects, click Gradle -> Refresh Dependencies.

For Forge: run the gradle clean setupDecompWorkspace command (manually, outside Eclipse) and then refresh the dependencies as you did for the Bukkit and Common parts.

Netbeans

Importing

Netbeans users can import the settings generated for Eclipse. Run the following command:

gradle setupDecompWorkspace eclipse

In Netbeans, click File --> Import Project --> Eclipse Project.... Choose Import Project ignoring Project Dependencies. Import the TerrainControl-Common project, which is located at path/to/terraincontrol/folder/common. Ignore the warning about dependencies. (Gradle stores the dependency settings in the project, so you'll be fine.) Repeat these steps for the Bukkit and Forge projects, which are located at path/to/terraincontrol/folder/platforms/bukkit and path/to/terraincontrol/folder/platforms/forge. The Project to Import and the Destination Folder should be the same.

Running

Just like we did for Eclipse, we're going to run the Forge project directly from Netbeans. We're going to create two configurations, one for the client and one for the server.

Right-click the TerrainControl-Forge project and select Properties. Click on Run in the (left) sidebar. Create a new configuration called something like TC Client. Use the following settings:

Replace the path in the VM options with the correct path. Unfortunately, the path needs to be absolute.

Main class:       net.minecraft.launchwrapper.Launch
VM options:       -Xmx1G -Xms512M -Dfml.ignoreInvalidMinecraftCertificates=true -Dorg.lwjgl.librarypath="path/to/TerrainControl/platforms/forge/build/natives"
Program args:     --version 1.6 --tweakClass cpw.mods.fml.common.launcher.FMLTweaker --accessToken foo --userProperties []

Repeat these steps for the server, using these settings:

Main class:       cpw.mods.fml.relauncher.ServerLaunchWrapper
VM options:       -Xmx1G -Xms512M -Dfml.ignoreInvalidMinecraftCertificates=true

IntelliJ IDEA

Importing

Run the following command to create the necessary config files:

gradle setupDecompWorkspace ideaModule

Now import the project in IDEA: click on the project directory, click OK, click Gradle, click Finish.

Running

We're going to create to configurations, one to start the Forge client and one to start the Forge server.

Let's start with the client. Click Run --> Edit Configurations.... In the screen that pops up, click + and select Application. Give the configuration a name, for example TC Client. Use the following settings:

Main class:          net.minecraft.launchwrapper.Launch
VM options:          -Xmx1G -Xms512M -Dfml.ignoreInvalidMinecraftCertificates=true -Dorg.lwjgl.librarypath="path/to/TerrainControl/platforms/forge/build/natives"
Program args:        --version 1.6 --tweakClass cpw.mods.fml.common.launcher.FMLTweaker --accessToken foo --userProperties []
Classpath of module: platforms_forge

Note: if the main class is not found, you can use the ... button next to the text field to select it. Copy-pasting doesn't work sometimes.

Repeat these steps for the server, but use the following settings:

Main class:          cpw.mods.fml.relauncher.ServerLaunchWrapper
VM options:          -Xmx1G -Xms512M -Dfml.ignoreInvalidMinecraftCertificates=true
Classpath of module: platforms_forge

##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