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

So I'm coding something that builds a list, from reading a txt file. The code itself works and has been tested outside of the realm of the Minecraft developing environment, but I can't get it to work correctly with Forge. I get a crash with file not found. So I was wondering if anyone knew what path I should be adding to find the file? As in, should I use a file path using only MY MODS directories, or should I make it look all through the minecraft folders example: ./minecraft/mods/-mymod or can I simply have it it search locally with my file path only like: /com/morpheuszero/mods/name.txt etc etc?

 

I've tried a few different ways and II can't get it to work because I don't know which directory Forge is running from to know where to put a file path to read my file....I'm doing it this way because the information in this file needs to be easily changed by other users to be able to add the output of this file to an array list so I don't have to recode it and make the array larger it just builds itself each launch as pertaining to each user of the mod.

If you use a MySQL Api it would be very very easy...

Use someting like JDBC (Java DataBase Connection)

  • Author

Well I already got the code working. That's not an issue, I just need some assistance with the correct file pathing solution to FIND the file in the code. I know how to do it within my own applications, but not within the Forge and Minecraft environment...

Minecraft#mcDataDir

Links to Minecraft active folder. Then you can use whatever child path you want.

I don't know if you figured this out, but here is what I have found that seems to work.

 

 

 

File myFile = FMLCommonHandler.instance().getMinecraftServerInstance().getFile("hello_world.txt");

System.out.println("Location: " + myFile.getAbsolutePath());

 

 

 

Output:

 

2013-11-22 17:48:37 [iNFO] [sTDOUT] Location: C:\Users\cody\forge_hardcore_mod\mcp\jars\.\hello_world.txt

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.