Components and self programed Classes. Serilization proplems!

Esereja

Active Member
Contributor
I found this annoying problem, due sandboxing components can have only certain limited types of variables(primitives,containers,vectors,blocks,Strings) and Needed data type that wasn't on that list. I Solved my case by serializing my object to String and de-serialized it when ever I needed it.

This problem arises because all data in components need to be stored to chunk at saving moment. And if engine don't know how to serialize some part of components data, component cant be used. Problem is that serialization (extends TypeHandler) rules cant be added to TypeSerializationLibrary outside of engine. and thus only way to have your fancy own stuff in components is store them to some supported type. like serializing them to string and but those strings to container.

I think it would be good if we could just make TypeHandler rules and hand them to TypeSerializationLibrary and be happy. Tough this is as much coding as serializing then in to combonent. But in performance later is lighter, because one doesn't need to serialize and de-serialize all times at one wants to access to data.
 

Esereja

Active Member
Contributor
@MappedContainer seems to be at least partial solution to this problem. example of it use:
https://github.com/Terasology/Workstation/blob/master/src/main/java/org/terasology/workstation/component/WorkstationProcessingComponent.java
and it restriction can be found on this class.(like restrictions of components in general):
https://github.com/MovingBlocks/Terasology/blob/develop/engine/src/main/java/org/terasology/persistence/typeHandling/TypeSerializationLibrary.java#L271

Ty for josariah for pointing this out.
 
Top