4242import java .util .concurrent .Executors ;
4343import java .util .concurrent .ScheduledExecutorService ;
4444import java .util .concurrent .TimeUnit ;
45-
4645@ Mod (modid = FarmHelper .MODID , name = FarmHelper .NAME , version = FarmHelper .VERSION )
4746public class FarmHelper
4847{
@@ -209,7 +208,7 @@ public void render(RenderGameOverlayEvent event)
209208 Utils .drawString ("profit/h = " + moneyper10sec * 6 * 60 , 6 , 104 , 0.8f , -1 );
210209 }
211210
212- mc .fontRendererObj .drawString ( Utils .getFrontBlock ()+ " " + Utils .getBackBlock ().toString (), 4 , new ScaledResolution (mc ).getScaledHeight () - 20 , -1 );
211+ mc .fontRendererObj .drawString (Utils .getFrontBlock () + " " + Utils .getBackBlock (). toString () + " " + Utils . getRightBlock (). toString () + " " + Utils . getLeftBlock ().toString (), 4 , new ScaledResolution (mc ).getScaledHeight () - 20 , -1 );
213212
214213
215214 }
@@ -300,15 +299,22 @@ public void OnTickPlayer(TickEvent.ClientTickEvent event) { //Client -> player
300299 KeyBinding .setKeyBindState (keybindD , true );
301300 Thread .sleep (300 );
302301 KeyBinding .setKeyBindState (keybindD , false );
302+ Thread .sleep (300 );
303+
303304 if (Config .FarmType == FarmEnum .LAYERED ){
304305 if (isWalkable (Utils .getFrontBlock ())) {
305306 initialX = (int )mc .thePlayer .posX ;
306307 initialZ = (int )mc .thePlayer .posZ ;
307308 process3 = true ;
308309 }
310+ Utils .debugLog (mc .thePlayer , "Checking if stuck at start" );
311+ if (!isWalkable (Utils .getFrontBlock ()) && !isWalkable (Utils .getBackBlock ()) && !isWalkable (Utils .getRightBlock ()) && isWalkable (Utils .getLeftBlock ())) {
312+ Utils .debugLog (mc .thePlayer , "Stuck at start of farm, changing direction" );
313+ ExecuteRunnable (changeMotion );
314+ Utils .debugLog (mc .thePlayer , "Changed direction" );
315+ }
309316 }
310317 ExecuteRunnable (stopAntistuck );
311-
312318 //exec
313319 }catch (Exception e ){
314320 e .printStackTrace ();
@@ -509,6 +515,7 @@ public void run() {
509515 }
510516 };
511517
518+
512519 Runnable changeLayer = () -> {
513520 if (!notInIsland && !emergency ) {
514521 try {
@@ -521,17 +528,27 @@ public void run() {
521528 Utils .smoothRotateClockwise (180 );
522529 Thread .sleep (2000 );
523530 rotating = false ;
531+
532+ // After 180 you are at back of trench, hold W for some time to go to front
533+ KeyBinding .setKeyBindState (keybindW , true );
534+ Thread .sleep (500 );
535+ KeyBinding .setKeyBindState (keybindW , false );
536+
524537 enabled = true ;
525538 }catch (Exception e ){
526539 e .printStackTrace ();
527540 }
541+
528542 }
529543 };
530544
531545 Runnable changeMotion = () -> {
546+ Utils .debugLog (mc .thePlayer , "Trying to change motion" );
532547 if (!notInIsland && !emergency ) {
533548 process1 = !process1 ;
534549 process2 = !process2 ;
550+ Utils .debugLog (mc .thePlayer , "1:" + process1 + ", 2: " + process2 + ", 3: " + process3 + ", 4: " + process4 );
551+ Utils .debugLog (mc .thePlayer , "Motion function: changed" );
535552 set = false ;
536553 }
537554 };
@@ -736,13 +753,17 @@ void clickWindow(int windowID, int slotID, int mouseButtonClicked, int mode) thr
736753 }
737754 }
738755 void initialize (){
756+ Utils .debugLog (mc .thePlayer , "Initializing" );
739757 deltaX = 10000 ;
740758 deltaZ = 10000 ;
741759 deltaY = 0 ;
742760
743-
744761 process1 = true ;
745762 process2 = false ;
763+ if (!isWalkable (Utils .getFrontBlock ()) && !isWalkable (Utils .getBackBlock ()) && !isWalkable (Utils .getRightBlock ()) && isWalkable (Utils .getLeftBlock ())) {
764+ process1 = false ;
765+ process2 = true ;
766+ }
746767 process3 = false ;
747768 process4 = false ;
748769 if (Config .FarmType == FarmEnum .LAYERED ){
@@ -751,7 +772,6 @@ void initialize(){
751772 }
752773 }
753774
754-
755775 setspawned = false ;
756776 shdBePressingKey = true ;
757777 notInIsland = false ;
0 commit comments