From 16dcd2f44d70368783aa2eac793517d8194d45f5 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 21 Feb 2019 11:25:03 -0800 Subject: [PATCH] blocks on top of chests, fixes #299 --- .../java/baritone/process/GetToBlockProcess.java | 16 +++++++++++++++- .../baritone/utils/InputOverrideHandler.java | 15 +++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/main/java/baritone/process/GetToBlockProcess.java b/src/main/java/baritone/process/GetToBlockProcess.java index 7796c029..0eb9f339 100644 --- a/src/main/java/baritone/process/GetToBlockProcess.java +++ b/src/main/java/baritone/process/GetToBlockProcess.java @@ -168,7 +168,13 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl } private Goal createGoal(BlockPos pos) { - return walkIntoInsteadOfAdjacent(gettingTo) ? new GoalTwoBlocks(pos) : new GoalGetToBlock(pos); + if (walkIntoInsteadOfAdjacent(gettingTo)) { + return new GoalTwoBlocks(pos); + } + if (blockOnTopMustBeRemoved(gettingTo) && baritone.bsi.get0(pos.up()).isBlockNormalCube()) { + return new GoalBlock(pos.up()); + } + return new GoalGetToBlock(pos); } private boolean rightClick() { @@ -203,4 +209,12 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl } return block == Blocks.CRAFTING_TABLE || block == Blocks.FURNACE || block == Blocks.ENDER_CHEST || block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST; } + + private boolean blockOnTopMustBeRemoved(Block block) { + if (!rightClickOnArrival(block)) { // only if we plan to actually open it on arrival + return false; + } + // only these chests; you can open a crafting table or furnace even with a block on top + return block == Blocks.ENDER_CHEST || block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST; + } } diff --git a/src/main/java/baritone/utils/InputOverrideHandler.java b/src/main/java/baritone/utils/InputOverrideHandler.java index f32bdaa4..f5ee0530 100755 --- a/src/main/java/baritone/utils/InputOverrideHandler.java +++ b/src/main/java/baritone/utils/InputOverrideHandler.java @@ -61,16 +61,23 @@ public final class InputOverrideHandler extends Behavior implements IInputOverri @Override public final Boolean isInputForcedDown(KeyBinding key) { Input input = Input.getInputForBind(key); - if (input == null || !inControl()) { + if (input == null) { return null; } - if (input == Input.CLICK_LEFT) { + if (input == Input.CLICK_LEFT && inControl()) { + // only override left click off when pathing return false; } if (input == Input.CLICK_RIGHT) { - return isInputForcedDown(Input.CLICK_RIGHT); + if (isInputForcedDown(Input.CLICK_RIGHT)) { + // gettoblock and builder can right click even when not pathing; allow them to do so + return true; + } else if (inControl()) { + // but when we are pathing for real, force right click off + return false; + } } - return null; + return null; // dont force any inputs other than left and right click } /**