Jump to content

Writing terrain generation code in Java


de5car7es

Recommended Posts

Hi

I'm highly experienced with Java but newbie in Modding and Forge.

I want to write a mod in Java that completely change the terrain.
As a starting point I would like to create a mod that cause the entire terrain to be flat above a certain height, or even entirely flat.

Can anyone direct me for a tutorial, code example or documentation for that.

I found some stuff about World Gen that uses JSON, but that is not what I am looking for.

Thanks ! 

Link to comment
Share on other sites

Json files (datapacks) is the way you do this. You will find a lot of information about them on the internet.

 

The main community developed documentation I know about are:

https://misode.github.io/ and https://minecraft.fandom.com/wiki/Data_pack

the second of those is really just a collation of all the minecraft release notes.

The first also has the vanilla world gen files:

https://github.com/misode/mcmeta/tree/data/data/minecraft/dimension

https://github.com/misode/mcmeta/tree/data/data/minecraft/dimension_type

https://github.com/misode/mcmeta/tree/data/data/minecraft/worldgen

 

Those json files are just configuration files that create java objects using codecs: https://forge.gemwire.uk/wiki/Codecs

either as;

* simple values or "records"/collections of them

* references to objects created from other json fles

* references to objects that are constructed and registered programmatically such as the vanilla provided presets, dimensions, chunk generators, carvers, features, structures, etc.

 

If you want to create flat terrain, I would suggest you start with vanilla's FlatLevelSource and FlatLevelGeneratorPresets and follow the rabbit hole.

 

As for tutorials, even if you find one, it is likely out-of-date. The modern worldgen has been marked as experimental since 1.16.

Mojang keep iterating on it without any real constraints of compatiblity across versions - the json file formats are more stable than the code they configure

I would suggest you read the vanilla source - net.minecraft.world.level.levelgen.* and net.minecraft.data.worldgen.*

or search on github for up-to-date implementations by other mods of the classes you are interested in.

 

  • Like 1

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.