Jump to content

[1.15.2] LayerUtil, Layers, traits


Recommended Posts

*edit: So the end goal of this would be having a somewhat-understanding of using the NoiseChunkGenerator (that generates the overworld) for a custom dimension to provide only a custom list of biomes, that may or may not include vanilla biomes, using the vanilla logic for elevation/temperature.


So I've been poking (more? again?) into the worldgen code, and it looks like LayerUtil has a method (func_227475_a_ in my 20200525 mappings) that essentially maps the layout of the world and what biomes are going to be where. And I'm not even 100% sure about that, it just kinda looks like it. Between a lot of srg names, and magic numbers that I'm not sure why they are there or what they represent, it leaves me a little lost.

This method appears to build areas of land/ocean and blend them together and smooth them out, using such things as OceanLayer and AddIslandLayer. Looking at these enums, I still don't know what the numbers it is using mean, or what it is returning.
So for instance, looking at AddIslandLayer, it is checking for various ocean types using biome IDs using LayerUtil, and then checking if a random number between 0 and 5 is 0, and then returning what? a number. That represents what? The parameters for the interface method are (INoiseRandom context, int x, int p_202792_3_, int p_202792_4_, int p_202792_5_, int p_202792_6_), and I haven't the foggiest notion what they represent, even when I set breakpoints and try stepping through the code.


Does anyone have any references for any of this seemingly low level worldgen?

I'll be grateful for any bits of insight or links to references or anything. I'm not looking for code unless it is well commented, otherwise I'll write my own once I have a little more of a clue how all these pieces fit together :)

Edited by Ugdhar
Link to comment
Share on other sites

3 minutes ago, TheGreyGhost said:

Dude, I have absolutely no idea.


But if you figure it out and make a couple of example codes out of it, I'd be very keen to incorporate into a tutorial project!



Well, if I get anywhere or figure anything out, I'll certainly update this thread and post a github of a simple dimension that uses NoiseChunkGenerator and a handful of cherry picked biomes. Or something like that. :D

I spend a few days hammering at it here and there, until my eyeballs start to bleed from all numbers floating around that I don't know what they represent, then take a break, then come back to it and make the teeny tiniest more sense out of it, rinse & repeat. I figure I'll scrounge up enough information eventually to at least fake knowing what it means.

Link to comment
Share on other sites

I've seen some descriptions of the world generation algorithms dating all the way back to 1.6.4.  It's pretty damn abstruse and unless you know what the algorithm is doing it's probably going to be very hard to reverse engineer.  It was hard enough for me to understand even when written in plain English (well - Mathematical notation actually).

Link to comment
Share on other sites

Some work dissecting how to use the structure system to generate features would be handy.

I've figured out some of the basics, but in terms of adapting that information to get Custom Ore Gen working again, I'm stuck, though part of that is not knowing how COG works either.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.


Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.


DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

So still looking into this, haven't figured a lot out yet or anything, but I've found some promising leads. I figured I would share here in case anyone else is looking into it, and it might help.


It would seem net.minecraft.world.gen.layer.BiomeLayer is the layer class that is the most readable and also seems as though it does some biome setup using BiomeManager. It looks more or less like this is the "main biome setup", where the basic plains, forests, mountains are setup.


At this point, I'm more or less thinking the required components are a BiomeManager, loosely based on the forge provided one; custom BiomeLayer to set things up, as well as other custom Layer classes (that actually don't even extend Layer class lol) for Rivers, Oceans, Hills, maybe Shores? And a custom LayerUtil replacement to build it.


Once I have some code to share (that isn't huge copy pastes of the vanilla/forge code for figuring out how it works), I will certainly share a github link.



Thanks for reading, and even more for posting if you have some insight!!!

Link to comment
Share on other sites

  • 2 weeks later...

So looking through the LayerUtil class, and accompanying Layer classes, I've realized a some things.


There are a TON of hardcoded biome references in here, so biomes are not always chosen "at random". If you look through these Layer files (IslandLayer, AddIslandLayer, etc) and you see methods returning magic numbers less than 5, changes are decent that they represent one of the "main" biomes (Ocean, Plains, Desert, Mountain, Forest).


Biome "borders" look like they are mostly managed in the EdgeLayer, EdgeBiomeLayer, and HillsLayer. They appear as if they decide what biomes will be able to be added to the edge of existing biomes. The main BiomeLayer appears to be built in IForgeWorldType#getBiomeLayer


Most of these apply methods used in here that come from the trait classes (i.e. IBishopTransformer, ICastleTransformer) return a value that represents a biome ID number.


Hopefully this information will be helpful to someone, or at least interesting. Feel free to chime in with any additional information related to this!


Link to comment
Share on other sites

Found some potentially useful example code in this repo: https://github.com/Tropicraft/Tropicraft/tree/1.15

(thanks tterrag, heard you mention Tropicraft and its worldgen while watching the FAP recording)


Sad thing, been tinkering with all this stuff for the past few weeks/month whatever, and there's theoretically going to be a bunch of changes to worldgen in 1.16, soooo....yup. :D It'll be back to the drawing board once forge releases start coming out for that! More than likely I will start a new thread for that discussion with the new version/features/way of doing things/whatever.


But, until then, or even after then (if 1.15.2 keeps support, which I imagine it will), feel free to pop in here with any tidbits of info or advice related to this stuff!!

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.

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.