Skip to main content
The AI and Pathfinding surface covers two related systems: NPC decision-making (via StateEvaluator) and navigation (via AStar pathfinding). AIAssert and AITestAdapter handle AI state checks, while PathfindingAssert and PathfindingTestAdapter verify that pathfinding classes are available on the server classpath. AI testing is valuable when your mod modifies NPC behavior - custom AI states, patrol routes, aggression triggers, or idle behaviors. These tests verify that the AI system is active on spawned NPCs and that the pathfinding infrastructure is available for navigation.

Complete Example Suite

AI Adapter Methods

AI Assertion Methods

Pathfinding Adapter Methods

Pathfinding Assertion Methods

Key Details

  • AI assertions require a valid ECS store and entity reference - use @WorldTest with spawnNPC to get a fully initialized NPC, or @EcsTest for classpath-level checks.
  • The StateEvaluator component must be present on the entity for AI checks to work. If missing, the assertion fails with a component-not-found message.
  • Use the adapter stateEvaluatorClassAvailable() as a precondition guard before running AI-specific tests.

Next Steps

  • NPCs - NPC spawning and role verification
  • Physics - movement and pathfinding-related testing
  • ECS Testing - component-level access