Posted November 10, 201410 yr Hello all, In my mod I have a block which plays some sound effects. The sounds/actions are triggered server-side and sent to the clients. I am currently going through a refactor which is trying to reduce the amount of packets that is sent between the server and client, however I noticed a problem. I am able to successfully send particle messages from the server to the client and have them spawn by invoking World#spawnParticle(String, double, double, double, double, double, double) on the world object, however for some reason invoking World#playSoundEffect(double, double, double, String, float, float) does not play the sound effect, instead I've found that it requires me to actually invoke that method server-side or it won't be heard on the client at all... I'm not too sure what I'm doing wrong here, so any suggestions would be greatly appreciated! Code IMessage: https://github.com/theoriginalbit/MoarPeripherals/blob/master/src/main/java/com/theoriginalbit/moarperipherals/common/network/message/MessageSoundEffect.java IMessageHandler: https://github.com/theoriginalbit/MoarPeripherals/blob/master/src/main/java/com/theoriginalbit/moarperipherals/common/network/message/handler/MessageHandlerSoundEffect.java — BIT
November 10, 201410 yr Hi If you want other clients to hear the sound effect you need to send it to the server. If you just want the local client to hear the sound, you can use Minecraft.getMinecraft().getSoundHandler().playSound(sound); where sound is an ISound, typically PositionedSoundRecord There are some good vanilla examples such as MovingSoundMinecartRiding -TGG
November 10, 201410 yr Author Hi, As it currently stands the code is being processed on the server, therefore I wish to send it out to the clients. I assume that the standard World#playSoundEffect(double, double, double, String, float, float) performs a lookup with the supplied name to find a Minecraft.getMinecraft().getSoundHandler().playSound(ISound)? — BIT
November 11, 201410 yr Yes. World#playSoundEffect and #playSoundAtEntity will automatically notify all nearby clients, so you don't have to; however, they may only be used on the server. On the client, you can use player#playSound (which doesn't work on the server). http://i.imgur.com/NdrFdld.png[/img]
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.