Generating randomized structure sets/dungeons

Started by PsalmFirewall on

Topic category: Help with MCreator software

Last seen on 05:41, 8. Nov 2023
Joined Nov 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Generating randomized structure sets/dungeons

I am interested in making generated structures like Villages. The only resource I could see was from about 4 years ago and it didn't seem to be the most up to date. Do you guys have any practical tips for doing this? I am basically looking to generate a randomized (in both position and variant) set of houses and buildings, and ideally pathing between them.

Last seen on 20:43, 20. Aug 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You can! But fair warning,…
Tue, 11/07/2023 - 04:40

You can! But fair warning, it will take a toll on your sanity. People always make fun of weird village generation in Minecraft, but, quite honestly, it's a miracle they work at all. Here's an example pic of something I made for my ongoing structures mod:

Small structures are easy enough because you only have to worry about one thing, and big structures because you can plop them down anywhere and as long as there's a big enough foundation it won't make a bit of difference. Villages are hard because they involve lots of structures that all need to be placed in a reasonable manner, on basically any terrain, in a way that can be loaded into newly generated chunks without breaking the game.

Since all the stuff behind this took a really long time to make, I'll sorta go over the general idea here, but if you've got specific questions, please ask!

So essentially, this is built using a series of procedures and modded blocks that first check to make sure the conditions are right, and then build the village if they are. That means first making sure the biome is suitable by checking locations around the center; using a procedure to scan the surface for other structures to make sure it's not too close to another village, and most importantly, checking if the terrain is flat enough. (This is accomplished by scanning a flat slice a couple of blocks below the village for blocks that can see the sky, indicating holes; and then scanning a slice above the village for solid blocks, indicating a significant change in elevation, with different tolerance levels depending on the biome) Lastly, it runs the checks for village houses at each location adjacent to the middle, making sure that there will be room for at least three houses.

All my villages use a pretty simple model, with a central square, four roads branching off, with buildings at predetermined positions from the center. Even still, it can get fairly complex. The roads are built using a procedure that replaces blocks at world-surface height in a rectangle shape, placing arches and decorations along the sides at specific positions. Each 'slot' for a building determines the average elevation of the four corners, and, if there isn't too big of a difference in terrain, randomly selects a building, prioritizing houses and larger structures nearer to the village center. Then, a procedure randomly selects the building and rotation. (This is the annoying part, as MCreator's interface for some reason does not like lots of structure calls, meaning the procedures for structure selection need to stay locked for the most part to avoid random compilation errors.). If the terrain is too rough, it instead randomly spreads gravestones around the area where the building would have been.

Lastly, there's other modded blocks that spawn villagers and golems, randomly convert nearby cobblestone to mossy variants, randomly plant flowers, etc. You can make your own blocks that run code and then dissapear on update tick, and as long as they're being placed in the world using procedures, they'll function. This weirdly means that my villages are actually world features, rather than true structures, because I can then more specifically configure how they generate. It's difficult, but it gives you a lot more control over stuff.

But yes, redesigning villages is a tall order, and has taken me longer than the Woodland Mansion and Jungle Temple combined, at least in part because there's just so many fricking buildings. Best of luck!