@@ -41,7 +41,6 @@ import com.lambda.interaction.request.rotating.visibilty.lookAt
4141import com.lambda.module.hud.ManagerDebugLoggers.rotationManagerLogger
4242import com.lambda.threading.runGameScheduled
4343import com.lambda.threading.runSafe
44- import com.lambda.util.extension.partialTicks
4544import com.lambda.util.extension.rotation
4645import com.lambda.util.math.MathUtils.toRadian
4746import com.lambda.util.math.Vec2d
@@ -173,12 +172,6 @@ object RotationManager : RequestHandler<RotationRequest>(
173172 activeRequest?.target?.targetRotation?.update()
174173 updateActiveRotation()
175174 }
176-
177- // Tick and reset the context
178- activeRequest?.let {
179- if (it.keepTicks-- > 0 ) return @let
180- it.decayTicks--
181- }
182175 }
183176
184177 @JvmStatic
@@ -290,14 +283,18 @@ object RotationManager : RequestHandler<RotationRequest>(
290283 * Otherwise, the [serverRotation] is interpolated towards the [RotationRequest.target] rotation.
291284 */
292285 private fun SafeContext.updateActiveRotation () {
293- activeRotation = activeRequest?.let { request ->
294- val rotationTo = if (request .keepTicks >= 0 )
295- request .target.targetRotation.value
286+ activeRotation = activeRequest?.let { active ->
287+ val rotationTo = if (active .keepTicks >= 0 )
288+ active .target.targetRotation.value
296289 ? : activeRotation // the same context gets used again && the rotation is null this tick
297290 else player.rotation
298291
299- val speedMultiplier = if (request.keepTicks < 0 ) 1.0 else request.speedMultiplier
300- val turnSpeed = request.turnSpeed * speedMultiplier
292+ val speedMultiplier = if (active.keepTicks < 0 ) 1.0 else active.speedMultiplier
293+ val turnSpeed = active.turnSpeed * speedMultiplier
294+
295+ if (active.keepTicks-- <= 0 ) {
296+ active.decayTicks--
297+ }
301298
302299 // Important: do NOT wrap the result yaw; keep it continuous to match vanilla packets
303300 serverRotation.slerp(rotationTo, turnSpeed)
@@ -314,12 +311,13 @@ object RotationManager : RequestHandler<RotationRequest>(
314311 activeRequest = null
315312 }
316313
317- private val smoothRotation
318- get() = lerp(mc.partialTicks, serverRotation, activeRotation)
319-
320314 @JvmStatic
321315 val lockRotation
322- get() = if (activeRequest?.rotationMode == RotationMode .Lock ) smoothRotation else null
316+ get() = activeRequest?.let {
317+ if (it.rotationMode == RotationMode .Lock && it.keepTicks > 0 && it.decayTicks > 0 )
318+ return @let activeRotation
319+ else null
320+ }
323321
324322 @JvmStatic
325323 val headYaw
0 commit comments