Skip to content

Commit

Permalink
fix animation field
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethan-Vann committed Sep 27, 2023
1 parent 2219c90 commit bd5a2f9
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/main/java/com/example/EthanApiPlugin/EthanApiPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import javax.swing.*;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
Expand All @@ -45,6 +46,7 @@ public class EthanApiPlugin extends Plugin {
static PluginManager pluginManager = RuneLite.getInjector().getInstance(PluginManager.class);
static ItemManager itemManager = RuneLite.getInjector().getInstance(ItemManager.class);
static Method doAction = null;
static String animationField = null;
public static final int[][] directionsMap = {
{-2, 0},
{0, 2},
Expand Down Expand Up @@ -151,7 +153,40 @@ public static boolean isQuickPrayerEnabled() {

@SneakyThrows
public static int getAnimation(NPC npc) {
Field animation = npc.getClass().getSuperclass().getDeclaredField("cd");
if (npc == null) {
return -1;
}
if (animationField == null) {
for (Field declaredField : npc.getClass().getSuperclass().getDeclaredFields()) {
if (declaredField == null) {
continue;
}
declaredField.setAccessible(true);
if (declaredField.getType() != int.class) {
continue;
}
if (Modifier.isFinal(declaredField.getModifiers())) {
continue;
}
if (Modifier.isStatic(declaredField.getModifiers())) {
continue;
}
int value = declaredField.getInt(npc);
declaredField.setInt(npc, 4795789);
if (npc.getAnimation() == 1375718357 * 4795789) {
animationField = declaredField.getName();
declaredField.setInt(npc, value);
declaredField.setAccessible(false);
break;
}
declaredField.setInt(npc, value);
declaredField.setAccessible(false);
}
}
if (animationField == null) {
return -1;
}
Field animation = npc.getClass().getSuperclass().getDeclaredField(animationField);
animation.setAccessible(true);
int anim = animation.getInt(npc) * 1375718357;
animation.setAccessible(false);
Expand Down

0 comments on commit bd5a2f9

Please sign in to comment.