Skip to content

Commit 27a07e3

Browse files
committed
Fixed call super
1 parent e8d9c73 commit 27a07e3

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

Diff for: pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
<dependencies>
2525
<dependency>
2626
<groupId>org.spigotmc</groupId>
27-
<artifactId>spigot</artifactId>
28-
<version>1.18.1-R0.1-SNAPSHOT</version>
27+
<artifactId>spigot-api</artifactId>
28+
<version>1.8.8-R0.1-SNAPSHOT</version>
2929
<scope>provided</scope>
3030
</dependency>
3131
<dependency>

Diff for: src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionCallSuper.java

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
package com.dragoncommissions.mixbukkit.api.action.impl;
22

33
import com.dragoncommissions.mixbukkit.api.MixinPlugin;
4-
import com.dragoncommissions.mixbukkit.api.ObfMap;
54
import com.dragoncommissions.mixbukkit.api.action.MixinAction;
5+
import com.dragoncommissions.mixbukkit.api.shellcode.impl.inner.IShellCodeMethodInvoke;
66
import com.dragoncommissions.mixbukkit.utils.ASMUtils;
7-
import javassist.bytecode.Descriptor;
87
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;
128
import org.objectweb.asm.tree.MethodNode;
9+
import org.objectweb.asm.tree.VarInsnNode;
1310

1411
import java.lang.reflect.Method;
12+
import java.lang.reflect.Modifier;
1513

1614
public class MActionCallSuper implements MixinAction {
1715

@@ -49,12 +47,15 @@ public void action(Class<?> owner, MethodNode method) {
4947
throw new IllegalArgumentException("Could not find super method in " + owner.getSimpleName());
5048
}
5149
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());
5859
method.instructions.add(ASMUtils.genReturnNode(superMethod.getReturnType()));
5960

6061
}

0 commit comments

Comments
 (0)