Use new nether-pathfinder API

Doesn't stitch segments, just partially functional
This commit is contained in:
Brady 2023-06-16 18:59:57 -05:00
parent e01093eb9a
commit 8c12416348
No known key found for this signature in database
GPG Key ID: 73A788379A197567
3 changed files with 48 additions and 7 deletions

View File

@ -88,6 +88,11 @@ repositories {
name = 'impactdevelopment-repo'
url = 'https://impactdevelopment.github.io/maven/'
}
maven {
name = 'babbaj-repo'
url = 'https://babbaj.github.io/maven/'
}
}
dependencies {
@ -100,9 +105,9 @@ dependencies {
exclude module: 'commons-io'
exclude module: 'log4j-core'
}
runtime launchCompile('dev.babbaj:nether-pathfinder:1.3')
runtime launchCompile('dev.babbaj:nether-pathfinder:0.2')
testImplementation 'junit:junit:4.12'
implementation 'dev.babbaj:nether-pathfinder:1.3'
implementation 'dev.babbaj:nether-pathfinder:0.2'
}
mixin {

View File

@ -26,6 +26,7 @@ import baritone.behavior.Behavior;
import baritone.utils.BlockStateInterface;
import com.mojang.realmsclient.util.Pair;
import dev.babbaj.pathfinder.NetherPathfinder;
import dev.babbaj.pathfinder.PathSegment;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityFireworkRocket;
@ -44,13 +45,48 @@ public class Elytra extends Behavior implements Helper {
public List<BetterBlockPos> path = new ArrayList<>();
public void path(BlockPos destination) {
playerNear = 0;
goingTo = 0;
path = Arrays.stream(NetherPathfinder.pathFind(146008555100680L, false, false, ctx.playerFeet().x, ctx.playerFeet().y, ctx.playerFeet().z, destination.getX(), destination.getY(), destination.getZ())).mapToObj(BlockPos::fromLong).map(BetterBlockPos::new).collect(Collectors.toList());
private long context;
private Long seed;
public void path(long seed, BlockPos destination) {
this.setupContext(seed);
this.playerNear = 0;
this.goingTo = 0;
final PathSegment segment = NetherPathfinder.pathFind(
this.context,
ctx.playerFeet().x, ctx.playerFeet().y, ctx.playerFeet().z,
destination.getX(), destination.getY(), destination.getZ()
);
this.path = Arrays.stream(segment.packed)
.mapToObj(BlockPos::fromLong)
.map(BetterBlockPos::new)
.collect(Collectors.toList());
if (!segment.finished) {
logDirect("segment not finished. path incomplete");
}
removeBacktracks();
}
private void setupContext(long seed) {
if (!Objects.equals(this.seed, seed)) {
this.freeContext();
this.context = NetherPathfinder.newContext(seed);
}
this.seed = seed;
}
private void freeContext() {
if (this.context != 0) {
NetherPathfinder.freeContext(this.context);
}
this.context = 0;
}
public int playerNear;
public int goingTo;
public int sinceFirework;

View File

@ -41,7 +41,7 @@ public class ElytraCommand extends Command {
ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
args.requireMax(0);
GoalXZ goal = (GoalXZ) customGoalProcess.getGoal();
((Baritone) baritone).elytra.path(new BlockPos(goal.getX(), 64, goal.getZ()));
((Baritone) baritone).elytra.path(146008555100680L, new BlockPos(goal.getX(), 64, goal.getZ()));
}
@Override