Jump to content

Recommended Posts

Posted

I did some research on how to prevent chunks from loading that shouldn't be loaded yet(caused by world generators generating across the edge of a chunk). So far what I have found is that usually, the generation is offset into the middle of the chunk.
But I need to generate structures bigger than a chunk. How do I do that? I considered using isChunkGeneratedAt(). However, for big structures, I would then need to offset generation far into chunks that were already loaded a long time ago, giving the impression that the structure simply "popped up". There has to be a solution to this. Of course I already checked Minecraft Village generation, but they all seem to have chunk-sized structure components. The only thing that is close to what I want to do is the Mansion, but it

 is a pain to understand it because of the insane amount of pieces it uses.

Posted (edited)

Well, the difficulties you're facing are pretty typical. If you try to only generate the portion of your structure in the loaded chunk there is potential that when the next chunk is generated that it isn't suitable for your structure. With smaller structures it kinda works because the village houses can be on a hillside or something, but it can look strange if your castle is halfway into a cliff or something. But like you said you can't wait until all the chunks are loaded to check for suitabiliy because then the structure will sort of "pop up" as you said.

 

And also, it is true that there are vanilla structures to look at but the code is kinda complicated. Also, depending on the structure it may not always make sense to break it up in same way as vanilla.

 

One solution could be that the generation of the chunk depends on whether there is a structure rather than the other way around. Like lets say the natural generation happens and then eventually provides a suitable place to start your structure. Well, then the next chunk maybe shouldn't be fully "natural" generation. Instead you can control it so you know it is suitable for the remainder of the structure. Basically prevent it from creating an ocean, lake or mountainside in the way of the structure you need to create. In fact, if parts of your structure cover a whole chunk, you could basically make sure that that chunk is generated as a "flat" structure.

 

Another solution was whenever you find a place that might be suitable for your structure to start, that you force the generation of the addtional chunks and then only build your structure if the overall area is suitable for it.

 

Overall, there isn't really a good general way to generate a structure because it really depends on the structure. For example, if your structure is very regular and symmetrical you might be able to generate it with a formula, but if it is very intricate and asymmetric then you will need to generate it block by block from a blueprint. If some parts of the structure are repeated then you will want to break it up into smaller pieces. If the structure has a lot of randonmess you will have to figure out how to ensure it all fits together. And so forth.

Edited by jabelar

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

Posted (edited)

I had a similar issue in one of my mods, trying to streamline snow/grass/sand/clay generation, with their location being determined by a noise-generator (hence I would have no control over chunk boundaries)
What I ended up doing, is creating a placeholder block, that when randomly ticked (which should provide ample time for the chunks around it to get generated) would first check the environment, and then act accordingly, and here, the first one to tick would replace itself and several others within range to the mentioned blocks.

What I'm trying to say here is, a single block placed during worldgen, and then "activated" afterwards, would perhaps be the best option to the "bigger than one chunk" issue.
Once it is activated, it checks if it can actually do everything. If it cannot, well, then it can just replace itself with air.
If it can do something, which here would be to build something, well, then time to pack up, cause it's settling in. (eg, start building)
Perhaps have the block contain a TileEntity that can perform higher logic, like "place x blocks per tick" to make the strain even less.

Edited by Matryoshika

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Posted

While having a placeholder block can definitely simplify the generation logic, I don't think it helps this particular issue. The problem here is that he didn't want the structure gen to force the load of a chunk, but without loading the chunk you won't know if the next chunk is suitable for continuing the structure. You'd have the same problem with your placeholder block -- it wouldn't be able to generate the structure even on the next tick because the next chunk wouldn't necessarily be loaded. 

 

There is really only three possible strategies. 1) When a chunk seems suitable to start a structure go ahead and force the additional chunks to load and then determine whether the overall area is suitable for your structure, 2)  You can make the presence of the start of your structure force the next chunks to be suitable, 3) design your structure so it kinda works in all possible cases -- like can extend into the ocean or into a mountainside or ravine, etc.

 

I kinda like strategy #2 in terms of liking creating the best result (because the surrounding chunks will be purposefully generated to be suitable).

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

Posted

If you are in a chunk, you can be absolutely sure that the chunk +X and +Z exist. You cannot be sure that -X or -Z exist.

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.

Posted

Well, I've been working on the same program.  My main mod (Doomlike Dungeons) does this all wrong, intentionally generating the whole thing across a huge area -- mostly because that's what I could figure out easily as a new modder back in 2014 and didn't think about the consequences.  I've been working out a new system for a sequel (since core parts like this are too broken so start over would be easier).

 

My plan, if it works, is very simple, though it requires slightly more complex data structures to store the structure.  Split the structure up into many structures along chunk boundaries and build only the part that is in the chunk being generated.  I don't know how well this will work with what you are trying to do, but that is how I would (hopefully) will do it.

Developer of Doomlike Dungeons.

Posted (edited)
  On 2/6/2018 at 12:54 PM, JaredBGreat said:

My plan, if it works, is very simple, though it requires slightly more complex data structures to store the structure.  Split the structure up into many structures along chunk boundaries and build only the part that is in the chunk being generated.  I don't know how well this will work with what you are trying to do, but that is how I would (hopefully) will do it.

Expand  

That's honestly the easy part, the difficult part is knowing whether the additional chunks that aren't generated yet will be suitable for your structure. imagine you start generating a big castle and then the next chunk ends up being a mountainside or ocean or ravine. As Draco18s says, the chunk +1, +1 is generated so you can check its suitability but I expect some people need to span even more chunks than that.

 

I think the easiest solution is to simply accept that Minecraft sometimes generates some weird stuff and do your best to have the structure work in all situations. Vanilla villages often generate on some weird hills, but that is fun when it happens. To do this approach you can make your structure also include the blocks underneath and above so that if it does end up getting generated in the middle of a lava lake it basically creates an island for it to be on, and if it gets generated in a mountain side it sort of chops out the mountain above it.

Edited by jabelar

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

Posted (edited)

Ah, I'm use to building huge things, but always underground.  For things on the surface I have only vague ideas -- I've toyed with the idea of building biome-sized cities and roads that stretch 1000 blocks for one mod idea, but never actually tried it or worked a precise system for doing that, or any really good ideas, really.  Oh well, I tried to help.

 

But for many structures I'm quite happy to have them half-burried, etc.  -- though for a ravine I might just put a foundation under the castle, or similar, so it will either reach the bottom of believable bridge it.

 

For the technical issue of just avoiding generating chuck it simple, but yeah, if you really want to check the terrain it would get harder.

Edited by JaredBGreat

Developer of Doomlike Dungeons.

Posted (edited)

While developing the structure generation system for my mod I had the same problem. I solved it with a pretty complex system involving a chunk cache.

It is not really completed yet, but maybe it helps you anyway. My mod replaces the vanilla (overworld) ChunkProvider with a modified one.

Source on github (my mod changes some other worldgen related things too, sorry if it is hard to read or understand the code)

 

How it works:

- Structure data is saved in NBT format (similiar to vanilla structures) and loaded on server start

- When a chunk is generated, it checks for suitable positions based on the conditions saved in the NBT data, for example a block at a specific position in the structure needs to be grass or dirt. If all conditions match, it adds the position to my StructurePositionMap and generates it in the world later during chunk population, chunk by chunk. StructurePositionMap source

 

The problem: What happens when the condition block that needs to be checked is in a chunk that is not generated yet?

My solution:

If the chunk that needs to be checked has not been generated yet, the ChunkProvider just 'pre-generates' it and stores it in a cache, like this (ChunkProviderDoomed.getChunk) :

 

public Chunk getChunk(int x, int z) { // called when checking structure conditions
		if (world.getChunkProvider().isChunkGeneratedAt(x, z)) { // if chunk is already generated, just retrieve it (vanilla)
			return world.getChunkFromChunkCoords(x, z);
		} else { 
			long c = ChunkPos.asLong(x, z); // if not, try to get it from our own chunk cache
			if (chunkCache.containsKey(c)) { 
				return chunkCache.get(c); // if it is cached, return it
			} else {
				return this.preGenerate(x, z); // if not, pre-generate it and put it into the cache
			}
		}
	}

 

Then it performs the checks, and later when the chunk is actually generated by minecraft it just retrieves the chunk from the cache instead of generating it again:

public Chunk generateChunk(int x, int z) { // (override: ChunkProvider)
		Chunk cached = getChunkFromCache(x, z, true); 
		if (cached!=null) { // if chunk has been pre-generated, we dont need to generate it again
			this.createVanillaStructures(x, z, null); //create vanilla structure data, everything else is already done
			this.createStructures(x, z);
			return cached;
		}
		return this.generateChunk(x, z, false); // if not, generate it normally
	}

 

However, I cant tell if this causes problems with vanilla structure generation (not tested yet)

But so far, it worked for me without any problems or lag.

 

I hope it helps :)

 

 

 

Edited by m00nl1ght
updated github links
  • Like 1
Posted

I think I will somehow manage to prevent weird looks on my Gens, by checking corners and altering terrain. The only issue I really have problems with is lag prevention. Look at for example how my Fortress Generator works(I hope it is on Github). Thanks for all the replies

  • Like 1
Posted
  On 2/6/2018 at 3:22 PM, jabelar said:

I think the easiest solution is to simply accept that Minecraft sometimes generates some weird stuff and do your best to have the structure work in all situations. Vanilla villages often generate on some weird hills, but that is fun when it happens. To do this approach you can make your structure also include the blocks underneath and above so that if it does end up getting generated in the middle of a lava lake it basically creates an island for it to be on, and if it gets generated in a mountain side it sort of chops out the mountain above it.

Expand  

 

Just ran across this example after reading this. :D

2018-01-30_23.05.03.png

  • Like 1
Posted (edited)

 

 

I created a different-from-vanilla system now. I looked up some source code from other mods and saw that they raise terrain additionally to world generation. I have a custom ChunkGenerator that

uses completely different height generation than Vanilla, so my conditions are a bit different. Basically, what I planned/already did until now was:

 

-Create ModStructure, quite similar to the Vanillas' structure start. 

-Create ModStructureType, determining how to generate in specific ModStructure instances.

-Have a List in my ChunkGenerator that holds all ModStructure instances.

 

Planned:

- Call generate() for all structures in the list

-Precalculating which chunks will be needed for the structure, so that I can raise the terrain. I think this will be the hardest part. Another idea: Raise terrain for each structure piece.

-Generating the structure itself on the terrain!

 

These are some screenshots of my dimension. As you can see, single fortresses spawn quite well, but I don't think this will be the case for other structures.

https://imgur.com/a/MWPHS (Somehow Uploading won't work)

 

 

 

Edited by ArmamentHaki

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Ready to unlock unbeatable savings on Temu? Our exclusive Temu code [ald244107] is your ultimate secret weapon for a $100 OFF discount, plus so much more this year! Whether you're making your first purchase or returning for another shopping spree, this verified promo code gives you an instant boost, with up to 50% off your next order and even deeper discounts on clearance items. With Temu coupon code [ald244107], you're not just getting a flat $100 discount; you're stacking it on top of already fantastic sales! New users can grab an extra 100% off selected products, while loyal customers automatically qualify for that sweet $100 OFF when they apply the code at checkout. Imagine slashing prices by up to 90% on everything from trending electronics and stylish fashion to essential home goods and top-rated beauty products, all available across the USA, Canada, UK, and countless other countries! 🔥 Top Temu Code [ald244107] Benefits:  * For New Users: Use ald244107 for 50% off your first order + an additional $100 OFF.  * For Existing Customers: Apply ald244107 to get an instant $100 OFF on your next purchase.  * Global Reach: Valid across the USA, UK, Canada, Germany, France, Japan, Chile, Colombia, Malaysia, Mexico, South Korea, Philippines, Saudi Arabia, Qatar, Pakistan, and many more.  * Best of 2025: Secure up to $200 OFF plus incredible bonus discounts with ald244107. Maximize Your Savings: Featured Temu Deals for 2025 (Code: ald244107)  * ✅ Temu Flash Sales: Don't miss out! Score $100 off during limited-time offers with ald244107.  * ✅ Temu First Order Bonanza: Use ald244107 for a powerful 50% + $100 OFF on your initial purchase.  * ✅ Temu US Shopper Advantage: Instantly save $100 on your orders with ald244107.  * ✅ International Temu Discounts: ald244107 works seamlessly to give you savings in Japan, Germany, Chile, and beyond.  * ✅ Temu Community Favorite: Enjoy $100 OFF for both new and old users, a widely praised deal!  * ✅ Temu Coupon Bundles 2025: Combine $100 OFF with up to 50% slash deals for ultimate savings.  * ✅ 100% OFF Free Gift Code: Use ald244107 to claim a free gift – no invitation or referral needed!  * ✅ Temu Welcome Bonus: Get a delightful $100 OFF instantly upon signing up for an account.  * ✅ Free Temu Code for New Accounts: Apply ald244107 for immediate, hassle-free savings.  * ✅ Temu Clearance Blowout 2025: Use ald244107 for jaw-dropping 85–100% discounts on clearance items. This Temu code [ald244107] is more than just a discount; it's your all-access pass to complimentary shipping, exclusive first-order perks, and stackable coupon bundles across an immense selection of electronics, trendy fashion, essential home goods, and premium beauty products. Truly unlock up to 90% OFF plus an additional $100 OFF on eligible orders! 💡 Pro Tip: Always remember to apply ald244107 during checkout on the Temu app or website. Your instant $100 discount activates automatically, even if you're a returning customer! Where Does Temu Code [ald244107] Work? (Global Availability)  * 🇺🇸 Temu USA – ald244107  * 🇯🇵 Temu Japan – ald244107  * 🇲🇽 Temu Mexico – ald244107  * 🇨🇱 Temu Chile – ald244107  * 🇨🇴 Temu Colombia – ald244107  * 🇲🇾 Temu Malaysia – ald244107  * 🇵🇭 Temu Philippines – ald244107  * 🇰🇷 Temu Korea – ald244107  * 🇵🇰 Temu Pakistan – ald244107  * 🇫🇮 Temu Finland – ald244107  * 🇸🇦 Temu Saudi Arabia – ald244107  * 🇶🇦 Temu Qatar – ald244107  * 🇫🇷 Temu France – ald244107  * 🇩🇪 Temu Germany – ald244107 Hear From Happy Shoppers: User Reviews We love hearing about your experiences! Here's what some satisfied customers are saying about using the Temu code [ald244107]:  * Alice W., USA ⭐️⭐️⭐️⭐️⭐️ (5/5) "Great experience! Temu's promo code {ald244107} saved me a lot on my first order. Highly recommend this offer!"  * James T., UK ⭐️⭐️⭐️⭐️ (4/5) "Very happy with the quality and prices on Temu. The $100 credits offer was a nice bonus using {ald244107}. Will shop again."  * Sara M., Canada ⭐️⭐️⭐️ (3/5) "Got some decent deals with the {ald244107} code, though shipping took a bit longer than expected. Overall satisfied with the credits." Trending Verified Temu Deals for 2025 Stay ahead of the curve with the most popular and verified Temu deals for 2025. Our community consistently confirms the effectiveness of Temu code [ald244107] for maximum savings across a wide range of products. Don't miss out on these trending opportunities to save big! FAQs: Everything You Need to Know About Temu Code [ald244107] Q: What is Temu code [ald244107] and what does it offer? A: Temu code [ald244107] is a verified promo code that provides users with a $100 discount, plus additional savings of up to 50% or even 90% on various items. It's valid for both new and existing customers on the Temu platform. Q: How do I apply Temu code [ald244107]? A: Simply enter [ald244107] in the coupon or promo code field during checkout on the Temu app or website to apply your discounts automatically. Q: Does Temu code [ald244107] benefit new users specifically? A: Yes, ald244107 offers fantastic benefits for new users, including an exclusive 50% off their very first order in addition to the $100 discount. Q: Is Temu code [ald244107] also valid for existing customers? A: Absolutely! Loyal Temu customers can also enjoy a flat $100 OFF discount by seamlessly applying ald244107 at checkout. Q: In which countries can I use Temu code [ald244107]? A: This code boasts widespread global availability, working in numerous countries including the USA, UK, Canada, Germany, France, Japan, Saudi Arabia, Qatar, and many more listed above. Q: Can Temu code [ald244107] be combined with other offers? A: Temu code [ald244107] is strategically designed to provide savings on top of existing deals, making it often stackable with other promotions for truly maximizing your discounts. Unlock Huge Savings with Temu Code [ald244107] – Your Best Bet for 2025! Don't let these incredible savings slip away! Whether you're exploring Temu for the first time or returning for more great finds, the Temu code [ald244107] is your ultimate tool for significant discounts, exciting free gifts, and unbeatable deals. Apply it today and see how much you can save! Happy shopping! [ald244107]  
    • I've tried the java version you linked to and got a new exit code of 127 Here is the new console log I also tried making sure that I had Java 8 selected with the version of Java 8 I already had installed and got the same exit code Here is the console log with that installation in case it has any differences I do notice both say 'Java checker returned some invalid data we don't understand:' followed by 'Minecraft might not start properly.' which could be some issues.  
    • Thank you so much! I didnt see it in the log😭😭  
    • So im completely new to modding in general, i have some experience in Behavior packs in minecraft bedrock and i would like to modify entities stats and attributes like in a behavior pack (health, damage, speed, xp drop...). The problem is that i cant find any information online on how to do that, and I have no clue on what to do and where to start. I am currently modding in 1.20.4 with IntelliJ if that helps. My final objective is to buff mobs health and damage (double it for exemple), but since there is no entity file anywhere i don't know how to change it... 😢
    • Hey there, nothing to do with the code, I am just suggesting you use Intelij IDEA. Trust me, it is the best.
  • Topics

×
×
  • Create New...

Important Information

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