|
1 | 1 | package com.dragoncommissions.mixbukkit.api.action.impl;
|
2 | 2 |
|
3 | 3 | import com.dragoncommissions.mixbukkit.api.MixinPlugin;
|
4 |
| -import com.dragoncommissions.mixbukkit.api.ObfMap; |
5 | 4 | import com.dragoncommissions.mixbukkit.api.action.MixinAction;
|
| 5 | +import com.dragoncommissions.mixbukkit.api.shellcode.impl.inner.IShellCodeMethodInvoke; |
6 | 6 | import com.dragoncommissions.mixbukkit.utils.ASMUtils;
|
7 |
| -import javassist.bytecode.Descriptor; |
8 | 7 | import javassist.bytecode.Opcode;
|
9 |
| -import net.minecraft.world.damagesource.DamageSource; |
10 |
| -import org.objectweb.asm.tree.InsnNode; |
11 |
| -import org.objectweb.asm.tree.MethodInsnNode; |
12 | 8 | import org.objectweb.asm.tree.MethodNode;
|
| 9 | +import org.objectweb.asm.tree.VarInsnNode; |
13 | 10 |
|
14 | 11 | import java.lang.reflect.Method;
|
| 12 | +import java.lang.reflect.Modifier; |
15 | 13 |
|
16 | 14 | public class MActionCallSuper implements MixinAction {
|
17 | 15 |
|
@@ -49,12 +47,15 @@ public void action(Class<?> owner, MethodNode method) {
|
49 | 47 | throw new IllegalArgumentException("Could not find super method in " + owner.getSimpleName());
|
50 | 48 | }
|
51 | 49 | method.instructions.clear();
|
52 |
| - method.instructions.add(ASMUtils.loadVar(Object.class, 0)); |
53 |
| - method.instructions.add(ASMUtils.loadVar(DamageSource.class, 1)); |
54 |
| - method.instructions.add(ASMUtils.loadVar(float.class, 2)); |
55 |
| - String descriptor = ASMUtils.getDescriptor(boolean.class, DamageSource.class, float.class); |
56 |
| - String mappingName = plugin.getObfMap().resolveMapping(new ObfMap.MethodMapping(superMethod.getDeclaringClass().getName().replace(".", "/"), descriptor, method.name)); |
57 |
| - method.instructions.add(new MethodInsnNode(Opcode.INVOKESPECIAL, superMethod.getDeclaringClass().getName().replace(".", "/"), mappingName, descriptor)); |
| 50 | + int varNum = 0; |
| 51 | + if (Modifier.isStatic(superMethod.getModifiers())) { |
| 52 | + method.instructions.add(new VarInsnNode(Opcode.ALOAD, varNum++)); |
| 53 | + } |
| 54 | + Class<?>[] parameterTypes = superMethod.getParameterTypes(); |
| 55 | + for (int i = 0; i < parameterTypes.length; i++) { |
| 56 | + method.instructions.add(ASMUtils.loadVar(parameterTypes[i], varNum++)); |
| 57 | + } |
| 58 | + method.instructions.add(new IShellCodeMethodInvoke(superMethod).generate()); |
58 | 59 | method.instructions.add(ASMUtils.genReturnNode(superMethod.getReturnType()));
|
59 | 60 |
|
60 | 61 | }
|
|
0 commit comments