Class PathJobFindWater
java.lang.Object
com.minecolonies.core.entity.pathfinding.pathjobs.AbstractPathJob
com.minecolonies.core.entity.pathfinding.pathjobs.PathJobFindWater
- All Implemented Interfaces:
IPathJob,ISearchPathJob,Callable<net.minecraft.world.level.pathfinder.Path>
Find and return a path to the nearest water. Created: March 25, 2016
-
Field Summary
Fields 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
ConstructorsConstructorDescriptionPathJobFindWater(net.minecraft.world.level.Level world, @NotNull net.minecraft.core.BlockPos start, net.minecraft.core.BlockPos home, int range, @NotNull List<Tuple<net.minecraft.core.BlockPos, net.minecraft.core.BlockPos>> ponds, net.minecraft.world.entity.Mob entity) AbstractPathJob constructor. -
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.doubleCalculates a score for potential points where the path may end given no destination By default the heuristic for the closest node is used@NotNull WaterPathResultGet the path result holder for this jobprotected booleanisAtDestination(@NotNull MNode n) Return true if the given node is a viable final destination, and the path should generate to here.protected doublemodifyCost(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) Modifies costs if needed for a nodevoidsetPathingOptions(PathingOptions pathingOptions) Sets the pathing optionsMethods inherited from class com.minecolonies.core.entity.pathfinding.pathjobs.AbstractPathJob
call, computeCost, exploreInDirection, getActualWorld, getEntity, getGroundHeight, getPathingOptions, getStart, handleDebugOptions, initDebug, isPassable, isPassable, search, stopOnNodeLimit, syncDebug, toString, visitNode
-
Constructor Details
-
PathJobFindWater
public PathJobFindWater(net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos start, net.minecraft.core.BlockPos home, int range, @NotNull @NotNull List<Tuple<net.minecraft.core.BlockPos, net.minecraft.core.BlockPos>> ponds, net.minecraft.world.entity.Mob entity) AbstractPathJob constructor.- Parameters:
world- the world within which to path.start- the start position from which to path from.home- the position of the worker hut.range- maximum path range.ponds- already visited fishing places.entity- the entity.
-
-
Method Details
-
getResult
Description copied from interface:IPathJobGet the path result holder for this job- Specified by:
getResultin interfaceIPathJob- Overrides:
getResultin classAbstractPathJob- Returns:
-
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
Description copied from class:AbstractPathJobReturn true if the given node is a viable final destination, and the path should generate to here.- Specified by:
isAtDestinationin classAbstractPathJob- Parameters:
n- Node to test.- Returns:
- true if the node is a viable destination.
-
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:AbstractPathJobModifies costs if needed for a node- Overrides:
modifyCostin classAbstractPathJob- Returns:
-
setPathingOptions
Description copied from class:AbstractPathJobSets the pathing options- Overrides:
setPathingOptionsin classAbstractPathJob- Parameters:
pathingOptions- the pathing options to set.
-
getEndNodeScore
Description copied from class:AbstractPathJobCalculates a score for potential points where the path may end given no destination By default the heuristic for the closest node is used- Specified by:
getEndNodeScorein interfaceISearchPathJob- Overrides:
getEndNodeScorein classAbstractPathJob- Parameters:
n- Node to test.- Returns:
- score for the node, lower is better
-