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.
- 0.18.0
- 0.17.7
- 0.17.6
- 0.17.5
- 0.17.4
- 0.17.3
- 0.17.2
- 0.17.1
- 0.17.0
- 0.16.4
- 0.16.3
- 0.16.2
- 0.16.1
- 0.16.0
- 0.15.9
- 0.15.8
- 0.15.7
- 0.15.6
- 0.15.5
- 0.15.4
- 0.15.3
- 0.15.2
- 0.15.1-alpha
- 0.15.0-alpha
- 0.14.12
- 0.14.11
- 0.14.10
- 0.14.9
- 0.14.8
- 0.14.7
- 0.14.6
- 0.14.5
- 0.14.4
- 0.14.3
- 0.14.2
- 0.14.1
- 0.14.0
- 0.13.0
- 0.12.4
- 0.12.3
- 0.12.2
- 0.12.1
- 0.12.0
- 0.11.0
- 0.10.6
- 0.10.5
- 0.10.4
- 0.10.3
- 0.10.2
- 0.10.1
- 0.10.0
- 0.9.6
- 0.9.5
- 0.9.4
- 0.9.0
- 0.5.4
- 0.5.2
- 0.5.1
- 0.5.0
1 parent
960d94e
commit 9a8c68d
Showing
4 changed files
with
74 additions
and
6 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
71 changes: 71 additions & 0 deletions
71
src/main/java/com/cleanroommc/transformer/EnumInputClassTransformer.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,71 @@ | ||
package com.cleanroommc.transformer; | ||
|
||
import com.cleanroommc.FugueLoadingPlugin; | ||
import net.minecraft.launchwrapper.IClassTransformer; | ||
import net.minecraft.launchwrapper.Launch; | ||
import org.objectweb.asm.ClassReader; | ||
import org.objectweb.asm.ClassWriter; | ||
import org.objectweb.asm.Opcodes; | ||
import org.objectweb.asm.tree.*; | ||
|
||
public class EnumInputClassTransformer implements IClassTransformer { | ||
public EnumInputClassTransformer() { | ||
FugueLoadingPlugin.registerToKnownTransformer("enchcontrol", this); | ||
} | ||
@Override | ||
public byte[] transform(String s, String s1, byte[] bytes) { | ||
if (bytes == null) | ||
{ | ||
return null; | ||
} | ||
|
||
if (!s1.equals("austeretony.enchcontrol.common.core.EnumInputClass")) | ||
{ | ||
return bytes; | ||
} | ||
|
||
ClassNode classNode = new ClassNode(); | ||
ClassReader classReader = new ClassReader(bytes); | ||
classReader.accept(classNode, 0); | ||
boolean firstPatched = false; | ||
boolean modified = false; | ||
if (classNode.methods != null) | ||
{ | ||
for (MethodNode methodNode : classNode.methods) | ||
{ | ||
if (methodNode.name.equals("pathcMCLocale")) { | ||
InsnList instructions = methodNode.instructions; | ||
if (instructions != null) | ||
{ | ||
for (AbstractInsnNode insnNode : instructions) | ||
{ | ||
if (insnNode.getOpcode() == Opcodes.SIPUSH && insnNode instanceof IntInsnNode intInsnNode) | ||
{ | ||
if (intInsnNode.operand == Opcodes.INVOKESPECIAL) | ||
{ | ||
intInsnNode.operand = Opcodes.INVOKEVIRTUAL; | ||
firstPatched = true; | ||
} | ||
} | ||
if (firstPatched && insnNode.getOpcode() == Opcodes.ICONST_3 && insnNode instanceof InsnNode insnNode1) | ||
{ | ||
instructions.insert(insnNode1, new InsnNode(Opcodes.ICONST_2)); | ||
instructions.remove(insnNode1); | ||
modified = true; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
if (modified) | ||
{ | ||
Launch.classLoader.unRegisterSuperTransformer(this); | ||
ClassWriter classWriter = new ClassWriter(0); | ||
|
||
classNode.accept(classWriter); | ||
return classWriter.toByteArray(); | ||
} | ||
return bytes; | ||
} | ||
} |
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