Skip to content

Commit

Permalink
Visitors Macro:
Browse files Browse the repository at this point in the history
 = TP fix

Auto Pest Hunter:
 = False TP Check fix

Pests Destroyer:
 = Adjustments

Warping back to farm fixes
  • Loading branch information
May2Beez committed Feb 29, 2024
1 parent f83ec91 commit aa5f973
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 13 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.4.5-pre16
version=2.4.5-pre17
shouldRelease=true
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ public void onTickUnstuck(TickEvent.ClientTickEvent event) {
if (intersectingBlockPos != null) {
Optional<EnumFacing> closestSide = findClosestSide(intersectingBlockPos);
if (!closestSide.isPresent() || unstuckTries > FarmHelperConfig.antiStuckTriesUntilRewarp) {
unstuckTries = 0;
LogUtils.sendError("[Anti Stuck] Can't unstuck from this place. That's a rare occurrence. Warping back to spawn...");
KeyBindUtils.stopMovement();
stop();
unstuckTries = 0;
MacroHandler.getInstance().triggerWarpGarden(true, true);
unstuckState = UnstuckState.DISABLE;
delayBetweenMovementsClock.schedule(150 + (int) (Math.random() * 250));
return;
}
EnumFacing facing = closestSide.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public boolean isToggled() {

@Override
public boolean shouldCheckForFailsafes() {
return state == State.NONE || state == State.GO_BACK || state == State.EMPTY_VACUUM || state == State.GO_TO_PHILLIP || state == State.TELEPORT_TO_DESK;
return state == State.NONE || state == State.GO_BACK || state == State.EMPTY_VACUUM || state == State.GO_TO_PHILLIP;
}

enum State {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.entity.monster.EntitySilverfish;
import net.minecraft.entity.passive.EntityBat;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.ContainerChest;
import net.minecraft.inventory.Slot;
Expand Down Expand Up @@ -676,7 +678,12 @@ public void onTickExecute(TickEvent.ClientTickEvent event) {
}
break;
}

if (closestPest instanceof EntityArmorStand) {
Entity realEntity = PlayerUtils.getEntityCuttingOtherEntity(closestPest, (e) -> e instanceof EntityBat || e instanceof EntitySilverfish);
if (realEntity != null) {
closestPest = realEntity;
}
}
if (FlyPathFinderExecutor.getInstance().isRunning()) {
FlyPathFinderExecutor.getInstance().stop();
}
Expand All @@ -694,6 +701,7 @@ public void onTickExecute(TickEvent.ClientTickEvent event) {
case KILL_PEST:
if (isInventoryOpenDelayed()) break;
if (!currentEntityTarget.isPresent()) {
FlyPathFinderExecutor.getInstance().stop();
RotationHandler.getInstance().reset();
state = States.CHECK_ANOTHER_PEST;
return;
Expand Down Expand Up @@ -730,10 +738,11 @@ public void onTickExecute(TickEvent.ClientTickEvent event) {
if (distance < 2 && targetVelocity < 0.15 && mc.thePlayer.canEntityBeSeen(entity)) {
if (FlyPathFinderExecutor.getInstance().isRunning()) {
FlyPathFinderExecutor.getInstance().stop();
} else {
float playerVelocity = (float) (Math.abs(mc.thePlayer.motionX) + Math.abs(mc.thePlayer.motionZ));
if (playerVelocity > 0.15)
KeyBindUtils.onTick(mc.gameSettings.keyBindBack);
}
float playerVelocity = (float) (Math.abs(mc.thePlayer.motionX) + Math.abs(mc.thePlayer.motionZ));
if (playerVelocity > 0.15)
KeyBindUtils.onTick(mc.gameSettings.keyBindBack);
}
if (rotationState != RotationState.CLOSE) {
rotationState = RotationState.CLOSE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,8 @@ public void onTick(TickEvent.ClientTickEvent event) {
setMainState(MainState.DISABLED);
stop();
} else {
stop();
teleportBackToFarm();
stop();
delayClock.schedule(2_500);
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ public void onTickCheckTeleport() {

private void checkForTeleport() {
if (!beforeTeleportationPos.isPresent()) return;
if (mc.thePlayer.getPosition().distanceSq(beforeTeleportationPos.get()) > 2) {
if (mc.thePlayer.getPosition().distanceSq(beforeTeleportationPos.get()) > 2 || PlayerUtils.isStandingOnSpawnPoint()) {
if (PlayerUtils.isPlayerSuffocating()) {
LogUtils.sendDebug("Player is suffocating. Waiting");
return;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/jelly/farmhelperv2/hud/DebugHUD.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public DebugHUD() {
@Override
protected void getLines(List<String> lines, boolean example) {
if (!FarmHelperConfig.debugMode) return;
if (Minecraft.getMinecraft().thePlayer == null || Minecraft.getMinecraft().theWorld == null) return;
lines.add("§lFarmHelper v" + FarmHelper.VERSION + " Debug HUD");
lines.add("wasGuestOnGarden: " + GuestVisitFailsafe.getInstance().wasGuestOnGarden);
lines.add("Jacob's Contest Collected: " + GameStateHandler.getInstance().getJacobsContestCropNumber());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ public void onTickNeededYaw(TickEvent.ClientTickEvent event) {
}

private boolean willArriveAtDestinationAfterStopping(Vec3 targetPos) {
return predictStoppingPosition().distanceTo(targetPos) < 0.5;
return predictStoppingPosition().distanceTo(targetPos) < 0.75;
}

private Vec3 predictStoppingPosition() {
Expand All @@ -485,7 +485,7 @@ private Vec3 predictStoppingPosition() {
private void stopAndDecelerate() {
float velocity = (float) Math.sqrt(mc.thePlayer.motionX * mc.thePlayer.motionX + mc.thePlayer.motionZ * mc.thePlayer.motionZ);
LogUtils.sendDebug("Stopping and decelerating. Velocity: " + velocity);
if (Math.abs(velocity) < 0.1) {
if (Math.abs(velocity) < 0.2) {
LogUtils.sendSuccess("Arrived at destination");
stop();
} else {
Expand Down

0 comments on commit aa5f973

Please sign in to comment.