Skip to content

Commit

Permalink
feat(legacy): Reworked RotationUtils. (CCBlueX#3031)
Browse files Browse the repository at this point in the history
* Reworked RotationUtils.

* Made rotations adapt to server rotation request and rotate back to previous rotation.
  • Loading branch information
mems01 authored May 16, 2024
1 parent 4af25fd commit 3b2cf67
Show file tree
Hide file tree
Showing 18 changed files with 498 additions and 368 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ object Aimbot : Module("Aimbot", ModuleCategory.COMBAT, hideModule = false) {

Backtrack.runWithNearestTrackedDistance(it) {
result = isSelected(it, true)
&& thePlayer.canEntityBeSeen(it)
&& thePlayer.getDistanceToEntityBox(it) <= range
&& getRotationDifference(it) <= fov
&& thePlayer.canEntityBeSeen(it)
&& thePlayer.getDistanceToEntityBox(it) <= range
&& getRotationDifference(it) <= fov
}

result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ object AutoPot : Module("AutoPot", ModuleCategory.COMBAT, hideModule = false) {
private val speedPotion by BoolValue("SpeedPotion", true)

private val openInventory by BoolValue("OpenInv", false)
private val simulateInventory by BoolValue("SimulateInventory", true) { !openInventory }
private val simulateInventory by BoolValue("SimulateInventory", true) { !openInventory }

private val groundDistance by FloatValue("GroundDistance", 2F, 0F..5F)
private val mode by ListValue("Mode", arrayOf("Normal", "Jump", "Port"), "Normal")
Expand Down Expand Up @@ -87,7 +87,9 @@ object AutoPot : Module("AutoPot", ModuleCategory.COMBAT, hideModule = false) {
sendPacket(C09PacketHeldItemChange(potion - 36))

if (thePlayer.rotationPitch <= 80F) {
setTargetRotation(Rotation(thePlayer.rotationYaw, nextFloat(80F, 90F)).fixedSensitivity())
setTargetRotation(Rotation(thePlayer.rotationYaw, nextFloat(80F, 90F)).fixedSensitivity(),
immediate = true
)
}
return
}
Expand All @@ -109,6 +111,7 @@ object AutoPot : Module("AutoPot", ModuleCategory.COMBAT, hideModule = false) {
msTimer.reset()
}
}

POST -> {
if (potion >= 0 && serverRotation.pitch >= 75F) {
val itemStack = thePlayer.inventoryContainer.getSlot(potion).stack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.features.module.ModuleCategory
import net.ccbluex.liquidbounce.utils.EntityUtils.isSelected
import net.ccbluex.liquidbounce.utils.Rotation
import net.ccbluex.liquidbounce.utils.RotationUtils.currentRotation
import net.ccbluex.liquidbounce.utils.RotationUtils.faceTrajectory
import net.ccbluex.liquidbounce.utils.RotationUtils.getRotationDifference
import net.ccbluex.liquidbounce.utils.RotationUtils.limitAngleChange
import net.ccbluex.liquidbounce.utils.RotationUtils.setTargetRotation
import net.ccbluex.liquidbounce.utils.extensions.getDistanceToEntityBox
import net.ccbluex.liquidbounce.utils.extensions.rotation
import net.ccbluex.liquidbounce.utils.misc.RandomUtils.nextFloat
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawPlatform
import net.ccbluex.liquidbounce.value.BoolValue
import net.ccbluex.liquidbounce.value.FloatValue
Expand Down Expand Up @@ -55,19 +51,28 @@ object BowAimbot : Module("BowAimbot", ModuleCategory.COMBAT, hideModule = false
private val silent by BoolValue("Silent", true)
private val strafe by ListValue("Strafe", arrayOf("Off", "Strict", "Silent"), "Off") { silent }
private val smootherMode by ListValue("SmootherMode", arrayOf("Linear", "Relative"), "Relative")
private val maxTurnSpeedValue: FloatValue = object : FloatValue("MaxTurnSpeed", 120f, 0f..180f) {
override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtLeast(minTurnSpeed)

private val maxHorizontalSpeedValue = object : FloatValue("MaxHorizontalSpeed", 180f, 1f..180f) {
override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtLeast(minHorizontalSpeed)
override fun isSupported() = silent

}
private val maxTurnSpeed by maxTurnSpeedValue
private val maxHorizontalSpeed by maxHorizontalSpeedValue

private val minTurnSpeed by object : FloatValue("MinTurnSpeed", 80f, 0f..180f) {
override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtMost(maxTurnSpeed)
private val minHorizontalSpeed: Float by object : FloatValue("MinHorizontalSpeed", 180f, 1f..180f) {
override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtMost(maxHorizontalSpeed)
override fun isSupported() = !maxHorizontalSpeedValue.isMinimal() && silent
}

override fun isSupported() = !maxTurnSpeedValue.isMinimal() && silent
private val maxVerticalSpeedValue = object : FloatValue("MaxVerticalSpeed", 180f, 1f..180f) {
override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtLeast(minVerticalSpeed)
}
private val maxVerticalSpeed by maxVerticalSpeedValue

private val minVerticalSpeed: Float by object : FloatValue("MinVerticalSpeed", 180f, 1f..180f) {
override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtMost(maxVerticalSpeed)
override fun isSupported() = !maxVerticalSpeedValue.isMinimal() && silent
}
private val angleThresholdUntilReset by FloatValue("AngleThresholdUntilReset", 5f, 0.1f..180f) { silent }

private var target: Entity? = null
Expand Down Expand Up @@ -109,31 +114,22 @@ object BowAimbot : Module("BowAimbot", ModuleCategory.COMBAT, hideModule = false
}
}

val limitedRotation = limitAngleChange(
currentRotation ?: mc.thePlayer.rotation,
setTargetRotation(
targetRotation ?: return,
nextFloat(minTurnSpeed, maxTurnSpeed),
smootherMode
strafe = strafe != "Off",
strict = strafe == "Strict",
applyClientSide = !silent,
turnSpeed = minHorizontalSpeed..maxHorizontalSpeed to minVerticalSpeed..maxVerticalSpeed,
angleThresholdForReset = angleThresholdUntilReset,
smootherMode = smootherMode
)

if (silent) {
setTargetRotation(
limitedRotation,
strafe = strafe != "Off",
strict = strafe == "Strict",
resetSpeed = minTurnSpeed to maxTurnSpeed,
angleThresholdForReset = angleThresholdUntilReset,
smootherMode = this.smootherMode
)
} else {
limitedRotation.toPlayer(mc.thePlayer)
}
}

@EventTarget
fun onRender3D(event: Render3DEvent) {
if (target != null && priority != "Multi" && mark)
if (target != null && priority != "Multi" && mark) {
drawPlatform(target!!, Color(37, 126, 255, 70))
}
}

private fun getTarget(throughWalls: Boolean, priorityMode: String): Entity? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ object Ignite : Module("Ignite", ModuleCategory.COMBAT, hideModule = false) {
if (thePlayer.getDistanceSq(blockPos) >= 22.3 || !blockPos.isReplaceable() || blockPos.getBlock() !is BlockAir)
continue

RotationUtils.keepLength += 1
RotationUtils.resetTicks += 1

InventoryUtils.serverSlot = fireInHotbar!! - 36

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import net.ccbluex.liquidbounce.utils.RotationUtils.getRotationDifference
import net.ccbluex.liquidbounce.utils.RotationUtils.getVectorForRotation
import net.ccbluex.liquidbounce.utils.RotationUtils.isRotationFaced
import net.ccbluex.liquidbounce.utils.RotationUtils.isVisible
import net.ccbluex.liquidbounce.utils.RotationUtils.limitAngleChange
import net.ccbluex.liquidbounce.utils.RotationUtils.searchCenter
import net.ccbluex.liquidbounce.utils.RotationUtils.setTargetRotation
import net.ccbluex.liquidbounce.utils.RotationUtils.toRotation
Expand All @@ -45,7 +44,6 @@ import net.ccbluex.liquidbounce.utils.extensions.*
import net.ccbluex.liquidbounce.utils.inventory.InventoryUtils
import net.ccbluex.liquidbounce.utils.inventory.InventoryUtils.serverOpenInventory
import net.ccbluex.liquidbounce.utils.inventory.ItemUtils.isConsumingItem
import net.ccbluex.liquidbounce.utils.misc.RandomUtils.nextFloat
import net.ccbluex.liquidbounce.utils.misc.RandomUtils.nextInt
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawEntityBox
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawPlatform
Expand Down Expand Up @@ -203,14 +201,24 @@ object KillAura : Module("KillAura", ModuleCategory.COMBAT, Keyboard.KEY_R, hide
{ autoBlock != "Off" && smartAutoBlock }

// Turn Speed
private val maxTurnSpeedValue = object : FloatValue("MaxTurnSpeed", 180f, 1f..180f) {
override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtLeast(minTurnSpeed)
private val maxHorizontalSpeedValue = object : FloatValue("MaxHorizontalSpeed", 180f, 1f..180f) {
override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtLeast(minHorizontalSpeed)
}
private val maxTurnSpeed by maxTurnSpeedValue
private val maxHorizontalSpeed by maxHorizontalSpeedValue

private val minTurnSpeed: Float by object : FloatValue("MinTurnSpeed", 180f, 1f..180f) {
override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtMost(maxTurnSpeed)
override fun isSupported() = !maxTurnSpeedValue.isMinimal()
private val minHorizontalSpeed: Float by object : FloatValue("MinHorizontalSpeed", 180f, 1f..180f) {
override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtMost(maxHorizontalSpeed)
override fun isSupported() = !maxHorizontalSpeedValue.isMinimal()
}

private val maxVerticalSpeedValue = object : FloatValue("MaxVerticalSpeed", 180f, 1f..180f) {
override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtLeast(minVerticalSpeed)
}
private val maxVerticalSpeed by maxVerticalSpeedValue

private val minVerticalSpeed: Float by object : FloatValue("MinVerticalSpeed", 180f, 1f..180f) {
override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtMost(maxVerticalSpeed)
override fun isSupported() = !maxVerticalSpeedValue.isMinimal()
}

// Raycast
Expand Down Expand Up @@ -832,39 +840,16 @@ object KillAura : Module("KillAura", ModuleCategory.COMBAT, Keyboard.KEY_R, hide
return false
}

// Get our current rotation. Otherwise, player rotation.
val currentRotation = currentRotation ?: player.rotation

var limitedRotation = limitAngleChange(currentRotation,
rotation,
nextFloat(minTurnSpeed, maxTurnSpeed),
smootherMode
setTargetRotation(rotation,
keepRotationTicks,
!(!silentRotation || rotationStrafe == "Off"),
rotationStrafe == "Strict",
!silentRotation,
minHorizontalSpeed..maxHorizontalSpeed to minVerticalSpeed..maxVerticalSpeed,
angleThresholdUntilReset,
smootherMode,
)

if (micronized) {
// Is player facing the entity with current rotation?
if (isRotationFaced(entity, maxRange.toDouble(), currentRotation)) {
// Limit angle change but this time modify the turn speed.
limitedRotation = limitAngleChange(currentRotation, rotation,
nextFloat(endInclusive = micronizedStrength)
)
}
}

if (silentRotation) {
setTargetRotation(
limitedRotation,
keepRotationTicks,
!(!silentRotation || rotationStrafe == "Off"),
rotationStrafe == "Strict",
minTurnSpeed to maxTurnSpeed,
angleThresholdUntilReset,
smootherMode
)
} else {
limitedRotation.toPlayer(player)
}

player.setPosAndPrevPos(currPos, oldPos)

return true
Expand Down Expand Up @@ -1103,3 +1088,4 @@ object KillAura : Module("KillAura", ModuleCategory.COMBAT, Keyboard.KEY_R, hide
val isBlockingChestAura
get() = handleEvents() && target != null
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ package net.ccbluex.liquidbounce.features.module.modules.misc
import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.features.module.ModuleCategory
import net.ccbluex.liquidbounce.utils.Rotation
import net.ccbluex.liquidbounce.utils.RotationUtils.currentRotation
import net.ccbluex.liquidbounce.utils.RotationUtils.setTargetRotation
import net.ccbluex.liquidbounce.utils.extensions.rotation
import net.ccbluex.liquidbounce.value.BoolValue
import net.ccbluex.liquidbounce.value.FloatValue
import net.ccbluex.liquidbounce.value.ListValue
import net.minecraft.entity.player.EntityPlayer

object NoRotateSet : Module("NoRotateSet", ModuleCategory.MISC, gameDetecting = false, hideModule = false) {
Expand All @@ -17,5 +22,55 @@ object NoRotateSet : Module("NoRotateSet", ModuleCategory.MISC, gameDetecting =
private val ignoreOnSpawn by BoolValue("IgnoreOnSpawn", false)
val affectServerRotation by BoolValue("AffectServerRotation", true)

private val strafe by ListValue("Strafe", arrayOf("Off", "Strict", "Silent"), "Off") { affectServerRotation }
private val smootherMode by ListValue("SmootherMode",
arrayOf("Linear", "Relative"),
"Relative"
) { affectServerRotation }

private val maxHorizontalSpeedValue = object : FloatValue("MaxHorizontalSpeed", 180f, 1f..180f) {
override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtLeast(minHorizontalSpeed)
override fun isSupported() = affectServerRotation
}
private val maxHorizontalSpeed by maxHorizontalSpeedValue

private val minHorizontalSpeed: Float by object : FloatValue("MinHorizontalSpeed", 180f, 1f..180f) {
override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtMost(maxHorizontalSpeed)
override fun isSupported() = !maxHorizontalSpeedValue.isMinimal() && affectServerRotation
}

private val maxVerticalSpeedValue = object : FloatValue("MaxVerticalSpeed", 180f, 1f..180f) {
override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtLeast(minVerticalSpeed)
override fun isSupported() = affectServerRotation
}
private val maxVerticalSpeed by maxVerticalSpeedValue

private val minVerticalSpeed: Float by object : FloatValue("MinVerticalSpeed", 180f, 1f..180f) {
override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtMost(maxVerticalSpeed)
override fun isSupported() = !maxVerticalSpeedValue.isMinimal() && affectServerRotation
}

private val angleThresholdUntilReset by FloatValue("AngleThresholdUntilReset",
5f,
0.1f..180f
) { affectServerRotation }

fun shouldModify(player: EntityPlayer) = handleEvents() && (!ignoreOnSpawn || player.ticksExisted != 0)

fun rotateBackToPlayerRotation() {
val player = mc.thePlayer ?: return

currentRotation = player.rotation

setTargetRotation(
savedRotation,
strafe = strafe != "Off",
strict = strafe == "Strict",
applyClientSide = false,
turnSpeed = minHorizontalSpeed..maxHorizontalSpeed to minVerticalSpeed..maxVerticalSpeed,
angleThresholdForReset = angleThresholdUntilReset,
smootherMode = smootherMode,
prioritizeRequest = true
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import net.ccbluex.liquidbounce.features.module.modules.combat.SuperKnockback
import net.ccbluex.liquidbounce.features.module.modules.world.Scaffold
import net.ccbluex.liquidbounce.utils.MovementUtils.isMoving
import net.ccbluex.liquidbounce.utils.RotationUtils.currentRotation
import net.ccbluex.liquidbounce.utils.RotationUtils.strict
import net.ccbluex.liquidbounce.utils.RotationUtils.rotationData
import net.ccbluex.liquidbounce.utils.inventory.InventoryUtils.serverOpenInventory
import net.ccbluex.liquidbounce.value.BoolValue
import net.ccbluex.liquidbounce.value.FloatValue
Expand All @@ -30,22 +30,22 @@ object Sprint : Module("Sprint", ModuleCategory.MOVEMENT, gameDetecting = false,
val alwaysCorrect by BoolValue("AlwaysCorrectSprint", false)

val allDirections by BoolValue("AllDirections", true) { mode == "Vanilla" }
val jumpDirections by BoolValue("JumpDirections", false) { mode == "Vanilla" && allDirections }
val jumpDirections by BoolValue("JumpDirections", false) { mode == "Vanilla" && allDirections }

private val allDirectionsLimitSpeed by FloatValue("AllDirectionsLimitSpeed", 1f, 0.75f..1f)
{ mode == "Vanilla" && allDirections }
private val allDirectionsLimitSpeedGround by BoolValue("AllDirectionsLimitSpeedOnlyGround", true)
{ mode == "Vanilla" && allDirections }
private val allDirectionsLimitSpeed by FloatValue("AllDirectionsLimitSpeed", 1f, 0.75f..1f)
{ mode == "Vanilla" && allDirections }
private val allDirectionsLimitSpeedGround by BoolValue("AllDirectionsLimitSpeedOnlyGround", true)
{ mode == "Vanilla" && allDirections }

private val blindness by BoolValue("Blindness", true) { mode == "Vanilla" }
private val usingItem by BoolValue("UsingItem", false) { mode == "Vanilla" }
private val inventory by BoolValue("Inventory", false) { mode == "Vanilla" }
private val food by BoolValue("Food", true) { mode == "Vanilla" }
private val blindness by BoolValue("Blindness", true) { mode == "Vanilla" }
private val usingItem by BoolValue("UsingItem", false) { mode == "Vanilla" }
private val inventory by BoolValue("Inventory", false) { mode == "Vanilla" }
private val food by BoolValue("Food", true) { mode == "Vanilla" }

private val checkServerSide by BoolValue("CheckServerSide", false) { mode == "Vanilla" }
private val checkServerSideGround by BoolValue("CheckServerSideOnlyGround", false)
{ mode == "Vanilla" && checkServerSide }
private val noPackets by BoolValue("NoPackets", false) { mode == "Vanilla" }
private val checkServerSide by BoolValue("CheckServerSide", false) { mode == "Vanilla" }
private val checkServerSideGround by BoolValue("CheckServerSideOnlyGround", false)
{ mode == "Vanilla" && checkServerSide }
private val noPackets by BoolValue("NoPackets", false) { mode == "Vanilla" }

private var isSprinting = false

Expand Down Expand Up @@ -92,7 +92,7 @@ object Sprint : Module("Sprint", ModuleCategory.MOVEMENT, gameDetecting = false,

val isLegitModeActive = mode == "Legit"

val modifiedForward = if (currentRotation != null && strict) {
val modifiedForward = if (currentRotation != null && rotationData?.strict == true) {
player.movementInput.moveForward
} else {
movementInput.moveForward
Expand Down
Loading

0 comments on commit 3b2cf67

Please sign in to comment.