(Java Minecraft 1.14) Does a scoreboard tag affect entity despawning?
The only NBT-tag that affects mob despawning is the PersistenceRequired
-tag, a custom name does NOT change this behaviour.
This command summons a renamed zombie that will despawn:
/summon minecraft:zombie ~ ~ ~ {CustomName:'{"text":"zombie"}'}
This command summons a renamed zombie that will not despawn:
/summon minecraft:zombie ~ ~ ~ {CustomName:'{"text":"zombie"}',PersistenceRequired:1b}
Changing the name of a zombie with a name tag will change both the name and set the PersistenceRequired
-tag to 1.
If a zombie picks up an item, then the PersistenceRequired
-tag will be set to 1.
Credits go to Fabian Röling for mentioning this in the comments
In conclusion, using this command will not make the nearest zombie despawn-proof:
/tag @e[type=minecraft:zombie,sort=nearest,limit=1] add zombie
Note: I only tested wether or not a zombie despawns in those cases, it may be possible that they take longer to despawn, or despawn quicker, or that they are affected in some other way.
Note 2: I only tested this with zombies, but it should apply to any entity