BalancingInitialisationSystem
Package: com.hypixel.hytale.server.npc.systems
public class BalancingInitialisationSystem extends HolderSystem<EntityStore>Sets up NPC entity stats (health) from the role’s configuration when an NPC entity is added. Reads the initialMaxHealth from the role, computes the difference from the default stat max, and applies a StaticModifier with key "NPC_Max" to adjust the maximum health. After applying the modifier, the stat value is maximized so the NPC spawns at full health.
Execution Order
Section titled “Execution Order”| Dependency | Direction |
|---|---|
RoleBuilderSystem | AFTER |
EntityStatsSystems.Setup | AFTER |
Matches entities with both NPCEntity and EntityStatMap components.
Lifecycle
Section titled “Lifecycle”@Overridepublic void onEntityAdd(@Nonnull Holder<EntityStore> holder, @Nonnull AddReason reason, @Nonnull Store<EntityStore> store)- Gets the role from the NPC component.
- Reads
initialMaxHealthfrom the role. - Looks up the
"Health"stat index fromEntityStatType.getAssetMap(). - Creates a
StaticModifier(ADDITIVE on MAX) with the delta between the role health and the default max. - Puts the modifier with key
"NPC_Max". - Calls
maximizeStatValueto fill health to the new maximum.
@Overridepublic void onEntityRemoved(@Nonnull Holder<EntityStore> holder, @Nonnull RemoveReason reason, @Nonnull Store<EntityStore> store)No-op.
Constants
Section titled “Constants”| Constant | Value | Description |
|---|---|---|
NPC_MAX_MODIFIER | "NPC_Max" | Modifier key applied to the health stat. |
HEALTH_STAT_INDEX | "Health" | Stat type key used for health lookup. |
Related Types
Section titled “Related Types”- RoleBuilderSystem — constructs the role before this system runs
- RoleSystems — behavior tick that uses the initialized stats
Hydex is an independent community resource. Hytale is a trademark of Hypixel Studios. Hydex is not affiliated with or endorsed by Hypixel Studios.