Skip to content

Commit

Permalink
feat(ElytraFly): glide and not while move (#5287)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccetl authored Jan 22, 2025
1 parent 18a82b2 commit 5b3f25c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.ClientModule
import net.ccbluex.liquidbounce.features.module.modules.movement.elytrafly.modes.ElytraFlyModeStatic
import net.ccbluex.liquidbounce.features.module.modules.movement.elytrafly.modes.ElytraFlyModeVanilla
import net.ccbluex.liquidbounce.utils.entity.moving
import net.ccbluex.liquidbounce.utils.entity.set
import net.minecraft.entity.EquipmentSlot
import net.minecraft.entity.effect.StatusEffects
Expand All @@ -41,8 +42,8 @@ object ModuleElytraFly : ClientModule("ElytraFly", Category.MOVEMENT) {
private val instantStop by boolean("InstantStop", true)

object Speed : ToggleableConfigurable(this, "Speed", true) {
val vertical by float("Vertical", 0.5f, 0.1f..2f)
val horizontal by float("Horizontal", 1f, 0.1f..5f)
val vertical by float("Vertical", 0.5f, 0.1f..5f)
val horizontal by float("Horizontal", 1f, 0.1f..8f)
}

init {
Expand Down Expand Up @@ -90,11 +91,14 @@ object ModuleElytraFly : ClientModule("ElytraFly", Category.MOVEMENT) {

if (player.isGliding) {
// we're already flying, yay
val activeChoice = modes.activeChoice
if (Speed.enabled) {
modes.activeChoice.onTick()
activeChoice.onTick()
}

if (durabilityExploit) {
val modeDoesNotPreventStopping = activeChoice !is ElytraFlyModeStatic ||
!activeChoice.durabilityExploitNotWhileMove || !player.moving
if (durabilityExploit && modeDoesNotPreventStopping) {
network.sendPacket(ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.START_FALL_FLYING))
needsToRestart = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,67 @@
*/
package net.ccbluex.liquidbounce.features.module.modules.movement.elytrafly.modes

import net.ccbluex.liquidbounce.config.types.ToggleableConfigurable
import net.ccbluex.liquidbounce.event.events.PlayerMoveEvent
import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.features.module.modules.movement.elytrafly.ModuleElytraFly
import net.ccbluex.liquidbounce.utils.entity.withStrafe

internal object ElytraFlyModeStatic : ElytraFlyMode("Static") {

/**
* Only runs the exploit while the player isn't moving.
* This might save some durability points
* while not moving as some anti-cheats just detect this exploit when you move.
*/
val durabilityExploitNotWhileMove by boolean("DurabilityExploitNotWhileNoMove", false)

/**
* Allows you to add a glide effect when you're not moving.
* This can prevent you from getting kicked for "flying is not enabled on this server" when you're not moving.
*/
object Glide : ToggleableConfigurable(this, "Glide", false) {

/**
* How fast the static glide should be.
*/
val verticalGlide by float("Vertical", 0.01f, 0f..1f)
val horizontalGlide by float("Horizontal", 0f, 0f..1f)

}

init {
tree(Glide)
}

@Suppress("unused")
private val moveHandler = handler<PlayerMoveEvent> { event ->
if (ModuleElytraFly.shouldNotOperate() || !player.isGliding) {
return@handler
}

val speed = ModuleElytraFly.Speed.enabled
if (speed) {
val input = player.input.playerInput
val isMoving = input.forward || input.backward || input.left || input.right
if (speed && isMoving) {
event.movement = event.movement.withStrafe(speed = ModuleElytraFly.Speed.horizontal.toDouble())
} else {
event.movement.x = 0.0
event.movement.z = 0.0
var glideX = 0.0
var glideZ = 0.0
if (Glide.running) {
val normalized = event.movement.normalize()
glideX = normalized.x * Glide.horizontalGlide.toDouble()
glideZ = normalized.z * Glide.horizontalGlide.toDouble()
}

event.movement.x = glideX
event.movement.z = glideZ
}

event.movement.y = when {
mc.options.jumpKey.isPressed && speed -> ModuleElytraFly.Speed.vertical.toDouble()
mc.options.sneakKey.isPressed && speed -> -ModuleElytraFly.Speed.vertical.toDouble()
else -> 0.0
else -> if (Glide.running) -Glide.verticalGlide.toDouble() else 0.0
}
}

Expand Down

0 comments on commit 5b3f25c

Please sign in to comment.