Package net.citizensnpcs.api.ai
Class NavigatorParameters
java.lang.Object
net.citizensnpcs.api.ai.NavigatorParameters
- All Implemented Interfaces:
- Cloneable
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionaddRunCallback(Runnable callback) Adds aRunnablecallback that will be called every tick while the path is running.addSingleUseCallback(NavigatorCallback callback) Adds aNavigatorCallbackthat will be removed immediately after being called.intattackDelayTicks(int ticks) Sets the delay in ticks between attacks.doubleattackRange(double range) When using aggressive NPC navigation, the NPC will wait until close enough to the target before attempting to use theattackStrategy().voidattackStrategy(AttackStrategy strategy) Sets theAttackStrategyfor use when attacking entity targets.booleanavoidWater(boolean avoidWater) Sets whether to avoid water while pathfindingfloatbaseSpeed(float speed) Sets the base movement speed of theNavigator.Clears all currentBlockExaminers.clone()booleandebug()Returns whether this path will be debugged.debug(boolean debug) Sets whether the path should be debugged.Returns the configured default attack strategy, which tries to perform the most Minecraft-like attack on the target.defaultAttackStrategy(AttackStrategy defaultStrategy) Sets the defaultAttackStrategy.doubledestinationTeleportMargin(double margin) Sets the distance (in blocks) after which the NPC will directly teleport to the destination or -1 if disabled.doubleReturns the distance margin or leeway that theNavigatorwill be able to stop from the target destination.distanceMargin(double newMargin) Sets the distance margin.Gets the target location mapper.entityTargetLocationMapper(Function<Entity, Location> mapper) Set the target location mapper.examiner(BlockExaminer examiner) Adds the givenBlockExaminer.Gets a copy of all currentBlockExaminers.intfallDistance(int distance) booleanhasExaminer(Class<? extends BlockExaminer> clazz) lookAtFunction(Function<Navigator, Location> lookAt) Sets the position to look at during pathfinding, overriding the default 'look at target' behaviour.floatmodifiedSpeed(float toModify) Modifieds the given speed value based on the current parameters.doubleGets the path distance margin.pathDistanceMargin(double distance) Sets the path distance margin.pathfinderType(PathfinderType type) Sets whether or not to use an A* pathfinder defined inAStarMachinefor pathfinding.floatrange()range(float range) Sets the pathfinding range in blocks.removeRunCallback(Runnable runnable) Removes a previously added run callback.voidrun()FOR INTERNAL USE ONLY: ticks allRunnablecallbacks.floatspeed()speed(float speed) Deprecated.floatspeedModifier(float percent) Sets the movement speed modifier of theNavigator.intstationaryTicks(int ticks) Sets the number of stationary ticks before navigation is cancelled with aCancelReasonof STUCK.floatstraightLineTargetingDistance(float distance) Sets the distance (in blocks) at which the entity targeter will switch to simply following a straight line to the target instead of pathfinding.Gets theStuckActionof these parameters.stuckAction(StuckAction action) Sets theStuckActionof the parameters.intupdatePathRate(int rate) Sets the update path rate, in ticks (default 20).booleanDeprecated.useNewPathfinder(boolean use) Deprecated.
- 
Constructor Details- 
NavigatorParameterspublic NavigatorParameters()
 
- 
- 
Method Details- 
addRunCallbackAdds aRunnablecallback that will be called every tick while the path is running.- Parameters:
- callback- The callback to add
 
- 
attackDelayTickspublic int attackDelayTicks()- Returns:
- The number of ticks to wait between attacks
- See Also:
 
- 
attackDelayTicksSets the delay in ticks between attacks. When attacking a target using an aggressive target strategy, the NPC waits for a certain number of ticks between attacks to avoid repeatedly damaging the target.- Parameters:
- ticks- The new number of ticks to wait between attacks
 
- 
attackRangepublic double attackRange()- Returns:
- The attack range, in blocks
- See Also:
 
- 
attackRangeWhen using aggressive NPC navigation, the NPC will wait until close enough to the target before attempting to use theattackStrategy(). This parameter determines the range in blocks before the target will be valid to attack.- Parameters:
- range- The new attack range, in blocks
 
- 
attackStrategy- Returns:
- The AttackStrategycurrently in use or thedefaultAttackStrategy()if not configured (may return null)
 
- 
attackStrategySets theAttackStrategyfor use when attacking entity targets.- Parameters:
- strategy- The strategy to use
 
- 
avoidWaterpublic boolean avoidWater()- Returns:
- Whether to avoid water while pathfinding
 
- 
avoidWaterSets whether to avoid water while pathfinding- Parameters:
- avoidWater- Whether to avoid water
 
- 
baseSpeedpublic float baseSpeed()- Returns:
- The base movement speed
 
- 
baseSpeedSets the base movement speed of theNavigator. Note that this is mob-specific and may not always be sane. UsingspeedModifier()is preferred.- Parameters:
- speed- The new movement speed
- See Also:
 
- 
callbacks- Returns:
- All callbacks currently registered
 
- 
clearExaminersClears all currentBlockExaminers.
- 
clone
- 
debugpublic boolean debug()Returns whether this path will be debugged. Path debugging happens by repeatedly setting the next destination block to a client-sided flower.- Returns:
- Whether the path is debugging
 
- 
debugSets whether the path should be debugged.- See Also:
 
- 
defaultAttackStrategyReturns the configured default attack strategy, which tries to perform the most Minecraft-like attack on the target.- Returns:
- The default strategy
 
- 
defaultAttackStrategySets the defaultAttackStrategy.- Parameters:
- defaultStrategy- The new default strategy
- See Also:
 
- 
destinationTeleportMarginpublic double destinationTeleportMargin()- See Also:
 
- 
destinationTeleportMarginSets the distance (in blocks) after which the NPC will directly teleport to the destination or -1 if disabled. For example, if the destination teleport margin was 1.5 and the NPC reached 1.5 blocks from the target it would instantly teleport to the target location.- Parameters:
- margin- Distance teleport margin
 
- 
distanceMarginpublic double distanceMargin()Returns the distance margin or leeway that theNavigatorwill be able to stop from the target destination. The margin will be measured against the block distance. For example: if the distance margin were 2, then theNavigatorcould stop moving towards the target when it is 2 blocks away from it.- Returns:
- The distance margin
 
- 
distanceMarginSets the distance margin.- Parameters:
- newMargin- The new distance margin
- See Also:
 
- 
entityTargetLocationMapperGets the target location mapper. This is a function that maps from a target entity to the location the NPC should pathfind to. The default mapper returns the location usingEntity.getLocation(Location).
- 
entityTargetLocationMapperSet the target location mapper.- Parameters:
- mapper- The new mapper
- See Also:
 
- 
examinerAdds the givenBlockExaminer.- Parameters:
- examiner- The BlockExaminer to add
 
- 
examinersGets a copy of all currentBlockExaminers.- Returns:
- An array of all current examiners
 
- 
fallDistancepublic int fallDistance()
- 
fallDistance
- 
hasExaminer
- 
lookAtFunction- See Also:
 
- 
lookAtFunctionSets the position to look at during pathfinding, overriding the default 'look at target' behaviour.- Parameters:
- lookAt- Where to look
 
- 
modifiedSpeedpublic float modifiedSpeed(float toModify) Modifieds the given speed value based on the current parameters.- Parameters:
- toModify- The speed value to modify
- Returns:
- The modified speed
 
- 
pathDistanceMarginpublic double pathDistanceMargin()Gets the path distance margin.- See Also:
 
- 
pathDistanceMarginSets the path distance margin. This is how close the pathfinder should pathfind to the target in blocks. If you need to set the cutoff distance before the NPC considers their path completed, usedistanceMargin(double).- Parameters:
- distance- The distance margin
 
- 
pathfinderType
- 
pathfinderTypeSets whether or not to use an A* pathfinder defined inAStarMachinefor pathfinding. If this is set to MINECRAFT, then the Minecraft pathfinder will be used, which may or may not be more consistent. Note that certain API features will not be possible if this is set to MINECRAFT - for example,examiner(BlockExaminer).- Parameters:
- type- The new pathfinder type
 
- 
rangepublic float range()- Returns:
- The pathfinding range of the navigator in blocks.
- See Also:
 
- 
rangeSets the pathfinding range in blocks. The pathfinding range determines how far away theNavigatorwill attempt to pathfind before giving up to save computation.- Parameters:
- range- The new range
 
- 
removeRunCallbackRemoves a previously added run callback.- Parameters:
- runnable- The run callback to remove
- See Also:
 
- 
runpublic void run()FOR INTERNAL USE ONLY: ticks allRunnablecallbacks.
- 
speedpublic float speed()- Returns:
- The modified movement speed as given by baseSpeed()multiplied byspeedModifier()
 
- 
speedDeprecated.@seebaseSpeed(float)Sets the base movement speed of theNavigator. Note that this is mob-specific and may not always be sane. UsingspeedModifier()is preferred.- Parameters:
- speed- The new movement speed
- See Also:
 
- 
speedModifierpublic float speedModifier()- Returns:
- The movement speed modifier
- See Also:
 
- 
speedModifierSets the movement speed modifier of theNavigator. This is a percentage modifier that alters the movement speed returned inspeed().- Parameters:
- percent- The new speed modifier
 
- 
stationaryTickspublic int stationaryTicks()- Returns:
- The number of stationary ticks
- See Also:
 
- 
stationaryTicksSets the number of stationary ticks before navigation is cancelled with aCancelReasonof STUCK.- Parameters:
- ticks- The new number of stationary ticks
 
- 
straightLineTargetingDistancepublic float straightLineTargetingDistance()- Returns:
- The distance
- See Also:
 
- 
straightLineTargetingDistanceSets the distance (in blocks) at which the entity targeter will switch to simply following a straight line to the target instead of pathfinding.- Parameters:
- distance- The distance (in blocks)
 
- 
stuckActionGets theStuckActionof these parameters. This will be run when the navigation is stuck and must either be fixed up or cancelled.- Returns:
- The current stuck action
 
- 
stuckActionSets theStuckActionof the parameters.- Parameters:
- action- The new stuck action
- See Also:
 
- 
updatePathRatepublic int updatePathRate()- Returns:
- The current path rate
- See Also:
 
- 
updatePathRateSets the update path rate, in ticks (default 20). Mainly used for target following at this point - the NPC will recalculate its path to the target everyrateticks.- Parameters:
- rate- The new rate in ticks to use
 
- 
useNewPathfinderDeprecated.- Returns:
- Whether to use the new pathfinder
- See Also:
 
- 
useNewPathfinderDeprecated.Sets whether or not to use an A* pathfinder defined inAStarMachinefor pathfinding. If this is set to false, then the Minecraft pathfinder will be used, which may or may not be more consistent. Note that certain API features will not be possible if this is set to false - this includesexaminer(BlockExaminer)anddistanceMargin(double).- Parameters:
- use- Whether to use the A* pathfinder
 
 
- 
baseSpeed(float)