diff options
Diffstat (limited to 'src/main/java')
-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) } } |