Merge branch 'master' into bot-system
This commit is contained in:
@@ -26,7 +26,7 @@ import baritone.api.process.*;
|
||||
import baritone.api.selection.ISelectionManager;
|
||||
import baritone.api.utils.IInputOverrideHandler;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import baritone.api.utils.command.manager.ICommandManager;
|
||||
import baritone.api.command.manager.ICommandManager;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
|
||||
@@ -19,13 +19,15 @@ package baritone.api;
|
||||
|
||||
import baritone.api.bot.IUserManager;
|
||||
import baritone.api.cache.IWorldScanner;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.ICommandSystem;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Provides the present {@link IBaritone} instances
|
||||
* Provides the present {@link IBaritone} instances, as well as non-baritone instance related APIs.
|
||||
*
|
||||
* @author leijurv
|
||||
*/
|
||||
@@ -78,4 +80,12 @@ public interface IBaritoneProvider {
|
||||
* @return The {@link IUserManager} instance.
|
||||
*/
|
||||
IUserManager getUserManager();
|
||||
|
||||
/**
|
||||
* Returns the {@link ICommandSystem} instance. This is not bound to a specific {@link IBaritone}
|
||||
* instance because {@link ICommandSystem} itself controls global behavior for {@link Command}s.
|
||||
*
|
||||
* @return The {@link ICommandSystem} instance.
|
||||
*/
|
||||
ICommandSystem getCommandSystem();
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ import java.awt.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
@@ -798,6 +798,14 @@ public final class Settings {
|
||||
*/
|
||||
public final Setting<Boolean> mineScanDroppedItems = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* While mining, wait this number of milliseconds after mining an ore to see if it will drop an item
|
||||
* instead of immediately going onto the next one
|
||||
* <p>
|
||||
* Thanks Louca
|
||||
*/
|
||||
public final Setting<Long> mineDropLoiterDurationMSThanksLouca = new Setting<>(250L);
|
||||
|
||||
/**
|
||||
* Trim incorrect positions too far away, helps performance but hurts reliability in very large schematics
|
||||
*/
|
||||
|
||||
+11
-11
@@ -15,13 +15,13 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command;
|
||||
package baritone.api.command;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -37,25 +37,21 @@ public abstract class Command implements Helper {
|
||||
/**
|
||||
* The names of this command. This is what you put after the command prefix.
|
||||
*/
|
||||
public final List<String> names;
|
||||
protected final List<String> names;
|
||||
|
||||
/**
|
||||
* Creates a new Baritone control command.
|
||||
*
|
||||
* @param names The names of this command. This is what you put after the command prefix.
|
||||
*/
|
||||
protected Command(IBaritone baritone, List<String> names) {
|
||||
this.names = names.stream()
|
||||
protected Command(IBaritone baritone, String... names) {
|
||||
this.names = Collections.unmodifiableList(Stream.of(names)
|
||||
.map(s -> s.toLowerCase(Locale.US))
|
||||
.collect(Collectors.toList());
|
||||
.collect(Collectors.toList()));
|
||||
this.baritone = baritone;
|
||||
this.ctx = baritone.getPlayerContext();
|
||||
}
|
||||
|
||||
protected Command(IBaritone baritone, String name) {
|
||||
this(baritone, Collections.singletonList(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this command is executed.
|
||||
*/
|
||||
@@ -83,4 +79,8 @@ public abstract class Command implements Helper {
|
||||
public boolean hiddenFromHelp() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public final List<String> getNames() {
|
||||
return this.names;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command;
|
||||
package baritone.api.command;
|
||||
|
||||
import baritone.api.Settings;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.api.command;
|
||||
|
||||
import baritone.api.command.argparser.IArgParserManager;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 10/4/2019
|
||||
*/
|
||||
public interface ICommandSystem {
|
||||
|
||||
IArgParserManager getParserManager();
|
||||
}
|
||||
+2
-6
@@ -15,9 +15,9 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.argparser;
|
||||
package baritone.api.command.argparser;
|
||||
|
||||
import baritone.api.utils.command.argument.ICommandArgument;
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
|
||||
public interface IArgParser<T> {
|
||||
|
||||
@@ -28,8 +28,6 @@ public interface IArgParser<T> {
|
||||
|
||||
/**
|
||||
* A stateless argument parser is just that. It takes a {@link ICommandArgument} and outputs its type.
|
||||
*
|
||||
* @see ArgParserManager#REGISTRY
|
||||
*/
|
||||
interface Stateless<T> extends IArgParser<T> {
|
||||
|
||||
@@ -45,8 +43,6 @@ public interface IArgParser<T> {
|
||||
/**
|
||||
* A stated argument parser is similar to a stateless one. It also takes a {@link ICommandArgument}, but it also
|
||||
* takes a second argument that can be any type, referred to as the state.
|
||||
*
|
||||
* @see ArgParserManager#REGISTRY
|
||||
*/
|
||||
interface Stated<T, S> extends IArgParser<T> {
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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.api.command.argparser;
|
||||
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.command.registry.Registry;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 10/4/2019
|
||||
*/
|
||||
public interface IArgParserManager {
|
||||
|
||||
/**
|
||||
* @param type The type trying to be parsed
|
||||
* @return A parser that can parse arguments into this class, if found.
|
||||
*/
|
||||
<T> IArgParser.Stateless<T> getParserStateless(Class<T> type);
|
||||
|
||||
/**
|
||||
* @param type The type trying to be parsed
|
||||
* @return A parser that can parse arguments into this class, if found.
|
||||
*/
|
||||
<T, S> IArgParser.Stated<T, S> getParserStated(Class<T> type, Class<S> stateKlass);
|
||||
|
||||
/**
|
||||
* Attempt to parse the specified argument with a stateless {@link IArgParser} that outputs the specified class.
|
||||
*
|
||||
* @param type The type to try and parse the argument into.
|
||||
* @param arg The argument to parse.
|
||||
* @return An instance of the specified class.
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
*/
|
||||
<T> T parseStateless(Class<T> type, ICommandArgument arg) throws CommandInvalidTypeException;
|
||||
|
||||
/**
|
||||
* Attempt to parse the specified argument with a stated {@link IArgParser} that outputs the specified class.
|
||||
*
|
||||
* @param type The type to try and parse the argument into.
|
||||
* @param arg The argument to parse.
|
||||
* @param state The state to pass to the {@link IArgParser.Stated}.
|
||||
* @return An instance of the specified class.
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
* @see IArgParser.Stated
|
||||
*/
|
||||
<T, S> T parseStated(Class<T> type, Class<S> stateKlass, ICommandArgument arg, S state) throws CommandInvalidTypeException;
|
||||
|
||||
Registry<IArgParser> getRegistry();
|
||||
}
|
||||
+4
-4
@@ -15,11 +15,11 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.argument;
|
||||
package baritone.api.command.argument;
|
||||
|
||||
import baritone.api.utils.command.argparser.IArgParser;
|
||||
import baritone.api.utils.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.argparser.IArgParser;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
/**
|
||||
+3
-3
@@ -15,10 +15,10 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.datatypes;
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.api.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
+3
-3
@@ -15,10 +15,10 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.datatypes;
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.api.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
+2
-2
@@ -15,10 +15,10 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.datatypes;
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
+3
-3
@@ -15,10 +15,10 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.datatypes;
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.api.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import java.util.Locale;
|
||||
+3
-3
@@ -15,13 +15,13 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.datatypes;
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.cache.IWaypoint;
|
||||
import baritone.api.cache.IWaypointCollection;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.api.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.stream.Stream;
|
||||
+4
-4
@@ -15,11 +15,11 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.datatypes;
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.utils.command.argparser.IArgParser;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.argparser.IArgParser;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
+2
-2
@@ -15,10 +15,10 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.datatypes;
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
|
||||
/**
|
||||
* Provides an {@link IDatatype} with contextual information so
|
||||
+2
-2
@@ -15,9 +15,9 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.datatypes;
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
+2
-2
@@ -15,9 +15,9 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.datatypes;
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
+2
-2
@@ -15,9 +15,9 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.datatypes;
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
+3
-3
@@ -15,11 +15,11 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.datatypes;
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.api.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import java.util.List;
|
||||
+3
-3
@@ -15,11 +15,11 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.datatypes;
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
+10
-6
@@ -15,10 +15,10 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.datatypes;
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -26,8 +26,7 @@ import java.util.stream.Stream;
|
||||
|
||||
public enum RelativeCoordinate implements IDatatypePost<Double, Double> {
|
||||
INSTANCE;
|
||||
|
||||
private static Pattern PATTERN = Pattern.compile("^(~?)([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)|)$");
|
||||
private static Pattern PATTERN = Pattern.compile("^(~?)([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)([k-k]?)|)$");
|
||||
|
||||
@Override
|
||||
public Double apply(IDatatypeContext ctx, Double origin) throws CommandException {
|
||||
@@ -41,7 +40,12 @@ public enum RelativeCoordinate implements IDatatypePost<Double, Double> {
|
||||
}
|
||||
|
||||
boolean isRelative = !matcher.group(1).isEmpty();
|
||||
double offset = matcher.group(2).isEmpty() ? 0 : Double.parseDouble(matcher.group(2));
|
||||
|
||||
double offset = matcher.group(2).isEmpty() ? 0 : Double.parseDouble(matcher.group(2).replaceAll("k", ""));
|
||||
|
||||
if (matcher.group(2).contains("k")) {
|
||||
offset *= 1000;
|
||||
}
|
||||
|
||||
if (isRelative) {
|
||||
return origin + offset;
|
||||
+3
-3
@@ -15,10 +15,10 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.datatypes;
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
+3
-3
@@ -15,15 +15,15 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.datatypes;
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
import baritone.api.pathing.goals.GoalYLevel;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
+3
-3
@@ -15,12 +15,12 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.datatypes;
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
+3
-3
@@ -15,12 +15,12 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.datatypes;
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
+3
-3
@@ -15,12 +15,12 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.datatypes;
|
||||
package baritone.api.command.datatypes;
|
||||
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.pathing.goals.GoalYLevel;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.exception;
|
||||
package baritone.api.command.exception;
|
||||
|
||||
public abstract class CommandErrorMessageException extends CommandException {
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.exception;
|
||||
package baritone.api.command.exception;
|
||||
|
||||
public abstract class CommandException extends Exception implements ICommandException {
|
||||
|
||||
+2
-2
@@ -15,9 +15,9 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.exception;
|
||||
package baritone.api.command.exception;
|
||||
|
||||
import baritone.api.utils.command.argument.ICommandArgument;
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
|
||||
public abstract class CommandInvalidArgumentException extends CommandErrorMessageException {
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.exception;
|
||||
package baritone.api.command.exception;
|
||||
|
||||
public class CommandInvalidStateException extends CommandErrorMessageException {
|
||||
|
||||
+2
-2
@@ -15,9 +15,9 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.exception;
|
||||
package baritone.api.command.exception;
|
||||
|
||||
import baritone.api.utils.command.argument.ICommandArgument;
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
|
||||
public class CommandInvalidTypeException extends CommandInvalidArgumentException {
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.exception;
|
||||
package baritone.api.command.exception;
|
||||
|
||||
public class CommandNoParserForTypeException extends CommandUnhandledException {
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.exception;
|
||||
package baritone.api.command.exception;
|
||||
|
||||
public class CommandNotEnoughArgumentsException extends CommandErrorMessageException {
|
||||
|
||||
+3
-3
@@ -15,10 +15,10 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.exception;
|
||||
package baritone.api.command.exception;
|
||||
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.argument.ICommandArgument;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.exception;
|
||||
package baritone.api.command.exception;
|
||||
|
||||
public class CommandTooManyArgumentsException extends CommandErrorMessageException {
|
||||
|
||||
+3
-3
@@ -15,10 +15,10 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.exception;
|
||||
package baritone.api.command.exception;
|
||||
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.argument.ICommandArgument;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import java.util.List;
|
||||
+3
-3
@@ -15,10 +15,10 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.exception;
|
||||
package baritone.api.command.exception;
|
||||
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.argument.ICommandArgument;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import java.util.List;
|
||||
+11
-11
@@ -15,19 +15,19 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.helpers.arguments;
|
||||
package baritone.api.command.helpers.arguments;
|
||||
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandTooManyArgumentsException;
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.argparser.IArgParser;
|
||||
import baritone.api.utils.command.argument.ICommandArgument;
|
||||
import baritone.api.utils.command.datatypes.IDatatype;
|
||||
import baritone.api.utils.command.datatypes.IDatatypeFor;
|
||||
import baritone.api.utils.command.datatypes.IDatatypePost;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.command.exception.CommandNotEnoughArgumentsException;
|
||||
import baritone.api.utils.command.exception.CommandTooManyArgumentsException;
|
||||
import baritone.api.command.argparser.IArgParser;
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
import baritone.api.command.datatypes.IDatatype;
|
||||
import baritone.api.command.datatypes.IDatatypeFor;
|
||||
import baritone.api.command.datatypes.IDatatypePost;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.command.exception.CommandNotEnoughArgumentsException;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import java.util.Deque;
|
||||
+4
-4
@@ -15,12 +15,12 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.helpers.pagination;
|
||||
package baritone.api.command.helpers.pagination;
|
||||
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
+4
-4
@@ -15,14 +15,14 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.helpers.tabcomplete;
|
||||
package baritone.api.command.helpers.tabcomplete;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.event.events.TabCompleteEvent;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.utils.command.manager.ICommandManager;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.manager.ICommandManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.Comparator;
|
||||
@@ -241,7 +241,7 @@ public class TabCompleteHelper {
|
||||
*/
|
||||
public TabCompleteHelper addCommands(ICommandManager manager) {
|
||||
return append(manager.getRegistry().descendingStream()
|
||||
.flatMap(command -> command.names.stream())
|
||||
.flatMap(command -> command.getNames().stream())
|
||||
.distinct()
|
||||
);
|
||||
}
|
||||
+4
-4
@@ -15,12 +15,12 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.manager;
|
||||
package baritone.api.command.manager;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.argument.ICommandArgument;
|
||||
import baritone.api.utils.command.registry.Registry;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
import baritone.api.command.registry.Registry;
|
||||
import net.minecraft.util.Tuple;
|
||||
|
||||
import java.util.List;
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.registry;
|
||||
package baritone.api.command.registry;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package baritone.api.process;
|
||||
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
/**
|
||||
@@ -24,7 +25,11 @@ import net.minecraft.block.Block;
|
||||
*/
|
||||
public interface IGetToBlockProcess extends IBaritoneProcess {
|
||||
|
||||
void getToBlock(Block block);
|
||||
void getToBlock(BlockOptionalMeta block);
|
||||
|
||||
default void getToBlock(Block block) {
|
||||
getToBlock(new BlockOptionalMeta(block));
|
||||
}
|
||||
|
||||
boolean blacklistClosest();
|
||||
}
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* 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.api.utils.command.argparser;
|
||||
|
||||
import baritone.api.utils.command.argument.ICommandArgument;
|
||||
import baritone.api.utils.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.command.exception.CommandNoParserForTypeException;
|
||||
import baritone.api.utils.command.registry.Registry;
|
||||
|
||||
public class ArgParserManager {
|
||||
|
||||
public static final Registry<IArgParser> REGISTRY = new Registry<>();
|
||||
|
||||
static {
|
||||
DefaultArgParsers.ALL.forEach(REGISTRY::register);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type The type trying to be parsed
|
||||
* @return A parser that can parse arguments into this class, if found.
|
||||
*/
|
||||
public static <T> IArgParser.Stateless<T> getParserStateless(Class<T> type) {
|
||||
//noinspection unchecked
|
||||
return REGISTRY.descendingStream()
|
||||
.filter(IArgParser.Stateless.class::isInstance)
|
||||
.map(IArgParser.Stateless.class::cast)
|
||||
.filter(parser -> parser.getTarget().isAssignableFrom(type))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type The type trying to be parsed
|
||||
* @return A parser that can parse arguments into this class, if found.
|
||||
*/
|
||||
public static <T, S> IArgParser.Stated<T, S> getParserStated(Class<T> type, Class<S> stateKlass) {
|
||||
//noinspection unchecked
|
||||
return REGISTRY.descendingStream()
|
||||
.filter(IArgParser.Stated.class::isInstance)
|
||||
.map(IArgParser.Stated.class::cast)
|
||||
.filter(parser -> parser.getTarget().isAssignableFrom(type))
|
||||
.filter(parser -> parser.getStateType().isAssignableFrom(stateKlass))
|
||||
.map(IArgParser.Stated.class::cast)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to parse the specified argument with a stateless {@link IArgParser} that outputs the specified class.
|
||||
*
|
||||
* @param type The type to try and parse the argument into.
|
||||
* @param arg The argument to parse.
|
||||
* @return An instance of the specified class.
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
*/
|
||||
public static <T> T parseStateless(Class<T> type, ICommandArgument arg) throws CommandInvalidTypeException {
|
||||
IArgParser.Stateless<T> parser = getParserStateless(type);
|
||||
if (parser == null) {
|
||||
throw new CommandNoParserForTypeException(type);
|
||||
}
|
||||
try {
|
||||
return parser.parseArg(arg);
|
||||
} catch (Exception exc) {
|
||||
throw new CommandInvalidTypeException(arg, type.getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to parse the specified argument with a stated {@link IArgParser} that outputs the specified class.
|
||||
*
|
||||
* @param type The type to try and parse the argument into.
|
||||
* @param arg The argument to parse.
|
||||
* @param state The state to pass to the {@link IArgParser.Stated}.
|
||||
* @return An instance of the specified class.
|
||||
* @throws CommandInvalidTypeException If the parsing failed
|
||||
* @see IArgParser.Stated
|
||||
*/
|
||||
public static <T, S> T parseStated(Class<T> type, Class<S> stateKlass, ICommandArgument arg, S state) throws CommandInvalidTypeException {
|
||||
IArgParser.Stated<T, S> parser = getParserStated(type, stateKlass);
|
||||
if (parser == null) {
|
||||
throw new CommandNoParserForTypeException(type);
|
||||
}
|
||||
try {
|
||||
return parser.parseArg(arg, state);
|
||||
} catch (Exception exc) {
|
||||
throw new CommandInvalidTypeException(arg, type.getSimpleName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,11 +25,11 @@ import baritone.api.utils.Helper;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import baritone.behavior.*;
|
||||
import baritone.cache.WorldProvider;
|
||||
import baritone.command.manager.CommandManager;
|
||||
import baritone.event.GameEventHandler;
|
||||
import baritone.process.*;
|
||||
import baritone.selection.SelectionManager;
|
||||
import baritone.utils.*;
|
||||
import baritone.utils.command.manager.CommandManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -19,12 +19,14 @@ package baritone;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.IBaritoneProvider;
|
||||
import baritone.api.bot.IBaritoneUser;
|
||||
import baritone.api.bot.IUserManager;
|
||||
import baritone.api.cache.IWorldScanner;
|
||||
import baritone.api.bot.IBaritoneUser;
|
||||
import baritone.api.command.ICommandSystem;
|
||||
import baritone.bot.UserManager;
|
||||
import baritone.utils.command.BaritoneChatControl;
|
||||
import baritone.cache.WorldScanner;
|
||||
import baritone.command.BaritoneChatControl;
|
||||
import baritone.command.CommandSystem;
|
||||
import baritone.utils.player.PrimaryPlayerContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -69,4 +71,9 @@ public final class BaritoneProvider implements IBaritoneProvider {
|
||||
public IUserManager getUserManager() {
|
||||
return UserManager.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICommandSystem getCommandSystem() {
|
||||
return CommandSystem.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
+10
-10
@@ -15,7 +15,7 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command;
|
||||
package baritone.command;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
@@ -26,14 +26,14 @@ import baritone.api.event.events.TabCompleteEvent;
|
||||
import baritone.api.event.listener.AbstractGameEventListener;
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.command.argument.ICommandArgument;
|
||||
import baritone.api.utils.command.exception.CommandNotEnoughArgumentsException;
|
||||
import baritone.api.utils.command.exception.CommandNotFoundException;
|
||||
import baritone.utils.command.helpers.arguments.ArgConsumer;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.api.utils.command.manager.ICommandManager;
|
||||
import baritone.utils.command.argument.CommandArguments;
|
||||
import baritone.utils.command.manager.CommandManager;
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
import baritone.api.command.exception.CommandNotEnoughArgumentsException;
|
||||
import baritone.api.command.exception.CommandNotFoundException;
|
||||
import baritone.command.helpers.arguments.ArgConsumer;
|
||||
import baritone.api.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.api.command.manager.ICommandManager;
|
||||
import baritone.command.argument.CommandArguments;
|
||||
import baritone.command.manager.CommandManager;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
@@ -47,7 +47,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static baritone.api.utils.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
|
||||
public class BaritoneChatControl implements Helper, AbstractGameEventListener {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.command;
|
||||
|
||||
import baritone.api.command.ICommandSystem;
|
||||
import baritone.command.argparser.ArgParserManager;
|
||||
import baritone.api.command.argparser.IArgParserManager;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 10/4/2019
|
||||
*/
|
||||
public enum CommandSystem implements ICommandSystem {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public IArgParserManager getParserManager() {
|
||||
return ArgParserManager.INSTANCE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.command.argparser;
|
||||
|
||||
import baritone.api.command.argparser.IArgParser;
|
||||
import baritone.api.command.argparser.IArgParserManager;
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.command.exception.CommandNoParserForTypeException;
|
||||
import baritone.api.command.registry.Registry;
|
||||
|
||||
public enum ArgParserManager implements IArgParserManager {
|
||||
INSTANCE;
|
||||
|
||||
public final Registry<IArgParser> registry = new Registry<>();
|
||||
|
||||
ArgParserManager() {
|
||||
DefaultArgParsers.ALL.forEach(this.registry::register);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> IArgParser.Stateless<T> getParserStateless(Class<T> type) {
|
||||
//noinspection unchecked
|
||||
return this.registry.descendingStream()
|
||||
.filter(IArgParser.Stateless.class::isInstance)
|
||||
.map(IArgParser.Stateless.class::cast)
|
||||
.filter(parser -> parser.getTarget().isAssignableFrom(type))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T, S> IArgParser.Stated<T, S> getParserStated(Class<T> type, Class<S> stateKlass) {
|
||||
//noinspection unchecked
|
||||
return this.registry.descendingStream()
|
||||
.filter(IArgParser.Stated.class::isInstance)
|
||||
.map(IArgParser.Stated.class::cast)
|
||||
.filter(parser -> parser.getTarget().isAssignableFrom(type))
|
||||
.filter(parser -> parser.getStateType().isAssignableFrom(stateKlass))
|
||||
.map(IArgParser.Stated.class::cast)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T parseStateless(Class<T> type, ICommandArgument arg) throws CommandInvalidTypeException {
|
||||
IArgParser.Stateless<T> parser = this.getParserStateless(type);
|
||||
if (parser == null) {
|
||||
throw new CommandNoParserForTypeException(type);
|
||||
}
|
||||
try {
|
||||
return parser.parseArg(arg);
|
||||
} catch (Exception exc) {
|
||||
throw new CommandInvalidTypeException(arg, type.getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T, S> T parseStated(Class<T> type, Class<S> stateKlass, ICommandArgument arg, S state) throws CommandInvalidTypeException {
|
||||
IArgParser.Stated<T, S> parser = this.getParserStated(type, stateKlass);
|
||||
if (parser == null) {
|
||||
throw new CommandNoParserForTypeException(type);
|
||||
}
|
||||
try {
|
||||
return parser.parseArg(arg, state);
|
||||
} catch (Exception exc) {
|
||||
throw new CommandInvalidTypeException(arg, type.getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Registry<IArgParser> getRegistry() {
|
||||
return this.registry;
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -15,9 +15,10 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils.command.argparser;
|
||||
package baritone.command.argparser;
|
||||
|
||||
import baritone.api.utils.command.argument.ICommandArgument;
|
||||
import baritone.api.command.argparser.IArgParser;
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
+6
-7
@@ -15,12 +15,11 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.argument;
|
||||
package baritone.command.argument;
|
||||
|
||||
import baritone.api.utils.command.argparser.ArgParserManager;
|
||||
import baritone.api.utils.command.argument.ICommandArgument;
|
||||
import baritone.api.utils.command.exception.CommandInvalidArgumentException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidTypeException;
|
||||
import baritone.command.argparser.ArgParserManager;
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -66,7 +65,7 @@ class CommandArgument implements ICommandArgument {
|
||||
|
||||
@Override
|
||||
public <T> T getAs(Class<T> type) throws CommandInvalidTypeException {
|
||||
return ArgParserManager.parseStateless(type, this);
|
||||
return ArgParserManager.INSTANCE.parseStateless(type, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,7 +81,7 @@ class CommandArgument implements ICommandArgument {
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
@Override
|
||||
public <T, S> T getAs(Class<T> type, Class<S> stateType, S state) throws CommandInvalidTypeException {
|
||||
return ArgParserManager.parseStated(type, stateType, this, state);
|
||||
return ArgParserManager.INSTANCE.parseStated(type, stateType, this, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
+3
-3
@@ -15,10 +15,10 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.argument;
|
||||
package baritone.command.argument;
|
||||
|
||||
import baritone.api.utils.command.argument.ICommandArgument;
|
||||
import baritone.api.utils.command.exception.CommandInvalidArgumentException;
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
import baritone.api.command.exception.CommandInvalidArgumentException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
+5
-5
@@ -15,14 +15,14 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalAxis;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -31,7 +31,7 @@ import java.util.stream.Stream;
|
||||
public class AxisCommand extends Command {
|
||||
|
||||
public AxisCommand(IBaritone baritone) {
|
||||
super(baritone, Arrays.asList("axis", "highway"));
|
||||
super(baritone, "axis", "highway");
|
||||
}
|
||||
|
||||
@Override
|
||||
+5
-5
@@ -15,14 +15,14 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.process.IGetToBlockProcess;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
+7
-7
@@ -15,16 +15,16 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
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.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.datatypes.RelativeBlockPos;
|
||||
import baritone.api.command.datatypes.RelativeFile;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.io.File;
|
||||
+5
-5
@@ -15,12 +15,12 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -29,7 +29,7 @@ import java.util.stream.Stream;
|
||||
public class CancelCommand extends Command {
|
||||
|
||||
public CancelCommand(IBaritone baritone) {
|
||||
super(baritone, Arrays.asList("cancel", "stop"));
|
||||
super(baritone, "cancel", "stop");
|
||||
}
|
||||
|
||||
@Override
|
||||
+5
-5
@@ -15,15 +15,15 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.cache.IRememberedInventory;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
+4
-4
@@ -15,12 +15,12 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
+5
-5
@@ -15,14 +15,14 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
+4
-4
@@ -15,11 +15,11 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -31,7 +31,7 @@ public class CommandAlias extends Command {
|
||||
public final String target;
|
||||
|
||||
public CommandAlias(IBaritone baritone, List<String> names, String shortDesc, String target) {
|
||||
super(baritone, names);
|
||||
super(baritone, names.toArray(new String[0]));
|
||||
this.shortDesc = shortDesc;
|
||||
this.target = target;
|
||||
}
|
||||
+3
-2
@@ -15,10 +15,10 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.command.Command;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -34,6 +34,7 @@ public final class DefaultCommands {
|
||||
new CommandAlias(baritone, Arrays.asList("modified", "mod", "baritone", "modifiedsettings"), "List modified settings", "set modified"),
|
||||
new CommandAlias(baritone, "reset", "Reset all settings or just one", "set reset"),
|
||||
new GoalCommand(baritone),
|
||||
new GotoCommand(baritone),
|
||||
new PathCommand(baritone),
|
||||
new ProcCommand(baritone),
|
||||
new VersionCommand(baritone),
|
||||
+5
-5
@@ -15,14 +15,14 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.RelativeGoalXZ;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.datatypes.RelativeGoalXZ;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
+7
-7
@@ -15,15 +15,15 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.RelativeFile;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.datatypes.RelativeFile;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import java.io.File;
|
||||
+4
-4
@@ -15,12 +15,12 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
+5
-5
@@ -15,14 +15,14 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.BlockById;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.datatypes.BlockById;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
+8
-8
@@ -15,16 +15,16 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.datatypes.EntityClassById;
|
||||
import baritone.api.utils.command.datatypes.IDatatypeFor;
|
||||
import baritone.api.utils.command.datatypes.NearbyPlayer;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.datatypes.EntityClassById;
|
||||
import baritone.api.command.datatypes.IDatatypeFor;
|
||||
import baritone.api.command.datatypes.NearbyPlayer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
+4
-4
@@ -15,13 +15,13 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.behavior.IPathingBehavior;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
+4
-4
@@ -15,12 +15,12 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
+7
-7
@@ -15,18 +15,18 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
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.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.datatypes.RelativeCoordinate;
|
||||
import baritone.api.command.datatypes.RelativeGoal;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.datatypes.BlockById;
|
||||
import baritone.api.command.datatypes.ForBlockOptionalMeta;
|
||||
import baritone.api.command.datatypes.RelativeCoordinate;
|
||||
import baritone.api.command.datatypes.RelativeGoal;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class GotoCommand extends Command {
|
||||
|
||||
protected GotoCommand(IBaritone baritone) {
|
||||
super(baritone, "goto");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||
if (args.peekDatatypeOrNull(RelativeCoordinate.INSTANCE) != null) { // if we have a numeric first argument...
|
||||
BetterBlockPos origin = baritone.getPlayerContext().playerFeet();
|
||||
Goal goal = args.getDatatypePostOrNull(RelativeGoal.INSTANCE, origin);
|
||||
logDirect(String.format("Going to: %s", goal.toString()));
|
||||
baritone.getCustomGoalProcess().setGoalAndPath(goal);
|
||||
return;
|
||||
}
|
||||
args.requireMax(1);
|
||||
BlockOptionalMeta destination = args.getDatatypeFor(ForBlockOptionalMeta.INSTANCE);
|
||||
baritone.getGetToBlockProcess().getToBlock(destination);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(String label, IArgConsumer args) throws CommandException {
|
||||
// since it's either a goal or a block, I don't think we can tab complete properly?
|
||||
// so just tab complete for the block variant
|
||||
return args.tabCompleteDatatype(BlockById.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getShortDesc() {
|
||||
return "Go to a coordinate or block";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return Arrays.asList(
|
||||
"The got command tells Baritone to head towards a given goal or block.",
|
||||
"",
|
||||
"Wherever a coordinate is expected, you can use ~ just like in regular Minecraft commands. Or, you can just use regular numbers.",
|
||||
"",
|
||||
"Usage:",
|
||||
"> goto <block> - Go to a block, wherever it is in the world",
|
||||
"> goto <y> - Go to a Y level",
|
||||
"> goto <x> <z> - Go to an X,Z position",
|
||||
"> goto <x> <y> <z> - Go to an X,Y,Z position"
|
||||
);
|
||||
}
|
||||
}
|
||||
+13
-13
@@ -15,15 +15,15 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandNotFoundException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.utils.command.helpers.pagination.Paginator;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandNotFoundException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.helpers.pagination.Paginator;
|
||||
import baritone.api.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
@@ -35,12 +35,12 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static baritone.api.utils.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
|
||||
public class HelpCommand extends Command {
|
||||
|
||||
public HelpCommand(IBaritone baritone) {
|
||||
super(baritone, Arrays.asList("help", "?"));
|
||||
super(baritone, "help", "?");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,8 +55,8 @@ public class HelpCommand extends Command {
|
||||
),
|
||||
() -> logDirect("All Baritone commands (clickable):"),
|
||||
command -> {
|
||||
String names = String.join("/", command.names);
|
||||
String name = command.names.get(0);
|
||||
String names = String.join("/", command.getNames());
|
||||
String name = command.getNames().get(0);
|
||||
ITextComponent shortDescComponent = new TextComponentString(" - " + command.getShortDesc());
|
||||
shortDescComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
|
||||
ITextComponent namesComponent = new TextComponentString(names);
|
||||
@@ -66,7 +66,7 @@ public class HelpCommand extends Command {
|
||||
hoverComponent.appendSibling(namesComponent);
|
||||
hoverComponent.appendText("\n" + command.getShortDesc());
|
||||
hoverComponent.appendText("\n\nClick to view full help");
|
||||
String clickCommand = FORCE_COMMAND_PREFIX + String.format("%s %s", label, command.names.get(0));
|
||||
String clickCommand = FORCE_COMMAND_PREFIX + String.format("%s %s", label, command.getNames().get(0));
|
||||
ITextComponent component = new TextComponentString(name);
|
||||
component.getStyle().setColor(TextFormatting.GRAY);
|
||||
component.appendSibling(shortDescComponent);
|
||||
@@ -83,7 +83,7 @@ public class HelpCommand extends Command {
|
||||
if (command == null) {
|
||||
throw new CommandNotFoundException(commandName);
|
||||
}
|
||||
logDirect(String.format("%s - %s", String.join(" / ", command.names), command.getShortDesc()));
|
||||
logDirect(String.format("%s - %s", String.join(" / ", command.getNames()), command.getShortDesc()));
|
||||
logDirect("");
|
||||
command.getLongDesc().forEach(this::logDirect);
|
||||
logDirect("");
|
||||
+5
-5
@@ -15,16 +15,16 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
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.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
+6
-6
@@ -15,15 +15,15 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
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.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.datatypes.BlockById;
|
||||
import baritone.api.command.datatypes.ForBlockOptionalMeta;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.cache.WorldScanner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
+8
-37
@@ -15,18 +15,13 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
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.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.cache.WorldScanner;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -36,47 +31,26 @@ import java.util.stream.Stream;
|
||||
public class PathCommand extends Command {
|
||||
|
||||
public PathCommand(IBaritone baritone) {
|
||||
super(baritone, Arrays.asList("path", "goto"));
|
||||
super(baritone, "path");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||
ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
|
||||
Goal goal;
|
||||
if (args.hasAny()) {
|
||||
args.requireMax(3);
|
||||
goal = args.getDatatypePost(RelativeGoal.INSTANCE, ctx.playerFeet());
|
||||
} else if ((goal = customGoalProcess.getGoal()) == null) {
|
||||
throw new CommandInvalidStateException("No goal");
|
||||
}
|
||||
args.requireMax(0);
|
||||
WorldScanner.INSTANCE.repack(ctx);
|
||||
customGoalProcess.setGoalAndPath(goal);
|
||||
customGoalProcess.path();
|
||||
logDirect("Now pathing");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(String label, IArgConsumer args) throws CommandException {
|
||||
if (args.hasAny() && !args.has(4)) {
|
||||
while (args.has(2)) {
|
||||
if (args.peekDatatypeOrNull(RelativeCoordinate.INSTANCE) == null) {
|
||||
break;
|
||||
}
|
||||
args.get();
|
||||
if (!args.has(2)) {
|
||||
return new TabCompleteHelper()
|
||||
.append("~")
|
||||
.filterPrefix(args.getString())
|
||||
.stream();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getShortDesc() {
|
||||
return "Start heading towards a goal";
|
||||
return "Start heading towards the goal";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,10 +59,7 @@ public class PathCommand extends Command {
|
||||
"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"
|
||||
"> path - Start the pathing."
|
||||
);
|
||||
}
|
||||
}
|
||||
+6
-5
@@ -15,16 +15,16 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
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.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -114,6 +114,7 @@ public class PauseResumeCommands {
|
||||
@Override
|
||||
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||
args.requireMax(0);
|
||||
baritone.getBuilderProcess().resume();
|
||||
if (!paused[0]) {
|
||||
throw new CommandInvalidStateException("Not paused");
|
||||
}
|
||||
+5
-5
@@ -15,16 +15,16 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
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.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
+4
-4
@@ -15,12 +15,12 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
+4
-4
@@ -15,13 +15,13 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
+5
-5
@@ -15,12 +15,12 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.cache.WorldScanner;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -30,7 +30,7 @@ import java.util.stream.Stream;
|
||||
public class RepackCommand extends Command {
|
||||
|
||||
public RepackCommand(IBaritone baritone) {
|
||||
super(baritone, Arrays.asList("repack", "rescan"));
|
||||
super(baritone, "repack", "rescan");
|
||||
}
|
||||
|
||||
@Override
|
||||
+4
-4
@@ -15,12 +15,12 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
+4
-4
@@ -15,12 +15,12 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
+11
-11
@@ -15,7 +15,7 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.IBaritone;
|
||||
@@ -28,15 +28,15 @@ import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
import baritone.api.utils.BlockOptionalMetaLookup;
|
||||
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.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.datatypes.ForBlockOptionalMeta;
|
||||
import baritone.api.command.datatypes.ForEnumFacing;
|
||||
import baritone.api.command.datatypes.RelativeBlockPos;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.utils.IRenderer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -56,7 +56,7 @@ public class SelCommand extends Command {
|
||||
private BetterBlockPos pos1 = null;
|
||||
|
||||
public SelCommand(IBaritone baritone) {
|
||||
super(baritone, Arrays.asList("sel", "selection", "s"));
|
||||
super(baritone, "sel", "selection", "s");
|
||||
baritone.getGameEventHandler().registerEventListener(new AbstractGameEventListener() {
|
||||
@Override
|
||||
public void onRenderPass(RenderEvent event) {
|
||||
+9
-9
@@ -15,18 +15,18 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.utils.command.helpers.pagination.Paginator;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.helpers.pagination.Paginator;
|
||||
import baritone.api.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
@@ -41,12 +41,12 @@ import java.util.stream.Stream;
|
||||
|
||||
import static baritone.api.utils.SettingsUtil.settingTypeToString;
|
||||
import static baritone.api.utils.SettingsUtil.settingValueToString;
|
||||
import static baritone.api.utils.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
|
||||
public class SetCommand extends Command {
|
||||
|
||||
public SetCommand(IBaritone baritone) {
|
||||
super(baritone, Arrays.asList("set", "setting", "settings"));
|
||||
super(baritone, "set", "setting", "settings");
|
||||
}
|
||||
|
||||
@Override
|
||||
+5
-5
@@ -15,13 +15,13 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -30,7 +30,7 @@ import java.util.stream.Stream;
|
||||
public class ThisWayCommand extends Command {
|
||||
|
||||
public ThisWayCommand(IBaritone baritone) {
|
||||
super(baritone, Arrays.asList("thisway", "forward"));
|
||||
super(baritone, "thisway", "forward");
|
||||
}
|
||||
|
||||
@Override
|
||||
+4
-4
@@ -15,14 +15,14 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalStrictDirection;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
+5
-5
@@ -15,13 +15,13 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
+12
-12
@@ -15,7 +15,7 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.defaults;
|
||||
package baritone.command.defaults;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.cache.IWaypoint;
|
||||
@@ -23,15 +23,15 @@ 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.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.utils.command.helpers.pagination.Paginator;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.datatypes.ForWaypoints;
|
||||
import baritone.api.command.datatypes.RelativeBlockPos;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.helpers.pagination.Paginator;
|
||||
import baritone.api.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
@@ -43,12 +43,12 @@ import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static baritone.api.utils.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
|
||||
public class WaypointsCommand extends Command {
|
||||
|
||||
public WaypointsCommand(IBaritone baritone) {
|
||||
super(baritone, Arrays.asList("waypoints", "waypoint", "wp"));
|
||||
super(baritone, "waypoints", "waypoint", "wp");
|
||||
}
|
||||
|
||||
@Override
|
||||
+13
-13
@@ -15,21 +15,21 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.helpers.arguments;
|
||||
package baritone.command.helpers.arguments;
|
||||
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.command.argument.ICommandArgument;
|
||||
import baritone.api.utils.command.datatypes.IDatatype;
|
||||
import baritone.api.utils.command.datatypes.IDatatypeContext;
|
||||
import baritone.api.utils.command.datatypes.IDatatypeFor;
|
||||
import baritone.api.utils.command.datatypes.IDatatypePost;
|
||||
import baritone.api.utils.command.exception.CommandException;
|
||||
import baritone.api.utils.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.command.exception.CommandNotEnoughArgumentsException;
|
||||
import baritone.api.utils.command.exception.CommandTooManyArgumentsException;
|
||||
import baritone.api.utils.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.utils.command.manager.ICommandManager;
|
||||
import baritone.utils.command.argument.CommandArguments;
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
import baritone.api.command.datatypes.IDatatype;
|
||||
import baritone.api.command.datatypes.IDatatypeContext;
|
||||
import baritone.api.command.datatypes.IDatatypeFor;
|
||||
import baritone.api.command.datatypes.IDatatypePost;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.command.exception.CommandNotEnoughArgumentsException;
|
||||
import baritone.api.command.exception.CommandTooManyArgumentsException;
|
||||
import baritone.api.command.helpers.arguments.IArgConsumer;
|
||||
import baritone.api.command.manager.ICommandManager;
|
||||
import baritone.command.argument.CommandArguments;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
+12
-12
@@ -15,20 +15,20 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.command.manager;
|
||||
package baritone.command.manager;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.utils.command.Command;
|
||||
import baritone.api.utils.command.argument.ICommandArgument;
|
||||
import baritone.api.utils.command.exception.CommandUnhandledException;
|
||||
import baritone.api.utils.command.exception.ICommandException;
|
||||
import baritone.utils.command.helpers.arguments.ArgConsumer;
|
||||
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.api.utils.command.manager.ICommandManager;
|
||||
import baritone.api.utils.command.registry.Registry;
|
||||
import baritone.utils.command.argument.CommandArguments;
|
||||
import baritone.utils.command.defaults.DefaultCommands;
|
||||
import baritone.api.command.Command;
|
||||
import baritone.api.command.argument.ICommandArgument;
|
||||
import baritone.api.command.exception.CommandUnhandledException;
|
||||
import baritone.api.command.exception.ICommandException;
|
||||
import baritone.command.helpers.arguments.ArgConsumer;
|
||||
import baritone.api.command.helpers.tabcomplete.TabCompleteHelper;
|
||||
import baritone.api.command.manager.ICommandManager;
|
||||
import baritone.api.command.registry.Registry;
|
||||
import baritone.command.argument.CommandArguments;
|
||||
import baritone.command.defaults.DefaultCommands;
|
||||
import net.minecraft.util.Tuple;
|
||||
|
||||
import java.util.List;
|
||||
@@ -64,7 +64,7 @@ public class CommandManager implements ICommandManager {
|
||||
@Override
|
||||
public Command getCommand(String name) {
|
||||
for (Command command : this.registry.entries) {
|
||||
if (command.names.contains(name.toLowerCase(Locale.US))) {
|
||||
if (command.getNames().contains(name.toLowerCase(Locale.US))) {
|
||||
return command;
|
||||
}
|
||||
}
|
||||
@@ -135,7 +135,7 @@ public class CalculationContext {
|
||||
return get(x, y, z).getBlock();
|
||||
}
|
||||
|
||||
public double costOfPlacingAt(int x, int y, int z) {
|
||||
public double costOfPlacingAt(int x, int y, int z, IBlockState current) {
|
||||
if (!hasThrowaway) { // only true if allowPlace is true, see constructor
|
||||
return COST_INF;
|
||||
}
|
||||
@@ -149,7 +149,7 @@ public class CalculationContext {
|
||||
return placeBlockCost;
|
||||
}
|
||||
|
||||
public double breakCostMultiplierAt(int x, int y, int z) {
|
||||
public double breakCostMultiplierAt(int x, int y, int z, IBlockState current) {
|
||||
if (!allowBreak) {
|
||||
return COST_INF;
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
if (block instanceof BlockLiquid) {
|
||||
return COST_INF;
|
||||
}
|
||||
double mult = context.breakCostMultiplierAt(x, y, z);
|
||||
double mult = context.breakCostMultiplierAt(x, y, z, state);
|
||||
if (mult >= COST_INF) {
|
||||
return COST_INF;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class MovementAscend extends Movement {
|
||||
IBlockState toPlace = context.get(destX, y, destZ);
|
||||
double additionalPlacementCost = 0;
|
||||
if (!MovementHelper.canWalkOn(context.bsi, destX, y, destZ, toPlace)) {
|
||||
additionalPlacementCost = context.costOfPlacingAt(destX, y, destZ);
|
||||
additionalPlacementCost = context.costOfPlacingAt(destX, y, destZ, toPlace);
|
||||
if (additionalPlacementCost >= COST_INF) {
|
||||
return COST_INF;
|
||||
}
|
||||
|
||||
@@ -147,11 +147,11 @@ public class MovementParkour extends Movement {
|
||||
// time 2 pop off with that dank skynet parkour place
|
||||
int destX = x + 4 * xDiff;
|
||||
int destZ = z + 4 * zDiff;
|
||||
double placeCost = context.costOfPlacingAt(destX, y - 1, destZ);
|
||||
IBlockState toReplace = context.get(destX, y - 1, destZ);
|
||||
double placeCost = context.costOfPlacingAt(destX, y - 1, destZ, toReplace);
|
||||
if (placeCost >= COST_INF) {
|
||||
return;
|
||||
}
|
||||
IBlockState toReplace = context.get(destX, y - 1, destZ);
|
||||
if (!MovementHelper.isReplaceable(destX, y - 1, destZ, toReplace, context.bsi)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,8 @@ public class MovementPillar extends Movement {
|
||||
}
|
||||
|
||||
public static double cost(CalculationContext context, int x, int y, int z) {
|
||||
Block from = context.get(x, y, z).getBlock();
|
||||
IBlockState fromState = context.get(x, y, z);
|
||||
Block from = fromState.getBlock();
|
||||
boolean ladder = from == Blocks.LADDER || from == Blocks.VINE;
|
||||
IBlockState fromDown = context.get(x, y - 1, z);
|
||||
if (!ladder) {
|
||||
@@ -86,7 +87,7 @@ public class MovementPillar extends Movement {
|
||||
double placeCost = 0;
|
||||
if (!ladder) {
|
||||
// we need to place a block where we started to jump on it
|
||||
placeCost = context.costOfPlacingAt(x, y, z);
|
||||
placeCost = context.costOfPlacingAt(x, y, z, fromState);
|
||||
if (placeCost >= COST_INF) {
|
||||
return COST_INF;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public class MovementTraverse extends Movement {
|
||||
// this happens when assume walk on water is true and this is a traverse in water, which isn't allowed
|
||||
return COST_INF;
|
||||
}
|
||||
double placeCost = context.costOfPlacingAt(destX, y - 1, destZ);
|
||||
double placeCost = context.costOfPlacingAt(destX, y - 1, destZ, destOn);
|
||||
if (placeCost >= COST_INF) {
|
||||
return COST_INF;
|
||||
}
|
||||
|
||||
@@ -791,11 +791,11 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
}
|
||||
|
||||
@Override
|
||||
public double costOfPlacingAt(int x, int y, int z) {
|
||||
public double costOfPlacingAt(int x, int y, int z, IBlockState current) {
|
||||
if (isPossiblyProtected(x, y, z) || !worldBorder.canPlaceAt(x, z)) { // make calculation fail properly if we can't build
|
||||
return COST_INF;
|
||||
}
|
||||
IBlockState sch = getSchematic(x, y, z, bsi.get0(x, y, z));
|
||||
IBlockState sch = getSchematic(x, y, z, current);
|
||||
if (sch != null) {
|
||||
// TODO this can return true even when allowPlace is off.... is that an issue?
|
||||
if (sch.getBlock() == Blocks.AIR) {
|
||||
@@ -825,11 +825,11 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
}
|
||||
|
||||
@Override
|
||||
public double breakCostMultiplierAt(int x, int y, int z) {
|
||||
public double breakCostMultiplierAt(int x, int y, int z, IBlockState current) {
|
||||
if (!allowBreak || isPossiblyProtected(x, y, z)) {
|
||||
return COST_INF;
|
||||
}
|
||||
IBlockState sch = getSchematic(x, y, z, bsi.get0(x, y, z));
|
||||
IBlockState sch = getSchematic(x, y, z, current);
|
||||
if (sch != null) {
|
||||
if (sch.getBlock() == Blocks.AIR) {
|
||||
// it should be air
|
||||
|
||||
@@ -22,6 +22,7 @@ import baritone.api.pathing.goals.*;
|
||||
import baritone.api.process.IGetToBlockProcess;
|
||||
import baritone.api.process.PathingCommand;
|
||||
import baritone.api.process.PathingCommandType;
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
import baritone.api.utils.BlockOptionalMetaLookup;
|
||||
import baritone.api.utils.Rotation;
|
||||
import baritone.api.utils.RotationUtils;
|
||||
@@ -33,14 +34,11 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.ContainerPlayer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
|
||||
public final class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBlockProcess {
|
||||
|
||||
private Block gettingTo;
|
||||
private BlockOptionalMeta gettingTo;
|
||||
private List<BlockPos> knownLocations;
|
||||
private List<BlockPos> blacklist; // locations we failed to calc to
|
||||
private BlockPos start;
|
||||
@@ -53,7 +51,7 @@ public final class GetToBlockProcess extends BaritoneProcessHelper implements IG
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getToBlock(Block block) {
|
||||
public void getToBlock(BlockOptionalMeta block) {
|
||||
onLostControl();
|
||||
gettingTo = block;
|
||||
start = ctx.playerFeet();
|
||||
@@ -109,7 +107,7 @@ public final class GetToBlockProcess extends BaritoneProcessHelper implements IG
|
||||
}
|
||||
if (goal.isInGoal(ctx.playerFeet()) && goal.isInGoal(baritone.getPathingBehavior().pathStart()) && isSafeToCancel) {
|
||||
// we're there
|
||||
if (rightClickOnArrival(gettingTo)) {
|
||||
if (rightClickOnArrival(gettingTo.getBlock())) {
|
||||
if (rightClick()) {
|
||||
onLostControl();
|
||||
return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL);
|
||||
@@ -175,16 +173,16 @@ public final class GetToBlockProcess extends BaritoneProcessHelper implements IG
|
||||
}
|
||||
|
||||
private synchronized void rescan(List<BlockPos> known, CalculationContext context) {
|
||||
List<BlockPos> positions = MineProcess.searchWorld(context, new BlockOptionalMetaLookup(gettingTo), 64, known, blacklist);
|
||||
List<BlockPos> positions = MineProcess.searchWorld(context, new BlockOptionalMetaLookup(gettingTo), 64, known, blacklist, Collections.emptyList());
|
||||
positions.removeIf(blacklist::contains);
|
||||
knownLocations = positions;
|
||||
}
|
||||
|
||||
private Goal createGoal(BlockPos pos) {
|
||||
if (walkIntoInsteadOfAdjacent(gettingTo)) {
|
||||
if (walkIntoInsteadOfAdjacent(gettingTo.getBlock())) {
|
||||
return new GoalTwoBlocks(pos);
|
||||
}
|
||||
if (blockOnTopMustBeRemoved(gettingTo) && baritone.bsi.get0(pos.up()).isBlockNormalCube()) {
|
||||
if (blockOnTopMustBeRemoved(gettingTo.getBlock()) && baritone.bsi.get0(pos.up()).isBlockNormalCube()) {
|
||||
return new GoalBlock(pos.up());
|
||||
}
|
||||
return new GoalGetToBlock(pos);
|
||||
|
||||
@@ -39,7 +39,6 @@ import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -58,6 +57,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
private BlockOptionalMetaLookup filter;
|
||||
private List<BlockPos> knownOreLocations;
|
||||
private List<BlockPos> blacklist; // inaccessible
|
||||
private Map<BlockPos, Long> anticipatedDrops;
|
||||
private BlockPos branchPoint;
|
||||
private GoalRunAway branchPointRunaway;
|
||||
private int desiredQuantity;
|
||||
@@ -101,6 +101,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
cancel();
|
||||
return null;
|
||||
}
|
||||
updateLoucaSystem();
|
||||
int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.value;
|
||||
List<BlockPos> curr = new ArrayList<>(knownOreLocations);
|
||||
if (mineGoalUpdateInterval != 0 && tickCount++ % mineGoalUpdateInterval == 0) { // big brain
|
||||
@@ -141,6 +142,23 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
return command;
|
||||
}
|
||||
|
||||
private void updateLoucaSystem() {
|
||||
Map<BlockPos, Long> copy = new HashMap<>(anticipatedDrops);
|
||||
ctx.getSelectedBlock().ifPresent(pos -> {
|
||||
if (knownOreLocations.contains(pos)) {
|
||||
copy.put(pos, System.currentTimeMillis() + Baritone.settings().mineDropLoiterDurationMSThanksLouca.value);
|
||||
}
|
||||
});
|
||||
// elaborate dance to avoid concurrentmodificationexcepption since rescan thread reads this
|
||||
// don't want to slow everything down with a gross lock do we now
|
||||
for (BlockPos pos : anticipatedDrops.keySet()) {
|
||||
if (copy.get(pos) < System.currentTimeMillis()) {
|
||||
copy.remove(pos);
|
||||
}
|
||||
}
|
||||
anticipatedDrops = copy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLostControl() {
|
||||
mine(0, (BlockOptionalMetaLookup) null);
|
||||
@@ -155,9 +173,10 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
boolean legit = Baritone.settings().legitMine.value;
|
||||
List<BlockPos> locs = knownOreLocations;
|
||||
if (!locs.isEmpty()) {
|
||||
List<BlockPos> locs2 = prune(new CalculationContext(baritone), new ArrayList<>(locs), filter, ORE_LOCATIONS_COUNT, blacklist);
|
||||
CalculationContext context = new CalculationContext(baritone);
|
||||
List<BlockPos> locs2 = prune(context, new ArrayList<>(locs), filter, ORE_LOCATIONS_COUNT, blacklist, droppedItemsScan());
|
||||
// can't reassign locs, gotta make a new var locs2, because we use it in a lambda right here, and variables you use in a lambda must be effectively final
|
||||
Goal goal = new GoalComposite(locs2.stream().map(loc -> coalesce(loc, locs2)).toArray(Goal[]::new));
|
||||
Goal goal = new GoalComposite(locs2.stream().map(loc -> coalesce(loc, locs2, context)).toArray(Goal[]::new));
|
||||
knownOreLocations = locs2;
|
||||
return new PathingCommand(goal, legit ? PathingCommandType.FORCE_REVALIDATE_GOAL_AND_PATH : PathingCommandType.REVALIDATE_GOAL_AND_PATH);
|
||||
}
|
||||
@@ -197,8 +216,9 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
if (Baritone.settings().legitMine.value) {
|
||||
return;
|
||||
}
|
||||
List<BlockPos> locs = searchWorld(context, filter, ORE_LOCATIONS_COUNT, already, blacklist);
|
||||
locs.addAll(droppedItemsScan(filter, ctx.world()));
|
||||
List<BlockPos> dropped = droppedItemsScan();
|
||||
List<BlockPos> locs = searchWorld(context, filter, ORE_LOCATIONS_COUNT, already, blacklist, dropped);
|
||||
locs.addAll(dropped);
|
||||
if (locs.isEmpty()) {
|
||||
logDirect("No locations for " + filter + " known, cancelling");
|
||||
cancel();
|
||||
@@ -207,19 +227,19 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
knownOreLocations = locs;
|
||||
}
|
||||
|
||||
private boolean internalMiningGoal(BlockPos pos, IPlayerContext ctx, List<BlockPos> locs) {
|
||||
private boolean internalMiningGoal(BlockPos pos, CalculationContext context, List<BlockPos> locs) {
|
||||
// Here, BlockStateInterface is used because the position may be in a cached chunk (the targeted block is one that is kept track of)
|
||||
if (locs.contains(pos)) {
|
||||
return true;
|
||||
}
|
||||
IBlockState state = BlockStateInterface.get(ctx, pos);
|
||||
IBlockState state = context.bsi.get0(pos);
|
||||
if (Baritone.settings().internalMiningAirException.value && state.getBlock() instanceof BlockAir) {
|
||||
return true;
|
||||
}
|
||||
return filter.has(state);
|
||||
return filter.has(state) && plausibleToBreak(context, pos);
|
||||
}
|
||||
|
||||
private Goal coalesce(BlockPos loc, List<BlockPos> locs) {
|
||||
private Goal coalesce(BlockPos loc, List<BlockPos> locs, CalculationContext context) {
|
||||
boolean assumeVerticalShaftMine = !(baritone.bsi.get0(loc.up()).getBlock() instanceof BlockFalling);
|
||||
if (!Baritone.settings().forceInternalMining.value) {
|
||||
if (assumeVerticalShaftMine) {
|
||||
@@ -230,9 +250,9 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
return new GoalTwoBlocks(loc);
|
||||
}
|
||||
}
|
||||
boolean upwardGoal = internalMiningGoal(loc.up(), ctx, locs);
|
||||
boolean downwardGoal = internalMiningGoal(loc.down(), ctx, locs);
|
||||
boolean doubleDownwardGoal = internalMiningGoal(loc.down(2), ctx, locs);
|
||||
boolean upwardGoal = internalMiningGoal(loc.up(), context, locs);
|
||||
boolean downwardGoal = internalMiningGoal(loc.down(), context, locs);
|
||||
boolean doubleDownwardGoal = internalMiningGoal(loc.down(2), context, locs);
|
||||
if (upwardGoal == downwardGoal) { // symmetric
|
||||
if (doubleDownwardGoal && assumeVerticalShaftMine) {
|
||||
// we have a checkerboard like pattern
|
||||
@@ -281,12 +301,12 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
}
|
||||
}
|
||||
|
||||
public static List<BlockPos> droppedItemsScan(BlockOptionalMetaLookup filter, World world) {
|
||||
public List<BlockPos> droppedItemsScan() {
|
||||
if (!Baritone.settings().mineScanDroppedItems.value) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<BlockPos> ret = new ArrayList<>();
|
||||
for (Entity entity : world.loadedEntityList) {
|
||||
for (Entity entity : ctx.world().loadedEntityList) {
|
||||
if (entity instanceof EntityItem) {
|
||||
EntityItem ei = (EntityItem) entity;
|
||||
if (filter.has(ei.getItem())) {
|
||||
@@ -294,10 +314,11 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
}
|
||||
}
|
||||
}
|
||||
ret.addAll(anticipatedDrops.keySet());
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static List<BlockPos> searchWorld(CalculationContext ctx, BlockOptionalMetaLookup filter, int max, List<BlockPos> alreadyKnown, List<BlockPos> blacklist) {
|
||||
public static List<BlockPos> searchWorld(CalculationContext ctx, BlockOptionalMetaLookup filter, int max, List<BlockPos> alreadyKnown, List<BlockPos> blacklist, List<BlockPos> dropped) {
|
||||
List<BlockPos> locs = new ArrayList<>();
|
||||
List<Block> untracked = new ArrayList<>();
|
||||
for (BlockOptionalMeta bom : filter.blocks()) {
|
||||
@@ -318,7 +339,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
}
|
||||
}
|
||||
|
||||
locs = prune(ctx, locs, filter, max, blacklist);
|
||||
locs = prune(ctx, locs, filter, max, blacklist, dropped);
|
||||
|
||||
if (!untracked.isEmpty() || (Baritone.settings().extendCacheOnThreshold.value && locs.size() < max)) {
|
||||
locs.addAll(WorldScanner.INSTANCE.scanChunkRadius(
|
||||
@@ -332,11 +353,12 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
|
||||
locs.addAll(alreadyKnown);
|
||||
|
||||
return prune(ctx, locs, filter, max, blacklist);
|
||||
return prune(ctx, locs, filter, max, blacklist, dropped);
|
||||
}
|
||||
|
||||
private void addNearby() {
|
||||
knownOreLocations.addAll(droppedItemsScan(filter, ctx.world()));
|
||||
List<BlockPos> dropped = droppedItemsScan();
|
||||
knownOreLocations.addAll(dropped);
|
||||
BlockPos playerFeet = ctx.playerFeet();
|
||||
BlockStateInterface bsi = new BlockStateInterface(ctx);
|
||||
int searchDist = 10;
|
||||
@@ -355,11 +377,10 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
}
|
||||
}
|
||||
}
|
||||
knownOreLocations = prune(new CalculationContext(baritone), knownOreLocations, filter, ORE_LOCATIONS_COUNT, blacklist);
|
||||
knownOreLocations = prune(new CalculationContext(baritone), knownOreLocations, filter, ORE_LOCATIONS_COUNT, blacklist, dropped);
|
||||
}
|
||||
|
||||
private static List<BlockPos> prune(CalculationContext ctx, List<BlockPos> locs2, BlockOptionalMetaLookup filter, int max, List<BlockPos> blacklist) {
|
||||
List<BlockPos> dropped = droppedItemsScan(filter, ctx.world);
|
||||
private static List<BlockPos> prune(CalculationContext ctx, List<BlockPos> locs2, BlockOptionalMetaLookup filter, int max, List<BlockPos> blacklist, List<BlockPos> dropped) {
|
||||
dropped.removeIf(drop -> {
|
||||
for (BlockPos pos : locs2) {
|
||||
if (pos.distanceSq(drop) <= 9 && filter.has(ctx.get(pos.getX(), pos.getY(), pos.getZ())) && MineProcess.plausibleToBreak(ctx, pos)) { // TODO maybe drop also has to be supported? no lava below?
|
||||
@@ -416,6 +437,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
this.blacklist = new ArrayList<>();
|
||||
this.branchPoint = null;
|
||||
this.branchPointRunaway = null;
|
||||
this.anticipatedDrops = new HashMap<>();
|
||||
if (filter != null) {
|
||||
rescan(new ArrayList<>(), new CalculationContext(baritone));
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ import java.nio.IntBuffer;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import static baritone.api.utils.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
|
||||
public class GuiClick extends GuiScreen {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user