diff --git a/src/main/java/baritone/bot/pathing/action/actions/ActionAscend.java b/src/main/java/baritone/bot/pathing/action/actions/ActionAscend.java deleted file mode 100644 index 5250016f..00000000 --- a/src/main/java/baritone/bot/pathing/action/actions/ActionAscend.java +++ /dev/null @@ -1,22 +0,0 @@ -package baritone.bot.pathing.action.actions; - -import baritone.bot.InputOverrideHandler; -import baritone.bot.pathing.action.Action; -import baritone.bot.pathing.action.ActionState; -import net.minecraft.util.math.BlockPos; - -public class ActionAscend extends Action { - - public ActionAscend(BlockPos src, BlockPos dest) { - super(src, dest); - } - - @Override - public ActionState calcState() { - ActionState latestState = currentState.setInput(InputOverrideHandler.Input.JUMP, true).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); - if (mc.player.getPosition().equals(latestState.getGoal().position)) - latestState.setStatus(ActionState.ActionStatus.SUCCESS); - return latestState; - } - -} diff --git a/src/main/java/baritone/bot/pathing/action/ActionCosts.java b/src/main/java/baritone/bot/pathing/movement/ActionCosts.java similarity index 97% rename from src/main/java/baritone/bot/pathing/action/ActionCosts.java rename to src/main/java/baritone/bot/pathing/movement/ActionCosts.java index 16e9d24d..242dd45b 100644 --- a/src/main/java/baritone/bot/pathing/action/ActionCosts.java +++ b/src/main/java/baritone/bot/pathing/movement/ActionCosts.java @@ -1,4 +1,4 @@ -package baritone.bot.pathing.action; +package baritone.bot.pathing.movement; public interface ActionCosts { /** diff --git a/src/main/java/baritone/bot/pathing/action/Action.java b/src/main/java/baritone/bot/pathing/movement/Movement.java similarity index 61% rename from src/main/java/baritone/bot/pathing/action/Action.java rename to src/main/java/baritone/bot/pathing/movement/Movement.java index 3d309730..878e14c8 100644 --- a/src/main/java/baritone/bot/pathing/action/Action.java +++ b/src/main/java/baritone/bot/pathing/movement/Movement.java @@ -1,36 +1,36 @@ -package baritone.bot.pathing.action; +package baritone.bot.pathing.movement; import baritone.bot.Baritone; import baritone.bot.event.AbstractGameEventListener; -import baritone.bot.pathing.action.ActionState.ActionStatus; +import baritone.bot.pathing.movement.MovementState.MovementStatus; import baritone.bot.utils.Helper; import baritone.bot.utils.Utils; import net.minecraft.util.Tuple; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; -public abstract class Action implements AbstractGameEventListener, Helper, ActionWorldHelper { +public abstract class Movement implements AbstractGameEventListener, Helper, MovementHelper { - protected ActionState currentState; + protected MovementState currentState; protected final BlockPos src; protected final BlockPos dest; - protected Action(BlockPos src, BlockPos dest) { + protected Movement(BlockPos src, BlockPos dest) { this(src, dest, Utils.calcCenterFromCoords(dest, mc.world)); } - protected Action(BlockPos src, BlockPos dest, Vec3d rotationTarget) { + protected Movement(BlockPos src, BlockPos dest, Vec3d rotationTarget) { this.src = src; this.dest = dest; - currentState = new ActionState() - .setGoal(new ActionState.ActionGoal(dest, rotationTarget)) - .setStatus(ActionStatus.WAITING); + currentState = new MovementState() + .setGoal(new MovementState.MovementGoal(dest, rotationTarget)) + .setStatus(MovementStatus.WAITING); } /** * Lowest denominator of the dynamic costs. - * TODO: Investigate performant ways to assign costs to action + * TODO: Investigate performant ways to assign costs to movement * * @return Cost */ @@ -40,7 +40,7 @@ public abstract class Action implements AbstractGameEventListener, Helper, Actio @Override public void onTick() { - ActionState latestState = calcState(); + MovementState latestState = calcState(); Tuple rotation = Utils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F), latestState.getGoal().rotation); mc.player.setPositionAndRotation(mc.player.posX, mc.player.posY, mc.player.posZ, @@ -55,8 +55,8 @@ public abstract class Action implements AbstractGameEventListener, Helper, Actio } public boolean isFinished() { - return (currentState.getStatus() != ActionStatus.RUNNING - && currentState.getStatus() != ActionStatus.WAITING); + return (currentState.getStatus() != MovementStatus.RUNNING + && currentState.getStatus() != MovementStatus.WAITING); } public BlockPos getSrc() { @@ -68,10 +68,10 @@ public abstract class Action implements AbstractGameEventListener, Helper, Actio } /** - * Calculate latest action state. + * Calculate latest movement state. * Gets called once a tick. * * @return */ - public abstract ActionState calcState(); + public abstract MovementState calcState(); } diff --git a/src/main/java/baritone/bot/pathing/action/ActionWorldHelper.java b/src/main/java/baritone/bot/pathing/movement/MovementHelper.java similarity index 98% rename from src/main/java/baritone/bot/pathing/action/ActionWorldHelper.java rename to src/main/java/baritone/bot/pathing/movement/MovementHelper.java index 6d9351ae..6c119b64 100644 --- a/src/main/java/baritone/bot/pathing/action/ActionWorldHelper.java +++ b/src/main/java/baritone/bot/pathing/movement/MovementHelper.java @@ -1,4 +1,4 @@ -package baritone.bot.pathing.action; +package baritone.bot.pathing.movement; import baritone.bot.utils.BlockStateInterface; import baritone.bot.utils.ToolSet; @@ -13,7 +13,7 @@ import net.minecraft.util.math.BlockPos; * * @author leijurv */ -public interface ActionWorldHelper extends ActionCosts { +public interface MovementHelper extends ActionCosts { Block waterFlowing = Block.getBlockById(8); Block waterStill = Block.getBlockById(9); Block lavaFlowing = Block.getBlockById(10); diff --git a/src/main/java/baritone/bot/pathing/action/ActionState.java b/src/main/java/baritone/bot/pathing/movement/MovementState.java similarity index 67% rename from src/main/java/baritone/bot/pathing/action/ActionState.java rename to src/main/java/baritone/bot/pathing/movement/MovementState.java index 45af036d..9a771a34 100644 --- a/src/main/java/baritone/bot/pathing/action/ActionState.java +++ b/src/main/java/baritone/bot/pathing/movement/MovementState.java @@ -1,4 +1,4 @@ -package baritone.bot.pathing.action; +package baritone.bot.pathing.movement; import baritone.bot.InputOverrideHandler.Input; import net.minecraft.util.math.BlockPos; @@ -7,22 +7,22 @@ import net.minecraft.util.math.Vec3d; import java.util.HashMap; import java.util.Map; -public class ActionState { +public class MovementState { - protected ActionStatus status; - public ActionGoal goal; + protected MovementStatus status; + public MovementGoal goal; protected final Map inputState = new HashMap<>(); - public ActionState setStatus(ActionStatus status) { + public MovementState setStatus(MovementStatus status) { this.status = status; return this; } - public ActionStatus getStatus() { + public MovementStatus getStatus() { return status; } - public static class ActionGoal { + public static class MovementGoal { /** * Necessary movement to achieve *

@@ -37,22 +37,22 @@ public class ActionState { */ public Vec3d rotation; - public ActionGoal(BlockPos position, Vec3d rotation) { + public MovementGoal(BlockPos position, Vec3d rotation) { this.position = position; this.rotation = rotation; } } - public ActionGoal getGoal() { + public MovementGoal getGoal() { return goal; } - public ActionState setGoal(ActionGoal goal) { + public MovementState setGoal(MovementGoal goal) { this.goal = goal; return this; } - public ActionState setInput(Input input, boolean forced) { + public MovementState setInput(Input input, boolean forced) { inputState.put(input, forced); return this; } @@ -61,7 +61,7 @@ public class ActionState { return inputState.getOrDefault(input, false); } - public enum ActionStatus { + public enum MovementStatus { WAITING, RUNNING, SUCCESS, UNREACHABLE, FAILED; } } diff --git a/src/main/java/baritone/bot/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/bot/pathing/movement/movements/MovementAscend.java new file mode 100644 index 00000000..5a7ea116 --- /dev/null +++ b/src/main/java/baritone/bot/pathing/movement/movements/MovementAscend.java @@ -0,0 +1,22 @@ +package baritone.bot.pathing.movement.movements; + +import baritone.bot.InputOverrideHandler; +import baritone.bot.pathing.movement.Movement; +import baritone.bot.pathing.movement.MovementState; +import net.minecraft.util.math.BlockPos; + +public class MovementAscend extends Movement { + + public MovementAscend(BlockPos src, BlockPos dest) { + super(src, dest); + } + + @Override + public MovementState calcState() { + MovementState latestState = currentState.setInput(InputOverrideHandler.Input.JUMP, true).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); + if (mc.player.getPosition().equals(latestState.getGoal().position)) + latestState.setStatus(MovementState.MovementStatus.SUCCESS); + return latestState; + } + +}