use of net.minecraft.server.v1_14_R1.PathfinderGoalSelector in project Citizens2 by CitizensDev.
the class NMSImpl method clearGoals.
public static void clearGoals(NPC npc, PathfinderGoalSelector... goalSelectors) {
if (GOAL_SET_FIELD == null || goalSelectors == null)
return;
int i = 0;
for (PathfinderGoalSelector selector : goalSelectors) {
try {
Collection<?> list = (Collection<?>) GOAL_SET_FIELD.invoke(selector);
if (!list.isEmpty()) {
npc.data().set("selector" + i, Lists.newArrayList(list));
}
list.clear();
} catch (Exception e) {
Messaging.logTr(Messages.ERROR_CLEARING_GOALS, e.getLocalizedMessage());
} catch (Throwable e) {
Messaging.logTr(Messages.ERROR_CLEARING_GOALS, e.getLocalizedMessage());
}
i++;
}
}
use of net.minecraft.server.v1_14_R1.PathfinderGoalSelector in project Citizens2 by CitizensDev.
the class NMSImpl method clearGoals.
public static void clearGoals(NPC npc, PathfinderGoalSelector... goalSelectors) {
if (GOAL_SET_FIELD == null || goalSelectors == null)
return;
int i = 0;
for (PathfinderGoalSelector selector : goalSelectors) {
try {
Collection<?> list = (Collection<?>) GOAL_SET_FIELD.invoke(selector);
if (!list.isEmpty()) {
npc.data().set("selector" + i, Lists.newArrayList(list));
}
list.clear();
} catch (Exception e) {
Messaging.logTr(Messages.ERROR_CLEARING_GOALS, e.getLocalizedMessage());
} catch (Throwable e) {
Messaging.logTr(Messages.ERROR_CLEARING_GOALS, e.getLocalizedMessage());
}
i++;
}
}
use of net.minecraft.server.v1_14_R1.PathfinderGoalSelector in project Citizens2 by CitizensDev.
the class NMSImpl method restoreGoals.
public static void restoreGoals(NPC npc, PathfinderGoalSelector... goalSelectors) {
if (GOAL_SET_FIELD == null || goalSelectors == null)
return;
int i = 0;
for (PathfinderGoalSelector selector : goalSelectors) {
try {
Collection<Object> list = (Collection<Object>) GOAL_SET_FIELD.invoke(selector);
list.clear();
Collection<Object> old = npc.data().get("selector" + i);
if (old != null) {
list.addAll(old);
}
} catch (Exception e) {
Messaging.logTr(Messages.ERROR_RESTORING_GOALS, e.getLocalizedMessage());
} catch (Throwable e) {
Messaging.logTr(Messages.ERROR_RESTORING_GOALS, e.getLocalizedMessage());
}
i++;
}
}
use of net.minecraft.server.v1_14_R1.PathfinderGoalSelector in project Citizens2 by CitizensDev.
the class NMSImpl method clearGoals.
public static void clearGoals(PathfinderGoalSelector... goalSelectors) {
if (GOAL_FIELD == null || goalSelectors == null)
return;
for (PathfinderGoalSelector selector : goalSelectors) {
try {
Collection<?> list = (Collection<?>) GOAL_FIELD.get(selector);
list.clear();
} catch (Exception e) {
Messaging.logTr(Messages.ERROR_CLEARING_GOALS, e.getLocalizedMessage());
}
}
}
use of net.minecraft.server.v1_14_R1.PathfinderGoalSelector in project UltraCosmetics by iSach.
the class MountCustomEntity method removeAI.
private void removeAI(EntityInsentient entity) {
try {
Field bField = PathfinderGoalSelector.class.getDeclaredField("b");
bField.setAccessible(true);
Field cField = PathfinderGoalSelector.class.getDeclaredField("c");
cField.setAccessible(true);
bField.set(entity.goalSelector, new UnsafeList<PathfinderGoalSelector>());
bField.set(entity.targetSelector, new UnsafeList<PathfinderGoalSelector>());
cField.set(entity.goalSelector, new UnsafeList<PathfinderGoalSelector>());
cField.set(entity.targetSelector, new UnsafeList<PathfinderGoalSelector>());
} catch (ReflectiveOperationException exc) {
exc.printStackTrace();
}
}
Aggregations