Posted January 16, 20169 yr TL;DR A plugin system which adds Jars to the classloader can call several Minecraft methods when running from within IntelliJ Idea, however it errors when running it in standard Forge (when the mod jar is dropped in the mods folder) Hi there! I'm trying to develop a plugin system for my mod, however I'm very confused as to why it works when I run / debug it from IntelliJ Idea, but it doesn't work when I put the mod jar in my mods folder, and the plugin in the mods/CraftedCart/MFFClientPlugins folder. The plugin loads, however it errors whenever I try to use several Minecraft methods. GLStateManager seems to be broken. It couldn't pushMatrix or translate BlockPos also seems to be broken. It errors when I try to getX() Here's the error for the getX() method ( testMFFPlugin is the plugin, and it's trying to draw a TESR ). Caused by: java.lang.NoSuchMethodError: net.minecraft.util.BlockPos.getX()I The whole stack: 10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: java.lang.reflect.InvocationTargetException [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source) [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at java.lang.reflect.Method.invoke(Method.java:497) [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at io.github.craftedcart.MFF.client.render.blocks.TERendererFFProjector.func_180535_a(TERendererFFProjector.java:37) [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher.func_178469_a(SourceFile:114) [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher.func_180546_a(SourceFile:102) [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at net.minecraft.client.renderer.RenderGlobal.func_180446_a(RenderGlobal.java:655) [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at net.minecraft.client.renderer.EntityRenderer.func_175068_a(EntityRenderer.java:1294) [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at net.minecraft.client.renderer.EntityRenderer.func_78471_a(EntityRenderer.java:1207) [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at net.minecraft.client.renderer.EntityRenderer.func_78480_b(EntityRenderer.java:1032) [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1048) [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:345) [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at net.minecraft.client.main.Main.main(SourceFile:120) [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at java.lang.reflect.Method.invoke(Method.java:497) [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: Caused by: java.lang.NoSuchMethodError: net.minecraft.util.BlockPos.getX()I [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at io.github.craftedcart.TestMFFPlugin.TestMFFPluginBase.renderTEFFProjector(TestMFFPluginBase.java:65) [10:19:29] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: ... 19 more FramebufferStatus 0x0000 at beginHand FramebufferStatus 0x0000 at pre endHand GL error 0x0502: Invalid operation at renderCompositeFinal The details of how plugins are loaded: 1: Plugins are added to the class loader LaunchClassLoader loader = (LaunchClassLoader) DependencyUtils.class.getClassLoader(); //DependencyUtils is one of my classes loader.addURL(file.toURI().toURL()); //In this case, the file variable would be the mods/CraftedCart/MFFClientPlugins/testMFFPlugin.jar file 2: Plugins are searched for an @MFFClientPlugin annotation using Reflections (Note the extra s on the end of that. It's an external library) Reflections reflections = new Reflections(); clientPlugins = reflections.getTypesAnnotatedWith(MFFClientPlugin.class); 3: The load() method is called on all plugins using Reflection for (Class clazz : clientPlugins) { Method loadMethod = clazz.getMethod("load"); loadMethod.invoke(clazz.newInstance()); } In the test plugin, it would set 2 variables (The method to call when rendering the TESR, and its class) The TESR then uses Reflection to invoke the method on that class
January 16, 20169 yr If you want to run code in actual Minecraft, not in dev, you need to reobfuscate your code. ForgeGradle does this automatically for you when you run gradle build . You also need to keep this in mind if you use reflection with Minecraft's classes. Every field/method has an SRG (semi-obfuscated) name like field_00120_a / func_12345_b and most fields/methods also have an MCP (deobfuscated) name like thing / getThing . You need to make sure you check both names when using reflection. FML's ReflectionHelper and ObfuscationReflectionHelper have methods to find a field/method with one of several names via reflection. You can find the SRG name of a field/method in the MCP mapping CSVs. If you've set up a ForgeGradle workspace for 1.8+, you can find the mappings it's using in the Gradle cache (~/.gradle/caches/minecraft/de/oceanlabs/mcp/<mappings_channel>/<mappings_version>, replace ~ with %USERPROFILE% on Windows). You can also download them from the MCPBot website. External libraries and Forge/FML code (including new methods/fields in vanilla classes) aren't affected by this, everything just has the one name. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
January 16, 20169 yr Author If you want to run code in actual Minecraft, not in dev, you need to reobfuscate your code. ForgeGradle does this automatically for you when you run gradle build . Ah, I probably should have said that I packaged the code into a .jar (IntelliJ's Build > Build Artifact) when it was running in the dev environment, and that the dev environment read from that jar, rather than reading from the soruce.
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.