Skip to content

Commit

Permalink
= Fixed issue with stuck on spawn after pests destroyer
Browse files Browse the repository at this point in the history
  • Loading branch information
May2Beez committed Jan 9, 2024
1 parent 4b7ed4c commit 0d6a47a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 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.1-pre1
version=2.4.1-pre2
shouldRelease=true
Original file line number Diff line number Diff line change
Expand Up @@ -943,13 +943,16 @@ private void manipulateHeight(Entity entity, double distance, double distanceWit
Vec3 playerPos = new Vec3(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ);
List<KeyBinding> keyBindings = new ArrayList<>(KeyBindUtils.getNeededKeyPresses(playerPos, target));
if (objectsInFrontOfPlayer() || entity.posY + entity.getEyeHeight() + 1 - mc.thePlayer.posY >= 2) {
if (distanceWithoutY <= 2.5) {
keyBindings.clear();
}
if (distance < 6) {
keyBindings.add(mc.gameSettings.keyBindUseItem);
}
if (mc.thePlayer.capabilities.isFlying) {
keyBindings.add(mc.gameSettings.keyBindJump);
}
if (FarmHelperConfig.sprintWhileFlying) {
if (FarmHelperConfig.sprintWhileFlying && keyBindings.contains(mc.gameSettings.keyBindForward)) {
keyBindings.add(mc.gameSettings.keyBindSprint);
}
KeyBindUtils.holdThese(keyBindings.toArray(new KeyBinding[0]));
Expand All @@ -962,13 +965,13 @@ private void manipulateHeight(Entity entity, double distance, double distanceWit
KeyBindUtils.holdThese(distance < 6 ? mc.gameSettings.keyBindUseItem : null, mc.gameSettings.keyBindSneak, distanceWithoutY > 6 && yawDifference < 25 ? mc.gameSettings.keyBindForward : null, distanceWithoutY < 1 && (GameStateHandler.getInstance().getDx() > 0.04 || GameStateHandler.getInstance().getDz() > 0.04) ? mc.gameSettings.keyBindBack : null, distanceWithoutY > 7 && yawDifference < 25 ? FarmHelperConfig.sprintWhileFlying ? mc.gameSettings.keyBindSprint : null : null);
}
} else {
if (distanceWithoutY < 3) {
if (distanceWithoutY <= 2.5 || distance <= 3.5) {
keyBindings.clear();
}
if (distance < 6) {
keyBindings.add(mc.gameSettings.keyBindUseItem);
}
if (FarmHelperConfig.sprintWhileFlying) {
if (FarmHelperConfig.sprintWhileFlying && keyBindings.contains(mc.gameSettings.keyBindForward)) {
keyBindings.add(mc.gameSettings.keyBindSprint);
}
KeyBindUtils.holdThese(keyBindings.toArray(new KeyBinding[0]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ private void adjustTargetRotation(boolean serverSide) {
Rotation neededChange = getNeededChange(startRotation, rot);
targetRotation.setYaw(startRotation.getYaw() + neededChange.getYaw());
targetRotation.setPitch(startRotation.getPitch() + neededChange.getPitch());
delayBetweenTargetFollow.schedule(150 + Math.random() * 75);
delayBetweenTargetFollow.schedule(250 + Math.random() * 125);
}

@SubscribeEvent(receiveCanceled = true)
Expand Down
25 changes: 15 additions & 10 deletions src/main/java/com/jelly/farmhelperv2/macro/AbstractMacro.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ public void onTickCheckTeleport() {
if (FailsafeManager.getInstance().triggeredFailsafe.isPresent() || FailsafeManager.getInstance().getChooseEmergencyDelay().isScheduled()) {
return;
}
if (mc.thePlayer.capabilities.isFlying) {
return;
}
checkForTeleport();
}

Expand Down Expand Up @@ -310,17 +307,25 @@ public void changeState(State state) {

private void checkForTeleport() {
if (!beforeTeleportationPos.isPresent()) return;
if (mc.thePlayer.getPosition().distanceSq(beforeTeleportationPos.get()) > 2 && !PlayerUtils.isPlayerSuffocating()) {
if (mc.thePlayer.getPosition().distanceSq(beforeTeleportationPos.get()) > 2) {
if (PlayerUtils.isPlayerSuffocating()) {
LogUtils.sendDebug("Player is suffocating. Waiting");
return;
}
if (!mc.thePlayer.capabilities.isFlying && !mc.thePlayer.onGround) {
LogUtils.sendDebug("Player is not on ground, but is not flying. Waiting");
return;
} else if (mc.thePlayer.capabilities.isFlying && !mc.thePlayer.onGround) {
if (!mc.gameSettings.keyBindSneak.isKeyDown()) {
KeyBindUtils.holdThese(mc.gameSettings.keyBindSneak);
Multithreading.schedule(() -> KeyBindUtils.stopMovement(), (long) (350 + Math.random() * 300), TimeUnit.MILLISECONDS);
if (rewarpTeleport) {
LogUtils.sendDebug("Player is flying, but is not on ground. Waiting");
if (!mc.gameSettings.keyBindSneak.isKeyDown()) {
KeyBindUtils.holdThese(mc.gameSettings.keyBindSneak);
Multithreading.schedule(() -> KeyBindUtils.stopMovement(), (long) (350 + Math.random() * 300), TimeUnit.MILLISECONDS);
}
return;
}
return;
}
afterRewarpDelay.schedule(5_000);
afterRewarpDelay.schedule(1_500);
LogUtils.sendDebug("Teleported!");
changeState(State.NONE);
checkOnSpawnClock.reset();
Expand Down Expand Up @@ -356,7 +361,7 @@ public void triggerWarpGarden(boolean force, boolean rewarpTeleport) {
LogUtils.sendDebug("Warping to spawn point");
mc.thePlayer.sendChatMessage("/warp garden");
GameStateHandler.getInstance().scheduleRewarp();

}
}

Expand Down

0 comments on commit 0d6a47a

Please sign in to comment.