Search in sources :

Example 6 with IWaypoint

use of baritone.api.cache.IWaypoint 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)

Aggregations

IWaypoint (baritone.api.cache.IWaypoint)6 CommandInvalidStateException (baritone.api.command.exception.CommandInvalidStateException)4 BetterBlockPos (baritone.api.utils.BetterBlockPos)4 IBaritone (baritone.api.IBaritone)2 Waypoint (baritone.api.cache.Waypoint)2 Command (baritone.api.command.Command)2 FORCE_COMMAND_PREFIX (baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX)2 IArgConsumer (baritone.api.command.argument.IArgConsumer)2 ForWaypoints (baritone.api.command.datatypes.ForWaypoints)2 RelativeBlockPos (baritone.api.command.datatypes.RelativeBlockPos)2 CommandException (baritone.api.command.exception.CommandException)2 CommandInvalidTypeException (baritone.api.command.exception.CommandInvalidTypeException)2 Paginator (baritone.api.command.helpers.Paginator)2 TabCompleteHelper (baritone.api.command.helpers.TabCompleteHelper)2 Goal (baritone.api.pathing.goals.Goal)2 GoalBlock (baritone.api.pathing.goals.GoalBlock)2 Path (java.nio.file.Path)2 java.util (java.util)2 BiFunction (java.util.function.BiFunction)2 Function (java.util.function.Function)2