From fce980f8fd7a1801489ca676ad8558df26755d44 Mon Sep 17 00:00:00 2001 From: Eclipses <99494277+EclipsesDev@users.noreply.github.com> Date: Mon, 20 Jan 2025 19:12:35 +0700 Subject: [PATCH] refactor(legacy): proper implementation for air/ground ticks (#5376) --- .../features/module/modules/exploit/Disabler.kt | 10 +++++----- .../modules/movement/flymodes/blocksmc/BlocksMC.kt | 10 ++-------- .../movement/flymodes/blocksmc/BlocksMC2.kt | 10 ++-------- .../movement/speedmodes/hypixel/HypixelLowHop.kt | 9 ++++----- .../movement/speedmodes/other/BlocksMCHop.kt | 8 ++++---- .../movement/speedmodes/verus/VerusLowHop.kt | 4 ++-- .../movement/speedmodes/verus/VerusLowHopNew.kt | 4 ++-- .../module/modules/world/scaffolds/Scaffold.kt | 14 +++++--------- .../forge/mixins/entity/MixinEntityPlayerSP.java | 8 ++++++-- .../hud/element/elements/ScoreboardElement.kt | 1 - .../ui/client/hud/element/elements/Text.kt | 3 ++- .../utils/extensions/PlayerExtension.kt | 6 ++++++ .../liquidbounce/utils/movement/MovementUtils.kt | 1 + 13 files changed, 41 insertions(+), 47 deletions(-) diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/exploit/Disabler.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/exploit/Disabler.kt index d5867f07dfc..ad1b9626c28 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/exploit/Disabler.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/exploit/Disabler.kt @@ -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 @@ -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 } @@ -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 @@ -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) diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/flymodes/blocksmc/BlocksMC.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/flymodes/blocksmc/BlocksMC.kt index d15d04e0f6d..cb48c017fc1 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/flymodes/blocksmc/BlocksMC.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/flymodes/blocksmc/BlocksMC.kt @@ -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 @@ -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() { @@ -68,8 +68,6 @@ object BlocksMC : FlyMode("BlocksMC"), Listenable { } } - updateOffGroundTicks(player) - if (shouldFly(player, world)) { if (isTeleported) { @@ -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) { @@ -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) diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/flymodes/blocksmc/BlocksMC2.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/flymodes/blocksmc/BlocksMC2.kt index 498eb90e69e..6050c087fd9 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/flymodes/blocksmc/BlocksMC2.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/flymodes/blocksmc/BlocksMC2.kt @@ -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 @@ -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>() @@ -69,8 +69,6 @@ object BlocksMC2 : FlyMode("BlocksMC2"), Listenable { } } - updateOffGroundTicks(player) - if (shouldFly(player, world)) { if (isBlinked) { @@ -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) { @@ -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) diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/speedmodes/hypixel/HypixelLowHop.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/speedmodes/hypixel/HypixelLowHop.kt index 3a12a1dc82b..95a10f9af74 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/speedmodes/hypixel/HypixelLowHop.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/speedmodes/hypixel/HypixelLowHop.kt @@ -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 @@ -32,8 +32,7 @@ object HypixelLowHop : SpeedMode("HypixelLowHop") { strafe() return } else { - - when (airTicks) { + when (player.airTicks) { 1 -> { strafe() } @@ -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) } @@ -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 diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/speedmodes/other/BlocksMCHop.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/speedmodes/other/BlocksMCHop.kt index fbd88feb7c5..29ee3a589a3 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/speedmodes/other/BlocksMCHop.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/speedmodes/other/BlocksMCHop.kt @@ -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 @@ -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 diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/speedmodes/verus/VerusLowHop.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/speedmodes/verus/VerusLowHop.kt index 5d4188118f7..c06a18d0cc1 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/speedmodes/verus/VerusLowHop.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/speedmodes/verus/VerusLowHop.kt @@ -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 @@ -30,7 +30,7 @@ object VerusLowHop : SpeedMode("VerusLowHop") { player.tryJump() } else { - if (airTicks <= 1) { + if (player.airTicks <= 1) { player.motionY = -0.09800000190734863 } diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/speedmodes/verus/VerusLowHopNew.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/speedmodes/verus/VerusLowHopNew.kt index aeed5ddffd0..77a47de1bf8 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/speedmodes/verus/VerusLowHopNew.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/movement/speedmodes/verus/VerusLowHopNew.kt @@ -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 @@ -45,7 +45,7 @@ object VerusLowHopNew : SpeedMode("VerusLowHopNew") { 0.33f } } else { - if (airTicks <= 1) { + if (player.airTicks <= 1) { mc.thePlayer.motionY = -0.09800000190734863 } diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/scaffolds/Scaffold.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/scaffolds/Scaffold.kt index fe5471135a8..13456fd4837 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/scaffolds/Scaffold.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/scaffolds/Scaffold.kt @@ -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() @@ -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 @@ -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 } } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntityPlayerSP.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntityPlayerSP.java index fe439b44cc9..cc59adeecf0 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntityPlayerSP.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/entity/MixinEntityPlayerSP.java @@ -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()) { diff --git a/src/main/java/net/ccbluex/liquidbounce/ui/client/hud/element/elements/ScoreboardElement.kt b/src/main/java/net/ccbluex/liquidbounce/ui/client/hud/element/elements/ScoreboardElement.kt index c73fe7f5b1d..95a12f16bbc 100644 --- a/src/main/java/net/ccbluex/liquidbounce/ui/client/hud/element/elements/ScoreboardElement.kt +++ b/src/main/java/net/ccbluex/liquidbounce/ui/client/hud/element/elements/ScoreboardElement.kt @@ -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 diff --git a/src/main/java/net/ccbluex/liquidbounce/ui/client/hud/element/elements/Text.kt b/src/main/java/net/ccbluex/liquidbounce/ui/client/hud/element/elements/Text.kt index 4a5223fc6f3..73baf61bddb 100644 --- a/src/main/java/net/ccbluex/liquidbounce/ui/client/hud/element/elements/Text.kt +++ b/src/main/java/net/ccbluex/liquidbounce/ui/client/hud/element/elements/Text.kt @@ -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 @@ -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 diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/extensions/PlayerExtension.kt b/src/main/java/net/ccbluex/liquidbounce/utils/extensions/PlayerExtension.kt index c1f97df43b8..a13040a104c 100644 --- a/src/main/java/net/ccbluex/liquidbounce/utils/extensions/PlayerExtension.kt +++ b/src/main/java/net/ccbluex/liquidbounce/utils/extensions/PlayerExtension.kt @@ -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 diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/movement/MovementUtils.kt b/src/main/java/net/ccbluex/liquidbounce/utils/movement/MovementUtils.kt index cea98b01d27..d6f39055aa0 100644 --- a/src/main/java/net/ccbluex/liquidbounce/utils/movement/MovementUtils.kt +++ b/src/main/java/net/ccbluex/liquidbounce/utils/movement/MovementUtils.kt @@ -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(