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
Job that handles moving to a location.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final @NotNull net.minecraft.core.BlockPosFields inherited from class com.minecolonies.core.entity.pathfinding.pathjobs.AbstractPathJob
cachedBlockLookup, debugDrawEnabled, debugNodesExtra, debugNodesNotVisited, debugNodesOrgPath, debugNodesPath, debugNodesVisited, debugNodesVisitedLater, entity, extraNodes, heuristicMod, MAX_NODES, maxNodes, result, start, tempWorldPos, totalNodesVisited, world -
Constructor Summary
ConstructorsConstructorDescriptionPathJobMoveToLocation(net.minecraft.world.level.Level world, @NotNull net.minecraft.core.BlockPos start, @NotNull net.minecraft.core.BlockPos end, int range, net.minecraft.world.entity.Mob entity) Prepares the PathJob for the path finding system. -
Method Summary
Modifier and TypeMethodDescriptionprotected doublecomputeHeuristic(int x, int y, int z) Compute the heuristic cost ('h' value) of a given position x,y,z.net.minecraft.core.BlockPosReturn the destinationprotected doublegetEndNodeScore(@NotNull MNode n) Calculate the distance to the target.protected booleanisAtDestination(@NotNull MNode n) Checks if the target has been reached.static booleanisJobFor(AbstractPathJob job, net.minecraft.core.BlockPos desiredPosition) Helper to compare if the given move to location job matches the input parametersprotected @Nullable net.minecraft.world.level.pathfinder.Pathsearch()Perform the search.protected booleanstopOnNodeLimit(int totalNodesVisited, MNode bestNode, int nodesSinceEndNode) Stops the pathjob when hitting a node limittoString()Methods inherited from class com.minecolonies.core.entity.pathfinding.pathjobs.AbstractPathJob
call, computeCost, exploreInDirection, getActualWorld, getEntity, getGroundHeight, getPathingOptions, getResult, getStart, handleDebugOptions, initDebug, isPassable, isPassable, modifyCost, setPathingOptions, syncDebug, visitNode
-
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:
searchin classAbstractPathJob- 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:AbstractPathJobCompute 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:
computeHeuristicin classAbstractPathJob- Returns:
- the heuristic.
-
isAtDestination
Checks if the target has been reached.- Specified by:
isAtDestinationin classAbstractPathJob- Parameters:
n- Node to test.- Returns:
- true if has been reached.
-
getEndNodeScore
Calculate the distance to the target.- Overrides:
getEndNodeScorein classAbstractPathJob- Parameters:
n- Node to test.- Returns:
- double of the distance.
-
stopOnNodeLimit
Description copied from class:AbstractPathJobStops the pathjob when hitting a node limit- Overrides:
stopOnNodeLimitin classAbstractPathJob- Returns:
-
toString
- Overrides:
toStringin classAbstractPathJob
-
getDestination
public net.minecraft.core.BlockPos getDestination()Description copied from interface:IDestinationPathJobReturn the destination- Specified by:
getDestinationin interfaceIDestinationPathJob- Returns:
- destination
-
isJobFor
Helper to compare if the given move to location job matches the input parameters- Returns:
- true if the given job is the same
-