SystemType
SystemType
Section titled “SystemType”Package: com.hypixel.hytale.component
public class SystemType<ECS_TYPE, T extends ISystem<ECS_TYPE>> implements Comparable<SystemType<ECS_TYPE, ?>>A type-safe handle that identifies a specific ECS system within a ComponentRegistry. SystemType is the system-side counterpart to ComponentType: where ComponentType identifies a component class, SystemType identifies a system class.
Each registered system receives a SystemType instance with a unique integer index within its registry. This index enables dense array-based lookup of systems during the tick pipeline.
SystemType instances are created by ComponentRegistry during system registration. Plugin code receives them from ComponentRegistryProxy.registerSystem() and uses them for system lookup and validation.
Type Parameters
Section titled “Type Parameters”| Parameter | Description |
|---|---|
ECS_TYPE | The store type this system operates on (EntityStore or ChunkStore) |
T | The system class, bounded by ISystem<ECS_TYPE> |
Static Fields
Section titled “Static Fields”@Nonnullpublic static final SystemType[] EMPTY_ARRAY = new SystemType[0]Shared empty array constant to avoid unnecessary allocations.
Constructor
Section titled “Constructor”protected SystemType(@Nonnull ComponentRegistry<ECS_TYPE> registry, @Nonnull Class<? super T> tClass, int index)Creates a SystemType bound to the given registry with the specified class and index. This constructor is protected — only ComponentRegistry and its subclasses create SystemType instances. Plugin code obtains them via ComponentRegistryProxy.registerSystem().
Methods
Section titled “Methods”Registry Access
Section titled “Registry Access”@Nonnullpublic ComponentRegistry<ECS_TYPE> getRegistry()Returns the ComponentRegistry that this system type belongs to. There is one ComponentRegistry per store type (EntityStore.REGISTRY, ChunkStore.REGISTRY).
Type Class
Section titled “Type Class”public Class<? super T> getTypeClass()Returns the Java class that this system type represents. The ? super T bound allows registration with a supertype class for polymorphic system access.
Type Checking
Section titled “Type Checking”public boolean isType(@Nonnull ISystem<ECS_TYPE> system)Returns true if the given system instance is assignable to this system type’s class. Uses Class.isAssignableFrom() on the system’s runtime class.
public int getIndex()Returns the numeric index assigned to this system type within its registry. The index is a dense, auto-incrementing integer starting from zero, assigned at registration time. It is used internally for array-indexed system storage and ordering.
Validation
Section titled “Validation”public void validateRegistry(@Nonnull ComponentRegistry<ECS_TYPE> registry)Asserts that this system type belongs to the given registry. Throws IllegalArgumentException if the registries do not match. This is a guard against accidentally using a system type from one registry with a different registry’s store.
public void validate()Asserts that this system type has not been invalidated. Throws IllegalStateException if the system type was invalidated (e.g., due to plugin unload). Code that holds long-lived references to SystemType instances should call this before use.
protected void invalidate()Marks this system type as invalid. Called by the registry when a system is unregistered (e.g., during plugin shutdown). After invalidation, validate() will throw and isValid() will return false.
protected boolean isValid()Returns true if this system type has not been invalidated.
Ordering
Section titled “Ordering”SystemType implements Comparable<SystemType<ECS_TYPE, ?>>. Ordering is by getIndex(), which provides a deterministic, registration-order sort. This ordering determines the default system execution order within the tick pipeline when no explicit dependency ordering is specified.
public int compareTo(@Nonnull SystemType<ECS_TYPE, ?> o)Compares this system type to another by index using Integer.compare().
Equality and Hashing
Section titled “Equality and Hashing”Two SystemType instances are equal when they have the same index and the same registry. This means system types from different registries are never equal, even if they have the same index.
Lifecycle
Section titled “Lifecycle”SystemType follows a create-use-invalidate lifecycle:
- Creation:
ComponentRegistrycreates aSystemTypewhen a system is registered. The index is assigned sequentially. - Usage: Plugin code uses the
SystemTypeto reference the system. The store’s tick pipeline uses the index for efficient dispatch. - Invalidation: When a plugin is unloaded, its registered system types are invalidated. Any subsequent use of an invalidated
SystemTypewill throwIllegalStateExceptionviavalidate().
This lifecycle mirrors ComponentType, which has the same create-use-invalidate pattern.
Related Types
Section titled “Related Types”- ComponentType — the component-side counterpart; identifies component classes within a registry
- Store — the entity container that executes systems during its tick pipeline
- ComponentRegistryProxy — plugin-scoped proxy for registering systems, which returns
SystemTypeinstances - PluginBase — provides
getEntityStoreRegistry()andgetChunkStoreRegistry() ComponentRegistry— the underlying registry that stores all system types for a store typeISystem— base interface for ECS systems;Tis bounded byISystem<ECS_TYPE>EcsEvent— base class for ECS events; systems handle events dispatched through the storeSystemGroup— optional grouping mechanism for related systemsDependency— declares execution ordering constraints between systemsDependencyGraph— resolves and sorts system execution order based on dependencies