Skip to content

Commit e7a60f8

Browse files
committed
default rotation mode to lock in rotation lock
1 parent f28b2dd commit e7a60f8

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

src/main/java/com/lambda/mixin/entity/EntityMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ private boolean wrapSetYaw(Entity instance, float yaw) {
152152
return (instance != Lambda.getMc().player ||
153153
RotationLock.INSTANCE.isDisabled() ||
154154
RotationLock.INSTANCE.getRotationConfig().getRotationMode() != RotationMode.Lock ||
155-
RotationLock.getYawMode() == RotationLock.RotationMode.None);
155+
RotationLock.getYawMode() == RotationLock.Mode.None);
156156
}
157157

158158
@WrapWithCondition(method = "changeLookDirection", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setPitch(F)V"))
159159
private boolean wrapSetPitch(Entity instance, float yaw) {
160160
return (instance != Lambda.getMc().player ||
161161
RotationLock.INSTANCE.isDisabled() ||
162162
RotationLock.INSTANCE.getRotationConfig().getRotationMode() != RotationMode.Lock ||
163-
RotationLock.getPitchMode() == RotationLock.RotationMode.None);
163+
RotationLock.getPitchMode() == RotationLock.Mode.None);
164164
}
165165
}

src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717

1818
package com.lambda.module.modules.player
1919

20+
import com.lambda.config.applyEdits
2021
import com.lambda.config.groups.RotationSettings
2122
import com.lambda.event.events.TickEvent
2223
import com.lambda.event.listener.SafeListener.Companion.listen
2324
import com.lambda.interaction.managers.rotating.Rotation
25+
import com.lambda.interaction.managers.rotating.RotationMode
2426
import com.lambda.interaction.managers.rotating.RotationRequest
2527
import com.lambda.interaction.managers.rotating.visibilty.lookAt
2628
import com.lambda.module.Module
@@ -38,39 +40,43 @@ object RotationLock : Module(
3840
Rotation("Rotation")
3941
}
4042

41-
@JvmStatic val yawMode by setting("Yaw Mode", RotationMode.Snap).group(Group.General)
42-
private val yawStep by setting("Yaw Step", 45.0, 1.0..180.0, 1.0) { yawMode == RotationMode.Snap }.group(Group.General)
43-
private val customYaw by setting("Custom Yaw", 0.0, -179.0..180.0, 1.0) { yawMode == RotationMode.Custom }.group(Group.General)
44-
@JvmStatic val pitchMode by setting("Pitch Mode", RotationMode.Custom).group(Group.General)
45-
private val pitchStep by setting("Pitch Step", 45.0, 1.0..90.0, 1.0) { pitchMode == RotationMode.Snap }.group(Group.General)
46-
private val customPitch by setting("Custom Pitch", 0.0, -90.0..90.0, 1.0) { pitchMode == RotationMode.Custom }.group(Group.General)
43+
@JvmStatic val yawMode by setting("Yaw Mode", Mode.Snap).group(Group.General)
44+
private val yawStep by setting("Yaw Step", 45.0, 1.0..180.0, 1.0) { yawMode == Mode.Snap }.group(Group.General)
45+
private val customYaw by setting("Custom Yaw", 0.0, -179.0..180.0, 1.0) { yawMode == Mode.Custom }.group(Group.General)
46+
@JvmStatic val pitchMode by setting("Pitch Mode", Mode.Custom).group(Group.General)
47+
private val pitchStep by setting("Pitch Step", 45.0, 1.0..90.0, 1.0) { pitchMode == Mode.Snap }.group(Group.General)
48+
private val customPitch by setting("Custom Pitch", 0.0, -90.0..90.0, 1.0) { pitchMode == Mode.Custom }.group(Group.General)
4749

48-
override val rotationConfig = RotationSettings(this, Group.Rotation)
50+
override val rotationConfig = RotationSettings(this, Group.Rotation).apply {
51+
applyEdits {
52+
::rotationMode.edit { defaultValue(RotationMode.Lock) }
53+
}
54+
}
4955

5056
init {
5157
listen<TickEvent.Pre> {
5258
val yaw = when (yawMode) {
53-
RotationMode.Custom -> customYaw
54-
RotationMode.Snap -> {
59+
Mode.Custom -> customYaw
60+
Mode.Snap -> {
5561
val normalizedYaw = (player.yaw % 360.0 + 360.0) % 360.0
5662
(normalizedYaw / yawStep).roundToInt() * yawStep
5763
}
58-
RotationMode.None -> player.yaw.toDouble()
64+
Mode.None -> player.yaw.toDouble()
5965
}
6066
val pitch = when (pitchMode) {
61-
RotationMode.Custom -> customPitch
62-
RotationMode.Snap -> {
67+
Mode.Custom -> customPitch
68+
Mode.Snap -> {
6369
val clampedPitch = player.pitch.coerceIn(-90f, 90f)
6470
(clampedPitch / pitchStep).roundToInt() * pitchStep
6571
}
66-
RotationMode.None -> player.pitch.toDouble()
72+
Mode.None -> player.pitch.toDouble()
6773
}
6874

6975
RotationRequest(lookAt(Rotation(yaw, pitch)), this@RotationLock).submit()
7076
}
7177
}
7278

73-
enum class RotationMode {
79+
enum class Mode {
7480
Snap,
7581
Custom,
7682
None

0 commit comments

Comments
 (0)