reset, fixes #84

This commit is contained in:
Leijurv 2018-08-23 11:14:37 -07:00
parent a7abfef329
commit 36cbffb593
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
7 changed files with 37 additions and 0 deletions

View File

@ -187,6 +187,9 @@ public abstract class Movement implements Helper, MovementHelper {
currentState.setStatus(MovementStatus.CANCELED);
}
public void reset() {
currentState = new MovementState().setStatus(MovementStatus.PREPPING);
}
public double getTotalHardnessOfBlocksToBreak(CalculationContext ctx) {
/*

View File

@ -64,6 +64,12 @@ public class MovementAscend extends Movement {
// Counterpoint to the above TODO ^ you should move then pillar instead of ascend
}
@Override
public void reset() {
super.reset();
ticksWithoutPlacement = 0;
}
@Override
protected double calculateCost(CalculationContext context) {
IBlockState toPlace = BlockStateInterface.get(positionsToPlace[0]);

View File

@ -36,6 +36,12 @@ public class MovementDescend extends Movement {
super(start, end, new BlockPos[]{end.up(2), end.up(), end}, new BlockPos[]{end.down()});
}
@Override
public void reset() {
super.reset();
numTicks = 0;
}
@Override
protected double calculateCost(CalculationContext context) {
if (!MovementHelper.canWalkOn(positionsToPlace[0])) {

View File

@ -36,6 +36,12 @@ public class MovementDownward extends Movement {
super(start, end, new BlockPos[]{end}, new BlockPos[0]);
}
@Override
public void reset() {
super.reset();
numTicks = 0;
}
@Override
protected double calculateCost(CalculationContext context) {
if (!MovementHelper.canWalkOn(dest.down())) {

View File

@ -38,6 +38,12 @@ public class MovementPillar extends Movement {
super(start, end, new BlockPos[]{start.up(2)}, new BlockPos[]{start});
}
@Override
public void reset() {
super.reset();
numTicks = 0;
}
@Override
protected double calculateCost(CalculationContext context) {
Block fromDown = BlockStateInterface.get(src).getBlock();

View File

@ -66,6 +66,12 @@ public class MovementTraverse extends Movement {
//note: do NOT add ability to place against .down().down()
}
@Override
public void reset() {
super.reset();
wasTheBridgeBlockAlwaysThere = true;
}
@Override
protected double calculateCost(CalculationContext context) {
IBlockState pb0 = BlockStateInterface.get(positionsToBreak[0]);

View File

@ -90,7 +90,11 @@ public class PathExecutor implements Helper {
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))) {
displayChatMessageRaw("Skipping back " + (pathPosition - i) + " steps, to " + i);
int previousPos = pathPosition;
pathPosition = Math.max(i - 1, 0); // previous step might not actually be done
for (int j = pathPosition; j <= previousPos; j++) {
path.movements().get(j).reset();
}
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
return false;
}