@@ -190,6 +190,14 @@ static void initialize() {
190190 beforeX = mc .thePlayer .posX ;
191191 beforeY = mc .thePlayer .posY ;
192192 beforeZ = mc .thePlayer .posZ ;
193+ angleEnum = Math .round (AngleUtils .get360RotationYaw () / 90 ) < 4 ? AngleEnum .values ()[Math .round (AngleUtils .get360RotationYaw () / 90 )] : AngleEnum .A0 ;
194+ playerYaw = AngleUtils .angleToValue (angleEnum );
195+
196+ try {
197+ AngleUtils .smoothRotateTo (AngleUtils .get360RotationYaw (playerYaw ), 1 );
198+ } catch (Exception e ) {
199+ e .printStackTrace ();
200+ }
193201
194202 Utils .resetExecutor ();
195203 mc .thePlayer .closeScreen ();
@@ -300,17 +308,30 @@ public void OnKeyPress(InputEvent.KeyInputEvent event) {
300308 mc .displayGuiScreen (new MenuGUI ());
301309 }
302310 if (customKeyBinds [1 ].isPressed ()) {
311+ mc .thePlayer .closeScreen ();
312+ openedGUI = false ;
313+
303314 if (!enabled ) {
304315 LogUtils .scriptLog ("Starting script" , EnumChatFormatting .GREEN );
305316 LogUtils .configLog ();
317+ if (MiscConfig .ungrab ) Utils .ungrabMouse ();
306318 if (MiscConfig .dropStone ) {
307319 LogUtils .scriptLog ("Make sure slot 7 has nothing important or it may be dropped" , EnumChatFormatting .RED );
308320 }
309321 if (MiscConfig .dropStone || AutoSellConfig .autoSell || MiscConfig .autoCookie || MiscConfig .autoGodPot ) {
310322 LogUtils .scriptLog ("Make sure important slots are locked with SBA" , EnumChatFormatting .DARK_BLUE );
311323 }
324+ enabled = true ;
325+ initialize ();
326+ } else {
327+ enabled = false ;
328+ Utils .regrabMouse ();
329+ LogUtils .scriptLog ("Stopped script" );
330+ LogUtils .webhookLog ("Stopped script" );
331+ updateKeys (false , false , false , false , false , false );
332+ Utils .resetExecutor ();
333+ mc .thePlayer .closeScreen ();
312334 }
313- toggle ();
314335 }
315336 }
316337
@@ -581,25 +602,46 @@ else if (!fixTpStuckFlag && blockIn == Blocks.end_portal_frame && (mc.thePlayer.
581602 }
582603 // In trenches walking along the layer
583604 else if (inTrenches ) {
584- angleEnum = Math .round (AngleUtils .get360RotationYaw () / 90 ) < 4 ? AngleEnum .values ()[Math .round (AngleUtils .get360RotationYaw () / 90 )] : AngleEnum .A0 ;
585- playerYaw = AngleUtils .angleToValue (angleEnum );
586605 if (FarmConfig .cropType .equals (CropEnum .NETHERWART )) {
587606 mc .thePlayer .rotationPitch = 0 ;
588607 } else {
589608 mc .thePlayer .rotationPitch = (float ) 2.8 ;
590609 }
610+ if (!rotating && AngleUtils .smallestAngleDifference (AngleUtils .get360RotationYaw (playerYaw ), AngleUtils .get360RotationYaw ()) > 179 ) {
611+ LogUtils .debugLog ("180 pad yaw change detected, ignoring" );
612+ angleEnum = Math .round (AngleUtils .get360RotationYaw () / 90 ) < 4 ? AngleEnum .values ()[Math .round (AngleUtils .get360RotationYaw () / 90 )] : AngleEnum .A0 ;
613+ playerYaw = AngleUtils .angleToValue (angleEnum );
614+ } else if (!rotating && AngleUtils .smallestAngleDifference (AngleUtils .get360RotationYaw (playerYaw ), AngleUtils .get360RotationYaw ()) > 10 ) {
615+ LogUtils .scriptLog ("Possible staff rotation check" , EnumChatFormatting .RED );
616+ LogUtils .webhookLog ("Possible staff rotation check" );
617+ new Thread (() -> {
618+ try {
619+ Thread .sleep (800 );
620+ updateKeys (false , false , false , false , false , false );
621+ Thread .sleep (800 );
622+ AngleUtils .smoothRotateTo (AngleUtils .get360RotationYaw (playerYaw ), 1 );
623+ rotating = false ;
624+ } catch (Exception e ) {
625+ e .printStackTrace ();
626+ }
627+ }).start ();
628+ rotating = true ;
629+ }
630+ if (rotating ) {
631+ return ;
632+ }
591633 // Not falling
592634 if (FarmConfig .farmType == FarmEnum .LAYERED ) {
593635 if (dy == 0 ) {
594636 // If on solid block
595637 if ((mc .thePlayer .posY % 1 ) == 0 ) {
596- if (!stuck && !dropping ) {
597- try {
598- AngleUtils .hardRotate (playerYaw );
599- } catch (Exception e ) {
600- e .printStackTrace ();
601- }
602- }
638+ // if (!stuck && !dropping) {
639+ // try {
640+ // AngleUtils.hardRotate(playerYaw);
641+ // } catch (Exception e) {
642+ // e.printStackTrace();
643+ // }
644+ // }
603645 // Cannot move forwards or backwards
604646 if (!isWalkable (BlockUtils .getFrontBlock ()) && !isWalkable (BlockUtils .getBackBlock ())) {
605647 if (!checkFull && !selling && mc .thePlayer .inventory .getFirstEmptyStack () == -1 ) {
@@ -965,7 +1007,6 @@ public void run() {
9651007 angleEnum = angleEnum .ordinal () < 2 ? AngleEnum .values ()[angleEnum .ordinal () + 2 ] : AngleEnum .values ()[angleEnum .ordinal () - 2 ];
9661008 playerYaw = AngleUtils .angleToValue (angleEnum );
9671009 AngleUtils .smoothRotateClockwise (180 , 1.2f );
968- System .out .println ("-------EXPECTED: " + AngleUtils .get360RotationYaw () + "ACTUAL--------" + playerYaw );
9691010 Thread .sleep (100 );
9701011 KeyBinding .setKeyBindState (PlayerUtils .keybindW , true );
9711012 Thread .sleep (200 );
@@ -1617,18 +1658,6 @@ public static void setStuckCooldown(int seconds) {
16171658 }
16181659
16191660 public static void toggle () {
1620- mc .thePlayer .closeScreen ();
1621- if (enabled ) {
1622- enabled = false ;
1623- LogUtils .scriptLog ("Stopped script" );
1624- LogUtils .webhookLog ("Stopped script" );
1625- updateKeys (false , false , false , false , false , false );
1626- Utils .resetExecutor ();
1627- mc .thePlayer .closeScreen ();
1628- } else {
1629- enabled = true ;
1630- initialize ();
1631- }
1632- openedGUI = false ;
1661+
16331662 }
16341663}
0 commit comments