Add option to throttle spawn attempts after several failures
This patch adds an option to use a longer ticks-per-spawn for given mob types in chunks where previous spawn attempts have consecutively failed (e.g. spawnproofed chunks). The ticks-per-spawn and the number of failed attempts before they kick in are both configurable (the setting is disabled by default). The number of failed spawn attempts is stored with the chunk so it persists across unloads. As soon as a mob is able to spawn in a chunk, the failed spawn attempt counter resets and the chunk starts using the default ticks-per-spawn again.
This behaviour is useful on servers where players use mob farms. Mob farms typically require spawnproofing the surrounding chunks to improve rates, which causes the server to waste CPU cycles trying to find suitable spawn locations. By identifying suspected spawnproof chunks and throttling attempts at spawning mobs in them, it is possible to improve performance without noticeably affecting overall mob spawning behaviour.
I've been using a similar patch on my reasonably busy survival server for nearly a year without any complaints from players.
For illustrative purposes I ran a simple test spending 5 minutes AFK at standard spawning-tower mob farm which had been properly spawnproofed.
Without patch (default ticks-per-spawn):
With patch (multiplying default ticks-per-spawn by 10 after 1200 failed attempts):
It looks a bit like https://github.com/PaperMC/Paper/pull/9400
Similar concept, but different implementations targeted at different problems. The other PR relates to spawn attempts that are failing due to plugins cancelling or aborting the PreCreatureSpawnEvent, while this one primarily relates to chunks where mobs have repeatedly failed to spawn for other reasons (e.g. no suitable spawning locations)
This patch makes creeper farms not work. Can you fix this? https://www.youtube.com/watch?v=qyUZ0iXkdBA
This patch makes creeper farms not work. Can you fix this? https://www.youtube.com/watch?v=qyUZ0iXkdBA
Do you have a world download/schematic and configuration you could share?
The patch slows down spawn attempts in chunks that have repeatedly failed to spawn mobs - it shouldn't be stopping spawn attempts altogether. Make sure you're not configuring failed-attempts-threshold too low (I recommend setting it to 1200) or the throttled-ticks-per-spawn settings too high (I recommend setting them to 10x the normal ticks-per-spawn settings)
This patch makes creeper farms not work. Can you fix this? https://www.youtube.com/watch?v=qyUZ0iXkdBA
Do you have a world download/schematic and configuration you could share?
The patch slows down spawn attempts in chunks that have repeatedly failed to spawn mobs - it shouldn't be stopping spawn attempts altogether. Make sure you're not configuring
failed-attempts-thresholdtoo low (I recommend setting it to 1200) or thethrottled-ticks-per-spawnsettings too high (I recommend setting them to 10x the normalticks-per-spawnsettings)
I have already set it as you said. I think it happens because the Creeper Farm prevents zombies, spiders and skeletons from spawning and only allows Creepers to be spawned.
Do you have a world download/schematic and configuration you could share?
https://www.planetminecraft.com/project/creeper-farm-6175218/
I would imagine that anything relying on spawn proofing is generally going to suck hard with this sort of feature, the concepts are pretty much incompatible, IMHO.