feat(Velocity): Strafe OnlyFacing option (#5467)

This commit is contained in:
Eclipses
2025-01-29 20:11:51 +07:00
committed by GitHub
parent 3b49aacf8d
commit 8f4b68638b

View File

@@ -18,10 +18,16 @@
*/
package net.ccbluex.liquidbounce.features.module.modules.combat.velocity.mode
import net.ccbluex.liquidbounce.config.types.ToggleableConfigurable
import net.ccbluex.liquidbounce.event.events.GameTickEvent
import net.ccbluex.liquidbounce.event.events.PacketEvent
import net.ccbluex.liquidbounce.event.events.PlayerMoveEvent
import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.event.sequenceHandler
import net.ccbluex.liquidbounce.utils.aiming.RotationManager
import net.ccbluex.liquidbounce.utils.aiming.facingEnemy
import net.ccbluex.liquidbounce.utils.combat.findEnemy
import net.ccbluex.liquidbounce.utils.entity.rotation
import net.ccbluex.liquidbounce.utils.entity.sqrtSpeed
import net.ccbluex.liquidbounce.utils.entity.withStrafe
import net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket
@@ -34,9 +40,33 @@ internal object VelocityStrafe : VelocityMode("Strafe") {
private val delay by int("Delay", 2, 0..10, "ticks")
private val strength by float("Strength", 1f, 0.1f..2f)
object OnlyFacing: ToggleableConfigurable(this, "OnlyFacing", false) {
val range by float("Range", 3.5f, 0.1f..6f)
}
init {
tree(OnlyFacing)
}
private val untilGround by boolean("UntilGround", false)
private var applyStrafe = false
private var shouldStrafe = false
@Suppress("unused")
private val tickHandler = handler<GameTickEvent> {
if (!OnlyFacing.enabled) return@handler
val target = world.findEnemy(0f..OnlyFacing.range) ?: return@handler
val isFacingEnemy = facingEnemy(
target,
OnlyFacing.range.toDouble(),
RotationManager.currentRotation ?: player.rotation
)
shouldStrafe = isFacingEnemy
}
@Suppress("unused")
private val packetHandler = sequenceHandler<PacketEvent> { event ->
@@ -44,6 +74,10 @@ internal object VelocityStrafe : VelocityMode("Strafe") {
// Check if this is a regular velocity update
if ((packet is EntityVelocityUpdateS2CPacket && packet.entityId == player.id) || packet is ExplosionS2CPacket) {
if (OnlyFacing.enabled && !shouldStrafe) {
return@sequenceHandler
}
// A few anti-cheats can be easily tricked by applying the velocity a few ticks after being damaged
waitTicks(delay)