Skip to content

Commit

Permalink
feat(Rotation): Movement Correction (#5633)
Browse files Browse the repository at this point in the history
Fix Velocity and Change Look has been moved into Movement Correction -> Silent. It also introduces Strict mode.
  • Loading branch information
1zun4 authored Feb 15, 2025
1 parent 4307f9f commit d4d663f
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.ccbluex.liquidbounce.event.events.MovementInputEvent;
import net.ccbluex.liquidbounce.event.events.SprintEvent;
import net.ccbluex.liquidbounce.features.module.modules.movement.ModuleInventoryMove;
import net.ccbluex.liquidbounce.utils.aiming.MovementCorrection;
import net.ccbluex.liquidbounce.utils.aiming.RotationManager;
import net.ccbluex.liquidbounce.utils.input.InputTracker;
import net.ccbluex.liquidbounce.utils.movement.DirectionalInput;
Expand Down Expand Up @@ -113,7 +114,8 @@ private DirectionalInput transformDirection(DirectionalInput input) {
float z = KeyboardInput.getMovementMultiplier(input.getForwards(), input.getBackwards());
float x = KeyboardInput.getMovementMultiplier(input.getLeft(), input.getRight());

if (configurable == null || !configurable.getApplyVelocityFix() || rotation == null || player == null) {
if (configurable == null || configurable.getMovementCorrection() != MovementCorrection.SILENT
|| rotation == null || player == null) {
return input;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import net.ccbluex.liquidbounce.features.module.modules.movement.*;
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleAntiBlind;
import net.ccbluex.liquidbounce.features.module.modules.world.scaffold.ModuleScaffold;
import net.ccbluex.liquidbounce.utils.aiming.MovementCorrection;
import net.ccbluex.liquidbounce.utils.aiming.RotationManager;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.LivingEntity;
Expand Down Expand Up @@ -176,7 +177,7 @@ private Vec3d hookFixRotation(Vec3d original) {
return original;
}

if (configurable == null || !configurable.getApplyVelocityFix() || rotation == null) {
if (configurable == null || configurable.getMovementCorrection() == MovementCorrection.OFF || rotation == null) {
return original;
}

Expand Down Expand Up @@ -248,7 +249,7 @@ private float hookModifyFallFlyingPitch(float original) {
var rotation = rotationManager.getCurrentRotation();
var configurable = rotationManager.getWorkingAimPlan();

if (rotation == null || configurable == null || !configurable.getApplyVelocityFix() || configurable.getChangeLook()) {
if (rotation == null || configurable == null || configurable.getMovementCorrection() == MovementCorrection.OFF) {
return original;
}

Expand All @@ -268,7 +269,7 @@ private Vec3d hookModifyFallFlyingRotationVector(Vec3d original) {
var rotation = rotationManager.getCurrentRotation();
var configurable = rotationManager.getWorkingAimPlan();

if (rotation == null || configurable == null || !configurable.getApplyVelocityFix() || configurable.getChangeLook()) {
if (rotation == null || configurable == null || configurable.getMovementCorrection() == MovementCorrection.OFF) {
return original;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import net.ccbluex.liquidbounce.features.module.modules.player.nofall.modes.NoFallNoGround;
import net.ccbluex.liquidbounce.features.module.modules.world.ModuleNoSlowBreak;
import net.ccbluex.liquidbounce.utils.aiming.AimPlan;
import net.ccbluex.liquidbounce.utils.aiming.MovementCorrection;
import net.ccbluex.liquidbounce.utils.aiming.Rotation;
import net.ccbluex.liquidbounce.utils.aiming.RotationManager;
import net.minecraft.client.MinecraftClient;
Expand Down Expand Up @@ -96,7 +97,7 @@ private float hookFixRotation(float original) {
Rotation rotation = rotationManager.getCurrentRotation();
AimPlan configurable = rotationManager.getWorkingAimPlan();

if (configurable == null || !configurable.getApplyVelocityFix() || rotation == null) {
if (configurable == null || configurable.getMovementCorrection() == MovementCorrection.OFF || rotation == null) {
return original;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import net.ccbluex.liquidbounce.features.module.modules.combat.aimbot.ModuleDroneControl;
import net.ccbluex.liquidbounce.features.module.modules.render.*;
import net.ccbluex.liquidbounce.utils.aiming.AimPlan;
import net.ccbluex.liquidbounce.utils.aiming.MovementCorrection;
import net.ccbluex.liquidbounce.utils.aiming.RotationManager;
import net.minecraft.client.render.Camera;
import net.minecraft.entity.Entity;
Expand Down Expand Up @@ -107,7 +108,7 @@ private void modifyCameraOrientation(BlockView area, Entity focusedEntity, boole
var currentRotation = RotationManager.INSTANCE.getCurrentRotation();

boolean shouldModifyRotation = ModuleRotations.INSTANCE.getRunning() && ModuleRotations.INSTANCE.getCamera()
|| aimPlan != null && aimPlan.getChangeLook();
|| aimPlan != null && aimPlan.getMovementCorrection() == MovementCorrection.CHANGE_LOOK;

if (currentRotation == null || previousRotation == null || !shouldModifyRotation) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.ClientModule
import net.ccbluex.liquidbounce.features.module.modules.world.scaffold.features.ScaffoldSprintControlFeature
import net.ccbluex.liquidbounce.utils.aiming.MovementCorrection
import net.ccbluex.liquidbounce.utils.aiming.Rotation
import net.ccbluex.liquidbounce.utils.aiming.RotationManager
import net.ccbluex.liquidbounce.utils.aiming.RotationsConfigurable
Expand Down Expand Up @@ -121,7 +122,7 @@ object ModuleSprint : ClientModule("Sprint", Category.MOVEMENT) {
MathHelper.sin(deltaYaw * 0.017453292f) > 1.0E-5
val preventSprint = (if (player.isOnGround) stopOnGround else stopOnAir)
&& !shouldSprintOmnidirectional
&& RotationManager.workingAimPlan?.applyVelocityFix == false && !hasForwardMovement
&& RotationManager.workingAimPlan?.movementCorrection == MovementCorrection.OFF && !hasForwardMovement

return running && preventSprint
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ import net.ccbluex.liquidbounce.event.EventListener
import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.ClientModule
import net.ccbluex.liquidbounce.script.bindings.api.ScriptRotationUtil.newRotationEntity
import net.ccbluex.liquidbounce.utils.aiming.Rotation
import net.ccbluex.liquidbounce.utils.aiming.RotationManager
import net.ccbluex.liquidbounce.utils.aiming.RotationsConfigurable
import net.ccbluex.liquidbounce.utils.aiming.raytraceBox
import net.ccbluex.liquidbounce.utils.aiming.*
import net.ccbluex.liquidbounce.utils.client.mc
import net.ccbluex.liquidbounce.utils.kotlin.Priority
import net.minecraft.entity.Entity
Expand Down Expand Up @@ -91,10 +88,9 @@ object ScriptRotationUtil {
RotationManager.aimAt(
rotation,
configurable = RotationsConfigurable(
object : EventListener { }
).also {
it.fixVelocity = fixVelocity
}, priority = Priority.NORMAL, provider = ClientModule("ScriptAPI", Category.MISC)
object : EventListener { },
movementCorrection = if (fixVelocity) MovementCorrection.SILENT else MovementCorrection.OFF
), priority = Priority.NORMAL, provider = ClientModule("ScriptAPI", Category.MISC)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ class AimPlan(
* Consider if the inventory is open or not. If the inventory is open, we might not want to continue updating.
*/
val considerInventory: Boolean,
val applyVelocityFix: Boolean,
val changeLook: Boolean,
val movementCorrection: MovementCorrection,
/**
* What should be done if the target rotation has been reached. Can be `null`.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
*
* Copyright (c) 2015 - 2025 CCBlueX
*
* LiquidBounce is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LiquidBounce is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
*/
package net.ccbluex.liquidbounce.utils.aiming

import net.ccbluex.liquidbounce.config.types.NamedChoice

/**
* Corrects movement when aiming away from client-side view direction.
*/
enum class MovementCorrection(override val choiceName: String) : NamedChoice {

/**
* No movement correction is applied. This feels the best, as it does not
* change the movement of the player and also not affects Sprinting.
* However, this can be detected by anti-cheats.
*/
OFF("Off"),

/**
* Corrects movement by changing the yaw when updating the movement.
*/
STRICT("Strict"),

/**
* Correct movement by changing the yaw when updating the movement,
* but also tweaks the keyboard input to not aggressively change the
* players walk direction.
*/
SILENT("Silent"),

/**
* Corrects movement by changing the actual look direction of the player.
*/
CHANGE_LOOK("ChangeLook")

}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ object RotationManager : EventListener {

aimPlanHandler.request(
RequestHandler.Request(
if (plan.changeLook) 1 else plan.ticksUntilReset,
if (plan.movementCorrection == MovementCorrection.CHANGE_LOOK) 1 else plan.ticksUntilReset,
priority.priority,
provider,
plan
Expand Down Expand Up @@ -156,7 +156,8 @@ object RotationManager : EventListener {

val diff = rotation.angleTo(playerRotation)

if (aimPlan == null && (workingAimPlan.changeLook || diff <= workingAimPlan.resetThreshold)) {
if (aimPlan == null && (workingAimPlan.movementCorrection == MovementCorrection.CHANGE_LOOK
|| diff <= workingAimPlan.resetThreshold)) {
currentRotation?.let { currentRotation ->
player.yaw = player.withFixedYaw(currentRotation)
player.renderYaw = player.yaw
Expand All @@ -166,7 +167,7 @@ object RotationManager : EventListener {
currentRotation = null
previousAimPlan = null
} else {
if (workingAimPlan.changeLook) {
if (workingAimPlan.movementCorrection == MovementCorrection.CHANGE_LOOK) {
player.setRotation(rotation)
}

Expand Down Expand Up @@ -198,7 +199,7 @@ object RotationManager : EventListener {

@Suppress("unused")
private val velocityHandler = handler<PlayerVelocityStrafe> { event ->
if (workingAimPlan?.applyVelocityFix == true) {
if (workingAimPlan?.movementCorrection != MovementCorrection.OFF) {
val rotation = currentRotation ?: return@handler

event.velocity = Entity.movementInputToVelocity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import net.minecraft.util.math.Vec3d
*/
open class RotationsConfigurable(
owner: EventListener,
fixVelocity: Boolean = true,
changeLook: Boolean = false,
movementCorrection: MovementCorrection = MovementCorrection.SILENT,
combatSpecific: Boolean = false
) : Configurable("Rotations") {

Expand All @@ -31,10 +30,9 @@ open class RotationsConfigurable(
private var shortStop = ShortStop(owner).takeIf { combatSpecific }?.also { tree(it) }
private val failFocus = FailFocus(owner).takeIf { combatSpecific }?.also { tree(it) }

var fixVelocity by boolean("FixVelocity", fixVelocity)
private val movementCorrection by enumChoice("MovementCorrection", movementCorrection)
private val resetThreshold by float("ResetThreshold", 2f, 1f..180f)
private val ticksUntilReset by int("TicksUntilReset", 5, 1..30, "ticks")
private val changeLook by boolean("ChangeLook", changeLook)

fun toAimPlan(
rotation: Rotation,
Expand All @@ -53,8 +51,7 @@ open class RotationsConfigurable(
ticksUntilReset,
resetThreshold,
considerInventory,
fixVelocity,
changeLook,
movementCorrection,
whenReached
)

Expand Down

0 comments on commit d4d663f

Please sign in to comment.