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

MethodReturnsDescription
getStateEvaluator(Object store, Object ref)ObjectGet the StateEvaluator component from an entity
isAIActive(Object store, Object ref)booleanCheck if the entity’s AI is currently active
stateEvaluatorClassAvailable()booleanCheck if the StateEvaluator class is on the classpath

AI Assertion Methods

MethodFailure Message
assertAIActive(Object store, Object ref)”Expected entity AI to be active but it was inactive”
assertAIInactive(Object store, Object ref)”Expected entity AI to be inactive but it was active”

Pathfinding Adapter Methods

MethodReturnsDescription
pathfindingAvailable()booleanCheck if the AStarBase class is on the classpath
astarEvaluatorAvailable()booleanCheck if the AStarEvaluator class is on the classpath
pathFollowerAvailable()booleanCheck if the PathFollower class is on the classpath

Pathfinding Assertion Methods

MethodFailure Message
assertPathfindingAvailable()”Expected AStar pathfinding classes to be available on the classpath but none were found”

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