I thought you were saying the default constructor wasn't getting called at all on load, which is why you needed something like readResolve() in the first place?
No no. It was getting called, but i did not understand why values where not being set. But now i understand.
First time object was created without any class fields and the game was saved.
On my next run, i added some fields to the class and run the debugger and was confused, as to why fields had no values on "active()", even tho constructor was clearly setting them.
Now i understand that the object from the first run, that had no class fields, was being loaded and that's why fields where null, even tho class constructor set them.
I had it tested by adding additional fields to class. After load old fields where set and new ones where null (even tho constructor was setting them).
But what confuses me a little is that object is restored and used, but the new object is also created and added to "sectorAPI.addScript(testEveryFrameScript);" yet it never fires or doesn't fire twice.
Also another thing that confuses me - if i create a different constructor, that sets additional data, that data won't be set for an already loaded object from a safe file as it will ignore whatever constructor does.
Correct. But: don't use static fields to put any data into! They will cause a giant memory leak when another game is loaded, since they'll still point at the previous game's data. Even if you think you might have some way of handling it, really, just don't
I am not storing the game data, i am storing reference to a custom message stack that is used to send data over socket, saving it has no value, as it gets cleaned as soon as data is sent over. But from what i understand from your post, that it's okay to use it as long as i don't use it to store game state related data.
Thank you very much for your responses!
I am a little on vacation right now, i plan to finish up my mod and show it to the world afterwards, maybe then it will be clearer what my goals are