Interface Goal<O extends Agent>

Type Parameters:
O - The type of agent
All Known Subinterfaces:
AttackLivingGoal, AvoidLivingGoal, FindNearestAttackableTargetGoal, LookAtGoal, LookRandomlyGoal, RandomWalkingGoal, RangedAttackAgainstAgentGoal, RunAroundLikeCrazyGoal, SwimGoal, TargetGoal<A>
All Known Implementing Classes:
AbstractGoal

public interface Goal<O extends Agent>
Represents an action performed by Agents. If you desire to create your own, see AbstractGoal.
  • Method Details

    • type

      GoalType type()
      Gets the GoalType.
      Returns:
      The type
    • executor

      Optional<GoalExecutor<O>> executor()
      Gets the GoalExecutor that is updating this goal, if any.
      Returns:
      The goal or Optional.empty() if not present
    • owner

      default Optional<O> owner()
      Gets the Agent that owns this goal, if any.
      Returns:
      The owner or Optional.empty() if not present
    • canRunConcurrentWith

      boolean canRunConcurrentWith(Goal<O> other)
      Tests if the provided Goal is allowed to be ran concurrently with this goal.

      This plays a role in determining if goals should be updated or not. If this method is being called on this task, that means:

      1. This task has higher priority than the provided goal for our executor().
      2. Returning "false" will remove the provided goal from the list of updated goals, if not there already.
      3. Returning "true" will add the provided task to the list of updated goals, if not there already.
      Parameters:
      other - The other goal
      Returns:
      True if it can be, false if not
    • canBeInterrupted

      boolean canBeInterrupted()
      Returns if this goal can be interrupted. This determines if this goal can be added to the list of updated goals as well as if it should continue updating.

      Thought should be made before blindly returning true or false here. In Minecraft, all goals can be interrupted by higher priority goals (goals added with lower numerical values in GoalExecutor.addGoal(int, Goal)) but a goal being created by a plugin might be deemed critical and as such should return false.

      Due note that the meaning of "true" changes based on the state of the GoalExecutor. To put it simply, this value can mean "Should I be added as an updating goal or "Should I continue updating?". Regardless of the question, the next step that happens is transferring from this method to canRunConcurrentWith(Goal) in the next AI tick loop.

      Returns:
      True if can be interrupted, false if not