A while back I added a bunch of terrain generation hooks to Minecraft Forge, completely opening up Minecraft vanilla terrain generation to modders. I expected many people to begin using the hooks I added to Forge to do all kinds of things with terrain generation. That hasn't happened, and I started thinking that, with a few notable exceptions, terrain generation in minecraft remains relatively untouched.
Points of Interest
Standard Biome Generation
Redwood forests, savannas and shrublands are all generated by registering the biomes and adding them to the list of biomes available for world generation. This is exactly the same technique used by the ExtrabiomesXL mod.
Intelligent Biome Insertion
A Forge terrain gen event (
WorldTypeEvent.InitBiomeGens) is caught to insert GenLayers into the heart of vanilla terrain generation. GenLayers are used by Minecraft's terrain generation to create organic looking terrain.
TerrainGenInjector to see how GenLayers are inserted. Specifically, the
GroveGenerator replaces bits of Forest with birch groves and Autumn tree groves, and the
WastelandGenerator inserts small bits of wasteland into terrain generation--but only in specific places chosen by the mod.
While writing this, I noticed that
HillGenerator remains unused. I'll leave it as an exercise for the reader to implement this in the proper place and explore what it does.
Traditionally, features are added to terrain gen by implementing
IWorldGenerator and passing the object to FML via
GameRegistry.registerWorldGenerator(). FML then calls its collection of these objects after vanilla decoration finishes for a chunk. This means that
IWorldGenerator must deal with vanilla trees and other features. If you have ever seen one of Eloraam's RedPower 2 volcanoes suspended in the top of a redwood tree from ExtrabiomesXL, you have seen one of the side effects of this technique.
By hooking forge's
DecorateBiomeEvent, modders can decorate chunks with surgical precision before, during and after vanilla chunk decoration. This mod demonstrates this by hooking (see
TerrainGenEventHandler) a Decorate event to create small Poplar groves in Plains after vanilla trees have been placed, but before anything else is placed. All other vanilla flora (pumpkins, flowers, grass, mushrooms, shrubs) and small lakes will be filled in around the poplars, making them appear more "natural" to the environment and making the generation code much simpler. Modders can use
DecorateBiomeEvent to insert their own custom features into chunks during early generation or even hook these events to turn off specific vanilla terrain gen features.
The realm of modded Minecraft terrain generation remains relatively unexplored, despite the huge success of mods like ExtrabiomesXL. I encourage developers to use Eclipse's excellent search features to explore the minecraft code to see how Forge's terrain gen events (see
net.minecraftforge.event.terraingen) can be used to realize the goals for their mods.
The logo is the Killen tartan designed by Paul Killen. This is not my work.
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to unlicense.org.