mirror of https://github.com/cabaletta/baritone
Use new nether-pathfinder API
Doesn't stitch segments, just partially functional
This commit is contained in:
parent
e01093eb9a
commit
8c12416348
|
@ -88,6 +88,11 @@ repositories {
|
||||||
name = 'impactdevelopment-repo'
|
name = 'impactdevelopment-repo'
|
||||||
url = 'https://impactdevelopment.github.io/maven/'
|
url = 'https://impactdevelopment.github.io/maven/'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maven {
|
||||||
|
name = 'babbaj-repo'
|
||||||
|
url = 'https://babbaj.github.io/maven/'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -100,9 +105,9 @@ dependencies {
|
||||||
exclude module: 'commons-io'
|
exclude module: 'commons-io'
|
||||||
exclude module: 'log4j-core'
|
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'
|
testImplementation 'junit:junit:4.12'
|
||||||
implementation 'dev.babbaj:nether-pathfinder:1.3'
|
implementation 'dev.babbaj:nether-pathfinder:0.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
mixin {
|
mixin {
|
||||||
|
|
|
@ -26,6 +26,7 @@ import baritone.behavior.Behavior;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import com.mojang.realmsclient.util.Pair;
|
import com.mojang.realmsclient.util.Pair;
|
||||||
import dev.babbaj.pathfinder.NetherPathfinder;
|
import dev.babbaj.pathfinder.NetherPathfinder;
|
||||||
|
import dev.babbaj.pathfinder.PathSegment;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.item.EntityFireworkRocket;
|
import net.minecraft.entity.item.EntityFireworkRocket;
|
||||||
|
@ -44,13 +45,48 @@ public class Elytra extends Behavior implements Helper {
|
||||||
|
|
||||||
public List<BetterBlockPos> path = new ArrayList<>();
|
public List<BetterBlockPos> path = new ArrayList<>();
|
||||||
|
|
||||||
public void path(BlockPos destination) {
|
private long context;
|
||||||
playerNear = 0;
|
private Long seed;
|
||||||
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());
|
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();
|
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 playerNear;
|
||||||
public int goingTo;
|
public int goingTo;
|
||||||
public int sinceFirework;
|
public int sinceFirework;
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class ElytraCommand extends Command {
|
||||||
ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
|
ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
|
||||||
args.requireMax(0);
|
args.requireMax(0);
|
||||||
GoalXZ goal = (GoalXZ) customGoalProcess.getGoal();
|
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
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue