ss7 Posted December 1, 2013 Posted December 1, 2013 Hello, My mod uses this line of code to go through all .lang files in a directory: for (File file : new File(URLDecoder.decode(Config.class.getResource("/assets/brickcraft/lang/").getPath(), "UTF-8")).listFiles()) That is working in Eclipse, but not when i recompile my mod. I've added a println that prints the URLDecoder output. (BTW, I'm on a Mac) Output in Eclipse: /Volumes/Daten/Minecraft Forge Modding 1.6.4/forge/mcp/eclipse/Minecraft/bin/assets/brickcraft/lang/ Output when compiled: file:/Users/ss7/Library/Application Support/minecraft/mods/Brickcraft.zip!/assets/brickcraft/lang/ I've also tried to remove the "file:" and the "!" from the string, but no such luck. I hope you can help me! ss7 Quote Quote You sir are a god damn hero.
TheGreyGhost Posted December 1, 2013 Posted December 1, 2013 Hi That path looks correct to me, because your lang resources are packaged inside a zip file. Vanilla uses a different code to retrieve files depending on whether they're in a folder in a zip file. See FileResourcePack.java (and ZipFile.java). Never used it myself so that's about all I know. -TGG Quote
GotoLink Posted December 1, 2013 Posted December 1, 2013 I'd recommend Class#getResourceAsStream(String) instead. Quote
ss7 Posted December 2, 2013 Author Posted December 2, 2013 Hello, @GotoLink But I can't cast a InputStream to a File or convert it. ss7 Quote Quote You sir are a god damn hero.
ss7 Posted December 2, 2013 Author Posted December 2, 2013 Hello, @diesieben07 How do I do that? Buildcraft also uses getResource(). I tried converting a InputStream to a File but that's not working. ss7 Quote Quote You sir are a god damn hero.
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.