@@ -351,6 +351,7 @@ public String toString()
351351 private boolean pausedNoY ;
352352 private boolean commandForwardUnlimited ;
353353 private Vec3 commandForwardDirection ;
354+ private double commandForwardY ;
354355 private boolean useExistingTargetsOnEnable ;
355356 private boolean arrivalPause ;
356357 private long arrivalPauseUntilMs ;
@@ -507,6 +508,7 @@ protected void onEnable()
507508 arrivedHold = false ;
508509 commandForwardUnlimited = false ;
509510 commandForwardDirection = null ;
511+ commandForwardY = Double .NaN ;
510512 manualAdjustHold = false ;
511513 manualAdjustStartMs = 0L ;
512514 manualAdjustStartPos = null ;
@@ -604,6 +606,7 @@ protected void onDisable()
604606 EVENTS .remove (GUIRenderListener .class , this );
605607 EVENTS .remove (RenderListener .class , this );
606608 PathProcessor .releaseControls ();
609+ clearAutoFlyInput ();
607610 restoreFlightSettings ();
608611 var hax = WURST .getHax ();
609612 if (enabledAntisocialForAutoFly && hax .antisocialHack .isEnabled ())
@@ -655,6 +658,7 @@ protected void onDisable()
655658 currentIndex = -1 ;
656659 commandForwardUnlimited = false ;
657660 commandForwardDirection = null ;
661+ commandForwardY = Double .NaN ;
658662 clearChunkCorridorAssist ();
659663 savedFlightVSpeed = -1 ;
660664 flightOverridesApplied = false ;
@@ -695,8 +699,7 @@ public void onUpdate()
695699 {
696700 // Allow player to decide what to do next (e.g. cycle waypoint).
697701 PathProcessor .releaseControls ();
698- resetAutoKeyFlags ();
699- clearMovementKeys ();
702+ clearAutoFlyInput ();
700703 return ;
701704 }
702705
@@ -772,9 +775,8 @@ public void onUpdate()
772775 {
773776 ensureFlightEnabled ();
774777 applyFlightSpeed ();
775- resetAutoKeyFlags ();
776778 PathProcessor .lockControls ();
777- clearMovementKeys ();
779+ clearAutoFlyInput ();
778780 autoSetKey (MC .options .keyJump , true );
779781 lastAutoControlMs = now ;
780782 return ;
@@ -910,9 +912,8 @@ public void onUpdate()
910912 }
911913
912914 now = System .currentTimeMillis ();
913- resetAutoKeyFlags ();
914915 PathProcessor .lockControls ();
915- clearMovementKeys ();
916+ clearAutoFlyInput ();
916917
917918 boolean approachHoriz = distHoriz <= descentStartRadius ;
918919 boolean nearTargetY =
@@ -986,8 +987,7 @@ private void advanceCruiseTarget()
986987 {
987988 // Stop immediately to avoid overshooting and oscillation at pass turns.
988989 PathProcessor .releaseControls ();
989- resetAutoKeyFlags ();
990- clearMovementKeys ();
990+ clearAutoFlyInput ();
991991 clearPathingState ();
992992 closeHorizLatched = false ;
993993 verticalMode = VerticalMode .NONE ;
@@ -1362,8 +1362,7 @@ private void stopAutoFly(String message)
13621362 {
13631363 // Stop immediately, even if keys were held from the previous tick.
13641364 PathProcessor .releaseControls ();
1365- resetAutoKeyFlags ();
1366- clearMovementKeys ();
1365+ clearAutoFlyInput ();
13671366
13681367 if (disableAutoFlyOnStop .isChecked ())
13691368 {
@@ -2007,8 +2006,7 @@ private void handleTargetReached()
20072006
20082007 // Ensure no keys are left pressed when switching to arrived-hold.
20092008 PathProcessor .releaseControls ();
2010- resetAutoKeyFlags ();
2011- clearMovementKeys ();
2009+ clearAutoFlyInput ();
20122010
20132011 manualAdjustHold = false ;
20142012 manualAdjustStartMs = 0L ;
@@ -2080,8 +2078,11 @@ private boolean isTargetReached(AutoFlyTarget target, Vec3 playerPos,
20802078 private double getCruiseY (AutoFlyTarget target )
20812079 {
20822080 double y = flightHeight .getValue ();
2081+ if (commandForwardUnlimited && target != null && target .hasY
2082+ && !Double .isNaN (commandForwardY ))
2083+ y = commandForwardY ;
20832084 if (routeType .getSelected () != RouteType .CHUNKS && target != null
2084- && target .hasY )
2085+ && target .hasY && ! commandForwardUnlimited )
20852086 y = Math .max (y , target .pos .getY () + 2 );
20862087
20872088 if (MC .level != null )
@@ -2328,20 +2329,27 @@ private void setForwardFromCommand(Double overrideHeight,
23282329 if (MC .player == null )
23292330 return ;
23302331
2331- Vec3 look = MC . player . getLookAngle ();
2332+ Vec3 look = getHorizontalLookDirection ();
23322333 if (look .lengthSqr () < 1.0E-6 )
23332334 look = new Vec3 (0.0 , 0.0 , 1.0 );
23342335 commandForwardDirection = look .normalize ();
2336+ double forwardY =
2337+ overrideHeight != null ? overrideHeight : MC .player .getY ();
2338+ commandForwardY = forwardY ;
23352339 commandForwardUnlimited = unlimitedMode ;
23362340
23372341 Vec3 target = MC .player .position ()
23382342 .add (commandForwardDirection .scale (commandForwardUnlimited
23392343 ? COMMAND_FORWARD_LEAD_DISTANCE : COMMAND_FORWARD_DISTANCE ));
2340- setTargetFromCommand (BlockPos .containing (target ), true , overrideHeight ,
2341- overrideSpeed );
2344+ setTargetFromCommand (BlockPos .containing (target . x , forwardY , target . z ) ,
2345+ true , overrideHeight , overrideSpeed );
23422346 commandForwardUnlimited = unlimitedMode ;
2347+ commandForwardY = forwardY ;
23432348 if (!commandForwardUnlimited )
2349+ {
23442350 commandForwardDirection = null ;
2351+ commandForwardY = Double .NaN ;
2352+ }
23452353 }
23462354
23472355 public void setChunkTrailFromCommand ()
@@ -2383,7 +2391,10 @@ private void refreshUnlimitedForwardTarget()
23832391 Vec3 target = MC .player .position ()
23842392 .add (dir .normalize ().scale (COMMAND_FORWARD_LEAD_DISTANCE ));
23852393 targets .clear ();
2386- targets .add (new AutoFlyTarget (BlockPos .containing (target ), true ));
2394+ double y =
2395+ Double .isNaN (commandForwardY ) ? MC .player .getY () : commandForwardY ;
2396+ targets .add (new AutoFlyTarget (
2397+ BlockPos .containing (target .x , y , target .z ), true ));
23872398 currentIndex = 0 ;
23882399 currentTarget = targets .get (0 );
23892400 }
@@ -2471,8 +2482,7 @@ else if(nowMs - chunkFullyRedSinceMs >= CHUNK_FULL_RED_STOP_MS)
24712482 {
24722483 chunkCorridorTargetPos = null ;
24732484 PathProcessor .releaseControls ();
2474- resetAutoKeyFlags ();
2475- clearMovementKeys ();
2485+ clearAutoFlyInput ();
24762486 stopAutoFly ("Stopped: Fully inside new chunks for 3s" );
24772487 return ;
24782488 }
@@ -2503,8 +2513,7 @@ else if(nowMs - chunkNoGreenSinceMs >= CHUNK_NO_GREEN_STOP_MS)
25032513 {
25042514 chunkCorridorTargetPos = null ;
25052515 PathProcessor .releaseControls ();
2506- resetAutoKeyFlags ();
2507- clearMovementKeys ();
2516+ clearAutoFlyInput ();
25082517 stopAutoFly ("Stopped: No green corridor for 3s" );
25092518 return ;
25102519 }
@@ -3924,8 +3933,7 @@ private void resetAfterTickGap(long now)
39243933 {
39253934 Vec3 playerPos = MC .player .position ();
39263935 PathProcessor .releaseControls ();
3927- resetAutoKeyFlags ();
3928- clearMovementKeys ();
3936+ clearAutoFlyInput ();
39293937 clearPathingState ();
39303938 verticalMode = VerticalMode .NONE ;
39313939 verticalAssistActive = false ;
@@ -3953,7 +3961,7 @@ private void beginManualAdjust(Vec3 playerPos)
39533961 manualAdjustStartMs = System .currentTimeMillis ();
39543962 manualAdjustStartPos = playerPos ;
39553963 lastManualInputMs = manualAdjustStartMs ;
3956- PathProcessor . releaseControls ();
3964+ releaseAutoFlyInput ();
39573965 }
39583966
39593967 private boolean handleAutoEatPause ()
@@ -3965,8 +3973,7 @@ private boolean handleAutoEatPause()
39653973 ensureFlightEnabled ();
39663974 applyFlightSpeed ();
39673975 PathProcessor .releaseControls ();
3968- resetAutoKeyFlags ();
3969- clearMovementKeys ();
3976+ clearAutoFlyInput ();
39703977 clearPathingState ();
39713978 manualAdjustHold = false ;
39723979 manualAdjustStartMs = 0L ;
@@ -4152,6 +4159,18 @@ private void resetAutoKeyFlags()
41524159 autoKeyShiftDown = false ;
41534160 }
41544161
4162+ private void releaseAutoFlyInput ()
4163+ {
4164+ PathProcessor .releaseControls ();
4165+ resetAutoKeyFlags ();
4166+ }
4167+
4168+ private void clearAutoFlyInput ()
4169+ {
4170+ resetAutoKeyFlags ();
4171+ clearMovementKeys ();
4172+ }
4173+
41554174 private boolean anyAutoKeyDown ()
41564175 {
41574176 return autoKeyUpDown || autoKeyDownDown || autoKeyLeftDown
0 commit comments