fabric-loader icon indicating copy to clipboard operation
fabric-loader copied to clipboard

Cannot read resources from mod JAR (ClassLoader#getResourceAsStream() always returns null)

Open SrRapero720 opened this issue 1 year ago • 3 comments

WHAT'S HAPPENING?

For some reason, when i try to read resources/assets from my mod Jar using ClassLoader#getResourceAsStream() this method always returns NULL indicating resource didn't exists... but resource exists...

The same code works fine on Forge and standalone Java, getting InputStream always works for every listed file, Fabric is the exception. My mod is... "multiloader". not based on architectury. Here is the fabric loader https://github.com/SrRapero720/watermedia/blob/master/src/main/java/me/srrapero720/watermedia/core/WaterFabricLoader.java

I use IWaterMediaLoader#getClassLoader() to get a specific classloader to use and from where i get resources...

here is an example of how i get resources https://github.com/SrRapero720/watermedia/blob/96bfe487c23ea56d73b7701fc7c8e1b84efe2989/src/main/java/me/srrapero720/watermedia/core/util/Tools.java#L48-L62

VERSIONS AFFECTED

Any Minecraft version (1.16.5 -> 1.20.x) is having this issue. i don't know if i am doing something wrong. i read a lot of other projects and use the same method i use. nothing different FabricLoader: 0.14.21

SrRapero720 avatar Jul 14 '23 18:07 SrRapero720

Does this only happen in-dev? If so it may be an incorrect class path groups setting.

sfPlayer1 avatar Jul 15 '23 00:07 sfPlayer1

happen in prod. my dev setup was based in forge-only so all my test i make is always on producction (building JAR + putting in mods folder + run a fabric build using curseforge client). And yes... everyone have the same issue

https://github.com/SrRapero720/watermedia/issues/7

SrRapero720 avatar Jul 15 '23 00:07 SrRapero720

You may want to step into a res access in the debugger, it should end up in KnotClassLoader with your jar in the ucp

sfPlayer1 avatar Jul 15 '23 08:07 sfPlayer1