Custom World Generator
This tutorial will give you the basic steps of creating a custom world generator using Bukkit. Following this tutorial, you will be making a simple, infinite world of plains and oceans, with some features added.
Custom World Generator
A Minecraft's world is divided into small chunks. Each chunk is 1625616 blocks and is created by a ChunkGenerator. After that the world meets some BlockPopulator 's to be filled in with the details.
Each biome in Minecraft has different heights, and in that biome the heights vary too. For example the Plains has a flat, low terrain, but the Extreme Hills biome has super high, steep, rocky cliffs. The height of each location is determined by an octave generator. It will make a randomized, but smooth terrain and you can use it for creating different kinds of biomes.
Why 15 and 50? 15 - the multiplier is the amount of difference between the highest and lowest possible heights of the world, and 50 is the minimum height of the whole world. You can change these if you want.
It's a pretty flat, boring world, much like the beginning of Minecraft (the very first version of Minecraft was a flat cube of blocks), but don't worry, we are going to add more stuff into this world later.
This time we don't use a boolean generator. Instead we randomize an integer from 1 to 100 and check if it is smaller than a cetain number. If true it will determine if it is a water, or lava lake. Then the lake's location is determined, finally we begin the generation.
This mod allows you to input a world seed shared by someone else to make your own version of their world, it allows you to browse and preview random seeds to find a world you like to play, and is a modding framework for creating new types of world in addition to the base game's normal island layout.
Generator type is a wrapper around a chunk generator and shows up on the world generation menu as world type.If you don't know what generator type is, you may want to scroll down and see the result section of this page first.
To create a generator type, you have to make a class that extends GeneratorType and implement getChunkGenerator method.In this tutorial, we reuse existing chunk generator FlatChunkGenerator to achieve void world.Feel free to replace it with your custom chunk generator.
For OTG 1.12.2 v7 and above worlds and dimensions can be created, edited and deleted using the world creation GUI. Press "O" to open the GUI in-game. Creating/editing/deleting dimensions is also possible during the game, no server restarts are required.
A preset is a world in the mods/openterraingenerator/worlds directory and contains all the information for the terrain generator, such as biomes, plants/trees, ores, custom structures, etc. When creating a new OTG world, select a preset to use for the overworld, you can then customise its dimensions in the dimension settings menu and create your world. If you'd like to use a vanilla overworld, create one using the vanilla world creation UI and use the OTG world creation UI ingame to add OTG dimensions.
A preset can either be copied in manually or automatically installed via an OTG worldpacker mod such as Biome Bundle or any of the OTG presets published on CurseForge by Team OTG. For 1.12.2 v7, the restriction that world names must match preset names has been lifted, so it is possible to create multiple worlds (though not dimensions) using the same preset. Biome id's and world specific settings (dimension settings) are saved to a config in each world's world save folder.
If a preset is packaged in a worldpacker jar (like biome bundle, void, flatlands, skylands etc) then the mod image, version, credits, url and description are shown. The WorldPackerModName setting in the worldconfig must be set to worldpacker mod's modname for this to work.
The dimensions screen allows you to customise the overworld and dimensions. Overworld and dimensions each have their own world settings, game rules and advanced settings. When ingame, the pre-generator can also be controlled and viewed here for each dimension.
World settings (top right): A list of installed presets with delete (X) buttons (this deletes the world preset, not the world, be careful!) as well as scroll () buttons to allow world creation using any installed preset at any time.
A world preset controls what dimensions a world has. Before 1.19 (22w11a), dimensions are defined in dimension folder rather than in world preset. Although in current version the world preset is recommended, the dimension folder is still supported.
Noise settings are for generating the shape of the terrain and noise caves, and what blocks the terrain is generated with, stored as JSON files within a data pack in the path data//worldgen/noise_settings, and are used with the minecraft:noise generator in a dimension. Vanilla settings include minecraft:overworld for normal Overworld generation, minecraft:amplified for Amplified Overworld generation, minecraft:nether for regular Nether generation, minecraft:caves for Cave (Nether-like generation but with Overworld terrain features) generation, minecraft:the_end for regular End generation, and minecraft:floating_islands for Floating Islands (similar to The End outer islands) generation.
A biome is a region in a dimension with distinct features, carvers, climates, spawned mobs, ambient sound and music, and sky, water, grass and foliage colors, stored as JSON files within a data pack in the path data//worldgen/biome.
Surface builders were used to control how the surface of the terrain is shaped and what blocks it is generated with. They are stored as JSON files within a data pack in the path data//worldgen/configured_surface_builder.
Custom is a world type that allows users to change the generation of the Overworld, Nether, and End dimensions as well as the ability to create custom dimensions. It is edited using a JSON file that is imported on the world creation screen.
These are the default values used for each biome in the multi_noise biome_source. Interestingly, although only the values for nether biomes are accessible through a preset, several overworld biomes have default values as well.
This file contains the same settings used to produce a default world, but with all of the presets expanded to their default values. Note that there is a bug that makes it impossible to create the ender dragon fight without using the dimension type preset minecraft:the_end, as the flag that creates the fight is hardcoded and not accessible through JSON. However, it is otherwise identical to the default world.
This dimension is a Superflat world with a layer of grass on four layers of coarse dirt on top of five layers of basalt. The entire world is full of village houses as spacing is set to 3 (default: 32) and separation is set to 1 (default: 8). The world starts by default at time 1000.
This tutorial will show you how to create a custom World Generator, note that it is still under construction and more sections will be added. So why would you want to create a custom World Generator? There could be multiple reasons why you want to, here's a few examples:
Before you can start to write your own world generator, you have to create a folder named "Global" in your mod folder, if you haven't done that already. In the "Global" folder you have to save a new, empty file named "World.cs" (Unless it already exists, in which case just edit it). This file will include all of our code and we're only working with this file the whole tutorial.
Note;This calculation is not necessary but it adds a good element of randomness. You can set the start of the surfacelayer or rocklayer to any number you want but you have to set it, otherwise it will be zero or will have the same value as the last world you played in. Cave Worlds are also possible, just set the surfacelayer and rocklayer to zero.
Okay, now that we're done with that we want to setup the spawn position because otherwise it will be [0, 0] (and therefore crash the game) or it will be adopted from the last world you played in. The code for setting the start position is pretty simple:
Okay, now we would be able to generate a map, however; we will surely fall to our death if we try to play. So we're going to replace a bit of our code with this little piece of code in the for next loop, to create a so called "flat world":
First it initializes the SectionType as well as the SectionWidth and set both to zero. For the SectionHeight, which will be the height of the first section, it takes 30% of the map height and afterwards it multiplies it with a value that can range from 0,45 to 0,54 (45% to 54%) for randomization. To make sure that the rockLayer starts is under the surface it takes the height of the section, adds another 20% of the map height for it and after that randomization will be done again (90% to 109% this time). On a small map, this will make the height of the surface section ranging from 162 to 194 and the rockLayer ranging from 378 to 456 in Y position.We also want to know which Y position the deepest point of the worldSurface has and which Y position the deepest point where the rockLayer starts at has. This will be used later to calculate the start of the rockLayer and the worldSurface for the map.
Allright, the variable SectionWidth is not only the variable containing the width of the section but is also a counter. Everytime we setup a line of blocks from the top to the buttom of the world, the SectionWidth will be reduced, because we're finished with that vertical line. If the SectionWidth is zero, we will setup a new section with a width ranging from 5 to 39 and a type ranging from 0 to 4. If the section is a flat section, it's size may increase almost sixfold, it will never be reduced though, as 5 * 0.2 is 1 and 29 * 0.2 is 5.8. This will make flat sections bigger.
This will control the rocklayer a bit. In 1 of 3 cases it is allowed to increase or decrease ranging from -2 to 2. If it goes too near to the SectionHeight (60 blocks away in a small world) it will increase and if goes too far away (420 blocks away in a small world) from it, it will decrease. Okay, we're almost done, now we can setup the actual blocks: 041b061a72