RoleSystems
Package: com.hypixel.hytale.server.npc.systems
public class RoleSystemsContainer class for the five core behavior tick pipeline systems. These systems form the heart of the NPC behavior tree evaluation each tick.
Execution Order
Section titled “Execution Order”PreBehaviourSupportTickSystem -> StateEvaluatorSystem (external) -> BehaviourTickSystem -> AvoidanceSystem (external) -> SteeringSystem (external) -> PostBehaviourSupportTickSystemInner Systems
Section titled “Inner Systems”RoleSystems.PreBehaviourSupportTickSystem
Section titled “RoleSystems.PreBehaviourSupportTickSystem”public static class PreBehaviourSupportTickSystem extends SteppableTickingSystemRuns before BehaviourTickSystem. Prepares each NPC for behavior evaluation:
- Validates marked entity targets: removes invalid refs, removes dead targets, removes creative players without
allowNPCDetection. - Calls
role.clearOnceIfNeeded()to reset once-triggered instructions. - Clears body and head steering vectors.
- Clears the ignored-for-avoidance entity set.
- Invalidates the cached horizontal speed multiplier.
Parallelism: EntityTickingSystem.maybeUseParallel.
RoleSystems.BehaviourTickSystem
Section titled “RoleSystems.BehaviourTickSystem”public static class BehaviourTickSystem extends TickingSystem<EntityStore>The core NPC behavior tick. Collects all NPC entity references, then iterates them. For each NPC:
- Skips entities with
NewSpawnComponent(not yet initialized). - Handles frozen/stepping logic: uses
StepComponent.getTickLength()for frozen entities. - Calls
role.tick(ref, tickLength, store)to evaluate the instruction tree. - Supports benchmarking via
NPCPlugin.isBenchmarkingRole(). - On exception (
IllegalArgumentException,IllegalStateException,NullPointerException), logs the error and removes the entity.
This system does not extend SteppableTickingSystem because it implements its own frozen-entity handling with custom collection logic.
RoleSystems.PostBehaviourSupportTickSystem
Section titled “RoleSystems.PostBehaviourSupportTickSystem”public static class PostBehaviourSupportTickSystem extends SteppableTickingSystemRuns after SteeringSystem and before TransformSystems.EntityTrackerUpdate. Post-tick cleanup:
- Clears motion controller overrides and constrains rotations.
- Ticks combat support and world support.
- Ticks entity support and handles nominated display names.
- Updates state support.
- Clears damage data.
- Resets avoidance ignore target slot.
- Resets terminal action flag.
- Clears position cache for next tick.
Parallelism: EntityTickingSystem.maybeUseParallel.
RoleSystems.RoleActivateSystem
Section titled “RoleSystems.RoleActivateSystem”public static class RoleActivateSystem extends HolderSystem<EntityStore>Runs after BalancingInitialisationSystem and ModelSystems.ModelSpawned. On entity add:
- Activates the role’s state support.
- Notifies debug flag listeners.
- Updates motion controllers with the model and bounding box.
- Clears once-triggered instructions.
- Activates the motion controller.
- Ensures the interaction chaining data component.
On entity remove: deactivates the motion controller and resets block sensors.
Query: NPCEntity AND ModelComponent AND BoundingBox
RoleSystems.RoleDebugSystem
Section titled “RoleSystems.RoleDebugSystem”public static class RoleDebugSystem extends SteppableTickingSystemRenders debug visualizations for NPC roles when debug flags are enabled:
- Debug display: Delegates to
RoleDebugDisplay.display()if configured. - Marked targets: Renders colored arrows from the NPC’s eye position to each marked target.
- Sensor visualization: Renders range discs/sectors and entity match markers.
- Leash visualization: Renders the leash point, chain rings, and connecting line.
Constants:
| Constant | Value |
|---|---|
DEBUG_SHAPE_TIME | 0.1F |
SENSOR_VIS_OPACITY | 0.4F |
LEASH_SPHERE_RADIUS | 0.3F |
LEASH_LINE_THICKNESS | 0.05F |
Related Types
Section titled “Related Types”- StateEvaluatorSystem — utility AI evaluation between pre and behaviour tick
- AvoidanceSystem — avoidance after behaviour tick
- SteeringSystem — steering after avoidance
- PositionCacheSystems — populates cache before pre-behaviour tick