movement timeout ticks setting

This commit is contained in:
Leijurv 2018-08-20 16:23:32 -07:00
parent d925dddb78
commit 6f10a007d5
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 10 additions and 4 deletions

View File

@ -129,6 +129,11 @@ public class Settings {
*/ */
public Setting<Integer> maxFallHeight = new Setting<>(3); public Setting<Integer> maxFallHeight = new Setting<>(3);
/**
* If a movement takes this many ticks more than its initial cost estimate, cancel it
*/
public Setting<Integer> movementTimeoutTicks = new Setting<>(100);
/** /**
* Pathing can never take longer than this * Pathing can never take longer than this
*/ */

View File

@ -85,7 +85,7 @@ public class PathExecutor implements Helper {
return true; return true;
} }
if (!whereShouldIBe.equals(whereAmI)) { if (!whereShouldIBe.equals(whereAmI)) {
System.out.println("Should be at " + whereShouldIBe + " actually am at " + whereAmI); //System.out.println("Should be at " + whereShouldIBe + " actually am at " + whereAmI);
if (!Blocks.AIR.equals(BlockStateInterface.getBlock(whereAmI.down()))) {//do not skip if standing on air, because our position isn't stable to skip if (!Blocks.AIR.equals(BlockStateInterface.getBlock(whereAmI.down()))) {//do not skip if standing on air, because our position isn't stable to skip
for (int i = 0; i < pathPosition - 2 && i < path.length(); i++) {//this happens for example when you lag out and get teleported back a couple blocks for (int i = 0; i < pathPosition - 2 && i < path.length(); i++) {//this happens for example when you lag out and get teleported back a couple blocks
if (whereAmI.equals(path.positions().get(i))) { if (whereAmI.equals(path.positions().get(i))) {
@ -100,6 +100,7 @@ public class PathExecutor implements Helper {
if (i - pathPosition > 2) { if (i - pathPosition > 2) {
displayChatMessageRaw("Skipping forward " + (i - pathPosition) + " steps, to " + i); displayChatMessageRaw("Skipping forward " + (i - pathPosition) + " steps, to " + i);
} }
System.out.println("Double skip sundae");
pathPosition = i - 1; pathPosition = i - 1;
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
return false; return false;
@ -224,12 +225,12 @@ public class PathExecutor implements Helper {
return true; return true;
} else { } else {
ticksOnCurrent++; ticksOnCurrent++;
if (ticksOnCurrent > currentMovementInitialCostEstimate + 100) { if (ticksOnCurrent > currentMovementInitialCostEstimate + Baritone.settings().movementTimeoutTicks.get()) {
// only fail if the total time has exceeded the initial estimate // only fail if the total time has exceeded the initial estimate
// as you break the blocks required, the remaining cost goes down, to the point where // as you break the blocks required, the remaining cost goes down, to the point where
// ticksOnCurrent is greater than recalculateCost + 1000 // ticksOnCurrent is greater than recalculateCost + 100
// this is why we cache cost at the beginning, and don't recalculate for this comparison every tick // this is why we cache cost at the beginning, and don't recalculate for this comparison every tick
displayChatMessageRaw("This movement has taken too long (" + ticksOnCurrent + " ticks, expected " + movement.getCost(null) + "). Cancelling."); displayChatMessageRaw("This movement has taken too long (" + ticksOnCurrent + " ticks, expected " + currentMovementInitialCostEstimate + "). Cancelling.");
movement.cancel(); movement.cancel();
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys(); Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
pathPosition = path.length() + 3; pathPosition = path.length() + 3;