Jump to content

Stackoverflow Exeption during Chunk Generating.


Schleim_time

Recommended Posts

I created my own World Generator which add some Custom Plants, Trees and Grass. The problem that occurs is when i add more stuff, it start to Stackoverflow, but only during world creation in my custom biome (custom worldtype) , finding my biome in a normal worldtype dont cause it because not that much chunks will created at same i think. I heard it is because if i try to generate blocks outside of chunks, they will try to generate over and over again until they get placed causing that overflow if it will use that to often. However it is sometimes nessesary for me to generate more than only a chunk of stuff, like clusters of blocks like pumpkins they need to reach over chunks borders otherwise it will looks weird.

 

I had a few thoughts for a solution, one is to ask if the chunk of the block is generated and if it isnt the block will not be generated and added to a pos/block hashmap and will be asked again during the next chunk generation but i think that isnt a good way because on restart it will maybe cause cuts of blocks in the landscape after the map will be unloaded.

 

Does anybody of ou have a solution to fix the stackoverflow Problem? Maybe i am completly wrong with what i think about the problem.

Link to comment
Share on other sites

i found out what causes it but now im feeling dumber than bevore

Quote

for(int i = 0; i < perChunk; i++) {
            int rx = random.nextInt(16);
            int rz = random.nextInt(16);
            int x = chunkX * 16 + rx;
            int z = chunkZ * 16 + rz;
            int y = world.getHeight(new BlockPos(x,0,z)).getY();
            if(world.getBlockState(new BlockPos(x, y-1, z)) == Modblocks.WASTEGRASS_BLOCK.getDefaultState()) {
                world.setBlockState(new BlockPos(x, y, z), block.getDefaultState());
            }
        }

im wondering why, if i turn rz/rx to randomnextint14+1 no cascadeworldgenlag will be triggered and i have stripes in my decoration exactly at chunk boarders, if i do random16 it will only generate in the chunk but still trigger that gen lags :C oof can anybody explain why? i also tested to only populate the chunk at 0,0 i dont see any dekoration reaching over chunk boarders but cascade worldgenlag say other stuff

Link to comment
Share on other sites

3 hours ago, Schleim_time said:

can anybody explain why?

Neighbor block updates. When a block is placed next to an unloaded chunk it tries to give the block in the unloaded chunk an update causing the chunk to load.

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.

Link to comment
Share on other sites

6 hours ago, Animefan8888 said:

Neighbor block updates. When a block is placed next to an unloaded chunk it tries to give the block in the unloaded chunk an update causing the chunk to load.

Hey thank you for responding, i already fixed it but i need an explaination, i readed i have to add 8 to the random for some reason. If do rz/rx=random16+8 no lag be be fired but whyyy? I mean the plus 8 in my thought will surely trigger 3 neigbour chunks with a very high chance

Link to comment
Share on other sites

53 minutes ago, Schleim_time said:

Hey thank you for responding, i already fixed it but i need an explaination, i readed i have to add 8 to the random for some reason. If do rz/rx=random16+8 no lag be be fired but whyyy? I mean the plus 8 in my thought will surely trigger 3 neigbour chunks with a very high chance

Here is an excerpt from on of Jabelar's Tutorials.

Quote

To avoid this, vanilla Minecraft causes all decoration, ore and feature generation to be offset by 8 blocks in the X and Z with the neighboring chunks only then needing to be loaded in those directions. In other words, a single chunk is never generated on its own but rather always at least four. The generation then takes place around the center of where those blocks come together.

 

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.

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.



×
×
  • Create New...

Important Information

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