Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

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

  • 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

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.