How to Fix Entity Lag in Minecraft
Fix entity-related lag and TPS drops in Minecraft servers. Covers mob caps, activation ranges, entity culling, and farm optimization for 1.21+.
How to Fix Entity Lag in Minecraft
The Problem
/spark profiler report:
ServerLevel.tickNonPassenger - 42.8%
LivingEntity.tick - 28.3%
Mob.tick - 18.6%
PathFinder.findPath - 12.1%
Entity counts: 3847 loaded, 1209 in mob cap
Entity lag is the most common cause of low TPS on Minecraft servers. Every loaded entity (mobs, items, armor stands, minecarts, arrows, experience orbs) is processed ("ticked") every server tick (50ms). When thousands of entities are loaded, entity ticking dominates the tick loop and pushes tick time above 50ms, causing the server to fall behind.
Quick Fix
Reduce mob spawn limits in paper-world-defaults.yml. Set monsters: 50, animals: 8, water-animals: 3, ambient: 1. Enable per-player-mob-spawns: true. This immediately reduces the number of entities the server ticks.
Step-by-Step Diagnosis
- Count entities. Run
/paper entity listto see entity counts per chunk. Look for chunks with 50+ entities, these are your problem areas (usually mob farms or animal pens). - Profile entity ticking. Run
/spark profiler start, wait 5 minutes, then/spark profiler stop. In the report, look at the percentage fortickNonPassengerandLivingEntity.tick. If these exceed 30%, entities are your bottleneck. - Identify entity types. Run
/paper entity listto see which types dominate. Common offenders: zombies (pathfinding), villagers (complex AI), dropped items (physics and merging), and armor stands (custom plugins using them for holograms). - Reduce spawn limits. Lower the values in
paper-world-defaults.ymlunderspawn-limits. The vanilla defaults are too high for most servers. - Enable entity activation ranges. In
paper-world-defaults.yml, setentity-activation-rangeto skip AI ticks for entities far from players. Monsters beyond 24 blocks, animals beyond 16, and miscellaneous entities beyond 8 blocks will have reduced AI processing. - Clear excessive entities. As an immediate measure, run
/kill @e[type=item]to clear dropped items, and/kill @e[type=zombie,distance=..100]to clear zombies in a radius. Set up automatic entity clearing with a plugin or command block. - Audit player builds. Large mob farms, animal breeding pens, and villager trading halls are the most common sources of entity lag. Work with players to add kill mechanisms to their farms and limit animal counts.
Key Configuration Settings
paper-world-defaults.yml
spawn-limits:
monsters: 50
animals: 8
water-animals: 3
water-ambient: 5
ambient: 1
per-player-mob-spawns: true
entity-activation-range:
monsters: 24
animals: 16
raiders: 48
misc: 8
villagers: 16
tick-inactive-villagers: false
despawn-ranges:
soft: 28
hard: 96
alt-item-despawn-rate:
enabled: true
items:
cobblestone: 300
netherrack: 300
dirt: 300
sand: 300
Common Causes
- Unoptimized mob farms. Farms that spawn mobs without killing them quickly accumulate hundreds of entities. Require kill mechanisms in all mob farms.
- Dropped items. Mining, farming, and mob drops create item entities that are ticked for physics and merging. Accelerate despawn rates for common junk items.
- Villager AI. Villagers have the most expensive AI in vanilla. They pathfind to beds, job sites, and bells every tick. Limit villager counts per chunk and disable
tick-inactive-villagers. - Armor stand holograms. Plugins that create holograms using armor stands can spawn hundreds or thousands of invisible entities. Use packet-based hologram plugins (like DecentHolograms) instead.
- Experience orbs. Large mob farms produce massive quantities of XP orbs. Paper merges nearby XP orbs, but older server software does not.
FAQ
Will reducing mob spawns break mob farms?
Farms will produce less, but they will still work. per-player-mob-spawns: true distributes the mob cap fairly among players, so a player at a mob farm does not consume the global cap.
What is the ideal entity count for a server?
There is no single number. As a guideline, keep total loaded entities below 2000 for a 20-player server. Monitor TPS and adjust limits until you find the balance between gameplay and performance.
Does entity activation range break mob AI?
Entities outside the activation range still exist and are visible, but their AI ticks less frequently. Players may notice mobs standing still in the distance. This is a trade-off between performance and immersion.
Need a server that handles all this? Astroworld Hosting, NVMe SSDs, Pterodactyl panel, DDoS protection on every plan.