diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-05-21 19:59:42 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-05-21 19:59:42 +0200 |
commit | cc7f4e3ebd476320d0f8750432c0de2e58588272 (patch) | |
tree | f6c9e493d0dda8f57e38b338691037dcde6de5ea /src/main | |
parent | 15d52eb5e458aafbd9a8b34bb5b24d0872b93846 (diff) | |
download | skyhanni-cc7f4e3ebd476320d0f8750432c0de2e58588272.tar.gz skyhanni-cc7f4e3ebd476320d0f8750432c0de2e58588272.tar.bz2 skyhanni-cc7f4e3ebd476320d0f8750432c0de2e58588272.zip |
fixed error message when playing sounds
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt | 30 |
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) } } |