Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (โ‹ฎ) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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?

what exactly are you triing to save?

one way would be to use good old java io, but you would need a unique identifier for each server / world

  • Author

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.

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.

if you just want persistent data without caring on which world you are you should be using simple java io to save the data and read it when u need it

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions โ†’ Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.