Posted December 4, 201311 yr 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!
December 6, 201311 yr 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)
December 6, 201311 yr 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){ }
December 6, 201311 yr 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.