use of net.minecraft.world.entity.ai.goal.target.TargetGoal in project MagicPlugin by elBukkit.
the class MobUtils method removeGoal.
protected boolean removeGoal(GoalSelector selector, Mob mob, Entity entity, GoalType goalType) {
// TODO: Is there a cleaner way?
try {
Goal targetGoal = getGoal(goalType, entity, mob, new MemoryConfiguration());
Collection<WrappedGoal> available = selector.getAvailableGoals();
List<Goal> found = new ArrayList<>();
for (WrappedGoal wrappedGoal : available) {
if (targetGoal.getClass().isAssignableFrom(wrappedGoal.getGoal().getClass())) {
found.add(wrappedGoal.getGoal());
}
}
for (Goal removeGoal : found) {
selector.removeGoal(removeGoal);
}
} catch (Exception ex) {
platform.getLogger().log(Level.WARNING, "Error removing goal: " + goalType + " from " + entity.getType(), ex);
return false;
}
return true;
}
use of net.minecraft.world.entity.ai.goal.target.TargetGoal in project MagicPlugin by elBukkit.
the class MobUtils method removeGoal.
protected boolean removeGoal(GoalSelector selector, Mob mob, Entity entity, GoalType goalType) {
// TODO: Is there a cleaner way?
try {
Goal targetGoal = getGoal(goalType, entity, mob, new MemoryConfiguration());
Collection<WrappedGoal> available = selector.getAvailableGoals();
List<Goal> found = new ArrayList<>();
for (WrappedGoal wrappedGoal : available) {
if (targetGoal.getClass().isAssignableFrom(wrappedGoal.getGoal().getClass())) {
found.add(wrappedGoal.getGoal());
}
}
for (Goal removeGoal : found) {
selector.removeGoal(removeGoal);
}
} catch (Exception ex) {
platform.getLogger().log(Level.WARNING, "Error removing goal: " + goalType + " from " + entity.getType(), ex);
return false;
}
return true;
}
use of net.minecraft.world.entity.ai.goal.target.TargetGoal in project MagicPlugin by elBukkit.
the class MobUtils method removeGoal.
protected boolean removeGoal(GoalSelector selector, Mob mob, Entity entity, GoalType goalType) {
// TODO: Is there a cleaner way?
try {
Goal targetGoal = getGoal(goalType, entity, mob, new MemoryConfiguration());
Collection<WrappedGoal> available = selector.getAvailableGoals();
List<Goal> found = new ArrayList<>();
for (WrappedGoal wrappedGoal : available) {
if (targetGoal.getClass().isAssignableFrom(wrappedGoal.getGoal().getClass())) {
found.add(wrappedGoal.getGoal());
}
}
for (Goal removeGoal : found) {
selector.removeGoal(removeGoal);
}
} catch (Exception ex) {
platform.getLogger().log(Level.WARNING, "Error removing goal: " + goalType + " from " + entity.getType(), ex);
return false;
}
return true;
}
use of net.minecraft.world.entity.ai.goal.target.TargetGoal in project MagicPlugin by elBukkit.
the class MobUtils method removeGoal.
protected boolean removeGoal(GoalSelector selector, Mob mob, Entity entity, GoalType goalType) {
// TODO: Is there a cleaner way?
try {
Goal targetGoal = getGoal(goalType, entity, mob, new MemoryConfiguration());
Collection<WrappedGoal> available = selector.getAvailableGoals();
List<Goal> found = new ArrayList<>();
for (WrappedGoal wrappedGoal : available) {
if (targetGoal.getClass().isAssignableFrom(wrappedGoal.getGoal().getClass())) {
found.add(wrappedGoal.getGoal());
}
}
for (Goal removeGoal : found) {
selector.removeGoal(removeGoal);
}
} catch (Exception ex) {
platform.getLogger().log(Level.WARNING, "Error removing goal: " + goalType + " from " + entity.getType(), ex);
return false;
}
return true;
}
Aggregations