Class NavigationParameters
java.lang.Object
de.Keyle.MyPet.api.entity.ai.navigation.NavigationParameters
Mutable parameter bag that controls how a pet navigates the world.
Holds the base speed, per-goal speed modifiers, and environmental flags (water avoidance). Goals manipulate these values between ticks; the navigation implementation reads them when computing the next path or applying attribute values to the Bukkit mob.
Speed modifiers are additive and keyed by a unique string ID so that
multiple goals (sprint, slow, control) can independently layer bonuses
without overwriting each other. The effective speed used during
navigation is base + sum(modifiers).
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionNavigationParameters(double baseSpeed) Creates a parameter set with no modifiers applied. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSpeedModifier(String id, double speedModifier) Adds or replaces a named speed modifier.booleanWhether pathfinding should penalize water blocks.avoidWater(boolean avoidWater) Whether pathfinding should penalize water blocks.doublegetSpeed()Base movement speed (excluding modifiers).voidRemoves a previously registered speed modifier by ID.voidsetOnSpeedChange(Runnable onSpeedChange) Optional callback fired whenever a speed modifier is added or removed.voidsetSpeed(double speed) Base movement speed (excluding modifiers).doubleReturns the sum of all active speed modifiers.
-
Constructor Details
-
NavigationParameters
public NavigationParameters(double baseSpeed) Creates a parameter set with no modifiers applied.- Parameters:
baseSpeed- the pet type's default walk speed, typically sourced fromPetInfoImplattribute defaults
-
-
Method Details
-
addSpeedModifier
Adds or replaces a named speed modifier. If a modifier with the sameidalready exists, its value is overwritten.Fires the
onSpeedChangecallback so the navigation layer can immediately sync the attribute — skipped when the value is unchanged.- Parameters:
id- stable identifier for this modifier (e.g."sprint","slow")speedModifier- additive speed delta (positive = faster, negative = slower)
-
removeSpeedModifier
Removes a previously registered speed modifier by ID. No-op if the ID is not present. Fires the speed-change callback only if a value was actually removed.- Parameters:
id- identifier the modifier was added under
-
speedModifier
public double speedModifier()Returns the sum of all active speed modifiers. Added to the base speed to produce the effective movement speed.- Returns:
- the combined additive speed delta
-
avoidWater
public boolean avoidWater()Whether pathfinding should penalize water blocks. When enabled, the navigation implementation raises the path cost of water nodes, so the pet prefers dry routes.- Returns:
trueif the pet is configured to avoid water paths
-
avoidWater
Whether pathfinding should penalize water blocks. When enabled, the navigation implementation raises the path cost of water nodes, so the pet prefers dry routes.- Parameters:
avoidWater-trueto penalize water paths- Returns:
this.
-
getSpeed
public double getSpeed()Base movement speed (excluding modifiers). Setting this does not clear existing speed modifiers — the effective speed will bebase + sum(modifiers).- Returns:
- current base speed
-
setSpeed
public void setSpeed(double speed) Base movement speed (excluding modifiers). Setting this does not clear existing speed modifiers — the effective speed will bebase + sum(modifiers).- Parameters:
speed- new base speed
-
setOnSpeedChange
Optional callback fired whenever a speed modifier is added or removed. PaperNavigation uses this to re-apply parameters to MOVEMENT_SPEED immediately, so that goals which only call removeSpeedModifier() (e.g., PetSprintGoal) actually see their speed drop without waiting for the next navigateTo() or nav.stop().- Parameters:
onSpeedChange- callback to invoke on modifier mutation, ornullto clear
-