Skip to content

Commit

Permalink
Fixed Legacy mode of Backtrack not working above limits, KillAura and…
Browse files Browse the repository at this point in the history
… Aimbot not respecting Backtrack positions. (CCBlueX#1692)
  • Loading branch information
mems01 authored Dec 17, 2023
1 parent 23e418f commit af59b5e
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import net.ccbluex.liquidbounce.utils.extensions.*
import net.ccbluex.liquidbounce.utils.timing.MSTimer
import net.ccbluex.liquidbounce.value.BoolValue
import net.ccbluex.liquidbounce.value.FloatValue
import net.minecraft.entity.Entity
import net.minecraft.util.Vec3
import java.util.*

Expand Down Expand Up @@ -51,17 +52,46 @@ object Aimbot : Module("Aimbot", ModuleCategory.COMBAT) {
if (onClick && (clickTimer.hasTimePassed(150) || (!mc.gameSettings.keyBindAttack.isKeyDown && AutoClicker.handleEvents()))) return

// Search for the best enemy to target

val entity = mc.theWorld.loadedEntityList.filter {
isSelected(it, true)
val distanceCheck = Backtrack.getNearestTrackedDistance(it)

return@filter isSelected(it, true)
&& thePlayer.canEntityBeSeen(it)
&& thePlayer.getDistanceToEntityBox(it) <= range
&& thePlayer.getDistanceToEntityBox(it) <= range || distanceCheck != 0.0 && distanceCheck <= range
&& getRotationDifference(it) <= fov
}.minByOrNull { getRotationDifference(it) } ?: return
}.minByOrNull { mc.thePlayer.getDistanceToEntityBox(it) } ?: return

// Should it always keep trying to lock on the enemy or just try to assist you?
if (!lock && isFaced(entity, range.toDouble())) return

val random = Random()

var shouldReturn = false

Backtrack.runWithNearestTrackedDistance(entity) {
shouldReturn = !findRotation(entity, random)
}

if (shouldReturn) {
return
}

// Jitter
// Some players do jitter on their mouses causing them to shake around. This is trying to simulate this behavior.
if (jitter) {
if (random.nextBoolean()) {
thePlayer.fixedSensitivityYaw += (random.nextGaussian() - 0.5f).toFloat()
}

if (random.nextBoolean()) {
thePlayer.fixedSensitivityPitch += (random.nextGaussian() - 0.5f).toFloat()
}
}
}

private fun findRotation(entity: Entity, random: Random): Boolean {
val thePlayer = mc.thePlayer ?: return false

val entityPrediction = Vec3(entity.posX - entity.prevPosX,
entity.posY - entity.prevPosY,
entity.posZ - entity.prevPosZ
Expand All @@ -83,10 +113,9 @@ object Aimbot : Module("Aimbot", ModuleCategory.COMBAT) {
predict = true,
lookRange = range,
attackRange = if (Reach.handleEvents()) Reach.combatReach else 3f
) ?: return
) ?: return false

// Figure out the best turn speed suitable for the distance and configured turn speed

val rotationDiff = getRotationDifference(playerRotation, destinationRotation)

// is enemy visible to player on screen. Fov is about to be right with that you can actually see on the screen. Still not 100% accurate, but it is fast check.
Expand All @@ -96,24 +125,13 @@ object Aimbot : Module("Aimbot", ModuleCategory.COMBAT) {
turnSpeed
}

val random = Random()
val gaussian = random.nextGaussian()

val realisticTurnSpeed = rotationDiff * ((supposedTurnSpeed + (gaussian - 0.5)) / 180)
val rotation = limitAngleChange(thePlayer.rotation, destinationRotation, realisticTurnSpeed.toFloat())

rotation.toPlayer(thePlayer)

// Jitter
// Some players do jitter on their mouses causing them to shake around. This is trying to simulate this behavior.
if (jitter) {
if (random.nextBoolean()) {
thePlayer.fixedSensitivityYaw += (random.nextGaussian() - 0.5f).toFloat()
}

if (random.nextBoolean()) {
thePlayer.fixedSensitivityPitch += (random.nextGaussian() - 0.5f).toFloat()
}
}
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ import net.ccbluex.liquidbounce.features.module.modules.misc.AntiBot.isBot
import net.ccbluex.liquidbounce.features.module.modules.misc.Teams
import net.ccbluex.liquidbounce.features.module.modules.player.Blink
import net.ccbluex.liquidbounce.injection.implementations.IMixinEntity
import net.ccbluex.liquidbounce.utils.*
import net.ccbluex.liquidbounce.utils.PacketUtils
import net.ccbluex.liquidbounce.utils.extensions.*
import net.ccbluex.liquidbounce.utils.misc.StringUtils.contains
import net.ccbluex.liquidbounce.utils.realX
import net.ccbluex.liquidbounce.utils.realY
import net.ccbluex.liquidbounce.utils.realZ
import net.ccbluex.liquidbounce.utils.render.ColorUtils.rainbow
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawBacktrackBox
import net.ccbluex.liquidbounce.utils.render.RenderUtils.glColor
Expand Down Expand Up @@ -49,13 +52,16 @@ object Backtrack : Module("Backtrack", ModuleCategory.COMBAT) {

val mode by object : ListValue("Mode", arrayOf("Legacy", "Modern"), "Modern") {
override fun onChanged(oldValue: String, newValue: String) {
clearPackets();
backtrackedPlayer.clear();
clearPackets()
backtrackedPlayer.clear()
}
}

// Legacy
private val legacyPos by ListValue("Caching mode", arrayOf("ClientPos", "ServerPos"), "ClientPos") { mode == "Legacy" }
private val legacyPos by ListValue("Caching mode",
arrayOf("ClientPos", "ServerPos"),
"ClientPos"
) { mode == "Legacy" }

// Modern
private val style by ListValue("Style", arrayOf("Pulse", "Smooth"), "Smooth") { mode == "Modern" }
Expand All @@ -73,10 +79,10 @@ object Backtrack : Module("Backtrack", ModuleCategory.COMBAT) {

// ESP
private val esp by BoolValue("ESP", true, subjective = true) { mode == "Modern" }
private val rainbow by BoolValue("Rainbow", true, subjective = true) { mode == "Modern" && esp }
private val red by IntegerValue("R", 0, 0..255, subjective = true) { !rainbow && mode == "Modern" && esp }
private val green by IntegerValue("G", 255, 0..255, subjective = true) { !rainbow && mode == "Modern" && esp }
private val blue by IntegerValue("B", 0, 0..255, subjective = true) { !rainbow && mode == "Modern" && esp }
private val rainbow by BoolValue("Rainbow", true, subjective = true) { mode == "Modern" && esp }
private val red by IntegerValue("R", 0, 0..255, subjective = true) { !rainbow && mode == "Modern" && esp }
private val green by IntegerValue("G", 255, 0..255, subjective = true) { !rainbow && mode == "Modern" && esp }
private val blue by IntegerValue("B", 0, 0..255, subjective = true) { !rainbow && mode == "Modern" && esp }

private val packetQueue = LinkedHashMap<Packet<*>, Long>()
private val positions = mutableListOf<Pair<Vec3, Long>>()
Expand Down Expand Up @@ -120,6 +126,7 @@ object Backtrack : Module("Backtrack", ModuleCategory.COMBAT) {
System.currentTimeMillis()
)
}

is S14PacketEntity -> {
if (legacyPos == "ServerPos") {
val entity = mc.theWorld?.getEntityByID(packet.entityId)
Expand Down Expand Up @@ -288,6 +295,7 @@ object Backtrack : Module("Backtrack", ModuleCategory.COMBAT) {

target = event.targetEntity
}

@EventTarget
fun onRender3D(event: Render3DEvent) {
when (mode.lowercase()) {
Expand Down Expand Up @@ -329,7 +337,7 @@ object Backtrack : Module("Backtrack", ModuleCategory.COMBAT) {
}

"modern" -> {
if (!shouldBacktrack() || packetQueue.isEmpty() || !shouldDraw || !esp )
if (!shouldBacktrack() || packetQueue.isEmpty() || !shouldDraw || !esp)
return

val renderManager = mc.renderManager
Expand Down Expand Up @@ -384,11 +392,12 @@ object Backtrack : Module("Backtrack", ModuleCategory.COMBAT) {
clearPackets(false)
}

override fun onEnable() = reset()
override fun onEnable() =
reset()

override fun onDisable() {
clearPackets();
backtrackedPlayer.clear();
clearPackets()
backtrackedPlayer.clear()
}

private fun handlePackets() {
Expand Down Expand Up @@ -544,6 +553,57 @@ object Backtrack : Module("Backtrack", ModuleCategory.COMBAT) {
entity.setPosition(entityPosition.xCoord, entityPosition.yCoord, entityPosition.zCoord)
}

fun runWithNearestTrackedDistance(entity: Entity, f: () -> Unit) {
if (entity !is EntityPlayer)
return

if (!handleEvents()|| mode == "Modern") {
f()

return
}

var backtrackDataArray = getBacktrackData(entity.uniqueID)?.toMutableList() ?: return

// Filter out negatives, sort by distance
backtrackDataArray = backtrackDataArray.sortedBy { (x, y, z, _) ->
runWithSimulatedPastPosition(entity, Vec3(x, y, z)) {
mc.thePlayer.getDistanceToBox(entity.hitBox)
}
}.toMutableList()

val (x, y, z, _) = backtrackDataArray.first()

runWithSimulatedPastPosition(entity, Vec3(x, y, z)) {
f()

null
}
}

private fun runWithSimulatedPastPosition(entity: Entity, vec3: Vec3, f: () -> Double?): Double? {
val entityPosition = entity.positionVector
val (prevX, prevY, prevZ) = Triple(entity.prevPosX, entity.prevPosY, entity.prevPosZ)

val (x, y, z) = Triple(vec3.xCoord, vec3.yCoord, vec3.zCoord)

entity.setPosition(x, y, z)
entity.prevPosX = x
entity.prevPosY = y
entity.prevPosZ = z

val result = f()

// Reset position
entity.prevPosX = prevX
entity.prevPosY = prevY
entity.prevPosZ = prevZ

entity.setPosition(entityPosition.xCoord, entityPosition.yCoord, entityPosition.zCoord)

return result
}

val color
get() = if (rainbow) rainbow() else Color(red, green, blue)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ object KillAura : Module("KillAura", ModuleCategory.COMBAT, Keyboard.KEY_R) {
override fun onChange(oldValue: Int, newValue: Int) =
newValue.coerceAtLeast(minimum)
}

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

private val micronizedValue = BoolValue("Micronized", true) { !maxTurnSpeedValue.isMinimal() }
Expand Down Expand Up @@ -553,13 +552,15 @@ object KillAura : Module("KillAura", ModuleCategory.COMBAT, Keyboard.KEY_R) {
if (entity !is EntityLivingBase || !isEnemy(entity) || (switchMode && entity.entityId in prevTargetEntities)) continue

var distance = thePlayer.getDistanceToEntityBox(entity)

if (Backtrack.handleEvents()) {
val trackedDistance = Backtrack.getNearestTrackedDistance(entity)

if (distance > trackedDistance) {
distance = trackedDistance
}
}

val entityFov = getRotationDifference(entity)

if (distance <= maxRange && (fov == 180F || entityFov <= fov)) {
Expand All @@ -569,9 +570,29 @@ object KillAura : Module("KillAura", ModuleCategory.COMBAT, Keyboard.KEY_R) {

// Sort targets by priority
when (priority.lowercase()) {
"distance" -> targets.sortBy { thePlayer.getDistanceToEntityBox(it) } // Sort by distance
"distance" -> {
targets.sortBy {
var result = 0.0

Backtrack.runWithNearestTrackedDistance(it) {
result = thePlayer.getDistanceToEntityBox(it) // Sort by distance
}

result
}
}

"direction" -> targets.sortBy {
var result = 0f

Backtrack.runWithNearestTrackedDistance(it) {
result = getRotationDifference(it) // Sort by FOV
}

result
}

"health" -> targets.sortBy { it.health } // Sort by health
"direction" -> targets.sortBy { getRotationDifference(it) } // Sort by FOV
"livingtime" -> targets.sortBy { -it.ticksExisted } // Sort by existence
"armor" -> targets.sortBy { it.totalArmorValue } // Sort by armor
"hurtresistance" -> targets.sortBy { it.hurtResistantTime } // Sort by armor hurt time
Expand All @@ -582,27 +603,20 @@ object KillAura : Module("KillAura", ModuleCategory.COMBAT, Keyboard.KEY_R) {
Potion.regeneration
).amplifier else -1
}

}

// Find best target
for (entity in targets) {
// Update rotations to current target
if (!updateRotations(entity)) {
var success = false
Backtrack.loopThroughBacktrackData(entity) {
if (updateRotations(entity)) {
success = true
return@loopThroughBacktrackData true
}
var success = false

return@loopThroughBacktrackData false
}
Backtrack.runWithNearestTrackedDistance(entity) {
success = updateRotations(entity)
}

if (!success) {
// when failed then try another target
continue
}
if (!success) {
// when failed then try another target
continue
}

// Set target to current entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
import net.minecraft.entity.item.EntityItemFrame;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.util.*;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.event.EntityViewRenderEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.spongepowered.asm.mixin.Mixin;
Expand Down Expand Up @@ -88,7 +91,7 @@ private void cameraClip(float partialTicks, CallbackInfo callbackInfo) {
if (!mc.gameSettings.debugCamEnable) {
BlockPos blockPos = new BlockPos(entity);
IBlockState blockState = mc.theWorld.getBlockState(blockPos);
net.minecraftforge.client.ForgeHooksClient.orientBedCamera(mc.theWorld, blockPos, blockState, entity);
ForgeHooksClient.orientBedCamera(mc.theWorld, blockPos, blockState, entity);

rotate(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks + 180f, 0f, -1f, 0f);
rotate(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks, -1f, 0f, 0f);
Expand Down Expand Up @@ -124,8 +127,8 @@ private void cameraClip(float partialTicks, CallbackInfo callbackInfo) {
}

Block block = ActiveRenderInfo.getBlockAtEntityViewpoint(mc.theWorld, entity, partialTicks);
net.minecraftforge.client.event.EntityViewRenderEvent.CameraSetup event = new net.minecraftforge.client.event.EntityViewRenderEvent.CameraSetup((EntityRenderer) (Object) this, entity, block, partialTicks, yaw, pitch, roll);
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
EntityViewRenderEvent.CameraSetup event = new EntityViewRenderEvent.CameraSetup((EntityRenderer) (Object) this, entity, block, partialTicks, yaw, pitch, roll);
MinecraftForge.EVENT_BUS.post(event);
rotate(event.roll, 0f, 0f, 1f);
rotate(event.pitch, 1f, 0f, 0f);
rotate(event.yaw, 0f, 1f, 0f);
Expand Down Expand Up @@ -175,7 +178,7 @@ private void getMouseOver(float p_getMouseOver_1_, CallbackInfo ci) {
double d1 = d0;
boolean flag = false;
if (mc.playerController.extendedReach()) {
d0 = 6;
// d0 = 6;
d1 = 6;
} else if (d0 > 3) {
flag = true;
Expand All @@ -195,8 +198,7 @@ private void getMouseOver(float p_getMouseOver_1_, CallbackInfo ci) {

pointedEntity = null;
Vec3 vec33 = null;
float f = 1f;
List<Entity> list = mc.theWorld.getEntitiesInAABBexcluding(entity, entity.getEntityBoundingBox().addCoord(vec31.xCoord * d0, vec31.yCoord * d0, vec31.zCoord * d0).expand(f, f, f), Predicates.and(EntitySelectors.NOT_SPECTATING, p_apply_1_ -> p_apply_1_ != null && p_apply_1_.canBeCollidedWith()));
List<Entity> list = mc.theWorld.getEntities(EntityLivingBase.class, Predicates.and(EntitySelectors.NOT_SPECTATING, p_apply_1_ -> p_apply_1_ != null && p_apply_1_.canBeCollidedWith() && p_apply_1_ != entity));
double d2 = d1;

for (Entity entity1 : list) {
Expand All @@ -208,7 +210,7 @@ private void getMouseOver(float p_getMouseOver_1_, CallbackInfo ci) {
Backtrack.INSTANCE.loopThroughBacktrackData(entity1, () -> {
boxes.add(entity1.getEntityBoundingBox().expand(f1, f1, f1));
return false;
});
});

for (final AxisAlignedBB axisalignedbb : boxes) {
MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(vec3, vec32);
Expand Down
Loading

0 comments on commit af59b5e

Please sign in to comment.