On public java servers I run, I like to let my players have villagers (I love those little nitwits), but a small colony of them can cause a fair bit of TPS loss and I end up resorting to rules like "only X villagers per village" and getting plugins like VillagerOptimizer which essentially turns them into mindless trading posts. From my understanding of the mechanics behind the default minecraft villager AI, this is because each villager is constantly locating and pathing to and then randomly fidgeting around their job blocks, bells, beds, and other villagers.
Maybe separating the pathfinding code from the moving code and having the pathfinding code only run if there is an important state change (weather, job block creation/destruction, block update near their intended path, bell rings, threatening entity focuses on villager, etc...) or only having their AI logic run every X ticks that could be configurable in the server config or gamerule could significantly reduce TPS loss.
Other ideas:
Allow turning off of socializing except for breeding.
Allow turning off or reduce desire to move and fidget about once reaching destination.
Some simple If/Then checks around their AI logic when they're in states like sleeping. "Is it morning, or has the bed broken?" No -> don't run any further AI logic.
Please sign in to leave a comment.
0 Comments