Jump to content

Class.getClass().getResource() working in Eclipse but not when compiled


ss7

Recommended Posts

Hello,

 

My mod uses this line of code to go through all .lang files in a directory:

 

for (File file : new File(URLDecoder.decode(Config.class.getResource("/assets/brickcraft/lang/").getPath(), "UTF-8")).listFiles())

 

That is working in Eclipse, but not when i recompile my mod.

I've added a println that prints the URLDecoder output. (BTW, I'm on a Mac)

 

Output in Eclipse: /Volumes/Daten/Minecraft Forge Modding 1.6.4/forge/mcp/eclipse/Minecraft/bin/assets/brickcraft/lang/

Output when compiled: file:/Users/ss7/Library/Application Support/minecraft/mods/Brickcraft.zip!/assets/brickcraft/lang/

 

I've also tried to remove the "file:" and the "!" from the string, but no such luck.

 

I hope you can help me!

 

ss7

You sir are a god damn hero.

Link to comment
Share on other sites

Hi

 

That path looks correct to me, because your lang resources are packaged inside a zip file.

 

Vanilla uses a different code to retrieve files depending on whether they're in a folder in a zip file.

See FileResourcePack.java (and ZipFile.java).

 

Never used it myself so that's about all I know.

 

-TGG

Link to comment
Share on other sites

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.