2018-08-08 03:16:53 +00:00
|
|
|
/*
|
|
|
|
* This file is part of Baritone.
|
|
|
|
*
|
|
|
|
* Baritone is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2018-08-08 04:15:22 +00:00
|
|
|
* Baritone is distributed in the hope that it will be useful,
|
2018-08-08 03:16:53 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2018-08-22 20:15:56 +00:00
|
|
|
package baritone.pathing.goals;
|
2018-08-02 03:13:48 +00:00
|
|
|
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
|
|
|
|
/**
|
2018-08-08 23:55:20 +00:00
|
|
|
* Useful if the goal is just to mine a block. This goal will be satisfied if the specified
|
|
|
|
* {@link BlockPos} is at to or above the specified position for this goal.
|
|
|
|
*
|
2018-08-02 03:13:48 +00:00
|
|
|
* @author leijurv
|
|
|
|
*/
|
|
|
|
public class GoalTwoBlocks implements Goal {
|
2018-08-02 04:22:21 +00:00
|
|
|
|
2018-08-08 23:55:20 +00:00
|
|
|
/**
|
|
|
|
* The X block position of this goal
|
|
|
|
*/
|
|
|
|
private final int x;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Y block position of this goal
|
|
|
|
*/
|
|
|
|
private final int y;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Z block position of this goal
|
|
|
|
*/
|
|
|
|
private final int 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;
|
2018-08-17 20:17:16 +00:00
|
|
|
int yDiff = pos.getY() - this.y;
|
2018-08-02 03:13:48 +00:00
|
|
|
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 + "}";
|
|
|
|
}
|
|
|
|
}
|