paperweight icon indicating copy to clipboard operation
paperweight copied to clipboard

Support for getDeclaredField and Class#forName in reobfJar

Open PlayerSchark opened this issue 2 years ago • 2 comments

Due to some nested classes in NMS are package-private it should be possible that Class#forName and Class#getDeclaredField are supported by the reobfJar task.

Example:

Class.forName("net.minecraft.network.ConnectionProtocol$PacketSet").getDeclaredField("classToId") should be reobfuscated to: Class.forName("net.minecraft.network.EnumProtocol$a").getDeclaredField("b")

or:

Entity.class.getDeclaredField("tickCount") should be reobfuscated to: Entity.class.getDeclaredField("ag")

It seems that SpecialSource already supports it in its RemapperProcessor.

PlayerSchark avatar Sep 09 '23 00:09 PlayerSchark

It's worth noting that there are already libraries to handle this at runtime, https://github.com/jpenilla/reflection-remapper

I'm not sure if this is something we will bother with, given our intent to move away from relying on remapping in the future

electronicboy avatar Sep 09 '23 01:09 electronicboy

we are in the process of building out tooling for the other direction, obf reflection calls -> mojang mapped source, since paper will ship mojang mapped jars per default in the future, so I dont see this being added to paperweight-userdev

MiniDigger avatar Sep 09 '23 10:09 MiniDigger