Jump to content

Recommended Posts

Posted

Hello!

 

I'm creating a mod that needs to save data on the client that will stay there through servers, worlds, etc. I thought config files would work, but I am not able to set the values, only get or create default ones. Is there an alternative like this that will save data on the client?

Posted

Well, I'm trying to save some Twitter keys and secrets. Otherwise, every time the player wanted to authenticate with Twitter, they would have to relogin ingame and go through the auth process every restart.

Also, why would I want a separate ID for each world? I want the data to be the same in every world I am in, as well as for servers.

Posted

Client physical side (.jar) is not really interanlly adapted to saving stuff.

 

That doesn't mean it can't.

 

You can use ClientTickEvent and setup some ticking counter.

Since client only ever has ONE World (Minecraft#theWorld) which you are currently in you can simply save data you need to IO every some ticks.

 

I suggest using CompressedStreamTools that will save data to your /root/server-Ip/world-name.dat using NBT system. (for integrated you could use "localhost" for server-Ip, but note that no matter what you do - there is a slight chance that there WILL be collisions (especially on integrated/LAN servers or dedicated ones on your own computer). And no - worlds don't have UUID or such. (On server they can be implemented, but never on client).

 

Most things can be gotten from: Minecraft.getMinecraft().getCurrentServerData()

And for world name you just use Minecraft#theWorld.

 

Note: TickEvents have 2 phases (use one, preferably Phase.END) and note that ClientTickEvent is ran always (even in MainMenu) - you need to check if Minecraft#theWorld is not null and if you are actually connected to server.

1.7.10 is no longer supported by forge, you are on your own.

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.