Skip to content

Commit

Permalink
Showing 4 changed files with 74 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ Also check [The Fugue Plane](https://forgottenrealms.fandom.com/wiki/Fugue_Plane
* Logistics Pipes
* OpenDisks
* OpenSecurity
* Enchantments Control

## Note
Add ! to start of the file name to fix Lag Goggles.
3 changes: 2 additions & 1 deletion src/main/java/com/cleanroommc/FugueLoadingPlugin.java
Original file line number Diff line number Diff line change
@@ -34,7 +34,8 @@ public class FugueLoadingPlugin implements IFMLLoadingPlugin, IEarlyMixinLoader
"com.cleanroommc.transformer.InitializerTransformer",
"com.cleanroommc.transformer.ClassBlockMultipartContainerHandlerTransformer",
"com.cleanroommc.transformer.OpenDisksUnpackTransformer",
"com.cleanroommc.transformer.SoundUnpackTransformer"
"com.cleanroommc.transformer.SoundUnpackTransformer",
"com.cleanroommc.transformer.EnumInputClassTransformer"
);

for(String str : transformers) {
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;
}
}
Original file line number Diff line number Diff line change
@@ -26,8 +26,6 @@ public byte[] transform(String s, String s1, byte[] bytes) {
return bytes;
}

Fugue.LOGGER.info("GOTCHA");

ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
@@ -37,15 +35,13 @@ public byte[] transform(String s, String s1, byte[] bytes) {
for (MethodNode methodNode : classNode.methods)
{
if (methodNode.name.equals("patch")) {
Fugue.LOGGER.info("GOTCHA2");
InsnList instructions = methodNode.instructions;
if (instructions != null)
{
for (AbstractInsnNode insnNode : instructions)
{
if (insnNode.getOpcode() == Opcodes.SIPUSH && insnNode instanceof IntInsnNode intInsnNode)
{
Fugue.LOGGER.info("NODE OPERAND" + intInsnNode.operand);
if (intInsnNode.operand == Opcodes.INVOKESPECIAL)
{
intInsnNode.operand = Opcodes.INVOKEVIRTUAL;
@@ -59,7 +55,6 @@ public byte[] transform(String s, String s1, byte[] bytes) {
}
if (modified)
{
Fugue.LOGGER.info("CHANGED");
Launch.classLoader.unRegisterSuperTransformer(this);
ClassWriter classWriter = new ClassWriter(0);

0 comments on commit 9a8c68d

Please sign in to comment.