The bug
Entities keep being accessible via the global entity list, even after the chunk they belong to appears to be unloaded (blocks can't be accessed with commands).
It appears that the entities only get removed from the global list once all chunks in a 23×23 area around them are unloaded. Though that might only be the case when the player leaves the chunks. By changing the render distance I was also able to get entities staying on the list which were over 30 chunks from the next loaded chunk.
How to reproduce
Setup: Superflat world, render distance 8.
Teleport away from the spawn
/tp 10000 100 0
Summon a tagged armor stand
/summon minecraft:armor_stand ~ ~ ~ {Tags:[MC141484]}
Run the following commands
/execute at @e[tag=MC141484] as @e[tag=MC141484,distance=..1] run say @s /say @e[tag=MC141484]
→ Both should output the entity
Teleport about 10 chunks away.
/tp ~160 ~ ~
Run the commands again
/execute at @e[tag=MC141484] as @e[tag=MC141484,distance=..1] run say @s /say @e[tag=MC141484]
→ Only the latter will output the entity now
Interpretation
/say @e[tag=MC141484]
This command will find entities using the global entity list, so it will be able to find the entity when it is on there.
/execute at @e[tag=MC141484] as @e[tag=MC141484,distance=..1] run say @s
This command will first find the entity using the global list but then use the local chunk list to find the entity again. Only if the entity can be found on both lists it will produce an output.
The bug is, that the entity is not removed from the global entity list.
If you keep moving further way and keep checking with the global entity list command, you will find that the entity will get removed from the global list once all chunks in a 23×23 area around it are unloaded.
Linked issues
relates to 3
Attachments
Comments 18
It seems that in latest snapshot either both commands give output or none of them does. Actual distance to teleport or walk before chunk unloads is bit higher than described though (>300 for chunk radius 8).
It still happens the same in 19w11b.
I think I described it badly, as one needs ignore the name in front in the outputs.
It will output the armor stand as long as it is on the global list, but only also have a second "Armor Stand" behind it if it is also on the local list.
When running the command:
/execute as @e[tag=MC141484] at @s run say @e[distance=..1]
The output before teleporting is:
[Armor Stand] Armor Stand
The output after teleporting is:
[Armor Stand]
That the name in front shows that is was found on the global list (aka @e[tag=MC141484]), while the name in the back shows that it is on the local list (aka at @s say @e[distance=..1]). Sorry for the confusion.
Thank you for looking into this!
@edit I replaced the commands in the post to only have an output if it is on the list. So now there is really no output for the command when the entity isn't on both lists.
Things start to get more clear. Especially
[media]helps a lot 🙂
Paraphrasing again to avoid misunderstandings:
So some actions can place tickets on chunks to force them to load, generate (different levels) or load the surroundings.
You named a few things that can place tickets and what ticket level they have, like players and spawn chunks. I assume random ticks and block updates probably both cause (temporary) ticket level 33, judging by the level of the "unknown"s?
And then there is actions that only run if there is a certain ticket level in the chunk.
What I currently got from testing:
Thing | Required level |
---|---|
Entity processing | <=31 |
Accessing the entities via global list | <=31; should probably be <=33 |
Accessing the entities via local list | <=31; should probably be <=33 |
Running scheduled ticks | <=33 |
Tileentity processing | <=33 |
Block events | ? (at least <=33) |
Accessing blocks (e.g. setblock) | <=33 |
In a few weeks I will have time to test these things in more detail.
To the couple of other things
The chunks that kept their ticket level when moving around with server lag kept that level even after the lag was gone. Only "picking them up" again would remove it. I will try to recreate it when I got time and make a report if it still happens.
I was about to ask why the player doesn't have just one ticket, thanks for clarifying 🙂 (Also I think the player had one ticket until one of the first snapshots of this year, as this probably caused MC-141483)
Haha, I would have taken you for the author after giving that detailed explanation. Just out of curiosity, may I ask who the author is?
About the 2 wide ticking border
After reading this second part of the explanation, I'm pretty sure what I described is due to ticket level 33 (border) is being handled differently than ticket level 34 (border).
This means MC-141482 is the same behaviour as the 2 wide border I described for the chunks around player placed tickets.
It's about /forceload "loading" more chunks than specified. Forceloading a chunk currently makes it's neighbours accessible as well.
Also the list of required levels above pretty much describes the observed already. Most things require <=33 (so a level classified as "border") rather than <=32 (which would be "ticking").
To test this behaviour:
1. Forceload a chunk
2. Take note of coordinates of any block in a chunk next to the forceloaded chunk.
3. Get far enough away for it to not be affected by the players ticket level
4. Run this command on the coordinates you took note of:
/execute unless block <x> <y> <z> air{N:O} run say chunk is loaded
The command only has an output if the blocks in the chunk can be accessed.
It will produce an output for chunks next to a forceloaded chunk.
Obviously it will also produce an output for chunks next to the "ticking" chunks caused by a players tickets.
Alternatively you can place a repeating command block with a say command in the chunk. That only runs if scheduled ticks get processed, so if you still get outputs that indicates that ticket level 33 still runs scheduled ticks. (and it does)
I you are looking at chunk loading logic and entity lists these two issues might also interest you:
It seems that double BORDER layer may not be correct and caused by "magic value" at one point was changed from 32 to 33 - some places might not be updated. Anyway, values posted here are probably not final.
Also, right now only requirement for block entity ticking is level 33, so yes, inner layer of border chunks will tick. This is also probably a bug. Though it seems that random tick and other things work only on level 34.
I'm not sure if `/execute unless block` is proper test for ticking chunk, command block method seems like better way of checking for it.
And yes, unknown tickets are from random ticks, or more specifically, any access to chunk (players also create one when checking for blocks around, but only lowest ticket is shown in dump).
Fair point, the `/execute unless block` only detects if commands got the proper clearance for the chunk, which may or may not be the same as ticking.
I mentioned the command first, because this is what I used to query and display the status of chunks in game (which is how I noticed it in the first place). The command block method doesn't work well for that, as the block already needs to be in the chunk.
A `/getticketlevel <x> <z>` would be really useful for debugging *hint**hint* 😛
A /getticketlevel or similar would be awesome!
That'd be so extremely helpful.
Thank you to both of you for additions/explanations 🙂
Relates to MC-142022 and MC-138871.