Skip to content

Commit

Permalink
Only dump relevant classes when enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
LunNova committed Jun 22, 2016
1 parent ae7e834 commit 3ac9396
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/main/java/me/nallar/modpatcher/LaunchClassLoaderUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public static void addTransformer(IClassTransformer transformer) {
PatcherLog.warn("Didn't find deobfuscation transformer " + LaunchClassLoaderUtil.DEOBF_TRANSFORMER_NAME + " in transformers list.\n" +
"Did you forget to set the SortingIndex for your coremod >= 1001? This message is expected in a deobf environment.");
transformers.add(transformer);
}

public static void dumpTransformersIfEnabled() {
if (System.getProperty(DUMP_TRANSFORMERS_PROPERTY_NAME) != null)
PatcherLog.info("Transformers: " + transformers.toString(), new Throwable());
}
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/me/nallar/modpatcher/ModPatcherTransformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public static void initialiseClassLoader(LaunchClassLoader classLoader) {

LaunchClassLoaderUtil.instance = classLoader;
LaunchClassLoaderUtil.addTransformer(ModPatcherTransformer.getInstance());
LaunchClassLoaderUtil.dumpTransformersIfEnabled();
LaunchClassLoaderUtil.removeRedundantExclusions();
}

Expand All @@ -131,7 +132,7 @@ private static class ClassTransformer implements IClassTransformer {
private boolean init;

private static void dumpIfEnabled(String name, byte[] data) {
if (!DUMP)
if (!DUMP || !name.contains("net.minecraft"))
return;

Path path = Paths.get("./DUMP/" + name + ".class");
Expand All @@ -150,11 +151,12 @@ public byte[] transform(String name, String transformedName, byte[] bytes) {
patcher.logDebugInfo();
}

dumpIfEnabled(name + "_unpatched", bytes);
dumpIfEnabled(transformedName + "_unpatched", bytes);

byte[] transformed = transformationHook(transformedName, bytes);

dumpIfEnabled(name, transformed);
if (bytes != transformed)
dumpIfEnabled(transformedName, transformed);

return transformed;
}
Expand Down

0 comments on commit 3ac9396

Please sign in to comment.