Jump to content

[SOLVED][1.14.4]Pack files within a mod jar and extract them


Recommended Posts

Posted (edited)

So I was trying to get a few files unpacked into a subfolder within the Minecraft profile. I got the folder and such working, but I didn't want to write an API for fetching the files from my file server. As the files may differ between versions of my mod. So I decided to just pack them in the jar,  which works fine, but like I expected the following line of code doesn't work.

InputStream inputStream = FolderManager.class.getResourceAsStream("files.json");

 

I figured this had to do with the fact that the mods are programmatically loaded in.

Is there an easy way for me to access these files I packed? I will make this API for the long term, but unless there's no alternative I'm not yet planning on making it.

 

Thanks

Edited by tebreca
added solved tag
Posted

I placed the file in the resources folder, it showed up in the jar when I opened it up with WinZip.

this is what happens while debugging. I got the same error when running it in a client with the jar compiled, may that make a difference with runClient.image.png.7f58fee4399890c0bf5ad1a4defd71e2.png

Posted
41 minutes ago, diesieben07 said:

Read the documentation for Class#getResourceAsStream. You did not provide an absolute path, so it will look in the current package. 

oh ok, thanks! I should've done that before asking here, my bad

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.