feat(delta): playSoundAttenuated - wave propagation + normalized decay, one packet per player
Build Delta / Build paperclip jar (push) Failing after 5m24s
Build Delta / Build paperclip jar (push) Failing after 5m24s
This commit is contained in:
@@ -3637,6 +3637,35 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
|
||||
default void playSound(@NotNull Location location, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch, float range) {
|
||||
playSound(location, sound, category, volume, pitch); // fallback: range == f(volume)
|
||||
}
|
||||
/**
|
||||
* Delta: plays a sound that travels outward as a wave and fades with distance.
|
||||
* <p>
|
||||
* Unlike vanilla, where audible range is derived from volume (so "audible at
|
||||
* 500 blocks" means volume 31 and is deafening up close), volume and distance
|
||||
* are independent here: {@code volume} is loudness at the source, {@code range}
|
||||
* is how far the sound carries. Attenuation follows
|
||||
* {@code gain = volume * (1 - d/range)^exponent}, reaching exactly zero at
|
||||
* {@code range}; beyond it nothing is transmitted at all.
|
||||
* <p>
|
||||
* The wave front moves at {@code delta.sound.propagation-blocks-per-tick}
|
||||
* (default 10, i.e. 100 blocks in 0.5s), so distant players hear it after that
|
||||
* delay. Exactly one packet per player is sent, when the front arrives, with
|
||||
* no per-tick updating.
|
||||
* <p>
|
||||
* Requires the Delta core; on any other server it falls back to
|
||||
* {@link #playSound(Location, Sound, SoundCategory, float, float)}.
|
||||
*
|
||||
* @param location where the sound originates
|
||||
* @param sound the sound to play
|
||||
* @param category the category of the sound
|
||||
* @param volume loudness at the source
|
||||
* @param pitch the pitch of the sound
|
||||
* @param range how far the sound carries, in blocks
|
||||
*/
|
||||
default void playSoundAttenuated(@NotNull Location location, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch, float range) {
|
||||
playSound(location, sound, category, volume, pitch);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Play a Sound at the location of the provided entity in the World. For sounds
|
||||
|
||||
Reference in New Issue
Block a user