use of net.minecraft.world.entity.ai.goal.Goal in project MagicPlugin by elBukkit.
the class MobUtils method getGoals.
private List<Goal> getGoals(Entity entity, Mob mob, ConfigurationSection config, String logContext) {
List<Goal> goals = new ArrayList<>();
List<GoalConfiguration> goalConfigurations = GoalConfiguration.fromList(config, "goals", platform.getLogger(), logContext);
if (goalConfigurations != null) {
Collections.sort(goalConfigurations);
for (GoalConfiguration goalConfig : goalConfigurations) {
try {
Goal goal = getGoal(goalConfig.getGoalType(), entity, mob, goalConfig.getConfiguration());
if (goal != null) {
goals.add(goal);
}
} catch (Exception ex) {
platform.getLogger().log(Level.WARNING, "Error creating goal: " + goalConfig.getGoalType() + " on mob " + entity.getType(), ex);
}
}
}
if (goals.isEmpty()) {
goals.add(new IdleGoal());
}
return goals;
}
use of net.minecraft.world.entity.ai.goal.Goal in project MagicPlugin by elBukkit.
the class MobUtils method getGoalDescriptions.
protected Collection<String> getGoalDescriptions(GoalSelector selector) {
List<String> descriptions = new ArrayList<>();
Collection<WrappedGoal> available = selector.getAvailableGoals();
for (WrappedGoal wrappedGoal : available) {
Goal goal = wrappedGoal.getGoal();
String description = goal.toString();
String parentDescription = getGoalParentDescriptions(goal);
if (parentDescription != null) {
description += " " + parentDescription;
}
if (wrappedGoal.isRunning()) {
description = ChatColor.AQUA + description;
} else {
description = ChatColor.GOLD + description;
}
descriptions.add(ChatColor.BLUE + Integer.toString(wrappedGoal.getPriority()) + ChatColor.DARK_GRAY + ": " + description);
}
return descriptions;
}
use of net.minecraft.world.entity.ai.goal.Goal in project MagicPlugin by elBukkit.
the class MagicGoal method getSubDescription.
protected String getSubDescription() {
List<String> goalDescriptions = new ArrayList<>();
for (Goal goal : goals) {
String goalDescription = goal.toString();
if (goal == currentGoal) {
goalDescription = ChatColor.AQUA + goalDescription;
} else {
goalDescription = ChatColor.DARK_AQUA + goalDescription;
}
goalDescriptions.add(goalDescription);
}
return ChatColor.DARK_GRAY + " [" + StringUtils.join(goalDescriptions, " ") + ChatColor.DARK_GRAY + "]";
}
use of net.minecraft.world.entity.ai.goal.Goal in project MagicPlugin by elBukkit.
the class MagicGoal method canContinueToUse.
@Override
public boolean canContinueToUse() {
boolean interrupt = false;
boolean continuing = false;
for (Goal goal : goals) {
if (goal == currentGoal) {
boolean canContinue = goal.canContinueToUse();
if (canContinue) {
continuing = true;
} else {
interrupt = true;
}
} else {
// A higher-priority goal can interrupt
boolean canUse = goal.canUse();
if (canUse && !continuing && (currentGoal == null || currentGoal.isInterruptable())) {
interrupt = true;
}
}
if (interrupt) {
return false;
}
}
return true;
}
use of net.minecraft.world.entity.ai.goal.Goal in project MagicPlugin by elBukkit.
the class MagicGoal method getSubDescription.
protected String getSubDescription() {
List<String> goalDescriptions = new ArrayList<>();
for (Goal goal : goals) {
String goalDescription = goal.toString();
if (goal == currentGoal) {
goalDescription = ChatColor.AQUA + goalDescription;
} else {
goalDescription = ChatColor.DARK_AQUA + goalDescription;
}
goalDescriptions.add(goalDescription);
}
return ChatColor.DARK_GRAY + " [" + StringUtils.join(goalDescriptions, " ") + ChatColor.DARK_GRAY + "]";
}
Aggregations