Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.