Snow golems can continuously shoot snowballs. If these snowballs travel beyond the simulation distance, they accumulate, potentially causing a memory overflow or server crash. Before a crash occurs, if player movement causes the simulation distance to load tens or even hundreds of thousands of accumulated snowballs, will experience a lag spike lasting for some time.
(Even with the simulation distance set to 16, it’s not immune—weakly-loaded chunks still exist.)
It’s not limited to snowballs—this can happen with any projectile, such as llama spit.
This simple device can be built on any survival server—just position a few snow golems at the edge of weakly-loaded chunks; it's extremely easy.
How to reproduce
Set up a vanilla server with
enable-command-block
(enableCommandBlocks
game rule in 25w35a+) set totrue
,simulation-distance
set to5
, andview-distance
set to6
.Run the server with the attached world
Press the button next to the gold block to start reproducing
Stay on the diamond block
Wait awhile (you can speed things up by using
/tick sprint
)Click on the lever connected to the repeating command block to see how many snowballs are in the world
Notice how the message is getting biggerClick on the button connected to the normal command block
Notice how many snowballs flew out
Observed Behavior
Projectiles will accumulate if the simulation distance is lower than the render/view distance.
Expected Behavior
Projectiles will not accumulate to the point where they can lag the game or crash the server.
Linked issues
relates to 1
Attachments
Comments 6
This seems pretty much WAI as there isn’t a way to prevent entities from accumulating outside the loaded area without just deleting entities that go outside the loaded area, in which case you basically just don’t save entities to unloaded chunks. It goes without saying that spawning tons of entities in your minecraft world will eventually crash your game and there are many ways to do this with various types of entities and fundamentally it is up to the player to decide if that is what they want to do with the game.
This should not be considered WAI—just a few mobs standing at the edge of your simulation-distance can fire projectiles into weakly-loaded chunks, and sooner or later the game or server will lag or crash. We can definitely fix this; we need to brainstorm.
After all, you can’t guarantee every projectile stays close to you—any inadvertent movement by the player can leave those projectiles sitting in weakly-loaded chunks, where they keep piling up. Down the road, we’ll just keep getting vague reports of lag and crashes, and we’ll have to tell them, “Sorry, your game ran out of memory.
Countless players are affected by this issue without even realizing it, while malicious actors can deliberately exploit it in ways that remain virtually undetectable.
There are three types of entities: persistent entities (these don’t despawn, example: cows), semi-persistent entities (these can despawn, example: zombies), and non-persistent entities (these must despawn, example: skeleton arrows and dropped items). Non-persistent entities include things like items or projectiles.
I have provided those definitions for clarity. The game treats all entities in non-ticking chunks the same, and a case can be made that they should have different rules. Non-persistent entities are a problem for performance because they can be spawned in unlimited numbers, the mechanics of ticking chunks forces them to remain loaded in the world, consuming memory and causing instability.
An example I have seen in-game is where a chicken on the edge of loaded chunks lays eggs that end up in lazy chunks. I have seen hundreds of eggs accumulating in this way in one location after going AFK for several hours. Another example I saw in a Youtube video involved snow golems and snowballs. A third example involved non-persistent entities summoned with commands.
I propose the following mechanism to reduce the number of non-persistent entities in lazy chunks:
Projectiles, items or other similar non-persistent entities are given an owner: the entity that created them. Such entities are called “lazy” if they are in lazy chunks. For dropped items, only items that can generate without limit are considered.
Every entity that can create non-persistent entities has a limit on the number of lazy entities of that type it can possess at a time. This is calculated by the length of time before those entities normally despawn divided by the rate of production. Examples: Chickens can lay one egg every five minutes and eggs despawn after five minutes, so the number of lazy eggs each chicken can have at a time is 1. Skeletons can shoot arrows every 2 seconds and these despawn after 2 minutes, so the number of lazy arrows a skeleton can have is 60.
If an entity creates a non-persistent entity that ends up in lazy chunks and it has already reached its cap of lazy entities of that type, the non-persistent entity despawns immediately.
Would this mechanism cause gameplay problems? Maybe. However, I don’t believe any gameplay problems caused by limiting the accumulation of non-persistent entities are as serious as the instability caused by allowing these entities to accumulate without limit.
For a related issue, see: MC-148494
Please edit your report to change the Affected Version to the version shown on the Minecraft title screen