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

The mod I'm working on currently needs a data file to be saved. I am using .json and have no problems with that.

 

My problem is saving it properly.

 

To save the file I need to get a Java File object pointing at <minecraftdir>\saves\<worldname>\data\myFile.dat.

 

I can have generated a file pointing to the saves folder of the current minecraft directory, and this code works.

public static final File SAVES_DIRECTORY = new File(Minecraft.getMinecraft().mcDataDir, "/saves");

 

However, when attempting to get to the data folder, I've run into a hitch.

 

With world w, I can make the call

w.getWorldInfo().getWorldName()

to (theoretically) get the name of the world, and can use this to access the correct directory.

 

But instead of returning the name of my world save, the above snippet is returning "MpServer".

 

TLDR; So my question is, what is the best way to access the data folder inside of the save folder for a world?

  • Author

Yep! Works like a charm! Thank you!

 

FILE_PATH = new File(DimensionManager.getCurrentSaveRootDirectory().toPath() + "/data/commandblocksigns.json");

 

Just have to make sure this is called when the world is open. (obviously.)

Guest
This topic is now closed to further replies.

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.