Open Barteks2x opened 6 years ago
This would be possible to achieve with some heuristics and probably folding (I don't think you can replace the elements completely). However, I'd say this would be much better suited as an extension to FernFlower (or something further up the pipeline, at a bytecode level). Don't take my word on it, but I think there actually already are some heuristics somewhere in the pipeline to resolve some constants.
Except fixing it in forge gradle may break some forge patches. It would be possible to add some of the Minecraft classes to the fg list but that would probably have to be done together with forge patches update
Except fixing it in forge gradle may break some forge patches.
Patches are applied before the GL (and other) fixes are applied. See https://github.com/MinecraftForge/ForgeGradle/blob/FG_2.3/src/main/java/net/minecraftforge/gradle/tasks/PostDecompileTask.java#L122
It should be fixed on ForgeGradle's side imo
Though an inspection could probably be added for modder code
This seems like it would be easy enough to add with folding, considering the GLConstantFixer reference.
But I'm curious - if that's in ForgeGradle already, is this valid anymore? Or even if FG does do it, would this still be useful?
As far as I can see it does it for raw GL calls, but not GLStateManager
I wrote a simple proof of concept to show that this is feasible, but it's probably inefficient and it doesn't check if the int literals are actually GL related. https://github.com/minecraft-dev/MinecraftDev/compare/dev...ramidzkh:magic-constants
Because of obfuscation, Minecraft's opengl code is full of things like this:
GlStateManager.glTexParameteri(3553, 10243, 10497);
. Would it be possible for MinecraftDev to either automatically replace them with actual GL constants likeGL_TEXTURE_2D
, or have a right click option to show method arguments as GL constants? This would probably involve creating a big list of which methods take arguments of which type of gl constants, but I think it should be possible.