mojira.dev
MC-255439

Sounds.json's attenuation distance doesn't work with type: event

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:

  1. 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
                }
            ]
        }
    }
  2. Logic dictates that custom.sound and custom.event both have an attenuation distance of 2 blocks.

  3. Use /playsound custom.sound master @s ~ ~ ~ and /playsound custom.sound master @s ~ ~ ~3

  4. Observe how the first command's sound can be heard, but the second one can't

  5. Use /playsound custom.event master @s ~ ~ ~ and /playsound custom.event master @s ~ ~ ~3

  6. 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

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.

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.

Yeah, that's not what this is about; and that works fine for me.

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

Still in 1.21.4. I suggest setting me to the reporter, as other commenters do not seem to understand the problem. The file/steps are provided, yet people are confusing it with another issue due to not following the steps. 

user-f2760

Dhranios

(Unassigned)

Confirmed

Platform

Low

Sound

1.19.2, 1.19.3, 1.19.4, 1.20.1, 1.20.2, 23w43b, 1.20.4, 24w03b, 1.21.4

Retrieved