Skip to content

NPCPreTickSystem

Package: com.hypixel.hytale.server.npc.systems

public class NPCPreTickSystem extends SteppableTickingSystem

Runs at the beginning of the NPC tick pipeline. Stores the tick-start position (used later by ComputeVelocitySystem), and manages the NPC despawn lifecycle including despawn timers, despawn animations, and despawn checks.

DependencyDirection
DeathSystems.CorpseRemovalBEFORE
public NPCPreTickSystem(@Nonnull ComponentType<EntityStore, NPCEntity> npcComponentType)

Matches entities with NPCEntity and TransformComponent.

@Override
public void steppedTick(
float dt,
int index,
@Nonnull ArchetypeChunk<EntityStore> archetypeChunk,
@Nonnull Store<EntityStore> store,
@Nonnull CommandBuffer<EntityStore> commandBuffer
)
  1. Stores the current position as the tick-start position via npcComponent.storeTickStartPosition(position).
  2. Despawn animation phase: If playing a despawn animation, ticks the animation timer. On expiry, removes the entity.
  3. Despawn timer phase: If despawning, ticks the despawn timer. On expiry, checks for a “Despawn” animation. If present, transitions to the animation phase. Otherwise, removes the entity immediately.
  4. Despawn check phase: Every 30 seconds (DEFAULT_DESPAWN_CHECK_DELAY), queries SpawningPlugin.shouldNPCDespawn(). If the NPC should despawn and is not in a busy state, initiates the despawn timer.
ConstantValueDescription
DEFAULT_DESPAWN_CHECK_DELAY30.0FSeconds between despawn eligibility checks.

Returns EntityTickingSystem.maybeUseParallel(archetypeChunkSize, taskCount).

Hydex is an independent community resource. Hytale is a trademark of Hypixel Studios. Hydex is not affiliated with or endorsed by Hypixel Studios.