better strategy

This commit is contained in:
Leijurv 2019-01-09 14:36:44 -08:00
parent 702b916948
commit c74c01271d
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
4 changed files with 31 additions and 8 deletions

View File

@ -30,17 +30,17 @@ public class GoalBlock implements Goal, IGoalRenderPos {
/** /**
* The X block position of this goal * The X block position of this goal
*/ */
private final int x; public final int x;
/** /**
* The Y block position of this goal * The Y block position of this goal
*/ */
private final int y; public final int y;
/** /**
* The Z block position of this goal * The Z block position of this goal
*/ */
private final int z; public final int z;
public GoalBlock(BlockPos pos) { public GoalBlock(BlockPos pos) {
this(pos.getX(), pos.getY(), pos.getZ()); this(pos.getX(), pos.getY(), pos.getZ());

View File

@ -65,7 +65,7 @@ public class CalculationContext {
public final int maxFallHeightBucket; public final int maxFallHeightBucket;
public final double waterWalkSpeed; public final double waterWalkSpeed;
public final double breakBlockAdditionalCost; public final double breakBlockAdditionalCost;
public final double jumpPenalty; public double jumpPenalty;
public final double walkOnWaterOnePenalty; public final double walkOnWaterOnePenalty;
public final BetterWorldBorder worldBorder; public final BetterWorldBorder worldBorder;

View File

@ -275,15 +275,25 @@ public class MovementTraverse extends Movement {
double faceX = (dest.getX() + against1.getX() + 1.0D) * 0.5D; double faceX = (dest.getX() + against1.getX() + 1.0D) * 0.5D;
double faceY = (dest.getY() + against1.getY()) * 0.5D; double faceY = (dest.getY() + against1.getY()) * 0.5D;
double faceZ = (dest.getZ() + against1.getZ() + 1.0D) * 0.5D; double faceZ = (dest.getZ() + against1.getZ() + 1.0D) * 0.5D;
state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(faceX, faceY, faceZ), ctx.playerRotations()), true)); Rotation rot = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(faceX, faceY, faceZ), ctx.playerRotations());
state.setTarget(new MovementState.MovementTarget(rot, true));
EnumFacing side = ctx.objectMouseOver().sideHit; EnumFacing side = ctx.objectMouseOver().sideHit;
if (Objects.equals(ctx.getSelectedBlock().orElse(null), against1) && (ctx.player().isSneaking() || Baritone.settings().assumeSafeWalk.get()) && ctx.getSelectedBlock().get().offset(side).equals(positionToPlace)) { if (Objects.equals(ctx.getSelectedBlock().orElse(null), against1) && (ctx.player().isSneaking() || Baritone.settings().assumeSafeWalk.get()) && ctx.getSelectedBlock().get().offset(side).equals(positionToPlace)) {
return state.setInput(Input.CLICK_RIGHT, true); return state.setInput(Input.CLICK_RIGHT, true);
} }
//System.out.println("Trying to look at " + against1 + ", actually looking at" + RayTraceUtils.getSelectedBlock()); if (ctx.playerRotations().isReallyCloseTo(rot)) {
double dist = Math.max(Math.abs(ctx.player().posX - (dest.getX() + 0.5D)), Math.abs(ctx.player().posZ - (dest.getZ() + 0.5D)));
if (dist > 0.83) {
// might need to go forward a bit
return state.setInput(Input.MOVE_FORWARD, true);
}
// don't left click for one tick
return state.setInput(Input.CLICK_LEFT, true); return state.setInput(Input.CLICK_LEFT, true);
} }
return state;
//System.out.println("Trying to look at " + against1 + ", actually looking at" + RayTraceUtils.getSelectedBlock());
}
} }
if (!Baritone.settings().assumeSafeWalk.get()) { if (!Baritone.settings().assumeSafeWalk.get()) {
state.setInput(Input.SNEAK, true); state.setInput(Input.SNEAK, true);

View File

@ -215,7 +215,7 @@ public class BuilderProcess extends BaritoneProcessHelper {
List<IBlockState> approxPlacable = placable(); List<IBlockState> approxPlacable = placable();
List<BetterBlockPos> placable = incorrectPositions.stream().filter(pos -> bcc.bsi.get0(pos).getBlock() == Blocks.AIR && approxPlacable.contains(bcc.getSchematic(pos.x, pos.y, pos.z))).collect(Collectors.toList()); List<BetterBlockPos> placable = incorrectPositions.stream().filter(pos -> bcc.bsi.get0(pos).getBlock() == Blocks.AIR && approxPlacable.contains(bcc.getSchematic(pos.x, pos.y, pos.z))).collect(Collectors.toList());
if (!placable.isEmpty()) { if (!placable.isEmpty()) {
return placable.stream().filter(pos -> !placable.contains(pos.down()) && !placable.contains(pos.down(2))).map(BetterBlockPos::up).map(GoalBlock::new).toArray(Goal[]::new); return placable.stream().filter(pos -> !placable.contains(pos.down()) && !placable.contains(pos.down(2))).map(GoalPlace::new).toArray(Goal[]::new);
} }
return incorrectPositions.stream().filter(pos -> bcc.bsi.get0(pos).getBlock() != Blocks.AIR).map(GoalBreak::new).toArray(Goal[]::new); return incorrectPositions.stream().filter(pos -> bcc.bsi.get0(pos).getBlock() != Blocks.AIR).map(GoalBreak::new).toArray(Goal[]::new);
} }
@ -229,7 +229,7 @@ public class BuilderProcess extends BaritoneProcessHelper {
@Override @Override
public boolean isInGoal(int x, int y, int z) { public boolean isInGoal(int x, int y, int z) {
// can't stand right on top of a block, that might not work (what if it's unsupported, can't break then) // can't stand right on top of a block, that might not work (what if it's unsupported, can't break then)
if (x == this.x && y == this.y + 1 && z == this.z) { if (y > this.y) {
return false; return false;
} }
// but any other adjacent works for breaking, including inside or below // but any other adjacent works for breaking, including inside or below
@ -237,6 +237,17 @@ public class BuilderProcess extends BaritoneProcessHelper {
} }
} }
public static class GoalPlace extends GoalBlock {
public GoalPlace(BlockPos placeAt) {
super(placeAt.up());
}
public double heuristic(int x, int y, int z) {
// prioritize lower y coordinates
return this.y * 100 + super.heuristic(x, y, z);
}
}
@Override @Override
public void onLostControl() { public void onLostControl() {
incorrectPositions = null; incorrectPositions = null;
@ -290,6 +301,8 @@ public class BuilderProcess extends BaritoneProcessHelper {
this.originX = schematicOrigin.getX(); this.originX = schematicOrigin.getX();
this.originY = schematicOrigin.getY(); this.originY = schematicOrigin.getY();
this.originZ = schematicOrigin.getZ(); this.originZ = schematicOrigin.getZ();
this.jumpPenalty += 10;
} }
private IBlockState getSchematic(int x, int y, int z) { private IBlockState getSchematic(int x, int y, int z) {