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

Surface Block Generation Chance Depends on World Height #5378

Open
mrgrim opened this issue Feb 23, 2025 · 2 comments
Open

Surface Block Generation Chance Depends on World Height #5378

mrgrim opened this issue Feb 23, 2025 · 2 comments
Labels
department: code Issues apparently caused by code

Comments

@mrgrim
Copy link

mrgrim commented Feb 23, 2025

I noticed this while seed hunting for worlds with large amounts of obsidian rocks. The higher the world height, the less likely top layer obsidian would produce surface stones. This can be seen at https://github.com/anegostudios/vssurvivalmod/blob/81e52e9a61eabd6aa2131fb255f072feaf9901f1/Systems/WorldGen/Standard/ChunkGen/5.GenDeposits/Generators/DiscGenerator.cs#L359.

int surfaceY = heremapchunk.RainHeightMap[lz * chunksize + lx];
int depth = surfaceY - posy;
float chance = SurfaceBlockChance * Math.Max(0, 1.11f - depth / 9f);
if (surfaceY < worldheight - 1 && DepositRand.NextFloat() < chance)

The hard coded 9f I believe is the problem. Since everything is percentage based, taller worlds are penalized in this calculation. This constant should be scaled to either sea level or world height.

@mrgrim
Copy link
Author

mrgrim commented Feb 23, 2025

I've been doing a little more digging, and I suspect the sea level is being set after the deposit generators are initialized. This would explain even better the behavior I'm seeing especially with obsidian. The deposit variants are loaded in the AssetsFinalize stage of the GenDeposits ModSystem, but the world height is set in the StartServerSide of the GenTerra ModSystem.

GenTerra's execute order is later, but it's unclear to me if mod initialization is "interleaved". As in, is AssetsFinalize called for all mods before any mods StartServerApi is called?

I'm not sure if it's safe to delay initializing deposit variants or move the world height setting to an earlier phase.

@Craluminum2413 Craluminum2413 added the department: code Issues apparently caused by code label Feb 23, 2025
@mrgrim
Copy link
Author

mrgrim commented Feb 24, 2025

I've created a new issue for what I described above, #5386. The surface rock generation and deposit generation issues are separate things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
department: code Issues apparently caused by code
Projects
None yet
Development

No branches or pull requests

2 participants