AlexModGuy / Citadel

A Library containing shared code used throughout most of my projects. Can be considered a continuation of LLibrary, of which this borrows the majority of its source code from.
30 stars 29 forks source link

[1.20.1] Modifier for spawn probabilities is not properly limited. #141

Open bconlon1 opened 12 months ago

bconlon1 commented 12 months ago

It seems that if too high of a value is assigned to chunkGenSpawnModifier in Citadel's config, it is capable of stalling certain biomes dependent on what their creature_spawn_probability value is set to. Due to how NaturalSpawner#spawnMobsForChunkGeneration uses a while loop that depends on checking a random float against the probability value, this means that the probability value can never be 1.0 or larger. For Vanilla, the default probability value given to biomes is 0.1, so it takes as high as a multiplier modifier of 10 to cause the Overworld to stall from an infinite spawn loop on generation. This can be more noticeable with other mods such as The Aether, which has a value of 0.25, and thus got noticed as stalling out with a modifier of 4 (https://github.com/The-Aether-Team/The-Aether/issues/1825). This infinite loop runs until the game runs out of memory and crashes. Fixing this would likely be doable by adding some kind of min-max check here https://github.com/AlexModGuy/Citadel/blob/06a3c35e5bc64c217fbf08be7308f1f2c277ca5e/src/main/java/com/github/alexthe666/citadel/server/generation/SpawnProbabilityModifier.java#L21 to prevent the new probability value from reaching or exceeding 1.0.

Orinai commented 9 months ago

yeah. I've been looking around for days trying to figure out what was causing runaway spawns in my world (literal hundreds of squids anytime i got near an ocean, for example), and finally nailed it down to this setting works. when set to it's default of 1.0 it is effectively disabling spawncap in my world. I had to dial it down to .125 to have something reasonable.