PlayerSnapshot


#1

I’ve been thinking about some things I want to do with players, and someone else was talking about saving player states. I have a few questions/suggestions:

  • do entity snapshots already work with players?
  • is it possible to ‘apply’ snapshots to entities

If possible, I was thinking of a PlayerSnapshot class that can be serialized, as well as easily applied to/ set to a player. That means you could, at any point in time, grab the players state, save it, and then arbitrarily re-apply it whenever we want.

Thoughts?


#2

EntitySnapshot is already designed for all entities, regardless whether they’re basic entities or actual Player entities. Deserializing an EntitySnapshot from a Player however is only going to reset the Player's information as long as the Player is actually online.


#3

Bioshock Vita-chamber effect?


#4

The EntitySnapshot’s restore() method has some checks that prevent the entityData from actually being written:


The assumption is: if the entity already exists, then there’s no need to restore a snapshot.

But often the goal (or at least my current goal) is to a restore a player to the exact state at which the player was in when the snapshot was taken.

I.e old location, inventory, everything.

setRawData also doesn’t help because it is currently does nothing for MixinEntitiy:


#5

While not perfect. This solution i made a while ago may suit your needs for restoring the player as a player snapshot.


#6

I’d suggest posting an issue on SpongeCommon to allow restoring and setting raw data.