Skip to content

Commit

Permalink
avoid unnecessary class loading in asm
Browse files Browse the repository at this point in the history
  • Loading branch information
FalsePattern committed Jan 31, 2025
1 parent bdcb3f1 commit 8d36e8a
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,10 @@
import mega.fluidlogged.Tags;
import org.jetbrains.annotations.NotNull;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.VarInsnNode;

import net.minecraft.client.renderer.RenderBlocks;

import java.lang.reflect.Method;

/**
* Waterlogging renderer hook
Expand Down Expand Up @@ -109,13 +105,11 @@ public boolean transformClass(@NotNull String className, @NotNull ClassNodeHandl
iter.add(new VarInsnNode(Opcodes.ILOAD, 21));
iter.add(new VarInsnNode(Opcodes.ILOAD, 22));
iter.add(new VarInsnNode(Opcodes.ILOAD, 17));
Method target;
try {
target = ASMHooks.class.getDeclaredMethod("drawFluidLogged", RenderBlocks.class, int.class, int.class, int.class, int.class);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
iter.add(new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(target.getDeclaringClass()), target.getName(), Type.getMethodDescriptor(target), false));
iter.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
Tags.ROOT_PKG.replace('.', '/') + "/internal/core/ASMHooks",
"drawFluidLogged",
"(Lnet/minecraft/client/renderer/RenderBlocks;IIII)I",
false));
iter.add(new InsnNode(Opcodes.DUP));
iter.add(new InsnNode(Opcodes.ICONST_1));
iter.add(new InsnNode(Opcodes.IAND));
Expand Down

0 comments on commit 8d36e8a

Please sign in to comment.