Fix fetching biomes during world generation
Fixes #11084
getBiome() on LevelReader calls getNoiseBiome(), which itself calls getChunk() in order to get the biome cached inside the chunk. However, calling getChunk() on WorldGenRegion will cause a crash if the chunk isn't found: "Requested chunk unavailable during world generation" This means that features which attempt to fetch biomes during generation (LakeFeature/SnowAndFreezeFeature) can cause the server to crash. This patch ensures that these features are fetching biomes in a way that doesn't call getChunk()
Currently running my server with this exact patch, works perfectly and server no longer crashes on LakeFeature. Would love to see this merged!
LakeFeature is deprecated and vanilla has moved away from using it for anything except for lava lakes. The error for unsafe chunk gets you are removing here is an intentional safeguard against bad code, such as that in the dead path in LakeFeature when creating water lakes. While it may appear to 'fix' the problem at hand it is not a proper solution and will cause other more serious problems to go undetected. This should be reported to Mojang if it's reproducible with a datapack. Given the circumstances I don't really think this is something we should care to fix, but if it is it would need to be a targeted change to LakeFeature for the aforementioned reasons.
This patch works, and stops my datapack heavy server (Terralith, Nullscape, etc...) from crashing. But, at the same time it makes new chunk generation performance x3-x4 worse! Why does it, and how can I make sure performance isn't so bad and it doesn't crash?
This patch works, and stops my datapack heavy server (Terralith, Nullscape, etc...) from crashing. But, at the same time it makes new chunk generation performance x3-x4 worse! Why does it, and how can I make sure performance isn't so bad and it doesn't crash?
Can confirm that this changed code is called very often during world gen and could therefore potentially have a negative performance impact, I will make just the two features which call getBiome() during worldgen (LakeFeature and SnowAndFreezeFeature) use the uncached biome instead of overriding getBiome() entirely on WorldGenRegion.
@fucksophie I changed the patch to fix the lake feature in a different way which shouldn't slow down world generation. Test it out and lmk
Hi @NewwindServer, can you please create a new issue with proper reproduction steps for 1.21? The issue you're linking that this PR fixes (https://github.com/PaperMC/Paper/issues/11084) was closed due to being incomplete and a deleted user.