audio: check attenuation distance before playing/loading

* This fixes a lot of issues with sound spamming (e.g. on Cuberite servers)
This commit is contained in:
Bixilon 2022-08-23 22:16:14 +02:00
parent 668e3d27dc
commit c5dfb63113
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -184,6 +184,12 @@ class AudioPlayer(
if (!profile.enabled) {
return
}
position?.let {
val distance = (this.listener.position - it).length()
if (distance >= sound.attenuationDistance) {
return
}
}
queue += add@{
sound.load(connection.assetsManager)
val source = getAvailableSource()