Skip to content

Commit 0990a21

Browse files
committed
Even more cleanup
1 parent 1767c22 commit 0990a21

File tree

2 files changed

+36
-34
lines changed

2 files changed

+36
-34
lines changed

src/main/java/com/lambda/mixin/render/LivingEntityRendererMixin.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ public class LivingEntityRendererMixin {
4949
* }</pre>
5050
*/
5151
@WrapOperation(method = "updateRenderState(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/client/render/entity/state/LivingEntityRenderState;F)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getLerpedPitch(F)F"))
52-
private float wrapGetLerpedPitch(LivingEntity instance, float v, Operation<Float> original) {
53-
@Nullable
52+
private float wrapGetLerpedPitch(LivingEntity livingEntity, float v, Operation<Float> original) {
5453
Float headPitch = RotationManager.getHeadPitch();
55-
if (instance != Lambda.getMc().player || headPitch == null)
56-
return original.call(instance, v);
54+
if (livingEntity != Lambda.getMc().player || headPitch == null) {
55+
return original.call(livingEntity, v);
56+
}
5757

58-
return lerp(v, RotationManager.INSTANCE.getPrevServerRotation().getPitchF(), headPitch);
58+
return lerp(v, RotationManager.getPrevServerRotation().getPitchF(), headPitch);
5959
}
6060
}

src/main/kotlin/com/lambda/interaction/request/rotating/RotationManager.kt

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ object RotationManager : RequestHandler<RotationRequest>(
5555
) {
5656
var activeRotation = Rotation.ZERO
5757
var serverRotation = Rotation.ZERO
58+
@JvmStatic
5859
var prevServerRotation = Rotation.ZERO
5960

6061
var activeRequest: RotationRequest? = null
@@ -155,34 +156,35 @@ object RotationManager : RequestHandler<RotationRequest>(
155156
var pressRight = false
156157

157158
// Determine which 45-degree sector the angle falls into and set the corresponding keys.
158-
if (angle > -boundary && angle <= boundary) {
159-
// Forward
160-
pressForward = true
161-
} else if (angle > boundary && angle <= boundary + sector) {
162-
// Forward-Left
163-
pressForward = true
164-
pressLeft = true
165-
} else if (angle > boundary + sector && angle <= boundary + 2 * sector) {
166-
// Left
167-
pressLeft = true
168-
} else if (angle > boundary + 2 * sector && angle <= boundary + 3 * sector) {
169-
// Backward-Left
170-
pressBackward = true
171-
pressLeft = true
172-
} else if (angle > boundary + 3 * sector || angle <= -(boundary + 3 * sector)) {
173-
// Backward
174-
pressBackward = true
175-
} else if (angle > -(boundary + 3 * sector) && angle <= -(boundary + 2 * sector)) {
176-
// Backward-Right
177-
pressBackward = true
178-
pressRight = true
179-
} else if (angle > -(boundary + 2 * sector) && angle <= -(boundary + sector)) {
180-
// Right
181-
pressRight = true
182-
} else if (angle > -(boundary + sector) && angle <= -boundary) {
183-
// Forward-Right
184-
pressForward = true
185-
pressRight = true
159+
when {
160+
angle > -boundary && angle <= boundary -> {
161+
pressForward = true
162+
}
163+
angle > boundary && angle <= boundary + sector -> {
164+
pressForward = true
165+
pressLeft = true
166+
}
167+
angle > boundary + sector && angle <= boundary + 2 * sector -> {
168+
pressLeft = true
169+
}
170+
angle > boundary + 2 * sector && angle <= boundary + 3 * sector -> {
171+
pressBackward = true
172+
pressLeft = true
173+
}
174+
angle > boundary + 3 * sector || angle <= -(boundary + 3 * sector) -> {
175+
pressBackward = true
176+
}
177+
angle > -(boundary + 3 * sector) && angle <= -(boundary + 2 * sector) -> {
178+
pressBackward = true
179+
pressRight = true
180+
}
181+
angle > -(boundary + 2 * sector) && angle <= -(boundary + sector) -> {
182+
pressRight = true
183+
}
184+
angle > -(boundary + sector) && angle <= -boundary -> {
185+
pressForward = true
186+
pressRight = true
187+
}
186188
}
187189

188190
input.playerInput = PlayerInput(
@@ -205,7 +207,7 @@ object RotationManager : RequestHandler<RotationRequest>(
205207

206208
fun onRotationSend() {
207209
prevServerRotation = serverRotation
208-
serverRotation = activeRotation/*.fixSensitivity(prevServerRotation)*/
210+
serverRotation = activeRotation
209211

210212
if (activeRequest?.rotationMode == RotationMode.Lock) {
211213
mc.player?.yaw = serverRotation.yawF

0 commit comments

Comments
 (0)