Merge branch 'master' of github.com:cabaletta/baritone
This commit is contained in:
commit
a6b5d423d5
@ -26,7 +26,20 @@ import net.minecraft.util.math.BlockPos;
|
||||
*/
|
||||
public class GoalBlock implements Goal {
|
||||
|
||||
private final int x, y, z;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public GoalBlock(BlockPos pos) {
|
||||
this(pos.getX(), pos.getY(), pos.getZ());
|
||||
@ -44,10 +57,14 @@ public class GoalBlock implements Goal {
|
||||
}
|
||||
|
||||
/**
|
||||
* The range over which to begin considering Y coordinate in the heuristic
|
||||
* The min range value over which to begin considering Y coordinate in the heuristic
|
||||
*/
|
||||
static final double MIN = 20;
|
||||
static final double MAX = 150;
|
||||
private static final double MIN = 20;
|
||||
|
||||
/**
|
||||
* The max range value over which to begin considering Y coordinate in the heuristic
|
||||
*/
|
||||
private static final double MAX = 150;
|
||||
|
||||
@Override
|
||||
public double heuristic(BlockPos pos) {
|
||||
@ -62,6 +79,13 @@ public class GoalBlock implements Goal {
|
||||
return "Goal{x=" + x + ",y=" + y + ",z=" + z + "}";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The position of this goal as a {@link BlockPos}
|
||||
*/
|
||||
public BlockPos getGoalPos() {
|
||||
return new BlockPos(x, y, z);
|
||||
}
|
||||
|
||||
public static double calculate(double xDiff, double yDiff, double zDiff) {
|
||||
double pythaDist = Math.sqrt(xDiff * xDiff + zDiff * zDiff);
|
||||
double heuristic = 0;
|
||||
@ -83,8 +107,4 @@ public class GoalBlock implements Goal {
|
||||
heuristic += GoalXZ.calculate(xDiff, zDiff, pythaDist);
|
||||
return heuristic;
|
||||
}
|
||||
|
||||
public BlockPos getGoalPos() {
|
||||
return new BlockPos(x, y, z);
|
||||
}
|
||||
}
|
||||
|
@ -25,10 +25,14 @@ import net.minecraft.util.math.BlockPos;
|
||||
* A composite of many goals, any one of which satisfies the composite.
|
||||
* For example, a GoalComposite of block goals for every oak log in loaded chunks
|
||||
* would result in it pathing to the easiest oak log to get to
|
||||
*
|
||||
* @author avecowa
|
||||
*/
|
||||
public class GoalComposite implements Goal {
|
||||
|
||||
/**
|
||||
* An array of goals that any one of must be satisfied
|
||||
*/
|
||||
public final Goal[] goals;
|
||||
|
||||
public GoalComposite(Goal... goals) {
|
||||
|
@ -21,8 +21,8 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
* Don't get into the block, but get directly adjacent to it.
|
||||
* Useful for chests.
|
||||
* Don't get into the block, but get directly adjacent to it. Useful for chests.
|
||||
*
|
||||
* @author avecowa
|
||||
*/
|
||||
public class GoalGetToBlock extends GoalComposite {
|
||||
|
@ -21,7 +21,7 @@ import java.util.Arrays;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
* Useful for automated combat (etreating specifically)
|
||||
* Useful for automated combat (retreating specifically)
|
||||
* @author leijurv
|
||||
*/
|
||||
public class GoalRunAway implements Goal {
|
||||
|
@ -20,13 +20,27 @@ package baritone.bot.pathing.goals;
|
||||
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.
|
||||
* 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.
|
||||
*
|
||||
* @author leijurv
|
||||
*/
|
||||
public class GoalTwoBlocks implements Goal {
|
||||
|
||||
final int x, y, z;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public GoalTwoBlocks(BlockPos pos) {
|
||||
this(pos.getX(), pos.getY(), pos.getZ());
|
||||
|
@ -25,12 +25,23 @@ import net.minecraft.util.math.BlockPos;
|
||||
*/
|
||||
public class GoalXZ implements Goal {
|
||||
|
||||
final int x, z;
|
||||
private static final double SQRT_2 = Math.sqrt(2);
|
||||
|
||||
/**
|
||||
* The X block position of this goal
|
||||
*/
|
||||
private final int x;
|
||||
|
||||
/**
|
||||
* The Z block position of this goal
|
||||
*/
|
||||
private final int z;
|
||||
|
||||
public GoalXZ(int x, int z) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInGoal(BlockPos pos) {
|
||||
return pos.getX() == x && pos.getZ() == z;
|
||||
@ -61,8 +72,6 @@ public class GoalXZ implements Goal {
|
||||
}
|
||||
*/
|
||||
|
||||
static final double sq = Math.sqrt(2);
|
||||
|
||||
public static double calculate(double xDiff, double zDiff, double pythaDist) {
|
||||
//This is a combination of pythagorean and manhattan distance
|
||||
//It takes into account the fact that pathing can either walk diagonally or forwards
|
||||
@ -80,7 +89,7 @@ public class GoalXZ implements Goal {
|
||||
straight = x - z;
|
||||
diagonal = z;
|
||||
}
|
||||
diagonal *= sq;
|
||||
diagonal *= SQRT_2;
|
||||
return (diagonal + straight) * WALK_ONE_BLOCK_COST;
|
||||
}
|
||||
|
||||
|
@ -21,11 +21,15 @@ import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
* Useful for mining (getting to diamond / iron level)
|
||||
*
|
||||
* @author leijurv
|
||||
*/
|
||||
public class GoalYLevel implements Goal {
|
||||
|
||||
final int level;
|
||||
/**
|
||||
* The target Y level
|
||||
*/
|
||||
private final int level;
|
||||
|
||||
public GoalYLevel(int level) {
|
||||
this.level = level;
|
||||
@ -38,8 +42,9 @@ public class GoalYLevel implements Goal {
|
||||
|
||||
@Override
|
||||
public double heuristic(BlockPos pos) {
|
||||
return 20 * Math.abs(pos.getY() - level);//the number 20 was chosen somewhat randomly.
|
||||
//TODO fix that
|
||||
// The number 20 was chosen somewhat randomly.
|
||||
// TODO fix that ^
|
||||
return 20 * Math.abs(pos.getY() - level);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user