gottsch Posted August 29, 2020 Posted August 29, 2020 (edited) 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 January 6, 2021 by gottsch Quote
Vinyarion Posted August 31, 2020 Posted August 31, 2020 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. Quote Have you ever want the new operator to return a type that you didn't ask for? Well, now you can!
gottsch Posted January 6, 2021 Author Posted January 6, 2021 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())), Quote
Recommended Posts
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.