From 583a5046ef241c26924134cc4f56bb4d987c408d Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 17 Sep 2018 12:17:42 -0500 Subject: [PATCH] Utilize the fact that all MovementState methods return "this" --- .../movement/movements/MovementDescend.java | 3 +-- .../movement/movements/MovementDownward.java | 3 +-- .../movement/movements/MovementFall.java | 3 +-- .../movement/movements/MovementPillar.java | 3 +-- .../movement/movements/MovementTraverse.java | 21 +++++++------------ 5 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index b033b6fc..99e6872b 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -76,8 +76,7 @@ public class MovementDescend extends Movement { if (playerFeet.equals(dest)) { if (BlockStateInterface.isLiquid(dest) || player().posY - playerFeet.getY() < 0.094) { // lilypads // Wait until we're actually on the ground before saying we're done because sometimes we continue to fall if the next action starts immediately - state.setStatus(MovementStatus.SUCCESS); - return state; + return state.setStatus(MovementStatus.SUCCESS); } else { System.out.println(player().posY + " " + playerFeet.getY() + " " + (player().posY - playerFeet.getY())); } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java index 48d26161..2ceb3c16 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java @@ -66,8 +66,7 @@ public class MovementDownward extends Movement { } if (playerFeet().equals(dest)) { - state.setStatus(MovementState.MovementStatus.SUCCESS); - return state; + return state.setStatus(MovementState.MovementStatus.SUCCESS); } double diffX = player().posX - (dest.getX() + 0.5); double diffZ = player().posZ - (dest.getZ() + 0.5); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index e0356444..a82826eb 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -113,8 +113,7 @@ public class MovementFall extends Movement { Rotation targetRotation = null; if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > Baritone.settings().maxFallHeightNoWater.get() && !playerFeet.equals(dest)) { if (!InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_WATER)) || world().provider.isNether()) { - state.setStatus(MovementStatus.UNREACHABLE); - return state; + return state.setStatus(MovementStatus.UNREACHABLE); } if (player().posY - dest.getY() < mc.playerController.getBlockReachDistance()) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index db5bbf49..1885f48b 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -160,8 +160,7 @@ public class MovementPillar extends Movement { } else { // Get ready to place a throwaway block if (!MovementHelper.throwaway(true)) { - state.setStatus(MovementState.MovementStatus.UNREACHABLE); - return state; + return state.setStatus(MovementState.MovementStatus.UNREACHABLE); } numTicks++; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index f28f29fb..b0efeb79 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -180,9 +180,8 @@ public class MovementTraverse extends Movement { } if (isDoorActuallyBlockingUs) { if (!(Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock()))) { - state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(positionsToBreak[0], world())), true)); - state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); - return state; + return state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(positionsToBreak[0], world())), true)) + .setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); } } } @@ -196,9 +195,8 @@ public class MovementTraverse extends Movement { } if (blocked != null) { - state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(blocked, world())), true)); - state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); - return state; + return state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(blocked, world())), true)) + .setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); } } @@ -214,8 +212,7 @@ public class MovementTraverse extends Movement { if (isTheBridgeBlockThere) { if (playerFeet().equals(dest)) { - state.setStatus(MovementState.MovementStatus.SUCCESS); - return state; + return state.setStatus(MovementState.MovementStatus.SUCCESS); } if (wasTheBridgeBlockAlwaysThere && !BlockStateInterface.isLiquid(playerFeet())) { state.setInput(InputOverrideHandler.Input.SPRINT, true); @@ -248,9 +245,8 @@ public class MovementTraverse extends Movement { double dist = Math.max(Math.abs(dest.getX() + 0.5 - player().posX), Math.abs(dest.getZ() + 0.5 - player().posZ)); if (dist < 0.85) { // 0.5 + 0.3 + epsilon MovementHelper.moveTowards(state, dest); - state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, false); - state.setInput(InputOverrideHandler.Input.MOVE_BACK, true); - return state; + return state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, false) + .setInput(InputOverrideHandler.Input.MOVE_BACK, true); } } state.setInput(InputOverrideHandler.Input.MOVE_BACK, false); @@ -290,8 +286,7 @@ public class MovementTraverse extends Movement { state.setInput(InputOverrideHandler.Input.MOVE_BACK, true); state.setInput(InputOverrideHandler.Input.SNEAK, true); if (Objects.equals(LookBehaviorUtils.getSelectedBlock().orElse(null), goalLook)) { - state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); // wait to right click until we are able to place - return state; + return state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); // wait to right click until we are able to place } // Out.log("Trying to look at " + goalLook + ", actually looking at" + Baritone.whatAreYouLookingAt()); return state.setInput(InputOverrideHandler.Input.CLICK_LEFT, true);