Skip to content

Update AntiAFK.java#6533

Open
fapotaa wants to merge 1 commit into
MeteorDevelopment:masterfrom
fapotaa:patch-1
Open

Update AntiAFK.java#6533
fapotaa wants to merge 1 commit into
MeteorDevelopment:masterfrom
fapotaa:patch-1

Conversation

@fapotaa

@fapotaa fapotaa commented Jul 25, 2026

Copy link
Copy Markdown

Type of change

  • Bug fix
  • New feature

Description

This PR fixes an issue where the Anti-AFK module's random jump feature could accidentally activate Elytra flight when two consecutive jumps occurred within a short time frame.

The Problem:

When wearing an Elytra, two jumps happening in quick succession (within < 0.75 seconds) would trigger the Elytra to activate mid-air. This caused the player to start flying and slowly drift from their original position. Over extended AFK periods, this could lead to:

  • Moving away from the intended AFK spot
  • Falling off high ledges or platforms
  • Walking into dangerous areas (lava, void, mobs)

The Solution:

Added a cooldown system between random jumps:

  • Minimum interval between jumps: 20 ticks (1 second)
  • This is longer than the full jump duration in Minecraft (~15 ticks / 0.75 seconds)
  • Prevents any possibility of two jumps occurring while the player is still in the air

Technical Implementation:

private int jumpCooldown = 0;

// In onTick():
if (jump.get()) {
    if (jumpCooldown > 0) {
        jumpCooldown--;
    } else {
        if (mc.options.keyJump.isDown()) {
            mc.options.keyJump.setDown(false);
        } else if (random.nextInt(99) == 0) {
            mc.options.keyJump.setDown(true);
            jumpCooldown = 20; // 1 second cooldown
        }
    }
}

This modification improves the Anti-AFK module to be safer when wearing an Elytra.

The Problem:
The module's random jump feature could trigger two consecutive jumps within a very short time frame (less than 0.75 seconds). This would accidentally activate the Elytra mid-air, causing the player to start flying and slowly drift away from their original position. Over time, this could lead to falling off high ledges or moving into dangerous areas while AFK.

The Solution:
- Added a cooldown system between random jumps.
- The minimum interval between any two jumps is now 1 full second (20 ticks).
- This interval is longer than the total duration of a single jump in Minecraft (0.75 seconds), ensuring that two jumps cannot occur while the player is still in the air.

The Result:
- Elytra cannot be accidentally activated by back-to-back jumps.
- The player stays completely stationary and safe while AFK.

@Powie69 Powie69 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants