From 9f803bc1856ba899bf58b1684e950718a2327024 Mon Sep 17 00:00:00 2001 From: Howard Stark Date: Wed, 8 Aug 2018 15:54:20 -0700 Subject: [PATCH] Fix target rotation logic --- .../movement/movements/MovementFall.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/java/baritone/bot/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/bot/pathing/movement/movements/MovementFall.java index aedab851..c3b4c587 100644 --- a/src/main/java/baritone/bot/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/bot/pathing/movement/movements/MovementFall.java @@ -30,6 +30,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; +import java.util.Optional; + public class MovementFall extends Movement { private static final ItemStack STACK_BUCKET_WATER = new ItemStack(Items.WATER_BUCKET); @@ -68,22 +70,24 @@ public class MovementFall extends Movement { state.setStatus(MovementStatus.RUNNING); case RUNNING: BlockPos playerFeet = playerFeet(); - if (!BlockStateInterface.isWater(dest) && playerFeet().getY() - dest.getY() > 3) { + Optional targetRotation = Optional.empty(); + if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > 3 && !playerFeet.equals(dest)) { if (!player().inventory.hasItemStack(STACK_BUCKET_WATER) || world().provider.isNether()) { state.setStatus(MovementStatus.UNREACHABLE); return state; + } else if (playerFeet().getY() - dest.getY() < mc.playerController.getBlockReachDistance()) { + player().inventory.currentItem = player().inventory.getSlotFor(STACK_BUCKET_WATER); + targetRotation = LookBehaviorUtils.reachable(dest.down()); } - player().inventory.currentItem = player().inventory.getSlotFor(STACK_BUCKET_WATER); - LookBehaviorUtils.reachable(dest).ifPresent(rotation -> - state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true) - .setTarget(new MovementTarget(rotation)) - ); - } else { - Rotation rotationToBlock = Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(dest, world())); - state.setTarget(new MovementTarget(rotationToBlock)); } + if(targetRotation.isPresent()) + state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true) + .setTarget(new MovementTarget(targetRotation.get())); + else + state.setTarget(new MovementTarget(Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(dest, world())))); + if (playerFeet.equals(dest) && (player().posY - playerFeet.getY() < 0.01 - || (BlockStateInterface.isWater(dest)))) { + || BlockStateInterface.isWater(dest))) { if (BlockStateInterface.isWater(dest) && player().inventory.hasItemStack(STACK_BUCKET_AIR)) { return state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); }