Posted August 11, 201411 yr 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);
August 12, 201411 yr Is there any console errors complaining about not finding the sound asset? Or other errors? Check out my tutorials here: http://jabelarminecraft.blogspot.com/
August 12, 201411 yr Author 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 :\
August 12, 201411 yr Is your mod open source? If so I could look at the code and so some testing of my own.
August 12, 201411 yr Author 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?
August 12, 201411 yr 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:< -Mitchellbrine 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: I don't want your charity, I want your information
August 12, 201411 yr 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.
August 12, 201411 yr Author 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); }
August 12, 201411 yr 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.
August 12, 201411 yr Author 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.
August 12, 201411 yr 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.
August 12, 201411 yr 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.
August 12, 201411 yr Author 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 .
August 12, 201411 yr 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
August 12, 201411 yr Author 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.
August 13, 201411 yr Author 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.
August 13, 201411 yr 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.
August 13, 201411 yr Author 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.
August 13, 201411 yr I should also warn you that your mod is a client only mod. It will not run on a server
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.