Class 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.
      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.
      time - the time of the update in milliseconds
    • shouldEnd

      public abstract boolean shouldEnd()
      Whether or not this GoalSelector should end.
      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.
      the target entity, null if not found
    • getEntityCreature

      @NotNull public @NotNull EntityCreature getEntityCreature()
      Gets the entity behind the goal selector.
      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().

      entityCreature - the new affected entity
    • getAIGroup

      @Nullable protected @Nullable EntityAIGroup getAIGroup()