-
Bug
-
Resolution: Unresolved
-
Minecraft 1.6.4, Minecraft 13w43a, Minecraft 15w51b, Minecraft 16w02a, Minecraft 16w33a, Minecraft 1.12.2, Minecraft 17w45b, Minecraft 18w03b, Minecraft 18w08b, Minecraft 1.13.1, Minecraft 19w09a, Minecraft 1.14.4 Pre-Release 5, 1.14.4, 1.15.2, 20w22a, 1.16.2, 20w51a, 21w03a, 1.16.5, 21w05b, 1.20.4, 24w07a
-
Confirmed
-
Commands, Sound
-
Low
-
Platform
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()).