Skip to content

Commit

Permalink
feat(FlagCheck): added force rotate check (#5469)
Browse files Browse the repository at this point in the history
  • Loading branch information
EclipsesDev authored Jan 27, 2025
1 parent aab31f4 commit 72f58c8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import net.minecraft.network.packet.s2c.common.DisconnectS2CPacket
import net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket
import net.minecraft.util.math.Vec3d
import org.apache.commons.lang3.StringUtils
import kotlin.math.abs
import kotlin.math.roundToLong

/**
* Module Flag Check.
Expand Down Expand Up @@ -112,21 +114,34 @@ object ModuleFlagCheck : ClientModule("FlagCheck", Category.MISC, aliases = arra
}

private var flagCount = 0
private var lastYaw = 0F
private var lastPitch = 0F

@Suppress("unused")
private val packetHandler = handler<PacketEvent> { event ->
if (player.age <= 25) {
return@handler
}

when (val packet = event.packet) {
is PlayerPositionLookS2CPacket -> {
if (player.age <= 25) {
return@handler
}
val change = packet.change
val deltaYaw = calculateAngleDelta(change.yaw, lastYaw)
val deltaPitch = calculateAngleDelta(change.pitch, lastPitch)

flagCount++
alert(AlertReason.LAGBACK)
if (deltaYaw >= 90 || deltaPitch >= 90) {
alert(AlertReason.FORCEROTATE, "(${deltaYaw.roundToLong()}° | ${deltaPitch.roundToLong()}°)")
} else {
alert(AlertReason.LAGBACK)
}

Render.reset()
val change = packet.change
val position = change.position
Render.wireframePlayer.setPosRot(position.x, position.y, position.z, change.yaw, change.pitch)

lastYaw = player.headYaw
lastPitch = player.pitch
}

is DisconnectS2CPacket -> {
Expand Down Expand Up @@ -182,9 +197,17 @@ object ModuleFlagCheck : ClientModule("FlagCheck", Category.MISC, aliases = arra
}
}

private fun calculateAngleDelta(newAngle: Float, oldAngle: Float): Float {
var delta = newAngle - oldAngle
if (delta > 180) delta -= 360
if (delta < -180) delta += 360
return abs(delta)
}

@Suppress("SpellCheckingInspection")
private enum class AlertReason(val key: String) {
INVALID("invalid"),
FORCEROTATE("forceRotate"),
LAGBACK("lagback")
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/resources/liquidbounce/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@
"liquidbounce.module.flagCheck.messages.alert": "Detected %s (%sx)",
"liquidbounce.module.flagCheck.messages.alertWithExtra": "Detected %s %s (%sx)",
"liquidbounce.module.flagCheck.messages.lagback": "LagBack",
"liquidbounce.module.flagCheck.messages.forceRotate": "Force-Rotate",
"liquidbounce.module.flagCheck.messages.invalid": "Invalid",
"liquidbounce.module.freeCam.description": "Allows you to move the camera out of your body.",
"liquidbounce.module.freeLook.description": "Allows you to move the camera freely around your character.",
Expand Down

0 comments on commit 72f58c8

Please sign in to comment.