increase air bubble radius, append destination to path when landing

This commit is contained in:
Babbaj 2023-07-30 19:45:25 -04:00
parent 3a6e5541fb
commit 27e45b816d
No known key found for this signature in database
GPG Key ID: F044309848A07CAC
3 changed files with 22 additions and 7 deletions

View File

@ -113,7 +113,7 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
BetterBlockPos landingSpot = findSafeLandingSpot(last);
// if this fails we will just keep orbiting the last node until we run out of rockets or the user intervenes
if (landingSpot != null) {
this.pathTo(landingSpot);
this.pathTo0(landingSpot, true);
this.landingSpot = landingSpot;
this.goingToLandingSpot = true;
}
@ -248,6 +248,7 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
public void onLostControl() {
this.goal = null;
this.goingToLandingSpot = false;
this.landingSpot = null;
this.reachedGoal = false;
this.state = State.START_FLYING; // TODO: null state?
if (this.behavior != null) {
@ -280,11 +281,15 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
@Override
public void pathTo(BlockPos destination) {
this.pathTo0(destination, false);
}
private void pathTo0(BlockPos destination, boolean appendDestination) {
if (ctx.player() == null || ctx.player().dimension != -1) {
return;
}
this.onLostControl();
this.behavior = new ElytraBehavior(this.baritone, this, destination);
this.behavior = new ElytraBehavior(this.baritone, this, destination, appendDestination);
if (ctx.world() != null) {
this.behavior.repackChunks();
}
@ -440,7 +445,7 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
}
private boolean hasAirBubble(BlockPos pos) {
final int radius = 2; // Half of 5, as we're counting blocks in each direction from the center
final int radius = 4; // Half of the full width, rounded down, as we're counting blocks in each direction from the center
BlockPos.MutableBlockPos mut = new BlockPos.MutableBlockPos();
for (int x = -radius; x <= radius; x++) {
for (int y = -radius; y <= radius; y++) {

View File

@ -99,6 +99,7 @@ public final class ElytraBehavior implements Helper {
private BlockStateInterface bsi;
private final BlockStateOctreeInterface boi;
public final BlockPos destination;
private final boolean appendDestination;
private final ExecutorService solverExecutor;
private Future<Solution> solver;
@ -111,7 +112,7 @@ public final class ElytraBehavior implements Helper {
private int invTickCountdown = 0;
private final Queue<Runnable> invTransactionQueue = new LinkedList<>();
public ElytraBehavior(Baritone baritone, ElytraProcess process, BlockPos destination) {
public ElytraBehavior(Baritone baritone, ElytraProcess process, BlockPos destination, boolean appendDestination) {
this.baritone = baritone;
this.ctx = baritone.getPlayerContext();
this.clearLines = new CopyOnWriteArrayList<>();
@ -119,6 +120,7 @@ public final class ElytraBehavior implements Helper {
this.pathManager = this.new PathManager();
this.process = process;
this.destination = destination;
this.appendDestination = appendDestination;
this.solverExecutor = Executors.newSingleThreadExecutor();
this.nextTickBoostCounter = new int[2];
@ -252,7 +254,15 @@ public final class ElytraBehavior implements Helper {
}
private void setPath(final UnpackedSegment segment) {
this.path = segment.collect();
List<BetterBlockPos> path = segment.collect();
if (ElytraBehavior.this.appendDestination) {
BlockPos dest = ElytraBehavior.this.destination;
BlockPos last = !path.isEmpty() ? path.get(path.size() - 1) : null;
if (last != null && ElytraBehavior.this.clearView(new Vec3d(dest), new Vec3d(last), false)) {
path.add(new BetterBlockPos(dest));
}
}
this.path = new NetherPath(path);
this.completePath = segment.isFinished();
this.playerNear = 0;
this.ticksNearUnchanged = 0;

View File

@ -49,7 +49,7 @@ public final class UnpackedSegment {
return new UnpackedSegment(Stream.concat(other, this.path), this.finished);
}
public NetherPath collect() {
public List<BetterBlockPos> collect() {
final List<BetterBlockPos> path = this.path.collect(Collectors.toList());
// Remove backtracks
@ -67,7 +67,7 @@ public final class UnpackedSegment {
}
}
return new NetherPath(path);
return path;
}
public boolean isFinished() {