mirror of https://github.com/cabaletta/baritone
improvements/fixes
This commit is contained in:
parent
7f9e50bbe2
commit
c9aa1658b2
|
@ -57,6 +57,7 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
|
||||||
|
|
||||||
public State state;
|
public State state;
|
||||||
private boolean goingToLandingSpot;
|
private boolean goingToLandingSpot;
|
||||||
|
private BetterBlockPos landingSpot;
|
||||||
private Goal goal;
|
private Goal goal;
|
||||||
private LegacyElytraBehavior behavior;
|
private LegacyElytraBehavior behavior;
|
||||||
|
|
||||||
|
@ -102,7 +103,7 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
|
||||||
|
|
||||||
if (ctx.player().isElytraFlying() && this.state != State.LANDING) {
|
if (ctx.player().isElytraFlying() && this.state != State.LANDING) {
|
||||||
final BetterBlockPos last = this.behavior.pathManager.path.getLast();
|
final BetterBlockPos last = this.behavior.pathManager.path.getLast();
|
||||||
if (last != null && ctx.player().getDistanceSqToCenter(last) < (5 * 5)) {
|
if (last != null && ctx.player().getDistanceSqToCenter(last) < 1) {
|
||||||
if (Baritone.settings().notificationOnPathComplete.value) {
|
if (Baritone.settings().notificationOnPathComplete.value) {
|
||||||
logNotification("Pathing complete", false);
|
logNotification("Pathing complete", false);
|
||||||
}
|
}
|
||||||
|
@ -113,22 +114,25 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
|
||||||
return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL);
|
return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL);
|
||||||
}
|
}
|
||||||
if (!goingToLandingSpot) {
|
if (!goingToLandingSpot) {
|
||||||
BlockPos landingSpot = findSafeLandingSpot();
|
BetterBlockPos landingSpot = findSafeLandingSpot();
|
||||||
if (landingSpot != null) {
|
if (landingSpot != null) {
|
||||||
this.pathTo(landingSpot);
|
this.pathTo(landingSpot);
|
||||||
|
this.landingSpot = landingSpot;
|
||||||
this.goingToLandingSpot = true;
|
this.goingToLandingSpot = true;
|
||||||
return this.onTick(calcFailed, isSafeToCancel);
|
return this.onTick(calcFailed, isSafeToCancel);
|
||||||
}
|
}
|
||||||
|
// don't spam call findLandingSpot if it somehow fails (it's slow)
|
||||||
|
this.goingToLandingSpot = true;
|
||||||
}
|
}
|
||||||
this.state = State.LANDING;
|
this.state = State.LANDING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.state == State.LANDING) {
|
if (this.state == State.LANDING) {
|
||||||
final BetterBlockPos endPos = behavior.pathManager.path.getLast();
|
final BetterBlockPos endPos = this.landingSpot != null ? this.landingSpot : behavior.pathManager.path.getLast();
|
||||||
if (ctx.player().isElytraFlying() && endPos != null) {
|
if (ctx.player().isElytraFlying() && endPos != null) {
|
||||||
Vec3d from = ctx.player().getPositionVector();
|
Vec3d from = ctx.player().getPositionVector();
|
||||||
Vec3d to = new Vec3d(endPos.x, from.y, endPos.z);
|
Vec3d to = new Vec3d(((double) endPos.x) + 0.5, from.y, ((double) endPos.z) + 0.5);
|
||||||
Rotation rotation = RotationUtils.calcRotationFromVec3d(from, to, ctx.playerRotations());
|
Rotation rotation = RotationUtils.calcRotationFromVec3d(from, to, ctx.playerRotations());
|
||||||
baritone.getLookBehavior().updateTarget(rotation, false);
|
baritone.getLookBehavior().updateTarget(rotation, false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -350,6 +354,18 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
|
||||||
return pos.getY() >= 0 && pos.getY() < 128;
|
return pos.getY() >= 0 && pos.getY() < 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isAtEdge(BlockPos pos) {
|
||||||
|
return ctx.world().isAirBlock(pos.north())
|
||||||
|
|| ctx.world().isAirBlock(pos.south())
|
||||||
|
|| ctx.world().isAirBlock(pos.east())
|
||||||
|
|| ctx.world().isAirBlock(pos.west())
|
||||||
|
// corners
|
||||||
|
|| ctx.world().isAirBlock(pos.north().west())
|
||||||
|
|| ctx.world().isAirBlock(pos.north().east())
|
||||||
|
|| ctx.world().isAirBlock(pos.south().west())
|
||||||
|
|| ctx.world().isAirBlock(pos.south().east());
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isSafeLandingSpot(BlockPos pos) {
|
private boolean isSafeLandingSpot(BlockPos pos) {
|
||||||
BlockPos.MutableBlockPos mut = new BlockPos.MutableBlockPos(pos);
|
BlockPos.MutableBlockPos mut = new BlockPos.MutableBlockPos(pos);
|
||||||
while (mut.getY() >= 0) {
|
while (mut.getY() >= 0) {
|
||||||
|
@ -358,21 +374,21 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (state.getMaterial().blocksMovement() && state.getBlock() != Blocks.MAGMA) {
|
if (state.getMaterial().blocksMovement() && state.getBlock() != Blocks.MAGMA) {
|
||||||
return true;
|
return !isAtEdge(mut);
|
||||||
}
|
}
|
||||||
mut.setPos(mut.getX(), mut.getY() - 1, mut.getZ());
|
mut.setPos(mut.getX(), mut.getY() - 1, mut.getZ());
|
||||||
}
|
}
|
||||||
return false; // void
|
return false; // void
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlockPos findSafeLandingSpot() {
|
private BetterBlockPos findSafeLandingSpot() {
|
||||||
final BlockPos start = new BlockPos(ctx.playerFeet());
|
final BetterBlockPos start = ctx.playerFeet();
|
||||||
Queue<BlockPos> queue = new LinkedList<>();
|
Queue<BetterBlockPos> queue = new LinkedList<>();
|
||||||
Set<BlockPos> visited = new HashSet<>();
|
Set<BetterBlockPos> visited = new HashSet<>();
|
||||||
queue.add(start);
|
queue.add(start);
|
||||||
|
|
||||||
while (!queue.isEmpty()) {
|
while (!queue.isEmpty()) {
|
||||||
BlockPos pos = queue.poll();
|
BetterBlockPos pos = queue.poll();
|
||||||
if (ctx.world().isBlockLoaded(pos) && isInBounds(pos) && ctx.world().getBlockState(pos).getBlock() == Blocks.AIR) {
|
if (ctx.world().isBlockLoaded(pos) && isInBounds(pos) && ctx.world().getBlockState(pos).getBlock() == Blocks.AIR) {
|
||||||
if (isSafeLandingSpot(pos)) {
|
if (isSafeLandingSpot(pos)) {
|
||||||
return pos;
|
return pos;
|
||||||
|
|
Loading…
Reference in New Issue