DespawnSystem
Package: com.hypixel.hytale.server.core.modules.entity
public class DespawnSystem extends EntityTickingSystem<EntityStore>An ECS ticking system that removes entities whose scheduled despawn time has elapsed. On each tick, reads the DespawnComponent to get the despawn instant, compares it against the current server time from TimeResource, and issues a RemoveReason.REMOVE command if the time has passed.
The query excludes entities with the Interactable component, preventing despawn of entities that are currently being interacted with.
Supports parallel execution via EntityTickingSystem.maybeUseParallel().
Constructor
Section titled “Constructor”public DespawnSystem(ComponentType<EntityStore, DespawnComponent> despawnComponentType)Constructs the system with the given despawn component type. The query is built as Query.and(despawnComponentType, Query.not(Interactable.getComponentType())).
Methods
Section titled “Methods”@Overridepublic boolean isParallel(int archetypeChunkSize, int taskCount)Returns true when parallel execution is beneficial, delegating to EntityTickingSystem.maybeUseParallel().
@Nonnull@Overridepublic Query<EntityStore> getQuery()Returns the compound query matching entities that have a DespawnComponent but do not have an Interactable component.
@Overridepublic void tick( float dt, int index, @Nonnull ArchetypeChunk<EntityStore> archetypeChunk, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer)Per-entity tick. Reads the despawn instant from the DespawnComponent, retrieves the current time from TimeResource, and removes the entity if the current time is after the despawn instant.
Related Types
Section titled “Related Types”- DespawnComponent — the component that stores the despawn time
- EntityModule — registers this system during setup
TimeResource— provides the current server time for comparisonInteractable— entities with this component are excluded from despawnEntityTickingSystem— base class for per-entity ticking systems