Merge branch '1.19.4' into 1.20.1

This commit is contained in:
Leijurv 2023-08-22 13:29:08 -07:00
commit 97067b9078
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
1 changed files with 20 additions and 14 deletions

View File

@ -24,6 +24,7 @@ import baritone.api.behavior.look.ITickableAimProcessor;
import baritone.api.event.events.*; import baritone.api.event.events.*;
import baritone.api.pathing.goals.GoalBlock; import baritone.api.pathing.goals.GoalBlock;
import baritone.api.utils.*; import baritone.api.utils.*;
import baritone.api.utils.input.Input;
import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementHelper;
import baritone.process.ElytraProcess; import baritone.process.ElytraProcess;
import baritone.utils.BlockStateInterface; import baritone.utils.BlockStateInterface;
@ -103,7 +104,7 @@ public final class ElytraBehavior implements Helper {
private BlockStateInterface bsi; private BlockStateInterface bsi;
private final BlockStateOctreeInterface boi; private final BlockStateOctreeInterface boi;
public final BlockPos destination; public final BetterBlockPos destination;
private final boolean appendDestination; private final boolean appendDestination;
private final ExecutorService solverExecutor; private final ExecutorService solverExecutor;
@ -124,7 +125,7 @@ public final class ElytraBehavior implements Helper {
this.blockedLines = new CopyOnWriteArrayList<>(); this.blockedLines = new CopyOnWriteArrayList<>();
this.pathManager = this.new PathManager(); this.pathManager = this.new PathManager();
this.process = process; this.process = process;
this.destination = destination; this.destination = new BetterBlockPos(destination);
this.appendDestination = appendDestination; this.appendDestination = appendDestination;
this.solverExecutor = Executors.newSingleThreadExecutor(); this.solverExecutor = Executors.newSingleThreadExecutor();
this.nextTickBoostCounter = new int[2]; this.nextTickBoostCounter = new int[2];
@ -193,16 +194,16 @@ public final class ElytraBehavior implements Helper {
}); });
} }
public CompletableFuture<Void> pathRecalcSegment(final int upToIncl) { public CompletableFuture<Void> pathRecalcSegment(final OptionalInt upToIncl) {
if (this.recalculating) { if (this.recalculating) {
throw new IllegalStateException("already recalculating"); throw new IllegalStateException("already recalculating");
} }
this.recalculating = true; this.recalculating = true;
final List<BetterBlockPos> after = this.path.subList(upToIncl + 1, this.path.size()); final List<BetterBlockPos> after = upToIncl.isPresent() ? this.path.subList(upToIncl.getAsInt() + 1, this.path.size()) : Collections.emptyList();
final boolean complete = this.completePath; final boolean complete = this.completePath;
return this.path0(ctx.playerFeet(), this.path.get(upToIncl), segment -> segment.append(after.stream(), complete)) return this.path0(ctx.playerFeet(), upToIncl.isPresent() ? this.path.get(upToIncl.getAsInt()) : ElytraBehavior.this.destination, segment -> segment.append(after.stream(), complete || (segment.isFinished() && !upToIncl.isPresent())))
.whenComplete((result, ex) -> { .whenComplete((result, ex) -> {
this.recalculating = false; this.recalculating = false;
if (ex != null) { if (ex != null) {
@ -320,7 +321,7 @@ public final class ElytraBehavior implements Helper {
} }
if (ElytraBehavior.this.process.state != ElytraProcess.State.LANDING && this.ticksNearUnchanged > 100) { if (ElytraBehavior.this.process.state != ElytraProcess.State.LANDING && this.ticksNearUnchanged > 100) {
this.pathRecalcSegment(rangeEndExcl - 1) this.pathRecalcSegment(OptionalInt.of(rangeEndExcl - 1))
.thenRun(() -> { .thenRun(() -> {
logDirect("Recalculating segment, no progress in last 100 ticks"); logDirect("Recalculating segment, no progress in last 100 ticks");
}); });
@ -336,15 +337,15 @@ public final class ElytraBehavior implements Helper {
if (!ElytraBehavior.this.clearView(this.path.getVec(i), this.path.getVec(i + 1), false)) { if (!ElytraBehavior.this.clearView(this.path.getVec(i), this.path.getVec(i + 1), false)) {
// obstacle. where do we return to pathing? // obstacle. where do we return to pathing?
// if the end of render distance is closer to goal, then that's fine, otherwise we'd be "digging our hole deeper" and making an already bad backtrack worse // if the end of render distance is closer to goal, then that's fine, otherwise we'd be "digging our hole deeper" and making an already bad backtrack worse
int rejoinMainPathAt; OptionalInt rejoinMainPathAt;
if (this.path.get(rangeEndExcl - 1).distanceSq(this.path.get(path.size() - 1)) < ctx.playerFeet().distanceSq(this.path.get(path.size() - 1))) { if (this.path.get(rangeEndExcl - 1).distanceSq(ElytraBehavior.this.destination) < ctx.playerFeet().distanceSq(ElytraBehavior.this.destination)) {
rejoinMainPathAt = rangeEndExcl - 1; // rejoin after current render distance rejoinMainPathAt = OptionalInt.of(rangeEndExcl - 1); // rejoin after current render distance
} else { } else {
rejoinMainPathAt = path.size() - 1; // large backtrack detected. ignore render distance, rejoin later on rejoinMainPathAt = OptionalInt.empty(); // large backtrack detected. ignore render distance, rejoin later on
} }
final BetterBlockPos blockage = this.path.get(i); final BetterBlockPos blockage = this.path.get(i);
final double distance = ctx.playerFeet().distanceTo(this.path.get(rejoinMainPathAt)); final double distance = ctx.playerFeet().distanceTo(this.path.get(rejoinMainPathAt.orElse(path.size() - 1)));
final long start = System.nanoTime(); final long start = System.nanoTime();
this.pathRecalcSegment(rejoinMainPathAt) this.pathRecalcSegment(rejoinMainPathAt)
@ -361,7 +362,7 @@ public final class ElytraBehavior implements Helper {
} }
} }
if (!canSeeAny && rangeStartIncl < rangeEndExcl - 2 && process.state != ElytraProcess.State.GET_TO_JUMP) { if (!canSeeAny && rangeStartIncl < rangeEndExcl - 2 && process.state != ElytraProcess.State.GET_TO_JUMP) {
this.pathRecalcSegment(rangeEndExcl - 1).thenRun(() -> logDirect("Recalculated segment since no path points were visible")); this.pathRecalcSegment(OptionalInt.of(rangeEndExcl - 1)).thenRun(() -> logDirect("Recalculated segment since no path points were visible"));
} }
} }
@ -604,6 +605,11 @@ public final class ElytraBehavior implements Helper {
this.deployedFireworkLastTick = false; this.deployedFireworkLastTick = false;
} }
final boolean inLava = ctx.player().isInLava();
if (inLava) {
baritone.getInputOverrideHandler().setInputForceState(Input.JUMP, true);
}
if (solution == null) { if (solution == null) {
logDirect("no solution"); logDirect("no solution");
return; return;
@ -622,7 +628,7 @@ public final class ElytraBehavior implements Helper {
solution.context.start, solution.context.start,
solution.goingTo, solution.goingTo,
solution.context.boost.isBoosted(), solution.context.boost.isBoosted(),
solution.forceUseFirework solution.forceUseFirework || inLava
); );
} }
@ -1004,7 +1010,7 @@ public final class ElytraBehavior implements Helper {
// if start == dest then the cpp raytracer dies // if start == dest then the cpp raytracer dies
clear = start.equals(dest) || this.context.raytrace(start, dest); clear = start.equals(dest) || this.context.raytrace(start, dest);
} else { } else {
clear = ctx.world().clip(new ClipContext(start, dest, ClipContext.Block.COLLIDER, ClipContext.Fluid.ANY, ctx.player())).getType() == HitResult.Type.MISS; clear = ctx.world().clip(new ClipContext(start, dest, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, ctx.player())).getType() == HitResult.Type.MISS;
} }
if (Baritone.settings().elytraRenderRaytraces.value) { if (Baritone.settings().elytraRenderRaytraces.value) {