Jump to content

[1.7.10] onWorldLoad and onWorldSave Events


robijnvogel

Recommended Posts

Dear everyone,

I am trying to repair a bug in the code of qCraft.

Because of this, I have quite a few questions about the events named in the title of this post.

 

Question one:

1. This is a dumb one: I assume that the "world" that is referred to in the naming of these methods, is referring to the whole world, as in: "the save file" and not, "the dimension". Am I correct in this?

2. If so, then could someone please explain to me why multiple onWorldLoad Events seem to happen while starting a game  and even while playing? (observed by introducing some logging calls)

3. How is it that, at the end of startup of the Unix server I'm maintaining, there is an onWorldSave Event before the first onWorldLoad Event? (This might be a discrepancy in the order these events get called on a Windows and a Unix system, something which shouldn't be possible, which is why I won't state this as a fact.)

 

The trouble I have with these methods is:

The server gets started with an empty configuration in memory -> The configuration in memory gets saved to harddisk (effectively removing all valuable information that was there) -> The configuration in memory gets loaded from harddisk (one step too late).

In short: all world-specific qCraft information resets on server restart.

 

This is the code responsible for handling all this. I already removed the whole "onWorldUnload" method, because it seems to be completely redundant. Also, that method seems to be called on random moments as well, making things even more broken.

 

4. So how do you think this could be handled better?

I walk amongst titans.

Link to comment
Share on other sites

Yeah, that is a horrible way of doing this. You want to use WorldSavedData to attach data to a world, not some random custom system.

There are various threads about that on this forum.

Thank you for your clear answer.

 

The thing is, there only needs to be one set of these settings for the whole save file. This does not have to be saved as a separate set for each and every dimension. For this, I'd need some singular save method, like the way playerdata is stored. What should I be using for this?

 

Something called "LevelSavedData" perhaps?

 

To be clear, this mod was originally written for MC 1.6.4 by dan200 (ComputerCraft) and has since then only been ported to higher versions so some things may have changed to Forge since then, explaining the now outdated format of this code. I was in the progress of porting it from 1.7.10 to 1.8.9 when I came across this issue in the 1.7.10 version of the mod.

I walk amongst titans.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.