MCInjector icon indicating copy to clipboard operation
MCInjector copied to clipboard

Add general parameter naming

Open JoJoDeveloping opened this issue 6 years ago • 3 comments

This extends the old constructors.txt file in favor of a more general one that allows naming parameters for all kind of methods. Along this exporting data in the old format is disabled, while importing is retained, but converted to the new format.

JoJoDeveloping avatar Aug 27 '19 13:08 JoJoDeveloping

I was about to add special handling for lambds$funcname$x synthetic methods, but they are already assigned srg names in previous steps, so I undid my changes.

JoJoDeveloping avatar Sep 18 '19 20:09 JoJoDeveloping

What is the change in the output data? Show examples/documentation of the new format. How much does it change the download size of the standard distributions? What do you mean by "all kinda of methods" I have ideas on what you mean, but you should post explicit documentation.

LexManos avatar Oct 14 '19 16:10 LexManos

This replaces the old constructors.txt file, which consisted of lines assinging "srg"-like IDs to constructors so that their params could be named even though the actual method name must always be "". Lines looked like this: 1005 net/minecraft/client/Minecraft$3 (Lnet/minecraft/client/Minecraft;)V

Since the last update caused lots of methods to "lose" their obfuscation, causing their params to become unrenameable, I added this PR, which extends the constructors format (renaming it to params.txt), to not only contain entries for constructors, but also for any other method that is not assigned a srg name. This deletes the cmdline argument "--ctrOut", and adds "--prm" and "--prmOut", which can be used to set the import and export files for the new params.txt format. "--ctr" is retained and will import the old constructors.txt format to be exported with --prmOut.

The new params.txt file looks like this:

e51806 net/minecraft/util/math/ChunkPos$1 tryAdvance (Ljava/util/function/Consumer;)Z
i1005 net/minecraft/client/Minecraft$3 <init> (Lnet/minecraft/client/Minecraft;)V
s51832 net/minecraft/realms/RealmsMth sin (F)F

The format consists of a number and a prefix char, which is i for initializers so that the param srg names stay the same. s is used for static methods, and is important since the static_methods.txt list does not contain non-srged methods, yet tools need to know if a method is static since that changes the parameter id (the x in p_s12345_x starts at 0 for the first parameter). Other methods simply have an 'e'.

This results in names for parameters like p_e51806_1, p_i1005_1 or p_s51832_0. Note that for p_i1005_1 is the same srg name as that what would have been generated by the old system.

As for download size change, the current (1.14.4) constructors.txt is 748683b, while the params.txt for 1.14.4 would be 963324b. The mcp_config zip would increase from 644820b to 677592b (with zip -9), which is an increase of 5.1%.

"All kind of methods" means that this tool generates such an "parameter srg base name" for all methods that are not A) synthetic B) already assigned a srg name.

An alternative to this I considered was adding the param base name to the main tsrg file, which would make the whole export data smaller, but require a rewrite of every tool working with tsrg files. Since neither me nor anyone else wants to do that I used this approach.

JoJoDeveloping avatar Oct 14 '19 18:10 JoJoDeveloping