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>
Job that handles moving away from something.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final @NotNull net.minecraft.core.BlockPosPosition to run to, in order to avoid something.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
ConstructorsConstructorDescriptionPathJobMoveAwayFromLocation(net.minecraft.world.level.Level world, @NotNull net.minecraft.core.BlockPos start, @NotNull net.minecraft.core.BlockPos avoid, int avoidDistance, 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) For MoveAwayFromLocation we want our heuristic to weight.net.minecraft.core.BlockPosReturn the destinationprotected doublegetEndNodeScore(@NotNull MNode n) Calculate the distance to the target.protected booleanisAtDestination(@NotNull MNode n) Checks if the destination has been reached.static booleanisJobFor(AbstractPathJob job, int avoidDistance, net.minecraft.core.BlockPos toAvoid) Helper to compare if the given move away job matches the input parametersprotected 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, getResult, getStart, handleDebugOptions, initDebug, isPassable, isPassable, search, stopOnNodeLimit, syncDebug, toString, visitNode
-
Field Details
-
avoid
@NotNull protected final @NotNull net.minecraft.core.BlockPos avoidPosition to run to, in order to avoid something. -
avoidDistance
protected final int avoidDistanceRequired 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:
computeHeuristicin classAbstractPathJob- 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:AbstractPathJobModifies costs if needed for a node- Overrides:
modifyCostin classAbstractPathJob- Returns:
-
isAtDestination
Checks if the destination has been reached. Meaning that the avoid distance has been reached.- Specified by:
isAtDestinationin classAbstractPathJob- Parameters:
n- Node to test.- Returns:
- true if so.
-
getEndNodeScore
Calculate the distance to the target.- Overrides:
getEndNodeScorein classAbstractPathJob- Parameters:
n- Node to test.- Returns:
- double amount.
-
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
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
-