Skip to content

Commit 97067b9

Browse files
committed
Merge branch '1.19.4' into 1.20.1
2 parents 3b30b06 + 2cd5c6b commit 97067b9

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

src/main/java/baritone/process/elytra/ElytraBehavior.java

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import baritone.api.event.events.*;
2525
import baritone.api.pathing.goals.GoalBlock;
2626
import baritone.api.utils.*;
27+
import baritone.api.utils.input.Input;
2728
import baritone.pathing.movement.MovementHelper;
2829
import baritone.process.ElytraProcess;
2930
import baritone.utils.BlockStateInterface;
@@ -103,7 +104,7 @@ public final class ElytraBehavior implements Helper {
103104

104105
private BlockStateInterface bsi;
105106
private final BlockStateOctreeInterface boi;
106-
public final BlockPos destination;
107+
public final BetterBlockPos destination;
107108
private final boolean appendDestination;
108109

109110
private final ExecutorService solverExecutor;
@@ -124,7 +125,7 @@ public ElytraBehavior(Baritone baritone, ElytraProcess process, BlockPos destina
124125
this.blockedLines = new CopyOnWriteArrayList<>();
125126
this.pathManager = this.new PathManager();
126127
this.process = process;
127-
this.destination = destination;
128+
this.destination = new BetterBlockPos(destination);
128129
this.appendDestination = appendDestination;
129130
this.solverExecutor = Executors.newSingleThreadExecutor();
130131
this.nextTickBoostCounter = new int[2];
@@ -193,16 +194,16 @@ public CompletableFuture<Void> pathToDestination(final BlockPos from) {
193194
});
194195
}
195196

196-
public CompletableFuture<Void> pathRecalcSegment(final int upToIncl) {
197+
public CompletableFuture<Void> pathRecalcSegment(final OptionalInt upToIncl) {
197198
if (this.recalculating) {
198199
throw new IllegalStateException("already recalculating");
199200
}
200201

201202
this.recalculating = true;
202-
final List<BetterBlockPos> after = this.path.subList(upToIncl + 1, this.path.size());
203+
final List<BetterBlockPos> after = upToIncl.isPresent() ? this.path.subList(upToIncl.getAsInt() + 1, this.path.size()) : Collections.emptyList();
203204
final boolean complete = this.completePath;
204205

205-
return this.path0(ctx.playerFeet(), this.path.get(upToIncl), segment -> segment.append(after.stream(), complete))
206+
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())))
206207
.whenComplete((result, ex) -> {
207208
this.recalculating = false;
208209
if (ex != null) {
@@ -320,7 +321,7 @@ private void pathfindAroundObstacles() {
320321
}
321322

322323
if (ElytraBehavior.this.process.state != ElytraProcess.State.LANDING && this.ticksNearUnchanged > 100) {
323-
this.pathRecalcSegment(rangeEndExcl - 1)
324+
this.pathRecalcSegment(OptionalInt.of(rangeEndExcl - 1))
324325
.thenRun(() -> {
325326
logDirect("Recalculating segment, no progress in last 100 ticks");
326327
});
@@ -336,15 +337,15 @@ private void pathfindAroundObstacles() {
336337
if (!ElytraBehavior.this.clearView(this.path.getVec(i), this.path.getVec(i + 1), false)) {
337338
// obstacle. where do we return to pathing?
338339
// 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
339-
int rejoinMainPathAt;
340-
if (this.path.get(rangeEndExcl - 1).distanceSq(this.path.get(path.size() - 1)) < ctx.playerFeet().distanceSq(this.path.get(path.size() - 1))) {
341-
rejoinMainPathAt = rangeEndExcl - 1; // rejoin after current render distance
340+
OptionalInt rejoinMainPathAt;
341+
if (this.path.get(rangeEndExcl - 1).distanceSq(ElytraBehavior.this.destination) < ctx.playerFeet().distanceSq(ElytraBehavior.this.destination)) {
342+
rejoinMainPathAt = OptionalInt.of(rangeEndExcl - 1); // rejoin after current render distance
342343
} else {
343-
rejoinMainPathAt = path.size() - 1; // large backtrack detected. ignore render distance, rejoin later on
344+
rejoinMainPathAt = OptionalInt.empty(); // large backtrack detected. ignore render distance, rejoin later on
344345
}
345346

346347
final BetterBlockPos blockage = this.path.get(i);
347-
final double distance = ctx.playerFeet().distanceTo(this.path.get(rejoinMainPathAt));
348+
final double distance = ctx.playerFeet().distanceTo(this.path.get(rejoinMainPathAt.orElse(path.size() - 1)));
348349

349350
final long start = System.nanoTime();
350351
this.pathRecalcSegment(rejoinMainPathAt)
@@ -361,7 +362,7 @@ private void pathfindAroundObstacles() {
361362
}
362363
}
363364
if (!canSeeAny && rangeStartIncl < rangeEndExcl - 2 && process.state != ElytraProcess.State.GET_TO_JUMP) {
364-
this.pathRecalcSegment(rangeEndExcl - 1).thenRun(() -> logDirect("Recalculated segment since no path points were visible"));
365+
this.pathRecalcSegment(OptionalInt.of(rangeEndExcl - 1)).thenRun(() -> logDirect("Recalculated segment since no path points were visible"));
365366
}
366367
}
367368

@@ -604,6 +605,11 @@ public void tick() {
604605
this.deployedFireworkLastTick = false;
605606
}
606607

608+
final boolean inLava = ctx.player().isInLava();
609+
if (inLava) {
610+
baritone.getInputOverrideHandler().setInputForceState(Input.JUMP, true);
611+
}
612+
607613
if (solution == null) {
608614
logDirect("no solution");
609615
return;
@@ -622,7 +628,7 @@ public void tick() {
622628
solution.context.start,
623629
solution.goingTo,
624630
solution.context.boost.isBoosted(),
625-
solution.forceUseFirework
631+
solution.forceUseFirework || inLava
626632
);
627633
}
628634

@@ -1004,7 +1010,7 @@ public boolean clearView(Vec3 start, Vec3 dest, boolean ignoreLava) {
10041010
// if start == dest then the cpp raytracer dies
10051011
clear = start.equals(dest) || this.context.raytrace(start, dest);
10061012
} else {
1007-
clear = ctx.world().clip(new ClipContext(start, dest, ClipContext.Block.COLLIDER, ClipContext.Fluid.ANY, ctx.player())).getType() == HitResult.Type.MISS;
1013+
clear = ctx.world().clip(new ClipContext(start, dest, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, ctx.player())).getType() == HitResult.Type.MISS;
10081014
}
10091015

10101016
if (Baritone.settings().elytraRenderRaytraces.value) {

0 commit comments

Comments
 (0)