Jump to content

Can I deobfuscate the Forge Jar at game startup?

Recommended Posts

Not so long ago I had an idea to make mod that able to execute Scripts in Kotlin directly at runtime.

But of course before compiling all the code must be obfuscated. At least this can be done manually, but it's a very boring and long process.

Using Kotlin PSI I was still able to automate this process, but only with deobfuscated Jar and tsrg mappings.

According to the MCP license I can't distribute a deobfuscated Jar, so I was wondering if it's acceptable to deobfuscate a Jar right at launch time? Or may be there is some better way to obfuscate the source code before compiling?

Link to comment
Share on other sites

If you deobfuscate the jar at runtime it will just break everything.

Instead you need to obfuscate whatever it is you are doing like ForgeGradle does with the reobfJar task


These are the mappings from minecraft's obfuscated names to forge names (for 1.19.3)



To get from mojangs official mappings to its obfuscated names, requires the use of the MojMap files (again 1.19.3)




To work out which mappings to use requires downloading the main version manifest to get the specific version file



then looking in that for the client/server mappings elements.



If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Well, I meant a little differently, but thanks for the answer!

I'll tell you a little bit about what exactly I want to do:
I conditionally have a script that uses game code:

val v = Vector3d.ZERO

In the development environment it runs and compiles correctly, and at normal startup the code should be:

val v = Vector3d.field_186680_a

Accordingly, there are two ways to obfuscate this script. The first is to first compile it using the deobfuscated dependency and then obfuscate Class, as Gradle does during "reobfJar". The second way, which I have already implemented, is to first obfuscate the code, and then compile and run the script itself in the game environment. But for obfuscation in second case I need to get deobfuscated version of Forge/Minecraft, so my idea is to copy Forge into a separate folder during first run and decompile it there, like during environment setup and then just point it into classpath, so Kotlin PSI could analyze the script properly (without dependency it doesn't see any mc fields and functions)

Link to comment
Share on other sites

This topic is now closed to further replies.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.