Skip to content

Commit

Permalink
chore(legacy): Min/Max variables replaced with ranged values. (CCBlue…
Browse files Browse the repository at this point in the history
…X#5374)

Should free up like 2% of screen space.
  • Loading branch information
mems01 authored Jan 19, 2025
1 parent dc71714 commit 0ab0d2b
Show file tree
Hide file tree
Showing 20 changed files with 118 additions and 450 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/
package net.ccbluex.liquidbounce.features.module.modules.combat

import net.ccbluex.liquidbounce.config.Value
import net.ccbluex.liquidbounce.event.EventState
import net.ccbluex.liquidbounce.event.MotionEvent
import net.ccbluex.liquidbounce.event.handler
Expand Down Expand Up @@ -68,17 +67,7 @@ object Aimbot : Module("Aimbot", Category.COMBAT) {

private val lowestBodyPointToTarget: String by lowestBodyPointToTargetValue

private val maxHorizontalBodySearch: Value<Float> = float("MaxHorizontalBodySearch", 1f, 0f..1f) {
horizontalAim
}.onChange { _, new ->
new.coerceAtLeast(minHorizontalBodySearch.get())
}

private val minHorizontalBodySearch: Value<Float> = float("MinHorizontalBodySearch", 0f, 0f..1f) {
horizontalAim
}.onChange { _, new ->
new.coerceAtMost(maxHorizontalBodySearch.get())
}
private val horizontalBodySearchRange by floatRange("HorizontalBodySearchRange", 0f..1f, 0f..1f) { horizontalAim }

private val minRotationDifference by float("MinRotationDifference", 0f, 0f..2f) { verticalAim || horizontalAim }

Expand Down Expand Up @@ -174,7 +163,7 @@ object Aimbot : Module("Aimbot", Category.COMBAT) {
lookRange = range,
attackRange = if (Reach.handleEvents()) Reach.combatReach else 3f,
bodyPoints = listOf(highestBodyPointToTarget, lowestBodyPointToTarget),
horizontalSearch = minHorizontalBodySearch.get()..maxHorizontalBodySearch.get(),
horizontalSearch = horizontalBodySearchRange
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,13 @@ import net.ccbluex.liquidbounce.utils.timing.TickedActions.awaitTicked
import net.ccbluex.liquidbounce.utils.timing.TickedActions.clickNextTick
import net.ccbluex.liquidbounce.utils.timing.TickedActions.isTicked
import net.ccbluex.liquidbounce.utils.timing.TickedActions.nextTick
import net.ccbluex.liquidbounce.utils.timing.TimeUtils.randomDelay
import net.minecraft.client.gui.inventory.GuiInventory
import net.minecraft.entity.EntityLiving.getArmorPosition
import net.minecraft.item.ItemStack
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement

object AutoArmor : Module("AutoArmor", Category.COMBAT) {
private val maxDelay: Int by int("MaxDelay", 50, 0..500).onChange { _, new ->
new.coerceAtLeast(minDelay)
}
private val minDelay: Int by int("MinDelay", 50, 0..500).onChange { _, new ->
new.coerceAtMost(maxDelay)
}
private val delay by intRange("Delay", 50..50, 0..1000)
private val minItemAge by int("MinItemAge", 0, 0..2000)

private val invOpen by +InventoryManager.invOpenValue
Expand Down Expand Up @@ -134,12 +128,11 @@ object AutoArmor : Module("AutoArmor", Category.COMBAT) {
nextTick(action = equippingAction)

if (delayedSlotSwitch) {
delay(randomDelay(minDelay, maxDelay).toLong())
delay(delay.random().toLong())
}
}

// Not really needed to bypass
delay(randomDelay(minDelay, maxDelay).toLong())
delay(delay.random().toLong())

awaitTicked()

Expand Down Expand Up @@ -303,6 +296,6 @@ object AutoArmor : Module("AutoArmor", Category.COMBAT) {

hasScheduledInLastLoop = true

delay(randomDelay(minDelay, maxDelay).toLong())
delay(delay.random().toLong())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,7 @@ import kotlin.random.Random.Default.nextBoolean
object AutoClicker : Module("AutoClicker", Category.COMBAT) {

private val simulateDoubleClicking by boolean("SimulateDoubleClicking", false)

private val maxCPS: Int by int("MaxCPS", 8, 1..20).onChange { _, new ->
new.coerceAtLeast(minCPS)
}

private val minCPS: Int by int("MinCPS", 5, 1..20).onChange { _, new ->
new.coerceAtMost(maxCPS)
}
private val cps by intRange("CPS", 5..8, 1..50)

private val hurtTime by int("HurtTime", 10, 0..10) { left }

Expand All @@ -54,9 +47,9 @@ object AutoClicker : Module("AutoClicker", Category.COMBAT) {

private val onlyBlocks by boolean("OnlyBlocks", true) { right }

private var rightDelay = randomClickDelay(minCPS, maxCPS)
private var rightDelay = generateNewClickTime()
private var rightLastSwing = 0L
private var leftDelay = randomClickDelay(minCPS, maxCPS)
private var leftDelay = generateNewClickTime()
private var leftLastSwing = 0L

private var lastBlocking = 0L
Expand Down Expand Up @@ -152,7 +145,7 @@ object AutoClicker : Module("AutoClicker", Category.COMBAT) {
KeyBinding.onTick(mc.gameSettings.keyBindAttack.keyCode)

leftLastSwing = time
leftDelay = randomClickDelay(minCPS, maxCPS)
leftDelay = generateNewClickTime()
}
}

Expand All @@ -161,7 +154,7 @@ object AutoClicker : Module("AutoClicker", Category.COMBAT) {
KeyBinding.onTick(mc.gameSettings.keyBindUseItem.keyCode)

rightLastSwing = time
rightDelay = randomClickDelay(minCPS, maxCPS)
rightDelay = generateNewClickTime()
}
}

Expand All @@ -172,4 +165,6 @@ object AutoClicker : Module("AutoClicker", Category.COMBAT) {
lastBlocking = time
}
}

fun generateNewClickTime() = randomClickDelay(cps.first, cps.last)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
*/
package net.ccbluex.liquidbounce.features.module.modules.combat

import net.ccbluex.liquidbounce.config.Value
import net.ccbluex.liquidbounce.event.UpdateEvent
import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.utils.attack.EntityUtils.isSelected
import net.ccbluex.liquidbounce.utils.inventory.InventoryUtils
import net.ccbluex.liquidbounce.utils.inventory.hotBarSlot
import net.ccbluex.liquidbounce.utils.kotlin.RandomUtils
import net.ccbluex.liquidbounce.utils.rotation.RaycastUtils.raycastEntity
import net.ccbluex.liquidbounce.utils.timing.MSTimer
import net.minecraft.init.Items.egg
Expand All @@ -22,21 +20,8 @@ import net.minecraft.init.Items.snowball
object AutoProjectile : Module("AutoProjectile", Category.COMBAT) {
private val facingEnemy by boolean("FacingEnemy", true)

private val mode by choices("Mode", arrayOf("Normal", "Smart"), "Normal")
private val range by float("Range", 8F, 1F..20F)
private val throwDelay by int("ThrowDelay", 1000, 50..2000) { mode != "Smart" }

private val minThrowDelay: Value<Int> = int("MinThrowDelay", 1000, 50..2000) {
mode == "Smart"
}.onChange { _, new ->
new.coerceAtMost(maxThrowDelay.get())
}

private val maxThrowDelay: Value<Int> = int("MaxThrowDelay", 1500, 50..2000) {
mode == "Smart"
}.onChange { _, new ->
new.coerceAtLeast(minThrowDelay.get())
}
private val throwDelay by intRange("ThrowDelay", 1000..1500, 50..2000)

private val switchBackDelay by int("SwitchBackDelay", 500, 50..2000)

Expand Down Expand Up @@ -84,21 +69,9 @@ object AutoProjectile : Module("AutoProjectile", Category.COMBAT) {
}

if (throwProjectile) {
if (mode == "Normal" && throwTimer.hasTimePassed(throwDelay)) {
if (player.heldItem?.item != snowball && player.heldItem?.item != egg) {
val projectile = InventoryUtils.findItemArray(36, 44, arrayOf(snowball, egg)) ?: return@handler

switchBack = player.inventory.currentItem

player.inventory.currentItem = projectile
mc.playerController.syncCurrentPlayItem()
}
val randomThrowDelay = throwDelay.random()

throwProjectile()
}

val randomThrowDelay = RandomUtils.nextInt(minThrowDelay.get(), maxThrowDelay.get())
if (mode == "Smart" && throwTimer.hasTimePassed(randomThrowDelay)) {
if (throwTimer.hasTimePassed(randomThrowDelay)) {
if (player.heldItem?.item != snowball && player.heldItem?.item != egg) {
val projectile = InventoryUtils.findItemArray(36, 44, arrayOf(snowball, egg)) ?: return@handler

Expand Down Expand Up @@ -138,10 +111,4 @@ object AutoProjectile : Module("AutoProjectile", Category.COMBAT) {
projectileInUse = false
switchBack = -1
}

/**
* HUD Tag
*/
override val tag
get() = mode
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,7 @@ object Backtrack : Module("Backtrack", Category.COMBAT) {

// Modern
private val style by choices("Style", arrayOf("Pulse", "Smooth"), "Smooth") { mode == "Modern" }

private val maxDistance: Float by float("MaxDistance", 3.0f, 0.0f..3.5f) {
mode == "Modern"
}.onChange { _, new ->
new.coerceAtLeast(minDistance)
}
private val minDistance: Float by float("MinDistance", 2.0f, 0.0f..3.0f) {
mode == "Modern"
}.onChange { _, new ->
new.coerceAtMost(maxDistance)
}
private val distance by floatRange("Distance", 2f..3f, 0f..6f) { mode == "Modern" }
private val smart by boolean("Smart", true) { mode == "Modern" }

// ESP
Expand Down Expand Up @@ -265,7 +255,7 @@ object Backtrack : Module("Backtrack", Category.COMBAT) {
) {
shouldRender = true

if (mc.thePlayer.getDistanceToEntityBox(target) in minDistance..maxDistance) {
if (mc.thePlayer.getDistanceToEntityBox(target) in distance) {
handlePackets()
} else {
handlePacketsRange()
Expand Down Expand Up @@ -505,7 +495,7 @@ object Backtrack : Module("Backtrack", Category.COMBAT) {

val targetBox = target.hitBox.offset(data.first - targetPos)

if (mc.thePlayer.getDistanceToBox(targetBox) in minDistance..maxDistance) {
if (mc.thePlayer.getDistanceToBox(targetBox) in distance) {
found = true
break
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package net.ccbluex.liquidbounce.features.module.modules.combat

import com.google.common.collect.Queues
import net.ccbluex.liquidbounce.config.Value
import net.ccbluex.liquidbounce.event.*
import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.Module
Expand Down Expand Up @@ -45,12 +44,7 @@ object FakeLag : Module("FakeLag", Category.COMBAT, gameDetecting = false) {
private val delay by int("Delay", 550, 0..1000)
private val recoilTime by int("RecoilTime", 750, 0..2000)

private val maxAllowedDistToEnemy: Value<Float> = float("MaxAllowedDistToEnemy", 3.5f, 0f..6f).onChange { _, new ->
new.coerceAtLeast(minAllowedDistToEnemy.get())
}
private val minAllowedDistToEnemy: Value<Float> = float("MinAllowedDistToEnemy", 1.5f, 0f..6f).onChange { _, new ->
new.coerceAtMost(maxAllowedDistToEnemy.get())
}
private val allowedDistToEnemy by floatRange("MinAllowedDistToEnemy", 1.5f..3.5f, 0f..6f)

private val blinkOnAction by boolean("BlinkOnAction", true)

Expand Down Expand Up @@ -80,7 +74,7 @@ object FakeLag : Module("FakeLag", Category.COMBAT, gameDetecting = false) {
val player = mc.thePlayer ?: return@handler
val packet = event.packet

if (!handleEvents() || player.isDead || event.isCancelled || maxAllowedDistToEnemy.get() > 0.0 && wasNearEnemy || ignoreWholeTick) {
if (!handleEvents() || player.isDead || event.isCancelled || allowedDistToEnemy.endInclusive > 0.0 && wasNearEnemy || ignoreWholeTick) {
return@handler
}

Expand Down Expand Up @@ -186,7 +180,7 @@ object FakeLag : Module("FakeLag", Category.COMBAT, gameDetecting = false) {
val player = mc.thePlayer ?: return@handler
val world = mc.theWorld ?: return@handler

if (maxAllowedDistToEnemy.get() > 0) {
if (allowedDistToEnemy.endInclusive > 0) {
val playerPos = player.currPos
val serverPos = positions.firstOrNull()?.pos ?: playerPos

Expand All @@ -202,12 +196,7 @@ object FakeLag : Module("FakeLag", Category.COMBAT, gameDetecting = false) {
if (entityMixin != null) {
val eyes = getTruePositionEyes(otherPlayer)

if (eyes.distanceTo(
getNearestPointBB(
eyes, playerBox
)
) in minAllowedDistToEnemy.get()..maxAllowedDistToEnemy.get()
) {
if (eyes.distanceTo(getNearestPointBB(eyes, playerBox)) in allowedDistToEnemy) {
blink()
wasNearEnemy = true
return@handler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,8 @@ object KillAura : Module("KillAura", Category.COMBAT, Keyboard.KEY_R) {
private val simulateDoubleClicking by boolean("SimulateDoubleClicking", false) { !simulateCooldown }

// CPS - Attack speed
private val maxCPSValue = int("MaxCPS", 8, 1..20) {
!simulateCooldown
}.onChange { _, new ->
new.coerceAtLeast(minCPS)
}.onChanged {
attackDelay = randomClickDelay(minCPS, it)
}

private val maxCPS by maxCPSValue

private val minCPS: Int by int("MinCPS", 5, 1..20) {
!simulateCooldown
}.onChange { _, new ->
new.coerceAtMost(maxCPS)
}.onChanged {
attackDelay = randomClickDelay(it, maxCPS)
private val cps by intRange("CPS", 5..8, 1..50) { !simulateCooldown }.onChanged {
attackDelay = randomClickDelay(it.first, it.last)
}

private val hurtTime by int("HurtTime", 10, 0..10) { !simulateCooldown }
Expand Down Expand Up @@ -257,17 +243,8 @@ object KillAura : Module("KillAura", Category.COMBAT, Keyboard.KEY_R) {

private val lowestBodyPointToTarget: String by lowestBodyPointToTargetValue

private val maxHorizontalBodySearch: Value<Float> = float("MaxHorizontalBodySearch", 1f, 0f..1f) {
options.rotationsActive
}.onChange { _, new ->
new.coerceAtLeast(minHorizontalBodySearch.get())
}

private val minHorizontalBodySearch: Value<Float> = float("MinHorizontalBodySearch", 0f, 0f..1f) {
options.rotationsActive
}.onChange { _, new ->
new.coerceAtMost(maxHorizontalBodySearch.get())
}
private val horizontalBodySearchRange by floatRange("HorizontalBodySearchRange", 0f..1f, 0f..1f)
{ options.rotationsActive }

private val fov by float("FOV", 180f, 0f..180f)

Expand Down Expand Up @@ -540,9 +517,9 @@ object KillAura : Module("KillAura", Category.COMBAT, Keyboard.KEY_R) {
target ?: return@handler

if (attackTimer.hasTimePassed(attackDelay)) {
if (maxCPS > 0) clicks++
if (cps.last > 0) clicks++
attackTimer.reset()
attackDelay = randomClickDelay(minCPS, maxCPS)
attackDelay = randomClickDelay(cps.first, cps.last)
}

val hittableColor = if (hittable) Color(37, 126, 255, 70) else Color(255, 0, 0, 70)
Expand Down Expand Up @@ -914,7 +891,7 @@ object KillAura : Module("KillAura", Category.COMBAT, Keyboard.KEY_R) {
attackRange = range,
throughWallsRange = throughWallsRange,
bodyPoints = listOf(highestBodyPointToTarget, lowestBodyPointToTarget),
horizontalSearch = minHorizontalBodySearch.get()..maxHorizontalBodySearch.get()
horizontalSearch = horizontalBodySearchRange
)

if (rotation == null) {
Expand Down
Loading

0 comments on commit 0ab0d2b

Please sign in to comment.