New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Force serialize entity via API #8492
base: master
Are you sure you want to change the base?
Conversation
|
The issue I see is that wouldn't this allow for the serialization of entities in an invalid state and then their state will be "reset"? Not sure if that's a good thing. |
Yes, it would, and that's partially the goal. Before you'd get a Personally, I don't think this is a problem for API which does nothing by itself and is even placed in Unsafe. |
|
Well, in my opinion, if you try serializing an invalid entity I wouldn't expect it to magically be deserialized as a valid entity? |
I think it depends. My wording might've not been the best, but I'll try to explain. Upon deserialization, you'll get the same set of data as before serialization. For example, if you serialize an entity with 0 health you'll also get an entity with 0 health upon deserialization, and nothing will happen if you try to spawn it, because, well, it's "invalid". One other example of an "invalid" state is when the entity was despawned. |
|
Generally after looking at this, I think it might be worth hiding these "bypasses" behind some form of flag system similar to relative teleportation. E.g. if I as a plugin wants to save an entity that is a vehicle, it could actively define that by passing some I do not really want to end up with completely invalid entities being saved when all I want to do is passenger saving. |
Makes an entity serializable via API no matter what.
Previously you'd get an empty component (and an error later when trying to spawn the deserialized entity) in some cases:
Now there's no problem serializing & deserializing & spawning entities in those cases.