Skip to content

Commit

Permalink
Add patch to zerocore
Browse files Browse the repository at this point in the history
  • Loading branch information
kappa-maintainer committed Mar 19, 2024
1 parent 1eb3a7b commit e214659
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/main/java/com/cleanroommc/fugue/FugueLoadingPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ public class FugueLoadingPlugin implements IFMLLoadingPlugin, IEarlyMixinLoader
new LoliFMLCallHookTransformer()
);
}
if (FugueConfig.enableZeroCore) {
TransformerDelegate.registerExplicitTransformerByInstance(
new String[]{
"it.zerono.mods.zerocore.lib.client.render.DisplayList"
},
new DisplayListTransformer()
);
}
if (FugueConfig.reflectionPatchTargets.length > 0) {
TransformerDelegate.registerExplicitTransformerByInstance(FugueConfig.reflectionPatchTargets, new ReflectFieldTransformer());
}
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/com/cleanroommc/fugue/config/FugueConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public class FugueConfig {
public static boolean enableTheASM = true;
@Config.Name("Enable mcjtylib Patch")
public static boolean enableMcjty = true;
@Config.Name("Enable ZeroCore (used by ExtremeReactor) Patch")
public static boolean enableZeroCore = true;

@Config.Comment("""
About *static final field has no write access*
Expand Down Expand Up @@ -132,19 +134,22 @@ public class FugueConfig {
"""
Javax (Java EE) redirect targets.
They are gone in newer Java, so we are redirecting them to a replacement.""")
@Config.Name("Javax Patch Target List")
public static String[] remapTargets = new String[] {
"com.ldtteam.structurize.util.StructureUtils",
"git.jbredwards.fluidlogged_api.api.asm.IASMPlugin",
"net.silentchaos512.scalinghealth.proxy.ScalingHealthCommonProxy",
"appeng.me.GridStorage",
"net.creeperhost.minetogether.misc.Callbacks",
};

@Config.Comment(
"""
Non-Update was gone with Security Manager.
As a workaround, These targets will be banned from making connections with URL.openStream().
If you don't need a proxy to access github, you could empty this setting.
If you don't need a proxy to access github, you could empty this setting.
This may block more connection than update checks, so if anything gone wrong please open an issue.""")
@Config.Name("Connection Blocking List")
public static String[] nonUpdateTargets = new String[] {
"xxrexraptorxx.customizeddungeonloot.util.UpdateChecker$1",
"com.nekokittygames.mffs.common.Versioninfo",
Expand All @@ -159,6 +164,7 @@ public class FugueConfig {
Foundation comes with some ABI changes.
If you got a crash says some methods/fields in LaunchClassLoader not found, that's the remapper you want.
As a workaround, These targets will be redirected to new API.""")
@Config.Name("Launch Wrapper API Change Patching List")
public static String[] remapLWTargets = new String[] {
"zone.rong.loliasm.common.crashes.ModIdentifier",
"zone.rong.loliasm.LoliReflector",
Expand All @@ -172,6 +178,7 @@ public class FugueConfig {
"""
sun.reflect.Reflection has moved to jdk.internal, and most of its features have replacements.
As a workaround, These targets will be redirected to new dummy class.""")
@Config.Name("sun.misc.Reflection Patching List")
public static String[] remapReflectionTargets = new String[] {
"quaternary.botaniatweaks.modules.botania.config.BotaniaConfig",
"quaternary.botaniatweaks.modules.shared.lib.GeneratingFlowers$FlowerData",
Expand All @@ -185,6 +192,7 @@ public class FugueConfig {
Target field's final modifier will be removed. No checks will be preformed before removal.
All fields with same name will be targeted.
Format: S:"foo.bar.classname"=field1|filed2""")
@Config.Name("Final Fields Patching List")
public static Map<String, String> finalRemovingTargets = Stream.of(new String[][] {
//VintageFix
{"net.minecraftforge.event.terraingen.BiomeEvent$BiomeColor", "originalColor"},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.cleanroommc.fugue.transformer;

import com.cleanroommc.fugue.Fugue;
import javassist.ClassPool;
import javassist.CtClass;
import top.outlands.foundation.IExplicitTransformer;

import java.io.ByteArrayInputStream;

public class DisplayListTransformer implements IExplicitTransformer {
@Override
public byte[] transform(byte[] bytes) {
try {
CtClass cc = ClassPool.getDefault().makeClass(new ByteArrayInputStream(bytes));
cc.getDeclaredMethod("finalize").setBody("{}");
bytes = cc.toBytecode();
} catch (Throwable t) {
Fugue.LOGGER.error(t);
}
return bytes;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.cleanroommc.fugue.transformer;

import com.cleanroommc.fugue.Fugue;
import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.expr.ExprEditor;
import javassist.expr.NewArray;
import top.outlands.foundation.IExplicitTransformer;
import top.outlands.foundation.boot.Foundation;

import java.io.ByteArrayInputStream;

public class LiteLoaderCoreAPIClientTransformer implements IExplicitTransformer {
@Override
public byte[] transform(byte[] bytes) {
try {
CtClass cc = ClassPool.getDefault().makeClass(new ByteArrayInputStream(bytes));
cc.getClassInitializer().instrument(new ExprEditor(){
@Override
public void edit(NewArray a) throws CannotCompileException {
Foundation.LOGGER.info(a.getLineNumber());
if (a.getLineNumber() == 48) {
a.where().setBody(
"""
{
requiredTransformers = new String[] { "com.mumfrey.liteloader.transformers.event.EventProxyTransformer", "com.mumfrey.liteloader.launch.LiteLoaderTransformer", "com.mumfrey.liteloader.client.transformers.CrashReportTransformer" };
requiredDownstreamTransformers = new String[] { "com.mumfrey.liteloader.common.transformers.LiteLoaderPacketTransformer", "com.mumfrey.liteloader.transformers.event.json.ModEventInjectionTransformer" };
clientMixinConfigs = new String[] { "mixins.liteloader.client.json", "mixins.liteloader.client.optional.json" };
}
""");
}
}
});
bytes = cc.toBytecode();
} catch (Throwable t) {
Fugue.LOGGER.error(t);
}
return bytes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class RemapLegacyLWTransformer implements IExplicitTransformer {
@Override
public byte[] transform(byte[] bytes) {
ClassReader reader = new ClassReader(bytes);
Fugue.LOGGER.info(reader.getClassName());
ClassNode classNode = new ClassNode();
reader.accept(classNode, 0);
classNode.methods.forEach(methodNode -> methodNode.instructions.forEach(abstractInsnNode -> {
Expand Down

0 comments on commit e214659

Please sign in to comment.