Class PathJobRandomPos
java.lang.Object
com.minecolonies.core.entity.pathfinding.pathjobs.AbstractPathJob
com.minecolonies.core.entity.pathfinding.pathjobs.PathJobRandomPos
- All Implemented Interfaces:
IPathJob,IDestinationPathJob,Callable<net.minecraft.world.level.pathfinder.Path>
Job that handles random pathing.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final @NotNull net.minecraft.core.BlockPosDirection to walk to.protected final intRequired avoidDistance.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
ConstructorsConstructorDescriptionPathJobRandomPos(net.minecraft.world.level.Level world, @NotNull net.minecraft.core.BlockPos start, int minDistFromStart, int searchRange, int maxDistToDest, net.minecraft.world.entity.Mob entity, @NotNull net.minecraft.core.BlockPos dest) Prepares the PathJob for the path finding system.PathJobRandomPos(net.minecraft.world.level.Level world, @NotNull net.minecraft.core.BlockPos start, int minDistFromStart, int range, net.minecraft.world.entity.Mob entity) Prepares the PathJob for the path finding system.PathJobRandomPos(net.minecraft.world.level.Level world, @NotNull net.minecraft.core.BlockPos start, int minDistFromStart, int range, net.minecraft.world.entity.Mob entity, net.minecraft.core.BlockPos startRestriction, net.minecraft.core.BlockPos endRestriction) Prepares the PathJob for the path finding system.PathJobRandomPos(net.minecraft.world.level.Level world, @NotNull net.minecraft.core.BlockPos start, int minDistFromStart, int range, net.minecraft.world.entity.Mob entity, net.minecraft.core.BlockPos startRestriction, net.minecraft.core.BlockPos endRestriction, boolean preferInside) 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) Calculates a score for potential points where the path may end given no destination By default the heuristic for the closest node is usedprotected booleanisAtDestination(@NotNull MNode n) Return true if the given node is a viable final destination, and the path should generate to here.static booleanisJobFor(AbstractPathJob job, net.minecraft.core.BlockPos center, int range) Helper to compare if the given random pos job matches the input parametersvoidsetPathingOptions(PathingOptions pathingOptions) Sets the pathing optionsMethods inherited from class com.minecolonies.core.entity.pathfinding.pathjobs.AbstractPathJob
call, computeCost, exploreInDirection, getActualWorld, getEntity, getGroundHeight, getPathingOptions, getResult, getStart, handleDebugOptions, initDebug, isPassable, isPassable, modifyCost, search, stopOnNodeLimit, syncDebug, toString, visitNode
-
Field Details
-
destination
@NotNull protected final @NotNull net.minecraft.core.BlockPos destinationDirection to walk to. -
minDistFromStart
protected final int minDistFromStartRequired avoidDistance.
-
-
Constructor Details
-
PathJobRandomPos
public PathJobRandomPos(net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos start, int minDistFromStart, 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.minDistFromStart- how far to move away.range- max range to search.entity- the entity.
-
PathJobRandomPos
public PathJobRandomPos(net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos start, int minDistFromStart, int searchRange, int maxDistToDest, net.minecraft.world.entity.Mob entity, @NotNull @NotNull net.minecraft.core.BlockPos dest) Prepares the PathJob for the path finding system.- Parameters:
world- world the entity is in.start- starting location.minDistFromStart- how far to move away.searchRange- max range to search.entity- the entity.
-
PathJobRandomPos
public PathJobRandomPos(net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos start, int minDistFromStart, int range, net.minecraft.world.entity.Mob entity, net.minecraft.core.BlockPos startRestriction, net.minecraft.core.BlockPos endRestriction) Prepares the PathJob for the path finding system.- Parameters:
world- world the entity is in.start- starting location.minDistFromStart- how far to move away.range- max range to search.entity- the entity.
-
PathJobRandomPos
public PathJobRandomPos(net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos start, int minDistFromStart, int range, net.minecraft.world.entity.Mob entity, net.minecraft.core.BlockPos startRestriction, net.minecraft.core.BlockPos endRestriction, boolean preferInside) Prepares the PathJob for the path finding system.- Parameters:
world- world the entity is in.start- starting location.minDistFromStart- how far to move away.range- max range to search.entity- the entity.preferInside- if the entity should try to stay inside.
-
-
Method Details
-
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.
-
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- Overrides:
getEndNodeScorein classAbstractPathJob- Parameters:
n- Node to test.- Returns:
- score for the node, lower is better
-
setPathingOptions
Description copied from class:AbstractPathJobSets the pathing options- Overrides:
setPathingOptionsin classAbstractPathJob- Parameters:
pathingOptions- the pathing options to set.
-
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 random pos job matches the input parameters- Returns:
- true if the given job is the same
-