Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to throttle spawn attempts after several failures #11099

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

froobynooby
Copy link
Contributor

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 froobynooby requested a review from a team as a code owner July 17, 2024 13:18
@molor
Copy link

molor commented Jul 17, 2024

It looks a bit like #9400

@froobynooby
Copy link
Contributor Author

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)

Copy link
Contributor

@lynxplay lynxplay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the general concept of the patch 👍
Keeping this on the chunk presumably also makes sense, I think there is some discussion to be had regarding EnumMap and object Long usage, but beyond that, just some minor nitpicks.

patches/server/1042-Throttle-failed-spawn-attempts.patch Outdated Show resolved Hide resolved
patches/server/1042-Throttle-failed-spawn-attempts.patch Outdated Show resolved Hide resolved
patches/server/1042-Throttle-failed-spawn-attempts.patch Outdated Show resolved Hide resolved
@Potothingi
Copy link

This patch makes creeper farms not work. Can you fix this?
https://www.youtube.com/watch?v=qyUZ0iXkdBA

@froobynooby
Copy link
Contributor Author

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)

@Potothingi
Copy link

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)

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.

@Potothingi
Copy link

Do you have a world download/schematic and configuration you could share?

https://www.planetminecraft.com/project/creeper-farm-6175218/

@electronicboy
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Changes required
Development

Successfully merging this pull request may close these issues.

5 participants