Jump to content

[SOLVED] Help Understanding Crash


Xenocider

Recommended Posts

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!

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.