From fbb2d37634714ee99fc13f7ec3bd7e8654cf07b6 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 25 Feb 2019 18:01:11 -0800 Subject: [PATCH] allow placing against replacable blocks --- .../java/baritone/pathing/movement/MovementHelper.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 07a983a3..a3fbf041 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -40,6 +40,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; +import java.util.Optional; + import static baritone.pathing.movement.Movement.HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP; /** @@ -494,7 +496,12 @@ public interface MovementHelper extends ActionCosts, Helper { static PlaceResult attemptToPlaceABlock(MovementState state, IBaritone baritone, BlockPos placeAt, boolean preferDown) { IPlayerContext ctx = baritone.getPlayerContext(); + Optional direct = RotationUtils.reachable(ctx, placeAt); // we assume that if there is a block there, it must be replacable boolean found = false; + if (direct.isPresent()) { + state.setTarget(new MovementState.MovementTarget(direct.get(), true)); + found = true; + } for (int i = 0; i < 5; i++) { BlockPos against1 = placeAt.offset(HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i]); if (MovementHelper.canPlaceAgainst(ctx, against1)) {