Posted April 13, 201312 yr 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
April 14, 201312 yr 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.
April 14, 201312 yr [*]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.
April 14, 201312 yr 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.
April 14, 201312 yr 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.