Closed m00nl1ght-dev closed 1 year ago
Looks good to me
My only worry would be compatibility issues if mods patch NaturalRockTypesIn
to modify the allNaturalRockDefs
list. Not sure how many do, though.
It's only applied when the list is null I think
Yeah in that case the field is already initialized and this code doesn't change anything.
Currently the method
RockUtility.PossibleRockTypesFor
relies onWorld.allNaturalRockDefs
being initialized. However, there are mods that add a prefix toWorld.NaturalRockTypesIn
to override the result, such as "Configurable Maps" and "World Edit".In that case, the vanilla code is skipped and
World.allNaturalRockDefs
is never initialized. This results in an NRE inRockUtility.PossibleRockTypesFor
and causes map generation to fail, and the world map UI to freeze.This PR makes
RockUtility.PossibleRockTypesFor
more resilient against this kind of mod compatibility issue, by ensuringWorld.allNaturalRockDefs
is initialized before it is used.Side note: Alpha Biomes started using the affected code in its latest update, and is often used together with the mentioned mods, which is why this issue pops up often in reports now.