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 Link icon

  • Constructor Details Link icon

    • GoalSelector Link icon

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

    • shouldStart Link icon

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

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

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

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

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

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

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

      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 Link icon

      @Nullable protected @Nullable EntityAIGroup getAIGroup()