diff --git a/src/main/java/baritone/bot/pathing/movement/Movement.java b/src/main/java/baritone/bot/pathing/movement/Movement.java index 71d7122a..1f491d7b 100644 --- a/src/main/java/baritone/bot/pathing/movement/Movement.java +++ b/src/main/java/baritone/bot/pathing/movement/Movement.java @@ -1,13 +1,11 @@ package baritone.bot.pathing.movement; import baritone.bot.Baritone; +import baritone.bot.InputOverrideHandler; import baritone.bot.behavior.impl.LookBehavior; import baritone.bot.behavior.impl.LookBehaviorUtils; import baritone.bot.pathing.movement.MovementState.MovementStatus; -import baritone.bot.utils.BlockStateInterface; -import baritone.bot.utils.Helper; -import baritone.bot.utils.Rotation; -import baritone.bot.utils.ToolSet; +import baritone.bot.utils.*; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -178,4 +176,8 @@ public abstract class Movement implements Helper, MovementHelper { toPlaceCached = result; return result; } + + protected void moveTowards(BlockPos pos) { + currentState.setTarget(new MovementState.MovementTarget(new Rotation(Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(pos, world())).getFirst(), player().rotationPitch))).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); + } } diff --git a/src/main/java/baritone/bot/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/bot/pathing/movement/movements/MovementAscend.java index a1bdd772..7337878e 100644 --- a/src/main/java/baritone/bot/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/bot/pathing/movement/movements/MovementAscend.java @@ -6,9 +6,7 @@ import baritone.bot.pathing.movement.MovementHelper; import baritone.bot.pathing.movement.MovementState; import baritone.bot.pathing.movement.MovementState.MovementStatus; import baritone.bot.utils.BlockStateInterface; -import baritone.bot.utils.Rotation; import baritone.bot.utils.ToolSet; -import baritone.bot.utils.Utils; import net.minecraft.block.BlockFalling; import net.minecraft.util.math.BlockPos; @@ -80,9 +78,8 @@ public class MovementAscend extends Movement { state.setStatus(MovementStatus.SUCCESS); return state; } - Rotation rotationToBlock = Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(positionsToBreak[0], world())); - return state.setTarget(new MovementState.MovementTarget(rotationToBlock)) - .setInput(InputOverrideHandler.Input.JUMP, true).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); + moveTowards(positionsToBreak[0]); + return state.setInput(InputOverrideHandler.Input.JUMP, true); default: return state; } diff --git a/src/main/java/baritone/bot/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/bot/pathing/movement/movements/MovementDescend.java index 1128252a..0dd09040 100644 --- a/src/main/java/baritone/bot/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/bot/pathing/movement/movements/MovementDescend.java @@ -1,14 +1,11 @@ package baritone.bot.pathing.movement.movements; -import baritone.bot.InputOverrideHandler; import baritone.bot.pathing.movement.Movement; import baritone.bot.pathing.movement.MovementHelper; import baritone.bot.pathing.movement.MovementState; import baritone.bot.pathing.movement.MovementState.MovementStatus; import baritone.bot.utils.BlockStateInterface; -import baritone.bot.utils.Rotation; import baritone.bot.utils.ToolSet; -import baritone.bot.utils.Utils; import net.minecraft.block.Block; import net.minecraft.block.BlockLadder; import net.minecraft.block.BlockVine; @@ -50,8 +47,8 @@ public class MovementDescend extends Movement { state.setStatus(MovementStatus.SUCCESS); return state; } - Rotation rotationToBlock = Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(positionsToBreak[1], world())); - return state.setTarget(new MovementState.MovementTarget(rotationToBlock)).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); + moveTowards(positionsToBreak[1]); + return state; default: return state; } diff --git a/src/main/java/baritone/bot/pathing/movement/movements/MovementDownward.java b/src/main/java/baritone/bot/pathing/movement/movements/MovementDownward.java index b0bdc371..43b4315c 100644 --- a/src/main/java/baritone/bot/pathing/movement/movements/MovementDownward.java +++ b/src/main/java/baritone/bot/pathing/movement/movements/MovementDownward.java @@ -1,13 +1,10 @@ package baritone.bot.pathing.movement.movements; -import baritone.bot.InputOverrideHandler; import baritone.bot.pathing.movement.Movement; import baritone.bot.pathing.movement.MovementHelper; import baritone.bot.pathing.movement.MovementState; import baritone.bot.utils.BlockStateInterface; -import baritone.bot.utils.Rotation; import baritone.bot.utils.ToolSet; -import baritone.bot.utils.Utils; import net.minecraft.block.Block; import net.minecraft.block.BlockLadder; import net.minecraft.block.BlockVine; @@ -38,8 +35,8 @@ public class MovementDownward extends Movement { if (numTicks++ < 10) { return state; } - Rotation rotationToBlock = Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(positionsToBreak[0], world())); - return state.setTarget(new MovementState.MovementTarget(rotationToBlock)).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); + moveTowards(positionsToBreak[0]); + return state; default: return state; } diff --git a/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java index 3d5b3e49..268f0044 100644 --- a/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java @@ -6,7 +6,6 @@ import baritone.bot.pathing.movement.Movement; import baritone.bot.pathing.movement.MovementHelper; import baritone.bot.pathing.movement.MovementState; import baritone.bot.utils.BlockStateInterface; -import baritone.bot.utils.Rotation; import baritone.bot.utils.ToolSet; import baritone.bot.utils.Utils; import net.minecraft.block.Block; @@ -118,8 +117,8 @@ public class MovementTraverse extends Movement { if (wasTheBridgeBlockAlwaysThere) { player().setSprinting(true); } - Rotation rotationToBlock = Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(positionsToBreak[0], world())); - return state.setTarget(new MovementState.MovementTarget(rotationToBlock)).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); + moveTowards(positionsToBreak[0]); + return state; } else { wasTheBridgeBlockAlwaysThere = false; for (BlockPos against1 : against) { @@ -170,8 +169,8 @@ public class MovementTraverse extends Movement { //Out.log("Trying to look at " + goalLook + ", actually looking at" + Baritone.whatAreYouLookingAt()); return state; } else { - Rotation rotationToBlock = Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(positionsToBreak[0], world())); - return state.setTarget(new MovementState.MovementTarget(rotationToBlock)).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); + moveTowards(positionsToBreak[0]); + return state; //TODO MovementManager.moveTowardsBlock(to);//move towards not look at because if we are bridging for a couple blocks in a row, it is faster if we dont spin around and walk forwards then spin around and place backwards for every block } }