Jump to content

[1.8.9] Forge Method mapping


Raycoms

Recommended Posts

We have the following code. This code works great in our dev environment (Using Intellij)

But the moment we leave the dev environment this doesn't work anymore.

 

try (DataOutputStream dataOutputStream = new DataOutputStream(new GZIPOutputStream(new FileOutputStream(file))))
            {
                Method method = ReflectionHelper.findMethod(NBTTagCompound.class, null, new String[] {
                        "writeEntry", "a" }, String.class, NBTBase.class, DataOutput.class);
                method.invoke(null, "Schematic", tagCompound, dataOutputStream);
            }

 

Executing it on technic leads to:

 

[b#347]  net.minecraftforge.fml.relauncher.ReflectionHelper$UnableToFindMethodException: java.lang.NoSuchMethodException: net.minecraft.nbt.NBTTagCompound.a(java.lang.String, net.minecraft.nbt.NBTBase, java.io.DataOutput)
[b#347]  	at net.minecraftforge.fml.relauncher.ReflectionHelper.findMethod(ReflectionHelper.java:183) ~[modpack.jar:?]
[b#347]  	at com.schematica.world.schematic.SchematicFormat.writeToFile(SchematicFormat.java:92) [schematicFormat.class:?]
[b#347]  	at com.minecolonies.util.Schematic.saveSchematic(Schematic.java:264) [schematic.class:?]
[b#347]  	at com.minecolonies.items.ItemScanTool.func_180614_a(ItemScanTool.java:58) [itemScanTool.class:?]
[b#347]  	at net.minecraft.item.ItemStack.func_179546_a(ItemStack.java:135) [zx.class:?]
[b#347]  	at net.minecraft.client.multiplayer.PlayerControllerMP.func_178890_a(PlayerControllerMP.java:403) [bda.class:?]
[b#347]  	at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1491) [ave.class:?]
[b#347]  	at net.minecraft.client.Minecraft.func_71407_l(Minecraft.java:2036) [ave.class:?]
[b#347]  	at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1024) [ave.class:?]
[b#347]  	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:349) [ave.class:?]
[b#347]  	at net.minecraft.client.main.Main.main(SourceFile:124) [Main.class:?]
[b#347]  	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91]
[b#347]  	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_91]
[b#347]  	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_91]
[b#347]  	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_91]
[b#347]  	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
[b#347]  	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
[b#347]  Caused by: java.lang.NoSuchMethodException: net.minecraft.nbt.NBTTagCompound.a(java.lang.String, net.minecraft.nbt.NBTBase, java.io.DataOutput)
[b#347]  	at java.lang.Class.getDeclaredMethod(Unknown Source) ~[?:1.8.0_91]
[b#347]  	at net.minecraftforge.fml.relauncher.ReflectionHelper.findMethod(ReflectionHelper.java:174) ~[modpack.jar:?]
[b#347]  	... 16 more

Link to comment
Share on other sites

There are 3 names:

 

obfuscated "notch" names (

a.bc()

)

SRG deobfuscated names (

WorldServer.func_12345_a()

)

MCP deobfuscated names (

WorldServer.getWorldTime()

)

 

For reflection, you have to use MCP names in dev, but SRG names in release.  There's no real way around this, which is why ReflectionHelper exists.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

There are 3 names:

 

obfuscated "notch" names (

a.bc()

)

SRG deobfuscated names (

WorldServer.func_12345_a()

)

MCP deobfuscated names (

WorldServer.getWorldTime()

)

 

For reflection, you have to use MCP names in dev, but SRG names in release.  There's no real way around this, which is why ReflectionHelper exists.

Hm, I'm doing this in my mod, too. So there has to be a check if we are in dev-env or not? If so, how can this be done?

Developer of Primeval Forest.

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.