PaperMC / paperweight

Gradle build system plugin for Paper and Paper forks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for getDeclaredField and Class#forName in reobfJar

PlayerSchark opened this issue · 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.

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

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