Jump to content

[1.8][Solved?] Prevent Vanilla Structures from Conflicts with Custom Structure?


Recommended Posts

Posted

I have a huge maze structure in my mod where alterations caused by vanilla generation can cut across large distances or destroy paths which can ruin the experience. I'd like to know how I can either: (1) prevent my structure from being altered after its generation OR (2) set my structure to generate after the generation of all vanilla structures and anything else that could overwrite the block states of my structure.

 

Image of what I want to prevent (that opening should not be there):

 

  Reveal hidden contents

 

 

WorldGenChaosLabyrinth.java

 

  Reveal hidden contents

 

Posted

When you register your worldGenerator (using GameRegistry.registerWorldGenerator()), you can specify a 'weight', which basically means the higher the number, the later your generator will generate.

If you use a high number there (Integer.MAX_VALUE ;)) your generator should be the last one to add it's worldGen.

I made the Mob Particles mod, you can check it out here: http://www.minecraftforum.net/topic/2709242-172-forge-mob-particles/

Posted
  On 8/13/2015 at 10:38 PM, wesserboy said:

When you register your worldGenerator (using GameRegistry.registerWorldGenerator()), you can specify a 'weight', which basically means the higher the number, the later your generator will generate.

If you use a high number there (Integer.MAX_VALUE ;)) your generator should be the last one to add it's worldGen.

 

Thank you! I will try this.

 

Edit: I have only tried a few generations but it hasn't happened so far. If I don't come back to this thread then that likely means it worked.

Posted
  On 8/14/2015 at 12:28 AM, diesieben07 said:

You can stop trying, it won't.

The number only relates to the order of IWorldGenerators, so modded generators. Vanilla has nothing to do with this.

 

Yeah, I figured out it doesn't work. So how can it be done then? (assuming it's possible)

Posted

I've tried every Forge world gen event hook there is and none of them work 100% - mineshafts, ravines, and other multi-chunk structures / terrain features (such as lakes >.<) still destroy my structures from time to time.

 

PopulateChunkEvent.Post is supposed to fire after everything else has generated (and it does, in the code), but it's still not bulletproof.

 

You can stop lakes from breaking your stuff setting PopulateChunkEvent.Populate to DENY for EventType.LAKE if your structure is in or around the current chunk.

 

Based on my experiences testing various things (as opposed to minutely dissecting the actual code, though I've done a fair amount of that as well), it seems that mineshafts and other such features have a 'start' chunk that triggers them to generate in their entirety, so in that one chunk you have the normal Forge event hook progression, but every other chunk that it generates in is completely outside of the normal flow.

 

Obviously that's not completely true, otherwise lakes wouldn't be posting the Populate event, but I haven't been able to figure out in all this time how to stop mineshafts and such from doing what they do. I'm probably just not looking in the right places, but I've traced the hell out of the world gen code multiple times and still can't figure out how to prevent it, so if you (or anyone else) does figure it out, please share!

Posted
  On 8/14/2015 at 3:11 PM, coolAlias said:

I've tried every Forge world gen event hook there is and none of them work 100% - mineshafts, ravines, and other multi-chunk structures / terrain features (such as lakes >.<) still destroy my structures from time to time.

 

PopulateChunkEvent.Post is supposed to fire after everything else has generated (and it does, in the code), but it's still not bulletproof.

 

You can stop lakes from breaking your stuff setting PopulateChunkEvent.Populate to DENY for EventType.LAKE if your structure is in or around the current chunk.

 

Based on my experiences testing various things (as opposed to minutely dissecting the actual code, though I've done a fair amount of that as well), it seems that mineshafts and other such features have a 'start' chunk that triggers them to generate in their entirety, so in that one chunk you have the normal Forge event hook progression, but every other chunk that it generates in is completely outside of the normal flow.

 

Obviously that's not completely true, otherwise lakes wouldn't be posting the Populate event, but I haven't been able to figure out in all this time how to stop mineshafts and such from doing what they do. I'm probably just not looking in the right places, but I've traced the hell out of the world gen code multiple times and still can't figure out how to prevent it, so if you (or anyone else) does figure it out, please share!

 

I found your thread about this earlier and also saw the disappointing results of other threads. Doing something like this really should be possible. I doubt I'll be the one to figure it out if there even is a way so I hope someone comes along that has. If there isn't a way then maybe forge needs a new event hook?

Posted

As a really hacky solution that might work, what if you used the chunk populate event to start a timer, and instead of immediately building your structure, build it some ticks later. I'm not sure if a chunk can be guaranteed to complete generation in a certain number of ticks, but worst case it still might work. Actually, possibly better would be to both build your structure once during the generation and then again after some time. That should avoid making visual glitches most of the times.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted
  On 8/19/2015 at 5:18 AM, jabelar said:

As a really hacky solution that might work, what if you used the chunk populate event to start a timer, and instead of immediately building your structure, build it some ticks later. I'm not sure if a chunk can be guaranteed to complete generation in a certain number of ticks, but worst case it still might work. Actually, possibly better would be to both build your structure once during the generation and then again after some time. That should avoid making visual glitches most of the times.

 

Building my structure in chunk populate seems to have worked judging by the image below. I've seen mine shafts stop right before my structure before so I'm not entirely sure my problem is solved but I haven't had it happen since so it looks promising.

 

uMPMN7H.png

Posted
  On 8/23/2015 at 11:31 PM, サムエル said:

Building my structure in chunk populate seems to have worked judging by the image below. I've seen mine shafts stop right before my structure before so I'm not entirely sure my problem is solved but I haven't had it happen since so it looks promising.

 

Awesome. Always good to learn a new trick that is useful to the modding community.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.