Posted October 7, 201410 yr Heyho Guys! Well, this time the title says everything .. How can I get a File object from a ResourceLocation object? http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
October 9, 201410 yr Something like this works for me. Since this contains file IO you'll have to add some try/catch exception handling: readIn = new BufferedReader(new InputStreamReader(getClass().getClassLoader() .getResourceAsStream("assets/my_mod/my_folder/myFile.txt"), "UTF-8")); firstInteger = Integer.valueOf(readIn.readLine()); With this, I'm reading a text file. You'd of course change the my_mod, my_folder, and myFile.txt to match your own assets directory and filename. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
October 9, 201410 yr If you want to use that code Jabelar posted with a ResourceLocation, you can use ResourceLocation#getResourceDomain() in place of my_mod , and ResourceLocation#getResourcePath() in place of my_folder/myFile.txt . Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
October 9, 201410 yr Author I tried the method diesieben07 mentioned and it works great! Thanks http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
October 10, 201410 yr The resource manager stuff is good, except it assumes that the "asset" file you want is only to be available on the client side (IResource is client only). For textures and sounds that is probably fine, but for example I put custom text files for things like structure generation into my assets and need them on the server side. I think my original "standard Java" answer is the more general answer for reading a file you happen to put in the JAR. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
October 10, 201410 yr Author Well, I also used your method but I didnt put the files into assets to avoid trouble with resource pack makers http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
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.