Jump to content

World Generation 1.12


Flemmli97

Recommended Posts

Hello. Currently i am trying to add structures via schematics/nbt to the world. Since the structures aren't chunk sized i would get the "cascading worldgen lag" issue if i just add them to the world.

I tried looking into how minecraft does it but it was really confusing for me so i wrote my own handling instead.

For that i took this approach:

I first search for a position, where the structure can spaw, save it into a WorldSavedData instance and then try generating the structure.

To make sure the structure doesn't go into unloaded chunk everytime before a block is placed i check for the neighbor blocks, if they are in loaded chunk via world.isChunkGeneratedAt(pos).

if they are, i save that chunk so later, when that chunk gets loaded i generate that chunks part of the structure.

Somehow though that check isn't completely good since i'm still occasionally getting that log. Am i missing something there?

 

The project is on github: https://github.com/Flemmli97/RuneCraftory/tree/master/src/main/java/com/flemmli97/runecraftory/common/world 

 

Link to comment
Share on other sites

Cascading chunk gen happens when you attempt to place blocks into a neighboring chunk that hasn't been created yet.

 

Vanilla avoids this by offsetting the generation by +8 and +8 (as the neighboring positive X and Z chunks are guaranteed to already exist, and won't cause them to get generated)

  • Like 1

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.

Link to comment
Share on other sites

thats why before i place a block i test wether the chunk is loaded and wether it will load neighbor chunks. it seems not to work in 100% of all cases though.

Spoiler

 


private boolean isNeighborChunkLoaded(World world, BlockPos pos, List<Position> list)
	{
		BlockPos west = pos.offset(EnumFacing.WEST);
		BlockPos north = pos.offset(EnumFacing.NORTH);
		BlockPos east = pos.offset(EnumFacing.EAST);
		BlockPos south = pos.offset(EnumFacing.SOUTH);
		boolean flagPos = world.isChunkGeneratedAt(pos.getX()>>4, pos.getZ()>>4);
		boolean flagNorth = world.isChunkGeneratedAt(north.getX()>>4, north.getZ()>>4);
		boolean flagWest = world.isChunkGeneratedAt(west.getX()>>4, west.getZ()>>4);
		boolean flagSouth = world.isChunkGeneratedAt(south.getX()>>4, south.getZ()>>4);
		boolean flagEast = world.isChunkGeneratedAt(east.getX()>>4, east.getZ()>>4);
		return flagPos&&flagNorth&&flagWest&& flagSouth&& flagEast;
	}

 

Link to comment
Share on other sites

I think you just need to go through standard debug -- add some console or logger print statements at critical points in your code and have it print out useful info like what location it is trying to modify. Basically you need to catch the cascading generation "in the act". Once you observe the failing case it is usually pretty obvious what went wrong.

Edited by jabelar

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

Link to comment
Share on other sites

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.