Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
onixiya1337 committed Mar 15, 2024
1 parent ad94108 commit 00227d6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 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.5.0-pre2
version=2.5.0-pre3
shouldRelease=true
21 changes: 16 additions & 5 deletions src/main/java/com/jelly/farmhelperv2/feature/impl/AutoGodPot.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class AutoGodPot implements IFeature {
@Getter
private BitsShopState bitsShopState = BitsShopState.NONE;
private Slot godPotItem;
private int teleportTries = 0;
private int tries = 0;

public static AutoGodPot getInstance() {
if (instance == null) {
Expand Down Expand Up @@ -138,6 +138,7 @@ public void stop() {
if (shouldTpToGarden) {
MacroHandler.getInstance().triggerWarpGarden(true, true);
}
tries = 0;
}

private void resetStates() {
Expand Down Expand Up @@ -216,6 +217,11 @@ public void onTickUpdate(TickEvent.ClientTickEvent event) {
if (stuckClock.isScheduled() && stuckClock.passed()) {
LogUtils.sendWarning("[Auto God Pot] Stuck for too long! Restarting!");
resetStates();
tries++;
if (tries >= 3) {
LogUtils.sendError("[Auto God Pot] Failed too many times! Stopping");
stop();
}
start();
return;
}
Expand All @@ -225,7 +231,7 @@ public void onTickUpdate(TickEvent.ClientTickEvent event) {
switch (godPotMode) {

case NONE:
LogUtils.sendWarning("[Auto God Pot] You didn't activate any God Pot source! Disabling");
LogUtils.sendWarning("[Auto God Pot] You didn't activate any God Pot source! Stopping");
stop();
break;
case FROM_AH_COOKIE:
Expand Down Expand Up @@ -457,8 +463,13 @@ private void onAhState(boolean rightClick) {
}
if (!Objects.requireNonNull(InventoryUtils.getInventoryName()).contains("Auction House")) break;
Slot viewBids = InventoryUtils.getSlotOfItemInContainer("View Bids");
if (viewBids == null) break;
InventoryUtils.clickContainerSlot(viewBids.slotNumber, InventoryUtils.ClickType.LEFT, InventoryUtils.ClickMode.PICKUP);
Slot manageBids = InventoryUtils.getSlotOfItemInContainer("Manage Bids");
if (viewBids == null && manageBids == null) break;
if (viewBids != null) {
InventoryUtils.clickContainerSlot(viewBids.slotNumber, InventoryUtils.ClickType.LEFT, InventoryUtils.ClickMode.PICKUP);
} else {
InventoryUtils.clickContainerSlot(manageBids.slotNumber, InventoryUtils.ClickType.LEFT, InventoryUtils.ClickMode.PICKUP);
}
setAhState(AhState.COLLECT_ITEM_CLICK_ITEM);
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
break;
Expand All @@ -481,7 +492,7 @@ private void onAhState(boolean rightClick) {
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
break;
}
if (!Objects.requireNonNull(InventoryUtils.getInventoryName()).contains("BIN Auction View")) break;
if (!Objects.requireNonNull(InventoryUtils.getInventoryName()).contains("Auction View")) break;
Slot collectItem = InventoryUtils.getSlotOfItemInContainer("Collect Auction");
if (collectItem == null) break;
InventoryUtils.clickContainerSlot(collectItem.slotNumber, InventoryUtils.ClickType.LEFT, InventoryUtils.ClickMode.PICKUP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,7 @@ public void onTickExecution(TickEvent.ClientTickEvent event) {
delayClock.schedule((long) (FarmHelperConfig.pestAdditionalGUIDelay + 300 + Math.random() * 300));
break;
case CLICK_PHILLIP:
if (BlockUtils.getHorizontalDistance(mc.thePlayer.getPositionVector(),
new Vec3(deskPos().getX() + 0.5, deskPos().getY() + 0.5, deskPos().getZ() + 0.5)) > 7) {
if (BlockUtils.getHorizontalDistance(mc.thePlayer.getPositionVector(), phillip.getPositionVector()) > 7) {
LogUtils.sendDebug("[Auto Pest Hunter] Can't click Phillip! Walking to the desk position...");
state = State.GO_TO_PHILLIP;
delayClock.schedule((long) (FarmHelperConfig.pestAdditionalGUIDelay + 300 + Math.random() * 300));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public class PestsDestroyer implements IFeature {
private float currentVacuumRange = 5F;

private boolean gotRangeOfVacuum = false;
private boolean isPlotObstructed = false;

private final List<Integer> killedPestsFrom = new ArrayList<>();

Expand Down Expand Up @@ -129,6 +130,7 @@ public boolean shouldStartAtMacroStart() {
public void start() {
if (enabled) return;
gotRangeOfVacuum = false;
isPlotObstructed = false;
preparing = true;
if (MacroHandler.getInstance().isMacroToggled()) {
MacroHandler.getInstance().pauseMacro();
Expand Down Expand Up @@ -168,6 +170,7 @@ public void stop() {
stuckClock.reset();
preparing = false;
enabled = false;
isPlotObstructed = false;
lastFireworkTime = 0;
getLocationTries = 0;
flyPathfinderTries = 0;
Expand Down Expand Up @@ -510,6 +513,7 @@ public void onTickExecute(TickEvent.ClientTickEvent event) {
LogUtils.sendWarning("[Pests Destroyer] The player is suffocating and/or it can't fly higher. Going back to spawnpoint.");
delayClock.schedule(1_000 + Math.random() * 500);
MacroHandler.getInstance().triggerWarpGarden(true, false);
isPlotObstructed = true;
state = States.CHECKING_SPAWN;
return;
}
Expand Down Expand Up @@ -542,14 +546,16 @@ public void onTickExecute(TickEvent.ClientTickEvent event) {
double distance = Math.sqrt(mc.thePlayer.getDistanceSq(PlotUtils.getPlotCenter(closestPlot.number)));

this.closestPlot = Optional.of(closestPlot);
if (distance > 80) {
if (distance > 80 && !isPlotObstructed) {
state = States.TELEPORT_TO_PLOT;
} else {
state = States.FLY_TO_THE_CLOSEST_PLOT;
isPlotObstructed = false;
}
delayClock.schedule((long) (500 + Math.random() * 500));
break;
case FLY_TO_THE_CLOSEST_PLOT:
if (MacroHandler.getInstance().isTeleporting()) return;
if (isInventoryOpenDelayed()) break;

if (!this.closestPlot.isPresent()) {
Expand Down Expand Up @@ -868,7 +874,7 @@ public void onTickExecute(TickEvent.ClientTickEvent event) {
if (plotOpt != null) {
double distanceToPlot = Math.sqrt(mc.thePlayer.getDistanceSqToCenter(PlotUtils.getPlotCenter(plotOpt.number)));
LogUtils.sendDebug("Distance to plot: " + distanceToPlot);
if (distanceToPlot < 100) {
if (distanceToPlot < 100 || isPlotObstructed) {
LogUtils.sendDebug("Going manually to another plot");
state = States.GET_CLOSEST_PLOT;
delayClock.schedule(300 + (long) (Math.random() * 250));
Expand Down Expand Up @@ -1234,7 +1240,7 @@ public void onGuiOpen(DrawScreenAfterEvent event) {
LogUtils.sendDebug("[Pests Destroyer] Updated plots");
if (state == States.WAIT_FOR_INFO) {
PlayerUtils.closeScreen();
state = States.TELEPORTING_TO_PLOT;
state = States.TELEPORT_TO_PLOT;
delayClock.schedule(300 + (long) (Math.random() * 300));
}
}
Expand Down Expand Up @@ -1294,7 +1300,6 @@ public enum States {
OPEN_DESK,
OPEN_PLOTS,
WAIT_FOR_INFO,
TELEPORTING_TO_PLOT,
TELEPORT_TO_PLOT,
WAIT_FOR_TP,
CHECKING_PLOT,
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/jelly/farmhelperv2/util/BlockUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@ public static boolean blockHasCollision(BlockPos blockPos, IBlockState blockStat
return false;
}

if (block.equals(Blocks.ladder)) {
return false;
}

try {
return !block.isPassable(blockAccess, blockPos) || block.getCollisionBoundingBox((World) blockAccess, blockPos, blockState) != null;
} catch (Exception e) {
Expand Down

0 comments on commit 00227d6

Please sign in to comment.