Entity data sometimes doesn't get properly updated in multiplayer
Entity metadata doesn't get properly updated for clients in a multiplayer game in some circumstances due to a networking race condition.
Steps to reproduce
- Start two instances of the game (make sure to use two different usernames, say host and guest)
- Open a LAN server (creative, allow cheats) on a fresh void superflat world
- Place two command block minecarts on connected activator rails (so they activate together)
- Command in one minecart: /tp @p[name=host] ~ ~1 ~
- Command in second minecart: /data modify entity @e[type=pig,limit=1] HasVisualFire set value true
- Spawn a pig near the minecarts: /summon pig ~ ~ ~ {NoAI:1}
- Join the server with the second player (guest)
- Teleport the host far away (200 blocks)
- Activate the minecarts using the guest player
- The pig should appear to be on fire for the host but not the guest
(The order of events is important. To be more precise: the pig needs to be spawned after the minecarts)
Code analysis
The ClientboundSetEntityDataPacket constructor called when an entity comes into a player's view calls clearDirty on the entity's data preventing synchronization with other players.