RoleBuilderSystem
Package: com.hypixel.hytale.server.npc.systems
public class RoleBuilderSystem extends HolderSystem<EntityStore>Constructs Role objects from builder configurations when an NPC entity is added to the store. This is the primary role initialization system, responsible for resolving the role name/index, invoking the builder pipeline, setting up the model, display name, interactions, beacon support, event support, timers, state evaluators, value stores, and visual effects.
Execution Order
Section titled “Execution Order”| Dependency | Direction |
|---|---|
EntityStatsSystems.Setup | AFTER |
PhysicsValuesAddSystem | AFTER |
Matches entities with NPCEntity and TransformComponent.
Entity Add Logic
Section titled “Entity Add Logic”@Overridepublic void onEntityAdd(@Nonnull Holder<EntityStore> holder, @Nonnull AddReason reason, @Nonnull Store<EntityStore> store)If the NPC does not already have a role:
- Resolves the role index from the role name if needed.
- Validates the role is spawnable (non-abstract).
- Creates a
BuilderSupportand invokesNPCPlugin.buildRole(). - Sets the role on the NPC component.
- Adds
Invulnerablecomponent if the role is invulnerable. - Sets the
DisplayNameComponentto the role’s translation key. - Configures
Interactions(Use NPC, death interaction). - Adds
BeaconSupportif beacon slot mappings exist. - Adds
PlayerBlockEventSupportandNPCBlockEventSupportif block event support is configured. - Adds
PlayerEntityEventSupportandNPCEntityEventSupportif entity event support is configured. - Adds
Timerscomponent if timers are allocated. - Adds
StateEvaluatorcomponent if utility AI is configured. - Adds
ValueStorecomponent if value store builder exists. - Ensures
EffectControllerComponentandActiveAnimationComponent. - For spawned or prefab entities, sets up the model and calls
role.spawned(). - Applies spawn effects if the builder implements
SpawnEffect.
On failure, calls the internal fail() method which strips all components and adds FailedSpawnComponent.
Related Types
Section titled “Related Types”- BalancingInitialisationSystem — stat initialization after role building
- FailedSpawnSystem — handles failed role construction
- RoleChangeSystem — handles runtime role changes
- RoleSystems — behavior tick pipeline
Hydex is an independent community resource. Hytale is a trademark of Hypixel Studios. Hydex is not affiliated with or endorsed by Hypixel Studios.