Class ReturnToStableGoal

java.lang.Object
net.minecraft.world.entity.ai.goal.Goal
com.minecolonies.core.entity.ai.cavalry.ReturnToStableGoal

public class ReturnToStableGoal extends net.minecraft.world.entity.ai.goal.Goal
Goal for a cavalry horse to return to its stable.
  • Nested Class Summary

    Nested classes/interfaces inherited from class net.minecraft.world.entity.ai.goal.Goal

    net.minecraft.world.entity.ai.goal.Goal.Flag
  • Constructor Summary

    Constructors
    Constructor
    Description
    ReturnToStableGoal(CavalryHorseEntity horse, double speed, double startDistance)
    Creates a new ReturnToStableGoal.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if the goal can continue to be used.
    boolean
    Check if the goal can be used.
    void
    Resets the return-to-stable state before the goal starts running.
    void
    Stops the horse navigation goal and resets return-to-stable targets.
    void
    Ticks the return-to-stable state machine.

    Methods inherited from class net.minecraft.world.entity.ai.goal.Goal

    adjustedTickDelay, getFlags, isInterruptable, reducedTickDelay, requiresUpdateEveryTick, setFlags, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ReturnToStableGoal

      public ReturnToStableGoal(CavalryHorseEntity horse, double speed, double startDistance)
      Creates a new ReturnToStableGoal.
      Parameters:
      horse - The cavalry horse entity.
      speed - The speed at which the cavalry horse moves.
      startDistance - The distance at which the cavalry horse starts returning to the stable.
  • Method Details

    • canUse

      public boolean canUse()
      Check if the goal can be used.

      Conditions to return false:

      • The horse has a passenger.
      • The horse does not have a stable block position.
      • The horse is within the start distance (blocks) of the stable block position.

      If the goal is usable, the stable block position is set to be the immutable target block position.

      Specified by:
      canUse in class net.minecraft.world.entity.ai.goal.Goal
      Returns:
      true if the goal can be used, false otherwise
    • canContinueToUse

      public boolean canContinueToUse()
      Checks if the goal can continue to be used.
      Overrides:
      canContinueToUse in class net.minecraft.world.entity.ai.goal.Goal
      Returns:
      true if the state machine is not done and the horse can still be controlled by this goal.
    • start

      public void start()
      Resets the return-to-stable state before the goal starts running.
      Overrides:
      start in class net.minecraft.world.entity.ai.goal.Goal
    • stop

      public void stop()
      Stops the horse navigation goal and resets return-to-stable targets.
      Overrides:
      stop in class net.minecraft.world.entity.ai.goal.Goal
    • tick

      public void tick()
      Ticks the return-to-stable state machine.
      Overrides:
      tick in class net.minecraft.world.entity.ai.goal.Goal