From 6a4771bd4704dad6c42ffb77e917ae46b5d66c19 Mon Sep 17 00:00:00 2001 From: Moritz Zwerger Date: Mon, 24 Jun 2024 23:15:11 +0200 Subject: [PATCH] audio: don't play sound if muted --- src/main/java/de/bixilon/minosoft/assets/util/FileUtil.kt | 1 + .../de/bixilon/minosoft/gui/rendering/sound/AudioPlayer.kt | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/bixilon/minosoft/assets/util/FileUtil.kt b/src/main/java/de/bixilon/minosoft/assets/util/FileUtil.kt index 78bab5e53..b443b6905 100644 --- a/src/main/java/de/bixilon/minosoft/assets/util/FileUtil.kt +++ b/src/main/java/de/bixilon/minosoft/assets/util/FileUtil.kt @@ -45,6 +45,7 @@ object FileUtil { return readFile(path.toFile(), compressed) } + @Deprecated("kutil 1.26.3") fun File.mkdirParent() { val parent = this.parentFile if (parent.exists()) { diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/sound/AudioPlayer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/sound/AudioPlayer.kt index edda3cff3..442e50e31 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/sound/AudioPlayer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/sound/AudioPlayer.kt @@ -1,6 +1,6 @@ /* * Minosoft - * Copyright (C) 2020-2023 Moritz Zwerger + * Copyright (C) 2020-2024 Moritz Zwerger * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * @@ -193,7 +193,7 @@ class AudioPlayer( } private fun playSound(sound: Sound, position: Vec3d? = null, volume: Float = 1.0f, pitch: Float = 1.0f) { - if (!profile.enabled) { + if (!profile.enabled || profile.volume.master <= 0.0f) { return } position?.let { if (!shouldPlay(sound, position)) return }