Class GoalSelector

java.lang.Object
net.minestom.server.entity.ai.GoalSelector
Direct Known Subclasses:
CombinedAttackGoal, DoNothingGoal, FollowTargetGoal, MeleeAttackGoal, RandomLookAroundGoal, RandomStrollGoal, RangedAttackGoal

public abstract class GoalSelector extends Object
  • Field Details

  • Constructor Details

    • GoalSelector

      public GoalSelector(@NotNull @NotNull EntityCreature entityCreature)
  • Method Details

    • shouldStart

      public abstract boolean shouldStart()
      Whether or not this GoalSelector should start.
      Returns:
      true to start
    • start

      public abstract void start()
      Starts this GoalSelector.
    • tick

      public abstract void tick(long time)
      Called every tick when this GoalSelector is running.
      Parameters:
      time - the time of the update in milliseconds
    • shouldEnd

      public abstract boolean shouldEnd()
      Whether or not this GoalSelector should end.
      Returns:
      true to end
    • end

      public abstract void end()
      Ends this GoalSelector.
    • findTarget

      @Nullable public @Nullable Entity findTarget()
      Finds a target based on the entity TargetSelector.
      Returns:
      the target entity, null if not found
    • getEntityCreature

      @NotNull public @NotNull EntityCreature getEntityCreature()
      Gets the entity behind the goal selector.
      Returns:
      the entity
    • setEntityCreature

      public void setEntityCreature(@NotNull @NotNull EntityCreature entityCreature)
      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 using EntityAIGroup.getGoalSelectors().

      Parameters:
      entityCreature - the new affected entity
    • getAIGroup

      @Nullable protected @Nullable EntityAIGroup getAIGroup()