mirror of https://github.com/cabaletta/baritone
Differ between no pitch solution and no solution at all
This commit is contained in:
parent
553c85f0f6
commit
0aad3470d9
|
@ -408,9 +408,8 @@ public final class ElytraBehavior extends Behavior implements IElytraBehavior, H
|
||||||
final Vec3d start = ctx.playerFeetAsVec();
|
final Vec3d start = ctx.playerFeetAsVec();
|
||||||
final boolean firework = isFireworkActive();
|
final boolean firework = isFireworkActive();
|
||||||
BetterBlockPos goingTo = null;
|
BetterBlockPos goingTo = null;
|
||||||
boolean forceUseFirework = false;
|
|
||||||
|
|
||||||
final boolean isInLava = ctx.player().isInLava();
|
final boolean isInLava = ctx.player().isInLava();
|
||||||
|
Solution solution = null;
|
||||||
|
|
||||||
outermost:
|
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)
|
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);
|
final Pair<Float, Boolean> pitch = this.solvePitch(dest.subtract(start), steps, relaxation, firework, isInLava);
|
||||||
if (pitch.first() == null) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
forceUseFirework = pitch.second();
|
|
||||||
goingTo = new BetterBlockPos(dest.x, dest.y, dest.z);
|
goingTo = new BetterBlockPos(dest.x, dest.y, dest.z);
|
||||||
this.aimPos = goingTo;
|
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;
|
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) {
|
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) {
|
private static boolean isFireworks(final ItemStack itemStack) {
|
||||||
if (itemStack.getItem() != Items.FIREWORKS) {
|
if (itemStack.getItem() != Items.FIREWORKS) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue