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 byAgent
s. If you desire to create your own, seeAbstractGoal
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
canBeInterrupted()
Returns if this goal can be interrupted.boolean
canRunConcurrentWith(Goal<O> other)
Tests if the providedGoal
is allowed to be ran concurrently with this goal.Optional<GoalExecutor<O>>
executor()
Gets theGoalExecutor
that is updating this goal, if any.default Optional<O>
owner()
Gets theAgent
that owns this goal, if any.GoalType
type()
Gets theGoalType
.
-
-
-
Method Detail
-
executor
Optional<GoalExecutor<O>> executor()
Gets theGoalExecutor
that is updating this goal, if any.- Returns:
- The goal or
Optional.empty()
if not present
-
owner
default Optional<O> owner()
Gets theAgent
that owns this goal, if any.- Returns:
- The owner or
Optional.empty()
if not present
-
canRunConcurrentWith
boolean canRunConcurrentWith(Goal<O> other)
Tests if the providedGoal
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:
- This task has higher priority than the provided goal for our
executor()
. - Returning "false" will remove the provided goal from the list of updated goals, if not there already.
- 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
- This task has higher priority than the provided goal for our
-
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 tocanRunConcurrentWith(Goal)
in the next AI tick loop.- Returns:
- True if can be interrupted, false if not
-
-