Jump to content

[Solved] Getting Paulscode Source - IllegalArgumentException


Xenocider

Recommended Posts

I been reading through Paulscode 3D SoundSystem Library http://www.paulscode.com/docs/SoundSystem/overview-summary.html and I can't find a way to get from Minecraft's SoundSystem to it's Library and then running .getSource("BgMusic").getSoundSequenceQueueSize();

 

This get's the java.lang.Class Library:

soundManager.sndSystem.currentLibrary()

is there a way from this point to run the Method .getSource()? I have looked at .getMethod() and .getMethods() but I can't quite understand what I can do with them.

 

Any help, tips or ideas would be most appreciated! Thanks!

Link to comment
Share on other sites

I tried your suggestion to access it via reflection however it is throwing an IllegalArgumentException and I need some help. I'm not very experienced with reflection and so I had to read up on some tutorials before attempting it.

    public static Source getSource() throws NoSuchFieldException, SecurityException, InstantiationException, IllegalAccessException {
        Source theSource = null;
        LogHelper.info("Getting field..."); 
        Field field = MainEventHandler.soundManager.sndSystem.getClass().getDeclaredField("soundLibrary");
        if (field == null) {LogHelper.severe("The field is null!");} 
        else {
        field.setAccessible(true);
        LogHelper.debug("Getting soundLibrary!"); 
        Class<?> targetType = field.getType();
        Object objectValue = targetType.newInstance();
        Library soundLibrary = (Library) field.get(objectValue);
        if (soundLibrary == null) {LogHelper.severe("The soundLibrary is null!");} 
        else {
            theSource = soundLibrary.getSource("BgMusic");
        }
        }
        return theSource;
    }

 

The crash log:

 

2013-12-05 16:58:50 [iNFO] [sTDERR] Exception in thread "Timer-1" java.lang.IllegalArgumentException: Can not set paulscode.sound.Library field paulscode.sound.SoundSystem.soundLibrary to paulscode.sound.Library

2013-12-05 16:58:50 [iNFO] [sTDERR] at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:164)

2013-12-05 16:58:50 [iNFO] [sTDERR] at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:168)

2013-12-05 16:58:50 [iNFO] [sTDERR] at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:55)

2013-12-05 16:58:50 [iNFO] [sTDERR] at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:36)

2013-12-05 16:58:50 [iNFO] [sTDERR] at java.lang.reflect.Field.get(Field.java:372)

2013-12-05 16:58:50 [iNFO] [sTDERR] at xenocider.grooves.handler.MusicHandler.getSource(MusicHandler.java:71)

2013-12-05 16:58:50 [iNFO] [sTDERR] at xenocider.grooves.handler.MusicHandler.updateCurrentSong(MusicHandler.java:81)

2013-12-05 16:58:50 [iNFO] [sTDERR] at xenocider.grooves.gui.MusicPlayerGui$1.run(MusicPlayerGui.java:140)

2013-12-05 16:58:50 [iNFO] [sTDERR] at java.util.TimerThread.mainLoop(Timer.java:555)

2013-12-05 16:58:50 [iNFO] [sTDERR] at java.util.TimerThread.run(Timer.java:505)

 

Link to comment
Share on other sites

I'd recommend:

try{
        Field field = SoundSystem.class.getDeclaredField("soundLibrary");
        field.setAccessible(true);
        Library soundLibrary = Library.class.cast(field.get(classMainEventHandler.soundManager.sndSystem));
}catch(Exception e){

}

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.



×
×
  • Create New...

Important Information

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