diff --git a/src/main/java/com/falsepattern/lib/internal/asm/FPTransformer.java b/src/main/java/com/falsepattern/lib/internal/asm/FPTransformer.java index df6d138..5251229 100644 --- a/src/main/java/com/falsepattern/lib/internal/asm/FPTransformer.java +++ b/src/main/java/com/falsepattern/lib/internal/asm/FPTransformer.java @@ -30,7 +30,7 @@ import lombok.experimental.Accessors; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import java.util.Collections; +import java.util.Arrays; import java.util.List; @Accessors(fluent = true) @@ -45,6 +45,6 @@ public class FPTransformer implements SmartTransformer { private final Logger logger = LOG; public FPTransformer() { - transformers = Collections.singletonList(new IMixinPluginTransformer()); + transformers = Arrays.asList(new IMixinPluginTransformer(), new ITypeDiscovererTransformer()); } } diff --git a/src/main/java/com/falsepattern/lib/internal/asm/ITypeDiscovererTransformer.java b/src/main/java/com/falsepattern/lib/internal/asm/ITypeDiscovererTransformer.java new file mode 100644 index 0000000..5387153 --- /dev/null +++ b/src/main/java/com/falsepattern/lib/internal/asm/ITypeDiscovererTransformer.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2022 FalsePattern + * All Rights Reserved + * + * The above copyright notice, this permission notice and the word "SNEED" + * shall be included in all copies or substantial portions of the Software. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.falsepattern.lib.internal.asm; + +import com.falsepattern.lib.asm.IClassNodeTransformer; +import lombok.val; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.LdcInsnNode; + +public class ITypeDiscovererTransformer implements IClassNodeTransformer { + @Override + public String getName() { + return "ITypeDiscovererTransformer"; + } + + @Override + public boolean shouldTransform(ClassNode cn, String transformedName, boolean obfuscated) { + return "cpw.mods.fml.common.discovery.ITypeDiscoverer".equals(transformedName); + } + + @Override + public void transform(ClassNode cn, String transformedName, boolean obfuscated) { + for (val method: cn.methods) { + if (!method.name.equals("")) { + continue; + } + val instructions = method.instructions; + for (int i = 0; i < instructions.size(); i++) { + val insn = instructions.get(i); + if (insn instanceof LdcInsnNode) { + val ldc = (LdcInsnNode) insn; + if (ldc.cst.equals("[^\\s\\$]+(\\$[^\\s]+)?\\.class$")) { + ldc.cst = "(?!module-info)[^\\s\\$]+(\\$[^\\s]+)?\\.class$"; + return; + } + } + } + } + } +}