From bc7554a86b3e0abe22fe057896c689e69a294581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9D=8F=E9=BB=91?= Date: Sun, 23 Sep 2018 09:28:58 +0800 Subject: [PATCH] Delete SimpleAISelector.java --- .../common/pathfinder/SimpleAISelector.java | 88 ------------------- 1 file changed, 88 deletions(-) delete mode 100644 src/main/java/me/skymc/taboolib/common/pathfinder/SimpleAISelector.java diff --git a/src/main/java/me/skymc/taboolib/common/pathfinder/SimpleAISelector.java b/src/main/java/me/skymc/taboolib/common/pathfinder/SimpleAISelector.java deleted file mode 100644 index 655162c..0000000 --- a/src/main/java/me/skymc/taboolib/common/pathfinder/SimpleAISelector.java +++ /dev/null @@ -1,88 +0,0 @@ -package me.skymc.taboolib.common.pathfinder; - -import com.ilummc.tlib.util.asm.AsmClassLoader; -import me.skymc.taboolib.TabooLib; -import me.skymc.taboolib.common.pathfinder.internal.ParentPathfinderGoalAsm; -import me.skymc.taboolib.nms.NMSUtils; -import me.skymc.taboolib.object.Instantiable; -import org.bukkit.entity.LivingEntity; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -/** - * @Author sky - * @Since 2018-09-19 20:31 - */ -@Instantiable("SimpleAISelector") -public class SimpleAISelector { - - private static Class parentPathfinderGoal; - private static Class pathfinderGoalFollowOwner; - private static Class pathfinderGoalSelector; - private static Class pathfinderGoal; - private static Class entityInsentient; - private static Field targetSelector; - private static Field goalSelector; - private static Field navigation; - private static Method a; - - public SimpleAISelector() { - try { - parentPathfinderGoal = AsmClassLoader.createNewClass("me.skymc.taboolib.common.pathfinder.internal.ParentPathfinderGoal", ParentPathfinderGoalAsm.create(TabooLib.getVersion())); - pathfinderGoalFollowOwner = NMSUtils.getNMSClass("PathfinderGoalFollowOwner"); - pathfinderGoalSelector = NMSUtils.getNMSClass("PathfinderGoalSelector"); - pathfinderGoal = NMSUtils.getNMSClass("PathfinderGoal"); - entityInsentient = NMSUtils.getNMSClass("EntityInsentient"); - targetSelector = entityInsentient.getField("targetSelector"); - goalSelector = entityInsentient.getField("goalSelector"); - navigation = entityInsentient.getField("navigation"); - a = pathfinderGoalSelector.getDeclaredMethod("a", Integer.TYPE, pathfinderGoal); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public static Object getNavigation(LivingEntity entity) { - try { - return navigation.get(entity.getClass().getMethod("getHandle").invoke(entity)); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - public static Object getGoalSelector(LivingEntity entity) { - try { - return goalSelector.get(entity.getClass().getMethod("getHandle").invoke(entity)); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - public static Object getTargetSelector(LivingEntity entity) { - try { - return targetSelector.get(entity.getClass().getMethod("getHandle").invoke(entity)); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - public static void setGoalAI(LivingEntity entity, Object ai, int priority) { - try { - a.invoke(getGoalSelector(entity), priority, ai); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public static void setTargetAI(LivingEntity entity, Object ai, int priority) { - try { - a.invoke(getTargetSelector(entity), priority, ai); - } catch (Exception e) { - e.printStackTrace(); - } - } -}