MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / LocalInterpComp_SetPosition

Function LocalInterpComp_SetPosition

src/EntityComponents.c:418–437  ·  view source on GitHub ↗

#######################################################################################################################* *-----------------------------------------------LocalInterpolationComponent-----------------------------------------------* *#########################################################################################################################*/

Source from the content-addressed store, hash-verified

416*-----------------------------------------------LocalInterpolationComponent-----------------------------------------------*
417*#########################################################################################################################*/
418static void LocalInterpComp_SetPosition(struct Entity* e, struct LocationUpdate* update, int mode) {
419 float yOffset;
420
421 if (mode == LU_POS_ABSOLUTE_INSTANT || mode == LU_POS_ABSOLUTE_SMOOTH) {
422 e->next.pos = update->pos;
423 } else if (mode == LU_POS_RELATIVE_SMOOTH) {
424 Vec3_AddBy(&e->next.pos, &update->pos);
425 } else if (mode == LU_POS_RELATIVE_SHIFT) {
426 Vec3_AddBy(&e->prev.pos, &update->pos);
427 Vec3_AddBy(&e->next.pos, &update->pos);
428 }
429
430 /* If server sets Y position exactly on ground, push up a tiny bit */
431 yOffset = e->next.pos.y - Math_Floor(e->next.pos.y);
432 if (yOffset < ENTITY_ADJUSTMENT) e->next.pos.y += ENTITY_ADJUSTMENT;
433
434 if (mode == LU_POS_ABSOLUTE_INSTANT) {
435 e->prev.pos = e->next.pos; e->Position = e->next.pos;
436 }
437}
438
439static void LocalInterpComp_Angle(float* prev, float* next, float value, cc_bool interpolate) {
440 value = Math_ClampAngle(value);

Callers 1

Calls 1

Math_FloorFunction · 0.85

Tested by

no test coverage detected