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

As the title says. This is the only thing I've found:

world.getWorldInfo().getWorldName()

, which only returns the worlds name.

Thanks in advance.

No 5 row long documentation = account on the help forums

Haha I had the exact same problem just this morning :) I figured it out though, so don't worry.

 

Explanation via words:

First, you're going to need to get the server instance from ModLoader ( ModLoader.getMinecraftServerInstance() ). Then, you're going to need to get the folder name of the server instance ( .getFolderName() ). Store that for later. Next, get the ISaveFormat from the server instance ( .getActiveAnvilConverter() ). After that, obtain the SaveHandler from the ISaveFormat and give it the folder name we stored earlier as well as a boolean as to whether or not to mkdirs for the player folder (I just use false) ( .getSaveLoader(folderName, false) ). Then, just get the saveDirectory from the SaveHandler ( .getSaveDirectory() ).

 

Explanation via code:

MinecraftServer mcServerInstance = ModLoader.getMinecraftServerInstance();
String folderName = mcServerInstance.getFolderName();
ISaveFormat saveFormat = mcServerInstance.getActiveAnvilConverter();
SaveHandler saveHandler = (SaveHandler)saveFormat.getSaveLoader(folderName, false); // You will have to typecast here
File saveDir = saveHandler.getSaveDirectory();

 

Hope this helps! Ask any questions if you have them and I'll try to answer them.

  • Author

Haha I had the exact same problem just this morning :) I figured it out though, so don't worry.

 

Explanation via words:

First, you're going to need to get the server instance from ModLoader ( ModLoader.getMinecraftServerInstance() ). Then, you're going to need to get the folder name of the server instance ( .getFolderName() ). Store that for later. Next, get the ISaveFormat from the server instance ( .getActiveAnvilConverter() ). After that, obtain the SaveHandler from the ISaveFormat and give it the folder name we stored earlier as well as a boolean as to whether or not to mkdirs for the player folder (I just use false) ( .getSaveLoader(folderName, false) ). Then, just get the saveDirectory from the SaveHandler ( .getSaveDirectory() ).

 

Explanation via code:

MinecraftServer mcServerInstance = ModLoader.getMinecraftServerInstance();
String folderName = mcServerInstance.getFolderName();
ISaveFormat saveFormat = mcServerInstance.getActiveAnvilConverter();
SaveHandler saveHandler = (SaveHandler)saveFormat.getSaveLoader(folderName, false); // You will have to typecast here
File saveDir = saveHandler.getSaveDirectory();

 

Hope this helps! Ask any questions if you have them and I'll try to answer them.

Thanks a lot for your answer. However I still got an error, and after printing the file path I saw it contained

a folder called MpServer. So I check when that occurs and return null, works so I'm happy.

No 5 row long documentation = account on the help forums

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.