1717
1818package com.lambda.module.modules.player
1919
20+ import com.lambda.config.applyEdits
2021import com.lambda.config.groups.RotationSettings
2122import com.lambda.event.events.TickEvent
2223import com.lambda.event.listener.SafeListener.Companion.listen
2324import com.lambda.interaction.managers.rotating.Rotation
25+ import com.lambda.interaction.managers.rotating.RotationMode
2426import com.lambda.interaction.managers.rotating.RotationRequest
2527import com.lambda.interaction.managers.rotating.visibilty.lookAt
2628import 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