Class NavigationParameters

java.lang.Object
de.Keyle.MyPet.api.entity.ai.navigation.NavigationParameters

public class NavigationParameters extends Object
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 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 from PetInfoImpl attribute defaults
  • Method Details

    • addSpeedModifier

      public void addSpeedModifier(String id, double speedModifier)
      Adds or replaces a named speed modifier. If a modifier with the same id already exists, its value is overwritten.

      Fires the onSpeedChange callback 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

      public void removeSpeedModifier(String id)
      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:
      true if the pet is configured to avoid water paths
    • avoidWater

      public NavigationParameters avoidWater(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.
      Parameters:
      avoidWater - true to 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 be base + 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 be base + sum(modifiers).
      Parameters:
      speed - new base speed
    • setOnSpeedChange

      public void setOnSpeedChange(Runnable onSpeedChange)
      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, or null to clear