generated from kappa-maintainer/1.12.2-FG6-Template
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa80688
commit d9a615e
Showing
4 changed files
with
82 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/main/java/com/cleanroommc/transformer/CommonRegistrar$Transformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.cleanroommc.transformer; | ||
|
||
import net.minecraft.launchwrapper.IClassTransformer; | ||
import org.objectweb.asm.ClassReader; | ||
import org.objectweb.asm.ClassWriter; | ||
import org.objectweb.asm.Opcodes; | ||
import org.objectweb.asm.tree.AbstractInsnNode; | ||
import org.objectweb.asm.tree.ClassNode; | ||
import org.objectweb.asm.tree.FieldNode; | ||
import org.objectweb.asm.tree.InsnList; | ||
import org.objectweb.asm.tree.MethodInsnNode; | ||
import org.objectweb.asm.tree.MethodNode; | ||
|
||
public class CommonRegistrar$Transformer implements IClassTransformer { | ||
private static boolean hit = false; | ||
@Override | ||
public byte[] transform(String s, String s1, byte[] bytes) { | ||
if (bytes == null) | ||
{ | ||
return null; | ||
} | ||
|
||
if (hit || !s1.equals("com.lumintorious.tfcmedicinal.CommonRegistrar$")) | ||
{ | ||
return bytes; | ||
} | ||
|
||
|
||
ClassNode classNode = new ClassNode(); | ||
ClassReader classReader = new ClassReader(bytes); | ||
classReader.accept(classNode, 0); | ||
boolean modified = false; | ||
classNode.version = Opcodes.V21; | ||
if (classNode.fields != null) | ||
{ | ||
for (FieldNode fieldNode : classNode.fields) | ||
{ | ||
if (fieldNode.name.equals("MODULE$")) | ||
{ | ||
fieldNode.access -= Opcodes.ACC_FINAL; | ||
} | ||
} | ||
} | ||
if (classNode.methods != null) | ||
{ | ||
for (MethodNode methodNode : classNode.methods) | ||
{ | ||
if (methodNode.name.equals("registerBarrelRecipes")) { | ||
InsnList instructions = methodNode.instructions; | ||
if (instructions != null) | ||
{ | ||
for (AbstractInsnNode insnNode : instructions) | ||
{ | ||
if (insnNode.getOpcode() == Opcodes.INVOKESTATIC && insnNode instanceof MethodInsnNode methodInsnNode) | ||
{ | ||
if (methodInsnNode.owner.equals("net/dries007/tfc/objects/inventory/ingredient/IIngredient") && methodInsnNode.name.equals("of")) | ||
{ | ||
methodInsnNode.itf = true; | ||
modified = true; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
if (modified) | ||
{ | ||
hit = true; | ||
ClassWriter classWriter = new ClassWriter(0); | ||
|
||
classNode.accept(classWriter); | ||
return classWriter.toByteArray(); | ||
} | ||
return bytes; | ||
} | ||
} |