move default commands to main module
This commit is contained in:
@@ -24,12 +24,14 @@ import baritone.api.event.listener.IEventBus;
|
||||
import baritone.api.utils.command.BaritoneChatControl;
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import baritone.api.utils.command.manager.CommandManager;
|
||||
import baritone.behavior.*;
|
||||
import baritone.cache.WorldProvider;
|
||||
import baritone.event.GameEventHandler;
|
||||
import baritone.process.*;
|
||||
import baritone.selection.SelectionManager;
|
||||
import baritone.utils.*;
|
||||
import baritone.utils.command.defaults.DefaultCommands;
|
||||
import baritone.utils.player.PrimaryPlayerContext;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
@@ -111,6 +113,8 @@ public class Baritone implements IBaritone {
|
||||
memoryBehavior = new MemoryBehavior(this);
|
||||
inventoryBehavior = new InventoryBehavior(this);
|
||||
inputOverrideHandler = new InputOverrideHandler(this);
|
||||
|
||||
DefaultCommands.commands.forEach(CommandManager.REGISTRY::register);
|
||||
new BaritoneChatControl(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalAxis;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class AxisCommand extends Command {
|
||||
public AxisCommand() {
|
||||
super(asList("axis", "highway"), "Set a goal to the axes");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(0);
|
||||
Goal goal = new GoalAxis();
|
||||
baritone.getCustomGoalProcess().setGoal(goal);
|
||||
logDirect(String.format("Goal: %s", goal.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"The axis command sets a goal that tells Baritone to head towards the nearest axis. That is, X=0 or Z=0.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> axis"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.process.IGetToBlockProcess;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class BlacklistCommand extends Command {
|
||||
public BlacklistCommand() {
|
||||
super("blacklist", "Blacklist closest block");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(0);
|
||||
IGetToBlockProcess proc = baritone.getGetToBlockProcess();
|
||||
|
||||
if (!proc.isActive()) {
|
||||
throw new CommandInvalidStateException("GetToBlockProcess is not currently active");
|
||||
}
|
||||
|
||||
if (proc.blacklistClosest()) {
|
||||
logDirect("Blacklisted closest instances");
|
||||
} else {
|
||||
throw new CommandInvalidStateException("No known locations, unable to blacklist");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"While, for example, mining, this command blacklists the closest block so that Baritone won't attempt to get to it.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> blacklist"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.RelativeBlockPos;
|
||||
import baritone.api.utils.command.datatypes.RelativeFile;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class BuildCommand extends Command {
|
||||
private static final File schematicsDir = new File(Minecraft.getMinecraft().gameDir, "schematics");
|
||||
|
||||
public BuildCommand() {
|
||||
super("build", "Build a schematic");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
File file = args.getDatatypePost(RelativeFile.class, schematicsDir).getAbsoluteFile();
|
||||
|
||||
if (!file.getName().toLowerCase(Locale.US).endsWith(".schematic")) {
|
||||
file = new File(file.getAbsolutePath() + ".schematic");
|
||||
}
|
||||
|
||||
BetterBlockPos origin = ctx.playerFeet();
|
||||
BetterBlockPos buildOrigin;
|
||||
|
||||
if (args.has()) {
|
||||
args.requireMax(3);
|
||||
buildOrigin = args.getDatatype(RelativeBlockPos.class).apply(origin);
|
||||
} else {
|
||||
args.requireMax(0);
|
||||
buildOrigin = origin;
|
||||
}
|
||||
|
||||
boolean success = baritone.getBuilderProcess().build(file.getName(), file, buildOrigin);
|
||||
|
||||
if (!success) {
|
||||
throw new CommandInvalidStateException("Couldn't load the schematic");
|
||||
}
|
||||
|
||||
logDirect(String.format("Successfully loaded schematic for building\nOrigin: %s", buildOrigin));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
if (args.hasExactlyOne()) {
|
||||
return RelativeFile.tabComplete(args, schematicsDir);
|
||||
} else if (args.has(2)) {
|
||||
args.get();
|
||||
|
||||
return args.tabCompleteDatatype(RelativeBlockPos.class);
|
||||
}
|
||||
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"Build a schematic from a file.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> build <filename> - Loads and builds '<filename>.schematic'",
|
||||
"> build <filename> <x> <y> <z> - Custom position"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class CancelCommand extends Command {
|
||||
public CancelCommand() {
|
||||
super(asList("cancel", "stop"), "Cancel what Baritone is currently doing");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(0);
|
||||
baritone.getPathingBehavior().cancelEverything();
|
||||
logDirect("ok canceled");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"The cancel command tells Baritons to stop whatever it's currently doing.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> cancel"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.cache.IRememberedInventory;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class ChestsCommand extends Command {
|
||||
public ChestsCommand() {
|
||||
super("chests", "Display remembered inventories");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(0);
|
||||
Set<Map.Entry<BlockPos, IRememberedInventory>> entries =
|
||||
ctx.worldData().getContainerMemory().getRememberedInventories().entrySet();
|
||||
|
||||
if (entries.isEmpty()) {
|
||||
throw new CommandInvalidStateException("No remembered inventories");
|
||||
}
|
||||
|
||||
for (Map.Entry<BlockPos, IRememberedInventory> entry : entries) {
|
||||
// betterblockpos has censoring
|
||||
BetterBlockPos pos = new BetterBlockPos(entry.getKey());
|
||||
IRememberedInventory inv = entry.getValue();
|
||||
|
||||
logDirect(pos.toString());
|
||||
|
||||
for (ItemStack item : inv.getContents()) {
|
||||
ITextComponent component = item.getTextComponent();
|
||||
component.appendText(String.format(" x %d", item.getCount()));
|
||||
logDirect(component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"The chests command lists remembered inventories, I guess?",
|
||||
"",
|
||||
"Usage:",
|
||||
"> chests"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.RelativeBlockPos;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class ClearareaCommand extends Command {
|
||||
public ClearareaCommand() {
|
||||
super("cleararea", "Clear an area of all blocks");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
BetterBlockPos pos1 = ctx.playerFeet();
|
||||
BetterBlockPos pos2;
|
||||
|
||||
if (args.has()) {
|
||||
args.requireMax(3);
|
||||
pos2 = args.getDatatype(RelativeBlockPos.class).apply(pos1);
|
||||
} else {
|
||||
args.requireMax(0);
|
||||
|
||||
Goal goal = baritone.getCustomGoalProcess().getGoal();
|
||||
|
||||
if (!(goal instanceof GoalBlock)) {
|
||||
throw new CommandInvalidStateException("Goal is not a GoalBlock");
|
||||
} else {
|
||||
pos2 = new BetterBlockPos(((GoalBlock) goal).getGoalPos());
|
||||
}
|
||||
}
|
||||
|
||||
baritone.getBuilderProcess().clearArea(pos1, pos2);
|
||||
logDirect("Success");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return args.tabCompleteDatatype(RelativeBlockPos.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"Clear an area of all blocks.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> cleararea - Clears the area marked by your current position and the current GoalBlock",
|
||||
"> cleararea <x> <y> <z> - Custom second corner rather than your goal"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class ClickCommand extends Command {
|
||||
public ClickCommand() {
|
||||
super("click", "Open click");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(0);
|
||||
baritone.openClick();
|
||||
logDirect("aight dude");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"Opens click dude",
|
||||
"",
|
||||
"Usage:",
|
||||
"> click"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Objects.isNull;
|
||||
|
||||
public class ComeCommand extends Command {
|
||||
public ComeCommand() {
|
||||
super("come", "Start heading towards your camera");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(0);
|
||||
Entity entity = MC.getRenderViewEntity();
|
||||
|
||||
if (isNull(entity)) {
|
||||
throw new CommandInvalidStateException("render view entity is null");
|
||||
}
|
||||
|
||||
baritone.getCustomGoalProcess().setGoalAndPath(new GoalBlock(new BlockPos(entity)));
|
||||
logDirect("Coming");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"The come command tells Baritone to head towards your camera.",
|
||||
"",
|
||||
"I'm... not actually sure how useful this is, to be honest.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> come"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import baritone.api.utils.command.manager.CommandManager;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class CommandAlias extends Command {
|
||||
public final String target;
|
||||
|
||||
public CommandAlias(List<String> names, String shortDesc, String target) {
|
||||
super(names, shortDesc);
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public CommandAlias(String name, String shortDesc, String target) {
|
||||
super(name, shortDesc);
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
CommandManager.execute(String.format("%s %s", target, args.rawRest()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return CommandManager.tabComplete(String.format("%s %s", target, args.rawRest()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return Collections.singletonList(String.format("This command is an alias, for: %s ...", target));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.manager.CommandManager;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class DefaultCommands {
|
||||
public static final List<Command> commands = Collections.unmodifiableList(asList(
|
||||
new HelpCommand(),
|
||||
new SetCommand(),
|
||||
new CommandAlias(asList("modified", "mod", "baritone", "modifiedsettings"), "List modified settings", "set modified"),
|
||||
new CommandAlias("reset", "Reset all settings or just one", "set reset"),
|
||||
new GoalCommand(),
|
||||
new PathCommand(),
|
||||
new ProcCommand(),
|
||||
new VersionCommand(),
|
||||
new RepackCommand(),
|
||||
new BuildCommand(),
|
||||
new SchematicaCommand(),
|
||||
new ComeCommand(),
|
||||
new AxisCommand(),
|
||||
new CancelCommand(),
|
||||
new ForceCancelCommand(),
|
||||
new GcCommand(),
|
||||
new InvertCommand(),
|
||||
new ClearareaCommand(),
|
||||
PauseResumeCommands.pauseCommand,
|
||||
PauseResumeCommands.resumeCommand,
|
||||
PauseResumeCommands.pausedCommand,
|
||||
new TunnelCommand(),
|
||||
new RenderCommand(),
|
||||
new FarmCommand(),
|
||||
new ChestsCommand(),
|
||||
new FollowCommand(),
|
||||
new ExploreFilterCommand(),
|
||||
new ReloadAllCommand(),
|
||||
new SaveAllCommand(),
|
||||
new ExploreCommand(),
|
||||
new BlacklistCommand(),
|
||||
new FindCommand(),
|
||||
new MineCommand(),
|
||||
new ClickCommand(),
|
||||
new ThisWayCommand(),
|
||||
new WaypointsCommand(),
|
||||
new CommandAlias("sethome", "Sets your home waypoint", "waypoints save home"),
|
||||
new CommandAlias("home", "Set goal to your home waypoint", "waypoints goal home"),
|
||||
new SelCommand()
|
||||
));
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class EmptyCommand extends Command {
|
||||
public EmptyCommand() {
|
||||
super(asList("name1", "name2"), "Short description");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"",
|
||||
"",
|
||||
"Usage:",
|
||||
"> "
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.RelativeGoalXZ;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class ExploreCommand extends Command {
|
||||
public ExploreCommand() {
|
||||
super("explore", "Explore things");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
if (args.has()) {
|
||||
args.requireExactly(2);
|
||||
} else {
|
||||
args.requireMax(0);
|
||||
}
|
||||
|
||||
GoalXZ goal = args.has()
|
||||
? args.getDatatypePost(RelativeGoalXZ.class, ctx.playerFeet())
|
||||
: new GoalXZ(ctx.playerFeet());
|
||||
|
||||
baritone.getExploreProcess().explore(goal.getX(), goal.getZ());
|
||||
logDirect(String.format("Exploring from %s", goal.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
if (args.hasAtMost(2)) {
|
||||
return args.tabCompleteDatatype(RelativeGoalXZ.class);
|
||||
}
|
||||
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"Tell Baritone to explore randomly. If you used explorefilter before this, it will be applied.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> explore - Explore from your current position.",
|
||||
"> explore <x> <z> - Explore from the specified X and Z position."
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.RelativeFile;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class ExploreFilterCommand extends Command {
|
||||
public ExploreFilterCommand() {
|
||||
super("explorefilter", "Explore chunks from a json");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(2);
|
||||
File file = args.getDatatypePost(RelativeFile.class, MC.gameDir.getAbsoluteFile().getParentFile());
|
||||
boolean invert = false;
|
||||
|
||||
if (args.has()) {
|
||||
if (args.getString().equalsIgnoreCase("invert")) {
|
||||
invert = true;
|
||||
} else {
|
||||
throw new CommandInvalidTypeException(args.consumed(), "either \"invert\" or nothing");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
baritone.getExploreProcess().applyJsonFilter(file.toPath().toAbsolutePath(), invert);
|
||||
} catch (NoSuchFileException e) {
|
||||
throw new CommandInvalidStateException("File not found");
|
||||
} catch (JsonSyntaxException e) {
|
||||
throw new CommandInvalidStateException("Invalid JSON syntax");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
logDirect(String.format("Explore filter applied. Inverted: %s", Boolean.toString(invert)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
if (args.hasExactlyOne()) {
|
||||
return RelativeFile.tabComplete(args, RelativeFile.gameDir());
|
||||
}
|
||||
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"Apply an explore filter before using explore, which tells the explore process which chunks have been explored/not explored.",
|
||||
"",
|
||||
"The JSON file will follow this format: [{\"x\":0,\"z\":0},...]",
|
||||
"",
|
||||
"If 'invert' is specified, the chunks listed will be considered NOT explored, rather than explored.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> explorefilter <path> [invert] - Load the JSON file referenced by the specified path. If invert is specified, it must be the literal word 'invert'."
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class FarmCommand extends Command {
|
||||
public FarmCommand() {
|
||||
super("farm", "Farm nearby crops");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(0);
|
||||
baritone.getFarmProcess().farm();
|
||||
logDirect("Farming");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"The farm command starts farming nearby plants. It harvests mature crops and plants new ones.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> farm"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.BlockById;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class FindCommand extends Command {
|
||||
public FindCommand() {
|
||||
super("find", "Find positions of a certain block");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
List<Block> toFind = new ArrayList<>();
|
||||
|
||||
while (args.has()) {
|
||||
toFind.add(args.getDatatypeFor(BlockById.class));
|
||||
}
|
||||
|
||||
BetterBlockPos origin = ctx.playerFeet();
|
||||
|
||||
toFind.stream()
|
||||
.flatMap(block ->
|
||||
ctx.worldData().getCachedWorld().getLocationsOf(
|
||||
Block.REGISTRY.getNameForObject(block).getPath(),
|
||||
Integer.MAX_VALUE,
|
||||
origin.x,
|
||||
origin.y,
|
||||
4
|
||||
).stream()
|
||||
)
|
||||
.map(BetterBlockPos::new)
|
||||
.map(BetterBlockPos::toString)
|
||||
.forEach(this::logDirect);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return args.tabCompleteDatatype(BlockById.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"",
|
||||
"",
|
||||
"Usage:",
|
||||
"> "
|
||||
);
|
||||
}
|
||||
}
|
||||
170
src/main/java/baritone/utils/command/defaults/FollowCommand.java
Normal file
170
src/main/java/baritone/utils/command/defaults/FollowCommand.java
Normal file
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.EntityClassById;
|
||||
import baritone.api.utils.command.datatypes.IDatatype;
|
||||
import baritone.api.utils.command.datatypes.IDatatypeFor;
|
||||
import baritone.api.utils.command.datatypes.PlayerByUsername;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Objects.isNull;
|
||||
import static java.util.Objects.nonNull;
|
||||
|
||||
public class FollowCommand extends Command {
|
||||
public FollowCommand() {
|
||||
super("follow", "Follow entity things");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMin(1);
|
||||
|
||||
FollowGroup group;
|
||||
FollowList list;
|
||||
List<Entity> entities = new ArrayList<>();
|
||||
List<Class<? extends Entity>> classes = new ArrayList<>();
|
||||
|
||||
if (args.hasExactlyOne()) {
|
||||
baritone.getFollowProcess().follow((group = args.getEnum(FollowGroup.class)).filter);
|
||||
} else {
|
||||
args.requireMin(2);
|
||||
|
||||
group = null;
|
||||
list = args.getEnum(FollowList.class);
|
||||
|
||||
while (args.has()) {
|
||||
//noinspection unchecked
|
||||
Object gotten = args.getDatatypeFor(list.datatype);
|
||||
|
||||
if (gotten instanceof Class) {
|
||||
//noinspection unchecked
|
||||
classes.add((Class<? extends Entity>) gotten);
|
||||
} else {
|
||||
entities.add((Entity) gotten);
|
||||
}
|
||||
}
|
||||
|
||||
baritone.getFollowProcess().follow(
|
||||
classes.isEmpty()
|
||||
? entities::contains
|
||||
: e -> classes.stream().anyMatch(c -> c.isInstance(e))
|
||||
);
|
||||
}
|
||||
|
||||
if (nonNull(group)) {
|
||||
logDirect(String.format("Following all %s", group.name().toLowerCase(Locale.US)));
|
||||
} else {
|
||||
logDirect("Following these types of entities:");
|
||||
|
||||
if (classes.isEmpty()) {
|
||||
entities.stream()
|
||||
.map(Entity::toString)
|
||||
.forEach(this::logDirect);
|
||||
} else {
|
||||
classes.stream()
|
||||
.map(EntityList::getKey)
|
||||
.map(Objects::requireNonNull)
|
||||
.map(ResourceLocation::toString)
|
||||
.forEach(this::logDirect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
if (args.hasExactlyOne()) {
|
||||
return new TabCompleteHelper()
|
||||
.append(FollowGroup.class)
|
||||
.append(FollowList.class)
|
||||
.filterPrefix(args.getString())
|
||||
.stream();
|
||||
} else {
|
||||
Class<? extends IDatatype> followType;
|
||||
|
||||
try {
|
||||
followType = args.getEnum(FollowList.class).datatype;
|
||||
} catch (NullPointerException e) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
while (args.has(2)) {
|
||||
if (isNull(args.peekDatatypeOrNull(followType))) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
args.get();
|
||||
}
|
||||
|
||||
return args.tabCompleteDatatype(followType);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"The follow command tells Baritone to follow certain kinds of entities.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> follow entities - Follows all entities.",
|
||||
"> follow entity <entity1> <entity2> <...> - Follow certain entities (for example 'skeleton', 'horse' etc.)",
|
||||
"> follow players - Follow players",
|
||||
"> follow player <username1> <username2> <...> - Follow certain players"
|
||||
);
|
||||
}
|
||||
|
||||
private enum FollowGroup {
|
||||
ENTITIES(EntityLiving.class::isInstance),
|
||||
PLAYERS(EntityPlayer.class::isInstance); /* ,
|
||||
FRIENDLY(entity -> entity.getAttackTarget() != HELPER.mc.player),
|
||||
HOSTILE(FRIENDLY.filter.negate()); */
|
||||
|
||||
final Predicate<Entity> filter;
|
||||
|
||||
FollowGroup(Predicate<Entity> filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
}
|
||||
|
||||
private enum FollowList {
|
||||
ENTITY(EntityClassById.class),
|
||||
PLAYER(PlayerByUsername.class);
|
||||
|
||||
final Class<? extends IDatatypeFor> datatype;
|
||||
|
||||
FollowList(Class<? extends IDatatypeFor> datatype) {
|
||||
this.datatype = datatype;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.behavior.IPathingBehavior;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class ForceCancelCommand extends Command {
|
||||
public ForceCancelCommand() {
|
||||
super("forcecancel", "Force cancel");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(0);
|
||||
IPathingBehavior pathingBehavior = baritone.getPathingBehavior();
|
||||
pathingBehavior.cancelEverything();
|
||||
pathingBehavior.forceCancel();
|
||||
logDirect("ok force canceled");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"Like cancel, but more forceful.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> forcecancel"
|
||||
);
|
||||
}
|
||||
}
|
||||
57
src/main/java/baritone/utils/command/defaults/GcCommand.java
Normal file
57
src/main/java/baritone/utils/command/defaults/GcCommand.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class GcCommand extends Command {
|
||||
public GcCommand() {
|
||||
super("gc", "Call System.gc()");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(0);
|
||||
|
||||
System.gc();
|
||||
|
||||
logDirect("ok called System.gc()");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"Calls System.gc().",
|
||||
"",
|
||||
"Usage:",
|
||||
"> gc"
|
||||
);
|
||||
}
|
||||
}
|
||||
104
src/main/java/baritone/utils/command/defaults/GoalCommand.java
Normal file
104
src/main/java/baritone/utils/command/defaults/GoalCommand.java
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.process.ICustomGoalProcess;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.RelativeCoordinate;
|
||||
import baritone.api.utils.command.datatypes.RelativeGoal;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Objects.isNull;
|
||||
import static java.util.Objects.nonNull;
|
||||
|
||||
public class GoalCommand extends Command {
|
||||
public GoalCommand() {
|
||||
super("goal", "Set or clear the goal");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
ICustomGoalProcess goalProcess = baritone.getCustomGoalProcess();
|
||||
|
||||
if (args.has() && asList("reset", "clear", "none").contains(args.peekString())) {
|
||||
args.requireMax(1);
|
||||
|
||||
if (nonNull(goalProcess.getGoal())) {
|
||||
goalProcess.setGoal(null);
|
||||
logDirect("Cleared goal");
|
||||
} else {
|
||||
logDirect("There was no goal to clear");
|
||||
}
|
||||
} else {
|
||||
args.requireMax(3);
|
||||
BetterBlockPos origin = baritone.getPlayerContext().playerFeet();
|
||||
Goal goal = args.getDatatype(RelativeGoal.class).apply(origin);
|
||||
goalProcess.setGoal(goal);
|
||||
logDirect(String.format("Goal: %s", goal.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
TabCompleteHelper helper = new TabCompleteHelper();
|
||||
|
||||
if (args.hasExactlyOne()) {
|
||||
helper.append(Stream.of("reset", "clear", "none", "~"));
|
||||
} else {
|
||||
if (args.hasAtMost(3)) {
|
||||
while (args.has(2)) {
|
||||
if (isNull(args.peekDatatypeOrNull(RelativeCoordinate.class))) {
|
||||
break;
|
||||
}
|
||||
|
||||
args.get();
|
||||
|
||||
if (!args.has(2)) {
|
||||
helper.append("~");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return helper.filterPrefix(args.getString()).stream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"The goal command allows you to set or clear Baritone's goal.",
|
||||
"",
|
||||
"Wherever a coordinate is expected, you can use ~ just like in regular Minecraft commands. Or, you can just use regular numbers.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> goal - Set the goal to your current position",
|
||||
"> goal <reset/clear/none> - Erase the goal",
|
||||
"> goal <y> - Set the goal to a Y level",
|
||||
"> goal <x> <z> - Set the goal to an X,Z position",
|
||||
"> goal <x> <y> <z> - Set the goal to an X,Y,Z position"
|
||||
);
|
||||
}
|
||||
}
|
||||
131
src/main/java/baritone/utils/command/defaults/HelpCommand.java
Normal file
131
src/main/java/baritone/utils/command/defaults/HelpCommand.java
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandNotFoundException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import baritone.api.utils.command.helpers.pagination.Paginator;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.api.utils.command.manager.CommandManager;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.util.text.event.HoverEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static baritone.api.utils.command.BaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
import static baritone.api.utils.command.manager.CommandManager.getCommand;
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Objects.isNull;
|
||||
|
||||
public class HelpCommand extends Command {
|
||||
public HelpCommand() {
|
||||
super(asList("help", "?"), "View all commands or help on specific ones");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(1);
|
||||
|
||||
if (!args.has() || args.is(Integer.class)) {
|
||||
Paginator.paginate(
|
||||
args, new Paginator<>(
|
||||
CommandManager.REGISTRY.descendingStream()
|
||||
.filter(command -> !command.hiddenFromHelp())
|
||||
.collect(Collectors.toCollection(ArrayList::new))
|
||||
),
|
||||
() -> logDirect("All Baritone commands (clickable):"),
|
||||
command -> {
|
||||
String names = String.join("/", command.names);
|
||||
String name = command.names.get(0);
|
||||
|
||||
return new TextComponentString(name) {{
|
||||
getStyle()
|
||||
.setColor(TextFormatting.GRAY)
|
||||
.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponentString("") {{
|
||||
getStyle().setColor(TextFormatting.GRAY);
|
||||
|
||||
appendSibling(new TextComponentString(names + "\n") {{
|
||||
getStyle().setColor(TextFormatting.WHITE);
|
||||
}});
|
||||
|
||||
appendText(command.shortDesc);
|
||||
appendText("\n\nClick to view full help");
|
||||
}}
|
||||
))
|
||||
.setClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
FORCE_COMMAND_PREFIX + String.format("help %s", command.names.get(0))
|
||||
));
|
||||
|
||||
appendSibling(new TextComponentString(" - " + command.shortDesc) {{
|
||||
getStyle().setColor(TextFormatting.DARK_GRAY);
|
||||
}});
|
||||
}};
|
||||
},
|
||||
FORCE_COMMAND_PREFIX + "help"
|
||||
);
|
||||
} else {
|
||||
String commandName = args.getString().toLowerCase();
|
||||
Command command = getCommand(commandName);
|
||||
|
||||
if (isNull(command)) {
|
||||
throw new CommandNotFoundException(commandName);
|
||||
}
|
||||
|
||||
logDirect(String.format("%s - %s", String.join(" / ", command.names), command.shortDesc));
|
||||
logDirect("");
|
||||
command.getLongDesc().forEach(this::logDirect);
|
||||
logDirect("");
|
||||
logDirect(new TextComponentString("Click to return to the help menu") {{
|
||||
getStyle().setClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
FORCE_COMMAND_PREFIX + "help"
|
||||
));
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
if (args.hasExactlyOne()) {
|
||||
return new TabCompleteHelper().addCommands().filterPrefix(args.getString()).stream();
|
||||
}
|
||||
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"Using this command, you can view detailed help information on how to use certain commands of Baritone.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> help - Lists all commands and their short descriptions.",
|
||||
"> help <command> - Displays help information on a specific command."
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalInverted;
|
||||
import baritone.api.process.ICustomGoalProcess;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Objects.isNull;
|
||||
|
||||
public class InvertCommand extends Command {
|
||||
public InvertCommand() {
|
||||
super("invert", "Run away from the current goal");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(0);
|
||||
|
||||
ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
|
||||
Goal goal;
|
||||
|
||||
if (isNull(goal = customGoalProcess.getGoal())) {
|
||||
throw new CommandInvalidStateException("No goal");
|
||||
}
|
||||
|
||||
if (goal instanceof GoalInverted) {
|
||||
goal = ((GoalInverted) goal).origin;
|
||||
} else {
|
||||
goal = new GoalInverted(goal);
|
||||
}
|
||||
|
||||
customGoalProcess.setGoal(goal);
|
||||
logDirect(String.format("Goal: %s", goal.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"The invert command tells Baritone to head away from the current goal rather than towards it.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> invert - Invert the current goal."
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.BlockById;
|
||||
import baritone.api.utils.command.datatypes.ForBlockOptionalMeta;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class MineCommand extends Command {
|
||||
public MineCommand() {
|
||||
super("mine", "Mine some blocks");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
int quantity = args.getAsOrDefault(Integer.class, 0);
|
||||
args.requireMin(1);
|
||||
List<BlockOptionalMeta> boms = new ArrayList<>();
|
||||
|
||||
while (args.has()) {
|
||||
boms.add(args.getDatatypeFor(ForBlockOptionalMeta.class));
|
||||
}
|
||||
|
||||
baritone.getMineProcess().mine(quantity, boms.toArray(new BlockOptionalMeta[0]));
|
||||
logDirect(String.format("Mining %s", boms.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return args.tabCompleteDatatype(BlockById.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"",
|
||||
"",
|
||||
"Usage:",
|
||||
"> "
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.process.ICustomGoalProcess;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.RelativeCoordinate;
|
||||
import baritone.api.utils.command.datatypes.RelativeGoal;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Objects.isNull;
|
||||
|
||||
public class PathCommand extends Command {
|
||||
public PathCommand() {
|
||||
super("path", "Start heading towards a goal");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
|
||||
Goal goal;
|
||||
|
||||
if (args.has()) {
|
||||
args.requireMax(3);
|
||||
goal = args.getDatatype(RelativeGoal.class).apply(ctx.playerFeet());
|
||||
} else if (isNull(goal = customGoalProcess.getGoal())) {
|
||||
throw new CommandInvalidStateException("No goal");
|
||||
}
|
||||
|
||||
args.requireMax(0);
|
||||
customGoalProcess.setGoalAndPath(goal);
|
||||
logDirect("Now pathing");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
if (args.has() && !args.has(4)) {
|
||||
while (args.has(2)) {
|
||||
if (isNull(args.peekDatatypeOrNull(RelativeCoordinate.class))) {
|
||||
break;
|
||||
}
|
||||
|
||||
args.get();
|
||||
|
||||
if (!args.has(2)) {
|
||||
return new TabCompleteHelper()
|
||||
.append("~")
|
||||
.filterPrefix(args.getString())
|
||||
.stream();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"The path command tells Baritone to head towards the current goal.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> path - Start the pathing.",
|
||||
"> path <y>",
|
||||
"> path <x> <z>",
|
||||
"> path <x> <y> <z> - Define the goal here"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.process.IBaritoneProcess;
|
||||
import baritone.api.process.PathingCommand;
|
||||
import baritone.api.process.PathingCommandType;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
/**
|
||||
* Contains the pause, resume, and paused commands.
|
||||
*
|
||||
* This thing is scoped to hell, private so far you can't even access it using reflection, because you AREN'T SUPPOSED
|
||||
* TO USE THIS to pause and resume Baritone. Make your own process that returns {@link PathingCommandType#REQUEST_PAUSE
|
||||
* REQUEST_PAUSE} as needed.
|
||||
*/
|
||||
public class PauseResumeCommands {
|
||||
public static Command pauseCommand;
|
||||
public static Command resumeCommand;
|
||||
public static Command pausedCommand;
|
||||
|
||||
static {
|
||||
// array for mutability, non-field so reflection can't touch it
|
||||
final boolean[] paused = {false};
|
||||
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getPathingControlManager().registerProcess(
|
||||
new IBaritoneProcess() {
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return paused[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
|
||||
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTemporary() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLostControl() {}
|
||||
|
||||
@Override
|
||||
public double priority() {
|
||||
return DEFAULT_PRIORITY + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String displayName0() {
|
||||
return "Pause/Resume Commands";
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
pauseCommand = new Command("pause", "Pauses Baritone until you use resume") {
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(0);
|
||||
|
||||
if (paused[0]) {
|
||||
throw new CommandInvalidStateException("Already paused");
|
||||
}
|
||||
|
||||
paused[0] = true;
|
||||
logDirect("Paused");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"The pause command tells Baritone to temporarily stop whatever it's doing.",
|
||||
"",
|
||||
"This can be used to pause pathing, building, following, whatever. A single use of the resume command will start it right back up again!",
|
||||
"",
|
||||
"Usage:",
|
||||
"> pause"
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
resumeCommand = new Command("resume", "Resumes Baritone after a pause") {
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(0);
|
||||
|
||||
if (!paused[0]) {
|
||||
throw new CommandInvalidStateException("Not paused");
|
||||
}
|
||||
|
||||
paused[0] = false;
|
||||
logDirect("Resumed");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"The resume command tells Baritone to resume whatever it was doing when you last used pause.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> resume"
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
pausedCommand = new Command("paused", "Tells you if Baritone is paused") {
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(0);
|
||||
|
||||
logDirect(String.format("Baritone is %spaused", paused[0] ? "" : "not "));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"The paused command tells you if Baritone is currently paused by use of the pause command.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> paused"
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.pathing.calc.IPathingControlManager;
|
||||
import baritone.api.process.IBaritoneProcess;
|
||||
import baritone.api.process.PathingCommand;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Objects.isNull;
|
||||
|
||||
public class ProcCommand extends Command {
|
||||
public ProcCommand() {
|
||||
super("proc", "View process state information");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(0);
|
||||
|
||||
IPathingControlManager pathingControlManager = baritone.getPathingControlManager();
|
||||
IBaritoneProcess process = pathingControlManager.mostRecentInControl().orElse(null);
|
||||
|
||||
if (isNull(process)) {
|
||||
throw new CommandInvalidStateException("No process in control");
|
||||
}
|
||||
|
||||
logDirect(String.format(
|
||||
"Class: %s\n" +
|
||||
"Priority: %f\n" +
|
||||
"Temporary: %b\n" +
|
||||
"Display name: %s\n" +
|
||||
"Last command: %s",
|
||||
process.getClass().getTypeName(),
|
||||
process.priority(),
|
||||
process.isTemporary(),
|
||||
process.displayName(),
|
||||
pathingControlManager
|
||||
.mostRecentCommand()
|
||||
.map(PathingCommand::toString)
|
||||
.orElse("None")
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"The proc command provides miscellaneous information about the process currently controlling Baritone.",
|
||||
"",
|
||||
"You are not expected to understand this if you aren't familiar with how Baritone works.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> proc - View process information, if present"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class ReloadAllCommand extends Command {
|
||||
public ReloadAllCommand() {
|
||||
super("reloadall", "Reloads Baritone's cache for this world");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(0);
|
||||
ctx.worldData().getCachedWorld().reloadAllFromDisk();
|
||||
logDirect("Reloaded");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"The reloadall command reloads Baritone's world cache.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> reloadall"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class RenderCommand extends Command {
|
||||
public RenderCommand() {
|
||||
super("render", "Fix glitched chunks");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(0);
|
||||
|
||||
BetterBlockPos origin = ctx.playerFeet();
|
||||
int renderDistance = (MC.gameSettings.renderDistanceChunks + 1) * 16;
|
||||
MC.renderGlobal.markBlockRangeForRenderUpdate(
|
||||
origin.x - renderDistance,
|
||||
0,
|
||||
origin.z - renderDistance,
|
||||
origin.x + renderDistance,
|
||||
255,
|
||||
origin.z + renderDistance
|
||||
);
|
||||
|
||||
logDirect("Done");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"The render command fixes glitched chunk rendering without having to reload all of them.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> render"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.cache.ICachedWorld;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Objects.nonNull;
|
||||
|
||||
public class RepackCommand extends Command {
|
||||
public RepackCommand() {
|
||||
super(asList("repack", "rescan"), "Re-cache chunks");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(0);
|
||||
|
||||
IChunkProvider chunkProvider = ctx.world().getChunkProvider();
|
||||
ICachedWorld cachedWorld = ctx.worldData().getCachedWorld();
|
||||
|
||||
BetterBlockPos playerPos = ctx.playerFeet();
|
||||
int playerChunkX = playerPos.getX() >> 4;
|
||||
int playerChunkZ = playerPos.getZ() >> 4;
|
||||
int queued = 0;
|
||||
for (int x = playerChunkX - 40; x <= playerChunkX + 40; x++) {
|
||||
for (int z = playerChunkZ - 40; z <= playerChunkZ + 40; z++) {
|
||||
Chunk chunk = chunkProvider.getLoadedChunk(x, z);
|
||||
|
||||
if (nonNull(chunk) && !chunk.isEmpty()) {
|
||||
queued++;
|
||||
cachedWorld.queueForPacking(chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logDirect(String.format("Queued %d chunks for repacking", queued));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"Repack chunks around you. This basically re-caches them.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> repack - Repack chunks."
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class SaveAllCommand extends Command {
|
||||
public SaveAllCommand() {
|
||||
super("saveall", "Saves Baritone's cache for this world");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(0);
|
||||
ctx.worldData().getCachedWorld().save();
|
||||
logDirect("Saved");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"The saveall command saves Baritone's world cache.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> saveall"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class SchematicaCommand extends Command {
|
||||
public SchematicaCommand() {
|
||||
super("schematica", "Opens a Schematica schematic?");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(0);
|
||||
baritone.getBuilderProcess().buildOpenSchematic();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"I'm not actually sure what this does.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> schematica"
|
||||
);
|
||||
}
|
||||
}
|
||||
375
src/main/java/baritone/utils/command/defaults/SelCommand.java
Normal file
375
src/main/java/baritone/utils/command/defaults/SelCommand.java
Normal file
@@ -0,0 +1,375 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.event.events.RenderEvent;
|
||||
import baritone.api.schematic.CompositeSchematic;
|
||||
import baritone.api.schematic.FillBomSchematic;
|
||||
import baritone.api.schematic.ReplaceSchematic;
|
||||
import baritone.api.schematic.ShellSchematic;
|
||||
import baritone.api.schematic.WallsSchematic;
|
||||
import baritone.api.selection.ISelection;
|
||||
import baritone.api.selection.ISelectionManager;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
import baritone.api.utils.BlockOptionalMetaLookup;
|
||||
import baritone.api.utils.IRenderer;
|
||||
import baritone.api.utils.ISchematic;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.ForBlockOptionalMeta;
|
||||
import baritone.api.utils.command.datatypes.ForEnumFacing;
|
||||
import baritone.api.utils.command.datatypes.RelativeBlockPos;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class SelCommand extends Command {
|
||||
private ISelectionManager manager = baritone.getSelectionManager();
|
||||
private BetterBlockPos pos1 = null;
|
||||
|
||||
public SelCommand() {
|
||||
super(asList("sel", "selection", "s"), "WorldEdit-like commands");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
Action action = Action.getByName(args.getString());
|
||||
|
||||
if (action == null) {
|
||||
throw new CommandInvalidTypeException(args.consumed(), "an action");
|
||||
}
|
||||
|
||||
if (action == Action.POS1 || action == Action.POS2) {
|
||||
if (action == Action.POS2 && pos1 == null) {
|
||||
throw new CommandInvalidStateException("Set pos1 first before using pos2");
|
||||
}
|
||||
|
||||
BetterBlockPos playerPos = ctx.playerFeet();
|
||||
BetterBlockPos pos = args.has() ? args.getDatatypePost(RelativeBlockPos.class, playerPos) : playerPos;
|
||||
args.requireMax(0);
|
||||
|
||||
if (action == Action.POS1) {
|
||||
pos1 = pos;
|
||||
logDirect("Position 1 has been set");
|
||||
} else {
|
||||
manager.addSelection(pos1, pos);
|
||||
pos1 = null;
|
||||
logDirect("Selection added");
|
||||
}
|
||||
} else if (action == Action.CLEAR) {
|
||||
args.requireMax(0);
|
||||
pos1 = null;
|
||||
logDirect(String.format("Removed %d selections", manager.removeAllSelections().length));
|
||||
} else if (action == Action.UNDO) {
|
||||
args.requireMax(0);
|
||||
|
||||
if (pos1 != null) {
|
||||
pos1 = null;
|
||||
logDirect("Undid pos1");
|
||||
} else {
|
||||
ISelection[] selections = manager.getSelections();
|
||||
|
||||
if (selections.length < 1) {
|
||||
throw new CommandInvalidStateException("Nothing to undo!");
|
||||
} else {
|
||||
pos1 = manager.removeSelection(selections[selections.length - 1]).pos1();
|
||||
logDirect("Undid pos2");
|
||||
}
|
||||
}
|
||||
} else if (action == Action.SET || action == Action.WALLS || action == Action.SHELL || action == Action.CLEARAREA || action == Action.REPLACE) {
|
||||
BlockOptionalMeta type = action == Action.CLEARAREA
|
||||
? new BlockOptionalMeta(Blocks.AIR)
|
||||
: args.getDatatypeFor(ForBlockOptionalMeta.class);
|
||||
BlockOptionalMetaLookup replaces = null;
|
||||
|
||||
if (action == Action.REPLACE) {
|
||||
args.requireMin(1);
|
||||
|
||||
List<BlockOptionalMeta> replacesList = new ArrayList<>();
|
||||
|
||||
while (args.has()) {
|
||||
replacesList.add(args.getDatatypeFor(ForBlockOptionalMeta.class));
|
||||
}
|
||||
|
||||
replaces = new BlockOptionalMetaLookup(replacesList.toArray(new BlockOptionalMeta[0]));
|
||||
} else {
|
||||
args.requireMax(0);
|
||||
}
|
||||
|
||||
ISelection[] selections = manager.getSelections();
|
||||
|
||||
if (selections.length == 0) {
|
||||
throw new CommandInvalidStateException("No selections");
|
||||
}
|
||||
|
||||
BetterBlockPos origin = selections[0].min();
|
||||
CompositeSchematic composite = new CompositeSchematic(baritone, 0, 0, 0);
|
||||
|
||||
for (ISelection selection : selections) {
|
||||
BetterBlockPos min = selection.min();
|
||||
origin = new BetterBlockPos(
|
||||
Math.min(origin.x, min.x),
|
||||
Math.min(origin.y, min.y),
|
||||
Math.min(origin.z, min.z)
|
||||
);
|
||||
}
|
||||
|
||||
for (ISelection selection : selections) {
|
||||
Vec3i size = selection.size();
|
||||
BetterBlockPos min = selection.min();
|
||||
|
||||
ISchematic schematic = new FillBomSchematic(baritone, size.getX(), size.getY(), size.getZ(), type);
|
||||
|
||||
if (action == Action.WALLS) {
|
||||
schematic = new WallsSchematic(baritone, schematic);
|
||||
} else if (action == Action.SHELL) {
|
||||
schematic = new ShellSchematic(baritone, schematic);
|
||||
} else if (action == Action.REPLACE) {
|
||||
schematic = new ReplaceSchematic(baritone, schematic, replaces);
|
||||
}
|
||||
|
||||
composite.put(schematic, min.x - origin.x, min.y - origin.y, min.z - origin.z);
|
||||
}
|
||||
|
||||
baritone.getBuilderProcess().build("Fill", composite, origin);
|
||||
logDirect("Filling now");
|
||||
} else if (action == Action.EXPAND || action == Action.CONTRACT || action == Action.SHIFT) {
|
||||
args.requireExactly(3);
|
||||
TransformTarget transformTarget = TransformTarget.getByName(args.getString());
|
||||
|
||||
if (transformTarget == null) {
|
||||
throw new CommandInvalidStateException("Invalid transform type");
|
||||
}
|
||||
|
||||
EnumFacing direction = args.getDatatypeFor(ForEnumFacing.class);
|
||||
int blocks = args.getAs(Integer.class);
|
||||
|
||||
ISelection[] selections = manager.getSelections();
|
||||
|
||||
if (selections.length < 1) {
|
||||
throw new CommandInvalidStateException("No selections found");
|
||||
}
|
||||
|
||||
selections = transformTarget.transform(selections);
|
||||
|
||||
for (ISelection selection : selections) {
|
||||
if (action == Action.EXPAND) {
|
||||
manager.expand(selection, direction, blocks);
|
||||
} else if (action == Action.CONTRACT) {
|
||||
manager.contract(selection, direction, blocks);
|
||||
} else {
|
||||
manager.shift(selection, direction, blocks);
|
||||
}
|
||||
}
|
||||
|
||||
logDirect(String.format("Transformed %d selections", selections.length));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
if (args.hasExactlyOne()) {
|
||||
return new TabCompleteHelper()
|
||||
.append(Action.getAllNames())
|
||||
.filterPrefix(args.getString())
|
||||
.sortAlphabetically()
|
||||
.stream();
|
||||
} else {
|
||||
Action action = Action.getByName(args.getString());
|
||||
|
||||
if (action != null) {
|
||||
if (action == Action.POS1 || action == Action.POS2) {
|
||||
if (args.hasAtMost(3)) {
|
||||
return args.tabCompleteDatatype(RelativeBlockPos.class);
|
||||
}
|
||||
} else if (action == Action.SET || action == Action.WALLS || action == Action.CLEARAREA || action == Action.REPLACE) {
|
||||
if (args.hasExactlyOne() || action == Action.REPLACE) {
|
||||
while (args.has(2)) {
|
||||
args.get();
|
||||
}
|
||||
|
||||
return args.tabCompleteDatatype(ForBlockOptionalMeta.class);
|
||||
}
|
||||
} else if (action == Action.EXPAND || action == Action.CONTRACT || action == Action.SHIFT) {
|
||||
if (args.hasExactlyOne()) {
|
||||
return new TabCompleteHelper()
|
||||
.append(TransformTarget.getAllNames())
|
||||
.filterPrefix(args.getString())
|
||||
.sortAlphabetically()
|
||||
.stream();
|
||||
} else {
|
||||
TransformTarget target = TransformTarget.getByName(args.getString());
|
||||
|
||||
if (target != null && args.hasExactlyOne()) {
|
||||
return args.tabCompleteDatatype(ForEnumFacing.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"The sel command allows you to manipulate Baritone's selections, similarly to WorldEdit.",
|
||||
"",
|
||||
"Using these selections, you can clear areas, fill them with blocks, or something else.",
|
||||
"",
|
||||
"The expand/contract/shift commands use a kind of selector to choose which selections to target. Supported ones are a/all, n/newest, and o/oldest.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> sel pos1/p1/1 - Set position 1 to your current position.",
|
||||
"> sel pos1/p1/1 <x> <y> <z> - Set position 1 to a relative position.",
|
||||
"> sel pos2/p2/2 - Set position 2 to your current position.",
|
||||
"> sel pos2/p2/2 <x> <y> <z> - Set position 2 to a relative position.",
|
||||
"",
|
||||
"> sel clear/c - Clear the selection.",
|
||||
"> sel undo/u - Undo the last action (setting positions, creating selections, etc.)",
|
||||
"> sel set/fill/s/f [block] - Completely fill all selections with a block.",
|
||||
"> sel walls/w [block] - Fill in the walls of the selection with a specified block.",
|
||||
"> sel shell/shl [block] - The same as walls, but fills in a ceiling and floor too.",
|
||||
"> sel cleararea/ca - Basically 'set air'.",
|
||||
"> sel replace/r <place> <break...> - Replaces, with 'place', all blocks listed after it.",
|
||||
"",
|
||||
"> sel expand <target> <direction> <blocks> - Expand the targets.",
|
||||
"> sel contract <target> <direction> <blocks> - Contract the targets.",
|
||||
"> sel shift <target> <direction> <blocks> - Shift the targets (does not resize)."
|
||||
);
|
||||
}
|
||||
|
||||
enum Action {
|
||||
POS1("pos1", "p1", "1"),
|
||||
POS2("pos2", "p2", "2"),
|
||||
|
||||
CLEAR("clear", "c"),
|
||||
UNDO("undo", "u"),
|
||||
|
||||
SET("set", "fill", "s", "f"),
|
||||
WALLS("walls", "w"),
|
||||
SHELL("shell", "shl"),
|
||||
CLEARAREA("cleararea", "ca"),
|
||||
REPLACE("replace", "r"),
|
||||
|
||||
EXPAND("expand", "ex"),
|
||||
CONTRACT("contract", "ct"),
|
||||
SHIFT("shift", "sh");
|
||||
|
||||
private final String[] names;
|
||||
|
||||
Action(String... names) {
|
||||
this.names = names;
|
||||
}
|
||||
|
||||
public static Action getByName(String name) {
|
||||
for (Action action : Action.values()) {
|
||||
for (String alias : action.names) {
|
||||
if (alias.equalsIgnoreCase(name)) {
|
||||
return action;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String[] getAllNames() {
|
||||
Set<String> names = new HashSet<>();
|
||||
|
||||
for (Action action : Action.values()) {
|
||||
names.addAll(asList(action.names));
|
||||
}
|
||||
|
||||
return names.toArray(new String[0]);
|
||||
}
|
||||
}
|
||||
|
||||
enum TransformTarget {
|
||||
ALL(sels -> sels, "all", "a"),
|
||||
NEWEST(sels -> new ISelection[] {sels[sels.length - 1]}, "newest", "n"),
|
||||
OLDEST(sels -> new ISelection[] {sels[0]}, "oldest", "o");
|
||||
|
||||
private final Function<ISelection[], ISelection[]> transform;
|
||||
private final String[] names;
|
||||
|
||||
TransformTarget(Function<ISelection[], ISelection[]> transform, String... names) {
|
||||
this.transform = transform;
|
||||
this.names = names;
|
||||
}
|
||||
|
||||
public ISelection[] transform(ISelection[] selections) {
|
||||
return transform.apply(selections);
|
||||
}
|
||||
|
||||
public static TransformTarget getByName(String name) {
|
||||
for (TransformTarget target : TransformTarget.values()) {
|
||||
for (String alias : target.names) {
|
||||
if (alias.equalsIgnoreCase(name)) {
|
||||
return target;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String[] getAllNames() {
|
||||
Set<String> names = new HashSet<>();
|
||||
|
||||
for (TransformTarget target : TransformTarget.values()) {
|
||||
names.addAll(asList(target.names));
|
||||
}
|
||||
|
||||
return names.toArray(new String[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderPass(RenderEvent event) {
|
||||
if (!settings.renderSelectionCorners.value || pos1 == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Color color = settings.colorSelectionPos1.value;
|
||||
float opacity = settings.selectionOpacity.value;
|
||||
float lineWidth = settings.selectionLineWidth.value;
|
||||
boolean ignoreDepth = settings.renderSelectionIgnoreDepth.value;
|
||||
|
||||
IRenderer.startLines(color, opacity, lineWidth, ignoreDepth);
|
||||
IRenderer.drawAABB(new AxisAlignedBB(pos1, pos1.add(1, 1, 1)));
|
||||
IRenderer.endLines(ignoreDepth);
|
||||
}
|
||||
}
|
||||
280
src/main/java/baritone/utils/command/defaults/SetCommand.java
Normal file
280
src/main/java/baritone/utils/command/defaults/SetCommand.java
Normal file
@@ -0,0 +1,280 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import baritone.api.utils.command.helpers.pagination.Paginator;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.util.text.event.HoverEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static baritone.api.utils.SettingsUtil.settingDefaultToString;
|
||||
import static baritone.api.utils.SettingsUtil.settingTypeToString;
|
||||
import static baritone.api.utils.SettingsUtil.settingValueToString;
|
||||
import static baritone.api.utils.command.BaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Objects.isNull;
|
||||
import static java.util.Objects.nonNull;
|
||||
import static java.util.stream.Stream.of;
|
||||
|
||||
public class SetCommand extends Command {
|
||||
public SetCommand() {
|
||||
super(asList("set", "setting", "settings"), "View or change settings");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
String arg = args.has() ? args.getString().toLowerCase(Locale.US) : "list";
|
||||
|
||||
if (asList("s", "save").contains(arg)) {
|
||||
SettingsUtil.save(settings);
|
||||
logDirect("Settings saved");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean viewModified = asList("m", "mod", "modified").contains(arg);
|
||||
boolean viewAll = asList("all", "l", "list").contains(arg);
|
||||
boolean paginate = viewModified || viewAll;
|
||||
if (paginate) {
|
||||
String search = args.has() && args.peekAsOrNull(Integer.class) == null ? args.getString() : "";
|
||||
args.requireMax(1);
|
||||
|
||||
List<? extends Settings.Setting> toPaginate =
|
||||
(viewModified ? SettingsUtil.modifiedSettings(settings) : settings.allSettings).stream()
|
||||
.filter(s -> !s.getName().equals("logger"))
|
||||
.filter(s -> s.getName().toLowerCase(Locale.US).contains(search.toLowerCase(Locale.US)))
|
||||
.sorted((s1, s2) -> String.CASE_INSENSITIVE_ORDER.compare(s1.getName(), s2.getName()))
|
||||
.collect(Collectors.toCollection(ArrayList<Settings.Setting>::new));
|
||||
|
||||
Paginator.paginate(
|
||||
args,
|
||||
new Paginator<>(toPaginate),
|
||||
() -> logDirect(
|
||||
!search.isEmpty()
|
||||
? String.format("All %ssettings containing the string '%s':", viewModified ? "modified " : "", search)
|
||||
: String.format("All %ssettings:", viewModified ? "modified " : "")
|
||||
),
|
||||
setting -> new TextComponentString(setting.getName()) {{
|
||||
getStyle()
|
||||
.setColor(TextFormatting.GRAY)
|
||||
.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponentString("") {{
|
||||
getStyle().setColor(TextFormatting.GRAY);
|
||||
appendText(setting.getName());
|
||||
appendText(String.format("\nType: %s", settingTypeToString(setting)));
|
||||
appendText(String.format("\n\nValue:\n%s", settingValueToString(setting)));
|
||||
|
||||
if (setting.value != setting.defaultValue) {
|
||||
appendText(String.format("\n\nDefault:\n%s", settingDefaultToString(setting)));
|
||||
}
|
||||
}}
|
||||
))
|
||||
.setClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.SUGGEST_COMMAND,
|
||||
settings.prefix.value + String.format("set %s ", setting.getName())
|
||||
));
|
||||
|
||||
appendSibling(new TextComponentString(String.format(" (%s)", settingTypeToString(setting))) {{
|
||||
getStyle().setColor(TextFormatting.DARK_GRAY);
|
||||
}});
|
||||
}},
|
||||
FORCE_COMMAND_PREFIX + "set " + arg + " " + search
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
args.requireMax(1);
|
||||
|
||||
boolean resetting = arg.equalsIgnoreCase("reset");
|
||||
boolean toggling = arg.equalsIgnoreCase("toggle");
|
||||
boolean doingSomething = resetting || toggling;
|
||||
|
||||
if (resetting) {
|
||||
if (!args.has()) {
|
||||
logDirect("Please specify 'all' as an argument to reset to confirm you'd really like to do this");
|
||||
logDirect("ALL settings will be reset. Use the 'set modified' or 'modified' commands to see what will be reset.");
|
||||
logDirect("Specify a setting name instead of 'all' to only reset one setting");
|
||||
} else if (args.peekString().equalsIgnoreCase("all")) {
|
||||
SettingsUtil.modifiedSettings(settings).forEach(Settings.Setting::reset);
|
||||
logDirect("All settings have been reset to their default values");
|
||||
SettingsUtil.save(settings);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (toggling) {
|
||||
args.requireMin(1);
|
||||
}
|
||||
|
||||
String settingName = doingSomething ? args.getString() : arg;
|
||||
Settings.Setting<?> setting = settings.allSettings.stream()
|
||||
.filter(s -> s.getName().equalsIgnoreCase(settingName))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (isNull(setting)) {
|
||||
throw new CommandInvalidTypeException(args.consumed(), "a valid setting");
|
||||
}
|
||||
|
||||
if (!doingSomething && !args.has()) {
|
||||
logDirect(String.format("Value of setting %s:", setting.getName()));
|
||||
logDirect(settingValueToString(setting));
|
||||
} else {
|
||||
String oldValue = settingValueToString(setting);
|
||||
|
||||
if (resetting) {
|
||||
setting.reset();
|
||||
} else if (toggling) {
|
||||
if (setting.getValueClass() != Boolean.class) {
|
||||
throw new CommandInvalidTypeException(args.consumed(), "a toggleable setting", "some other setting");
|
||||
}
|
||||
|
||||
//noinspection unchecked
|
||||
((Settings.Setting<Boolean>) setting).value ^= true;
|
||||
|
||||
logDirect(String.format(
|
||||
"Toggled setting %s to %s",
|
||||
setting.getName(),
|
||||
Boolean.toString((Boolean) setting.value)
|
||||
));
|
||||
} else {
|
||||
String newValue = args.getString();
|
||||
|
||||
try {
|
||||
SettingsUtil.parseAndApply(settings, arg, newValue);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
throw new CommandInvalidTypeException(args.consumed(), "a valid value", t);
|
||||
}
|
||||
}
|
||||
|
||||
if (!toggling) {
|
||||
logDirect(String.format(
|
||||
"Successfully %s %s to %s",
|
||||
resetting ? "reset" : "set",
|
||||
setting.getName(),
|
||||
settingValueToString(setting)
|
||||
));
|
||||
}
|
||||
|
||||
logDirect(new TextComponentString(String.format("Old value: %s", oldValue)) {{
|
||||
getStyle()
|
||||
.setColor(TextFormatting.GRAY)
|
||||
.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponentString("Click to set the setting back to this value")
|
||||
))
|
||||
.setClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
FORCE_COMMAND_PREFIX + String.format("set %s %s", setting.getName(), oldValue)
|
||||
));
|
||||
}});
|
||||
|
||||
if ((setting.getName().equals("chatControl") && !(Boolean) setting.value && !settings.chatControlAnyway.value) ||
|
||||
setting.getName().equals("chatControlAnyway") && !(Boolean) setting.value && !settings.chatControl.value) {
|
||||
logDirect("Warning: Chat commands will no longer work. If you want to revert this change, use prefix control (if enabled) or click the old value listed above.", TextFormatting.RED);
|
||||
} else if (setting.getName().equals("prefixControl") && !(Boolean) setting.value) {
|
||||
logDirect("Warning: Prefixed commands will no longer work. If you want to revert this change, use chat control (if enabled) or click the old value listed above.", TextFormatting.RED);
|
||||
}
|
||||
}
|
||||
|
||||
SettingsUtil.save(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
if (args.has()) {
|
||||
String arg = args.getString();
|
||||
|
||||
if (args.hasExactlyOne() && !asList("s", "save").contains(args.peekString().toLowerCase(Locale.US))) {
|
||||
if (arg.equalsIgnoreCase("reset")) {
|
||||
return new TabCompleteHelper()
|
||||
.addModifiedSettings()
|
||||
.prepend("all")
|
||||
.filterPrefix(args.getString())
|
||||
.stream();
|
||||
} else if (arg.equalsIgnoreCase("toggle")) {
|
||||
return new TabCompleteHelper()
|
||||
.addToggleableSettings()
|
||||
.filterPrefix(args.getString())
|
||||
.stream();
|
||||
}
|
||||
|
||||
Settings.Setting setting = settings.byLowerName.get(arg.toLowerCase(Locale.US));
|
||||
|
||||
if (nonNull(setting)) {
|
||||
if (setting.getType() == Boolean.class) {
|
||||
TabCompleteHelper helper = new TabCompleteHelper();
|
||||
|
||||
if ((Boolean) setting.value) {
|
||||
helper.append(of("true", "false"));
|
||||
} else {
|
||||
helper.append(of("false", "true"));
|
||||
}
|
||||
|
||||
return helper.filterPrefix(args.getString()).stream();
|
||||
} else {
|
||||
return Stream.of(settingValueToString(setting));
|
||||
}
|
||||
}
|
||||
} else if (!args.has()) {
|
||||
return new TabCompleteHelper()
|
||||
.addSettings()
|
||||
.sortAlphabetically()
|
||||
.prepend("list", "modified", "reset", "toggle", "save")
|
||||
.filterPrefix(arg)
|
||||
.stream();
|
||||
}
|
||||
}
|
||||
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"Using the set command, you can manage all of Baritone's settings. Almost every aspect is controlled by these settings - go wild!",
|
||||
"",
|
||||
"Usage:",
|
||||
"> set - Same as `set list`",
|
||||
"> set list [page] - View all settings",
|
||||
"> set modified [page] - View modified settings",
|
||||
"> set <setting> - View the current value of a setting",
|
||||
"> set <setting> <value> - Set the value of a setting",
|
||||
"> set reset all - Reset ALL SETTINGS to their defaults",
|
||||
"> set reset <setting> - Reset a setting to its default",
|
||||
"> set toggle <setting> - Toggle a boolean setting",
|
||||
"> set save - Save all settings (this is automatic tho)"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class ThisWayCommand extends Command {
|
||||
public ThisWayCommand() {
|
||||
super(asList("thisway", "forward"), "Travel in your current direction");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireExactly(1);
|
||||
|
||||
GoalXZ goal = GoalXZ.fromDirection(
|
||||
ctx.playerFeetAsVec(),
|
||||
ctx.player().rotationYawHead,
|
||||
args.getAs(Double.class)
|
||||
);
|
||||
|
||||
baritone.getCustomGoalProcess().setGoal(goal);
|
||||
logDirect(String.format("Goal: %s", goal));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"Creates a GoalXZ some amount of blocks in the direction you're currently looking",
|
||||
"",
|
||||
"Usage:",
|
||||
"> thisway <distance> - makes a GoalXZ distance blocks in front of you"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalStrictDirection;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class TunnelCommand extends Command {
|
||||
public TunnelCommand() {
|
||||
super("tunnel", "Set a goal to tunnel in your current direction");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(0);
|
||||
|
||||
Goal goal = new GoalStrictDirection(
|
||||
ctx.playerFeet(),
|
||||
ctx.player().getHorizontalFacing()
|
||||
);
|
||||
|
||||
baritone.getCustomGoalProcess().setGoal(goal);
|
||||
logDirect(String.format("Goal: %s", goal.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"The tunnel command sets a goal that tells Baritone to mine completely straight in the direction that you're facing.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> tunnel"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Objects.isNull;
|
||||
|
||||
public class VersionCommand extends Command {
|
||||
public VersionCommand() {
|
||||
super("version", "View the Baritone version");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
args.requireMax(0);
|
||||
|
||||
String version = getClass().getPackage().getImplementationVersion();
|
||||
|
||||
if (isNull(version)) {
|
||||
throw new CommandInvalidStateException("Null version (this is normal in a dev environment)");
|
||||
} else {
|
||||
logDirect(String.format("You are running Baritone v%s", version));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"The version command prints the version of Baritone you're currently running.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> version - View version information, if present"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,352 @@
|
||||
/*
|
||||
* 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.utils.command.defaults;
|
||||
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.cache.IWaypoint;
|
||||
import baritone.api.cache.Waypoint;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.ForWaypoints;
|
||||
import baritone.api.utils.command.datatypes.RelativeBlockPos;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
||||
import baritone.api.utils.command.helpers.pagination.Paginator;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.util.text.event.HoverEvent;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static baritone.api.utils.command.BaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class WaypointsCommand extends Command {
|
||||
public WaypointsCommand() {
|
||||
super(asList("waypoints", "waypoint", "wp"), "Manage waypoints");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executed(String label, ArgConsumer args, Settings settings) {
|
||||
Action action = args.has() ? Action.getByName(args.getString()) : Action.LIST;
|
||||
|
||||
if (action == null) {
|
||||
throw new CommandInvalidTypeException(args.consumed(), "an action");
|
||||
}
|
||||
|
||||
BiFunction<IWaypoint, Action, ITextComponent> toComponent = (waypoint, _action) -> {
|
||||
ITextComponent component = new TextComponentString("");
|
||||
|
||||
ITextComponent tagComponent = new TextComponentString(waypoint.getTag().name() + " ");
|
||||
tagComponent.getStyle().setColor(TextFormatting.GRAY);
|
||||
String name = waypoint.getName();
|
||||
ITextComponent nameComponent = new TextComponentString(!name.isEmpty() ? name : "<empty>");
|
||||
nameComponent.getStyle().setColor(!name.isEmpty() ? TextFormatting.GRAY : TextFormatting.DARK_GRAY);
|
||||
ITextComponent timestamp = new TextComponentString(" @ " + new Date(waypoint.getCreationTimestamp()));
|
||||
timestamp.getStyle().setColor(TextFormatting.DARK_GRAY);
|
||||
|
||||
component.appendSibling(tagComponent);
|
||||
component.appendSibling(nameComponent);
|
||||
component.appendSibling(timestamp);
|
||||
component.getStyle()
|
||||
.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponentString("Click to select")
|
||||
))
|
||||
.setClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
"%s%s %s %s @ %d",
|
||||
FORCE_COMMAND_PREFIX,
|
||||
label,
|
||||
_action.names[0],
|
||||
waypoint.getTag().names[0],
|
||||
waypoint.getCreationTimestamp()
|
||||
))
|
||||
);
|
||||
|
||||
return component;
|
||||
};
|
||||
|
||||
Function<IWaypoint, ITextComponent> transform = waypoint ->
|
||||
toComponent.apply(waypoint, action == Action.LIST ? Action.INFO : action);
|
||||
|
||||
if (action == Action.LIST) {
|
||||
IWaypoint.Tag tag = args.has() ? ForWaypoints.getTagByName(args.peekString()) : null;
|
||||
|
||||
if (tag != null) {
|
||||
args.get();
|
||||
}
|
||||
|
||||
IWaypoint[] waypoints = tag != null
|
||||
? ForWaypoints.getWaypointsByTag(tag)
|
||||
: ForWaypoints.getWaypoints();
|
||||
|
||||
if (waypoints.length > 0) {
|
||||
args.requireMax(1);
|
||||
Paginator.paginate(
|
||||
args,
|
||||
waypoints,
|
||||
() -> logDirect(
|
||||
tag != null
|
||||
? String.format("All waypoints by tag %s:", tag.name())
|
||||
: "All waypoints:"
|
||||
),
|
||||
transform,
|
||||
String.format(
|
||||
"%s%s %s%s",
|
||||
FORCE_COMMAND_PREFIX,
|
||||
label,
|
||||
action.names[0],
|
||||
tag != null ? " " + tag.names[0] : ""
|
||||
)
|
||||
);
|
||||
} else {
|
||||
args.requireMax(0);
|
||||
throw new CommandInvalidStateException(
|
||||
tag != null
|
||||
? "No waypoints found by that tag"
|
||||
: "No waypoints found"
|
||||
);
|
||||
}
|
||||
} else if (action == Action.SAVE) {
|
||||
IWaypoint.Tag tag = ForWaypoints.getTagByName(args.getString());
|
||||
|
||||
if (tag == null) {
|
||||
throw new CommandInvalidStateException(String.format("'%s' is not a tag ", args.consumedString()));
|
||||
}
|
||||
|
||||
String name = args.has() ? args.getString() : "";
|
||||
BetterBlockPos pos = args.has()
|
||||
? args.getDatatypePost(RelativeBlockPos.class, ctx.playerFeet())
|
||||
: ctx.playerFeet();
|
||||
|
||||
args.requireMax(0);
|
||||
|
||||
IWaypoint waypoint = new Waypoint(name, tag, pos);
|
||||
ForWaypoints.waypoints().addWaypoint(waypoint);
|
||||
|
||||
ITextComponent component = new TextComponentString("Waypoint added: ");
|
||||
component.getStyle().setColor(TextFormatting.GRAY);
|
||||
component.appendSibling(toComponent.apply(waypoint, Action.INFO));
|
||||
logDirect(component);
|
||||
} else if (action == Action.CLEAR) {
|
||||
args.requireMax(1);
|
||||
IWaypoint.Tag tag = ForWaypoints.getTagByName(args.getString());
|
||||
IWaypoint[] waypoints = ForWaypoints.getWaypointsByTag(tag);
|
||||
|
||||
for (IWaypoint waypoint : waypoints) {
|
||||
ForWaypoints.waypoints().removeWaypoint(waypoint);
|
||||
}
|
||||
|
||||
logDirect(String.format("Cleared %d waypoints", waypoints.length));
|
||||
} else {
|
||||
IWaypoint[] waypoints = args.getDatatypeFor(ForWaypoints.class);
|
||||
IWaypoint waypoint = null;
|
||||
|
||||
if (args.has() && args.peekString().equals("@")) {
|
||||
args.requireExactly(2);
|
||||
args.get();
|
||||
long timestamp = args.getAs(Long.class);
|
||||
|
||||
for (IWaypoint iWaypoint : waypoints) {
|
||||
if (iWaypoint.getCreationTimestamp() == timestamp) {
|
||||
waypoint = iWaypoint;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (waypoint == null) {
|
||||
throw new CommandInvalidStateException("Timestamp was specified but no waypoint was found");
|
||||
}
|
||||
} else {
|
||||
switch (waypoints.length) {
|
||||
case 0:
|
||||
throw new CommandInvalidStateException("No waypoints found");
|
||||
case 1:
|
||||
waypoint = waypoints[0];
|
||||
}
|
||||
}
|
||||
|
||||
if (waypoint == null) {
|
||||
args.requireMax(1);
|
||||
Paginator.paginate(
|
||||
args,
|
||||
waypoints,
|
||||
() -> logDirect("Multiple waypoints were found:"),
|
||||
transform,
|
||||
String.format(
|
||||
"%s%s %s %s",
|
||||
FORCE_COMMAND_PREFIX,
|
||||
label,
|
||||
action.names[0],
|
||||
args.consumedString()
|
||||
)
|
||||
);
|
||||
} else {
|
||||
if (action == Action.INFO) {
|
||||
logDirect(transform.apply(waypoint));
|
||||
logDirect(String.format("Position: %s", waypoint.getLocation()));
|
||||
ITextComponent deleteComponent = new TextComponentString("Click to delete this waypoint");
|
||||
deleteComponent.getStyle().setClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
"%s%s delete %s @ %d",
|
||||
FORCE_COMMAND_PREFIX,
|
||||
label,
|
||||
waypoint.getTag().names[0],
|
||||
waypoint.getCreationTimestamp()
|
||||
)
|
||||
));
|
||||
ITextComponent goalComponent = new TextComponentString("Click to set goal to this waypoint");
|
||||
goalComponent.getStyle().setClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
"%s%s goal %s @ %d",
|
||||
FORCE_COMMAND_PREFIX,
|
||||
label,
|
||||
waypoint.getTag().names[0],
|
||||
waypoint.getCreationTimestamp()
|
||||
)
|
||||
));
|
||||
ITextComponent backComponent = new TextComponentString("Click to return to the waypoints list");
|
||||
backComponent.getStyle().setClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
String.format(
|
||||
"%s%s list",
|
||||
FORCE_COMMAND_PREFIX,
|
||||
label
|
||||
)
|
||||
));
|
||||
logDirect(deleteComponent);
|
||||
logDirect(goalComponent);
|
||||
logDirect(backComponent);
|
||||
} else if (action == Action.DELETE) {
|
||||
ForWaypoints.waypoints().removeWaypoint(waypoint);
|
||||
logDirect("That waypoint has successfully been deleted");
|
||||
} else if (action == Action.GOAL) {
|
||||
Goal goal = new GoalBlock(waypoint.getLocation());
|
||||
baritone.getCustomGoalProcess().setGoal(goal);
|
||||
logDirect(String.format("Goal: %s", goal));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
|
||||
if (args.has()) {
|
||||
if (args.hasExactlyOne()) {
|
||||
return new TabCompleteHelper()
|
||||
.append(Action.getAllNames())
|
||||
.sortAlphabetically()
|
||||
.filterPrefix(args.getString())
|
||||
.stream();
|
||||
} else {
|
||||
Action action = Action.getByName(args.getString());
|
||||
|
||||
if (args.hasExactlyOne()) {
|
||||
if (action == Action.LIST || action == Action.SAVE || action == Action.CLEAR) {
|
||||
return new TabCompleteHelper()
|
||||
.append(ForWaypoints.getTagNames())
|
||||
.sortAlphabetically()
|
||||
.filterPrefix(args.getString())
|
||||
.stream();
|
||||
} else {
|
||||
return args.tabCompleteDatatype(ForWaypoints.class);
|
||||
}
|
||||
} else if (args.has(3) && action == Action.SAVE) {
|
||||
args.get();
|
||||
args.get();
|
||||
return args.tabCompleteDatatype(RelativeBlockPos.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return asList(
|
||||
"The waypoint command allows you to manage Baritone's waypoints.",
|
||||
"",
|
||||
"Waypoints can be used to mark positions for later. Waypoints are each given a tag and an optional name.",
|
||||
"",
|
||||
"Note that the info, delete, and goal commands let you specify a waypoint by tag. If there is more than one waypoint with a certain tag, then they will let you select which waypoint you mean.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> wp [l/list] - List all waypoints.",
|
||||
"> wp <s/save> <tag> - Save your current position as an unnamed waypoint with the specified tag.",
|
||||
"> wp <s/save> <tag> <name> - Save the waypoint with the specified name.",
|
||||
"> wp <s/save> <tag> <name> <pos> - Save the waypoint with the specified name and position.",
|
||||
"> wp <i/info/show> <tag> - Show info on a waypoint by tag.",
|
||||
"> wp <d/delete> <tag> - Delete a waypoint by tag.",
|
||||
"> wp <g/goal/goto> <tag> - Set a goal to a waypoint by tag."
|
||||
);
|
||||
}
|
||||
|
||||
private enum Action {
|
||||
LIST("list", "get", "l"),
|
||||
CLEAR("clear", "c"),
|
||||
SAVE("save", "s"),
|
||||
INFO("info", "show", "i"),
|
||||
DELETE("delete", "d"),
|
||||
GOAL("goal", "goto", "g");
|
||||
|
||||
private final String[] names;
|
||||
|
||||
Action(String... names) {
|
||||
this.names = names;
|
||||
}
|
||||
|
||||
public static Action getByName(String name) {
|
||||
for (Action action : Action.values()) {
|
||||
for (String alias : action.names) {
|
||||
if (alias.equalsIgnoreCase(name)) {
|
||||
return action;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String[] getAllNames() {
|
||||
Set<String> names = new HashSet<>();
|
||||
|
||||
for (Action action : Action.values()) {
|
||||
names.addAll(asList(action.names));
|
||||
}
|
||||
|
||||
return names.toArray(new String[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user