Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Add option to throttle spawn attempts after several failures

Open froobynooby opened this issue 7 months ago • 7 comments

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): image With patch (multiplying default ticks-per-spawn by 10 after 1200 failed attempts): Screenshot from 2024-07-17 22-08-00

froobynooby avatar Jul 17 '24 13:07 froobynooby