EntityStats are saved to NBT, synced with packets.

Not all EntityStats, only the parts concerning current health, mana and
gold. Fixed items not being retained when a player logs out while dead.