Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
1zun4 committed Jan 8, 2025
1 parent a7a1d5a commit a8fff35
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ class MovementInputEvent(

@Nameable("sprint")
class SprintEvent(var sprint: Boolean, val source: Source) : Event() {
enum class Source {
INPUT,
MOVEMENT_TICK,
NETWORK
enum class Source(val key: Boolean) {
INPUT(true),
MOVEMENT_TICK(true),
NETWORK(false)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ object ModuleSuperKnockback : ClientModule("SuperKnockback", Category.COMBAT, al

@Suppress("unused")
private val attackHandler = sequenceHandler<AttackEntityEvent> { event ->
if (event.isCancelled || !shouldOperate(event.entity) || !shouldStopSprinting(event)) {
if (event.isCancelled || !shouldOperate(event.entity) || !shouldStopSprinting(event) || cancelSprint) {
return@sequenceHandler
}

Expand All @@ -114,7 +114,7 @@ object ModuleSuperKnockback : ClientModule("SuperKnockback", Category.COMBAT, al
private val movementHandler = handler<SprintEvent>(
priority = EventPriorityConvention.FIRST_PRIORITY
) { event ->
if (cancelSprint) {
if (cancelSprint && event.source.key) {
event.sprint = false
}
}
Expand All @@ -135,30 +135,34 @@ object ModuleSuperKnockback : ClientModule("SuperKnockback", Category.COMBAT, al
private val ticksUntilAllowedMovement by intRange("UntilAllowedMovement", 0..1, 0..10,
"ticks")

private var inSequence = false
private var cancelMovement = false

@Suppress("unused")
private val attackHandler = sequenceHandler<AttackEntityEvent> { event ->
if (event.isCancelled || !shouldOperate(event.entity) || !shouldStopSprinting(event)) {
if (event.isCancelled || !shouldOperate(event.entity) || !shouldStopSprinting(event) || inSequence) {
return@sequenceHandler
}

inSequence = true
waitTicks(ticksUntilMovementBlock.random())
cancelMovement = true
waitUntil { !player.input.hasForwardMovement() }
waitTicks(ticksUntilAllowedMovement.random())
cancelMovement = false
inSequence = false
}

@Suppress("unused")
private val movementHandler = handler<MovementInputEvent> { event ->
if (cancelMovement) {
if (inSequence && cancelMovement) {
event.directionalInput = DirectionalInput.NONE
}
}

override fun disable() {
cancelMovement = false
inSequence = false
super.disable()
}

Expand Down

0 comments on commit a8fff35

Please sign in to comment.