Skip to content

ComputeVelocitySystem

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

public class ComputeVelocitySystem extends SteppableTickingSystem

Computes the NPC’s velocity from the position delta between tick start (stored by NPCPreTickSystem) and the current position. The velocity is written to the Velocity component as (currentPosition - oldPosition) / dt.

public ComputeVelocitySystem(
@Nonnull ComponentType<EntityStore, NPCEntity> npcEntityComponentType,
@Nonnull ComponentType<EntityStore, Velocity> velocityComponentType,
@Nonnull Set<Dependency<EntityStore>> dependencies
)

Matches entities with NPCEntity, TransformComponent, and Velocity components.

@Override
public void steppedTick(
float dt,
int index,
@Nonnull ArchetypeChunk<EntityStore> archetypeChunk,
@Nonnull Store<EntityStore> store,
@Nonnull CommandBuffer<EntityStore> commandBuffer
)

Reads the current position from TransformComponent and the old (tick-start) position from NPCEntity.getOldPosition(), then sets the velocity to (current - old) / dt on all three axes.

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.