MachineMuse / MachineMusePowersuits

Minecraft mod, take 2
236 stars 105 forks source link

class.getResource produces incorrect resource file path #836

Closed ZornTaov closed 6 years ago

ZornTaov commented 6 years ago

I eventually got the 1.12.2 branch to compile, however you're using class.getResource in a few different place, namely in net.machinemuse.powersuits.common.config.MPSConfig.extractModelSpecFiles() where I see you're attempting to get the folder the modelspec xml files are in, check if it's valid with toUri(), before loading each one. Unfortunately having that code run outside of an IDE produces a different path to the file/folder you want and causes an IllegalArgumentException: URI is not hierarchical, because now the files are inside of the jar. Most StackOverflow posts say to use class.getClassLoader().getResourceAsStream(string path) and to determine if you're in a IDE or in a jar by some other means, though I am uncertain if that is the correct way.

lehjr commented 6 years ago

Yeah, the 1.12.2 branch is a work in progress with a lot of issues and far from ready for use outside of a development environment. While I do appreciate you bringing that issue to light, the reality is there are many, many more issues, most of which involve the way values are calculated, stored and synchronized, especially when trying to implement capabilities.

dshadowwolf commented 6 years ago

Recently fixed an issue like this in one of the MMD mods and because it was actually iterating a directory I had to get even deeper into internals. For direct loading like this, however, getResourceAsStream() is probably the best direction.

lehjr commented 6 years ago

This isn't a thing anymore. It might be part of a stale branch, but it's not in the code for the current development branch.