maintain y while exploring

This commit is contained in:
Leijurv 2019-04-25 13:40:33 -07:00
parent c8419dc362
commit 5a0ccac0a1
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 23 additions and 1 deletions

View File

@ -610,6 +610,13 @@ public final class Settings {
*/
public final Setting<Integer> exploreChunkSetMinimumSize = new Setting<>(10);
/**
* Attempt to maintain Y coordinate while exploring
* <p>
* -1 to disable
*/
public final Setting<Integer> exploreMaintainY = new Setting<>(64);
/**
* Replant nether wart
*/

View File

@ -22,6 +22,7 @@ import baritone.api.cache.ICachedWorld;
import baritone.api.pathing.goals.Goal;
import baritone.api.pathing.goals.GoalComposite;
import baritone.api.pathing.goals.GoalXZ;
import baritone.api.pathing.goals.GoalYLevel;
import baritone.api.process.IExploreProcess;
import baritone.api.process.PathingCommand;
import baritone.api.process.PathingCommandType;
@ -133,11 +134,25 @@ public class ExploreProcess extends BaritoneProcessHelper implements IExplorePro
}
}
if (centers.size() >= count) {
return centers.stream().map(pos -> new GoalXZ(pos.getX(), pos.getZ())).toArray(Goal[]::new);
return centers.stream().map(pos -> createGoal(pos.getX(), pos.getZ())).toArray(Goal[]::new);
}
}
}
private static Goal createGoal(int x, int z) {
if (Baritone.settings().exploreMaintainY.value == -1) {
return new GoalXZ(x, z);
}
// don't use a goalblock because we still want isInGoal to return true if X and Z are correct
// we just want to try and maintain Y on the way there, not necessarily end at that specific Y
return new GoalXZ(x, z) {
@Override
public double heuristic(int x, int y, int z) {
return super.heuristic(x, y, z) + GoalYLevel.calculate(Baritone.settings().exploreMaintainY.value, y);
}
};
}
private enum Status {
EXPLORED, NOT_EXPLORED, UNKNOWN;
}