Posted December 7, 201410 yr Hello, is there a way to "unmap" names of field/ method? Example: I'm using the "IClassTransformer" and want to edit the 2"onUpdate" ("()V") in "EntityItem". I can "unmap" EntityItem using this method: FMLDeobfuscatingRemapper.INSTANCE.map("net/minecraft/entity/item/EntityItem") but "unmapping" onUpdate is not possible... i can only map fields/methods FMLDeobfuscatingRemapper.INSTANCE.mapFieldName(owner, name, desc); FMLDeobfuscatingRemapper.INSTANCE.mapMethodName(owner, name, desc); So my question is: Is there a way to unmap Fields/Methods?
December 7, 201410 yr Author The MCP names (onUpdate, onBlockActivated, etc.) are not available at runtime outside the dev environment. All you have access to are the SRG names (field_xxxxx_x, func_xxxxx_x) and you can map between those and the "fully obfuscated names" (the names in the original jar file). How? I will need that, too . FMLDeobfuscatingRemapper.INSTANCE.mapFieldName(owner, name, desc); doesn't work , maybe i'm doing it wrong? If you only want 1 name in your code you need to use SRG names in the code and translate to MCP names in the development environment. I use this class for that: https://github.com/diesieben07/SevenCommons/blob/master/src/main/java/de/take_weiland/mods/commons/asm/MCPNames.java You will need to update the path to the mappings files for 1.7 though. I searched for these two files (fields.csv and methods.csv), but couldn't find it for 1.8 . Also i don't understand these lines: String prop = System.getProperty(SYS_PROP); if (prop == null) { mappingsDir = "./../build/unpacked/mappings/"; } else { mappingsDir = prop; } Does this also work outside of my eclipse environment?
December 8, 201410 yr Author but this does only work in m eclipse enviroment: public void replaceOnUpdateMethod(ClassNode node) { String targetMethodName = "onUpdate"; String targetDESC = "(Lnet/minecraft/entity/item/EntityItem;)V"; Iterator<MethodNode> methods = node.methods.iterator(); while(methods.hasNext()) { MethodNode m = methods.next(); if ((m.name.equals(targetMethodName) && m.desc.equals("()V"))) { m.instructions.clear(); m.instructions.add(new VarInsnNode(ALOAD, 0)); m.instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/creativemd/itemphysic/physics/ServerPhysic", "update", targetDESC, false)); m.instructions.add(new InsnNode(RETURN)); } } } I think because it's not a real "link" to the method, but only a string.
December 8, 201410 yr Author I don't know the name, but i used names like a, ai or something like that, but i thought i could use this class "map" these names. Obviously this is not possible .
December 8, 201410 yr Author Hm, what are SRG names? I used the file 'notch-mcp.srg' in he past here is one extract: MD: adw/s_ ()V net/minecraft/entity/item/EntityItem/onUpdate ()V so i would have to replace onUpdate with s_, that's how i did it in the past.
December 8, 201410 yr Author So is there a way to get the notch names? Also i couldn't get the srg names as well, the only thing i found was mapping func_xxxxxx to onUpdate(), but not the other way round. Did i something wrong?
December 8, 201410 yr Author I'm confused, i don't think that i could use srg name ("funcxxxx") instead of ("s_") do transform the class. MethodNode m = methods.next(); if ((m.name.equals(targetMethodName) && m.desc.equals("()V"))) Therefore i need the notch names ...
January 31, 201510 yr Author After a little break, i continued working on it and failed I'm using "@IFMLLoadingPlugin.SortingIndex(1001)" but there is no way i can map an methodname like "interactFirst" to something like "func....". I tried everything but couldn't find anything which could help me doing it. FMLDeobfuscatingRemapper is saving these names in "rawFieldMaps", but there is no way i could access them, also it's only saving the SRG names. So i don't know if this class is able to find the SRG name for a given MCP name. Could someone help me out?
January 31, 201510 yr Author You mean i should use SRG names and map it to mcp names. Not my favorite, but a better way than before.
January 31, 201510 yr Author I could use these files 'notch-mcp.srg', but this would consume a way to much time for a startup.
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.