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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidend()Ends thisGoalSelector.@Nullable EntityFinds a target based on the entityTargetSelector.protected @Nullable EntityAIGroup@NotNull EntityCreatureGets the entity behind the goal selector.voidsetEntityCreature(@NotNull EntityCreature entityCreature) Changes the entity affected by the goal selector.abstract booleanWhether or not thisGoalSelectorshould end.abstract booleanWhether or not thisGoalSelectorshould start.abstract voidstart()Starts thisGoalSelector.abstract voidtick(long time) Called every tick when thisGoalSelectoris running.
-
Field Details
-
entityCreature
-
-
Constructor Details
-
GoalSelector
-
-
Method Details
-
shouldStart
public abstract boolean shouldStart()Whether or not thisGoalSelectorshould start.- Returns:
- true to start
-
start
public abstract void start()Starts thisGoalSelector. -
tick
public abstract void tick(long time) Called every tick when thisGoalSelectoris running.- Parameters:
time- the time of the update in milliseconds
-
shouldEnd
public abstract boolean shouldEnd()Whether or not thisGoalSelectorshould 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
-