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

[SOLVED][1.11.2] Play default minecraft sound

Featured Replies

Hi everyone, I want to play default minecraft sound:

world.playSound(pos.getX() + 0.5D, pos.getY() + 1.0D, pos.getZ() + 0.5D, "liquid.splash", SoundCategory.AMBIENT, 1.0f, 1.0f, true);

But it doesn't work. I don't know how to play it :(

HELP ME PLS

Edited by IvanSteklow
Solved

World::playSound takes a SoundEvent as it's 4th parameter, not a string. Vanilla SoundEvents can be found at net.minecraft.init.SoundEvents.

You should also use the overload that takes an EntityPlayer as it's first parameter as the method you are using will only work on the client.

All that is explained in the docs here.

  • Author
8 minutes ago, V0idWa1k3r said:

World::playSound takes a SoundEvent as it's 4th parameter, not a string. Vanilla SoundEvents can be found at net.minecraft.init.SoundEvents.

You should also use the overload that takes an EntityPlayer as it's first parameter as the method you are using will only work on the client.

All that is explained in the docs here.

So, 'cause I have only to blockpos, how to get nearest player?

  • Author
48 minutes ago, V0idWa1k3r said:

https://mcforge.readthedocs.io/en/latest/effects/sounds/#world-playsound-pxyzecvp.

A player can be null on a server and then all the players nearby will hear it. And if your side is the client - there is only 1 player on the client(if that is the case you can also use the overload you were using originaly).

So thanks!

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.

Account

Navigation

Search

Search

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.