Skip to content

Commit

Permalink
Fly pathfinder:
Browse files Browse the repository at this point in the history
 = Fixed false tp and rotation check while aotv'ing during fly (again)
 + Will aotv only if it's path is clear (won't tp into walls)

GUIs:
 = Lowered minimum delay down to 50ms (1 tick), need further tests, but should work even with higher/unstable ping
 + Added check for not loaded guis (lag spikes, high ping)

Pests Destroyer:
 = Fixed not able to reach pest with 1st tier of vacuum
 = Manual pests destroyer can be run regardless of amount of pests (except of 0, lol)
 = Macro will try to fly more above the pest, instead of into the pest

Visitors Macro:
 = Tweaks and fixes in compactor mode
  • Loading branch information
May2Beez committed Apr 27, 2024
1 parent cf24d44 commit 1c32c00
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 98 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ baseGroup=com.jelly.farmhelperv2
mcVersion=1.8.9
modid=farmhelperv2
modName=FarmHelper
version=2.6.6
version=2.6.7
shouldRelease=true
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,7 @@ public enum SPRAYONATOR_ITEM {
@Slider(
name = "GUI Delay", category = DELAYS, subcategory = "GUI Delays",
description = "The delay between clicking during GUI macros (in milliseconds)",
min = 250f, max = 2000f
min = 50f, max = 2000f
)
public static float macroGuiDelay = 400f;
@Slider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public void onReceivedPacketDetection(ReceivePacketEvent event) {
double playerPitch = mc.thePlayer.rotationPitch;
double yawDiff = Math.abs(packetYaw - playerYaw);
double pitchDiff = Math.abs(packetPitch - playerPitch);
if (FlyPathFinderExecutor.getInstance().isRunning() && FlyPathFinderExecutor.getInstance().isRotationInCache((float) packetYaw, (float) packetPitch)) {
LogUtils.sendDebug("[Failsafe] Rotation packet received while Fly pathfinder is running. Ignoring");
if (FlyPathFinderExecutor.getInstance().isRunning() && (FlyPathFinderExecutor.getInstance().isTping() || FlyPathFinderExecutor.getInstance().getLastTpTime() + 100 > System.currentTimeMillis() || FlyPathFinderExecutor.getInstance().isRotationInCache((float) packetYaw, (float) packetPitch))) {
LogUtils.sendDebug("[Failsafe] Teleport packet received while Fly pathfinder is running. Ignoring");
return;
}
if (yawDiff == 360 && pitchDiff == 0) // prevents false checks
Expand Down Expand Up @@ -111,7 +111,8 @@ private void evaluateRotation() {
if (rotationBeforeReacting == null) {
LogUtils.sendDebug("[Failsafe] Original rotation is null. Ignoring");
return;
} if (shouldTriggerCheck(rotationBeforeReacting.getYaw(), rotationBeforeReacting.getPitch())) {
}
if (shouldTriggerCheck(rotationBeforeReacting.getYaw(), rotationBeforeReacting.getPitch())) {
FailsafeManager.getInstance().possibleDetection(this);
} else {
FailsafeManager.getInstance().stopFailsafes();
Expand All @@ -123,7 +124,7 @@ private void evaluateRotation() {
}

private boolean shouldTriggerCheck(double newYaw, double newPitch) {
double yawDiff = Math.abs(newYaw - mc.thePlayer.rotationYaw);
double yawDiff = Math.abs(newYaw - mc.thePlayer.rotationYaw);
double pitchDiff = Math.abs(newPitch - mc.thePlayer.rotationPitch);
double yawThreshold = FarmHelperConfig.rotationCheckYawSensitivity;
double pitchThreshold = FarmHelperConfig.rotationCheckPitchSensitivity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void onReceivedPacketDetection(ReceivePacketEvent event) {
LogUtils.sendDebug("[Failsafe] Player is below Y = 0. Ignoring");
return;
}
if (FlyPathFinderExecutor.getInstance().isRunning() && (FlyPathFinderExecutor.getInstance().isTping() || FlyPathFinderExecutor.getInstance().isPositionInCache(packetPlayerBlockPos))) {
if (FlyPathFinderExecutor.getInstance().isRunning() && (FlyPathFinderExecutor.getInstance().isTping() || FlyPathFinderExecutor.getInstance().getLastTpTime() + 100 > System.currentTimeMillis() || FlyPathFinderExecutor.getInstance().isPositionInCache(packetPlayerBlockPos))) {
LogUtils.sendDebug("[Failsafe] Teleport packet received while Fly pathfinder is running. Ignoring");
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ private void handleBuyFromBz() {
this.buyState = BuyState.BZ_VERIFY;
break;
case BZ_VERIFY:
if (!InventoryUtils.isInventoryLoaded()) return;
if (this.openedChestGuiNameStartsWith("Bazaar ➜ \"")) {
log("Opened Bz.");
this.timer.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
Expand Down Expand Up @@ -226,6 +227,7 @@ private void handleBuyFromBz() {
this.buyState = BuyState.PRODUCT_VERIFY;
break;
case PRODUCT_VERIFY:
if (!InventoryUtils.isInventoryLoaded()) return;
if (this.openedChestGuiProductNameStartsWith(this.itemToBuy)) {
log("Opened item page.");
this.timer.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
Expand All @@ -248,6 +250,7 @@ private void handleBuyFromBz() {
this.timer.schedule(2000);
break;
case BUY_INSTANTLY_VERIFY:
if (!InventoryUtils.isInventoryLoaded()) return;
if (this.openedChestGuiNameStartsWith(this.itemToBuy + " ➜ Instant Buy")) {
log("Opened instant buy page");
this.timer.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
Expand Down Expand Up @@ -288,6 +291,7 @@ private void handleBuyFromBz() {
}
break;
case OPEN_SIGN:
if (!InventoryUtils.isInventoryLoaded()) return;
if (!this.hasTimerEnded()) return;

Slot signSlot = InventoryUtils.getSlotOfItemInContainer("Custom Amount");
Expand Down Expand Up @@ -326,6 +330,7 @@ private void handleBuyFromBz() {
this.buyState = BuyState.VERIFY_CONFIRM_PAGE;
break;
case VERIFY_CONFIRM_PAGE:
if (!InventoryUtils.isInventoryLoaded()) return;
if (this.openedChestGuiNameContains("Confirm Instant Buy")) {
log("Opened confirm buy page");
this.buyNowButtonSlot = InventoryUtils.getSlotIdOfItemInContainer("Custom Amount");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ public void onTickUpdate(TickEvent.ClientTickEvent event) {
case CLICK_ODDITIES:
if (mc.currentScreen == null) {
autoCookieDelay.schedule(getRandomDelay());
setBazaarState(BazaarState.OPEN_BAZAAR);
break;
}
if (!InventoryUtils.isInventoryLoaded()) return;
if (InventoryUtils.getInventoryName() != null && InventoryUtils.getInventoryName().startsWith("Bazaar ➜ Oddities")) {
setBazaarState(BazaarState.CLICK_COOKIE);
autoCookieDelay.schedule(getRandomDelay());
Expand Down Expand Up @@ -307,6 +307,7 @@ public void onTickUpdate(TickEvent.ClientTickEvent event) {
break;
}

if (!InventoryUtils.isInventoryLoaded()) return;
if (InventoryUtils.getInventoryName() != null && InventoryUtils.getInventoryName().startsWith("Bazaar ➜") && !InventoryUtils.getInventoryName().startsWith("Bazaar ➜ Oddities")) {
setBazaarState(BazaarState.CLICK_ODDITIES);
autoCookieDelay.schedule(getRandomDelay());
Expand Down Expand Up @@ -337,6 +338,7 @@ public void onTickUpdate(TickEvent.ClientTickEvent event) {
autoCookieDelay.schedule(getRandomDelay());
break;
}
if (!InventoryUtils.isInventoryLoaded()) return;
if (InventoryUtils.getInventoryName() != null && InventoryUtils.getInventoryName().startsWith("Oddities ➜") && !InventoryUtils.getInventoryName().startsWith("Oddities ➜ Booster Cookie")) {
setBazaarState(BazaarState.OPEN_BAZAAR);
autoCookieDelay.schedule(getRandomDelay());
Expand All @@ -361,6 +363,7 @@ public void onTickUpdate(TickEvent.ClientTickEvent event) {
autoCookieDelay.schedule(getRandomDelay());
break;
}
if (!InventoryUtils.isInventoryLoaded()) return;
if (InventoryUtils.getInventoryName() != null && InventoryUtils.getInventoryName().startsWith("Booster Cookie ➜") && !InventoryUtils.getInventoryName().startsWith("Booster Cookie ➜ Instant Buy")) {
setBazaarState(BazaarState.OPEN_BAZAAR);
autoCookieDelay.schedule(getRandomDelay());
Expand Down
29 changes: 14 additions & 15 deletions src/main/java/com/jelly/farmhelperv2/feature/impl/AutoGodPot.java
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,10 @@ private void onAhState(boolean rightClick) {
break;
case OPEN_BROWSER:
if (mc.currentScreen == null) {
setAhState(AhState.OPEN_AH);
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
break;
}
if (!InventoryUtils.isInventoryLoaded()) return;
if (!Objects.requireNonNull(InventoryUtils.getInventoryName()).contains("Auction House")) break;
Slot ahBrowserItem = InventoryUtils.getSlotOfItemInContainer("Auctions Browser");
if (ahBrowserItem == null) break;
Expand All @@ -322,10 +322,10 @@ private void onAhState(boolean rightClick) {
break;
case CLICK_SEARCH:
if (mc.currentScreen == null) {
setAhState(AhState.OPEN_AH);
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
break;
}
if (!InventoryUtils.isInventoryLoaded()) return;
if (Objects.requireNonNull(InventoryUtils.getInventoryName()).startsWith("Auctions: \"God Potion\"")) {
setAhState(AhState.SORT_ITEMS);
break;
Expand All @@ -344,10 +344,10 @@ private void onAhState(boolean rightClick) {
break;
case SORT_ITEMS:
if (mc.currentScreen == null) {
setAhState(AhState.OPEN_AH);
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
break;
}
if (!InventoryUtils.isInventoryLoaded()) return;
if (checkIfWrongInventory("Auctions: \"God Potion\"")) break;
Slot sortItem = InventoryUtils.getSlotOfItemInContainer("Sort");
if (sortItem == null) break;
Expand All @@ -362,10 +362,10 @@ private void onAhState(boolean rightClick) {
break;
case CHECK_IF_BIN:
if (mc.currentScreen == null) {
setAhState(AhState.OPEN_AH);
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
break;
}
if (!InventoryUtils.isInventoryLoaded()) return;
if (checkIfWrongInventory("Auctions: \"God Potion\"")) break;
Slot binItem = InventoryUtils.getSlotOfItemInContainer("BIN Filter");
if (binItem == null) break;
Expand All @@ -380,10 +380,10 @@ private void onAhState(boolean rightClick) {
break;
case SELECT_ITEM:
if (mc.currentScreen == null) {
setAhState(AhState.OPEN_AH);
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
break;
}
if (!InventoryUtils.isInventoryLoaded()) return;
if (checkIfWrongInventory("Auctions: \"God Potion\"")) break;
for (Slot slot : mc.thePlayer.openContainer.inventorySlots) {
if (!slot.getHasStack()) continue;
Expand Down Expand Up @@ -412,10 +412,10 @@ private void onAhState(boolean rightClick) {
break;
case BUY_ITEM:
if (mc.currentScreen == null) {
setAhState(AhState.OPEN_AH);
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
break;
}
if (!InventoryUtils.isInventoryLoaded()) return;
if (checkIfWrongInventory("BIN Auction View")) break;
Slot buyItem = InventoryUtils.getSlotOfItemInContainer("Buy Item Right Now");
if (buyItem == null) {
Expand All @@ -442,10 +442,10 @@ private void onAhState(boolean rightClick) {
break;
case CONFIRM_PURCHASE:
if (mc.currentScreen == null) {
setAhState(AhState.OPEN_AH);
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
break;
}
if (!InventoryUtils.isInventoryLoaded()) return;
if (checkIfWrongInventory("Confirm Purchase")) break;
Slot confirmPurchase = InventoryUtils.getSlotOfItemInContainer("Confirm");
if (confirmPurchase == null) break;
Expand All @@ -468,10 +468,10 @@ private void onAhState(boolean rightClick) {
break;
case COLLECT_ITEM_VIEW_BIDS:
if (mc.currentScreen == null) {
setAhState(AhState.COLLECT_ITEM_OPEN_AH);
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
break;
}
if (!InventoryUtils.isInventoryLoaded()) return;
if (!Objects.requireNonNull(InventoryUtils.getInventoryName()).contains("Auction House")) break;
Slot viewBids = InventoryUtils.getSlotOfItemInContainer("View Bids");
Slot manageBids = InventoryUtils.getSlotOfItemInContainer("Manage Bids");
Expand All @@ -486,10 +486,10 @@ private void onAhState(boolean rightClick) {
break;
case COLLECT_ITEM_CLICK_ITEM:
if (mc.currentScreen == null) {
setAhState(AhState.COLLECT_ITEM_OPEN_AH);
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
break;
}
if (!InventoryUtils.isInventoryLoaded()) return;
if (!Objects.requireNonNull(InventoryUtils.getInventoryName()).contains("Bids")) break;
Slot godPotSlot = InventoryUtils.getSlotOfItemInContainer("God Potion");
if (godPotSlot == null) break;
Expand All @@ -499,10 +499,10 @@ private void onAhState(boolean rightClick) {
break;
case COLLECT_ITEM_CLICK_COLLECT:
if (mc.currentScreen == null) {
setAhState(AhState.COLLECT_ITEM_OPEN_AH);
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
break;
}
if (!InventoryUtils.isInventoryLoaded()) return;
if (!Objects.requireNonNull(InventoryUtils.getInventoryName()).contains("Auction View")) break;
Slot collectItem = InventoryUtils.getSlotOfItemInContainer("Collect Auction");
if (collectItem == null) break;
Expand Down Expand Up @@ -746,9 +746,9 @@ private void onBackpackState() {
case MOVE_POT_TO_INVENTORY:
if (mc.currentScreen == null) {
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
setBackpackState(BackpackState.OPEN_STORAGE);
break;
}
if (!InventoryUtils.isInventoryLoaded()) return;
if (InventoryUtils.getInventoryName() == null) break;

for (Slot slot : mc.thePlayer.openContainer.inventorySlots) {
Expand Down Expand Up @@ -868,12 +868,12 @@ private void onBitsShop() {
break;
case BITS_SHOP_TAB:
if (mc.currentScreen == null) {
setBitsShopState(BitsShopState.OPEN_BITS_SHOP);
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
break;
}
String invNam = InventoryUtils.getInventoryName();
if (invNam == null) break;
if (!InventoryUtils.isInventoryLoaded()) return;
if (!invNam.contains("Community Shop")) {
PlayerUtils.closeScreen();
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
Expand All @@ -896,10 +896,10 @@ private void onBitsShop() {
break;
case CHECK_CONFIRM:
if (mc.currentScreen == null) {
setBitsShopState(BitsShopState.OPEN_BITS_SHOP);
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
break;
}
if (!InventoryUtils.isInventoryLoaded()) return;
if (!Objects.requireNonNull(InventoryUtils.getInventoryName()).contains("Community Shop")) break;
Slot confirm = InventoryUtils.getSlotOfItemInContainer("Purchase Confirmation");
if (confirm == null) break;
Expand All @@ -917,10 +917,10 @@ private void onBitsShop() {
break;
case CLICK_GOD_POT:
if (mc.currentScreen == null) {
setBitsShopState(BitsShopState.OPEN_BITS_SHOP);
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
break;
}
if (!InventoryUtils.isInventoryLoaded()) return;
if (!Objects.requireNonNull(InventoryUtils.getInventoryName()).contains("Community Shop")) break;
Slot godPot = InventoryUtils.getSlotOfItemInContainer("God Potion");
if (godPot == null) break;
Expand Down Expand Up @@ -1051,7 +1051,6 @@ private void resetBitsShopState() {

private boolean checkIfWrongInventory(String inventoryNameStartsWith) {
if (mc.currentScreen == null) {
setAhState(AhState.OPEN_AH);
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ public void onTickExecution(TickEvent.ClientTickEvent event) {
break;
case SWAP_REPELLENT_TO_HOTBAR_PUT:
if (mc.currentScreen == null) {
moveRepellentState = MoveRepellentState.SWAP_REPELLENT_TO_HOTBAR_PICKUP;
delay.schedule(300 + (long) (Math.random() * 300));
break;
}
Expand All @@ -269,7 +268,6 @@ public void onTickExecution(TickEvent.ClientTickEvent event) {
break;
case SWAP_REPELLENT_TO_HOTBAR_PUT_BACK:
if (mc.currentScreen == null) {
moveRepellentState = MoveRepellentState.SWAP_REPELLENT_TO_HOTBAR_PICKUP;
delay.schedule(300 + (long) (Math.random() * 300));
break;
}
Expand All @@ -290,7 +288,6 @@ public void onTickExecution(TickEvent.ClientTickEvent event) {
break;
case PUT_ITEM_BACK_PUT:
if (mc.currentScreen == null) {
moveRepellentState = MoveRepellentState.SWAP_REPELLENT_TO_HOTBAR_PICKUP;
delay.schedule(300 + (long) (Math.random() * 300));
break;
}
Expand Down
Loading

0 comments on commit 1c32c00

Please sign in to comment.