Search in sources :

Example 21 with CommandInvalidStateException

use of baritone.api.command.exception.CommandInvalidStateException in project baritone by cabaletta.

the class FarmCommand method execute.

@Override
public void execute(String label, IArgConsumer args) throws CommandException {
    args.requireMax(2);
    int range = 0;
    BetterBlockPos origin = null;
    // range
    if (args.has(1)) {
        range = args.getAs(Integer.class);
    }
    // waypoint
    if (args.has(1)) {
        IWaypoint[] waypoints = args.getDatatypeFor(ForWaypoints.INSTANCE);
        IWaypoint waypoint = null;
        switch(waypoints.length) {
            case 0:
                throw new CommandInvalidStateException("No waypoints found");
            case 1:
                waypoint = waypoints[0];
                break;
            default:
                throw new CommandInvalidStateException("Multiple waypoints were found");
        }
        origin = waypoint.getLocation();
    }
    baritone.getFarmProcess().farm(range, origin);
    logDirect("Farming");
}
Also used : IWaypoint(baritone.api.cache.IWaypoint) BetterBlockPos(baritone.api.utils.BetterBlockPos) CommandInvalidStateException(baritone.api.command.exception.CommandInvalidStateException) IWaypoint(baritone.api.cache.IWaypoint)

Example 22 with CommandInvalidStateException

use of baritone.api.command.exception.CommandInvalidStateException in project baritone by cabaletta.

the class InvertCommand method execute.

@Override
public void execute(String label, IArgConsumer args) throws CommandException {
    args.requireMax(0);
    ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
    Goal goal;
    if ((goal = customGoalProcess.getGoal()) == null) {
        throw new CommandInvalidStateException("No goal");
    }
    if (goal instanceof GoalInverted) {
        goal = ((GoalInverted) goal).origin;
    } else {
        goal = new GoalInverted(goal);
    }
    customGoalProcess.setGoalAndPath(goal);
    logDirect(String.format("Goal: %s", goal.toString()));
}
Also used : Goal(baritone.api.pathing.goals.Goal) ICustomGoalProcess(baritone.api.process.ICustomGoalProcess) CommandInvalidStateException(baritone.api.command.exception.CommandInvalidStateException) GoalInverted(baritone.api.pathing.goals.GoalInverted)

Aggregations

CommandInvalidStateException (baritone.api.command.exception.CommandInvalidStateException)22 BetterBlockPos (baritone.api.utils.BetterBlockPos)9 CommandInvalidTypeException (baritone.api.command.exception.CommandInvalidTypeException)7 CommandException (baritone.api.command.exception.CommandException)5 BlockPos (net.minecraft.util.math.BlockPos)5 IWaypoint (baritone.api.cache.IWaypoint)4 RelativeBlockPos (baritone.api.command.datatypes.RelativeBlockPos)4 RelativeFile (baritone.api.command.datatypes.RelativeFile)4 IPathingControlManager (baritone.api.pathing.calc.IPathingControlManager)4 Goal (baritone.api.pathing.goals.Goal)4 GoalBlock (baritone.api.pathing.goals.GoalBlock)4 IBaritoneProcess (baritone.api.process.IBaritoneProcess)4 File (java.io.File)4 ITextComponent (net.minecraft.util.text.ITextComponent)4 IBaritone (baritone.api.IBaritone)3 Command (baritone.api.command.Command)3 FORCE_COMMAND_PREFIX (baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX)3 IArgConsumer (baritone.api.command.argument.IArgConsumer)3 Paginator (baritone.api.command.helpers.Paginator)3 TabCompleteHelper (baritone.api.command.helpers.TabCompleteHelper)3