Cubitect / cubiomes

C library that mimics the Minecraft biome generation.
MIT License
579 stars 104 forks source link

Document how to extract biome parameters from the game #96

Closed jmi2k closed 1 year ago

jmi2k commented 1 year ago

I'm currently trying to mod cubiomes to add support for the new cherry grove biome before the release (yeah I cannot wait). The issue is, I have no idea about Minecraft biome generation. Everything else (which is surprisingly not too much) was quite straightforward to implement, but I don't know where to take the values for the parameter table from. I've tried looking into the JSON, but either I cannot make sense of it or it isn't there.

It could be interesting to have a short document explaining where to get those values from. It would significantly lower the entry barrier for people to get ahead the official releases by modding the library.

jmi2k commented 1 year ago

Ok just for the record: after decompiling the game, I managed to find some information in the VanillaBiomeParameters class, and it looks like what I need... but not quite.

The integers in cubiomes correlate with the floating point values in the ranges specified there, although I don't quite fully grasp how to extract all the parameters. There are 2D arrays indexed by temperature and humidity, so I can extract the ranges for these two by looking at the positions of those keys, but I don't know 100% how to handle overlapping ranges. Also, the weirdness value (which should be positive in my case and other ones) is -500 in cubiomes' table, not 0, and I cannot make sense of that either.

Cubitect commented 1 year ago

I've added experimental support for 1.20.

The climate / noise point generation is the same for all 1.18+ versions. Only the biome mapping changes between version. Here cubiomes differs from Majangs implementation. Rather than emulating all the code that generates the biome tree mapping structure from JSON, cubiomes directly stores the resulting biome tree structure (in biomeEntries), though in a more compressed binary format.

The way I obtain the biome tree is a combination of copying the value of the structure from a debugger dump and running it through a couple of mostly one-off python scripts to clean it up. I've added the scripts to the ./docu directory, but I'm not sure they'll be of much use to anyone else.

jmi2k commented 1 year ago

Thanks a lot, and sorry for making you go through the trouble before the official release. Indeed, there are some steps I was missing (after a few hours of head-scratching in front of the decompiled source I figured out only a few things).

Also, thanks for the scripts. They may prove useful into understanding what's going on. Feel free to close the issue if you don't plan to document this process further.