aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-21 19:59:42 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-21 19:59:42 +0200
commitcc7f4e3ebd476320d0f8750432c0de2e58588272 (patch)
treef6c9e493d0dda8f57e38b338691037dcde6de5ea /src/main/java/at/hannibal2/skyhanni
parent15d52eb5e458aafbd9a8b34bb5b24d0872b93846 (diff)
downloadskyhanni-cc7f4e3ebd476320d0f8750432c0de2e58588272.tar.gz
skyhanni-cc7f4e3ebd476320d0f8750432c0de2e58588272.tar.bz2
skyhanni-cc7f4e3ebd476320d0f8750432c0de2e58588272.zip
fixed error message when playing sounds
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt
index 9eb476666..95406b1bf 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt
@@ -10,23 +10,25 @@ object SoundUtils {
private val beepSound by lazy { createSound("random.orb", 1f) }
fun ISound.playSound() {
- val gameSettings = Minecraft.getMinecraft().gameSettings
- val oldLevel = gameSettings.getSoundLevel(SoundCategory.PLAYERS)
- gameSettings.setSoundLevel(SoundCategory.PLAYERS, 1f)
- try {
- Minecraft.getMinecraft().soundHandler.playSound(this)
- } catch (e: Exception) {
- if (e is IllegalArgumentException) {
- e.message?.let {
- if (it.startsWith("value already present:")) {
- println("SkyHanni Sound error: $it")
- return
+ Minecraft.getMinecraft().addScheduledTask {
+ val gameSettings = Minecraft.getMinecraft().gameSettings
+ val oldLevel = gameSettings.getSoundLevel(SoundCategory.PLAYERS)
+ gameSettings.setSoundLevel(SoundCategory.PLAYERS, 1f)
+ try {
+ Minecraft.getMinecraft().soundHandler.playSound(this)
+ } catch (e: Exception) {
+ if (e is IllegalArgumentException) {
+ e.message?.let {
+ if (it.startsWith("value already present:")) {
+ println("SkyHanni Sound error: $it")
+ return@addScheduledTask
+ }
}
}
+ e.printStackTrace()
+ } finally {
+ gameSettings.setSoundLevel(SoundCategory.PLAYERS, oldLevel)
}
- e.printStackTrace()
- } finally {
- gameSettings.setSoundLevel(SoundCategory.PLAYERS, oldLevel)
}
}