Class PathJobMoveAwayFromLocation

java.lang.Object
com.minecolonies.core.entity.pathfinding.pathjobs.AbstractPathJob
com.minecolonies.core.entity.pathfinding.pathjobs.PathJobMoveAwayFromLocation
All Implemented Interfaces:
IPathJob, IDestinationPathJob, Callable<net.minecraft.world.level.pathfinder.Path>

public class PathJobMoveAwayFromLocation extends AbstractPathJob implements IDestinationPathJob
Job that handles moving away from something.
  • Field Details

    • avoid

      @NotNull protected final @NotNull net.minecraft.core.BlockPos avoid
      Position to run to, in order to avoid something.
    • avoidDistance

      protected final int avoidDistance
      Required avoidDistance.
  • Constructor Details

    • PathJobMoveAwayFromLocation

      public PathJobMoveAwayFromLocation(net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos start, @NotNull @NotNull net.minecraft.core.BlockPos avoid, int avoidDistance, int range, net.minecraft.world.entity.Mob entity)
      Prepares the PathJob for the path finding system.
      Parameters:
      world - world the entity is in.
      start - starting location.
      avoid - location to avoid.
      avoidDistance - how far to move away.
      range - max range to search.
      entity - the entity.
  • Method Details

    • computeHeuristic

      protected double computeHeuristic(int x, int y, int z)
      For MoveAwayFromLocation we want our heuristic to weight.
      Specified by:
      computeHeuristic in class AbstractPathJob
      Returns:
      heuristic as a double - Manhatten Distance with tie-breaker.
    • modifyCost

      protected double modifyCost(double cost, MNode parent, boolean swimstart, boolean swimming, int x, int y, int z, net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.block.state.BlockState below)
      Description copied from class: AbstractPathJob
      Modifies costs if needed for a node
      Overrides:
      modifyCost in class AbstractPathJob
      Parameters:
      cost -
      parent -
      swimstart -
      swimming -
      state -
      Returns:
    • isAtDestination

      protected boolean isAtDestination(@NotNull @NotNull MNode n)
      Checks if the destination has been reached. Meaning that the avoid distance has been reached.
      Specified by:
      isAtDestination in class AbstractPathJob
      Parameters:
      n - Node to test.
      Returns:
      true if so.
    • getEndNodeScore

      protected double getEndNodeScore(@NotNull @NotNull MNode n)
      Calculate the distance to the target.
      Overrides:
      getEndNodeScore in class AbstractPathJob
      Parameters:
      n - Node to test.
      Returns:
      double amount.
    • setPathingOptions

      public void setPathingOptions(PathingOptions pathingOptions)
      Description copied from class: AbstractPathJob
      Sets the pathing options
      Overrides:
      setPathingOptions in class AbstractPathJob
      Parameters:
      pathingOptions - the pathing options to set.
    • getDestination

      public net.minecraft.core.BlockPos getDestination()
      Description copied from interface: IDestinationPathJob
      Return the destination
      Specified by:
      getDestination in interface IDestinationPathJob
      Returns:
      destination
    • isJobFor

      public static boolean isJobFor(AbstractPathJob job, int avoidDistance, net.minecraft.core.BlockPos toAvoid)
      Helper to compare if the given move away job matches the input parameters
      Returns:
      true if the given job is the same