EDIT: Was unable to find specific cause for the problem, will post crash report
Teleport away from spawn chunks before doing any of the below.
Summon armorstand using below command:
/summon ArmorStand ~ ~ ~ {CustomName:"tank"}
Create testing objective
/scoreboard objectives add testObjective dummy
Set objective to sidebar:
/scoreboard objectives setdisplay sidebar testObjective
Set 'tank' score:
/scoreboard players set @e[name=tank] testObjective 1
Afterwards, unload chunks by teleporting away.
tp @p ~500 ~ ~
Notice that the score on the sidebar dissapears, proving that the score resets after the entity is unloaded.
Steps to reproduce can be found in this comment
Code analysis: https://bugs.mojang.com/browse/MC-96131?focusedCommentId=306331&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-306331
Related issues
is duplicated by
Attachments
Comments


EDIT: The title is false, although I redid my custom map to use another entity name, but the problem still occurred when the entity (with the adjusted name) is unloaded. It seems to me that entities having their scores changed often by command blocks have their scores reset when unloaded.

You can edit your title.
Could not reproduce, score remains on the scoreboard. The score should only be removed automatically if the entity is killed. Ensure no other command blocks are interfering (such as killing the armor stand).

can confirm this with my custom AI entity made of command blocks and armor stands

Can you attach a world download that includes it for replication?

Yes, but is's a big and rather laggy world due to amount of commands running, so be warned.
I can't as of now, as I'm about to go to school.
I'll attach screenshots as well then.
For some reason this only appears to happen with armor stands (that I know of), as for example ghast, enderman, creepers and items are uneffected.

here's screenshots of the process, I seem to be only capable to make it happen in this world, as a newly created world, doesn't have this problem.
http://www.mediafire.com/download/n59vs05t0t8di1e/MC-96131.zip
can this please be reopened?

Hum, I still could not reproduce it even using your world and following the steps in the screenshots.
EDIT: Figured it out, you have to open to LAN for this to occur in your world.
That said, I could not reproduce it in a new world. I've noticed your tickrate is extremely poor (running at 10t/s instead of 20t/s) due to the sheer number of commands being executed constantly, which is probably contributing to this problem.

or run it on a server, I know about the tick rate problem, and I'm trying to make eveything as compact as possible to lower the tick lag.
((If you want to help me out, to fix the tick lag, contact me on minecraft forum, I'll give you the server IP and we'll take a look together, any help is much appreciated))

I'm having this trouble too, but it is not all entities, only particular ones. All are having their scoreboard values checked or modified frequently, and I do have a slight bit of server lag (Just enough to be noticeable when punching enemies). Some entities are unaffected and reliably (Reliable as far as I can tell, anyways) retain their scoreboard values while others occasionally lose them.

A really helpful one-command that I made is broken because of this bug. Please fix it!

still an issue in 1.9.4, I add a score to an entity, (I've tried different score types like dummy and item.stick.use), display it to the sidebar, then leave the area and when the chunk becomes unloaded the score resets on any entity inside. This glitch happens in my worlds even when the amount of command blocks is low, and in singleplayer.

I also have not been able to reproduce this. If you can reproduce it, please add a bit of detail, such as what type of entity type you're using, how far you teleported, what your render distance is, whether either side of the teleporter is spawn chunks, whether it's single player, LAN, or server, etc.

Okay, after like 5 hours of testing I have a new suggested title "/execute detect command causing entities within a chunk to be scoreboard reset" and i will explain why.
What I have found is the steps to re-produce in any world, no matter the tick rate, (I have only tested in singleplayer but I assume multiplayer does this too since you all have said you have opened to lan and reproduced it)
1) Spawn in a world, just do superflat to make it easier (also make the world creative mode )
2) use /setworldspawn, and mark the spawn with anything you choose, just so you know where your spawn was
3) give yourself a command block, and place it down anywhere as long as it should be in a spawn chunk, so near where you marked.
4) enter this into the command block:
/execute @e[type=Armor_Stand,name=Test] ~ ~ ~ detect ~ ~ ~ minecraft:air 0 /say @p[r=1] testing
(sometimes the command block may not register it should be always active, so you may need to toggle that again)
5) make it a repeat command block along with always active
6) teleport 500 blocks away in any direction (although 300 seems to fine as well {MY RENDER DISTANCE: 10 chunks}, as long as the chunk un-loads from view)
7) mark out the chunk you are in, and use this command inside of that chunk:
/summon minecraft:armor_stand ~ ~ ~ {CustomName:Test}
(you should see the command block begin to make it say "(your_name) testing", just step away from it a bit)
8) now place another armorstand OUTSIDE that chunk, just place it down using any method using the default item even
9) Now use these commands with both armorstands in view
/scoreboard objectives add Test dummy
/scoreboard players set @e[type=Armor_Stand,c=1,name=Test] Test 1
/scoreboard players set @e[type=Armor_Stand,c=1,name=!Test] Test 2
/scoreboard objectives setdisplay sidebar Test
(that should make both appear on the scoreboard)
10) Now go back to spawn using any method you choose, teleport or flying/walking back
11) The one with the score of 1 should disapear off the scoreboard, and the other one should stay on the scoreboard, if not, then place a block or something else to update chunks in the world.
There, that should succesfully re-produce the bug.
Some interesting facts:
-If you put MORE armorstands (with scoreboard values set) into the chunk that the "Test" armorstand is in, they ALSO will have their scores reset, yet the armorstand outside of the chunk will keep it's scoreboard value.
-If you make the command in the command block into:
/execute @e[type=Armor_Stand,name=Test] ~ ~ ~ /say @p[r=1] testing
and then go back over (making sure both armorstands have their scores set to 1 and 2) and then come back, it will not reset their scores.
--If you remove the name parameter from the command block to make it:
/execute @e[type=Armor_Stand] ~ ~ ~ detect ~ ~ ~ minecraft:air 0 /say @p[r=1] testing
and then go back over (making sure both armorstands have their scores set to 1 and 2) and then come back, BOTH should have their scores reset when the chunk becomes unloaded
-If a score is not unloaded when I said it would be, again try placing blocks, moving around, or re-loading the world possibly, to cause the chunk to properly unload from the world, sometimes teleporting can leave a chunk loaded for a moment or two. (Sometimes clicking the command block then clicking out of it can cause chunk updates as well.) Or check if the command block is always active, as in making it "needs redstone", clicking done, then clicking back in and making it "always active".
EDIT: made it so the commands still work in the latest snapshot, but god knows why mojang decided to make it armor_stand, but the commands should work now

I can confirm @unknown's analysis. The particular line using 1.9 MCP is in class CommandExecuteAt
that seems to be causing it:
IBlockState iblockstate = world.getBlockState(blockpos1);
I can't currently look further into it though.

Please link to this comment in the description
The following is based on a decompiled version of Minecraft 1.9 using MCP 9.24 beta.
The reason for this is that the detect
function of the /execute
command does not test if the block position is loaded before calling the net.minecraft.world.World.getBlockState(BlockPos)
method. Because of this the chunk is loaded again and in combination with MC-102348 the entity (in this case ArmorStand) is dangerously removed and its scoreboard entries are removed as well.

Can someone explain the title to me? It used to be titled something about how scoreboards are reset when the chunk it's in is unloaded. Why was it changed? The new title doesn't make any sense.

The original title was inaccurate as to the cause of the bug, before it said that simply unloading a chunk would cause the entity to have it's scoreboard value reset, when in reality that is not exactly true, it is that when an entity has a /execute command with a detect part attached to it, for example "/execute @e[type=Pig] ~ ~ ~ detect ~ ~ ~ minecraft:air 0", when it's chunk becomes unloaded, it causes all scoreboard values for the entity and all other entities within the chunk to be reset.

A workaround for the current update of 1.9: use "/execute @a ~ ~ ~ " and add an appropriate range to the second "/execute", I am not entirely sure if adding something over a certain amount causes the bug to re-occur, but this should work, just use a large radius and it should work just as well. Just make sure to do testing while making any command block things to make sure it if it works.

Can someone confirm it's fixed since 16w21a/in the current snapshot (prerelease)? Thank you }=)

I might be able to test later today, if not today, then tomorrow.
(You're allowed to beat me to it. 🙂 )

Still seems broken in my case...

@@unknown Are you using the latest development version (1.10 pre-1)? I cannot replicate it in that version.

@Skylinerw Yes, I am.
And on an unrelated note, how to you properly tag people in your replies?

Can you provide reproduction steps? The one earlier in the comments no longer works for me.
To tag another user, you'll need their profile name:
[~Skylinerw]
(The @ symbol doesn't appear on its own)

Confirmed for 1.10.2
You can confirm this bug at mcdicminecraft.mcph.co (Server address)
Not often, but sometimes unloaded entities lose their score.

What server type is it? (Vanilla, forge, bucket, spigot, etc.)

Vanilla @FVbico

I can confirm this is happening in Vanilla 1.12.2.
Set a score of an armor stand outside of spawn chunks, either with the default scoreboard command, or preceded with execute @p: In both instances, once the chunk becomes unloaded, the armor stand completely loses its score.

I am having this issue in 1.12.2 as well.
I created a system for players to build Warp Relay structures in the world that uses execute/detect commands and assigns a unique ID score to a pair of armor stands to create a tp link between them. When one of them unloads from the chunk, it vanishes along with it's scoreboard value, thus breaking the Warp Relay link.
I created this system back in Vanilla 1.10 and have been scrambling to find a fix for it. Including trying to find ways to glitch a chunk load and even resorting to trying to find chunk loading plugins on Spigot... which is not helpful either, since I cannot find any that can target select entities.
A fix would be a huge relief!
May I suggest possibly adding a feature that could allow keeping an entity loaded (or at least it's data loaded) within an unloaded chunk?

I cannot repro this in 18w02a

@@unknown: were you able to reproduce it before?

Cannot reproduce on 1.12.2 using the post, Wyatt's comment, or Rob's comment; and I believe Nikolas' comment is a feature request for non-glitch chunk loading rather than a confirmation of the bug.
execute detect
does not load chunks.testforblock
does not load chunks.
The only strange behavior I found was that entities I teleported to other chunks stayed loaded indefinitely (until I loaded them manually or restarted the world). The chunks themselves never loaded (testforblock
and setblock
did not work).

This is still happening for me in 1.12.2. I haven't tested it in the new snapshots (as I'm in the process of rewriting all of my other commands).
Â
However, it is very sporadic. My use case: armor stand that has a score that relates to a certain players score, and protects an area around it for vanilla land claim protection.
Â
When I TP to and from the area, load/unload, whatever, it sometimes retains the score. However, at random times, it just forgets everything all together, and then prompts the error message I have set when the person isn't "the owner". Upon debugging, the armor stand lost all scores it had, which is why it thinks the player is no longer the owner.
Â
Annoying, but it takes some time to happen, as it appears to be sporadic.
Â
It happens at random points, but I expect that the randomness of this isn't expected behaviour.
Can't reproduce by following Wyatt's instructions in 1.13 pre-1 (using updated command syntax). Please, someone else give it a try and let me know if you can.

Cannot reproduce in 18w31a either (using Wyatt's instructions).
Instead of detect
I used if block
. The bug might have been acidentally fixed in the process of rewriting the command system for 1.13.

Is this still a issue in the latest version of the game(currently 1.13.1)?
If so, please add it to the affected versions, thanks!

This is still an issue in 1.13.1, however it is difficult to reproduce in a creative test world. I have a survival world with custom villagers, and their scoreboard objectives are almost always reset when I return to trade with them. I have noticed that this affects entities inside spawn chunks as well as outside spawn chunks.

Ran into the same issue in 1.13.2, however instead of a villager it was a item stand, but still same issue.

Cannot reproduce in 20w07a using the equivalent execute if block
. Please let us know if this can still be reproduced.

Note that execute if block
does not load the position (which is required for reproduction). It appears /spreadplayers
still does this, but I cannot reproduce this using that command either.