- 
                Notifications
    
You must be signed in to change notification settings  - Fork 160
 
Developer page
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.
##The Terrain Control interface
###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 to your build path (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();
}Terrain Control has been divided in three parts: Forge, Common and Bukkit. Common contains almost all generation code. It hasn't any dependencies, besides the standard class libary of Java 6. The Bukkit part uses the code from the Common part to generate a world. The Forge part does the same, but for Forge. This setup prevents having a lot of duplicated code.
##Setting up your workspace To compile Terrain Control, I (Rutger Kok) am using a setup with two workspaces. It's not a very nice setup, so if anyone else has a suggestion, I'd be happy to hear it.
First of all, create a new workspace or use an existing one. Download the Terrain Control source from here and extract. If you know how to use Git, you should of course use that, as it will make it easier to send your changes back. Create a new project, with the location pointing to the Terrain Control source:
Using the Eclipse IDE to add Terrain Control
After you have created the project, a lot of errors will show up. You need to add CraftBukkit and Forge to the project. You can download the latest development of CraftBukkit here. Right-click the project, select Build Path and click Configure Build Path. Click Add External JARs... and select the file you just downloaded.
There are still errors in the Forge version. The Forge version is a lot more difficult to compile. If you don't know how make a simple Forge mod, it is strongly recommend to follow a Forge tutorial first, otherwise you will have a hard time compiling Terrain Control. Feel free to delete the Forge folder if you are only interested in the CraftBukkit version.
Why is compiling the Forge version so difficult? As you might know, the Minecraft JAR file is obfuscated: every class, field and method has been renamed to a meaningless term, like a or nb. The MCP team has given many of those a meaningful name to help modders. Using MCP you can get a nice, deobfuscated source code. MCP has also made a script to convert the deobfuscated names back to the original, so that your mod works with the original Minecraft (obfuscated) names again.
The Bukkit team is directly distributing an already deobfucated JAR file, made with their own tools. They don't reobfuscate it, so that plugins working with Bukkit also don't need to. For Forge, will we have to create a JAR file similar to the Craftbukkit one by ourselves, and we will also have to reobfuscate our mod.
Make sure that the JDK is installed and that you can use Java from the command line (tutorial). Download the latest Forge build (use the source) and extract everything into a new folder, the Forge folder. Run Forge/install.cmd (Windows) or Forge/install.sh (Mac and Linux). This can take a while. You'll need an internet connection for this, as it will automatically download and setup MCP for you. After everything is installed, open the Eclipse IDE and set the workspace to the Forge/mcp/eclispe folder. You should theoretically be able to use any IDE, but MCP has built in support for Eclipse only.
You now have two different workspaces. The first one contains Terrain Control, the second one Forge. In the second workspace you should now see one project: Minecraft (with a lot of files inside it). Choose File, Export, JAR file and export everything. This is the jar file we need to add to the Terrain Control project in the first workspace. It contains the deobfuscated Minecraft "source" along with the Forge files. You can now make changes to Terrain Control in the first workspace.
##Compiling For Craftbukkit it's easy: just (in the first workspace) select Export, Java, JAR file and include the bukkit and common files.
For Forge it's more complicated. We need to get the compiled classes reobfuscated, so that it works with the original Minecraft classes. Therefore we are going to copy all Terrain Control files from the first workspace (with TC) to the second (with MCP and Forge). Copy the forge and common classes (the com folders) from the first workspace to the Forge/mcp/src/minecraft folder in the second workspace. You can now run (in this order) Forge/mcp/recompile.bat and Forge/mcp/reobfuscate.bat (Windows) or Forge/mcp/recompile.sh and Forge/mcp/reobfuscate.sh (Mac or Linux). It will output all Terrain Control files to Forge/mcp/reofb/minecraft. You can add them to the JAR file of the Craftbukkit version to create a universal build, or you can put them in a ZIP file.
Here's a small Windows .bat file to automate the copying and recompiling process. Place it in the Forge folder. You'll need to adjust the paths on line 4 and 5 for your computer, of course.
@echo off
cd mcp
rmdir "src\minecraft\com" /S /Q
xcopy "C:\Users\Rutger\Documents\GitHub\TerrainControl\common\src" "src\minecraft" /E /I /Q /Y
xcopy "C:\Users\Rutger\Documents\GitHub\TerrainControl\forge\src" "src\minecraft" /E /I /Q /Y
runtime\bin\python\python_mcp runtime\recompile.py %*
runtime\bin\python\python_mcp runtime\reobfuscate.py --srgnames %*
copy "src\minecraft\mcmod.info" "reobf\minecraft\mcmod.info" /Y
copy "src\minecraft\tclogo.png" "reobf\minecraft\tclogo.png" /Y
pause
##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 useCamelCase), class names inCamelCaseand 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 (likeTerrainModeinWorldConfig.java). - No line lenght limit. Just keep your code readable.
 - Each enum element on a new line.
 - Imports: group all 
javaimports together and all other imports together. Place the other imports above thejavaimports. 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.

