Jump to content

Recommended Posts

Posted (edited)

Hello! I made a custom dimension and i got strange problem. Whenever I add any structure to generate in my dimension minecraft gets strange server lags. I tried everything. Changing way of registering biome,dimension, moving custom structure from custom biome decorator to Generator Handler that implements IWorldGenerator and then registering it in main class. Nothing helped. These server lags lasts for about 1-2 minutes, and then everything is just fine. During the lag, I cannot break blocks, entites are lagged, etc. When I do not generate the structure, my dimension isn't laggy. My dimension is multi biome and the bug occurs no matter which forge version I use. I am working on minecraft 1.12. I can post the whole code on github if someone knows what can cause these lags. What can be wrong?

 

Generators are copied from vanilla (changed only blocks).

 

  Reveal hidden contents

 

  Reveal hidden contents

 

Edited by Krevik
Solved
Posted
  On 3/24/2018 at 3:28 PM, jabelar said:

You might be causing "cascading" during generation. This is where during the generation of a chunk you place a block (or call a function such as looking at neighbor blocks) that causes adjacent chunks to have to load and generate.  Learn more about it here: 

 

 

 

Expand  

I actually knew about this. Lags occure even if there's no word about cascading in console

Posted

Well, when it is lagging there is something happening that is taking the computer's processing time. There are really three common categories of lag that modders can create:

1) cascading as discussed

2) inefficient loops. Like if you're searching an area for something over and over again.

3) improper use of wait loops or other code that halts continued execution of the thread.

 

Are you making custom trees? What is your full code for generation?

 

Anyway, you just need to observe what is taking the time. You can do this by either setting breakpoints and using debug mode in Eclipse to figure out what is executing or you can add judicious console or logger print statements to trace the execution. By looking at the timestamps you can figure out what is taking the time and narrow it down. Like if you put a print statement at the beginning and end of your methods you can see how long each is taking, or maybe see that they are being called much more times than you expect.

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

Posted
  On 3/24/2018 at 4:27 PM, jabelar said:

Well, when it is lagging there is something happening that is taking the computer's processing time. There are really three common categories of lag that modders can create:

1) cascading as discussed

2) inefficient loops. Like if you're searching an area for something over and over again.

3) improper use of wait loops or other code that halts continued execution of the thread.

 

Are you making custom trees? What is your full code for generation?

 

Anyway, you just need to observe what is taking the time. You can do this by either setting breakpoints and using debug mode in Eclipse to figure out what is executing or you can add judicious console or logger print statements to trace the execution. By looking at the timestamps you can figure out what is taking the time and narrow it down. Like if you put a print statement at the beginning and end of your methods you can see how long each is taking, or maybe see that they are being called much more times than you expect.

Expand  

Added code. Actually the problem is I tried a lot of structures e.g. some small constant structures like mushroom from blocks, and any of them cause these lags, even if (as I said) there is no word about cascading in console. Yea I am making custom trees but disabling them from generation doesn't help :/ Thanks will be trying with these print statements.

Posted (edited)

Do any of your blocks contain TileEntities?
Do any of your blocks do anything when placed?

 

and as Jabelar stated, you should try to see where everything is bottle-necking by comparing the before & after time of your methods/loops' executions.

 

Oh, and use bit-shifting instead of multiplying/dividing by 16.
By habit you'll likely (in the future) divide by 16 to get chunk-coordinate from a block coordinate. This will be incorrect for negative values, due to how integers are rounded down (-15/16 = -0.9375).

chunkX << 4 = blockX, blockX >> 4 = chunkX

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
  On 3/25/2018 at 4:25 AM, Matryoshika said:

Do any of your blocks contain TileEntities?
Do any of your blocks do anything when placed?

 

and as Jabelar stated, you should try to see where everything is bottle-necking by comparing the before & after time of your methods/loops' executions.

 

Oh, and use bit-shifting instead of multiplying/dividing by 16.
By habit you'll likely (in the future) divide by 16 to get chunk-coordinate from a block coordinate. This will be incorrect for negative values, due to how integers are rounded down (-15/16 = 0.9375).

chunkX << 4 = blockX, blockX >> 4 = chunkX

Expand  

Yes some of my blocks do something and they"re "ticking" but even if they"re disabled from generation lags occure. Also these blocks start ticking after these lags end. Yes I have some tileEntities but they"re not generated, they"re available only from crafting table. Thanks will remember about shifting! :D

Posted (edited)

Checked with these print Statements and it seems that structures are not causing these lags. Every structure is generated very fast and finished also. Lags occure even if no structure is actually being generated.  So It seems that generators are correct, but there's problem with something "higher".

Edited by Krevik
Forgot about sth
Posted (edited)

Found a solution. I was just using setBlockState method instead of 

setBlockAndNotifyAdequately

Even if no generate method was called there were lags (Idk why) but now the lags are gone

Edited by Krevik
forgot about State

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.