Entity (de)spawning and AI
As entities are one of the biggest server lag sources for multiplayer, the spawning rules have been heavily modified to accommodate for multiplayer. Our modifications aim to achieve a balance between providing a familiar experience and being computationally capable for the server.
Tracking range
Entities are only viewable to players while they're within a specific range of them. This is called their tracking range. Tracking range is entirely clientside, and helps reduce latency and improve FPS by only rendering entities that are closeby. Players: 145 blocks Hostiles: 55 blocks Animals: 48 blocks Misc: 32 blocks
Spawning
Per dimension, within physically ticked chunks (3 chunk radius or 48 blocks in all directions around players) the server will spawn no more than a certain number of entities of particular types. Chunks are consistently being loaded & unloaded, meaning the cap for how many of these entities can spawn is constantly shifting. The total amount of entities spawned & observed in the world is much higher than these caps (this is what observed entities refers to). Entities spawned when the chunk was ticking will persist within unticked chunks with an exception of hostile entities at a certain distance unless nametagged (see despawning section). No entities spawn in unloaded chunks.
Entities are spawned spread amongst all players until their cap is reached. This means at peak activity times, you'll notice less entities around you as they're more spread out. Already existing entities around players are taken into account before spawning new ones. The server will favor spawning entities near players which are not around specific entity groups and are in spaces which meet those entities' spawning requirements over other players who are already around those entity types. This enables a more singleplayer-like and balanced spawning experience while keeping resource use reasonable. Spawn rate refers to how frequently the server checks conditions around players as well as computes which applicable player the mob should spawn near. An entity is not always successfully spawned every spawn rate, for example when the cap is reached or there are no locations near players meeting the spawn requirements. Consistent with Vanilla behavior, mobs will not spawn within a 24 block radius of players. With the other settings, this means auto farms cannot exceed a radius of 32 blocks for spawning. This also makes the ideal AFK position is just under 48 blocks away.
Hostiles Cap: 52 Observed entities (avg): 300-800 Spawn rate: 0.5 seconds
Animals Cap: 12 Observed entities (avg): 50-200 Spawn rate: 20 seconds
Axolotls Cap: 5 Observed entities (avg): 10-40 Spawn rate: 20 seconds Sea creatures Cap: 8 Observed entities (avg): 20-90 Spawn rate: 20 seconds
Despawning
Range-based despawning
Hostiles & sea creatures Chance to despawn when: >28 blocks Immediately despawned when: >48 blocks horizontally, and >128 blocks vertically
Radius-based (mob cap) despawning
Good to know
Nametagged and tamed mobs are exempt from despawning
Overflow mobs are checked and despawned once every 65 seconds, meaning you can have mobs exceeding the limits temporarily but they will be at risk of being removed
Radius is calculated from each mobs position, meaning you'll want to have a gap of at least the radius starting from the outermost mob
Animals (pig, cow, sheep, chicken) Main cap: 22 Within: 14x14 blocks Secondary cap: 10 Within 2x2 blocks Rabbits Cap: 12 Within: 15x15 blocks Bees Cap: 12 Within: 8x8 blocks Villagers Cap: 8 Within: 6x6 blocks Iron Golems Cap: 8 Within: 15x15 blocks Turtles Cap: 8 Within: 7x7 blocks Frogs Cap: 20 Within: 15x15 blocks Pandas Cap: 8 Within: 15x15 blocks Armor Stands Cap: 20 Within: 6x6 blocks Paintings Cap: 10 Within: 10x10 blocks Ender Crystals Cap: 5 Within: 6x6 blocks Boats Cap: 6 Within: 15x15 blocks Minecarts Cap: 8 Within: 13x13 blocks Item Frames Cap: 120 Within: 15x15 blocks Exclusive to creative plots & the parkour course builder
Additional
These entities are despawned by range-based and radius-based despawning to fine tune their spawning behavior
Lifetime-based despawning
Arrows: 500 ticks - 25 seconds Creative arrows: 200 ticks - 10 seconds Tridents: 1200 ticks - 1 minute Items: 1200 ticks - 1 minute ("junk" items despawn faster for server performance, see below)
A tick refers to the game loop firing. Without lag, the game runs at 20 ticks per second, updating entity AI, block changes, and everything else in the game.
Entity AI
Entities AI allow them to interact with their surroundings, whether by moving, reacting to damage, or other events. Only entities which are close enough to players retain their AI. The server uses two main algorithms for determining an entity's AI: EAR (entity activation range) & DAB (dynamic activation of brain). EAR works by fully activating entity AI if they are within a defined radius of players. DAB takes this a step further and reduces the amount an entity is ticked the further away it is from players. It works on a gradient instead of a hard cutoff like EAR; instead of fully ticking close entities and barely ticking far entities like EAR, DAB reduces the frequency an entity is ticked (lessens their AI) based on the exact distance they are from players. DAB provides major optimization to entities performance hit without being very noticeable, and allows the server to spawn more mobs at the cost of reducing the AI or activity of mobs further away from players. In mob farms congested with entities, additional one-off algorithms selectively disable & re-enable random pathfinding movement, collisions, and in some cases entirety of AI, even when within EAR range.
EAR ranges
Hostiles: 24 blocks Animals: 16 blocks Villagers: 14 blocks Raiders: 48 blocks Water creatures: 32 blocks Misc. entities: 8 blocks
DAB
Begins ticking less frequently on a gradient when: >8 blocks away Slowest tick frequency: every 30 ticks when at a distance of 20 or more blocks away Ghast, Slime, and Endermen are exempt from DAB.
When AI is fully activated, entities are ticked every single tick (20 times / sec).
Last updated