@@ -57,26 +57,18 @@ object Speed : Module(
5757
5858 // Grim
5959 private val diagonal by setting(" Diagonal" , true ) { mode == Mode .GRIM_STRAFE }
60- private val grimEntityBoost by setting(" Entity Boost" , 1.0 , 0.0 .. 2.0 , 0.01 ) { mode == Mode .GRIM_STRAFE }
61- private val grimCollideMultiplier by setting(" Entity Collide Multiplier" , 0.5 , 0.0 .. 1.0 , 0.01 ) { mode == Mode .GRIM_STRAFE && grimEntityBoost > 0.0 }
62- private val grimBoatBoost by setting(" Boat Boost" , 0.4 , 0.0 .. 1.0 , 0.01 ) { mode == Mode .GRIM_STRAFE }
63- private val grimMaxSpeed by setting(" Max Speed" , 1.0 , 0.2 .. 1.0 , 0.01 ) { mode == Mode .GRIM_STRAFE }
6460
6561 // NCP
6662 private val strict by setting(" Strict" , true ) { mode == Mode .NCP_STRAFE }
6763 private val lowerJump by setting(" Lower Jump" , true ) { mode == Mode .NCP_STRAFE }
6864 private val ncpAutoJump by setting(" Auto Jump" , false ) { mode == Mode .NCP_STRAFE }
6965 private val ncpTimerBoost by setting(" Timer Boost" , 1.08 , 1.0 .. 1.1 , 0.01 ) { mode == Mode .NCP_STRAFE }
7066
71- // Grim
7267 private val rotationConfig = RotationConfig .Instant (RotationMode .Sync )
7368
74- private var prevTickJumping = false
75-
76- // NCP
69+ // NCP state variables
7770 const val NCP_BASE_SPEED = 0.2873
7871 private const val NCP_AIR_DECAY = 0.9937
79-
8072 private var ncpPhase = NCPPhase .SLOWDOWN
8173 private var ncpSpeed = NCP_BASE_SPEED
8274 private var lastDistance = 0.0
@@ -99,9 +91,8 @@ object Speed : Module(
9991 return @listen
10092 }
10193
102- when (mode) {
103- Mode .GRIM_STRAFE -> handleGrim()
104- Mode .NCP_STRAFE -> handleStrafe()
94+ if (mode == Mode .NCP_STRAFE ) {
95+ handleStrafe()
10596 }
10697 }
10798
@@ -119,40 +110,19 @@ object Speed : Module(
119110 if (mode == Mode .NCP_STRAFE && shouldWork()) it.cancel()
120111 }
121112
122- listen<MovementEvent .InputUpdate >(Int .MIN_VALUE ) {
123- if (mode != Mode .GRIM_STRAFE || ! shouldWork()) return @listen
124-
125- // Delay jumping key state by 1 tick to let the rotation predict jump timing
126- it.input.apply {
127- val jump = jumping
128- jumping = prevTickJumping
129- prevTickJumping = jump
130- }
131- }
132-
133113 listen<UpdateManagerEvent .Rotation > {
134- if (mode != Mode .GRIM_STRAFE ) return @listen
135- if (! shouldWork()) return @listen
114+ if (mode != Mode .GRIM_STRAFE || ! shouldWork()) return @listen
136115
137- var yaw = player.yaw
138116 val input = newMovementInput()
139-
140117 if (! input.isInputting) return @listen
141118
142- if (diagonal || ! player.isOnGround || ! input.playerInput.jump) {
143- val forward = input.roundedForward.toFloat()
144- var strafe = input.roundedStrafing.toFloat()
145-
146- if (strafe == 0f ) strafe = - 1f
147- if (forward == 0f ) strafe * = - 1
148-
149- yaw - = 45 * strafe
150- }
151-
152- val moveYaw = calcMoveYaw(yaw, input.roundedForward, input.roundedStrafing)
119+ val intendedMoveYaw = calcMoveYaw(player.yaw, input.roundedForward, input.roundedStrafing)
120+ val targetYaw = if (diagonal && ! (input.playerInput.jump && player.isOnGround)) {
121+ intendedMoveYaw - 45.0f
122+ } else intendedMoveYaw
153123
154124 lookAt(
155- Rotation (moveYaw , player.pitch.toDouble())
125+ Rotation (targetYaw , player.pitch.toDouble())
156126 ).requestBy(rotationConfig)
157127 }
158128
@@ -161,25 +131,6 @@ object Speed : Module(
161131 }
162132 }
163133
164- private fun SafeContext.handleGrim () {
165- if (! isInputting) return
166- if (player.moveDelta > grimMaxSpeed) return
167-
168- var boostAmount = 0.0
169-
170- boostAmount + = entitySearch<LivingEntity >(3.0 ) {
171- player.boundingBox.expand(1.0 ) in it.boundingBox && it !is ArmorStandEntity
172- }.sumOf { 0.08 * grimEntityBoost }
173-
174- if (grimBoatBoost > 0.0 ) {
175- boostAmount + = entitySearch<BoatEntity >(4.0 ) {
176- player.boundingBox in it.boundingBox.expand(0.01 )
177- }.sumOf { grimBoatBoost }
178- }
179-
180- addSpeed(boostAmount)
181- }
182-
183134 private fun SafeContext.handleStrafe () {
184135 val shouldJump = player.input.playerInput.jump || (ncpAutoJump && isInputting)
185136
@@ -227,18 +178,13 @@ object Speed : Module(
227178 if (player.abilities.flying || player.isElytraFlying || player.isTouchingWater || player.isInLava) return false
228179
229180 return when (mode) {
230- Mode .GRIM_STRAFE -> {
231- ! player.input.handledByBaritone && ! TargetStrafe .isActive
232- }
233-
234- Mode .NCP_STRAFE -> {
235- ! player.isSneaking
236- }
181+ Mode .GRIM_STRAFE -> ! player.input.handledByBaritone
182+ Mode .NCP_STRAFE -> ! player.isSneaking
237183 }
238184 }
239185
240186 private fun reset () {
241187 ncpPhase = NCPPhase .SLOWDOWN
242188 ncpSpeed = NCP_BASE_SPEED
243189 }
244- }
190+ }
0 commit comments