Skip to content

Commit 864a123

Browse files
author
Ahmed Mahmud
committed
fixed crash issues
1 parent 38c09cd commit 864a123

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

src/main/java/com/jelly/FarmHelper/FarmHelper.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ public void OnTickPlayer(TickEvent.ClientTickEvent event) {
346346
if (mc.currentScreen instanceof GuiIngameMenu) {
347347
// LogUtils.debugLog("Detected esc menu, stopping all threads");
348348
Utils.resetExecutor();
349+
updateKeys(false, false, false, false, false, false);
350+
return;
349351
}
350352

351353
if (mc.currentScreen instanceof GuiInventory && buying) {
@@ -355,6 +357,7 @@ public void OnTickPlayer(TickEvent.ClientTickEvent event) {
355357
buying = false;
356358
cookie = true;
357359
godPot = true;
360+
return;
358361
}
359362

360363
if (buying && (System.currentTimeMillis() - timeoutStart) > 20000) {
@@ -373,6 +376,7 @@ public void OnTickPlayer(TickEvent.ClientTickEvent event) {
373376
LogUtils.debugLog("Failed to buy 3 times, turning off auto cookie/pot");
374377
LogUtils.webhookLog("Failed to buy 3 times, turning off auto cookie/pot");
375378
}
379+
return;
376380
}
377381

378382
if (selling && checkFull && (System.currentTimeMillis() - timeoutStart) > 20000) {
@@ -396,7 +400,7 @@ public void OnTickPlayer(TickEvent.ClientTickEvent event) {
396400
double dz = Math.abs(mc.thePlayer.posZ - mc.thePlayer.lastTickPosZ);
397401
double dy = Math.abs(mc.thePlayer.posY - mc.thePlayer.lastTickPosY);
398402
currentLocation = getLocation();
399-
Utils.ExecuteRunnable(updateCounters);
403+
if (ProfitCalculatorConfig.profitCalculator) Utils.ExecuteRunnable(updateCounters);
400404

401405
if (caged) {
402406
switch (currentLocation) {
@@ -585,7 +589,7 @@ else if (inTrenches) {
585589
if ((mc.thePlayer.posY % 1) == 0) {
586590
if (!stuck && !dropping) {
587591
try {
588-
AngleUtils.hardRotate(playerYaw);
592+
// AngleUtils.hardRotate(playerYaw);
589593
} catch (Exception e) {
590594
e.printStackTrace();
591595
}
@@ -822,7 +826,7 @@ else if ((mc.thePlayer.posY % 1) == 0.8125) {
822826
}
823827
} else {
824828
try {
825-
AngleUtils.hardRotate(playerYaw);
829+
// AngleUtils.hardRotate(playerYaw);
826830
} catch (Exception e) {
827831
e.printStackTrace();
828832
}
@@ -955,6 +959,7 @@ public void run() {
955959
angleEnum = angleEnum.ordinal() < 2 ? AngleEnum.values()[angleEnum.ordinal() + 2] : AngleEnum.values()[angleEnum.ordinal() - 2];
956960
playerYaw = AngleUtils.angleToValue(angleEnum);
957961
AngleUtils.smoothRotateClockwise(180, 1.2f);
962+
System.out.println("-------EXPECTED: " + AngleUtils.get360RotationYaw() + "ACTUAL--------" + playerYaw);
958963
Thread.sleep(100);
959964
KeyBinding.setKeyBindState(PlayerUtils.keybindW, true);
960965
Thread.sleep(200);
@@ -1341,6 +1346,7 @@ public void run() {
13411346
Thread.sleep(100);
13421347
KeyBinding.onTick(PlayerUtils.keybindUseItem);
13431348
}
1349+
Thread.sleep(20);
13441350
KeyBinding.setKeyBindState(PlayerUtils.keybindUseItem, false);
13451351
if (mc.thePlayer.inventory.getFirstEmptyStack() != -1) {
13461352
InventoryUtils.waitForItemClick(19, "God Potion", 4, "Bits Shop");
@@ -1358,7 +1364,10 @@ public void run() {
13581364
Thread.sleep(100);
13591365
}
13601366
LogUtils.debugLog("Found god pot in inventory, switching");
1367+
KeyBinding.unPressAllKeys();
13611368
mc.thePlayer.closeScreen();
1369+
Thread.sleep(20);
1370+
KeyBinding.setKeyBindState(PlayerUtils.keybindUseItem, false);
13621371
while (mc.currentScreen instanceof GuiContainer) {
13631372
if (Thread.currentThread().isInterrupted()) throw new Exception("Detected interrupt - stopping");
13641373
LogUtils.debugLog("Waiting for shop to close");

src/main/java/com/jelly/FarmHelper/utils/AngleUtils.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,18 @@ public static float getActualRotationYaw(float yaw) { //f3
133133
(-yaw % 360 > 180 ? (180 - (-yaw % 360 - 180)) : -(-yaw % 360));
134134
}
135135

136-
public static void hardRotate(float yaw) throws Exception {
137-
while (get360RotationYaw() != yaw) {
138-
if (Thread.currentThread().isInterrupted()) throw new Exception("Detected interrupt - stopping");
139-
if (Math.abs(get360RotationYaw() - yaw) < 0.2f) {
140-
mc.thePlayer.rotationYaw = yaw;
141-
return;
142-
}
143-
if (shouldRotateClockwise(get360RotationYaw(), yaw)) {
144-
mc.thePlayer.rotationYaw += 0.1f;
145-
} else {
146-
mc.thePlayer.rotationYaw -= 0.1f;
147-
}
136+
public static void hardRotate(float yaw) {
137+
Minecraft mc = Minecraft.getMinecraft();
138+
if (Math.abs(mc.thePlayer.rotationYaw - yaw) < 0.2f) {
139+
mc.thePlayer.rotationYaw = yaw;
140+
return;
141+
}
142+
while (mc.thePlayer.rotationYaw > yaw) {
143+
mc.thePlayer.rotationYaw -= 0.1f;
144+
}
145+
while (mc.thePlayer.rotationYaw < yaw) {
146+
mc.thePlayer.rotationYaw += 0.1f;
147+
148148
}
149149
}
150150
}

0 commit comments

Comments
 (0)