11import { 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
44import Config from '../libs/Config' ;
55import { 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