Class PathJobMoveToLocation

java.lang.Object
com.minecolonies.core.entity.pathfinding.pathjobs.AbstractPathJob
com.minecolonies.core.entity.pathfinding.pathjobs.PathJobMoveToLocation
All Implemented Interfaces:
IPathJob, IDestinationPathJob, Callable<net.minecraft.world.level.pathfinder.Path>
Direct Known Subclasses:
PathJobMoveToWithPassable, PathJobSignConnection

public class PathJobMoveToLocation extends AbstractPathJob implements IDestinationPathJob
Job that handles moving to a location.
  • Field Details

    • destination

      @NotNull protected final @NotNull net.minecraft.core.BlockPos destination
  • Constructor Details

    • PathJobMoveToLocation

      public PathJobMoveToLocation(net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos start, @NotNull @NotNull net.minecraft.core.BlockPos end, 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.
      end - target location.
      range - max search range.
      entity - the entity.
  • Method Details

    • search

      @Nullable protected @Nullable net.minecraft.world.level.pathfinder.Path search()
      Perform the search.
      Overrides:
      search in class AbstractPathJob
      Returns:
      Path of a path to the given location, a best-effort, or null.
    • computeHeuristic

      protected double computeHeuristic(int x, int y, int z)
      Description copied from class: AbstractPathJob
      Compute the heuristic cost ('h' value) of a given position x,y,z.

      Returning a value of 0 performs a breadth-first search. Returning a value less than actual possible cost to goal guarantees shortest path, but at computational expense. Returning a value exactly equal to the cost to the goal guarantees shortest path and least expense (but generally. only works when path is straight and unblocked). Returning a value greater than the actual cost to goal produces good, but not perfect paths, and is fast. Returning a very high value (such that 'h' is very high relative to 'g') then only 'h' (the heuristic) matters as the search will be a very fast greedy best-first-search, ignoring cost weighting and distance.

      Specified by:
      computeHeuristic in class AbstractPathJob
      Returns:
      the heuristic.
    • isAtDestination

      protected boolean isAtDestination(@NotNull @NotNull MNode n)
      Checks if the target has been reached.
      Specified by:
      isAtDestination in class AbstractPathJob
      Parameters:
      n - Node to test.
      Returns:
      true if has been reached.
    • 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 of the distance.
    • stopOnNodeLimit

      protected boolean stopOnNodeLimit(int totalNodesVisited, MNode bestNode, int nodesSinceEndNode)
      Description copied from class: AbstractPathJob
      Stops the pathjob when hitting a node limit
      Overrides:
      stopOnNodeLimit in class AbstractPathJob
      Parameters:
      totalNodesVisited -
      bestNode -
      nodesSinceEndNode -
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class AbstractPathJob
    • 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, net.minecraft.core.BlockPos desiredPosition)
      Helper to compare if the given move to location job matches the input parameters
      Returns:
      true if the given job is the same