Skip to main content

Villager Optimization

An explanation of how villager AI works, why villagers are heavy on the server, and how to optimize them using plugins like FarmControl & AntiVillagerLag.


Villagers are one of the heaviest entities in Minecraft, even heavier than many other mobs. The reason is simple: villagers have complex AI, daily routines, block searching, pathfinding, and even a job gossip system. This section explains:

  • How villager AI works (the technical basics)
  • Why breeders & trading halls cause CPU spikes
  • How plugins like FarmControl, AntiVillagerLag, and server integration help control them

How Villager AI Works

Villagers run several AI processes every tick:

  • Job Search (Looking for a Workstation)
    Every villager searches for a workstation repetitively, checks pathfinding to the workstation, and changes jobs if a block is claimed/released. This is one of the biggest causes of CPU spikes.
  • Pathfinding
    Villagers try to reach their workstation, reach their bed, go to the bell, and interact with other villagers. Pathfinding -> a very expensive operation for the CPU, especially if villagers are given a lot of block space to move around in.
  • Sleep Cycle
    Villagers try to sleep -> fail -> repeat pathfinding -> fail again -> repeat.
    Common problems: bed taken, blockage, cramped position.
  • Restock Cycle
    Villagers restock twice per day: they check the workstation, run pathfinding, try to restock and repeat when they fail. If the workstation is far or unreachable -> spamming the AI loop.
  • Gossip System
    Villagers store reputation for each other, exchange gossip, and calculate trade prices. This process isn't very heavy, but it happens continuously.

Limiting Villagers with Plugins

By understanding the basics above, we can use plugins to help hold back or limit the server load. Here are the plugins & methods I often use:

AntiVillagerLag

AntiVillagerLag is a plugin that works to reduce lag from trading halls without breaking vanilla villager behavior. This plugin works by turning villager AI off and on flexibly so villagers can still restock and level up, but don't burden the server when they aren't needed.

  • How It Works (Briefly)
    Villagers can be optimized (AI disabled) using a nametag, block, or workstation depending on the configuration. When AI is disabled: villagers don't move, don't sleep, don't breed, and don't contribute to farms—so it's lighter for the server but they can still trade. Players can still click a villager to trigger restock and level-up.

  • Real-World Usage
    For real-world usage, you can see an example on Foxy Network:
    Player-facing documentation: https://wiki.foxy-network.net/gameplay-limits-and-rule/aturan-ai-villager
    Player-facing usage explanation (video):

Use Farm Control

Besides AntiVillagerLag, the FarmControl plugin is effective for limiting the number of villagers piling up in an area.


Written by Evan Andreyan (A.K.A LourenT) - Head of Development, foxy-network.net