We do a little trolling

This commit is contained in:
Brady 2023-06-20 21:27:54 -05:00
parent e76f79214e
commit bd7a57f7aa
No known key found for this signature in database
GPG Key ID: 73A788379A197567
2 changed files with 22 additions and 19 deletions

View File

@ -185,7 +185,6 @@ public final class ElytraBehavior extends Behavior implements IElytraBehavior, H
private void setPath(final UnpackedSegment segment) {
this.path = segment.collect();
this.removeBacktracks();
this.completePath = segment.isFinished();
this.playerNear = 0;
this.ticksNearUnchanged = 0;
@ -295,22 +294,6 @@ public final class ElytraBehavior extends Behavior implements IElytraBehavior, H
}
this.playerNear = index;
}
private void removeBacktracks() {
Map<BetterBlockPos, Integer> positionFirstSeen = new HashMap<>();
for (int i = 0; i < this.path.size(); i++) {
BetterBlockPos pos = this.path.get(i);
if (positionFirstSeen.containsKey(pos)) {
int j = positionFirstSeen.get(pos);
while (i > j) {
this.path.remove(i);
i--;
}
} else {
positionFirstSeen.put(pos, i);
}
}
}
}
@Override
@ -466,7 +449,7 @@ public final class ElytraBehavior extends Behavior implements IElytraBehavior, H
for (int relaxation = 0; relaxation < 3; relaxation++) { // try for a strict solution first, then relax more and more (if we're in a corner or near some blocks, it will have to relax its constraints a bit)
int[] heights = isBoosted ? new int[]{20, 10, 5, 0} : new int[]{0}; // attempt to gain height, if we can, so as not to waste the boost
float[] interps = new float[] {1.0f, 0.75f, 0.5f, 0.25f};
float[] interps = new float[] {1.0f};
int steps = relaxation < 2 ? isBoosted ? 5 : Baritone.settings().elytraSimulationTicks.value : 3;
int lookahead = relaxation == 0 ? 2 : 3; // ideally this would be expressed as a distance in blocks, rather than a number of voxel steps
//int minStep = Math.max(0, playerNear - relaxation);

View File

@ -22,6 +22,9 @@ import dev.babbaj.pathfinder.PathSegment;
import net.minecraft.util.math.BlockPos;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -48,7 +51,24 @@ public final class UnpackedSegment {
}
public NetherPath collect() {
return new NetherPath(this.path.collect(Collectors.toList()));
final List<BetterBlockPos> path = this.path.collect(Collectors.toList());
// Remove backtracks
final Map<BetterBlockPos, Integer> positionFirstSeen = new HashMap<>();
for (int i = 0; i < path.size(); i++) {
BetterBlockPos pos = path.get(i);
if (positionFirstSeen.containsKey(pos)) {
int j = positionFirstSeen.get(pos);
while (i > j) {
path.remove(i);
i--;
}
} else {
positionFirstSeen.put(pos, i);
}
}
return new NetherPath(path);
}
public boolean isFinished() {