Posted December 1, 201311 yr I need some help understanding what caused Minecraft to crash. Crash: Description: Updating screen events java.lang.StackOverflowError at net.minecraftforge.client.event.sound.PlayBackgroundMusicEvent.getListenerList(PlayBackgroundMusicEvent.java) at net.minecraftforge.event.EventBus.post(EventBus.java:105) at net.minecraftforge.client.event.sound.SoundEvent.getResult(SoundEvent.java:16) at xenocider.grooves.handler.MainEventHandler.onPlayBackgroundMusic(MainEventHandler.java:65) at net.minecraftforge.event.ASMEventHandler_5_MainEventHandler_onPlayBackgroundMusic_PlayBackgroundMusicEvent.invoke(.dynamic) at net.minecraftforge.event.ASMEventHandler.invoke(ASMEventHandler.java:39) at net.minecraftforge.event.EventBus.post(EventBus.java:108) at net.minecraftforge.client.event.sound.SoundEvent.getResult(SoundEvent.java:16) The crash was triggered after the code MainEventHandler.soundManager.playMusic(MusicHandler.currentSong); was run. Some of my code that I think might be the problem: EventListener Class: @ForgeSubscribe public void onPlayBackgroundMusic(PlayBackgroundMusicEvent event) { SoundPoolEntry playingSong = SoundEvent.getResult(event); if (playingSong.getSoundName() == MusicHandler.currentSong.getSoundName()) { MusicHandler.goToNextSong(); } } Base Class SoundManager modified code: public void playMusic(SoundPoolEntry currentSong) { currentSong = SoundEvent.getResult(new PlayBackgroundMusicEvent(this, currentSong)); if (currentSong != null) { this.sndSystem.backgroundMusic("BgMusic", currentSong.getSoundUrl(), currentSong.getSoundName(), false); this.sndSystem.setVolume("BgMusic", this.options.musicVolume); this.sndSystem.play("BgMusic"); } } Anything that would help understand what caused the StackOverflow error would be appreciated. Thanks!
December 1, 201311 yr Aren't you just saying that if the current song = the current song then go to the next song, making it constantly go to the next song, on and on? "StackOverflow" Usually means you are getting stuck in an infinite loop somewhere. You could try placing a breakpoint and see where it leads you If you guys dont get it.. then well ya.. try harder...
December 1, 201311 yr Author No goToNextSong() just makes it so that the next time it runs playMusic(MusicHandler.currentSong) it will play the next song after it. I'm not the best at naming my methods and variables. This is what happens in goToNextSong: public static void goToNextSong() { if (currentSong == null || currentSongInt == MainEventHandler.musicSoundPoolEntryArray.length) {currentSong = MainEventHandler.musicSoundPoolEntryArray[0]; currentSongInt = 0;} else { currentSong = MainEventHandler.musicSoundPoolEntryArray[currentSongInt + 1]; currentSongInt = currentSongInt + 1; } LogHelper.info("Going to next song."); } EDIT: I added a logger to the PlayBackgroundMusicEvent and it was spammed a lot of times before the game crashed. So somehow the PlayBackgroundMusicEvent keeps on getting triggered in a endless loop.
December 1, 201311 yr Hi I think Mazetar is probably right, your code is effectively calling itself in a loop. You could confirm this by adding a few more logging statements to your PlayBackgroundMusicEvent. Or a breakpoint. -TGG
December 1, 201311 yr Author Yeah it is looping PlayBackgroundMusicEvent for some reason. I edited my reply right when you replied. Any ideas why this is happening and how could I fix it?
December 1, 201311 yr getSoundName() == Use .equals(Object) instead. String are immutable. By the way, use event.source to get the sound played, and set event.result to change to the new sound.
December 2, 201311 yr Author Thank you! It was the event.result that was continuously running the event. Changing it to event.source solved it!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.