Skip to content

(platform-bukkit) Sound played without a location inaccuracies #240

@imkunet

Description

@imkunet

feet vs eyes

If you just call the public void playSound(final net.kyori.adventure.sound.@NotNull Sound original) on an audience, it'll grab their position via createPosition which in BukkitFacet just turns the target player's location into a vector. This means that in effect, the sound will play at the feet of the player.

The craft places the listener for the audio at the eye height of the player. This means if the volume if the sound is 1f, and we assume a non shifting eye-height of 1.62f; we can expect up to a 0.10125 consistent error in volume. Instrumenting the (1.8.9) game to measure this, the picture becomes clear:

Image

(the x axis is the volume of the sound played, and there were 100 sounds played over the 0-1 range)

The error is apparent and makes itself very known by the time it reaches 1f volume, it being 10% quieter than it should be, and all that.

legacy spigot snapping

To supplement this error further, the way legacy Bukkit handles playing sounds is a bit funky. To avoid legal issues, I will ask you to inspect the CraftPlayer class in 1.8.8 Spigot and note how in public void playSound(Location loc, String sound, float volume, float pitch)it snaps the sound to the center of the block of the location it is played at, further increasing the error.

The worst case scenario of this snapping is another 0.86602540 block error (which means 0.0541265875 change in volume in a 1f volume sound) by distance formula of 0.5 on all dimensions.

Since no one cares about legacy, maybe we can let this one slip past.

no good

The total possible absolute error as a result of these inaccuracies is a staggering is a total of 1.62 + 0.86602540 = 2.4860254 block error which corresponds to a whopping 0.1553765875 (≈15% ‽) change in output volume. Recall that the change in output volume for a 1f volume sound can be found by dividing the distance from origin blocks by 16.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions