2019-08-30 18:55:25 +00:00
|
|
|
/*
|
|
|
|
* This file is part of Baritone.
|
|
|
|
*
|
|
|
|
* Baritone is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Baritone is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-09-04 18:17:36 +00:00
|
|
|
package baritone.utils.command.defaults;
|
2019-08-30 18:55:25 +00:00
|
|
|
|
2019-09-19 20:30:40 +00:00
|
|
|
import baritone.api.IBaritone;
|
2019-08-30 18:55:25 +00:00
|
|
|
import baritone.api.Settings;
|
2019-08-30 22:38:15 +00:00
|
|
|
import baritone.api.utils.BlockOptionalMeta;
|
2019-08-30 18:55:25 +00:00
|
|
|
import baritone.api.utils.command.Command;
|
|
|
|
import baritone.api.utils.command.datatypes.BlockById;
|
2019-08-30 22:38:15 +00:00
|
|
|
import baritone.api.utils.command.datatypes.ForBlockOptionalMeta;
|
2019-09-20 23:32:43 +00:00
|
|
|
import baritone.api.utils.command.exception.CommandException;
|
2019-08-30 18:55:25 +00:00
|
|
|
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
|
2019-09-06 10:59:10 +00:00
|
|
|
import baritone.cache.WorldScanner;
|
2019-08-30 18:55:25 +00:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2019-09-19 21:38:13 +00:00
|
|
|
import java.util.Arrays;
|
2019-08-30 18:55:25 +00:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
public class MineCommand extends Command {
|
2019-09-19 20:40:46 +00:00
|
|
|
|
2019-09-19 20:30:40 +00:00
|
|
|
public MineCommand(IBaritone baritone) {
|
|
|
|
super(baritone, "mine");
|
2019-08-30 18:55:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-09-21 07:07:10 +00:00
|
|
|
protected void executed(String label, ArgConsumer args) throws CommandException {
|
2019-08-30 18:55:25 +00:00
|
|
|
int quantity = args.getAsOrDefault(Integer.class, 0);
|
|
|
|
args.requireMin(1);
|
2019-08-30 22:38:15 +00:00
|
|
|
List<BlockOptionalMeta> boms = new ArrayList<>();
|
2019-09-20 23:32:43 +00:00
|
|
|
while (args.hasAny()) {
|
2019-08-30 22:38:15 +00:00
|
|
|
boms.add(args.getDatatypeFor(ForBlockOptionalMeta.class));
|
2019-08-30 18:55:25 +00:00
|
|
|
}
|
2019-09-06 10:59:10 +00:00
|
|
|
WorldScanner.INSTANCE.repack(ctx);
|
2019-08-30 22:38:15 +00:00
|
|
|
logDirect(String.format("Mining %s", boms.toString()));
|
2019-09-20 00:53:29 +00:00
|
|
|
baritone.getMineProcess().mine(quantity, boms.toArray(new BlockOptionalMeta[0]));
|
2019-08-30 18:55:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-09-21 07:07:10 +00:00
|
|
|
protected Stream<String> tabCompleted(String label, ArgConsumer args) {
|
2019-08-30 18:55:25 +00:00
|
|
|
return args.tabCompleteDatatype(BlockById.class);
|
|
|
|
}
|
|
|
|
|
2019-09-06 10:59:10 +00:00
|
|
|
@Override
|
|
|
|
public String getShortDesc() {
|
|
|
|
return "Mine some blocks";
|
|
|
|
}
|
|
|
|
|
2019-08-30 18:55:25 +00:00
|
|
|
@Override
|
|
|
|
public List<String> getLongDesc() {
|
2019-09-19 21:38:13 +00:00
|
|
|
return Arrays.asList(
|
2019-09-19 19:53:15 +00:00
|
|
|
"The mine command allows you to tell Baritone to search for and mine individual blocks.",
|
|
|
|
"",
|
|
|
|
"The specified blocks can be ores (which are commonly cached), or any other block.",
|
|
|
|
"",
|
|
|
|
"Also see the legitMine settings (see #set l legitMine).",
|
|
|
|
"",
|
|
|
|
"Usage:",
|
|
|
|
"> mine diamond_ore - Mines all diamonds it can find.",
|
|
|
|
"> mine redstone_ore lit_redstone_ore - Mines redstone ore.",
|
|
|
|
"> mine log:0 - Mines only oak logs."
|
2019-08-30 18:55:25 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|