Attenuation distance controls how far away a sound can be heard before it's silent. This works properly with type "sound" (default) entries, but not with type "event" entries; it'll use the parent's attenuation distance, rather than using the event's, or multiplying with it (divided by 16).
Steps to reproduce:
Create a sounds.json with the following:
{ "custom.parent": { "sounds": [ { "name": "mob/zombie/hurt2" } ] }, "custom.event": { "sounds": [ { "type": "event", "name": "custom.parent", "attenuation_distance": 2 } ] }, "custom.sound": { "sounds": [ { "name": "mob/zombie/hurt2", "attenuation_distance": 2 } ] } }
Logic dictates that custom.sound and custom.event both have an attenuation distance of 2 blocks.
Use
/playsound custom.sound master @s ~ ~ ~
and/playsound custom.sound master @s ~ ~ ~3
Observe how the first command's sound can be heard, but the second one can't
Use
/playsound custom.event master @s ~ ~ ~
and/playsound custom.event master @s ~ ~ ~3
Observe how the both command's sound can be heard.
Expected result:custom.event
has an attenuation distance of 2 blocks.
Actual result:custom.event
has an attenuation distance of the default value of 16 blocks because that's what custom.parent
's attenuation distance is.
Comments 6
Are you sure this is the issue you're experiencing? Sound following you everywhere can be achieved by using high volume in playsound commands.
What I meant was that using playsound to play sounds, like minecraft:xxxxxx, works without any problems.
when using playsound to play sounds from resourcepacks, such as custom:bgm.01, the volume does not decrease with distance, even if it is more than 16 blocks away or further.
The same issue persists in the new version 1.20.5 where attenuation_distance still does not affect custom sound (from resourcepacks), while vanilla sound functions normally without any issues.
vanilla sound works normally. (hear nothing)
/playsound minecraft:entity.pig.hurt master @a ~ ~64 ~ 1 1 0
custom sounds can still be heard and have the highest volume anywhere in the range.. (even set attenuation_distance=150 or more)
/playsound {any custom sound} master @a ~ ~64 ~ 1 1 0
The same issue appeared in version 1.19.4, where the volume of sounds in custom resource packs does not decrease with distance. Instead, it stays constant and follows the player at the same volume during playback. However, this does not happen with sounds in the original Minecraft.