Skip to content

Commit

Permalink
refactor(legacy): proper implementation for air/ground ticks (#5376)
Browse files Browse the repository at this point in the history
  • Loading branch information
EclipsesDev authored Jan 20, 2025
1 parent cf4c431 commit fce980f
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.ui.client.hud.element.elements.Notification
import net.ccbluex.liquidbounce.utils.client.PacketUtils.sendPacket
import net.ccbluex.liquidbounce.utils.client.chat
import net.ccbluex.liquidbounce.utils.extensions.airTicks
import net.ccbluex.liquidbounce.utils.extensions.isInLiquid
import net.ccbluex.liquidbounce.utils.extensions.isMoving
import net.ccbluex.liquidbounce.utils.extensions.tryJump
import net.ccbluex.liquidbounce.utils.inventory.InventoryUtils
import net.ccbluex.liquidbounce.utils.movement.MovementUtils.airTicks
import net.ccbluex.liquidbounce.utils.timing.MSTimer
import net.minecraft.client.gui.inventory.GuiInventory
import net.minecraft.init.Items
Expand Down Expand Up @@ -91,7 +91,7 @@ object Disabler : Module("Disabler", Category.EXPLOIT) {
get() = InventoryUtils.findItem(36, 44, Items.nether_star) != null

private val betaVerus by boolean("VerusBeta", false)
private val betaVerusSlientFlagApply by boolean("SlientFlagApply", false) { betaVerus }
private val betaVerusSilentFlagApply by boolean("SilentFlagApply", false) { betaVerus }
private val betaVerusBufferSize by int("BufferSize", 300, 0..1000) { betaVerus }
private val betaVerusRepeatTimesValue by int("RepeatTimes", 1, 1..5) { betaVerus }
private val betaVerusRepeatTimesFighting by int("BRepeatTimesFighting", 1, 1..5) { betaVerus }
Expand Down Expand Up @@ -359,7 +359,7 @@ object Disabler : Module("Disabler", Category.EXPLOIT) {
packet.y -= 11.4514
packet.onGround = false
}
} else if (packet is S08PacketPlayerPosLook && betaVerusSlientFlagApply) {
} else if (packet is S08PacketPlayerPosLook && betaVerusSilentFlagApply) {
val x = packet.x - player.posX
val y = packet.y - player.posY
val z = packet.z - player.posZ
Expand Down Expand Up @@ -445,8 +445,8 @@ object Disabler : Module("Disabler", Category.EXPLOIT) {
if (event.eventState != EventState.PRE) return@handler
if (notWhenStarAvailable && hasStar) return@handler

if (execute && airTicks >= 10) {
if (airTicks % 2 == 0) {
if (execute && player.airTicks >= 10) {
if (player.airTicks % 2 == 0) {
event.x += 0.095
}
player.setVelocity(0.0, 0.0, 0.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import net.ccbluex.liquidbounce.features.module.modules.movement.Fly.timerSlowed
import net.ccbluex.liquidbounce.features.module.modules.movement.flymodes.FlyMode
import net.ccbluex.liquidbounce.utils.client.PacketUtils.sendPackets
import net.ccbluex.liquidbounce.utils.client.chat
import net.ccbluex.liquidbounce.utils.extensions.airTicks
import net.ccbluex.liquidbounce.utils.extensions.isMoving
import net.ccbluex.liquidbounce.utils.extensions.tryJump
import net.ccbluex.liquidbounce.utils.movement.MovementUtils.strafe
Expand Down Expand Up @@ -47,7 +48,6 @@ object BlocksMC : FlyMode("BlocksMC"), Listenable {
private var isFlying = false
private var isNotUnder = false
private var isTeleported = false
private var airborneTicks = 0
private var jumped = false

override fun onUpdate() {
Expand All @@ -68,8 +68,6 @@ object BlocksMC : FlyMode("BlocksMC"), Listenable {
}
}

updateOffGroundTicks(player)

if (shouldFly(player, world)) {
if (isTeleported) {

Expand Down Expand Up @@ -100,10 +98,6 @@ object BlocksMC : FlyMode("BlocksMC"), Listenable {
Fly.state = false
}

private fun updateOffGroundTicks(player: EntityPlayerSP) {
airborneTicks = if (player.onGround) 0 else airborneTicks + 1
}

private fun handleTimerSlow(player: EntityPlayerSP) {
if (!player.onGround && timerSlowed) {
if (player.ticksExisted % 7 == 0) {
Expand All @@ -122,7 +116,7 @@ object BlocksMC : FlyMode("BlocksMC"), Listenable {
}

private fun handlePlayerFlying(player: EntityPlayerSP) {
when (airborneTicks) {
when (player.airTicks) {
0 -> {
if (isNotUnder && isTeleported) {
strafe(boostSpeed + extraBoost)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import net.ccbluex.liquidbounce.features.module.modules.movement.flymodes.FlyMod
import net.ccbluex.liquidbounce.utils.client.PacketUtils
import net.ccbluex.liquidbounce.utils.client.PacketUtils.sendPackets
import net.ccbluex.liquidbounce.utils.client.chat
import net.ccbluex.liquidbounce.utils.extensions.airTicks
import net.ccbluex.liquidbounce.utils.extensions.isMoving
import net.ccbluex.liquidbounce.utils.extensions.tryJump
import net.ccbluex.liquidbounce.utils.movement.MovementUtils.strafe
Expand Down Expand Up @@ -45,7 +46,6 @@ object BlocksMC2 : FlyMode("BlocksMC2"), Listenable {
private var isFlying = false
private var isNotUnder = false
private var isBlinked = false
private var airborneTicks = 0
private var jumped = false

private val packets = mutableListOf<Packet<*>>()
Expand All @@ -69,8 +69,6 @@ object BlocksMC2 : FlyMode("BlocksMC2"), Listenable {
}
}

updateOffGroundTicks(player)

if (shouldFly(player, world)) {
if (isBlinked) {

Expand Down Expand Up @@ -111,10 +109,6 @@ object BlocksMC2 : FlyMode("BlocksMC2"), Listenable {
}
}

private fun updateOffGroundTicks(player: EntityPlayerSP) {
airborneTicks = if (player.onGround) 0 else airborneTicks++
}

private fun handleTimerSlow(player: EntityPlayerSP) {
if (!player.onGround && timerSlowed) {
if (player.ticksExisted % 4 == 0) {
Expand All @@ -133,7 +127,7 @@ object BlocksMC2 : FlyMode("BlocksMC2"), Listenable {
}

private fun handlePlayerFlying(player: EntityPlayerSP) {
when (airborneTicks) {
when (player.airTicks) {
0 -> {
if (isNotUnder) {
strafe(boostSpeed + extraBoost)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ package net.ccbluex.liquidbounce.features.module.modules.movement.speedmodes.hyp
import net.ccbluex.liquidbounce.event.JumpEvent
import net.ccbluex.liquidbounce.features.module.modules.movement.Speed.glide
import net.ccbluex.liquidbounce.features.module.modules.movement.speedmodes.SpeedMode
import net.ccbluex.liquidbounce.utils.extensions.airTicks
import net.ccbluex.liquidbounce.utils.extensions.isMoving
import net.ccbluex.liquidbounce.utils.extensions.tryJump
import net.ccbluex.liquidbounce.utils.movement.MovementUtils.airTicks
import net.ccbluex.liquidbounce.utils.movement.MovementUtils.speed
import net.ccbluex.liquidbounce.utils.movement.MovementUtils.strafe
import net.minecraft.potion.Potion
Expand All @@ -32,8 +32,7 @@ object HypixelLowHop : SpeedMode("HypixelLowHop") {
strafe()
return
} else {

when (airTicks) {
when (player.airTicks) {
1 -> {
strafe()
}
Expand All @@ -44,7 +43,7 @@ object HypixelLowHop : SpeedMode("HypixelLowHop") {
7 -> if (glide) player.motionY /= 1.5
}

if (airTicks >= 7 && glide) {
if (player.airTicks >= 7 && glide) {
strafe(speed = speed.coerceAtLeast(0.281F), strength = 0.7)
}

Expand All @@ -53,7 +52,7 @@ object HypixelLowHop : SpeedMode("HypixelLowHop") {
}

if ((player.getActivePotionEffect(Potion.moveSpeed)?.amplifier ?: 0) == 2) {
when (airTicks) {
when (player.airTicks) {
1, 2, 5, 6, 8 -> {
player.motionX *= 1.2
player.motionZ *= 1.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import net.ccbluex.liquidbounce.features.module.modules.movement.Speed.damageLow
import net.ccbluex.liquidbounce.features.module.modules.movement.Speed.fullStrafe
import net.ccbluex.liquidbounce.features.module.modules.movement.Speed.safeY
import net.ccbluex.liquidbounce.features.module.modules.movement.speedmodes.SpeedMode
import net.ccbluex.liquidbounce.utils.extensions.airTicks
import net.ccbluex.liquidbounce.utils.extensions.isInLiquid
import net.ccbluex.liquidbounce.utils.extensions.isMoving
import net.ccbluex.liquidbounce.utils.extensions.tryJump
import net.ccbluex.liquidbounce.utils.movement.MovementUtils.airTicks
import net.ccbluex.liquidbounce.utils.movement.MovementUtils.speed
import net.ccbluex.liquidbounce.utils.movement.MovementUtils.strafe
import net.minecraft.potion.Potion
Expand All @@ -32,17 +32,17 @@ object BlocksMCHop : SpeedMode("BlocksMCHop") {
if (fullStrafe) {
strafe(speed - 0.004F)
} else {
if (airTicks >= 6) {
if (player.airTicks >= 6) {
strafe()
}
}

if ((player.getActivePotionEffect(Potion.moveSpeed)?.amplifier ?: 0) > 0 && airTicks == 3) {
if ((player.getActivePotionEffect(Potion.moveSpeed)?.amplifier ?: 0) > 0 && player.airTicks == 3) {
player.motionX *= 1.12
player.motionZ *= 1.12
}

if (bmcLowHop && airTicks == 4) {
if (bmcLowHop && player.airTicks == 4) {
if (safeY) {
if (player.posY % 1.0 == 0.16610926093821377) {
player.motionY = -0.09800000190734863
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
package net.ccbluex.liquidbounce.features.module.modules.movement.speedmodes.verus

import net.ccbluex.liquidbounce.features.module.modules.movement.speedmodes.SpeedMode
import net.ccbluex.liquidbounce.utils.extensions.airTicks
import net.ccbluex.liquidbounce.utils.extensions.isInLiquid
import net.ccbluex.liquidbounce.utils.extensions.isMoving
import net.ccbluex.liquidbounce.utils.extensions.tryJump
import net.ccbluex.liquidbounce.utils.movement.MovementUtils.airTicks
import net.ccbluex.liquidbounce.utils.movement.MovementUtils.strafe
import net.minecraft.potion.Potion

Expand All @@ -30,7 +30,7 @@ object VerusLowHop : SpeedMode("VerusLowHop") {

player.tryJump()
} else {
if (airTicks <= 1) {
if (player.airTicks <= 1) {
player.motionY = -0.09800000190734863
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
package net.ccbluex.liquidbounce.features.module.modules.movement.speedmodes.verus

import net.ccbluex.liquidbounce.features.module.modules.movement.speedmodes.SpeedMode
import net.ccbluex.liquidbounce.utils.extensions.airTicks
import net.ccbluex.liquidbounce.utils.extensions.isInLiquid
import net.ccbluex.liquidbounce.utils.extensions.isMoving
import net.ccbluex.liquidbounce.utils.extensions.tryJump
import net.ccbluex.liquidbounce.utils.movement.MovementUtils.airTicks
import net.ccbluex.liquidbounce.utils.movement.MovementUtils.strafe
import net.minecraft.potion.Potion

Expand Down Expand Up @@ -45,7 +45,7 @@ object VerusLowHopNew : SpeedMode("VerusLowHopNew") {
0.33f
}
} else {
if (airTicks <= 1) {
if (player.airTicks <= 1) {
mc.thePlayer.motionY = -0.09800000190734863
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ object Scaffold : Module("Scaffold", Category.WORLD, Keyboard.KEY_I) {
}

// Telly
private var offGroundTicks = 0
private var ticksUntilJump = 0
private var blocksUntilAxisChange = 0
private var jumpTicks = jumpTicksRange.random()
Expand Down Expand Up @@ -313,12 +312,7 @@ object Scaffold : Module("Scaffold", Category.WORLD, Keyboard.KEY_I) {
mc.timer.timerSpeed = timer

// Telly
if (player.onGround) {
offGroundTicks = 0
ticksUntilJump++
} else {
offGroundTicks++
}
if (player.onGround) ticksUntilJump++

if (shouldGoDown) {
mc.gameSettings.keyBindSneak.pressed = false
Expand Down Expand Up @@ -583,8 +577,10 @@ object Scaffold : Module("Scaffold", Category.WORLD, Keyboard.KEY_I) {
}

private fun setRotation(rotation: Rotation, ticks: Int) {
if (scaffoldMode == "Telly" && mc.thePlayer.isMoving) {
if (offGroundTicks < ticksUntilRotation.get() && ticksUntilJump >= jumpTicks) {
val player = mc.thePlayer ?: return

if (scaffoldMode == "Telly" && player.isMoving) {
if (player.airTicks < ticksUntilRotation.get() && ticksUntilJump >= jumpTicks) {
return
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,14 @@ private void onUpdateWalkingPlayer(CallbackInfo ci) {
serverSneakState = sneaking;
}

final MovementUtils movementUtils = MovementUtils.INSTANCE;

if (motionEvent.getOnGround()) {
MovementUtils.INSTANCE.setAirTicks(0);
movementUtils.setGroundTicks(movementUtils.getGroundTicks() + 1);
movementUtils.setAirTicks(0);
} else {
MovementUtils.INSTANCE.setAirTicks(MovementUtils.INSTANCE.getAirTicks() + 1);
movementUtils.setGroundTicks(0);
movementUtils.setAirTicks(movementUtils.getAirTicks() + 1);
}

if (isCurrentViewEntity()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package net.ccbluex.liquidbounce.ui.client.hud.element.elements

import net.ccbluex.liquidbounce.LiquidBounce.CLIENT_NAME
import net.ccbluex.liquidbounce.LiquidBounce.CLIENT_WEBSITE
import net.ccbluex.liquidbounce.features.module.modules.render.AntiBlind
import net.ccbluex.liquidbounce.ui.client.hud.element.Border
import net.ccbluex.liquidbounce.ui.client.hud.element.Element
import net.ccbluex.liquidbounce.ui.client.hud.element.ElementInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import net.ccbluex.liquidbounce.utils.movement.TimerBalanceUtils
import net.ccbluex.liquidbounce.utils.render.ColorSettingsFloat
import net.ccbluex.liquidbounce.utils.render.ColorSettingsInteger
import net.ccbluex.liquidbounce.utils.render.ColorUtils
import net.ccbluex.liquidbounce.utils.render.ColorUtils.withAlpha
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawRoundedBorder
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawRoundedRect
import net.ccbluex.liquidbounce.utils.render.shader.shaders.GradientFontShader
Expand Down Expand Up @@ -95,7 +96,7 @@ class Text(x: Double = 10.0, y: Double = 10.0, scale: Float = 1F, side: Side = S

text.displayString = "Blocks: %blockamount%"
text.shadow = true
text.bgColors.with(a = 100)
text.bgColors.color().withAlpha(100)
text.onScaffold = true
text.showBlock = true
text.backgroundScale = 1F
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ val Entity.lastTickPos: Vec3
val EntityLivingBase?.isMoving: Boolean
get() = this?.run { moveForward != 0F || moveStrafing != 0F } == true

val EntityPlayerSP.airTicks
get() = MovementUtils.airTicks

val EntityPlayerSP.groundTicks
get() = MovementUtils.groundTicks

val Entity.isInLiquid: Boolean
get() = isInWater || isInLava

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ object MovementUtils : MinecraftInstance, Listenable {
get() = mc.thePlayer?.run { motionX != .0 || motionY != .0 || motionZ != .0 } == true

var airTicks = 0
var groundTicks = 0

@JvmOverloads
fun strafe(
Expand Down

0 comments on commit fce980f

Please sign in to comment.