Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offset population by 8 blocks in x, y and z coordinates #4

Closed
Barteks2x opened this issue May 20, 2017 · 3 comments
Closed

Offset population by 8 blocks in x, y and z coordinates #4

Barteks2x opened this issue May 20, 2017 · 3 comments

Comments

@Barteks2x
Copy link

Barteks2x commented May 20, 2017

This is not a huge performance issue in CubicChunks thanks to changes made by xcube16, but it's still the wrong thing to do. Without these changes, your mod would immediateely crash with StackOverflowError. You are setting blocks at the x=0/z=0 border of the give chunk, which when given "do block updates" flag also notifies neighbors... which causes neighbor chunks to be generated. In vanilla this could cause infinite chain of chunk generation and population that would almost instantly crash. With cubic chunks it "only" causes generating more chunks. In the near future I'm going to add warnings when this happens.

Also it would break if I ever go back to the vanilla way (which isn't that unlikely).

So basically what you are doing:

# - the area you are populating.
The middle chunk is the one you got as CubePos.

+--------+--------+--------+
|        |        |        |
|        |        |        |
+--------+--------+--------+
|        |########|        |
|        |########|        |
+--------+--------+--------+
|        |        |        |
|        |        |        |
+--------+--------+--------+

And what you should do (this is also now explained in javadoc):

# - the area you are populating.
The middle chunk is the one you got as CubePos.

+--------+--------+--------+
|        |        |        |
|        |    ####|####    |
+--------+--------+--------+
|        |    ####|####    |
|        |        |        |
+--------+--------+--------+
|        |        |        |
|        |        |        |
+--------+--------+--------+

The reason for this is that the vast majoroty of populators need to set blocks outside of the directly populated area, like trees for example. If the middle chunk was to be populated directly, populating this one chunk could affect - in vanilla - 8 neighbor chunks, and - in cubic chunks - 26 neighbor cubes. This means that to make sure that all the chunks that affect the currently populated cube are populated, we would need to populate 27 cubes which would need actually generating a whole 125 of them.

Now we need to populate only 8 of them and actually generate 27.

@Foghrye4
Copy link
Owner

But if I set a flag to 0 it will work fine, isn't it?

@Barteks2x
Copy link
Author

Barteks2x commented May 20, 2017

it should but then you are doing it at your own risk. It will also potentially confuse other populators a bit, and you may break for example some earlier generated plant in half and it won't destroy the other half. It won't properly update liquids. It won't make sand and gravel fall. Abd potentially a lot of other hard to predict things.

Generally it's easier to just add that offset and not care about all the potential issues.

@Foghrye4
Copy link
Owner

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants