From 3867d3b778c8a710365ba996a034f81fce03cfd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Thu, 26 Feb 2015 16:48:25 +0100 Subject: [PATCH] Mute looping sounds while game is paused. --- src/main/scala/li/cil/oc/client/Sound.scala | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/scala/li/cil/oc/client/Sound.scala b/src/main/scala/li/cil/oc/client/Sound.scala index 1974b1e30..abb6fa4f4 100644 --- a/src/main/scala/li/cil/oc/client/Sound.scala +++ b/src/main/scala/li/cil/oc/client/Sound.scala @@ -19,6 +19,8 @@ import net.minecraft.client.Minecraft import net.minecraft.client.audio.SoundCategory import net.minecraft.client.audio.SoundManager import net.minecraft.client.audio.SoundPoolEntry +import net.minecraft.server.MinecraftServer +import net.minecraft.server.integrated.IntegratedServer import net.minecraft.tileentity.TileEntity import net.minecraft.util.ResourceLocation import net.minecraftforge.client.event.sound.SoundLoadEvent @@ -52,7 +54,9 @@ object Sound { def soundSystem: SoundSystem = ReflectionHelper.getPrivateValue(classOf[SoundManager], manager, "sndSystem", "field_148620_e", "e") private def updateVolume() { - val volume = FMLClientHandler.instance.getClient.gameSettings.getSoundLevel(SoundCategory.BLOCKS) + val volume = + if (isGamePaused) 0f + else FMLClientHandler.instance.getClient.gameSettings.getSoundLevel(SoundCategory.BLOCKS) if (volume != lastVolume) { lastVolume = volume sources.synchronized { @@ -63,6 +67,11 @@ object Sound { } } + private def isGamePaused = MinecraftServer.getServer != null && !MinecraftServer.getServer.isDedicatedServer && (MinecraftServer.getServer match { + case integrated: IntegratedServer => Minecraft.getMinecraft.isGamePaused + case _ => false + }) + private def processQueue() { if (commandQueue.nonEmpty) { commandQueue.synchronized {