Jump to content

[SOLVED][1.11.2] Play default minecraft sound


IvanSteklow

Recommended Posts

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
  • Like 1
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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?

  • Like 1
Link to comment
Share on other sites

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!

  • Like 1
Link to comment
Share on other sites

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.