24
24
import baritone .api .event .events .*;
25
25
import baritone .api .pathing .goals .GoalBlock ;
26
26
import baritone .api .utils .*;
27
+ import baritone .api .utils .input .Input ;
27
28
import baritone .pathing .movement .MovementHelper ;
28
29
import baritone .process .ElytraProcess ;
29
30
import baritone .utils .BlockStateInterface ;
@@ -103,7 +104,7 @@ public final class ElytraBehavior implements Helper {
103
104
104
105
private BlockStateInterface bsi ;
105
106
private final BlockStateOctreeInterface boi ;
106
- public final BlockPos destination ;
107
+ public final BetterBlockPos destination ;
107
108
private final boolean appendDestination ;
108
109
109
110
private final ExecutorService solverExecutor ;
@@ -124,7 +125,7 @@ public ElytraBehavior(Baritone baritone, ElytraProcess process, BlockPos destina
124
125
this .blockedLines = new CopyOnWriteArrayList <>();
125
126
this .pathManager = this .new PathManager ();
126
127
this .process = process ;
127
- this .destination = destination ;
128
+ this .destination = new BetterBlockPos ( destination ) ;
128
129
this .appendDestination = appendDestination ;
129
130
this .solverExecutor = Executors .newSingleThreadExecutor ();
130
131
this .nextTickBoostCounter = new int [2 ];
@@ -193,16 +194,16 @@ public CompletableFuture<Void> pathToDestination(final BlockPos from) {
193
194
});
194
195
}
195
196
196
- public CompletableFuture <Void > pathRecalcSegment (final int upToIncl ) {
197
+ public CompletableFuture <Void > pathRecalcSegment (final OptionalInt upToIncl ) {
197
198
if (this .recalculating ) {
198
199
throw new IllegalStateException ("already recalculating" );
199
200
}
200
201
201
202
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 ( );
203
204
final boolean complete = this .completePath ;
204
205
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 ()) ))
206
207
.whenComplete ((result , ex ) -> {
207
208
this .recalculating = false ;
208
209
if (ex != null ) {
@@ -320,7 +321,7 @@ private void pathfindAroundObstacles() {
320
321
}
321
322
322
323
if (ElytraBehavior .this .process .state != ElytraProcess .State .LANDING && this .ticksNearUnchanged > 100 ) {
323
- this .pathRecalcSegment (rangeEndExcl - 1 )
324
+ this .pathRecalcSegment (OptionalInt . of ( rangeEndExcl - 1 ) )
324
325
.thenRun (() -> {
325
326
logDirect ("Recalculating segment, no progress in last 100 ticks" );
326
327
});
@@ -336,15 +337,15 @@ private void pathfindAroundObstacles() {
336
337
if (!ElytraBehavior .this .clearView (this .path .getVec (i ), this .path .getVec (i + 1 ), false )) {
337
338
// obstacle. where do we return to pathing?
338
339
// 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
342
343
} 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
344
345
}
345
346
346
347
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 ) ));
348
349
349
350
final long start = System .nanoTime ();
350
351
this .pathRecalcSegment (rejoinMainPathAt )
@@ -361,7 +362,7 @@ private void pathfindAroundObstacles() {
361
362
}
362
363
}
363
364
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" ));
365
366
}
366
367
}
367
368
@@ -604,6 +605,11 @@ public void tick() {
604
605
this .deployedFireworkLastTick = false ;
605
606
}
606
607
608
+ final boolean inLava = ctx .player ().isInLava ();
609
+ if (inLava ) {
610
+ baritone .getInputOverrideHandler ().setInputForceState (Input .JUMP , true );
611
+ }
612
+
607
613
if (solution == null ) {
608
614
logDirect ("no solution" );
609
615
return ;
@@ -622,7 +628,7 @@ public void tick() {
622
628
solution .context .start ,
623
629
solution .goingTo ,
624
630
solution .context .boost .isBoosted (),
625
- solution .forceUseFirework
631
+ solution .forceUseFirework || inLava
626
632
);
627
633
}
628
634
@@ -1004,7 +1010,7 @@ public boolean clearView(Vec3 start, Vec3 dest, boolean ignoreLava) {
1004
1010
// if start == dest then the cpp raytracer dies
1005
1011
clear = start .equals (dest ) || this .context .raytrace (start , dest );
1006
1012
} 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 ;
1008
1014
}
1009
1015
1010
1016
if (Baritone .settings ().elytraRenderRaytraces .value ) {
0 commit comments