md-5 / SpecialSource

Automatic generator and renamer of jar obfuscation mappings.
Other
206 stars 49 forks source link

class which extend other classes, their methods are not remapped #68

Closed AngryCarrot789 closed 3 years ago

AngryCarrot789 commented 3 years ago

im trying to reobfuscate a minecraft mod, and i have the srg file all setup, and this is my code:

player.setSprinting(true)

the setSprinting function is found in the class LivingEntity. but the player variable is an EntityPlayer which is in a different package, but it extends LivingEntity (so, public class EntityPlayer extends LivingEntity). and as a result, the setSprinting method never gets remapped, even when using the --reverse parameter when remapping. the only fix i've found, is to manually edit the .srg file, and change the method location from LivingEntity to EntityPlayer (and also change the obfuscated class and method names too), but that would break other things too...

i've heard another fix is to deliberately cast the EntityPlayer method to LivingEntity (in my case atleast), so the code would look like this: ((LivingEntity) player).setSprinting(true). i haven't tried that, but i assume it does work. but i dont really want to have to do that for every line of code. or maybe there's an option in the compiler to make it do this? im not sure

is this fixable? or do i just have to do the above; manually cast the derived class to the base classes

md-5 commented 3 years ago

Follow the examples and you wont have this issue: https://www.spigotmc.org/threads/spigot-bungeecord-1-17-1-17-1.510208/#post-4184317

AngryCarrot789 commented 3 years ago

im not sure those will help tbh, thats for minecraft 1.17 but im using 1.6.4 :( ive also tried using some of the command parameters from one of the replies, but they dont seem to help either

md-5 commented 3 years ago

Same thing, you need an MC jar in your classpath or as a remapped depend if using the maven plugin

AngryCarrot789 commented 3 years ago

i still cant get it to work :(

my full command is: java -classpath minecraft_server-mcpremap.jar -jar specialsource.jar --live --in-jar ModFileMCP.jar --out-jar ModFileObfus.jar --srg-in obf2srg.srg --reverse. all of these files are in the same directory too

it remapps the class names (converts EntityPlayer to uf, but the methods that were inherited aren't). on that forum they used the --live parameter, but it still doesn't work. i even tried changing the classpath from the minecraft_server-mcpremap (containing MCP class names/methods/fields) to the obfuscated version (obfuscated everything, no packages), but none of that works

and ive also tried supplying --srg-in with a folder which contains files like fields.csv, joined.srg, packaged.srg, etc. that didn't work either

md-5 commented 3 years ago

You can't mix -classpath and -jar. Read the forum post example closely.

AngryCarrot789 commented 3 years ago

ah i see. i managed to get it to remap the function :) using java -cp specialsource.jar;minecraft_server-mcpremap.jar net.md_5.specialsource.SpecialSource --live -i ModFileMCP.jar -o ModFileObfus.jar -m obf2srg.srg --reverse

thanks for helping too :)))

solarrabbit99 commented 3 years ago

It seems that the issue raised applies when using SpecialSource jar in BuildTools.jar directory ./BuildData/bin/SpecialSource.jar, even with the manual commands presented in https://www.spigotmc.org/threads/spigot-bungeecord-1-17-1-17-1.510208/#post-4184317