2019-10-06 20:44:37 +00:00
|
|
|
/*
|
|
|
|
* This file is part of Baritone.
|
|
|
|
*
|
|
|
|
* Baritone is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Baritone is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package baritone.command.defaults;
|
|
|
|
|
|
|
|
import baritone.api.IBaritone;
|
|
|
|
import baritone.api.command.Command;
|
2021-01-30 04:17:53 +00:00
|
|
|
import baritone.api.command.argument.IArgConsumer;
|
2019-10-06 20:44:37 +00:00
|
|
|
import baritone.api.command.datatypes.BlockById;
|
|
|
|
import baritone.api.command.datatypes.ForBlockOptionalMeta;
|
|
|
|
import baritone.api.command.datatypes.RelativeCoordinate;
|
|
|
|
import baritone.api.command.datatypes.RelativeGoal;
|
|
|
|
import baritone.api.command.exception.CommandException;
|
|
|
|
import baritone.api.pathing.goals.Goal;
|
|
|
|
import baritone.api.utils.BetterBlockPos;
|
|
|
|
import baritone.api.utils.BlockOptionalMeta;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
public class GotoCommand extends Command {
|
|
|
|
|
|
|
|
protected GotoCommand(IBaritone baritone) {
|
|
|
|
super(baritone, "goto");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void execute(String label, IArgConsumer args) throws CommandException {
|
2019-10-25 12:48:53 +00:00
|
|
|
// If we have a numeric first argument, then parse arguments as coordinates.
|
|
|
|
// Note: There is no reason to want to go where you're already at so there
|
|
|
|
// is no need to handle the case of empty arguments.
|
|
|
|
if (args.peekDatatypeOrNull(RelativeCoordinate.INSTANCE) != null) {
|
|
|
|
args.requireMax(3);
|
2019-10-06 20:44:37 +00:00
|
|
|
BetterBlockPos origin = baritone.getPlayerContext().playerFeet();
|
2019-10-25 12:48:53 +00:00
|
|
|
Goal goal = args.getDatatypePost(RelativeGoal.INSTANCE, origin);
|
2019-10-06 20:44:37 +00:00
|
|
|
logDirect(String.format("Going to: %s", goal.toString()));
|
|
|
|
baritone.getCustomGoalProcess().setGoalAndPath(goal);
|
|
|
|
return;
|
|
|
|
}
|
2019-10-06 20:49:24 +00:00
|
|
|
args.requireMax(1);
|
2019-10-06 20:44:37 +00:00
|
|
|
BlockOptionalMeta destination = args.getDatatypeFor(ForBlockOptionalMeta.INSTANCE);
|
|
|
|
baritone.getGetToBlockProcess().getToBlock(destination);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Stream<String> tabComplete(String label, IArgConsumer args) throws CommandException {
|
|
|
|
// since it's either a goal or a block, I don't think we can tab complete properly?
|
|
|
|
// so just tab complete for the block variant
|
|
|
|
return args.tabCompleteDatatype(BlockById.INSTANCE);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getShortDesc() {
|
|
|
|
return "Go to a coordinate or block";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<String> getLongDesc() {
|
|
|
|
return Arrays.asList(
|
2020-04-13 18:39:56 +00:00
|
|
|
"The goto command tells Baritone to head towards a given goal or block.",
|
2019-10-06 20:44:37 +00:00
|
|
|
"",
|
|
|
|
"Wherever a coordinate is expected, you can use ~ just like in regular Minecraft commands. Or, you can just use regular numbers.",
|
|
|
|
"",
|
|
|
|
"Usage:",
|
|
|
|
"> goto <block> - Go to a block, wherever it is in the world",
|
|
|
|
"> goto <y> - Go to a Y level",
|
|
|
|
"> goto <x> <z> - Go to an X,Z position",
|
|
|
|
"> goto <x> <y> <z> - Go to an X,Y,Z position"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|