@@ -38,7 +38,6 @@ import com.lambda.util.math.MathUtils.toRadian
3838import com.lambda.util.math.Vec2d
3939import com.lambda.util.math.lerp
4040import net.minecraft.client.input.Input
41- import net.minecraft.client.input.KeyboardInput
4241import net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket
4342import net.minecraft.util.PlayerInput
4443import net.minecraft.util.math.Vec2f
@@ -141,15 +140,9 @@ object RotationManager : RequestHandler<RotationRequest>(
141140
142141 val cos = cos(deltaYawRad)
143142 val sin = sin(deltaYawRad)
144- // This is the IDEAL movement vector in the server-side entity's frame of reference
145143 val newStrafe = originalStrafe * cos - originalForward * sin
146144 val newForward = originalStrafe * sin + originalForward * cos
147145
148- // --- ANGLE SNAPPING LOGIC ---
149- // Instead of simple thresholds, we find the closest of the 8 possible directions.
150-
151- // Get the angle of the ideal vector. atan2 gives us an angle in radians.
152- // Note: Minecraft input vector's +Y is forward, +X is left.
153146 val angle = atan2(newStrafe.toDouble(), newForward.toDouble())
154147
155148 // Define the boundaries for our 8 sectors (in radians). Each sector is 45 degrees (PI/4).
@@ -192,7 +185,6 @@ object RotationManager : RequestHandler<RotationRequest>(
192185 pressRight = true
193186 }
194187
195- // --- Update Minecraft's input objects ---
196188 input.playerInput = PlayerInput (
197189 pressForward,
198190 pressBackward,
@@ -203,18 +195,13 @@ object RotationManager : RequestHandler<RotationRequest>(
203195 input.playerInput.sprint()
204196 )
205197
206- val f = getMovementMultiplier (input.playerInput.forward (), input.playerInput.backward ())
207- val g = getMovementMultiplier (input.playerInput.left (), input.playerInput.right ())
208- input.movementVector = Vec2f (g, f ).normalize()
198+ val x = multiplier (input.playerInput.left (), input.playerInput.right ())
199+ val y = multiplier (input.playerInput.forward (), input.playerInput.backward ())
200+ input.movementVector = Vec2f (x, y ).normalize()
209201 }
210202
211- private fun getMovementMultiplier (positive : Boolean , negative : Boolean ): Float {
212- return if (positive == negative) {
213- 0.0f
214- } else {
215- if (positive) 1.0f else - 1.0f
216- }
217- }
203+ private fun multiplier (positive : Boolean , negative : Boolean ) =
204+ ((if (positive) 1 else 0 ) - (if (negative) 1 else 0 )).toFloat()
218205
219206 fun onRotationSend () {
220207 prevServerRotation = serverRotation
0 commit comments