Skip to content

Commit

Permalink
Fix optifine and minieffect
Browse files Browse the repository at this point in the history
  • Loading branch information
kappa-maintainer committed Mar 29, 2024
1 parent bd451ac commit e6a8180
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
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.12.1-beta
mod_version=0.12.2-beta
mod_base_package=com.cleanroommc.fugue
mod_authors=kappa_maintainer
mod_description=A mod that patch dead mods for Cleanroom
2 changes: 2 additions & 0 deletions src/main/java/com/cleanroommc/fugue/config/FugueConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ Add them to list could redirect their toURI() to a decent jar URL.
"pcl.opendisks.OpenDisksUnpack",
"pcl.opensecurity.util.SoundUnpack",
"pcl.OpenFM.misc.DepLoader",
"optifine.OptiFineClassTransformer",
"snownee.minieffects.core.CoreMod"
};

@Config.Comment(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.cleanroommc.fugue.transformer.universal;

import com.cleanroommc.fugue.Fugue;
import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;
import javassist.*;
import javassist.expr.ExprEditor;
import javassist.expr.MethodCall;
import top.outlands.foundation.IExplicitTransformer;
Expand All @@ -16,21 +13,20 @@ public class ITweakerTransformer implements IExplicitTransformer {
public byte[] transform(byte[] bytes) {
try {
CtClass cc = ClassPool.getDefault().makeClass(new ByteArrayInputStream(bytes));
for (CtMethod ctMethod : cc.getDeclaredMethods()) {
ctMethod.instrument(new ExprEditor() {
@Override
public void edit(MethodCall m) throws CannotCompileException {
if (m.getMethodName().equals("toURI")) {
m.replace(
"""
{
$_ = com.cleanroommc.fugue.helper.HookHelper#toURI($0);
}
""");
}
ExprEditor editor = new ExprEditor() {
@Override
public void edit(MethodCall m) throws CannotCompileException {
if (m.getMethodName().equals("toURI")) {
m.replace(
"""
{
$_ = com.cleanroommc.fugue.helper.HookHelper#toURI($0);
}
""");
}
});
}
}
};
cc.instrument(editor);
bytes = cc.toBytecode();
} catch (Throwable t) {
Fugue.LOGGER.error(t);
Expand Down

0 comments on commit e6a8180

Please sign in to comment.