Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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!

  • Author

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)

 

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){

}

  • Author

Thanks so much GotoLink! It works perfectly! I had absolutely no idea how to do a reflection, so thanks a lot!

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.