mirror of
https://github.com/cabaletta/baritone
synced 2024-12-17 20:55:09 +00:00
Replace sublist troll in PathRenderer with visiblePath
This commit is contained in:
parent
5b39eb5041
commit
800cb2e747
@ -44,20 +44,25 @@ import java.util.stream.Collectors;
|
|||||||
public class Elytra extends Behavior implements Helper {
|
public class Elytra extends Behavior implements Helper {
|
||||||
|
|
||||||
// Used exclusively for PathRenderer
|
// Used exclusively for PathRenderer
|
||||||
public List<Pair<Vec3d, Vec3d>> lines = new ArrayList<>();
|
public List<Pair<Vec3d, Vec3d>> lines;
|
||||||
public BlockPos goal;
|
public BlockPos goal;
|
||||||
|
public List<BetterBlockPos> visiblePath;
|
||||||
|
|
||||||
public List<BetterBlockPos> path = new ArrayList<>();
|
// NetherPathfinder stuff
|
||||||
|
|
||||||
private long context;
|
private long context;
|
||||||
private Long seed;
|
private Long seed;
|
||||||
|
|
||||||
|
// yay!
|
||||||
|
private List<BetterBlockPos> path;
|
||||||
public int playerNear;
|
public int playerNear;
|
||||||
private int goingTo;
|
private int goingTo;
|
||||||
private int sinceFirework;
|
private int sinceFirework;
|
||||||
|
|
||||||
protected Elytra(Baritone baritone) {
|
protected Elytra(Baritone baritone) {
|
||||||
super(baritone);
|
super(baritone);
|
||||||
|
this.lines = new ArrayList<>();
|
||||||
|
this.visiblePath = Collections.emptyList();
|
||||||
|
this.path = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void path(long seed, BlockPos destination) {
|
public void path(long seed, BlockPos destination) {
|
||||||
@ -100,6 +105,7 @@ public class Elytra extends Behavior implements Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
|
this.visiblePath = Collections.emptyList();
|
||||||
this.path.clear();
|
this.path.clear();
|
||||||
this.goal = null;
|
this.goal = null;
|
||||||
this.playerNear = 0;
|
this.playerNear = 0;
|
||||||
@ -120,7 +126,12 @@ public class Elytra extends Behavior implements Helper {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fixNearPlayer();
|
playerNear = fixNearPlayer(playerNear);
|
||||||
|
visiblePath = path.subList(
|
||||||
|
Math.max(playerNear - 30, 0),
|
||||||
|
Math.min(playerNear + 30, path.size())
|
||||||
|
);
|
||||||
|
|
||||||
baritone.getInputOverrideHandler().clearAllKeys(); // FIXME: This breaks the regular path-finder
|
baritone.getInputOverrideHandler().clearAllKeys(); // FIXME: This breaks the regular path-finder
|
||||||
lines.clear();
|
lines.clear();
|
||||||
|
|
||||||
@ -316,29 +327,29 @@ public class Elytra extends Behavior implements Helper {
|
|||||||
return new Vec3d(motionX, motionY, motionZ);
|
return new Vec3d(motionX, motionY, motionZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fixNearPlayer() {
|
private int fixNearPlayer(int index) {
|
||||||
BetterBlockPos pos = ctx.playerFeet();
|
final BetterBlockPos pos = ctx.playerFeet();
|
||||||
for (int i = playerNear; i >= Math.max(playerNear - 1000, 0); i -= 10) {
|
for (int i = index; i >= Math.max(index - 1000, 0); i -= 10) {
|
||||||
if (path.get(i).distanceSq(pos) < path.get(playerNear).distanceSq(pos)) {
|
if (path.get(i).distanceSq(pos) < path.get(index).distanceSq(pos)) {
|
||||||
playerNear = i; // intentional: this changes the bound of the loop
|
index = i; // intentional: this changes the bound of the loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = playerNear; i < Math.min(playerNear + 1000, path.size()); i += 10) {
|
for (int i = index; i < Math.min(index + 1000, path.size()); i += 10) {
|
||||||
if (path.get(i).distanceSq(pos) < path.get(playerNear).distanceSq(pos)) {
|
if (path.get(i).distanceSq(pos) < path.get(index).distanceSq(pos)) {
|
||||||
playerNear = i; // intentional: this changes the bound of the loop
|
index = i; // intentional: this changes the bound of the loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = playerNear; i >= Math.max(playerNear - 50, 0); i--) {
|
for (int i = index; i >= Math.max(index - 50, 0); i--) {
|
||||||
if (path.get(i).distanceSq(pos) < path.get(playerNear).distanceSq(pos)) {
|
if (path.get(i).distanceSq(pos) < path.get(index).distanceSq(pos)) {
|
||||||
playerNear = i; // intentional: this changes the bound of the loop
|
index = i; // intentional: this changes the bound of the loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = playerNear; i < Math.min(playerNear + 50, path.size()); i++) {
|
for (int i = index; i < Math.min(index + 50, path.size()); i++) {
|
||||||
if (path.get(i).distanceSq(pos) < path.get(playerNear).distanceSq(pos)) {
|
if (path.get(i).distanceSq(pos) < path.get(index).distanceSq(pos)) {
|
||||||
playerNear = i; // intentional: this changes the bound of the loop
|
index = i; // intentional: this changes the bound of the loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//System.out.println(playerNear);
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeBacktracks() {
|
private void removeBacktracks() {
|
||||||
|
@ -105,7 +105,7 @@ public final class PathRenderer implements IRenderer {
|
|||||||
drawPath(next.getPath().positions(), 0, settings.colorNextPath.value, settings.fadePath.value, 10, 20);
|
drawPath(next.getPath().positions(), 0, settings.colorNextPath.value, settings.fadePath.value, 10, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawPath(behavior.baritone.elytra.path.subList(Math.max(behavior.baritone.elytra.playerNear - 30, 0), Math.min(behavior.baritone.elytra.playerNear + 30, behavior.baritone.elytra.path.size())), 0, Color.RED, false, 0, 0);
|
drawPath(behavior.baritone.elytra.visiblePath, 0, Color.RED, false, 0, 0);
|
||||||
if (behavior.baritone.elytra.goal != null) {
|
if (behavior.baritone.elytra.goal != null) {
|
||||||
drawGoal(renderView, new GoalBlock(behavior.baritone.elytra.goal), partialTicks, Color.GREEN);
|
drawGoal(renderView, new GoalBlock(behavior.baritone.elytra.goal), partialTicks, Color.GREEN);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user