Repository navigation
ModuleContext
github-actions[bot] edited this page Mar 1, 2026
·
1 revision
org.scentient.spp.persona.module.ModuleContext
Immutable context record passed to PersonaModule.evaluate() each cycle. Contains everything a module needs to make a decision. Built once per ActionEngine evaluation — shared across all modules.
| Field | Type | Description |
|---|---|---|
personaUuid |
UUID |
The persona's unique identifier |
environment |
WorldSnapshot | Immutable snapshot of the world around the persona |
inventory |
PersonaInventory | Read-only view of the persona's inventory |
actionLog |
ActionLog |
Historical action log for behavior inference (nullable) |
directives |
DirectiveRegistry |
Active directives from players/Maestro |
battleCapability |
BattleCapabilityProvider | Generic battle readiness check |
position |
Vec3d |
Current position of the persona |
homePosition |
Vec3d |
Home position (spawn point / assigned base) |
world |
ServerWorld |
The server world instance |
serverTick |
long |
Current server tick count |
@Override
public Optional<ActionDecision> evaluate(ModuleContext ctx) {
// Check environment
if (ctx.environment().hasHostileWithin(8.0)) {
return Optional.of(ActionDecision.flee(findSafePos(ctx)));
}
// Check inventory
if (ctx.inventory().hasFood() && ctx.environment().food() < 6) {
return Optional.of(ActionDecision.eat("hungry"));
}
return Optional.empty();
}Marked API-SURFACE — part of the public spp-lib API. Fields may be added in future versions but existing fields will not change type or be removed.
SPP-AI Wiki
API Reference
- PersonaModule
- AbstractModule
- ActionPriority
- TickResult
- ModuleContext
- WorldSnapshot
- PersonaInventory
- ActionDecision
- BattleCapabilityProvider
Guides
Addon System