Jump to content

Recommended Posts

Posted

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?

Posted

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)

https://raw.githubusercontent.com/MinecraftForge/MCPConfig/master/versions/release/1.19.3/joined.tsrg

 

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

https://piston-data.mojang.com/v1/objects/42366909cc612e76208d34bf1356f05a88e08a1d/client.txt

https://piston-data.mojang.com/v1/objects/bc44f6dd84cd2f3ad8c0caad850eaca9e82067e3/server.txt

 

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

https://piston-meta.mojang.com/mc/game/version_manifest_v2.json

https://piston-meta.mojang.com/v1/packages/6607feafdb2f96baad9314f207277730421a8e76/1.19.3.json

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

 

Boilerplate:

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.

Posted

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
println(v)

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

val v = Vector3d.field_186680_a
println(v)

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)

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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