Jump to content

Recommended Posts

Posted

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

Posted

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.

Posted

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.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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