Updated movement naming
This commit is contained in:
parent
7eae7a86b5
commit
49cc61d2ca
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package baritone.bot.pathing.action;
|
package baritone.bot.pathing.movement;
|
||||||
|
|
||||||
public interface ActionCosts {
|
public interface ActionCosts {
|
||||||
/**
|
/**
|
@ -1,36 +1,36 @@
|
|||||||
package baritone.bot.pathing.action;
|
package baritone.bot.pathing.movement;
|
||||||
|
|
||||||
import baritone.bot.Baritone;
|
import baritone.bot.Baritone;
|
||||||
import baritone.bot.event.AbstractGameEventListener;
|
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.Helper;
|
||||||
import baritone.bot.utils.Utils;
|
import baritone.bot.utils.Utils;
|
||||||
import net.minecraft.util.Tuple;
|
import net.minecraft.util.Tuple;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
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 src;
|
||||||
protected final BlockPos dest;
|
protected final BlockPos dest;
|
||||||
|
|
||||||
protected Action(BlockPos src, BlockPos dest) {
|
protected Movement(BlockPos src, BlockPos dest) {
|
||||||
this(src, dest, Utils.calcCenterFromCoords(dest, mc.world));
|
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.src = src;
|
||||||
this.dest = dest;
|
this.dest = dest;
|
||||||
currentState = new ActionState()
|
currentState = new MovementState()
|
||||||
.setGoal(new ActionState.ActionGoal(dest, rotationTarget))
|
.setGoal(new MovementState.MovementGoal(dest, rotationTarget))
|
||||||
.setStatus(ActionStatus.WAITING);
|
.setStatus(MovementStatus.WAITING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lowest denominator of the dynamic costs.
|
* 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
|
* @return Cost
|
||||||
*/
|
*/
|
||||||
@ -40,7 +40,7 @@ public abstract class Action implements AbstractGameEventListener, Helper, Actio
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTick() {
|
public void onTick() {
|
||||||
ActionState latestState = calcState();
|
MovementState latestState = calcState();
|
||||||
Tuple<Float, Float> rotation = Utils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F),
|
Tuple<Float, Float> rotation = Utils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F),
|
||||||
latestState.getGoal().rotation);
|
latestState.getGoal().rotation);
|
||||||
mc.player.setPositionAndRotation(mc.player.posX, mc.player.posY, mc.player.posZ,
|
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() {
|
public boolean isFinished() {
|
||||||
return (currentState.getStatus() != ActionStatus.RUNNING
|
return (currentState.getStatus() != MovementStatus.RUNNING
|
||||||
&& currentState.getStatus() != ActionStatus.WAITING);
|
&& currentState.getStatus() != MovementStatus.WAITING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockPos getSrc() {
|
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.
|
* Gets called once a tick.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public abstract ActionState calcState();
|
public abstract MovementState calcState();
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package baritone.bot.pathing.action;
|
package baritone.bot.pathing.movement;
|
||||||
|
|
||||||
import baritone.bot.utils.BlockStateInterface;
|
import baritone.bot.utils.BlockStateInterface;
|
||||||
import baritone.bot.utils.ToolSet;
|
import baritone.bot.utils.ToolSet;
|
||||||
@ -13,7 +13,7 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
*
|
*
|
||||||
* @author leijurv
|
* @author leijurv
|
||||||
*/
|
*/
|
||||||
public interface ActionWorldHelper extends ActionCosts {
|
public interface MovementHelper extends ActionCosts {
|
||||||
Block waterFlowing = Block.getBlockById(8);
|
Block waterFlowing = Block.getBlockById(8);
|
||||||
Block waterStill = Block.getBlockById(9);
|
Block waterStill = Block.getBlockById(9);
|
||||||
Block lavaFlowing = Block.getBlockById(10);
|
Block lavaFlowing = Block.getBlockById(10);
|
@ -1,4 +1,4 @@
|
|||||||
package baritone.bot.pathing.action;
|
package baritone.bot.pathing.movement;
|
||||||
|
|
||||||
import baritone.bot.InputOverrideHandler.Input;
|
import baritone.bot.InputOverrideHandler.Input;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@ -7,22 +7,22 @@ import net.minecraft.util.math.Vec3d;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class ActionState {
|
public class MovementState {
|
||||||
|
|
||||||
protected ActionStatus status;
|
protected MovementStatus status;
|
||||||
public ActionGoal goal;
|
public MovementGoal goal;
|
||||||
protected final Map<Input, Boolean> inputState = new HashMap<>();
|
protected final Map<Input, Boolean> inputState = new HashMap<>();
|
||||||
|
|
||||||
public ActionState setStatus(ActionStatus status) {
|
public MovementState setStatus(MovementStatus status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionStatus getStatus() {
|
public MovementStatus getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ActionGoal {
|
public static class MovementGoal {
|
||||||
/**
|
/**
|
||||||
* Necessary movement to achieve
|
* Necessary movement to achieve
|
||||||
* <p>
|
* <p>
|
||||||
@ -37,22 +37,22 @@ public class ActionState {
|
|||||||
*/
|
*/
|
||||||
public Vec3d rotation;
|
public Vec3d rotation;
|
||||||
|
|
||||||
public ActionGoal(BlockPos position, Vec3d rotation) {
|
public MovementGoal(BlockPos position, Vec3d rotation) {
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.rotation = rotation;
|
this.rotation = rotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionGoal getGoal() {
|
public MovementGoal getGoal() {
|
||||||
return goal;
|
return goal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionState setGoal(ActionGoal goal) {
|
public MovementState setGoal(MovementGoal goal) {
|
||||||
this.goal = goal;
|
this.goal = goal;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionState setInput(Input input, boolean forced) {
|
public MovementState setInput(Input input, boolean forced) {
|
||||||
inputState.put(input, forced);
|
inputState.put(input, forced);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ public class ActionState {
|
|||||||
return inputState.getOrDefault(input, false);
|
return inputState.getOrDefault(input, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ActionStatus {
|
public enum MovementStatus {
|
||||||
WAITING, RUNNING, SUCCESS, UNREACHABLE, FAILED;
|
WAITING, RUNNING, SUCCESS, UNREACHABLE, FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user