mojira.dev
MC-36387

/playsound - minVolume not working as expected

The bug

The /playsound parameter minVolume is not exactly a minimum volume but rather a default volume.
Basically, if the player is out of range, the sound's origin is centered at the player instead of the entered coordinates.
However if the player moves away from the new position while the sound is still playing, the volume will decrease as if it were played at the player's previous location without the minVolume parameter.
Therefore it is impossible to play a sound globally because even with a minVolume of 1 the volume will decrease as the player moves.

How to reproduce

/playsound minecraft:entity.ender_dragon.growl hostile @a ~ ~ ~ 1

→ ✔ Sound is played at the current location with maximum volume

/playsound minecraft:entity.ender_dragon.growl hostile @a ~17 ~ ~ 1

→ ✔ Player is out of range, sound isn't played at all

/playsound minecraft:entity.ender_dragon.growl hostile @a ~ ~ ~ 1 1 1

→ ❌ Sound is played at the current location with maximum volume, but volume decreases if the player moves

/playsound minecraft:entity.ender_dragon.growl hostile @a ~15 ~ ~ 1 1 1

→ ❌ Sound is played at the specified location with maximum volume, but at the players location it's barely hearable (volume < minVolume)

/playsound minecraft:entity.ender_dragon.growl hostile @a ~17 ~ ~ 1 1 1

→ ❌ Player is out of range, sound gets centered at the current location with maximum volume

Solution

The problem is not as simple as I first thought.

The minVolume parameter is processed only by the server and never actually sent to the client, so in order to resolve this issue the network protocol would have to be altered.
Instead of simply repositioning the source the client needs to know that the sound is meant to be played with a global minimum volume.

Btw, you are calculating the distance between the audio source and the player twice; once via EntityPlayerMP.getDistance() and once manually (net.minecraft.command.CommandPlaySound.processCommand()).

Linked issues

Comments 25

I have noticed that to. and i don't know why.

I too have noticed this. It makes it impossible to have a sound be played globally which is required for fx background music in adventure maps.

Is this still a concern in the current Minecraft version 14w10c / Launcher version 1.3.10 or later? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

Is this still a concern in the current Minecraft version 14w18b / Launcher version 1.3.11 or later? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

This ticket is incomplete without the requested information, no response has been received within a reasonable time and we are assuming the issue has been resolved. If you are still experiencing this issue, we can reopen it at your request.

Please review the guidelines before reporting issues.

15 more comments

Can confirm in 20w51a.

Can confirm in 21w03a.

Can confirm in 21w05b.

Can confirm in 1.16.5.

Can confirm in 1.17.0.02 bedrock same as java

René

Mario Welzig

(Unassigned)

Confirmed

Platform

Low

Commands, Sound

/playsound, minVolume, sound

Minecraft 1.6.4, Minecraft 13w43a, Minecraft 15w51b, Minecraft 16w02a, Minecraft 16w33a, ..., 21w03a, 1.16.5, 21w05b, 1.20.4, 24w07a

Minecraft 16w35a

Retrieved