Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[solved][1.15.2] Accessing resource in my mod jar


Recommended Posts

Hello. I'm updating my mod from 1.12.2 to 1.15.2. However, I am having issues accessing files in my mod jar (I copy some directories/files to the file system so the user can modify/configure). I used to be able to use MyClass.class.getResource("...") to get the URL to the resource, which I could later use to generate a FileSystem and walk all the file in a directory.  However, in 1.15.2, the URL returned is no longer in the same format - it is like "modjar://[...path]". The path to the actual jar file is no longer available. Can anyone help on how to get access to files within the mod jar?

 

Thanks,

gottsch 

Edited by gottsch
Link to post
Share on other sites

You should probably be using the IResourceManager instead. If your data is client-side, you use the resource manager instance from the Minecraft class, if for the server, from the MinecraftServer class.

Have you ever want the new operator to return a type that you didn't ask for? Well, now you can!

Link to post
Share on other sites

I had to go another route - I had to add another json file that explicitly listed the path to the resources and then was able to use FileUtils.copyInputStreamToFile(Objects.requireNonNull(mymod.class.getClassLoader().getResourceAsStream(resourcePath.toString())), 

Link to post
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.

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



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.