Skip to content

Commit c7aab5a

Browse files
committed
fix: elevated antiafk priority in tick subroutine order
1 parent b9b3c0e commit c7aab5a

File tree

1 file changed

+32
-53
lines changed

1 file changed

+32
-53
lines changed

src/skyblock/main.ts

Lines changed: 32 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ class StrafingScript {
7171
// State
7272
private currentTarget: 1 | 2 = 2;
7373
public isRunning = false;
74-
public isPaused = false;
74+
public captchaProceed = true;
75+
7576
private isStarting = false;
7677
private startTickCounter = 0;
7778

@@ -183,19 +184,6 @@ class StrafingScript {
183184
// Control Logic
184185
// =========================================================================
185186

186-
public pause() {
187-
if (!this.isRunning || this.isPaused) return;
188-
this.isPaused = true;
189-
this.cleanupKeys();
190-
this.showStatus('§eStrafing paused (Out of Bounds/AFK Check).');
191-
}
192-
193-
public resume() {
194-
if (!this.isRunning || !this.isPaused) return;
195-
this.isPaused = false;
196-
this.showStatus('§aStrafing resumed.');
197-
}
198-
199187
public stop() {
200188
if (!this.isRunning) return;
201189
this.isRunning = false;
@@ -222,7 +210,7 @@ class StrafingScript {
222210
}
223211

224212
this.isRunning = true;
225-
this.isPaused = false;
213+
this.captchaProceed = true;
226214
this.isStarting = true;
227215
this.startTickCounter = 0;
228216
this.currentTarget = 2;
@@ -266,7 +254,11 @@ class StrafingScript {
266254
this.keys.jump.release();
267255
}
268256

269-
private isOutOfBounds(pos: any): boolean {
257+
public get outOfBounds(): boolean {
258+
const player = Player.getPlayer();
259+
if (!player) return false;
260+
const pos = player.getPos();
261+
270262
const { '1': p1, '2': p2 } = this.config.position;
271263
if (isNaN(p1.x) || isNaN(p2.x)) return false;
272264

@@ -296,17 +288,35 @@ class StrafingScript {
296288
const player = Player.getPlayer();
297289
if (!player) return;
298290

299-
if (this.isPaused) {
300-
this.checkResume(player);
291+
// 1. External Pause (AntiAFK)
292+
if (!this.captchaProceed) {
293+
this.cleanupKeys();
294+
this.showStatus('§eStrafing paused (AntiAFK).', 100);
301295
return;
302296
}
303297

304-
if (this.isStarting) {
305-
this.handleStartup(player);
298+
// 2. Bounds Check
299+
if (this.outOfBounds) {
300+
this.cleanupKeys();
301+
this.showStatus('§eStrafing paused (Out of Bounds).', 100);
306302
return;
307303
}
304+
305+
// 3. Screen Check (Inventory Open)
306+
if (Hud.getOpenScreen()) {
307+
this.cleanupKeys();
308+
return;
309+
}
308310

309-
if (this.shouldPauseOrStop(player)) {
311+
// 4. Flight Recovery
312+
if (!player.getAbilities().getFlying()) {
313+
this.isStarting = true;
314+
this.startTickCounter = 0;
315+
this.cleanupKeys();
316+
}
317+
318+
if (this.isStarting) {
319+
this.handleStartup(player);
310320
return;
311321
}
312322

@@ -324,36 +334,6 @@ class StrafingScript {
324334
}
325335
}
326336

327-
private checkResume(player: any) {
328-
const pPos = player.getPos();
329-
if (!this.isOutOfBounds(pPos)) {
330-
this.resume();
331-
}
332-
}
333-
334-
private shouldPauseOrStop(player: any): boolean {
335-
if (Hud.getOpenScreen()) {
336-
this.cleanupKeys();
337-
return true; // Just skip inputs, don't necessarily stop unless it's long
338-
}
339-
340-
const pPos = player.getPos();
341-
if (this.isOutOfBounds(pPos)) {
342-
this.pause();
343-
return true;
344-
}
345-
346-
if (!player.getAbilities().getFlying()) {
347-
// Re-init flight
348-
this.isStarting = true;
349-
this.startTickCounter = 0;
350-
this.cleanupKeys();
351-
return true;
352-
}
353-
354-
return false;
355-
}
356-
357337
private handleStartup(player: any) {
358338
if (this.startTickCounter === 0) {
359339
if (player.getAbilities().getFlying()) {
@@ -494,8 +474,7 @@ class StrafingScript {
494474

495475
const strafer = new StrafingScript();
496476
const antiAFK = new AntiAFK((active) => {
497-
if (active) strafer.pause();
498-
else strafer.resume();
477+
strafer.captchaProceed = !active;
499478
});
500479

501480
(event as any).stopListener = JavaWrapper.methodToJava(() => strafer.stop());

0 commit comments

Comments
 (0)