baritone/src/main/java/baritone/bot/pathing/goals/GoalTwoBlocks.java

45 lines
1.1 KiB
Java
Raw Normal View History

2018-08-02 03:30:12 +00:00
package baritone.bot.pathing.goals;
2018-08-02 03:13:48 +00:00
import net.minecraft.util.math.BlockPos;
/**
* Useful if the goal is just to mine a block.
* This goal gets either the player's feet or head into the desired block.
* @author leijurv
*/
public class GoalTwoBlocks implements Goal {
2018-08-02 04:22:21 +00:00
2018-08-02 03:13:48 +00:00
final int x, y, z;
2018-08-02 04:22:21 +00:00
2018-08-02 03:13:48 +00:00
public GoalTwoBlocks(BlockPos pos) {
this(pos.getX(), pos.getY(), pos.getZ());
}
2018-08-02 04:22:21 +00:00
2018-08-02 03:13:48 +00:00
public GoalTwoBlocks(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
2018-08-02 04:22:21 +00:00
2018-08-02 03:13:48 +00:00
@Override
public boolean isInGoal(BlockPos pos) {
return pos.getX() == this.x && (pos.getY() == this.y || pos.getY() == this.y - 1) && pos.getZ() == this.z;
}
2018-08-02 04:22:21 +00:00
2018-08-02 03:13:48 +00:00
@Override
public double heuristic(BlockPos pos) {
double xDiff = pos.getX() - this.x;
double yDiff = pos.getY() - this.y;
if (yDiff < 0) {
yDiff++;
}
double zDiff = pos.getZ() - this.z;
return GoalBlock.calculate(xDiff, yDiff, zDiff);
}
2018-08-02 04:22:21 +00:00
2018-08-02 03:13:48 +00:00
@Override
public String toString() {
return "GoalTwoBlocks{x=" + x + ",y=" + y + ",z=" + z + "}";
}
}