Skip to content

Commit

Permalink
KillAura fix + Backtrack improvements (CCBlueX#1534)
Browse files Browse the repository at this point in the history
* isEnemy check for backtrack

* Added backtrack smart mode
  • Loading branch information
yorik100 authored Nov 10, 2023
1 parent b110a7c commit 66fe361
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ import net.ccbluex.liquidbounce.event.*
import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.features.module.ModuleCategory
import net.ccbluex.liquidbounce.features.module.modules.player.Blink
import net.ccbluex.liquidbounce.features.module.modules.misc.Teams
import net.ccbluex.liquidbounce.features.module.modules.misc.AntiBot.isBot
import net.ccbluex.liquidbounce.injection.implementations.IMixinEntity
import net.ccbluex.liquidbounce.utils.*
import net.ccbluex.liquidbounce.utils.PacketUtils.handlePacket
import net.ccbluex.liquidbounce.utils.extensions.getDistanceToEntityBox
import net.ccbluex.liquidbounce.utils.extensions.isClientFriend
import net.ccbluex.liquidbounce.utils.misc.StringUtils.contains
import net.ccbluex.liquidbounce.utils.render.ColorUtils.rainbow
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawBacktrackBox
Expand Down Expand Up @@ -58,6 +61,7 @@ object Backtrack : Module("Backtrack", ModuleCategory.COMBAT) {
override fun onChange(oldValue: Float, newValue: Float) = newValue.coerceIn(minimum, maxDistance)
override fun isSupported() = mode == "Modern"
}
private val smart by BoolValue("Smart", true) { mode == "Modern" }

// ESP
private val rainbow by BoolValue("Rainbow", true) { mode == "Modern" }
Expand Down Expand Up @@ -235,13 +239,12 @@ object Backtrack : Module("Backtrack", ModuleCategory.COMBAT) {
if (mode != "Modern")
return

val target = target as? IMixinEntity
val target = target as? EntityLivingBase
val targetMixin = target as? IMixinEntity
val trueDist = targetMixin?.let {mc.thePlayer.getDistance(it.trueX, it.trueY, it.trueZ)} ?: 0.0
val dist = target?.let {mc.thePlayer.getDistance(it.posX, it.posY, it.posZ)} ?: 0.0

if (target != null && !Blink.blinkingReceive() && shouldBacktrack() && target.truePos && mc.thePlayer.getDistance(
target.trueX,
target.trueY,
target.trueZ
) <= 6f && (style == "Smooth" || !globalTimer.hasTimePassed(delay))
if (targetMixin != null && !Blink.blinkingReceive() && shouldBacktrack() && targetMixin.truePos && trueDist <= 6f && (!smart || trueDist >= dist) && (style == "Smooth" || !globalTimer.hasTimePassed(delay))
) {
handlePackets()
} else {
Expand All @@ -252,7 +255,7 @@ object Backtrack : Module("Backtrack", ModuleCategory.COMBAT) {

@EventTarget
fun onAttack(event: AttackEvent) {
if (event.targetEntity !is EntityLivingBase)
if (!isEnemy(event.targetEntity))
return

// Clear all packets, start again on enemy change
Expand Down Expand Up @@ -412,6 +415,22 @@ object Backtrack : Module("Backtrack", ModuleCategory.COMBAT) {

private fun removeBacktrackData(id: UUID) = backtrackedPlayer.remove(id)

private fun isEnemy(entity: Entity?): Boolean {
if (entity is EntityLivingBase && entity != mc.thePlayer) {
if (entity is EntityPlayer) {
if (entity.isSpectator || isBot(entity)) return false

if (entity.isClientFriend() && !NoFriends.handleEvents()) return false

return !Teams.handleEvents() || !Teams.isInYourTeam(entity)
}

return true
}

return false
}

/**
* This function will return the nearest tracked range of an entity.
*/
Expand Down Expand Up @@ -466,7 +485,7 @@ object Backtrack : Module("Backtrack", ModuleCategory.COMBAT) {

private fun shouldBacktrack() =
target?.let {
!it.isDead && (mc.thePlayer?.ticksExisted ?: 0) > 20
!it.isDead && isEnemy(it) && (mc.thePlayer?.ticksExisted ?: 0) > 20
&& mc.thePlayer.getDistanceToEntityBox(it) in minDistance..maxDistance
} ?: false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ object FakeLag : Module("FakeLag", ModuleCategory.PLAYER, gameDetecting = false)

// Flush on kb
is S12PacketEntityVelocity -> {
if (mc.thePlayer.entityId == packet.entityID && (packet.motionY != 0 || packet.motionX != 0 || packet.motionZ != 0)) {
if (mc.thePlayer.entityId == packet.entityID) {
blink()
return
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/ccbluex/liquidbounce/utils/RotationUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,14 @@ object RotationUtils : MinecraftInstance(), Listenable {
bb.minY + (bb.maxY - bb.minY) * (y * 0.3 + 1.0),
bb.minZ + (bb.maxZ - bb.minZ) * (z * 0.3 + 1.0)
)
return VecRotation(vec3, toRotation(vec3, predict))
return VecRotation(vec3, toRotation(vec3, predict).fixedSensitivity())
}

val randomVec = Vec3(
bb.minX + (bb.maxX - bb.minX) * x, bb.minY + (bb.maxY - bb.minY) * y, bb.minZ + (bb.maxZ - bb.minZ) * z
)

val randomRotation = toRotation(randomVec, predict)
val randomRotation = toRotation(randomVec, predict).fixedSensitivity()

val eyes = mc.thePlayer.eyes
var vecRotation: VecRotation? = null
Expand All @@ -300,7 +300,7 @@ object RotationUtils : MinecraftInstance(), Listenable {
val dist = eyes.distanceTo(randomVec)

if (dist <= distance && (throughWalls || isVisible(randomVec))) {
return VecRotation(randomVec, randomRotation)
return VecRotation(randomVec, randomRotation.fixedSensitivity())
}
}

Expand All @@ -313,7 +313,7 @@ object RotationUtils : MinecraftInstance(), Listenable {
bb.minZ + (bb.maxZ - bb.minZ) * z
)

val rotation = toRotation(vec, predict)
val rotation = toRotation(vec, predict).fixedSensitivity()
val vecDist = eyes.distanceTo(vec)

if (vecDist <= distance) {
Expand All @@ -336,7 +336,7 @@ object RotationUtils : MinecraftInstance(), Listenable {
val dist = eyes.distanceTo(vec)

if (dist <= distance && (throughWalls || isVisible(vec))) {
return VecRotation(vec, toRotation(vec, predict))
return VecRotation(vec, toRotation(vec, predict).fixedSensitivity())
}
}

Expand Down

0 comments on commit 66fe361

Please sign in to comment.