Open waseric opened 3 years ago
You're absolutely right, thanks very much for investigating this! The SpawnEvents class isn't even initiated when limits are disabled:
Should be an easy fix.
Do need to add some condition tho, because guardians will keep spawning otherwise:
Perhaps just make it just be a chance that it will spawn a guardian instead of the original watermob (once conditions are met). It could even be a fairly low chance. (e.g.: 5-20%). At the rate water mobs spawn, this would still create a decent chance. It might be somewhat closer to vanilla survival, too...
Did some testing tonight with probability, but I'm not sure about the right approach here.
If we alter the spawning of guardians to spawn with a 0.2 chance, the server will stop spawning guardians when there is enough "regular" fish in the water. Some fish has to be killed then to restart the guardian spawning process. I'm unsure if that's what we want, especially on most of the servers with spawn-limits enabled.
We could always cancel the spawn event, even when the fish isn't replaced with a guardian. That does lower the speed at which guardians spawn obviously, but still leads to a huge amount of guardians after a few minutes.
It would be an option to always cancel the spawn event when limits are enabled, and don't when disabled. But I don't think that would be a good solution, is it?
I could create a test build if you prefer btw.
The description for the deep ocean biome says that passive mobs will not spawn. Hostile mobs (including Guardians) will spawn normally.
While, of course, the behavior can change, and the documentation could be updated, I think the "documented" behavior supports the idea that we always cancel. It WILL still result in a large number of guardians over time, but really, if the operator is choosing to not set limits, they're saying that's ok.
The wiki for the guardian lists a 95% spawn failure rate in a number of conditions. I would be completely comfortable with a 95% failure rate (.05 probability). Even then, that's still giving excellent chances given the normal spawn rate of water mobs. It just slows things down a little bit.
Lets go with cancelling all the events then. My biggest concern is that users will start altering these settings without checking, and start complaining then.
Default failure rate of 95% sounds reasonable, but that seems like a good setting to add to the config.yml. Not that hard too. And a good place to add a warning that it might flood the server with guardians when spawn-limits are disabled.
Will update the PR soon.
Please paste the output from
/usb version
belowWhat steps will reproduce the problem?
We had been trying to avoid adding spawn limits, so hadn't turned the option on. After isolation for other plugins, servers, config elements, changing this config item is consistent.
Our workaround is to enable limits, with a fairly high threshold. So, impact is low once we know the cause.
With limits disabled, I'm pretty sure we're not getting past SpawnEvents.java:onCreatureSpawn call to checkLimits. That, in turn, is likely canceling based on call to LimitLogic.java:canSpawn. canSpawn focuses on maximums, which (probably) aren't relevant if limits aren't enabled. Maybe just a first test in canSpawn if limits config is enabled?