I'm back guys. Sorry, have been busy on other projects and other things too, but I can now help out some more.
@Raggarcowboy
Now when I play the game, it doesn't give any errors but the sound just doesn't play. I don't know what I'm doing wrong.
I believe the problem is with the name of your sound. See what I'm talking about below
//Installs the fart sound
mc.installResource("/newsound/simoncraft/fart.ogg", new File(mc.mcDataDir,"/resources/newsound/simoncraft/fart1.ogg"));
mc.installResource("/newsound/simoncraft/fart.ogg", new File(mc.mcDataDir,"/resources/newsound/simoncraft/fart2.ogg"));
mc.installResource("/newsound/simoncraft/fart.ogg", new File(mc.mcDataDir,"/resources/newsound/simoncraft/fart3.ogg"));
}
Make sure you don't have a slash in front of the data type, in this case it's newsound.
"/newsound/simoncraft/fart.ogg"
Remove that slash in each sound. It doesn't really matter for the actual File Location,
new File(mc.mcDataDir,"/resources/newsound/simoncraft/fart1.ogg")
you can keep that slash if you want. That should fix your problems.
@JohnMosuela
Read the spoiler above since your problem looks about the same
@ULinuxRyan314
same issue for you too, I didn't look at all your code but it looks like you have the same issue.
@THeo_sA80
can you post your code again please?
Rollback Post to RevisionRollBack
Same ****, different day - Modification Development Section
Good to know that you fixed your own problem To be honest I haven't touched Minecraft code in a long time so unless it's a simple problem I wouldn't know. I have been busy doing other projects.
Rollback Post to RevisionRollBack
Same ****, different day - Modification Development Section
Hello hiloser, I just realized what the problem was.
"awp1" is the value of the variable sound.
I just found out that you can't put trailing numbers on your sound names. The reason for that is that the sound manager marks it as a random sound and removes the trailing number from your sound name. So awp1 will actually be awp. I will update my Thread explaining in more detail.
Rollback Post to RevisionRollBack
Same ****, different day - Modification Development Section
Hello hiloser, I just realized what the problem was.
I just found out that you can't put trailing numbers on your sound names. The reason for that is that the sound manager marks it as a random sound and removes the trailing number from your sound name. So awp1 will actually be awp. I will update my Thread explaining in more detail.
Please check out my First Post, it explains why you can't add trailing numbers on your sound names.
Alright, so I got 2 sounds working, but once I pasted the line for the third sound, the second sound stopped working. I can only get 2 sounds working at a time.
EDIT: Fixed it, just had the gun try to play arx instead of ar.
Hello, I've been trying to do this for several days, and I cannot seem to get the sound to work. :/
Here is my code:
mod_Blahblahlbah
package net.minecraft.src;
import java.util.Random;
import java.io.File;
import net.minecraft.client.Minecraft;
import java.util.Map;
public class mod_Lightsaber extends BaseMod
{
@Override
public void load()
{
Minecraft mc = ModLoader.getMinecraftInstance();
mc.installResource("newsound/ltsaberon.ogg", new File(mc.mcDataDir,"resources/lightsabersounds/ltsaberon.ogg"));
}
Item class:
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
{
Minecraft mc = ModLoader.getMinecraftInstance();
mc.sndManager.playSoundFX("ltsaberon", 1F, 1F);
}
When I attempt to play the sound by right clicking, I get no audible sound, however in the console, I get this error each time i right click:
Error in class 'LibraryLWJGLOpenAL'
Source 'sound_14' was not created because a sound buffer was not found for ltsaberon.ogg
Error in class 'LibraryLWJGLOpenAL'
Source 'sound_14' not found in method 'play'
Error in class 'LibraryLWJGLOpenAL'
Source 'sound_14' was not created because a sound buffer was not found for ltsaberon.ogg
Error in class 'LibraryLWJGLOpenAL'
Source 'sound_14' not found in method 'play'
I hope you can help me!
It's probably a problem with ogg file? Did you encode it right? Try other ones and see if the same error comes up.
Rollback Post to RevisionRollBack
Same ****, different day - Modification Development Section
Hello, I've been trying to do this for several days, and I cannot seem to get the sound to work. :/
Here is my code:
mod_Blahblahlbah
package net.minecraft.src;
import java.util.Random;
import java.io.File;
import net.minecraft.client.Minecraft;
import java.util.Map;
public class mod_Lightsaber extends BaseMod
{
@Override
public void load()
{
Minecraft mc = ModLoader.getMinecraftInstance();
mc.installResource("newsound/ltsaberon.ogg", new File(mc.mcDataDir,"resources/lightsabersounds/ltsaberon.ogg"));
}
Item class:
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
{
Minecraft mc = ModLoader.getMinecraftInstance();
mc.sndManager.playSoundFX("ltsaberon", 1F, 1F);
}
When I attempt to play the sound by right clicking, I get no audible sound, however in the console, I get this error each time i right click:
Error in class 'LibraryLWJGLOpenAL'
Source 'sound_14' was not created because a sound buffer was not found for ltsaberon.ogg
Error in class 'LibraryLWJGLOpenAL'
Source 'sound_14' not found in method 'play'
I hope you can help me!
Got that same message once, if it's the one I'm thinking of, basically it means minecraft can't find the OGG, check your file paths.
I'm having major issues trying to get a sound to play on an action.
For example, i have an item that i right click with, and i need it to play a sound.
But the problem is, i need it only to play under certain circumstances. For example, the hoe.
When i right click grass it plays a sound, when i right click stone it doesn't work, so it doesn't play a sound.
I need this same event, and i've looked into the hoe code and it doesn't help me, it fetches it based on too many variables.
Here is my mod_xxx.java:
import net.minecraft.client.*;
import java.io.File;
public void load()
{
Minecraft mc = ModLoader.getMinecraftInstance();
mc.installResource("/newsound/deodorantspray.ogg", new File(mc.mcDataDir, "/resources/newsound/deodorantspray.ogg"));
}
Here is the two methods i've tried in my item:
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World world, int i, int j, int k, int par7)
{
Minecraft mc = ModLoader.getMinecraftInstance();
world.playSoundAtEntity(par2EntityPlayer, "deodorantspray", 1.0F, 1.0F / (itemRand.nextFloat() * 1.0F + 1.0F));
And
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World world, int i, int j, int k, int par7)
{
Minecraft mc = ModLoader.getMinecraftInstance();
mc.sndManager.playSoundFX("deodorantspray", 1.0F, 1.0F);
I'm having major issues trying to get a sound to play on an action.
For example, i have an item that i right click with, and i need it to play a sound.
But the problem is, i need it only to play under certain circumstances. For example, the hoe.
When i right click grass it plays a sound, when i right click stone it doesn't work, so it doesn't play a sound.
I need this same event, and i've looked into the hoe code and it doesn't help me, it fetches it based on too many variables.
Here is my mod_xxx.java:
import net.minecraft.client.*;
import java.io.File;
public void load()
{
Minecraft mc = ModLoader.getMinecraftInstance();
mc.installResource("/newsound/deodorantspray.ogg", new File(mc.mcDataDir, "/resources/newsound/deodorantspray.ogg"));
}
Here is the two methods i've tried in my item:
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World world, int i, int j, int k, int par7)
{
Minecraft mc = ModLoader.getMinecraftInstance();
world.playSoundAtEntity(par2EntityPlayer, "deodorantspray", 1.0F, 1.0F / (itemRand.nextFloat() * 1.0F + 1.0F));
And
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World world, int i, int j, int k, int par7)
{
Minecraft mc = ModLoader.getMinecraftInstance();
mc.sndManager.playSoundFX("deodorantspray", 1.0F, 1.0F);
Please help, this is very frustrating, thank you!
Under what circumstances are you trying to play the sound?
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've since gotten this mod to work thanks to some trial and error.
But now I have another question. Do you know how to limit the sound to a certain X/Y distance? My mod's sound plays for other players even 500 blocks away.
Would this work thanks to all of the vars that it gives? If so, are you familiar with that?
I've since gotten this mod to work thanks to some trial and error.
But now I have another question. Do you know how to limit the sound to a certain X/Y distance? My mod's sound plays for other players even 500 blocks away.
Would this work thanks to all of the vars that it gives? If so, are you familiar with that?
mc.sndManager.playSound("blah.blah")....
Are you trying to play a sound at a mob? Then use the playSoundAtEntity method in the world object
@Raggarcowboy
I believe the problem is with the name of your sound. See what I'm talking about below
Make sure you don't have a slash in front of the data type, in this case it's newsound.
"/newsound/simoncraft/fart.ogg"
Remove that slash in each sound. It doesn't really matter for the actual File Location,
new File(mc.mcDataDir,"/resources/newsound/simoncraft/fart1.ogg")
you can keep that slash if you want. That should fix your problems.
@JohnMosuela
Read the spoiler above since your problem looks about the same
@ULinuxRyan314
same issue for you too, I didn't look at all your code but it looks like you have the same issue.
@THeo_sA80
can you post your code again please?
- The Cubic Chunks Mod is back! Be a part of it's rebirth and Development.
-- Robinton's Mods: [ Mirror ] for some of his Mods incl Cubic Chunks Mod, due to DropBox broken links.
- Dungeon Generator for the Open Cubic Chunks Mod
- QuickSAVE-QuickLOAD for the Open Cubic Chunks Mod
Mod_******
EDIT: Fixed
all i had to do was remove the resources on the first one and add a .ogg behind both of them
Here is the code being initialized:
That is in the load() method, and upon starting the game (im using eclipse btw) the console prints out "Sounds loaded"
Now here is how I am calling the sound:
This is for a gun mod, so that code is in ItemGun and one of the parameters in the constructor is String sound, in my mod_xxx I have this gun:
"awp1" is the value of the variable sound.
I tried your lines of code to see if the file even exists, and it said it did...
I just found out that you can't put trailing numbers on your sound names. The reason for that is that the sound manager marks it as a random sound and removes the trailing number from your sound name. So awp1 will actually be awp. I will update my Thread explaining in more detail.
So do I need to change the name of my ogg to awp?
Yes are something else like "awpone" or "awp_one".
Alright, so I got 2 sounds working, but once I pasted the line for the third sound, the second sound stopped working. I can only get 2 sounds working at a time.
EDIT: Fixed it, just had the gun try to play arx instead of ar.
Here is my code:
mod_Blahblahlbah
Item class:
When I attempt to play the sound by right clicking, I get no audible sound, however in the console, I get this error each time i right click:
I hope you can help me!
It's probably a problem with ogg file? Did you encode it right? Try other ones and see if the same error comes up.
Got that same message once, if it's the one I'm thinking of, basically it means minecraft can't find the OGG, check your file paths.
For example, i have an item that i right click with, and i need it to play a sound.
But the problem is, i need it only to play under certain circumstances. For example, the hoe.
When i right click grass it plays a sound, when i right click stone it doesn't work, so it doesn't play a sound.
I need this same event, and i've looked into the hoe code and it doesn't help me, it fetches it based on too many variables.
Here is my mod_xxx.java:
Here is the two methods i've tried in my item:
And
Please help, this is very frustrating, thank you!
I've tried, it doesn't work unless its onItemUse. :/
Under what circumstances are you trying to play the sound?
together they are powerful beyond imagination."
But now I have another question. Do you know how to limit the sound to a certain X/Y distance? My mod's sound plays for other players even 500 blocks away.
Would this work thanks to all of the vars that it gives? If so, are you familiar with that?
Are you trying to play a sound at a mob? Then use the playSoundAtEntity method in the world object