Skip to content

Conversation

@LexManos
Copy link
Member

@LexManos LexManos commented Feb 9, 2026

Simple example of using the renamer plugin to build a obfusicated jar.
Addresses #3

Two main concerns I wanted to bounce of @Jonathing

  1. This relies on having the mavenizer run, but currently doesn't invoke it in any way.
  2. This also relies on the modder finding the mcpconfig version/parchment version. Which I can imagine now people geting confused about.

So basically, FG needs to make a couple helpers to get the mappings artifacts.
Not super critical, FD7 is the primary, but I think something like the Files object you're doing for that is probably something we could pull for this as well.

Copy link

@PaintNinja PaintNinja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, a bit clearer how to reobf in FG7 now. Left a bunch of comments - some minor stuff, some more significant questions.

private static final Logger LOGGER = LogUtils.getLogger();

public ExampleMod(FMLJavaModLoadingContext context) {
LOGGER.info("If this shows up we can reference obfusication code: " + Blocks.DIRT.getDescriptionId());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

Suggested change
LOGGER.info("If this shows up we can reference obfusication code: " + Blocks.DIRT.getDescriptionId());
LOGGER.info("If this shows up we can reference obfuscated code: " + Blocks.DIRT.getDescriptionId());

Comment on lines +8 to +9
displayName="Test"
description="Test"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
displayName="Test"
description="Test"
displayName="FG7 Obfuscation Example"
description="Demonstrates how to build an obfuscated Forge mod jar for versions that don't have runtime MojMap (1.20.4 and older)"

id 'net.minecraftforge.renamer' version '1.0.1'
}

version = '0'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
version = '0'
version = '0.0'

To match the mods.toml version


version = '0'
group = 'com.example'
base.archivesName = 'test'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
base.archivesName = 'test'
base.archivesName = 'obfuscation'

Comment on lines +14 to +17
java.toolchain.languageVersion = JavaLanguageVersion.of(21)

minecraft {
mappings channel: 'official', version: '1.21.10'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.20.1 please, to avoid noobs being confused thinking that modern versions need reobf

// This is generated by mavenizer, this is `net.minecraft:mappings_{channel}:{minecraft}-{mcp}:map2srg@tsrg.gz`
// I intend to both publish these as public artifacts on the Forge maven, and expose a FG helper to make you not need to find the MCP version
// Parchment is official mappings, just with parameters, so you can use official.
mappings('net.minecraft:mappings_official:1.21.10-20251007.101210:map2srg@tsrg.gz')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where can users find the MCP timestamp found in this artifact string?

@@ -0,0 +1,9 @@
modLoader="javafml"
loaderVersion="[0,)"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
loaderVersion="[0,)"
loaderVersion="*"

I don't remember if the Neo mod detection in FML checks for "[2,)" or "[0,)", but a "*" definitely won't trigger a false-positive and goes through a fast-path skipping a maven version range comparison. Not all that relevant to this example but might as well as it's cleaner.

implementation minecraft.dependency('net.minecraftforge:forge:1.21.10-60.0.17')
}

renamer.classes(jar) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
renamer.classes(jar) {
renamer.classes(tasks.named('jar', Jar)) {

To avoid eager configuration of the Jar task

implementation minecraft.dependency('net.minecraftforge:forge:1.21.10-60.0.17')
}

renamer.classes(jar) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does one register multiple reobf jar tasks for different inputs?

tasks.register('reobfJar', RenameJar) {
    // ?
}

Is renamer.classes(...) { ... } a helper for task registration or required for it to work? If the former and not much more verbose, I'd prefer knowing the standard Gradle way for registering the task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants