diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/Aimbot.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/Aimbot.kt index 4cd40913830..223ca0f9318 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/Aimbot.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/Aimbot.kt @@ -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 diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/AutoPot.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/AutoPot.kt index 1f150f85cb3..8d96659c8c4 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/AutoPot.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/AutoPot.kt @@ -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") @@ -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 } @@ -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 diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/BowAimbot.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/BowAimbot.kt index e7f94e890a0..5320a5ca458 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/BowAimbot.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/BowAimbot.kt @@ -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 @@ -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 @@ -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? { diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/Ignite.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/Ignite.kt index 4b9068b52b3..aa832c80f5f 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/Ignite.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/Ignite.kt @@ -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 diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/KillAura.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/KillAura.kt index aa92b4a5562..5fe1318fb12 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/KillAura.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/combat/KillAura.kt @@ -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 @@ -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 @@ -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 @@ -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 @@ -1103,3 +1088,4 @@ object KillAura : Module("KillAura", ModuleCategory.COMBAT, Keyboard.KEY_R, hide val isBlockingChestAura get() = handleEvents() && target != null } + diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/misc/NoRotateSet.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/misc/NoRotateSet.kt index d3b28a25a5b..672d156c668 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/misc/NoRotateSet.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/misc/NoRotateSet.kt @@ -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) { @@ -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 + ) + } } \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/Sprint.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/Sprint.kt index ef10e4d502b..e3ac0848e2d 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/Sprint.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/Sprint.kt @@ -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 @@ -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 @@ -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 diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/player/AntiFireball.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/player/AntiFireball.kt index b53849a03e5..b47bc905407 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/player/AntiFireball.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/player/AntiFireball.kt @@ -14,11 +14,9 @@ import net.ccbluex.liquidbounce.features.module.ModuleCategory import net.ccbluex.liquidbounce.utils.PacketUtils.sendPacket import net.ccbluex.liquidbounce.utils.RotationUtils.currentRotation import net.ccbluex.liquidbounce.utils.RotationUtils.isRotationFaced -import net.ccbluex.liquidbounce.utils.RotationUtils.limitAngleChange import net.ccbluex.liquidbounce.utils.RotationUtils.setTargetRotation import net.ccbluex.liquidbounce.utils.RotationUtils.toRotation import net.ccbluex.liquidbounce.utils.extensions.* -import net.ccbluex.liquidbounce.utils.misc.RandomUtils.nextFloat import net.ccbluex.liquidbounce.value.BoolValue import net.ccbluex.liquidbounce.value.FloatValue import net.ccbluex.liquidbounce.value.ListValue @@ -36,14 +34,27 @@ object AntiFireball : Module("AntiFireball", ModuleCategory.PLAYER, hideModule = private val smootherMode by ListValue("SmootherMode", arrayOf("Linear", "Relative"), "Relative") { rotations } private val strafe by BoolValue("Strafe", false) { rotations } - 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() = rotations + + } + 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() && rotations + } + + private val maxVerticalSpeedValue = object : FloatValue("MaxVerticalSpeed", 180f, 1f..180f) { + override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtLeast(minVerticalSpeed) } - private val maxTurnSpeed by maxTurnSpeedValue + private val maxVerticalSpeed by maxVerticalSpeedValue - private val minTurnSpeed by object : FloatValue("MinTurnSpeed", 80f, 0f..180f) { - override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtMost(maxTurnSpeed) - override fun isSupported() = !maxTurnSpeedValue.isMinimal() + 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() && rotations } private val angleThresholdUntilReset by FloatValue("AngleThresholdUntilReset", 5f, 0.1f..180f) { rotations } @@ -82,14 +93,11 @@ object AntiFireball : Module("AntiFireball", ModuleCategory.PLAYER, hideModule = if (rotations) { setTargetRotation( - limitAngleChange(currentRotation ?: player.rotation, - toRotation(nearestPoint, true), - nextFloat(minTurnSpeed, maxTurnSpeed), - smootherMode - ), + toRotation(nearestPoint, true), strafe = this.strafe, - resetSpeed = minTurnSpeed to maxTurnSpeed, - angleThresholdForReset = angleThresholdUntilReset + turnSpeed = minHorizontalSpeed..maxHorizontalSpeed to minVerticalSpeed..maxVerticalSpeed, + angleThresholdForReset = angleThresholdUntilReset, + smootherMode = smootherMode ) } diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/ChestAura.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/ChestAura.kt index e3780ed570f..3c5ae4df879 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/ChestAura.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/ChestAura.kt @@ -13,17 +13,15 @@ import net.ccbluex.liquidbounce.features.module.modules.player.Blink import net.ccbluex.liquidbounce.utils.ClientUtils.displayChatMessage import net.ccbluex.liquidbounce.utils.EntityUtils.isSelected import net.ccbluex.liquidbounce.utils.PacketUtils.sendPacket -import net.ccbluex.liquidbounce.utils.RotationUtils import net.ccbluex.liquidbounce.utils.RotationUtils.currentRotation import net.ccbluex.liquidbounce.utils.RotationUtils.getVectorForRotation -import net.ccbluex.liquidbounce.utils.RotationUtils.limitAngleChange import net.ccbluex.liquidbounce.utils.RotationUtils.performRayTrace +import net.ccbluex.liquidbounce.utils.RotationUtils.performRaytrace import net.ccbluex.liquidbounce.utils.RotationUtils.setTargetRotation import net.ccbluex.liquidbounce.utils.RotationUtils.toRotation import net.ccbluex.liquidbounce.utils.block.BlockUtils.getBlock import net.ccbluex.liquidbounce.utils.extensions.* import net.ccbluex.liquidbounce.utils.inventory.InventoryUtils.serverOpenContainer -import net.ccbluex.liquidbounce.utils.misc.RandomUtils.nextFloat import net.ccbluex.liquidbounce.utils.misc.StringUtils.contains import net.ccbluex.liquidbounce.utils.realX import net.ccbluex.liquidbounce.utils.realY @@ -89,15 +87,28 @@ object ChestAura : Module("ChestAura", ModuleCategory.WORLD) { private val rotations by BoolValue("Rotations", true) private val silentRotation by BoolValue("SilentRotation", true) { rotations } - private val maxTurnSpeedValue: FloatValue = object : FloatValue("MaxTurnSpeed", 120f, 0f..180f) { - override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtLeast(minTurnSpeed) + + // Turn Speed + private val maxHorizontalSpeedValue = object : FloatValue("MaxHorizontalSpeed", 180f, 1f..180f) { + override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtLeast(minHorizontalSpeed) override fun isSupported() = rotations + + } + 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() && rotations } - private val maxTurnSpeed by maxTurnSpeedValue - private val minTurnSpeed by object : FloatValue("MinTurnSpeed", 80f, 0f..180f) { - override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtMost(maxTurnSpeed) - override fun isSupported() = !maxTurnSpeedValue.isMinimal() && rotations + 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() && rotations } private val strafe by ListValue("Strafe", arrayOf("Off", "Strict", "Silent"), "Off") { silentRotation && rotations } private val smootherMode by ListValue("SmootherMode", arrayOf("Linear", "Relative"), "Relative") { rotations } @@ -129,22 +140,21 @@ object ChestAura : Module("ChestAura", ModuleCategory.WORLD) { @EventTarget fun onMotion(event: MotionEvent) { - if (Blink.handleEvents() || KillAura.isBlockingChestAura || event.eventState != EventState.POST || !timer.hasTimePassed(delay)) + if (Blink.handleEvents() || KillAura.isBlockingChestAura || event.eventState != EventState.POST || !timer.hasTimePassed( + delay + )) return val thePlayer = mc.thePlayer ?: return // Check if there is an opponent in range if (mc.theWorld.loadedEntityList.any { - isSelected(it, true) && thePlayer.getDistanceSqToEntity(it) < minDistanceFromOpponentSq - }) return + isSelected(it, true) && thePlayer.getDistanceSqToEntity(it) < minDistanceFromOpponentSq + }) return if (serverOpenContainer && tileTarget != null) { timer.reset() - if (rotations && silentRotation) - RotationUtils.keepLength = RotationUtils.keepLength.coerceAtLeast(keepRotation) - return } @@ -153,7 +163,10 @@ object ChestAura : Module("ChestAura", ModuleCategory.WORLD) { val pointsInRange = mc.theWorld.tickableTileEntities // Check if tile entity is correct type, not already clicked, not blocked by a block and in range .filter { - shouldClickTileEntity(it) && it.getDistanceSq(thePlayer.posX, thePlayer.posY, thePlayer.posZ) <= searchRadiusSq + shouldClickTileEntity(it) && it.getDistanceSq(thePlayer.posX, + thePlayer.posY, + thePlayer.posZ + ) <= searchRadiusSq }.flatMap { entity -> val box = entity.blockType.getSelectedBoundingBox(mc.theWorld, entity.pos) @@ -194,39 +207,17 @@ object ChestAura : Module("ChestAura", ModuleCategory.WORLD) { tileTarget = closestClickable - var (vec, entity) = closestClickable - if (rotations) { - val limitedRotation = limitAngleChange( - currentRotation ?: thePlayer.rotation, - toRotation(vec), - nextFloat(minTurnSpeed, maxTurnSpeed) - ).fixedSensitivity() - - if (silentRotation) - setTargetRotation( - limitedRotation, - keepRotation, - strafe = strafe != "Off", - strict = strafe == "Strict", - resetSpeed = minTurnSpeed to maxTurnSpeed, - angleThresholdForReset = angleThresholdUntilReset, - smootherMode - ) - else limitedRotation.toPlayer(thePlayer) - - vec = eyes + getVectorForRotation(limitedRotation) * range.toDouble() - } - - performRayTrace(entity.pos, vec)?.run { - TickScheduler += { - if (thePlayer.onPlayerRightClick(blockPos, sideHit, hitVec)) { - if (visualSwing) thePlayer.swingItem() - else sendPacket(C0APacketAnimation()) - - timer.reset() - } - } + setTargetRotation( + toRotation(closestClickable.first), + keepRotation, + !(!silentRotation || strafe == "Off"), + strafe == "Strict", + !silentRotation, + minHorizontalSpeed..maxHorizontalSpeed to minVerticalSpeed..maxVerticalSpeed, + angleThresholdUntilReset, + smootherMode, + ) } } @@ -306,7 +297,7 @@ object ChestAura : Module("ChestAura", ModuleCategory.WORLD) { val actionMsg = if (packet.data2 == 1) "§a§lOpened§3" else "§c§lClosed§3" val timeTakenMsg = if (packet.data2 == 0 && prevTime != null) ", took §b${decimalFormat.format((System.currentTimeMillis() - prevTime) / 1000.0)} s§3" - else "" + else "" val playerMsg = if (player == mc.thePlayer) actionMsg else "§b${player.name} §3${actionMsg.lowercase()}" displayChatMessage("§8[§9§lChestAura§8] $playerMsg chest from §b$distance m§3$timeTakenMsg.") @@ -341,6 +332,44 @@ object ChestAura : Module("ChestAura", ModuleCategory.WORLD) { } } + @EventTarget + fun onTick(event: TickEvent) { + val player = mc.thePlayer ?: return + val target = tileTarget ?: return + + val rotationToUse = if (rotations) { + currentRotation ?: return + } else toRotation(target.first) + + val distance = sqrt(target.third) + + if (distance <= range) { + val pos = target.second.pos + + val rotationVec = getVectorForRotation(rotationToUse) * mc.playerController.blockReachDistance.toDouble() + + val visibleResult = performRayTrace(pos, rotationVec) + val invisibleResult = performRaytrace(pos, rotationToUse) + + val resultToUse = if (visibleResult?.blockPos == pos) { + visibleResult + } else { + if (invisibleResult?.blockPos == pos) { + invisibleResult + } else null + } + + resultToUse?.run { + if (player.onPlayerRightClick(blockPos, sideHit, hitVec)) { + if (visualSwing) player.swingItem() + else sendPacket(C0APacketAnimation()) + + timer.reset() + } + } + } + } + private fun shouldClickTileEntity(entity: TileEntity): Boolean { // Check if entity hasn't been clicked already if (entity in clickedTileEntities) return false diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/CivBreak.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/CivBreak.kt index 80dba885c2b..057b3901b9f 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/CivBreak.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/CivBreak.kt @@ -10,14 +10,10 @@ import net.ccbluex.liquidbounce.features.module.Module import net.ccbluex.liquidbounce.features.module.ModuleCategory import net.ccbluex.liquidbounce.utils.PacketUtils.sendPacket import net.ccbluex.liquidbounce.utils.PacketUtils.sendPackets -import net.ccbluex.liquidbounce.utils.RotationUtils.currentRotation import net.ccbluex.liquidbounce.utils.RotationUtils.faceBlock -import net.ccbluex.liquidbounce.utils.RotationUtils.limitAngleChange import net.ccbluex.liquidbounce.utils.RotationUtils.setTargetRotation import net.ccbluex.liquidbounce.utils.block.BlockUtils.getBlock import net.ccbluex.liquidbounce.utils.block.BlockUtils.getCenterDistance -import net.ccbluex.liquidbounce.utils.extensions.rotation -import net.ccbluex.liquidbounce.utils.misc.RandomUtils.nextFloat import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawBlockBox import net.ccbluex.liquidbounce.value.BoolValue import net.ccbluex.liquidbounce.value.FloatValue @@ -41,17 +37,26 @@ object CivBreak : Module("CivBreak", ModuleCategory.WORLD) { private val strafe by ListValue("Strafe", arrayOf("Off", "Strict", "Silent"), "Off") { rotations } private val smootherMode by ListValue("SmootherMode", arrayOf("Linear", "Relative"), "Relative") { rotations } - 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() = rotations + } - 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() && rotations + } + + private val maxVerticalSpeedValue = object : FloatValue("MaxVerticalSpeed", 180f, 1f..180f) { + override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtLeast(minVerticalSpeed) + } + private val maxVerticalSpeed by maxVerticalSpeedValue - override fun isSupported() = !maxTurnSpeedValue.isMinimal() && rotations + 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() && rotations } private val angleThresholdUntilReset by FloatValue("AngleThresholdUntilReset", 5f, 0.1f..180f) { rotations } @@ -77,8 +82,6 @@ object CivBreak : Module("CivBreak", ModuleCategory.WORLD) { @EventTarget fun onMotion(event: MotionEvent) { - val player = mc.thePlayer ?: return - if (event.eventState != EventState.POST) { return } @@ -94,20 +97,13 @@ object CivBreak : Module("CivBreak", ModuleCategory.WORLD) { if (rotations) { val spot = faceBlock(pos) ?: return - val limitedRotation = limitAngleChange( - currentRotation ?: player.rotation, - spot.rotation, - nextFloat(minTurnSpeed, maxTurnSpeed), - smootherMode - ) - setTargetRotation( - limitedRotation, + spot.rotation, strafe = strafe != "Off", strict = strafe == "Strict", - resetSpeed = minTurnSpeed to maxTurnSpeed, + turnSpeed = minHorizontalSpeed..maxHorizontalSpeed to minVerticalSpeed..maxVerticalSpeed, angleThresholdForReset = angleThresholdUntilReset, - smootherMode = this.smootherMode + smootherMode = smootherMode, ) } } diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Fucker.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Fucker.kt index 7f6157a4381..62605606370 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Fucker.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Fucker.kt @@ -13,7 +13,6 @@ import net.ccbluex.liquidbounce.features.module.modules.player.AutoTool import net.ccbluex.liquidbounce.utils.PacketUtils.sendPacket import net.ccbluex.liquidbounce.utils.RotationUtils.currentRotation import net.ccbluex.liquidbounce.utils.RotationUtils.faceBlock -import net.ccbluex.liquidbounce.utils.RotationUtils.limitAngleChange import net.ccbluex.liquidbounce.utils.RotationUtils.performRaytrace import net.ccbluex.liquidbounce.utils.RotationUtils.setTargetRotation import net.ccbluex.liquidbounce.utils.RotationUtils.toRotation @@ -22,7 +21,6 @@ import net.ccbluex.liquidbounce.utils.block.BlockUtils.getBlockName import net.ccbluex.liquidbounce.utils.block.BlockUtils.getCenterDistance import net.ccbluex.liquidbounce.utils.block.BlockUtils.isFullBlock import net.ccbluex.liquidbounce.utils.extensions.* -import net.ccbluex.liquidbounce.utils.misc.RandomUtils.nextFloat import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawBlockBox import net.ccbluex.liquidbounce.utils.timing.MSTimer import net.ccbluex.liquidbounce.value.* @@ -58,16 +56,27 @@ object Fucker : Module("Fucker", ModuleCategory.WORLD, hideModule = false) { private val rotations by BoolValue("Rotations", true) private val strafe by ListValue("Strafe", arrayOf("Off", "Strict", "Silent"), "Off") { rotations } private val smootherMode by ListValue("SmootherMode", arrayOf("Linear", "Relative"), "Relative") { rotations } - 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() = rotations + } + private val maxHorizontalSpeed by maxHorizontalSpeedValue - private val maxTurnSpeed by maxTurnSpeedValue + 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() && rotations + } + + 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 minTurnSpeed by object : FloatValue("MinTurnSpeed", 80f, 0f..180f) { - override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceAtMost(maxTurnSpeed) - override fun isSupported() = !maxTurnSpeedValue.isMinimal() && rotations + 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() && rotations } private val angleThresholdUntilReset by FloatValue("AngleThresholdUntilReset", 5f, 0.1f..180f) { rotations } @@ -160,20 +169,13 @@ object Fucker : Module("Fucker", ModuleCategory.WORLD, hideModule = false) { // Face block if (rotations) { - val limitedRotation = limitAngleChange( - currentRotation ?: player.rotation, - spot.rotation, - nextFloat(minTurnSpeed, maxTurnSpeed), - smootherMode - ) - setTargetRotation( - limitedRotation, + spot.rotation, strafe = strafe != "Off", strict = strafe == "Strict", - resetSpeed = minTurnSpeed to maxTurnSpeed, + turnSpeed = minHorizontalSpeed..maxHorizontalSpeed to minVerticalSpeed..maxVerticalSpeed, angleThresholdForReset = angleThresholdUntilReset, - smootherMode = this.smootherMode + smootherMode = smootherMode, ) } } diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Nuker.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Nuker.kt index ad9242d7f06..038d048ff04 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Nuker.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Nuker.kt @@ -49,7 +49,7 @@ object Nuker : Module("Nuker", ModuleCategory.WORLD, gameDetecting = false, hide private val priority by ListValue("Priority", arrayOf("Distance", "Hardness"), "Distance") private val rotations by BoolValue("Rotations", true) - private val strafe by ListValue("Strafe", arrayOf("Off", "Strict", "Silent"), "Off") { rotations } + private val strafe by ListValue("Strafe", arrayOf("Off", "Strict", "Silent"), "Off") { rotations } private val layer by BoolValue("Layer", false) private val hitDelay by IntegerValue("HitDelay", 4, 0..20) @@ -145,7 +145,11 @@ object Nuker : Module("Nuker", ModuleCategory.WORLD, gameDetecting = false, hide // Change head rotations to next block if (rotations) { val rotation = faceBlock(blockPos) ?: return // In case of a mistake. Prevent flag. - setTargetRotation(rotation.rotation, strafe = strafe != "Off", strict = strafe == "Strict") + setTargetRotation(rotation.rotation, + strafe = strafe != "Off", + strict = strafe == "Strict", + immediate = true + ) } // Set next target block diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Scaffold.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Scaffold.kt index cfd730cac02..eb3ba9703b7 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Scaffold.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Scaffold.kt @@ -265,14 +265,25 @@ object Scaffold : Module("Scaffold", ModuleCategory.WORLD, Keyboard.KEY_I, hideM private val minDist by FloatValue("MinDist", 0f, 0f..0.2f) { scaffoldMode !in arrayOf("GodBridge", "Telly") } // Turn Speed - private val maxTurnSpeedValue: FloatValue = 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) override fun isSupported() = rotationMode != "Off" } - private val maxTurnSpeed by maxTurnSpeedValue - private val minTurnSpeed by object : FloatValue("MinTurnSpeed", 180f, 1f..180f) { - override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceIn(minimum, maxTurnSpeed) - override fun isSupported() = !maxTurnSpeedValue.isMinimal() && rotationMode != "Off" + 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() && rotationMode != "Off" + } + + 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() && rotationMode != "Off" } private val angleThresholdUntilReset by FloatValue( @@ -530,37 +541,14 @@ object Scaffold : Module("Scaffold", ModuleCategory.WORLD, Keyboard.KEY_I, hideM update() if (rotationMode != "Off" && rotation != null) { - // Keep aiming at the target spot even if we have already placed - // Prevents rotation correcting itself after a bit of bridging - // Instead of doing it in the first place. - // Normally a rotation utils recode is needed to rotate regardless of placeRotation being null or not, but whatever. - val placeRotation = this.placeRotation?.rotation ?: rotation - - val pitch = if (scaffoldMode == "GodBridge" && useStaticRotation) { - if (placeRotation == this.placeRotation?.rotation) { - if (isLookingDiagonally) 75.6f else 73.5f - } else placeRotation.pitch - } else { - placeRotation.pitch - } - - val targetRotation = Rotation(placeRotation.yaw, pitch).fixedSensitivity() - - val limitedRotation = RotationUtils.limitAngleChange( - rotation, - targetRotation, - RandomUtils.nextFloat(minTurnSpeed, maxTurnSpeed), - smootherMode - ) - val ticks = if (keepRotation) { if (scaffoldMode == "Telly") 1 else keepTicks } else { - RotationUtils.keepLength + RotationUtils.resetTicks } - if (RotationUtils.keepLength != 0 || keepRotation) { - setRotation(limitedRotation, ticks) + if (RotationUtils.resetTicks != 0 || keepRotation) { + setRotation(rotation, ticks) } } } @@ -576,7 +564,7 @@ object Scaffold : Module("Scaffold", ModuleCategory.WORLD, Keyboard.KEY_I, hideM setTargetRotation( lockRotation!!.fixedSensitivity(), strafe = strafe, - resetSpeed = minTurnSpeed to maxTurnSpeed, + turnSpeed = minHorizontalSpeed..maxHorizontalSpeed to minVerticalSpeed..maxVerticalSpeed, smootherMode = smootherMode ) } @@ -871,7 +859,7 @@ object Scaffold : Module("Scaffold", ModuleCategory.WORLD, Keyboard.KEY_I, hideM rotation, ticks, strafe, - resetSpeed = minTurnSpeed to maxTurnSpeed, + turnSpeed = minHorizontalSpeed..maxHorizontalSpeed to minVerticalSpeed..maxVerticalSpeed, angleThresholdForReset = angleThresholdUntilReset, smootherMode = this.smootherMode ) @@ -906,9 +894,6 @@ object Scaffold : Module("Scaffold", ModuleCategory.WORLD, Keyboard.KEY_I, hideM shouldPlaceHorizontally )) ) { - /*if (mode != "GodBridge" || MathHelper.wrapAngleTo180_float(currRotation.yaw.toInt().toFloat()) in arrayOf(-135f, -45f, 45f, 135f)) { - placeRotation = null - }*/ return } @@ -1297,14 +1282,7 @@ object Scaffold : Module("Scaffold", ModuleCategory.WORLD, Keyboard.KEY_I, hideM } } - val limitedRotation = RotationUtils.limitAngleChange( - currRotation, - targetRotation, - RandomUtils.nextFloat(minTurnSpeed, maxTurnSpeed), - smootherMode - ) - - setRotation(limitedRotation, if (scaffoldMode == "Telly") 1 else keepTicks) + setRotation(targetRotation, if (scaffoldMode == "Telly") 1 else keepTicks) } this.placeRotation = placeRotation return true @@ -1577,6 +1555,10 @@ object Scaffold : Module("Scaffold", ModuleCategory.WORLD, Keyboard.KEY_I, hideM updatePlacedBlocksForTelly() + if (clickPos == placeRotation?.placeInfo?.blockPos) { + placeRotation = null + } + if (stack.stackSize <= 0) { thePlayer.inventory.mainInventory[serverSlot] = null ForgeEventFactory.onPlayerDestroyItem(thePlayer, stack) diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/client/MixinMinecraft.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/client/MixinMinecraft.java index 99f990093a5..cb232246022 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/client/MixinMinecraft.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/client/MixinMinecraft.java @@ -217,11 +217,13 @@ private void shutdown(CallbackInfo callbackInfo) { @Inject(method = "clickMouse", at = @At("HEAD")) private void clickMouse(CallbackInfo callbackInfo) { - CPSCounter.INSTANCE.registerClick(CPSCounter.MouseButton.LEFT); - if (AutoClicker.INSTANCE.handleEvents()) { leftClickCounter = 0; } + + if (leftClickCounter <= 0) { + CPSCounter.INSTANCE.registerClick(CPSCounter.MouseButton.LEFT); + } } @Inject(method = "middleClickMouse", at = @At("HEAD")) diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntityLivingBase.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntityLivingBase.java index 773b811bb53..f52f83e8b01 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntityLivingBase.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntityLivingBase.java @@ -87,7 +87,8 @@ protected void jump() { final RotationUtils rotationUtils = RotationUtils.INSTANCE; final Rotation currentRotation = rotationUtils.getCurrentRotation(); - if (currentRotation != null && rotationUtils.getStrafe()) { + final RotationUtils.RotationData rotationData = rotationUtils.getRotationData(); + if (currentRotation != null && rotationData != null && rotationData.getStrafe()) { fixedYaw = currentRotation.getYaw(); } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinNetHandlerPlayClient.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinNetHandlerPlayClient.java index 941bc838630..a65ebe83d94 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinNetHandlerPlayClient.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinNetHandlerPlayClient.java @@ -36,7 +36,6 @@ import net.minecraft.network.play.server.*; import net.minecraft.util.MathHelper; import net.minecraft.world.WorldSettings; -import org.apache.commons.lang3.tuple.MutableTriple; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -220,7 +219,7 @@ private void injectNoRotateSetAndAntiServerRotationOverride(NetworkManager insta Rotation currentRotation = RotationUtils.INSTANCE.getCurrentRotation(); if (currentRotation != null && module.getAffectServerRotation()) { - RotationUtils.INSTANCE.setSetbackRotation(new MutableTriple<>(PlayerExtensionKt.getRotation(player), true, currentRotation)); + NoRotateSet.INSTANCE.rotateBackToPlayerRotation(); } // Slightly modify the client-side rotations, so they pass the rotation difference check in onUpdateWalkingPlayer, EntityPlayerSP. diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/RotationUtils.kt b/src/main/java/net/ccbluex/liquidbounce/utils/RotationUtils.kt index aec75dcf575..ddf533a4264 100644 --- a/src/main/java/net/ccbluex/liquidbounce/utils/RotationUtils.kt +++ b/src/main/java/net/ccbluex/liquidbounce/utils/RotationUtils.kt @@ -9,12 +9,11 @@ import net.ccbluex.liquidbounce.event.* import net.ccbluex.liquidbounce.features.module.modules.combat.FastBow import net.ccbluex.liquidbounce.utils.RaycastUtils.raycastEntity import net.ccbluex.liquidbounce.utils.extensions.* -import net.ccbluex.liquidbounce.utils.misc.RandomUtils +import net.ccbluex.liquidbounce.utils.inventory.InventoryUtils import net.ccbluex.liquidbounce.utils.misc.RandomUtils.nextDouble import net.minecraft.entity.Entity import net.minecraft.network.play.client.C03PacketPlayer import net.minecraft.util.* -import org.apache.commons.lang3.tuple.MutableTriple import java.security.SecureRandom import java.util.* import kotlin.math.* @@ -24,104 +23,16 @@ object RotationUtils : MinecraftInstance(), Listenable { private val secureRandom = SecureRandom() private var currentSpot = Vec3(0.0, 0.0, 0.0) - /** - * Handle minecraft tick - * - * @param event Update event - */ - @EventTarget(priority = 1) - fun onTick(event: TickEvent) { - currentRotation?.let { rotation -> - setbackRotation?.let { - if (it.middle) { - currentRotation = it.left - it.setMiddle(false) - return - } - - val sign = if (random.nextBoolean()) 1 else -1 - - rotation.yaw = (it.right.yaw + 0.000001f * sign) % 360f - rotation.pitch = (it.right.pitch + 0.000001f * sign) % 360f - setbackRotation = null - return - } - - if (keepLength > 0) { - keepLength-- - } else { - if (getRotationDifference(rotation, mc.thePlayer.rotation) <= angleThresholdForReset) { - resetRotation() - } else { - val speed = RandomUtils.nextFloat(speedForReset.first, speedForReset.second) - currentRotation = limitAngleChange(rotation, - mc.thePlayer.rotation, - speed, - smoothMode?.name ?: "Linear" - ).fixedSensitivity() - } - } - } - } - - /** - * Handle strafing - */ - @EventTarget - fun onStrafe(event: StrafeEvent) { - if (!strafe) { - return - } - - currentRotation?.let { - it.applyStrafeToPlayer(event, strict) - event.cancelEvent() - } - } - - /** - * Handle packet - * - * @param event Packet Event - */ - @EventTarget - fun onPacket(event: PacketEvent) { - val packet = event.packet - - if (packet !is C03PacketPlayer || !packet.rotating) { - return - } - - currentRotation?.let { - packet.yaw = it.yaw - packet.pitch = it.pitch - } - - serverRotation = Rotation(packet.yaw, packet.pitch) - } - - /** - * @return YESSSS! - */ - override fun handleEvents() = true - - var keepLength = 0 - - var strafe = false - var strict = false + private val random = Random() - private var speedForReset = 0f to 0f - private var angleThresholdForReset = 0f + private var targetRotation: Rotation? = null var currentRotation: Rotation? = null var serverRotation = Rotation(0f, 0f) - private var smoothMode: SmootherMode? = null - - // (The priority, the active check and the original rotation) - var setbackRotation: MutableTriple? = null + var rotationData: RotationData? = null - private val random = Random() + var resetTicks = 0 private fun findNextAimSpot() { val nextSpot = currentSpot.add( @@ -425,24 +336,50 @@ object RotationUtils : MinecraftInstance(), Listenable { targetRotation: Rotation, turnSpeed: Float, smootherMode: String = "Linear", + ): Rotation { + return limitAngleChange(currentRotation, targetRotation, turnSpeed..turnSpeed, smootherMode = smootherMode) + } + + fun limitAngleChange( + currentRotation: Rotation, + targetRotation: Rotation, + hSpeed: ClosedFloatingPointRange, + vSpeed: ClosedFloatingPointRange = hSpeed, + smootherMode: String = "Linear", ): Rotation { chooseSmootherMode(smootherMode) - return if (smoothMode == SmootherMode.LINEAR) { - linearAngleChange(currentRotation, targetRotation, turnSpeed) + return if (rotationData?.smootherMode == SmootherMode.LINEAR) { + linearAngleChange(currentRotation, targetRotation, hSpeed, vSpeed) } else { - relativeAngleChange(currentRotation, targetRotation, turnSpeed) + relativeAngleChange(currentRotation, targetRotation, hSpeed, vSpeed) } } - private fun linearAngleChange(currentRotation: Rotation, targetRotation: Rotation, turnSpeed: Float): Rotation { + fun limitAngleChange( + currentRotation: Rotation, + targetRotation: Rotation, + rotationData: RotationData, + ): Rotation { + return limitAngleChange(currentRotation, + targetRotation, + rotationData.hSpeed, + rotationData.vSpeed, + rotationData.smootherMode.modeName + ) + } + + private fun linearAngleChange( + currentRotation: Rotation, targetRotation: Rotation, hSpeed: ClosedFloatingPointRange, + vSpeed: ClosedFloatingPointRange, + ): Rotation { val yawDifference = getAngleDifference(targetRotation.yaw, currentRotation.yaw) val pitchDifference = getAngleDifference(targetRotation.pitch, currentRotation.pitch) val rotationDifference = hypot(yawDifference, pitchDifference) - val straightLineYaw = abs(yawDifference / rotationDifference) * turnSpeed - val straightLinePitch = abs(pitchDifference / rotationDifference) * turnSpeed + val straightLineYaw = abs(yawDifference / rotationDifference) * hSpeed.random() + val straightLinePitch = abs(pitchDifference / rotationDifference) * vSpeed.random() return Rotation( currentRotation.yaw + yawDifference.coerceIn(-straightLineYaw, straightLineYaw), @@ -450,16 +387,20 @@ object RotationUtils : MinecraftInstance(), Listenable { ) } - private fun relativeAngleChange(currentRotation: Rotation, targetRotation: Rotation, turnSpeed: Float): Rotation { + private fun relativeAngleChange( + currentRotation: Rotation, targetRotation: Rotation, + hSpeed: ClosedFloatingPointRange, vSpeed: ClosedFloatingPointRange, + ): Rotation { val yawDifference = getAngleDifference(targetRotation.yaw, currentRotation.yaw) val pitchDifference = getAngleDifference(targetRotation.pitch, currentRotation.pitch) val rotationDifference = hypot(yawDifference, pitchDifference) - val factor = computeFactor(rotationDifference, turnSpeed) + val (hFactor, vFactor) = + computeFactor(rotationDifference, hSpeed.random()) to computeFactor(rotationDifference, vSpeed.random()) - val straightLineYaw = abs(yawDifference / rotationDifference) * factor - val straightLinePitch = abs(pitchDifference / rotationDifference) * factor + val straightLineYaw = abs(yawDifference / rotationDifference) * hFactor + val straightLinePitch = abs(pitchDifference / rotationDifference) * vFactor return Rotation( currentRotation.yaw + yawDifference.coerceIn(-straightLineYaw, straightLineYaw), @@ -468,13 +409,13 @@ object RotationUtils : MinecraftInstance(), Listenable { } private fun computeFactor(rotationDifference: Float, turnSpeed: Float): Float { - return (rotationDifference / 180 * turnSpeed) - .coerceAtMost(180f) - .coerceAtLeast((4f..6f).random().toFloat()) + return (rotationDifference / 120 * turnSpeed).coerceAtMost(180f).coerceAtLeast((4f..6f).random()) } private fun chooseSmootherMode(mode: String) { - smoothMode = if (mode == "Linear") SmootherMode.LINEAR else SmootherMode.RELATIVE + val data = rotationData ?: return + + data.smootherMode = if (mode == "Linear") SmootherMode.LINEAR else SmootherMode.RELATIVE } /** @@ -544,34 +485,53 @@ object RotationUtils : MinecraftInstance(), Listenable { keepLength: Int = 1, strafe: Boolean = false, strict: Boolean = false, - resetSpeed: Pair = 180f to 180f, + applyClientSide: Boolean = false, + turnSpeed: Pair, ClosedFloatingPointRange> = 180f..180f to 180f..180f, angleThresholdForReset: Float = 180f, smootherMode: String = "Linear", + immediate: Boolean = false, + prioritizeRequest: Boolean = false, ) { - if (rotation.yaw.isNaN() || rotation.pitch.isNaN() || rotation.pitch > 90 || rotation.pitch < -90) return + if (rotation.yaw.isNaN() || rotation.pitch.isNaN() || rotation.pitch > 90 || rotation.pitch < -90) { + return + } + + if (!prioritizeRequest && rotationData?.prioritizeRequest == true) { + return + } + + targetRotation = rotation + + rotationData = RotationData( + turnSpeed.first, + turnSpeed.second, + SmootherMode.values().first { it.modeName == smootherMode }, + strafe, + strict, + applyClientSide, + immediate, + angleThresholdForReset, + prioritizeRequest + ) - currentRotation = rotation.fixedSensitivity() + this.resetTicks = if (applyClientSide) 1 else keepLength - this.strafe = strafe - this.strict = strict - this.keepLength = keepLength - this.speedForReset = resetSpeed - this.angleThresholdForReset = angleThresholdForReset - this.smoothMode = SmootherMode.values().first { it.modeName == smootherMode } + if (immediate) { + update() + } } private fun resetRotation() { - keepLength = 0 + resetTicks = 0 currentRotation?.let { rotation -> mc.thePlayer?.let { it.rotationYaw = rotation.yaw + getAngleDifference(it.rotationYaw, rotation.yaw) syncRotations() } } - smoothMode = null + targetRotation = null currentRotation = null - strafe = false - strict = false + rotationData = null } /** @@ -621,5 +581,112 @@ object RotationUtils : MinecraftInstance(), Listenable { player.prevRotationPitch = player.rotationPitch } + private fun update() { + val data = rotationData ?: return + val player = mc.thePlayer ?: return + + val playerRotation = player.rotation + + if (resetTicks == 0) { + val distanceToPlayerRotation = getRotationDifference(currentRotation ?: serverRotation, playerRotation) + + if (distanceToPlayerRotation <= data.resetThreshold || data.clientSide) { + resetRotation() + return + } + + currentRotation = limitAngleChange(currentRotation ?: serverRotation, + playerRotation, + data + ).fixedSensitivity() + return + } + + val shouldUpdate = !InventoryUtils.serverOpenContainer + + if (!shouldUpdate) { + return + } + + targetRotation?.let { + limitAngleChange(currentRotation ?: playerRotation, it, data).let { rotation -> + if (data.clientSide) { + rotation.toPlayer(player) + } else { + currentRotation = rotation.fixedSensitivity() + } + } + } + + if (resetTicks > 0) { + resetTicks-- + } + } + + @EventTarget(priority = -1) + fun onMotion(event: MotionEvent) { + if (event.eventState != EventState.POST) { + return + } + + rotationData?.let { + // Was the rotation update immediate? Allow updates the next tick. + if (it.immediate) { + it.immediate = false + return + } + } + + update() + } + + /** + * Handle strafing + */ + @EventTarget + fun onStrafe(event: StrafeEvent) { + val data = rotationData ?: return + + if (!data.strafe) { + return + } + + currentRotation?.let { + it.applyStrafeToPlayer(event, data.strict) + event.cancelEvent() + } + } + + /** + * Handle rotation-packet modification + */ + @EventTarget + fun onPacket(event: PacketEvent) { + val packet = event.packet + + if (packet !is C03PacketPlayer || !packet.rotating) { + return + } + + currentRotation?.let { + packet.yaw = it.yaw + packet.pitch = it.pitch + } + + serverRotation = Rotation(packet.yaw, packet.pitch) + } + enum class SmootherMode(val modeName: String) { LINEAR("Linear"), RELATIVE("Relative") } + + data class RotationData( + var hSpeed: ClosedFloatingPointRange, var vSpeed: ClosedFloatingPointRange, + var smootherMode: SmootherMode, var strafe: Boolean, var strict: Boolean, var clientSide: Boolean, + var immediate: Boolean, var resetThreshold: Float, val prioritizeRequest: Boolean, + ) + + /** + * @return YESSSS! + */ + override fun handleEvents() = true + } diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/extensions/MathExtensions.kt b/src/main/java/net/ccbluex/liquidbounce/utils/extensions/MathExtensions.kt index 604391e7be0..339b3d14f90 100644 --- a/src/main/java/net/ccbluex/liquidbounce/utils/extensions/MathExtensions.kt +++ b/src/main/java/net/ccbluex/liquidbounce/utils/extensions/MathExtensions.kt @@ -91,10 +91,10 @@ class RangeIterator( operator fun ClosedFloatingPointRange.iterator() = RangeIterator(this) infix fun ClosedFloatingPointRange.step(step: Double) = RangeIterator(this, step) -fun ClosedFloatingPointRange.random(): Double { +fun ClosedFloatingPointRange.random(): Float { require(start.isFinite()) require(endInclusive.isFinite()) - return start + (endInclusive - start) * Math.random() + return (start + (endInclusive - start) * Math.random()).toFloat() } /**