Skip to content

Commit

Permalink
Patch better fc
Browse files Browse the repository at this point in the history
  • Loading branch information
kappa-maintainer committed Jun 21, 2024
1 parent 07c23b0 commit 659915f
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ If you are still using 0.1.0 Cleanroom, use 0.5.4. But that's not recommended.
* MAGE (Graphical Tweaks)
* Extra Utilities 2
* In Control!
* More Refined Storage
* Better Formatting Code

## Note
Add + to start of the file if it's not there.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mappings_version=39-1.12
mod_id=fugue
mod_name=Fugue
mod_main_class=Fugue
mod_version=0.15.5
mod_version=0.15.6
mod_base_package=com.cleanroommc.fugue
mod_authors=kappa_maintainer
mod_description=A mod that patch dead mods for Cleanroom
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ public class FugueLoadingPlugin implements IFMLLoadingPlugin {
if (FugueConfig.modPatchConfig.enableExtraUtilities) {
TransformerDelegate.registerExplicitTransformerByInstance(new FieldSetterTransformer(), "com.rwtema.extrautils2.utils.datastructures.FieldSetter");
}
if (FugueConfig.modPatchConfig.enableBetterFC) {
TransformerDelegate.registerExplicitTransformerByInstance(new HK_LoaderTransformer(), "kpan.better_fc.asm.hook.HK_Loader");
}

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 @@ -54,6 +54,7 @@ public class FugueConfig {
"com.noobanidus.variegated.compat.bloodmagic.handlers.HellfireSpeed",
"ic2.core.util.ReflectionUtil",
"net.arsenalnetwork.betterhud.h",
"com.github.alexthe666.iceandfire.entity.EntitySnowVillager",
};

@Config.Comment(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,6 @@ public class ModPatchConfig {
public boolean enableMoreRefinedStorage = true;
@Config.Name("Enable HEI Patch (temporary)")
public boolean enableHEI = true;
@Config.Name("Enable Better Formatting Code Patch")
public boolean enableBetterFC = true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.cleanroommc.fugue.transformer;

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 top.outlands.foundation.TransformerDelegate;

import java.io.ByteArrayInputStream;

public class HK_LoaderTransformer implements IExplicitTransformer {

@Override
public byte[] transform(byte[] bytes) {
try {
CtClass cc = ClassPool.getDefault().makeClass(new ByteArrayInputStream(bytes));
cc.getDeclaredMethod("onConstructed").instrument(new ExprEditor() {
public void edit(MethodCall m) throws CannotCompileException {
if (m.getMethodName().equals("getPrivateField") && m.getLineNumber() == 16) {
m.replace("$_ = top.outlands.foundation.TransformerDelegate#getTransformers();");
}
}
});
bytes = cc.toBytecode();
} catch (Throwable t) {
Fugue.LOGGER.error(t);
}
return bytes;
}
}

0 comments on commit 659915f

Please sign in to comment.