fixes to descend, and goto coords
This commit is contained in:
parent
6faa7344aa
commit
67fa91abe8
@ -245,7 +245,7 @@ public class MovementDescend extends Movement {
|
||||
// (dest - src) + dest is offset 1 more in the same direction
|
||||
// so it's the block we'd need to worry about running into if we decide to sprint straight through this descend
|
||||
BlockPos into = dest.subtract(src.down()).add(dest);
|
||||
if (!MovementHelper.canWalkThrough(ctx, new BetterBlockPos(into)) && MovementHelper.canWalkThrough(ctx, new BetterBlockPos(into).up()) && MovementHelper.canWalkThrough(ctx, new BetterBlockPos(into).up(2))) {
|
||||
if (skipToAscend()) {
|
||||
// if dest extends into can't walk through, but the two above are can walk through, then we can overshoot and glitch in that weird way
|
||||
return true;
|
||||
}
|
||||
@ -256,4 +256,9 @@ public class MovementDescend extends Movement {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean skipToAscend() {
|
||||
BlockPos into = dest.subtract(src.down()).add(dest);
|
||||
return !MovementHelper.canWalkThrough(ctx, new BetterBlockPos(into)) && MovementHelper.canWalkThrough(ctx, new BetterBlockPos(into).up()) && MovementHelper.canWalkThrough(ctx, new BetterBlockPos(into).up(2));
|
||||
}
|
||||
}
|
||||
|
@ -398,7 +398,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||
IMovement current = path.movements().get(pathPosition);
|
||||
if (current instanceof MovementDescend) {
|
||||
|
||||
if (((MovementDescend) current).safeMode()) {
|
||||
if (((MovementDescend) current).safeMode() && !((MovementDescend) current).skipToAscend()) {
|
||||
logDebug("Sprinting would be unsafe");
|
||||
return false;
|
||||
}
|
||||
|
@ -163,36 +163,19 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
||||
}
|
||||
|
||||
if (msg.startsWith("goal")) {
|
||||
String[] params = msg.substring(4).trim().split(" ");
|
||||
if (params[0].equals("")) {
|
||||
params = new String[]{};
|
||||
}
|
||||
String rest = msg.substring(4).trim();
|
||||
Goal goal;
|
||||
try {
|
||||
switch (params.length) {
|
||||
case 0:
|
||||
goal = new GoalBlock(ctx.playerFeet());
|
||||
break;
|
||||
case 1:
|
||||
if (params[0].equals("clear") || params[0].equals("none")) {
|
||||
goal = null;
|
||||
} else {
|
||||
goal = new GoalYLevel(Integer.parseInt(params[0]));
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
goal = new GoalXZ(Integer.parseInt(params[0]), Integer.parseInt(params[1]));
|
||||
break;
|
||||
case 3:
|
||||
goal = new GoalBlock(new BlockPos(Integer.parseInt(params[0]), Integer.parseInt(params[1]), Integer.parseInt(params[2])));
|
||||
break;
|
||||
default:
|
||||
logDirect("unable to understand lol");
|
||||
return true;
|
||||
if (rest.equals("clear") || rest.equals("none")) {
|
||||
goal = null;
|
||||
} else {
|
||||
String[] params = rest.split(" ");
|
||||
if (params[0].equals("")) {
|
||||
params = new String[]{};
|
||||
}
|
||||
goal = parseGoal(params);
|
||||
if (goal == null) {
|
||||
return true;
|
||||
}
|
||||
} catch (NumberFormatException ex) {
|
||||
logDirect("unable to parse integer " + ex);
|
||||
return true;
|
||||
}
|
||||
customGoalProcess.setGoal(goal);
|
||||
logDirect("Goal: " + goal);
|
||||
@ -469,7 +452,11 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
||||
if (block == null) {
|
||||
waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getAllWaypoints().stream().filter(w -> w.getName().equalsIgnoreCase(mining)).max(Comparator.comparingLong(IWaypoint::getCreationTimestamp)).orElse(null);
|
||||
if (waypoint == null) {
|
||||
logDirect("No locations for " + mining + " known, cancelling");
|
||||
Goal goal = parseGoal(waypointType.split(" "));
|
||||
if (goal != null) {
|
||||
logDirect("Going to " + goal);
|
||||
customGoalProcess.setGoalAndPath(goal);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
@ -548,4 +535,31 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Goal parseGoal(String[] params) {
|
||||
Goal goal;
|
||||
try {
|
||||
switch (params.length) {
|
||||
case 0:
|
||||
goal = new GoalBlock(ctx.playerFeet());
|
||||
break;
|
||||
case 1:
|
||||
goal = new GoalYLevel(Integer.parseInt(params[0]));
|
||||
break;
|
||||
case 2:
|
||||
goal = new GoalXZ(Integer.parseInt(params[0]), Integer.parseInt(params[1]));
|
||||
break;
|
||||
case 3:
|
||||
goal = new GoalBlock(new BlockPos(Integer.parseInt(params[0]), Integer.parseInt(params[1]), Integer.parseInt(params[2])));
|
||||
break;
|
||||
default:
|
||||
logDirect("unable to understand lol");
|
||||
return null;
|
||||
}
|
||||
} catch (NumberFormatException ex) {
|
||||
logDirect("unable to parse integer " + ex);
|
||||
return null;
|
||||
}
|
||||
return goal;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user