From d1a2476a4e503d931f187760cced5db7b280ad6a Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Fri, 14 Mar 2014 17:22:55 -0400 Subject: [PATCH] Quick Fix for Limbo Music Crash The following small change deals with a strange background-music-related crash. Wasn't this issue fixed for Jaitsu and Aether II? I'm not sure what's the cause but I've added a check to prevent the NPE. Please deal with this most robustly in the future. --- .../mod_pocketDim/EventHookContainer.java | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/EventHookContainer.java b/src/main/java/StevenDimDoors/mod_pocketDim/EventHookContainer.java index d3b09f46..02f3aeaf 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/EventHookContainer.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/EventHookContainer.java @@ -218,24 +218,29 @@ public class EventHookContainer public void playMusicForDim(World world) { - if(world.isRemote) + if (world.isRemote) { SoundManager sndManager = FMLClientHandler.instance().getClient().sndManager; - if(world.provider instanceof LimboProvider) - { - sndManager.sndSystem.stop("BgMusic"); - SoundPoolEntry soundPoolEntry = sndManager.soundPoolSounds.getRandomSoundFromSoundPool(mod_pocketDim.modid+":creepy"); - if(soundPoolEntry!=null) - { - sndManager.sndSystem.backgroundMusic("LimboMusic", soundPoolEntry.getSoundUrl(), soundPoolEntry.getSoundName(), false); - sndManager.sndSystem.play("LimboMusic"); - } - } - else if(!(world.provider instanceof LimboProvider)) - { - sndManager.sndSystem.stop("LimboMusic"); - } + // SenseiKiwi: I've added the following check as a quick fix for a reported crash. + // This needs to work without a hitch or we have to stop trying to replace the background music... + if (sndManager != null && sndManager.sndSystem != null) + { + if (world.provider instanceof LimboProvider) + { + sndManager.sndSystem.stop("BgMusic"); + SoundPoolEntry soundPoolEntry = sndManager.soundPoolSounds.getRandomSoundFromSoundPool(mod_pocketDim.modid+":creepy"); + if (soundPoolEntry != null) + { + sndManager.sndSystem.backgroundMusic("LimboMusic", soundPoolEntry.getSoundUrl(), soundPoolEntry.getSoundName(), false); + sndManager.sndSystem.play("LimboMusic"); + } + } + else if (!(world.provider instanceof LimboProvider)) + { + sndManager.sndSystem.stop("LimboMusic"); + } + } } } } \ No newline at end of file