Differ between no pitch solution and no solution at all

This commit is contained in:
Brady 2023-06-20 15:05:59 -05:00
parent 553c85f0f6
commit 0aad3470d9
No known key found for this signature in database
GPG Key ID: 73A788379A197567
1 changed files with 31 additions and 10 deletions

View File

@ -408,9 +408,8 @@ public final class ElytraBehavior extends Behavior implements IElytraBehavior, H
final Vec3d start = ctx.playerFeetAsVec();
final boolean firework = isFireworkActive();
BetterBlockPos goingTo = null;
boolean forceUseFirework = false;
final boolean isInLava = ctx.player().isInLava();
Solution solution = null;
outermost:
for (int relaxation = 0; relaxation < 3; relaxation++) { // try for a strict solution first, then relax more and more (if we're in a corner or near some blocks, it will have to relax its constraints a bit)
@ -459,25 +458,34 @@ public final class ElytraBehavior extends Behavior implements IElytraBehavior, H
final Pair<Float, Boolean> pitch = this.solvePitch(dest.subtract(start), steps, relaxation, firework, isInLava);
if (pitch.first() == null) {
baritone.getLookBehavior().updateTarget(new Rotation(yaw, ctx.playerRotations().getPitch()), false);
solution = new Solution(new Rotation(yaw, ctx.playerRotations().getPitch()), false, false);
continue;
}
forceUseFirework = pitch.second();
goingTo = new BetterBlockPos(dest.x, dest.y, dest.z);
this.aimPos = goingTo;
baritone.getLookBehavior().updateTarget(new Rotation(yaw, pitch.first()), false);
// A solution was found with yaw AND pitch, break out of the loop to use it
solution = new Solution(new Rotation(yaw, pitch.first()), true, pitch.second());
break outermost;
}
}
}
}
if (relaxation == 2) {
logDirect("no pitch solution, probably gonna crash in a few ticks LOL!!!");
return;
}
}
this.tickUseFireworks(start, firework, goingTo, forceUseFirework);
if (solution == null) {
logDirect("no solution");
return;
}
baritone.getLookBehavior().updateTarget(solution.rotation, false);
if (!solution.solvedPitch) {
logDirect("no pitch solution, probably gonna crash in a few ticks LOL!!!");
return;
}
this.tickUseFireworks(start, firework, goingTo, solution.forceUseFirework);
}
private void tickUseFireworks(final Vec3d start, final boolean firework, final BetterBlockPos goingTo, final boolean forceUseFirework) {
@ -512,6 +520,19 @@ public final class ElytraBehavior extends Behavior implements IElytraBehavior, H
}
}
private static final class Solution {
public final Rotation rotation;
public final boolean solvedPitch;
public final boolean forceUseFirework;
public Solution(Rotation rotation, boolean solvedPitch, boolean forceUseFirework) {
this.rotation = rotation;
this.solvedPitch = solvedPitch;
this.forceUseFirework = forceUseFirework;
}
}
private static boolean isFireworks(final ItemStack itemStack) {
if (itemStack.getItem() != Items.FIREWORKS) {
return false;