@@ -3,6 +3,7 @@ updateScript(file.getAbsolutePath(), 'jayc331/JSMacros-Scripts', './config/jayc3
33
44import Config from '../libs/Config' ;
55import { AntiAFK } from './AntiAFK' ;
6+ import { PhantomBlocks } from './PhantomBlocks' ;
67import { BaritoneAPI , BetterBlockPos } from '../libs/BaritoneAPIProvider' ;
78import { Key } from '../libs/KeyManager' ;
89import { CommandManager } from '../libs/CommandBuilderWrapper' ;
@@ -37,6 +38,7 @@ interface StrafingOptions {
3738 interact : DirectionConfig < InteractionConfig > ;
3839 pitch : DirectionConfig < number | null > ;
3940 threshold : DirectionConfig < number > ;
41+ flight : boolean ;
4042}
4143
4244interface StrafingConfig {
@@ -68,6 +70,7 @@ class StrafingScript {
6870 } ,
6971 pitch : { left : - 2 , right : - 10 } ,
7072 threshold : { left : 0.5 , right : 0.5 } ,
73+ flight : true ,
7174 } ,
7275 } ;
7376
@@ -135,7 +138,7 @@ class StrafingScript {
135138 /**
136139 * Updates a directional configuration option safely.
137140 */
138- private updateOption < K extends keyof StrafingOptions > (
141+ private updateOption < K extends 'sneak' | 'interact' | 'pitch' | 'threshold' > (
139142 key : K ,
140143 direction : Direction ,
141144 updater : ( current : StrafingOptions [ K ] [ 'left' ] ) => StrafingOptions [ K ] [ 'left' ]
@@ -190,6 +193,12 @@ class StrafingScript {
190193 this . showStatus ( `§7Interact set to §a${ ref . mode } §7 (${ ref . key } , ${ ref . cps } CPS) for §e${ direction } ` ) ;
191194 }
192195
196+ public setFlight ( state : boolean ) {
197+ this . config . options . flight = state ;
198+ this . saveConfig ( ) ;
199+ this . showStatus ( `§7Flight recovery set to §a${ state } ` ) ;
200+ }
201+
193202 // =========================================================================
194203 // Control Logic
195204 // =========================================================================
@@ -202,7 +211,7 @@ class StrafingScript {
202211 JsMacros . off ( this . tickListener ) ;
203212 this . tickListener = null ;
204213 }
205-
214+
206215 // Clear visuals
207216 try {
208217 if ( this . currentSelection ) {
@@ -231,7 +240,7 @@ class StrafingScript {
231240
232241 this . isRunning = true ;
233242 this . captchaProceed = true ;
234- this . isStarting = true ;
243+ this . isStarting = this . config . options . flight ;
235244 this . startTickCounter = 0 ;
236245 this . currentTarget = 2 ;
237246 this . startTime = Date . now ( ) ;
@@ -252,13 +261,18 @@ class StrafingScript {
252261 JavaWrapper . methodToJava ( ( ) => this . tick ( ) )
253262 ) ;
254263 }
255- this . showStatus ( '§aStrafing initializing...' ) ;
264+
265+ if ( this . isStarting ) {
266+ this . showStatus ( '§aStrafing initializing...' ) ;
267+ } else {
268+ this . showStatus ( '§aStrafing started!' ) ;
269+ }
256270 }
257271
258272 private updateVisuals ( ) {
259273 try {
260274 const primary = BaritoneAPI . getProvider ( ) . getPrimaryBaritone ( ) ;
261-
275+
262276 if ( this . currentSelection ) {
263277 primary . getSelectionManager ( ) . removeSelection ( this . currentSelection ) ;
264278 this . currentSelection = null ;
@@ -315,6 +329,12 @@ class StrafingScript {
315329
316330 private tick ( ) {
317331 try {
332+ // Force allowPaused to true (field_1695)
333+ const mc = Client . getMinecraft ( ) ;
334+ const field = Reflection . getDeclaredField ( mc . getClass ( ) , 'field_1695' ) ;
335+ field . setAccessible ( true ) ;
336+ field . set ( mc , true ) ;
337+
318338 if ( ! this . isRunning ) return ;
319339
320340 const player = Player . getPlayer ( ) ;
@@ -333,15 +353,15 @@ class StrafingScript {
333353 this . showStatus ( '§eStrafing paused (Out of Bounds).' , 100 ) ;
334354 return ;
335355 }
336-
356+
337357 // 3. Screen Check (Inventory Open)
338358 if ( Hud . getOpenScreen ( ) ) {
339- this . cleanupKeys ( ) ;
340- return ;
359+ this . cleanupKeys ( ) ;
360+ return ;
341361 }
342362
343363 // 4. Flight Recovery
344- if ( ! player . getAbilities ( ) . getFlying ( ) && ! this . isStarting ) {
364+ if ( this . config . options . flight && ! player . getAbilities ( ) . getFlying ( ) && ! this . isStarting ) {
345365 this . isStarting = true ;
346366 this . startTickCounter = 0 ;
347367 this . cleanupKeys ( ) ;
@@ -383,7 +403,7 @@ class StrafingScript {
383403 // Tick 2: Release
384404 // Tick 4: Press (Toggle flight)
385405 // Tick 6: Release
386-
406+
387407 if ( tick === 0 ) this . keys . jump . set ( true ) ;
388408 if ( tick === 2 ) this . keys . jump . set ( false ) ;
389409 if ( tick === 4 ) this . keys . jump . set ( true ) ;
@@ -393,8 +413,9 @@ class StrafingScript {
393413 if ( player . getAbilities ( ) . getFlying ( ) ) {
394414 this . isStarting = false ;
395415 this . showStatus ( '§aStrafing started!' ) ;
396- } else if ( tick > 20 ) { // Retry after 1 second
397- this . startTickCounter = 0 ;
416+ } else if ( tick > 20 ) {
417+ // Retry after 1 second
418+ this . startTickCounter = 0 ;
398419 }
399420 }
400421 }
@@ -508,15 +529,15 @@ class StrafingScript {
508529 // Dynamic hold time based on CPS to ensure reliability
509530 // Aim for ~60-70% duty cycle, but ensure at least 60ms if possible (for reliable server tick detection)
510531 // and ensure we leave at least 25ms gap for the release logic.
511-
532+
512533 const maxPossibleHold = Math . max ( 0 , interval - 40 ) ; // Leave ~40ms gap
513534 const targetHold = Math . min ( maxPossibleHold , Math . max ( 60 , interval * 0.6 ) ) ;
514535 const randomness = Math . min ( 30 , maxPossibleHold - targetHold ) ; // Add jitter if room exists
515536
516537 const holdTime = targetHold + Math . random ( ) * randomness ;
517-
538+
518539 state . releaseTime = now + holdTime ;
519-
540+
520541 // Schedule next press
521542 state . nextPressTime = Math . max ( now , state . nextPressTime ) + interval ;
522543 }
@@ -536,6 +557,7 @@ const strafer = new StrafingScript();
536557const antiAFK = new AntiAFK ( ( active ) => {
537558 strafer . captchaProceed = ! active ;
538559} ) ;
560+ const phantomBlocks = new PhantomBlocks ( ) ;
539561
540562( event as any ) . stopListener = JavaWrapper . methodToJava ( ( ) => strafer . stop ( ) ) ;
541563
@@ -620,6 +642,10 @@ set.literal('threshold')
620642 . suggestMatching ( [ 'both' , 'left' , 'right' ] )
621643 . executes ( ( ctx ) => strafer . setDistanceThreshold ( ctx . getArg ( 'value' ) , ctx . getArg ( 'direction' ) ) ) ;
622644
645+ set . literal ( 'flight' )
646+ . argument ( 'state' , 'boolean' )
647+ . executes ( ( ctx ) => strafer . setFlight ( ctx . getArg ( 'state' ) ) ) ;
648+
623649strafe . register ( ) ;
624650
625651export default event ;
0 commit comments