Jump to content

[1.12] Simple Question - Is the way that vanilla generates structures bigger than 1 chunk the most efficient way?


Recommended Posts

Posted

I haven't really started playing around with it yet, but I feel very limited by the need to generate a structure inside one chunk. Is the way that vanilla generates villages and strongholds the best way of doing this? What if the structure is one large building?

 

Just wondering if anyone has done something similar and can help out with a little advice before I start digging into it, thanks!

Posted
7 minutes ago, naturaGodhead said:

Is the way that vanilla generates villages and strongholds the best way of doing this?

Probably not, but I couldn't say.

9 minutes ago, naturaGodhead said:

but I feel very limited by the need to generate a structure inside one chunk.

This is how you should do it, otherwise you are generating a chunk from another chunk. Which is bad. So what you have to do is split it up between chunks somehow. There may be a more efficient way than how vanilla does it, but what they do works.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
Just now, Animefan8888 said:

 

This is how you should do it, otherwise you are generating a chunk from another chunk. Which is bad. So what you have to do is split it up between chunks somehow.

Yes, I realize that. Thanks for your answer though.

Posted

Several of the existing "dungeon" mods out there do, in fact, generate the entire dungeon inside the terrain at once (loading all necessary unloaded/non-existing chunks in the process).  That being said, I agree with Animefan in that this is a terrible way to do things (it often causes a massive server TPS drop).

 

So I suggest getting inventive in how you generate your structure "one chunk at a time".  Them quotation marks are not an accident.

 

For example, if you have a very, very specific structure (ie. no/very few random parts) you can have all the data for said structure already existing in the form of a set of data that is quick and easy to push into chunks (in the form of a file, or simply data that is created inside your mod when it is first loaded, etc).  At this point, you just need to make sure you transfer your data correctly.  This could involve, for one thing, making sure your structure never generates only partially due to what I like to call "loaded chunk collisions".  For example, say a player has traveled in a large circle, ofc. loading all the chunks in the area.  Let's say that by some miracle (or the player's intention) there is only 1 unloaded chunk left in the center of this circle.  If you decide to start generating a structure purely on chance and decide to start generating it in that one chunk, things may not go well (this is an extreme example, but it's just to illustrate the idea).

 

Pre-generated structures have their uses, but in many cases you may want a bit more flexibility.  One way is to simply expand on the first method, but dynamically generate a few structures while the game is loading instead of during runtime, keeping track of their chunk footprints, etc.

 

Another way could be to generate the structure in "rooms" or "tiles" which are each a chunk large, and can connect with each other in a modular manner.  This method allows you to literally generate the structure one chunk at a time, but forces a few conditions on you.  For example, when you decide to start generating in a given chunk, you should probably make that chunk's "room" have an entrance to your structure.  If you have eg. a boss or treasure room at the "end" then each time you create a "room" you'll need to see if there are any remaining unloaded chunks adjacent for you to make more rooms with in the future.  If not, you'll need to force your structure to generate an end room in the current chunk.

 

And finally, one of the most complex, but most flexible ways.  Using noise algorithms such as those used for minecraft's normal terrain generation.  I honestly haven't studied noise algorithms enough to tell you exactly how they work, but basically, they are what allows a player to travel in a giant circle and have the terrain still connect in a sensible way when the circle hits itself, if you know what I mean.  A while back I took *someone else's* noise algorithm engine and messed with a bunch of variables it used to make some interesting things like volcanoes.  This was not for minecraft, was not in java, and was 2D, not 3D, so don't ask me for advice with noise algorithms in minecraft...

 

I'm sure some crafty people out there can think up a few other ways to generate structures one chunk at a time as well.  I haven't gotten around to coding any of these yet, but I thought these up because one of my mod ideas is a dungeon generator that doesn't load extra chunks for generation (to replace roguelike dungeons and a few other dungeon generator mods I had to remove from my modpack due to the cascading worldgen issue Animefan mentioned).

Posted
25 minutes ago, Laike_Endaril said:

I'm sure some crafty people out there can think up a few other ways to generate structures one chunk at a time as well.

I just thought of one and it may be similar to 1.13(dont know how it's done yet). But instead of generating things in the main generation loop you could generate the whole structure on a separate thread, and sectioning it off into chunks then only when a specific chunk is generated obtain the chunk data that was generated and put it in the chunk. I say it might be similar to 1.13 because they have moved world gen to it's own thread(maybe threads).

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.

Announcements



×
×
  • Create New...

Important Information

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