0

This may seem complicated, but what I am trying to do is that when any player walk on water for a bit, a playsound will be executed at the position of the player that walked on water, but everyone will hear it.

I already tried these commands:

/scoreboard objectives add water minecraft.custom:minecraft.walk_on_water_one_cm

/execute at @a[scores={water=220..}] run playsound minecraft:entity.player.swim master @a ~ ~ ~ 0.3 1 0.3

/scoreboard players reset @a[scores={water=220..}]

but this plays the sound at the position of every player, not only at the specific player

/execute at @a[scores={water=220..}] run playsound minecraft:entity.player.swim master @s ~ ~ ~ 0.3 1 0.3 also doesn't work, because it only plays the sound for the player that walked on water

2 Answers 2

2

Here I am, answering my own question. I found the source of the problem, and it is exactly what I commented on the other answer: when you use /playsound...@a ~ ~ ~, after the relative coords there are 3 numbers, the 1st being the volume, the 2nd being the pitch, and the 3rd being the minVolume, which I tested and found out that it is the minimum volume that can be heard out of that sound, no matter where you are, so if you set it to 0.5, even if you are 10000+ blocks away, you will hear the sound, but with the volume of 0.5.

1
  • 1
    I see, I never get to use the minVolume. Learnt something new, thanks
    – hfanatic
    Commented Dec 10, 2021 at 6:06
0

execute as @a[scores={water=220..}] at @s run playsound minecraft:entity.player.swim master @a ~ ~ ~

Minecraft sound should not be heard by other players far away unless the volume configuration is too high. By inspecting your code I cannot find the source of your problem. You can try out the code above.

Note: I recommend using ambient instead of master. Master mode would allow the specific sound to take over all other sounds and come out on top, which doesn't fit the purpose of your ambient walking-on-water sound.

The @a and @s at the end of the command only indicates the player that could possibly hear them. Say if you playsound only to @s even players next to you won't hear them. On the contrary, setting it to @a won't let everyone on the server hear it as if it is a broadcast. I still follows the minecraft sound engine and can fade from a few blocks away.

Finally, try to run the command positioned ^ ^ ^1 which would make the sound run in front of you so that when you are moving you can still hear the sound.

2
  • execute as @a[scores={water=220..}] at @s run playsound minecraft:entity.player.swim master @a ~ ~ ~ was the first thing I tried, and as you can see, the volume is set to 0.3, but I could still hear the sound from hundreds of blocks away
    – Aruser_
    Commented Dec 10, 2021 at 2:49
  • Maybe the problem is the minVolume? I can't test it right now because my friend is not online, but it could be the problem. I don't know how it works, but I guess it may be the lowest volume that can be heard out of that sound, no matter the distance
    – Aruser_
    Commented Dec 10, 2021 at 2:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.