From 471c170884386b7ce79aef441090e83d2fff4add Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 2 Aug 2018 14:12:56 -0400 Subject: [PATCH] implement getSrc and getDest --- .../baritone/bot/pathing/action/Action.java | 21 ++++++++----------- .../bot/pathing/action/ActionState.java | 5 +++-- .../pathing/action/actions/ActionAscend.java | 8 +++---- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/main/java/baritone/bot/pathing/action/Action.java b/src/main/java/baritone/bot/pathing/action/Action.java index 56da0396..4a6c9309 100644 --- a/src/main/java/baritone/bot/pathing/action/Action.java +++ b/src/main/java/baritone/bot/pathing/action/Action.java @@ -12,20 +12,17 @@ import net.minecraft.util.math.Vec3d; public abstract class Action implements AbstractGameEventListener, Helper, ActionWorldHelper { protected ActionState currentState; + protected final BlockPos src; + protected final BlockPos dest; - public Action(BlockPos dest) { - this(Utils.calcCenterFromCoords(dest, mc.world)); + protected Action(BlockPos src, BlockPos dest) { + this(src, dest, Utils.calcCenterFromCoords(dest, mc.world)); } - public Action(Vec3d dest) { - this(dest, dest); - } - public Action(BlockPos dest, Vec3d rotationTarget) { - this(Utils.calcCenterFromCoords(dest, mc.world), rotationTarget); - } - - public Action(Vec3d dest, Vec3d rotationTarget) { + protected Action(BlockPos src, BlockPos dest, Vec3d rotationTarget) { + this.src = src; + this.dest = dest; currentState = new ActionState() .setGoal(new ActionState.ActionGoal(dest, rotationTarget)) .setStatus(ActionStatus.WAITING); @@ -63,11 +60,11 @@ public abstract class Action implements AbstractGameEventListener, Helper, Actio } public BlockPos getSrc() { - return null; // TODO + return src; } public BlockPos getDest() { - return null; // TODO + return dest; } /** diff --git a/src/main/java/baritone/bot/pathing/action/ActionState.java b/src/main/java/baritone/bot/pathing/action/ActionState.java index 996e0211..45af036d 100644 --- a/src/main/java/baritone/bot/pathing/action/ActionState.java +++ b/src/main/java/baritone/bot/pathing/action/ActionState.java @@ -1,6 +1,7 @@ package baritone.bot.pathing.action; import baritone.bot.InputOverrideHandler.Input; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import java.util.HashMap; @@ -27,7 +28,7 @@ public class ActionState { *

* TODO: Decide desiredMovement type */ - public Vec3d position; + public BlockPos position; /** * Yaw and pitch angles that must be matched *

@@ -36,7 +37,7 @@ public class ActionState { */ public Vec3d rotation; - public ActionGoal(Vec3d position, Vec3d rotation) { + public ActionGoal(BlockPos position, Vec3d rotation) { this.position = position; this.rotation = rotation; } diff --git a/src/main/java/baritone/bot/pathing/action/actions/ActionAscend.java b/src/main/java/baritone/bot/pathing/action/actions/ActionAscend.java index 7c5cd0f6..5250016f 100644 --- a/src/main/java/baritone/bot/pathing/action/actions/ActionAscend.java +++ b/src/main/java/baritone/bot/pathing/action/actions/ActionAscend.java @@ -7,14 +7,14 @@ import net.minecraft.util.math.BlockPos; public class ActionAscend extends Action { - public ActionAscend(BlockPos dest) { - super(dest); + 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)) + 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; }