Skip to content

Commit 8373bf3

Browse files
committed
fix(skyblock): check bounds before re-enabling flight
- Prevents infinite flight re-enable loop when out of bounds.
1 parent 0e97b8f commit 8373bf3

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/skyblock/main.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { updateScript } from '../libs/Updater';
2-
updateScript(file.getAbsolutePath(), 'jayc331/JSMacros-Scripts', './config/jayc331-config.json');
2+
// updateScript(file.getAbsolutePath(), 'jayc331/JSMacros-Scripts', './config/jayc331-config.json');
33

44
import Config from '../libs/Config';
55
import { AntiAFK } from './AntiAFK';
@@ -337,6 +337,12 @@ class StrafingScript {
337337
return true; // Just skip inputs, don't necessarily stop unless it's long
338338
}
339339

340+
const pPos = player.getPos();
341+
if (this.isOutOfBounds(pPos)) {
342+
this.pause();
343+
return true;
344+
}
345+
340346
if (!player.getAbilities().getFlying()) {
341347
// Re-init flight
342348
this.isStarting = true;
@@ -345,12 +351,6 @@ class StrafingScript {
345351
return true;
346352
}
347353

348-
const pPos = player.getPos();
349-
if (this.isOutOfBounds(pPos)) {
350-
this.pause();
351-
return true;
352-
}
353-
354354
return false;
355355
}
356356

@@ -413,11 +413,13 @@ class StrafingScript {
413413

414414
private checkTargetSwitch(player: any, dir: Direction) {
415415
const { '1': p1, '2': p2 } = this.config.position;
416-
const target = this.currentTarget === 1 ? p1 : p2;
416+
const rawTarget = this.currentTarget === 1 ? p1 : p2;
417+
const target = { x: rawTarget.x + 0.5, z: rawTarget.z + 0.5 };
417418
const pPos = player.getPos();
418419

419420
const dist = Math.sqrt(Math.pow(pPos.getX() - target.x, 2) + Math.pow(pPos.getZ() - target.z, 2));
420-
const threshold = this.config.options.threshold[dir === 'left' ? 'left' : 'right'];
421+
// Default threshold to 0.5 if not set or invalid
422+
const threshold = this.config.options.threshold[dir === 'left' ? 'left' : 'right'] || 0.5;
421423

422424
if (dist < threshold) {
423425
this.currentTarget = this.currentTarget === 1 ? 2 : 1;

0 commit comments

Comments
 (0)