fabric-loader
fabric-loader copied to clipboard
Cannot read resources from mod JAR (ClassLoader#getResourceAsStream() always returns null)
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
Does this only happen in-dev? If so it may be an incorrect class path groups setting.
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
You may want to step into a res access in the debugger, it should end up in KnotClassLoader with your jar in the ucp