Skip to content

Commit

Permalink
Patch Thaumic Fixes (Moved from MixinFixer)
Browse files Browse the repository at this point in the history
  • Loading branch information
kappa-maintainer committed Nov 18, 2024
1 parent b7ee598 commit 49322fb
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ If you are still using 0.1.0 Cleanroom, use 0.5.4. But that's not recommended.
* Aqua Acrobatics
* Refined Relocation 2
* Integrated Proxy
* Thaumic Fixes

## Note
Add + to start of the file if it's not there.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public List<String> getMixinConfigs() {
if (FugueConfig.modPatchConfig.enableIntegratedProxyPatch && Loader.isModLoaded("integrated_proxy")) {
configs.add("mixins.integrated_proxy.mod.json");
}
if (FugueConfig.modPatchConfig.enableThaumicFixesPatch && Loader.isModLoaded("thaumicfixes")) {
configs.add("mixins.thaumicfixes.modsupport.json");
}
return configs;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.cleanroommc.fugue.transformer.openmodlib.InjectorMethodVisitorTransformer;
import com.cleanroommc.fugue.transformer.openmodlib.PlayerRendererHookVisitorTransformer;
import com.cleanroommc.fugue.transformer.subaquatic.PluginEntityTransformer;
import com.cleanroommc.fugue.transformer.thaumicfixes.ThaumicFixesLoadingPluginTransformer;
import com.cleanroommc.fugue.transformer.tickcentral.*;
import com.cleanroommc.fugue.transformer.universal.*;
import org.spongepowered.asm.mixin.transformer.Config;
Expand Down Expand Up @@ -172,6 +173,10 @@ public static void registerTransformers() {
if (FugueConfig.modPatchConfig.enableIntegratedProxyPatch) {
TransformerDelegate.registerExplicitTransformerByInstance(new MixinLoaderTransformer(), "com.shblock.integrated_proxy.mixin.MixinLoader");
}
if (FugueConfig.modPatchConfig.enableThaumicFixesPatch) {
TransformerDelegate.registerExplicitTransformerByInstance(new ThaumicFixesLoadingPluginTransformer(), "com.seriouscreeper.thaumicfixes.core.ThaumicFixesLoadingPlugin");
}

if (FugueConfig.getCodeSourcePatchTargets.length > 0) {
TransformerDelegate.registerExplicitTransformerByInstance(new ITweakerTransformer(), FugueConfig.getCodeSourcePatchTargets);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,6 @@ public class ModPatchConfig {
public boolean enableRefinedRelocation2Patch = true;
@Config.Name("Enable Integrated Proxy Patch")
public boolean enableIntegratedProxyPatch = true;
@Config.Name("Enable Thaumic Fixes Patch")
public boolean enableThaumicFixesPatch = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public byte[] transform(byte[] bytes) {
cc.getConstructors()[0].instrument(new ExprEditor(){
@Override
public void edit(MethodCall m) throws CannotCompileException {
Fugue.LOGGER.info("{} {}", m.getMethodName() , m.getLineNumber());
if (m.getMethodName().equals("addConfiguration") && m.getLineNumber() == 21) {
m.where().setBody("{}");
} else if (m.getMethodName().equals("init")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.cleanroommc.fugue.transformer.thaumicfixes;

import com.cleanroommc.fugue.common.Fugue;
import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.expr.ExprEditor;
import javassist.expr.MethodCall;
import top.outlands.foundation.IExplicitTransformer;

import java.io.ByteArrayInputStream;

public class ThaumicFixesLoadingPluginTransformer implements IExplicitTransformer {
@Override
public byte[] transform(byte[] bytes) {
try {
CtClass cc = ClassPool.getDefault().makeClass(new ByteArrayInputStream(bytes));
cc.getConstructors()[0].instrument(new ExprEditor(){
@Override
public void edit(MethodCall m) throws CannotCompileException {
if (m.getMethodName().equals("addConfiguration") && m.getMethodName().equals("init")) {
m.where().setBody("{}");
}
}
});
bytes = cc.toBytecode();
cc.defrost();
} catch (Throwable t) {
Fugue.LOGGER.error("Exception {} on {}", t, this.getClass().getSimpleName());
}
return bytes;
}
}

0 comments on commit 49322fb

Please sign in to comment.