creates new TrackedDataHandlers
TropheusJ opened this issue ยท 3 comments
TrackedDataHandlers registers 2 new handlers.
This is extremely dangerous and makes the mod prone to load-order dependent bugs.
They should be replaced with vanilla ones or custom packets.
Vanilla has had a quaternion handler built in since display entities were added. Short should be easily swapped to an int.
Thanks for the insight! Do you have a minimum reproducible example for when this might cause an issue? Does it break if other mods register a handler for the same type? Is there a more "correct" way to do it if we needed a handler for a different type in the future? Sorry for all the questions, just trying to wrap my head around the scope of the issue.
I don't have a specific case but it's usually a random index out of bounds after an entity tracked data sync packet. It happens when more than 1 mod does this, and the load order differs on the client and server.
It breaks if mods register new handlers at all. Note how the register method only has one arg. There is nothing identifying each handler. The "registry" is really just a registration-order array. So when the sync packet says "deserialize this data with handler 19," that can be a different one on the client and server, and catastrophe strikes.
If you need to sync a custom type, you shouldn't use tracked data. Just add a field to the entity and sync it manually with a custom packet.