Deobfuscation Fix Task — Instructions

Your Goal

Fix compilation errors in GregTech Java source files by editing
Python fix modules in recreate_sources/gregtech/. Errors come from leftover obfuscated
field/method names that the automated deobfuscator couldn't resolve.

How the Pipeline Works

  1. recreate_sources/gregtech/deobfuscate.py runs first — it uses MCP mapping files to rename obfuscated
    classes, fields, and methods. Do not modify this file..

    It replaces modified files with its output so previous pipeline runs have no effect on future runs.
    It does not handle all cases, and does only partial deobfuscation.

    Pipeline can't apply processing twice no matter what. It always works with fresh files on input.

  2. Per-file fix modules (.py files) run second — each one opens a specific
    .java file, applies vr()/vrx()/ai() fixes, and writes it back.

    CRITICAL: If ANY vr() or vrx() replacement warns (text not found), the pipeline
    ABORTS before compilation. All modules finish processing first, then warnings are
    checked — if any exist, compilation is skipped. You MUST fix all warnings before
    compilation can run. Disabling this behavior or bypassing warnings is FORBIDDEN.

  3. recompile.bat runs last — located in project root.
    Compilation filters out all warnings; only errors are shown.

Run everything with:

python recreate_sources/gregtech/gregtech_fix_pipeline.py

What You Can Modify

Only the per-file fix modules under these directories.

ALL fix modules already exist as stub files. You do NOT need to create new ones.
Every .java file already has a corresponding .py fix module registered in
fix_registry.py. Just open the existing file and add vr()/vrx()/ai() calls
inside the fix() function.

For anonymous inner class files ($1.java, $2.java, etc.), fix them by adding
code to the parent class's fix module. Example: GT_ModHandler$1.java errors
are fixed inside recreate_sources/gregtech/common/GT_ModHandler.py.

Fix modules go directly inside recreate_sources/gregtech/, mirroring the Java
package structure. Example:

1
2
3
4
5
6
Java:  src/minecraft/gregtechmod/GT_Mod.java
Fix:   recreate_sources/gregtech/GT_Mod.py    already exists, just add fixes
Java:  src/minecraft/gregtechmod/api/GregTech_API.java
Fix:   recreate_sources/gregtech/api/GregTech_API.py
Java:  src/minecraft/gregtechmod/common/GT_Config.java
Fix:   recreate_sources/gregtech/common/GT_Config.py

What You Cannot Modify

File Reason
deobfuscate.py Correct, do not touch
fix_registry.py Correct, do not touch
fix_shared.py Shared helpers, changing it breaks everything
gregtech_fix_pipeline.py The orchestrator, do not change
run_pi_cycle.py Batch runner for pi iterations
run_pi_cycle.bat Windows wrapper for the batch runner
Any .java file Fixes go in the Python modules, not the Java source

Do not create new pipeline scripts, LAST_fix.py, FINAL_patch.py, or anything
similar. Do not add wrapper scripts. Do NOT create new fix module .py files — all
fix modules already exist, just modify them. All fixes belong in the per-file modules.


Fix Module Anatomy

#!/usr/bin/env python3
"""Fix module for gregtechmod/GT_Mod.java"""
from fix_shared import ROOT, WARNINGS, r, w, ai, vr, vrx
import os


def fix():
    # ROOT is a relative path from fix_shared.py to the Java source directory.
    # ALWAYS use ROOT from fix_shared — do NOT define your own path.
    full_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), ROOT,
                             'GT_Mod.java')
    c = r(full_path)
    # --- fixes go here ---
    c = vr(c, 'old text', 'new text', ctx='GT.context')
    c = vrx(c, r'regex pattern', r'replacement', ctx='GT.context')
    c = ai(c, 'net.minecraft.some.Class')
    # ---------------------
    w(full_path, c)

if __name__ == '__main__':
    fix()

Fix Module Template (already exists for every file)

Every fix module starts as a stub that just reads, does nothing, and writes back.
Your job is to add vr()/vrx()/ai() calls in the marked section:

#!/usr/bin/env python3
"""Fix module for gregtechmod/GT_Mod.java"""
from fix_shared import ROOT, WARNINGS, r, w, ai, vr, vrx
import os


def fix():
    full_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), ROOT,
                             'GT_Mod.java')
    c = r(full_path)
    # --- Add fixes below using vr(), vrx(), ai() ---

    w(full_path, c)

if __name__ == '__main__':
    fix()

Available Helpers

Helper What it does
r(path) Read file, records path for warnings
w(path, content) Write content to file
ai(c, import_str) Add import import_str; if missing
vr(c, old, new, ctx) Replace literal old with new. Warns and ABORTS pipeline if old not found.
vrx(c, pattern, replacement, ctx) Regex replace. Warns and ABORTS pipeline if pattern not found.

Use vr() for exact text and vrx() for regex patterns. The ctx string is
shown in warnings to identify which replacement failed.


Work Cycle

1. Run the pipeline

python recreate_sources/gregtech/gregtech_fix_pipeline.py

2. Read the first error

The Java compiler shows only the last 100 errors in its output. There are
many errors total. As you fix errors, new ones become visible.
Do not use total error count as a progress metric — it stays at ~100 no matter
how many you fix. Always read the exact error you intend to fix.

Example error output:

1
2
3
4
5
src/minecraft/gregtechmod/GT_Mod.java:456: error: cannot find symbol
  someObfuscatedField.someMethod()
  ^
  symbol:   method someMethod()
  location: variable someObfuscatedField of type SomeClass

3. Open the corresponding fix module

Match the Java file path to the fix module path. The fix module already exists
just add vr()/vrx()/ai() calls inside its fix() function:

src/minecraft/gregtechmod/GT_Mod.java    recreate_sources/gregtech/GT_Mod.py

For anonymous inner class files ($1.java, $2.java), use the parent class's
fix module. The fix() function can read and write multiple files:

src/minecraft/gregtechmod/common/GT_ModHandler$1.java    recreate_sources/gregtech/common/GT_ModHandler.py

4. Diagnose the obfuscated name

The Java source at src/minecraft/gregtechmod/ may still contain obfuscated names that
the deobfuscator didn't catch. Use your knowledge of Minecraft 1.4.7 MCP mappings
to figure out the correct deobfuscated name.

Common patterns (approximate — verify against MCP mappings when unsure):

  • obj.cobj.itemID (ItemStack field)
  • obj.cmobj.blockID (Block field)
  • obj.d()obj.getMaxStackSize() (ItemStack method)
  • obj.a() → varies widely (check method signature and parameters)
  • obj.animationsToGo()obj.getItem() (ItemStack method)
  • this.kthis.worldObj (TileEntity field)
  • this.l, this.m, this.nthis.xCoord, this.yCoord, this.zCoord
  • obj.b()obj.getItem() (ItemStack method)
  • .a() on collection → .getStackInSlot(), .isItemEqual(), etc.
  • Raw collection iteration → needs explicit Object + cast

5. Add the fix

Insert the fix call inside fix() before w(full_path, c):

c = vr(c, 'obfuscatedName', 'correctName', ctx='GT.short-context')

Or for patterns:

c = vrx(c, r'regex matching obfuscated code', r'correct replacement', ctx='GT.context')

For missing imports:

c = ai(c, 'net.minecraft.some.package.ClassName')

6. Verify the fix

Run the pipeline again:

python recreate_sources/gregtech/gregtech_fix_pipeline.py

The pipeline ABORTS immediately if any vr()/vrx() warning triggers — meaning
the text you tried to replace wasn't found (the code is different than expected).

You CANNOT proceed to compilation until all warnings are fixed.

If the pipeline reaches compilation and your error is gone, the fix worked.

7. Tracking progress

The compiler only shows the last 100 errors out of many total.
The total error count will remain at ~100 even as you fix errors — it is NOT a
progress metric. Instead:

  • Pick one specific error from the output, fix it, verify it's gone.
  • Move to the next error shown.
  • When all 100 visible errors are fixed, the next batch of 100 appears.

Important Rules

  • Do not modify: deobfuscate.py, fix_shared.py, fix_registry.py
    gregtech_fix_pipeline.py, any .java files, or the pipeline's batch
    files. Only edit per-file fix modules.
  • Do not create new fix modules. All fix modules already exist as stub files
    in recreate_sources/gregtech/. fix_registry.py already lists every module.
    Just open the existing file and add your fixes.
  • Do not leave this project directory. Everything needed is here.
  • Do not use git. No commits, branches, or repository operations.
  • Do not create alternative pipelines. No LAST_fix.py, ending_touches.py,
    final_round.py, or similar scripts. Fixes go in the per-file modules only.
  • Do not assume you are close to finishing. The project has many errors.
    There is no "last" or "final" step. Just keep fixing one error at a time.
  • Assume deobfuscate.py is correct. Do not second-guess its output or try
    to improve it. Fix only leftover obfuscated names in the per-file modules.
  • Preserve the existing structure. Keep modules in their mirrored directory
    layout. Keep one fix() function per module.

Best Practices

  • ALWAYS Prefer using single line replacements vr() over vrx() where applicable
  • Don't try replacing multiline content => use multiple single vr()
  • Process only one file at a time => It's easier to track problems and resolve them this way
  • No conditional fixes, just use vr().
  • Verify your fix by re-running gregtech_fix_pipeline.py after fix
  • Do NOT try to fix whole file at once. Do 1 to 2 small fixes.

Autonomy Rules

You are in an unattended batch run. No user is watching.

  1. Do NOT ask for clarification, confirmation, or input.
  2. If something is unclear, make a reasonable assumption and proceed.
  3. Fix 100 errors, then stop.
  4. After fixing, run the pipeline once:
    python recreate_sources/gregtech/gregtech_fix_pipeline.py
  5. Write a brief report with this exact format:

REPORT
File fixed: path
Error fixed: what the obfuscated name was and what you changed it to
Pipeline result: success or what error remains
END REPORT

  1. After the report, output ONLY the word DONE on its own line.
    Do NOT make any more tool calls. Do NOT output anything else.
    No more reading, editing, or bash commands. Just DONE and stop.

FAILURE MODE: If you do anything after DONE, the run will be killed.
Fix one file, write the report, say DONE, then stop completely.

Edit

Pub: 12 Aug 2026 21:59 UTC

Views: 19