Package net.minestom.server.entity.ai
Class GoalSelector
java.lang.Object
net.minestom.server.entity.ai.GoalSelector
- Direct Known Subclasses:
CombinedAttackGoal
,DoNothingGoal
,FollowTargetGoal
,MeleeAttackGoal
,RandomLookAroundGoal
,RandomStrollGoal
,RangedAttackGoal
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
end()
Ends thisGoalSelector
.@Nullable Entity
Finds a target based on the entityTargetSelector
.protected @Nullable EntityAIGroup
@NotNull EntityCreature
Gets the entity behind the goal selector.void
setEntityCreature
(@NotNull EntityCreature entityCreature) Changes the entity affected by the goal selector.abstract boolean
Whether or not thisGoalSelector
should end.abstract boolean
Whether or not thisGoalSelector
should start.abstract void
start()
Starts thisGoalSelector
.abstract void
tick
(long time) Called every tick when thisGoalSelector
is running.
-
Field Details
-
entityCreature
-
-
Constructor Details
-
GoalSelector
-
-
Method Details
-
shouldStart
public abstract boolean shouldStart()Whether or not thisGoalSelector
should start.- Returns:
- true to start
-
start
public abstract void start()Starts thisGoalSelector
. -
tick
public abstract void tick(long time) Called every tick when thisGoalSelector
is running.- Parameters:
time
- the time of the update in milliseconds
-
shouldEnd
public abstract boolean shouldEnd()Whether or not thisGoalSelector
should end.- Returns:
- true to end
-
end
public abstract void end()Ends thisGoalSelector
. -
findTarget
Finds a target based on the entityTargetSelector
.- Returns:
- the target entity, null if not found
-
getEntityCreature
Gets the entity behind the goal selector.- Returns:
- the entity
-
setEntityCreature
Changes the entity affected by the goal selector.WARNING: this does not add the goal selector to
entityCreature
, this only change the internal entity AI group's field. Be sure to remove the goal from the previous entity AI group and add it to the new one usingEntityAIGroup.getGoalSelectors()
.- Parameters:
entityCreature
- the new affected entity
-
getAIGroup
-