From 13505a052f88c8edc04a532ab3d161f9907b0e85 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 9 Nov 2018 15:59:03 -0800 Subject: [PATCH] wait a tick until objectMouseOver matches, fixes #254 --- .../java/baritone/pathing/movement/Movement.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 31dd952b..6d9f5487 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -20,10 +20,7 @@ package baritone.pathing.movement; import baritone.Baritone; import baritone.api.pathing.movement.IMovement; import baritone.api.pathing.movement.MovementStatus; -import baritone.api.utils.BetterBlockPos; -import baritone.api.utils.Rotation; -import baritone.api.utils.RotationUtils; -import baritone.api.utils.VecUtils; +import baritone.api.utils.*; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import baritone.utils.InputOverrideHandler; @@ -34,6 +31,7 @@ import net.minecraft.world.chunk.EmptyChunk; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.Optional; import static baritone.utils.InputOverrideHandler.Input; @@ -154,7 +152,10 @@ public abstract class Movement implements IMovement, Helper, MovementHelper { Optional reachable = RotationUtils.reachable(player(), blockPos); if (reachable.isPresent()) { MovementHelper.switchToBestToolFor(BlockStateInterface.get(blockPos)); - state.setTarget(new MovementState.MovementTarget(reachable.get(), true)).setInput(Input.CLICK_LEFT, true); + state.setTarget(new MovementState.MovementTarget(reachable.get(), true)); + if (Objects.equals(RayTraceUtils.getSelectedBlock().orElse(null), blockPos)) { + state.setInput(Input.CLICK_LEFT, true); + } return false; } //get rekt minecraft @@ -163,7 +164,9 @@ public abstract class Movement implements IMovement, Helper, MovementHelper { //you dont own me!!!! state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(player().getPositionEyes(1.0F), VecUtils.getBlockPosCenter(blockPos)), true) - ).setInput(InputOverrideHandler.Input.CLICK_LEFT, true); + ); + // don't check selectedblock on this one, this is a fallback when we can't see any face directly, it's intended to be breaking the "incorrect" block + state.setInput(InputOverrideHandler.Input.CLICK_LEFT, true); return false; } }