Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hey!

 

I was wondering if there was any way to download files when the game runs. What I want to do is have Minecraft download all sound files needed for my mod, and place them into /resources/mod/streaming for me.

 

Is this possible and if so, what is the best way to do this??

 

Thanks!

Luis

Well you can pack the streaming stuff in your mod and copy it from the classpath into the file system. I made it like this:

 

[*]Get the file from the streaming folder and check if it exists and is valid

[*]If it's valid, register it

[*]If not, get the InputStream from your streaming file in your classpath like this:

 

InputStream is = MyMod.class.getClassLoader().getResourceAsStream("mod/streaming/file.ogg"); // The file is under Minecraft/src/mod/streaming/file.ogg

[*]check if the InputStream is not null and write the InputStream to the streaming folder

[*]check if the new file is created and valid

[*]If it's valid, register it

[*]If not, either print a warning or throw an exception (I would rather go for the first one)

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

[*]Get the file from the streaming folder and check if it exists and is valid

[*]If it's valid, register it

[*]If not, get the InputStream from your streaming file in your classpath like this:

 

InputStream is = MyMod.class.getClassLoader().getResourceAsStream("mod/streaming/file.ogg"); // The file is under Minecraft/src/mod/streaming/file.ogg

[*]check if the InputStream is not null and write the InputStream to the streaming folder

[*]check if the new file is created and valid

[*]If it's valid, register it

[*]If not, either print a warning or throw an exception (I would rather go for the first one)

Which is just overhead. When you register your sounds you can use any URL (including Classpath URLs that directly point into your Mod zip-file). No need to extract them first.

 

Which is true for sound effects, but not for streaming stuff (like record music). At least that didn't work for me unless I copied the music into the streaming folder. You only have to copy them once, though, so it's doable!

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

  • Author

Thanks for replying so quickly!

 

[*]Get the file from the streaming folder and check if it exists and is valid

[*]If it's valid, register it

[*]If not, get the InputStream from your streaming file in your classpath like this:

 

InputStream is = MyMod.class.getClassLoader().getResourceAsStream("mod/streaming/file.ogg"); // The file is under Minecraft/src/mod/streaming/file.ogg

[*]check if the InputStream is not null and write the InputStream to the streaming folder

[*]check if the new file is created and valid

[*]If it's valid, register it

[*]If not, either print a warning or throw an exception (I would rather go for the first one)

Which is just overhead. When you register your sounds you can use any URL (including Classpath URLs that directly point into your Mod zip-file). No need to extract them first.

 

Which is true for sound effects, but not for streaming stuff (like record music). At least that didn't work for me unless I copied the music into the streaming folder. You only have to copy them once, though, so it's doable!

 

I was just typing the same thing when you replied! These files are for a music disc, maybe I should have pointed that out in my first post. Also, do I need to register the sounds as when I have placed them into the folder manually, they played without registering.

Thanks for replying so quickly!

 

[*]Get the file from the streaming folder and check if it exists and is valid

[*]If it's valid, register it

[*]If not, get the InputStream from your streaming file in your classpath like this:

 

InputStream is = MyMod.class.getClassLoader().getResourceAsStream("mod/streaming/file.ogg"); // The file is under Minecraft/src/mod/streaming/file.ogg

[*]check if the InputStream is not null and write the InputStream to the streaming folder

[*]check if the new file is created and valid

[*]If it's valid, register it

[*]If not, either print a warning or throw an exception (I would rather go for the first one)

Which is just overhead. When you register your sounds you can use any URL (including Classpath URLs that directly point into your Mod zip-file). No need to extract them first.

 

Which is true for sound effects, but not for streaming stuff (like record music). At least that didn't work for me unless I copied the music into the streaming folder. You only have to copy them once, though, so it's doable!

 

I was just typing the same thing when you replied! These files are for a music disc, maybe I should have pointed that out in my first post. Also, do I need to register the sounds as when I have placed them into the folder manually, they played without registering.

 

If they work w/o registering, then you don't need to.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.