This repository contains the results of a freelance project to decompile, debug, and patch a closed-source Minecraft Forge mod (Vic's Modern Warfare for version 1.7.10).
The goal of this project was to resolve several critical client and server crashes, restore missing textures, and successfully recompile and reobfuscate the patched classes back into the production mod jar without access to the original source code.
Minecraft mods in production are obfuscated (using SRG/Searge mappings) to match the obfuscated Minecraft runtime. Decompiling a 24MB mod jar yields thousands of Java classes, many of which contain minor decompiler-induced errors (like invalid casts, raw type mismatches, and synthetic methods) that would prevent a full project compilation.
To solve this efficiently, the following approach was taken:
- Decompilation: Extracted all source code and assets using the CFR decompiler.
- Selective Fixes: Set up a Forge 1.7.10 Gradle workspace to modify only the classes causing crashes.
- Classpath Compiling: Compiled only the modified files by including the original mod jar (
vicsmw.jar) in the compilation classpath to resolve unchanged class dependencies. - Reobfuscation: Used
SpecialSourcewith MCP-to-SRG mappings to reobfuscate the newly compiled classes so they are compatible with the production Forge runtime. - Hot-Patching: Injected the reobfuscated classes and new textures directly back into the original jar.
- File: WorldGeneratorEventHandler.java
- Issue: The mod crashed on world generation in production due to referencing the deobfuscated MCP field name
world.provider.dimensionId. - Fix: Replaced it with the obfuscated Searge field name
world.field_73011_w.field_76574_gto ensure proper runtime field lookup.
- Files: PropsTab.java and SpartanTab.java
- Issue: Opening or rendering the mod's creative tabs crashed the game because the deobfuscated method
getTabIconItem()was not resolved at runtime. - Fix: Overrode the obfuscated Forge method
func_78016_d()directly to ensure the creative tab icons render correctly.
- File: TileEntities.java
- Issue: Decorative props (such as Server Racks, Flood Lights, Radios, and Cameras) failed to render or caused crashes due to unresolved/missing texture paths.
- Fix: Corrected the texture resource path assignments (e.g. changing
"radio"to"textures/models/radio.png") and restored all missing asset files under/workspace/src/main/resources/assets/mw/textures/models/.
VicsMW_Fix/
├── 📂 input/
│ └── vicsmw.jar # Original, compiled production jar
├── 📂 decompiled/
│ └── 📂 com/ # Raw decompiled Java source code from CFR
├── 📂 workspace/
│ ├── 📂 src/main/java/ # Active development source code containing the fixes
│ ├── 📂 src/main/resources/ # Fixed textures and metadata
│ └── build.gradle # Forge 1.7.10 Gradle build script
├── 📂 libs/
│ ├── forge.jar # Minecraft Forge API library
│ └── minecraft.jar # Minecraft 1.7.10 client library
├── 📂 compiled_classes/ # Output folder for freshly compiled .class files
├── 📂 reobf_classes/ # Reobfuscated .class files ready for injection
├── 📂 output/
│ └── vicsmw_fixed.jar # Final, patched production jar
├── cfr.jar # CFR Java Decompiler (v0.152)
├── SpecialSource-shaded.jar # Remapping tool for reobfuscation
└── mcp_to_srg.srg # MCP to SRG mapping definitions for 1.7.10
Follow these steps to compile changes, reobfuscate the classes, and patch the final mod jar:
Compile only the modified Java files using the original jar as part of the classpath (resolves all unchanged class dependencies):
javac -cp "libs/forge.jar;libs/minecraft.jar;input/vicsmw.jar" -d compiled_classes workspace/src/main/java/com/vicmatskiv/mw/WorldGeneratorEventHandler.java workspace/src/main/java/com/vicmatskiv/mw/PropsTab.java workspace/src/main/java/com/vicmatskiv/mw/SpartanTab.java workspace/src/main/java/com/vicmatskiv/mw/TileEntities.javaPackage the compiled classes into a temporary jar to prepare for reobfuscation:
jar cvf temp_reobf_input.jar -C compiled_classes .Run SpecialSource using the MCP-to-SRG mappings:
java -jar SpecialSource-shaded.jar -i temp_reobf_input.jar -o temp_reobf_output.jar -m mcp_to_srg.srgExtract the reobfuscated classes into the reobf_classes folder:
jar xvf temp_reobf_output.jar -C reobf_classes(Note: Ensure only the successfully remapped class files reside in reobf_classes)
- Copy the original jar to the output folder:
copy input\vicsmw.jar output\vicsmw_fixed.jar
- Inject the reobfuscated
.classfiles into the jar:jar uf output/vicsmw_fixed.jar -C reobf_classes com/vicmatskiv/mw/WorldGeneratorEventHandler.class com/vicmatskiv/mw/PropsTab.class com/vicmatskiv/mw/SpartanTab.class com/vicmatskiv/mw/TileEntities.class
- Inject the restored assets and textures into the jar:
jar uf output/vicsmw_fixed.jar -C workspace/src/main/resources assets
Now, output/vicsmw_fixed.jar is ready to be loaded into Minecraft!