NomNuggetNom Posted August 11, 2014 Posted August 11, 2014 Plain and simple, sounds are not playing. I am trying to use vanilla sounds. Here's an example: mc.theWorld.playSoundAtEntity(mc.thePlayer, "random.levelup", 0.75F, 1.0F); I'm sure it's reaching this code. I copied the "random.levelup" from the EntityPlayerMP class, where the player is leveling up. But I don't hear anything. My mod is client-side only on a vanilla server. Any help is appreciated EDIT: This is the solution: mc.thePlayer.playSound("random.levelup", 0.75F, 1.0F); Quote
penguinsfan77 Posted August 12, 2014 Posted August 12, 2014 Can you post the whole method that line is in? Quote
jabelar Posted August 12, 2014 Posted August 12, 2014 Is there any console errors complaining about not finding the sound asset? Or other errors? Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
NomNuggetNom Posted August 12, 2014 Author Posted August 12, 2014 On 8/12/2014 at 1:39 AM, penguinsfan77 said: Can you post the whole method that line is in? It's a very large method, with lots of unrelated bits. What could possibly be affecting it in the method? So, here's proof it's making it there: System.out.println("abc123"); mc.theWorld.playSoundAtEntity(mc.thePlayer, "random.levelup", 0.75F, 1.0F); System.out.println("123abc"); Which results as abc123 123abc on the console. So, jabelar, no errors or anything :\ Quote
penguinsfan77 Posted August 12, 2014 Posted August 12, 2014 Is your mod open source? If so I could look at the code and so some testing of my own. Quote
NomNuggetNom Posted August 12, 2014 Author Posted August 12, 2014 On 8/12/2014 at 4:56 AM, penguinsfan77 said: Is your mod open source? If so I could look at the code and so some testing of my own. It's not, and I'd rather not share the code right now. Perhaps you could just copy the bit I pasted and see if it works? Quote
Mitchellbrine Posted August 12, 2014 Posted August 12, 2014 You're wanting people to help but not letting them see the code they need to see to fix it? You could at least show them the method you're using. That way they could test and help. D:< Quote -Mitchellbrine Quote Minecraft can do ANYTHING, it's coded in Java and you got the full power of Java behind you when you code. So nothing is impossible. It may be freaking fucking hard though, but still possible If you create a topic on Modder Support, live by this motto: Quote I don't want your charity, I want your information
penguinsfan77 Posted August 12, 2014 Posted August 12, 2014 On 8/12/2014 at 2:44 PM, NomNuggetNom said: It's not, and I'd rather not share the code right now. Perhaps you could just copy the bit I pasted and see if it works? i would need the whole method to do proper testing. This is because the .playSoundAtEntity() method probably works fine, its just the way your calling it. Quote
daafganggdg Posted August 12, 2014 Posted August 12, 2014 I think u have to call it on the client, so use that world.isRemote thing Quote
NomNuggetNom Posted August 12, 2014 Author Posted August 12, 2014 On 8/12/2014 at 5:50 PM, Mitchellbrine said: You're wanting people to help but not letting them see the code they need to see to fix it? You could at least show them the method you're using. That way they could test and help. D:< The thing is, the rest of the code is really messy and completely unrelated. I've posted only the relevant code because I didn't want people to be confused . But here, I moved it out of where it is, and into a more general spot (still not working): @SubscribeEvent public void onChat(ClientChatReceivedEvent event) { mc.theWorld.playSoundAtEntity(mc.thePlayer, "random.levelup", 1.0F, 1.0F); ChatFilter.handleChat(event); } Quote
TehSeph Posted August 12, 2014 Posted August 12, 2014 On 8/12/2014 at 7:50 PM, NomNuggetNom said: The thing is, the rest of the code is really messy and completely unrelated. I've posted only the relevant code because I didn't want people to be confused . You're misunderstanding. For people to help you you'll need to show the entire class, not just that method. playSoundAtEntity() works just fine. Its a vanilla method. If it didn't, than there'd be no sound in the vanilla game. In order to see what is happening to cause it to not work, we need to see the rest of the .java file's contents to understand where the problem is. You can't expect help on something without providing people with the thing you need help on. Quote
NomNuggetNom Posted August 12, 2014 Author Posted August 12, 2014 On 8/12/2014 at 8:41 PM, TehSeph said: Quote The thing is, the rest of the code is really messy and completely unrelated. I've posted only the relevant code because I didn't want people to be confused . You're misunderstanding. For people to help you you'll need to show the entire class, not just that method. playSoundAtEntity() works just fine. Its a vanilla method. If it didn't, than there'd be no sound in the vanilla game. In order to see what is happening to cause it to not work, we need to see the rest of the .java file's contents to understand where the problem is. You can't expect help on something without providing people with the thing you need help on. I understand. I posted the method above. Quote
penguinsfan77 Posted August 12, 2014 Posted August 12, 2014 That method doesn't help. We need to see the everything in the same method that your trying to make it work in. For example, I have no idea what the "mc" variable is and where you define it. without that I can't help you. Quote
TehSeph Posted August 12, 2014 Posted August 12, 2014 On 8/12/2014 at 8:51 PM, NomNuggetNom said: I understand. I posted the method above. You're either trolling, or were dropped on your head as a child. That is not the entire method. That doesn't even validate as java. Reread my post or read the post above this. Quote
NomNuggetNom Posted August 12, 2014 Author Posted August 12, 2014 On 8/12/2014 at 9:12 PM, TehSeph said: Quote I understand. I posted the method above. You're either trolling, or were dropped on your head as a child. That is not the entire method. That doesn't even validate as java. Reread my post or read the post above this. Sorry guys, I misunderstood. To make it much easier, I have separated it into it's own class - both to make sure nothing is interfering, and to make it easier to debug. import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.client.Minecraft; import net.minecraftforge.client.event.ClientChatReceivedEvent; public class ChatSound { public static Minecraft mc = Minecraft.getMinecraft(); @SubscribeEvent public void onChat(ClientChatReceivedEvent event) { System.out.println("About to play a sound."); mc.theWorld.playSoundAtEntity(mc.thePlayer, "random.levelup", 1.0F, 1.0F); System.out.println("Done playing a sound."); } } Every time chat comes in, the lines are being printed, so I know the event is being called. My apologies for the misunderstanding. Thank you guys for trying to help, I really appreciate it. If I am still giving you the wrong things, please tell me - I'm not trying to make it hard for you guys to help . Quote
penguinsfan77 Posted August 12, 2014 Posted August 12, 2014 Is the method that you are trying to use it in an Overide of another method? If so which one? and does the class you are trying to use it in extend anything? If you give me these two pieces of information I might be able to help you Quote
NomNuggetNom Posted August 12, 2014 Author Posted August 12, 2014 On 8/12/2014 at 11:35 PM, penguinsfan77 said: Is the method that you are trying to use it in an Overide of another method? If so which one? and does the class you are trying to use it in extend anything? If you give me these two pieces of information I might be able to help you I am not overriding any other method, and the class is not extending anything. Quote
NomNuggetNom Posted August 13, 2014 Author Posted August 13, 2014 On 8/13/2014 at 12:15 AM, penguinsfan77 said: What is the class doing? I'm not sure what you mean. The only purpose of the class is to play a sound on a chat event. I posted the whole class. Quote
penguinsfan77 Posted August 13, 2014 Posted August 13, 2014 If you only want the player to hear the sound and not every player around that player then this works fine: mc.thePlayer.playSound("random.levelup", 1.0F, 1.0F); However if you want every player near the player that sent the message to hear the sound this won't work. Quote
NomNuggetNom Posted August 13, 2014 Author Posted August 13, 2014 On 8/13/2014 at 3:06 AM, penguinsfan77 said: If you only want the player to hear the sound and not every player around that player then this works fine: mc.thePlayer.playSound("random.levelup", 1.0F, 1.0F); However if you want every player near the player that sent the message to hear the sound this won't work. This is the solution. Thank you very much. Quote
penguinsfan77 Posted August 13, 2014 Posted August 13, 2014 I should also warn you that your mod is a client only mod. It will not run on a server Quote
Recommended Posts
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.