there a reason the game freezes upon playing the sound?
You probably don't have the sound in the directory you are pointing it too.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
there a reason the game freezes upon playing the sound?
Are you getting any errors or does it freeze then play. Are you loading the sounds first when the mod loads or when you want to play them? Reason it could freeze is because the sound file could be big. It freezes or hangs because you are loading the sound on the same Thread as the game is on. If that is the problem I would load the sounds in another thread when the mod loads first.
Rollback Post to RevisionRollBack
Same ****, different day - Modification Development Section
Hi. I've been testing this method out, and it works great. I just wanted to ask (I bet this is a noob question) how do you change the volume of the sound that is played?
Rollback Post to RevisionRollBack
A word for the wise ain't necessary, it's the stupid ones that need the advice.
-Bill Cosby
Hi. I've been testing this method out, and it works great. I just wanted to ask (I bet this is a noob question) how do you change the volume of the sound that is played?
I'm fairly sure you can use something like this:
protected float getSoundVolume()
{
return 10F;
}
I think that only works for entities though. I'm sure lockNload has a much better way of doing it though
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
I think that only works for entities though. I'm sure lockNload has a much better way of doing it though
Well I have a different way . I'm not sure if this works really well cause I tried it and not really a difference.
mc.sndManager.playSoundFX("sound", 5.0F, 1.0F);
The first argument "sound" is the sound name, 5.0F is the sound volume, and 1.0F is the pitch. The sound is 5.0F * the sound setting. It should be the same for the rest of the methods like this.
Rollback Post to RevisionRollBack
Same ****, different day - Modification Development Section
Hi. I've been trying to get this to work, but for some reason no matter what, it doesn't. It will play other sounds, but i'm guessing it doesn't install my resource.
Here is my code:
Minecraft mc = ModLoader.getMinecraftInstance();
mc.installResource("/newsound/random/hurt1.ogg", new File(mc.mcDataDir, "/resources/newsound/random/hurt1.ogg"));
I have tried it with, and without the '/' in front of 'newsound/...' If someone could help me out, that would be great!
Are you sure you are not getting any errors when compiling the code? Unless you copied it wrong you are missing a quote for the string. Make sure you have your strings in both quotes. Also you will still have a problem too.
"resources.newsound.siren.standardsiren.ogg"
When you are using 'newsound', don't put the 'resources.newsound' in front of your string.
I mean it should look like this "siren.standardsiren", read my tutorial again it look at the examples. So this is how it should look all together.
I was resorting to another method from a different tutorial and that's why I had the resources thing mixed up. I reformatted it back to this tut and forgot to omit the resources section.
Yeah, I have no issues with recompiling on eclipse or mcp at this point.
In regards to the tutorial, i have followed it to the T about twice, and i haven't seen a specific area for case specific locations. For example, in a previous comment, you instructed a reader that it was ok to call the two lines in the public void load() like so:
public void load()
{
// gets minecraft instance
Minecraft mc = ModLoader.getMinecraftInstance();
// installs the resource
mc.installResource(
"newsound/siren/standardsiren.ogg", new File(mc.mcDataDir,"newsound/siren/standardsiren.ogg"));
}
Is this location correct?
Plus, have you made any headway on the sound preloading like mentioned in the previous comment?
Edit: Nevermind. I figured out what was wrong with that. but another issue arose, my sound file is quite large (a few minutes long), and it freezes minecraft until it's done loading. Do you know of a way to pre-load the sound on start-up?
Quote from quote name="GLOBALWolf" timestamp="1334182036" post="14179397" »
In regards to the tutorial, i have followed it to the T about twice, and i haven't seen a specific area for case specific locations. For example, in a previous comment, you instructed a reader that it was ok to call the two lines in the public void load() like so:
public void load()
{
// gets minecraft instance
Minecraft mc = ModLoader.getMinecraftInstance();
// installs the resource
mc.installResource(
"newsound/siren/standardsiren.ogg", new File(mc.mcDataDir,"newsound/siren/standardsiren.ogg"));
}
Is this location correct?
Look at this part of the code, newFile(mc.mcDataDir,"newsound/siren/standardsiren.ogg"));
This is the install location of the sound file, sense it's a File Object. Right now Java is looking for the newsound folder in the root of your minecraft folder. Unless you put that there it should be in the resources folder. So it should be
You can have your sound files anywhere you like but make sure you copy the correct file path like so.
Plus, have you made any headway on the sound preloading like mentioned in the previous comment?
Quote
Edit: Nevermind. I figured out what was wrong with that. but another issue arose, my sound file is quite large (a few minutes long), and it freezes minecraft until it's done loading. Do you know of a way to pre-load the sound on start-up?
Alright, so how does this look then. Hopefully I have everything right.
(Still no dice)
mod_xxx.class
package net.minecraft.src;
import java.io.File;
import java.util.Random;
import net.minecraft.client.Minecraft;
...
public void load()
{
Minecraft mc = ModLoader.getMinecraftInstance();
mc.installResource(
"newsound/siren/standardsiren.ogg", new File(mc.mcDataDir,"resources/newsound/siren/standardsiren.ogg"));
}
Blockxxx.class
import java.io.File;
import java.util.Random;
import net.minecraft.client.Minecraft;
...
public void onNeighborBlockChange(World world, int i, int j, int k, int l)
{
if (l > 0 && Block.blocksList[l].canProvidePower())
{
world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
}
}
public void updateTick(World world, int i, int j, int k, Random random)
{
if (world.isBlockIndirectlyGettingPowered(i, j, k))
{
world.setBlockWithNotify(i, j, k, mod_xxxx.Sirenon.blockID);
// gets minecraft instance
Minecraft mc = ModLoader.getMinecraftInstance();
// installs the resource mc.installResource(
"newsound/siren/standardsiren.ogg", new File mc.mcDataDir,"resources/newsound/siren/standardsiren.ogg"));
//Plays Sound
sndManager.playSoundFX("newsound.siren.standardsiren.ogg", 1.0F, 1.0F);
}
else
{
world.setBlockWithNotify(i, j, k, mod_xxxx.
Sirenoff.blockID);
}
1. Corrected Installation code
2. Made sure to put installs in public void load()
3. Tested Redstone code and block updates are still constant with no sound
Alright, so how does this look then. Hopefully I have everything right.
(Still no dice)
mod_xxx.class
package net.minecraft.src;
import java.io.File;
import java.util.Random;
import net.minecraft.client.Minecraft;
...
public void load()
{
Minecraft mc = ModLoader.getMinecraftInstance();
mc.installResource(
"newsound/siren/standardsiren.ogg", new File(mc.mcDataDir,"resources/newsound/siren/standardsiren.ogg"));
}
Blockxxx.class
import java.io.File;
import java.util.Random;
import net.minecraft.client.Minecraft;
...
public void onNeighborBlockChange(World world, int i, int j, int k, int l)
{
if (l > 0 && Block.blocksList[l].canProvidePower())
{
world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
}
}
public void updateTick(World world, int i, int j, int k, Random random)
{
if (world.isBlockIndirectlyGettingPowered(i, j, k))
{
world.setBlockWithNotify(i, j, k, mod_xxxx.Sirenon.blockID);
// gets minecraft instance
Minecraft mc = ModLoader.getMinecraftInstance();
// installs the resource mc.installResource(
"newsound/siren/standardsiren.ogg", new File mc.mcDataDir,"resources/newsound/siren/standardsiren.ogg"));
//Plays Sound
sndManager.playSoundFX("newsound.siren.standardsiren.ogg", 1.0F, 1.0F);
}
else
{
world.setBlockWithNotify(i, j, k, mod_xxxx.
Sirenoff.blockID);
}
1. Corrected Installation code
2. Made sure to put installs in public void load()
3. Tested Redstone code and block updates are still constant with no sound
Well for one, you only have to install the resource one time. You are installing it every time the block updates. So that will take up some cpu; depending on how large it is. So make sure you only install the sound in the load method.
ergh T.T hi, im using this for my sounds but for some reason a small sound i have wont play to the end =/, whilst a sound longer doesnt play till the end either but it plays for longer is there a way i can change this?
mc.installResource("newsound/mob/SNK/Rooster/Rooster.ogg", new File(mc.mcDataDir,"resources/newsound/mob/SNK/Rooster/Rooster.ogg"));
mc.installResource("newsound/mob/SNK/Skully/AH.ogg", new File(mc.mcDataDir,"resources/newsound/mob/SNK/Skully/AH.ogg"));
Sorry but I don't know sense you only showed me the sound installation code. Could you post the code where you actually play it? Also how big are the sound files, I don't think that matters but I don't really know what the problem could be.
I will try to make a video some time soon sense some people are having trouble
Rollback Post to RevisionRollBack
Same ****, different day - Modification Development Section
You probably don't have the sound in the directory you are pointing it too.
together they are powerful beyond imagination."
Are you getting any errors or does it freeze then play. Are you loading the sounds first when the mod loads or when you want to play them? Reason it could freeze is because the sound file could be big. It freezes or hangs because you are loading the sound on the same Thread as the game is on. If that is the problem I would load the sounds in another thread when the mod loads first.
-Bill Cosby
I'm fairly sure you can use something like this:
I think that only works for entities though. I'm sure lockNload has a much better way of doing it though
together they are powerful beyond imagination."
Ok, thanks!
-Bill Cosby
Well I have a different way . I'm not sure if this works really well cause I tried it and not really a difference.
The first argument "sound" is the sound name, 5.0F is the sound volume, and 1.0F is the pitch. The sound is 5.0F * the sound setting. It should be the same for the rest of the methods like this.
Here is my code:
I have tried it with, and without the '/' in front of 'newsound/...' If someone could help me out, that would be great!
It didnt work for me, I put the install code in the public void load() at mod_xxx file
And it doesnt play any sound :/
Should I install the code somewhere else?
Yes post the code.
It looks like your problem is right here.
As you can see you are trying to concat the "newsound/map" and par1 Strings. It will come out as this
I'm guessing 'map' is a directory? So try putting a slash after it as well.
mc.installResource("newsound/map/" + par1, new File(mc.mcDataDir, "resources/newsound/map/" + par1));
Thanks for this tut
Cheers!
So, i seem to be having a very large amount of trouble with this method that lock and load has put in for us.
Here's my code. I have omitted a bit.
mod_xxx.java
xxxBlock.java
I believe the error is in this line of code
Are you sure you are not getting any errors when compiling the code? Unless you copied it wrong you are missing a quote for the string. Make sure you have your strings in both quotes. Also you will still have a problem too.
"resources.newsound.siren.standardsiren.ogg"
When you are using 'newsound', don't put the 'resources.newsound' in front of your string.
I mean it should look like this "siren.standardsiren", read my tutorial again it look at the examples. So this is how it should look all together.
I was resorting to another method from a different tutorial and that's why I had the resources thing mixed up. I reformatted it back to this tut and forgot to omit the resources section.
Yeah, I have no issues with recompiling on eclipse or mcp at this point.
In regards to the tutorial, i have followed it to the T about twice, and i haven't seen a specific area for case specific locations. For example, in a previous comment, you instructed a reader that it was ok to call the two lines in the public void load() like so:
Is this location correct?
Plus, have you made any headway on the sound preloading like mentioned in the previous comment?
Look at this part of the code, newFile(mc.mcDataDir,"newsound/siren/standardsiren.ogg"));
This is the install location of the sound file, sense it's a File Object. Right now Java is looking for the newsound folder in the root of your minecraft folder. Unless you put that there it should be in the resources folder. So it should be
You can have your sound files anywhere you like but make sure you copy the correct file path like so.
Yes I did,
http://www.minecraft...st__p__13232437
Have you already set up the sound in your load method? Are you trying to call the sound in the EntityVillager?
(Still no dice)
mod_xxx.class
Blockxxx.class
1. Corrected Installation code
2. Made sure to put installs in public void load()
3. Tested Redstone code and block updates are still constant with no sound
Well for one, you only have to install the resource one time. You are installing it every time the block updates. So that will take up some cpu; depending on how large it is. So make sure you only install the sound in the load method.
The error is in this segment. Remove the .ogg at the end of the string, you don't need it.
"newsound.siren.standardsiren.ogg"
Sorry but I don't know sense you only showed me the sound installation code. Could you post the code where you actually play it? Also how big are the sound files, I don't think that matters but I don't really know what the problem could be.
I will try to make a video some time soon sense some people are having trouble
Don't really understand, i'm quite new to this. Could you perhaps plot out what code goes on what line and such?
You First install the the sound in the load method,
Then you play it,
If your using an entity then you just use the method that require the sounds.