Plugin Proposal: Disable distant villager AI

Post various suggestions here, if support is shown for your suggestion a vote will be started
Post Reply
User avatar
KoriJenkins
in iron armor
Posts: 196
Joined: Thu Mar 21, 2019 6:09 am

Plugin Proposal: Disable distant villager AI

Post by KoriJenkins »

This is in response to Burger's post at viewtopic.php?f=5&t=2789

Plugin concept: Villager AI is disabled if no players are within a certain distance, say 50 blocks. I've asked Kutecats to try and write this plugin, but if someone else wants to write it if the idea sounds good, go for it. Yukarion asked for pros and cons to be listed of such a plugin, so I'll do my best to come up with some.

Pros:

Villagers are one of the laggiest things on the server due to their horribly broken AI, and currently bases like CreaPat's are single-handedly destroying TPS due to an abundance of villagers.

Players wouldn't have to make trading halls far from their base to account for passive lag.

This plugin is entirely possible to make seeing as a different version of it exists to disable tamed mob AI if their owner is too far away.

Cons:

Could create situations where villagers just allow themselves to be killed.

Trades wouldn't reset unless a person was close to the villager.

Villager breeders would be impacted.


I'd like to hear suggestions though about how some of those cons could be eliminated. Maybe villagers could be invulnerable if no player was nearby to account for them not being able to flee from a threat? On the second con, maybe trades could be tweaked to reset twice a day regardless of whether it's day or night?

And some might call this "un-vanilla" but inherently any change is going to be that. The actual impact this would have on the game itself would pretty much not be noticeable. Villagers themselves aren't rendered if you're more than 50 blocks away anyway, so you wouldn't see them actually turning into lifeless robots.

Would like some thoughts though and maybe more information about villager AI. Does their AI even continue to function if they're out of render distance?
MoWobbler
in iron armor
Posts: 106
Joined: Sat Apr 06, 2019 3:38 am

Re: Plugin Proposal: Disable distant villager AI

Post by MoWobbler »

I was thinking about this as well. I found a plugin that implements this and I believe that we should try it. I asked Yukar around a week ago about plugins that try to prevent lag and he said he is not necessarily opposed to them. If it doesn't work or if it is damaging to the game, we can always remove it.
Plugin: https://www.spigotmc.org/resources/enti ... lag.70902/
User avatar
KoriJenkins
in iron armor
Posts: 196
Joined: Thu Mar 21, 2019 6:09 am

Re: Plugin Proposal: Disable distant villager AI

Post by KoriJenkins »

MoWobbler wrote: Fri Apr 02, 2021 2:45 am I was thinking about this as well. I found a plugin that implements this and I believe that we should try it. I asked Yukar around a week ago about plugins that try to prevent lag and he said he is not necessarily opposed to them. If it doesn't work or if it is damaging to the game, we can always remove it.
Plugin: https://www.spigotmc.org/resources/enti ... lag.70902/
Something I hope Yukar understands is that there's probably not going to be one single magic solution plugin. It's going to take a combination of two or three to address the main sources of lag individually without destroying their usage.

The villager change seems to be an ideal place to start though. If it only improved TPS by 1 on average, that's still an improvement over 0. Personally I'm of a mind that there's no real cons to writing a plugin to address them specifically given they de-render at a distance anyway.

There are a few very minor things that could actually be done on Sim right now. Chests cause some small amount of lag, and in an always-rendered spawn you might as well remove extraneous chests that have no use (those chests underneath Spawn have no use in any way and could simply be relocated somewhere that they aren't always rendered if I'm wrong and they do have a use). Same can apply to furnaces at Spawn and other container blocks. The improvement this would cause would be absolutely tiny, but it would still be an improvement.

There are probably a few other things like that at Spawn that could just be removed for the sake of improving TPS by a small amount.
Yukar9
Admin
Posts: 3242
Joined: Sat Aug 13, 2011 12:08 pm

Re: Plugin Proposal: Disable distant villager AI

Post by Yukar9 »

Spigot apparently has an option called tick-inactive-villagers. I've set this to false.
Post Reply