Skip to content

Commit

Permalink
feat(AntiHunger) NoSprint WhileSwimming (#5627)
Browse files Browse the repository at this point in the history
  • Loading branch information
ManInMyVan authored Feb 15, 2025
1 parent 9362fd3 commit 2c07039
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package net.ccbluex.liquidbounce.features.module.modules.exploit

import net.ccbluex.liquidbounce.config.types.ToggleableConfigurable
import net.ccbluex.liquidbounce.event.events.NotificationEvent
import net.ccbluex.liquidbounce.event.events.PacketEvent
import net.ccbluex.liquidbounce.event.events.SprintEvent
Expand All @@ -43,10 +44,15 @@ object ModuleAntiHunger : ClientModule("AntiHunger", Category.EXPLOIT) {

/**
* Cancels hunger decrease by making the player not sprint server side
*
* @see net.ccbluex.liquidbounce.injection.mixins.minecraft.entity.MixinClientPlayerEntity sendSprintingPacket
*/
var noSprint by boolean("NoSprint", true)
private object NoSprint : ToggleableConfigurable(this, "NoSprint", true) {
private val whileSwimming by boolean("WhileSwimming", false)

override val running
get() = super.running && (!player.isSwimming || whileSwimming)
}

init { tree(NoSprint) }

/**
* Cancels hunger decrease by making the player float (not on ground) permanently
Expand All @@ -57,7 +63,8 @@ object ModuleAntiHunger : ClientModule("AntiHunger", Category.EXPLOIT) {

@Suppress("unused")
private val sprintHandler = handler<SprintEvent> { event ->
if (noSprint && (event.source == SprintEvent.Source.NETWORK || event.source == SprintEvent.Source.INPUT)) {
if (NoSprint.running && (event.source == SprintEvent.Source.NETWORK
|| event.source == SprintEvent.Source.INPUT)) {
event.sprint = false
}
}
Expand All @@ -67,7 +74,7 @@ object ModuleAntiHunger : ClientModule("AntiHunger", Category.EXPLOIT) {
when (val packet = event.packet) {

is ClientCommandC2SPacket -> {
if (!noSprint || !notificationCooldown.hasElapsed(500)) {
if (!NoSprint.running || !notificationCooldown.hasElapsed(500)) {
return@handler
}

Expand Down Expand Up @@ -114,5 +121,4 @@ object ModuleAntiHunger : ClientModule("AntiHunger", Category.EXPLOIT) {
}
}
}

}

0 comments on commit 2c07039

Please # to comment.