Merge branch '1.20.5' into 1.21.1
This commit is contained in:
@@ -26,11 +26,13 @@ import baritone.api.command.datatypes.RelativeFile;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidStateException;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.utils.schematic.SchematicSystem;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class BuildCommand extends Command {
|
||||
@@ -44,10 +46,29 @@ public class BuildCommand extends Command {
|
||||
|
||||
@Override
|
||||
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||
File file = args.getDatatypePost(RelativeFile.INSTANCE, schematicsDir).getAbsoluteFile();
|
||||
final File file0 = args.getDatatypePost(RelativeFile.INSTANCE, schematicsDir).getAbsoluteFile();
|
||||
File file = file0;
|
||||
if (FilenameUtils.getExtension(file.getAbsolutePath()).isEmpty()) {
|
||||
file = new File(file.getAbsolutePath() + "." + Baritone.settings().schematicFallbackExtension.value);
|
||||
}
|
||||
if (!file.exists()) {
|
||||
if (file0.exists()) {
|
||||
throw new CommandInvalidStateException(String.format(
|
||||
"Cannot load %s because I do not know which schematic format"
|
||||
+ " that is. Please rename the file to include the correct"
|
||||
+ " file extension.",
|
||||
file));
|
||||
}
|
||||
throw new CommandInvalidStateException("Cannot find " + file);
|
||||
}
|
||||
if (!SchematicSystem.INSTANCE.getByFile(file).isPresent()) {
|
||||
StringJoiner formats = new StringJoiner(", ");
|
||||
SchematicSystem.INSTANCE.getFileExtensions().forEach(formats::add);
|
||||
throw new CommandInvalidStateException(String.format(
|
||||
"Unsupported schematic format. Reckognized file extensions are: %s",
|
||||
formats
|
||||
));
|
||||
}
|
||||
BetterBlockPos origin = ctx.playerFeet();
|
||||
BetterBlockPos buildOrigin;
|
||||
if (args.hasAny()) {
|
||||
@@ -59,7 +80,7 @@ public class BuildCommand extends Command {
|
||||
}
|
||||
boolean success = baritone.getBuilderProcess().build(file.getName(), file, buildOrigin);
|
||||
if (!success) {
|
||||
throw new CommandInvalidStateException("Couldn't load the schematic. Make sure to use the FULL file name, including the extension (e.g. blah.schematic).");
|
||||
throw new CommandInvalidStateException("Couldn't load the schematic. Either your schematic is corrupt or this is a bug.");
|
||||
}
|
||||
logDirect(String.format("Successfully loaded schematic for building\nOrigin: %s", buildOrigin));
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ public final class DefaultCommands {
|
||||
new RenderCommand(baritone),
|
||||
new FarmCommand(baritone),
|
||||
new FollowCommand(baritone),
|
||||
new PickupCommand(baritone),
|
||||
new ExploreFilterCommand(baritone),
|
||||
new ReloadAllCommand(baritone),
|
||||
new SaveAllCommand(baritone),
|
||||
|
||||
@@ -216,7 +216,7 @@ public class ElytraCommand extends Command {
|
||||
final String osArch = System.getProperty("os.arch");
|
||||
final String osName = System.getProperty("os.name");
|
||||
return String.format(
|
||||
"Legacy architectures are not supported. Your CPU is %s and your operating system is %s. " +
|
||||
"Failed loading native library. Your CPU is %s and your operating system is %s. " +
|
||||
"Supported architectures are 64 bit x86, and 64 bit ARM. Supported operating systems are Windows, " +
|
||||
"Linux, and Mac",
|
||||
osArch, osName
|
||||
|
||||
82
src/main/java/baritone/command/defaults/PickupCommand.java
Normal file
82
src/main/java/baritone/command/defaults/PickupCommand.java
Normal file
@@ -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.argument.IArgConsumer;
|
||||
import baritone.api.command.datatypes.ItemById;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class PickupCommand extends Command {
|
||||
|
||||
public PickupCommand(IBaritone baritone) {
|
||||
super(baritone, "pickup");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||
Set<Item> collecting = new HashSet<>();
|
||||
while (args.hasAny()) {
|
||||
Item item = args.getDatatypeFor(ItemById.INSTANCE);
|
||||
collecting.add(item);
|
||||
}
|
||||
if (collecting.isEmpty()) {
|
||||
baritone.getFollowProcess().pickup(stack -> true);
|
||||
logDirect("Picking up all items");
|
||||
} else {
|
||||
baritone.getFollowProcess().pickup(stack -> collecting.contains(stack.getItem()));
|
||||
logDirect("Picking up these items:");
|
||||
collecting.stream().map(BuiltInRegistries.ITEM::getKey).map(ResourceLocation::toString).forEach(this::logDirect);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<String> tabComplete(String label, IArgConsumer args) throws CommandException {
|
||||
while (args.has(2)) {
|
||||
if (args.peekDatatypeOrNull(ItemById.INSTANCE) == null) {
|
||||
return Stream.empty();
|
||||
}
|
||||
args.get();
|
||||
}
|
||||
return args.tabCompleteDatatype(ItemById.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getShortDesc() {
|
||||
return "Pickup items";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLongDesc() {
|
||||
return Arrays.asList(
|
||||
"Usage:",
|
||||
"> pickup - Pickup anything",
|
||||
"> pickup <item1> <item2> <...> - Pickup certain items"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import baritone.api.pathing.calc.IPath;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.movement.ActionCosts;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.pathing.calc.openset.BinaryHeapOpenSet;
|
||||
import baritone.pathing.movement.CalculationContext;
|
||||
import baritone.pathing.movement.Moves;
|
||||
@@ -122,17 +123,39 @@ public final class AStarPathFinder extends AbstractNodeCostSearch {
|
||||
continue;
|
||||
}
|
||||
if (actionCost <= 0 || Double.isNaN(actionCost)) {
|
||||
throw new IllegalStateException(moves + " calculated implausible cost " + actionCost);
|
||||
throw new IllegalStateException(String.format(
|
||||
"%s from %s %s %s calculated implausible cost %s",
|
||||
moves,
|
||||
SettingsUtil.maybeCensor(currentNode.x),
|
||||
SettingsUtil.maybeCensor(currentNode.y),
|
||||
SettingsUtil.maybeCensor(currentNode.z),
|
||||
actionCost));
|
||||
}
|
||||
// check destination after verifying it's not COST_INF -- some movements return a static IMPOSSIBLE object with COST_INF and destination being 0,0,0 to avoid allocating a new result for every failed calculation
|
||||
// check destination after verifying it's not COST_INF -- some movements return COST_INF without adjusting the destination
|
||||
if (moves.dynamicXZ && !worldBorder.entirelyContains(res.x, res.z)) { // see issue #218
|
||||
continue;
|
||||
}
|
||||
if (!moves.dynamicXZ && (res.x != newX || res.z != newZ)) {
|
||||
throw new IllegalStateException(moves + " " + res.x + " " + newX + " " + res.z + " " + newZ);
|
||||
throw new IllegalStateException(String.format(
|
||||
"%s from %s %s %s ended at x z %s %s instead of %s %s",
|
||||
moves,
|
||||
SettingsUtil.maybeCensor(currentNode.x),
|
||||
SettingsUtil.maybeCensor(currentNode.y),
|
||||
SettingsUtil.maybeCensor(currentNode.z),
|
||||
SettingsUtil.maybeCensor(res.x),
|
||||
SettingsUtil.maybeCensor(res.z),
|
||||
SettingsUtil.maybeCensor(newX),
|
||||
SettingsUtil.maybeCensor(newZ)));
|
||||
}
|
||||
if (!moves.dynamicY && res.y != currentNode.y + moves.yOffset) {
|
||||
throw new IllegalStateException(moves + " " + res.y + " " + (currentNode.y + moves.yOffset));
|
||||
throw new IllegalStateException(String.format(
|
||||
"%s from %s %s %s ended at y %s instead of %s",
|
||||
moves,
|
||||
SettingsUtil.maybeCensor(currentNode.x),
|
||||
SettingsUtil.maybeCensor(currentNode.y),
|
||||
SettingsUtil.maybeCensor(currentNode.z),
|
||||
SettingsUtil.maybeCensor(res.y),
|
||||
SettingsUtil.maybeCensor(currentNode.y + moves.yOffset)));
|
||||
}
|
||||
long hashCode = BetterBlockPos.longHash(res.x, res.y, res.z);
|
||||
if (isFavoring) {
|
||||
|
||||
@@ -112,7 +112,7 @@ class Path extends PathBase {
|
||||
|
||||
private boolean assembleMovements() {
|
||||
if (path.isEmpty() || !movements.isEmpty()) {
|
||||
throw new IllegalStateException();
|
||||
throw new IllegalStateException("Path must not be empty");
|
||||
}
|
||||
for (int i = 0; i < path.size() - 1; i++) {
|
||||
double cost = nodes.get(i + 1).cost - nodes.get(i).cost;
|
||||
@@ -145,7 +145,7 @@ class Path extends PathBase {
|
||||
@Override
|
||||
public IPath postProcess() {
|
||||
if (verified) {
|
||||
throw new IllegalStateException();
|
||||
throw new IllegalStateException("Path must not be verified twice");
|
||||
}
|
||||
verified = true;
|
||||
boolean failed = assembleMovements();
|
||||
@@ -154,7 +154,7 @@ class Path extends PathBase {
|
||||
if (failed) { // at least one movement became impossible during calculation
|
||||
CutoffPath res = new CutoffPath(this, movements().size());
|
||||
if (res.movements().size() != movements.size()) {
|
||||
throw new IllegalStateException();
|
||||
throw new IllegalStateException("Path has wrong size after cutoff");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -166,7 +166,8 @@ class Path extends PathBase {
|
||||
@Override
|
||||
public List<IMovement> movements() {
|
||||
if (!verified) {
|
||||
throw new IllegalStateException();
|
||||
// edge case note: this is called during verification
|
||||
throw new IllegalStateException("Path not yet verified");
|
||||
}
|
||||
return Collections.unmodifiableList(movements);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package baritone.pathing.calc;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.movement.ActionCosts;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
|
||||
/**
|
||||
* A node in the path, containing the cost and steps to get to it.
|
||||
@@ -68,7 +69,12 @@ public final class PathNode {
|
||||
this.cost = ActionCosts.COST_INF;
|
||||
this.estimatedCostToGoal = goal.heuristic(x, y, z);
|
||||
if (Double.isNaN(estimatedCostToGoal)) {
|
||||
throw new IllegalStateException(goal + " calculated implausible heuristic");
|
||||
throw new IllegalStateException(String.format(
|
||||
"%s calculated implausible heuristic NaN at %s %s %s",
|
||||
goal,
|
||||
SettingsUtil.maybeCensor(x),
|
||||
SettingsUtil.maybeCensor(y),
|
||||
SettingsUtil.maybeCensor(z)));
|
||||
}
|
||||
this.heapPosition = -1;
|
||||
this.x = x;
|
||||
|
||||
@@ -92,7 +92,7 @@ public final class BinaryHeapOpenSet implements IOpenSet {
|
||||
@Override
|
||||
public final PathNode removeLowest() {
|
||||
if (size == 0) {
|
||||
throw new IllegalStateException();
|
||||
throw new IllegalStateException("Cannot remove from empty heap");
|
||||
}
|
||||
PathNode result = array[1];
|
||||
PathNode val = array[size];
|
||||
|
||||
@@ -189,6 +189,12 @@ public class CalculationContext {
|
||||
if (!worldBorder.canPlaceAt(x, z)) {
|
||||
return COST_INF;
|
||||
}
|
||||
if (!Baritone.settings().allowPlaceInFluidsSource.value && current.getFluidState().isSource()) {
|
||||
return COST_INF;
|
||||
}
|
||||
if (!Baritone.settings().allowPlaceInFluidsFlow.value && !current.getFluidState().isEmpty() && !current.getFluidState().isSource()) {
|
||||
return COST_INF;
|
||||
}
|
||||
return placeBlockCost;
|
||||
}
|
||||
|
||||
|
||||
@@ -347,7 +347,7 @@ public enum Moves {
|
||||
|
||||
public void apply(CalculationContext context, int x, int y, int z, MutableMoveResult result) {
|
||||
if (dynamicXZ || dynamicY) {
|
||||
throw new UnsupportedOperationException();
|
||||
throw new UnsupportedOperationException("Movements with dynamic offset must override `apply`");
|
||||
}
|
||||
result.x = x + xOffset;
|
||||
result.y = y + yOffset;
|
||||
@@ -356,6 +356,6 @@ public enum Moves {
|
||||
}
|
||||
|
||||
public double cost(CalculationContext context, int x, int y, int z) {
|
||||
throw new UnsupportedOperationException();
|
||||
throw new UnsupportedOperationException("Movements must override `cost` or `apply`");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,7 +455,9 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||
if (data != null) {
|
||||
BetterBlockPos fallDest = new BetterBlockPos(data.getB());
|
||||
if (!path.positions().contains(fallDest)) {
|
||||
throw new IllegalStateException();
|
||||
throw new IllegalStateException(String.format(
|
||||
"Fall override at %s %s %s returned illegal destination %s %s %s",
|
||||
current.getSrc(), fallDest));
|
||||
}
|
||||
if (ctx.playerFeet().equals(fallDest)) {
|
||||
pathPosition = path.positions().indexOf(fallDest);
|
||||
@@ -603,7 +605,9 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||
}
|
||||
return SplicedPath.trySplice(path, next.path, false).map(path -> {
|
||||
if (!path.getDest().equals(next.getPath().getDest())) {
|
||||
throw new IllegalStateException();
|
||||
throw new IllegalStateException(String.format(
|
||||
"Path has end %s instead of %s after splicing",
|
||||
path.getDest(), next.getPath().getDest()));
|
||||
}
|
||||
PathExecutor ret = new PathExecutor(behavior, path);
|
||||
ret.pathPosition = pathPosition;
|
||||
@@ -619,7 +623,9 @@ public class PathExecutor implements IPathExecutor, Helper {
|
||||
int cutoffAmt = Baritone.settings().pathHistoryCutoffAmount.value;
|
||||
CutoffPath newPath = new CutoffPath(path, cutoffAmt, path.length() - 1);
|
||||
if (!newPath.getDest().equals(path.getDest())) {
|
||||
throw new IllegalStateException();
|
||||
throw new IllegalStateException(String.format(
|
||||
"Path has end %s instead of %s after trimming its start",
|
||||
newPath.getDest(), path.getDest()));
|
||||
}
|
||||
logDebug("Discarding earliest segment movements, length cut from " + path.length() + " to " + newPath.length());
|
||||
PathExecutor ret = new PathExecutor(behavior, newPath);
|
||||
|
||||
@@ -92,7 +92,7 @@ public class SplicedPath extends PathBase {
|
||||
}
|
||||
int positionInSecond = second.positions().indexOf(first.positions().get(firstPositionInSecond));
|
||||
if (!allowOverlapCutoff && positionInSecond != 0) {
|
||||
throw new IllegalStateException();
|
||||
throw new IllegalStateException("Paths to be spliced are overlapping incorrectly");
|
||||
}
|
||||
List<BetterBlockPos> positions = new ArrayList<>();
|
||||
List<IMovement> movements = new ArrayList<>();
|
||||
|
||||
@@ -441,7 +441,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
double z = side.getStepZ() == 0 ? 0.5 : (1 + side.getStepZ()) / 2D;
|
||||
return new Vec3[]{new Vec3(x, 0.25, z), new Vec3(x, 0.75, z)};
|
||||
default: // null
|
||||
throw new IllegalStateException();
|
||||
throw new IllegalStateException("Unexpected side " + side);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ public final class CustomGoalProcess extends BaritoneProcessHelper implements IC
|
||||
}
|
||||
return new PathingCommand(this.goal, PathingCommandType.SET_GOAL_AND_PATH);
|
||||
default:
|
||||
throw new IllegalStateException();
|
||||
throw new IllegalStateException("Unexpected state " + this.state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,9 @@ public final class ExploreProcess extends BaritoneProcessHelper implements IExpl
|
||||
int dz = (mult * 2 - 1) * zval; // dz can be either -zval or zval
|
||||
int trueDist = Math.abs(dx) + Math.abs(dz);
|
||||
if (trueDist != dist) {
|
||||
throw new IllegalStateException();
|
||||
throw new IllegalStateException(String.format(
|
||||
"Offset %s %s has distance %s, expected %s",
|
||||
dx, dz, trueDist, dist));
|
||||
}
|
||||
switch (filter.isAlreadyExplored(chunkX + dx, chunkZ + dz)) {
|
||||
case UNKNOWN:
|
||||
|
||||
@@ -19,6 +19,7 @@ package baritone.process;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.pathing.goals.GoalComposite;
|
||||
import baritone.api.pathing.goals.GoalNear;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
@@ -27,11 +28,14 @@ import baritone.api.process.PathingCommand;
|
||||
import baritone.api.process.PathingCommandType;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.utils.BaritoneProcessHelper;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
/**
|
||||
* Follow an entity
|
||||
@@ -42,6 +46,7 @@ public final class FollowProcess extends BaritoneProcessHelper implements IFollo
|
||||
|
||||
private Predicate<Entity> filter;
|
||||
private List<Entity> cache;
|
||||
private boolean into; // walk straight into the target, regardless of settings
|
||||
|
||||
public FollowProcess(Baritone baritone) {
|
||||
super(baritone);
|
||||
@@ -56,12 +61,15 @@ public final class FollowProcess extends BaritoneProcessHelper implements IFollo
|
||||
|
||||
private Goal towards(Entity following) {
|
||||
BlockPos pos;
|
||||
if (Baritone.settings().followOffsetDistance.value == 0) {
|
||||
if (Baritone.settings().followOffsetDistance.value == 0 || into) {
|
||||
pos = following.blockPosition();
|
||||
} else {
|
||||
GoalXZ g = GoalXZ.fromDirection(following.position(), Baritone.settings().followOffsetDirection.value, Baritone.settings().followOffsetDistance.value);
|
||||
pos = new BetterBlockPos(g.getX(), following.position().y, g.getZ());
|
||||
}
|
||||
if (into) {
|
||||
return new GoalBlock(pos);
|
||||
}
|
||||
return new GoalNear(pos, Baritone.settings().followRadius.value);
|
||||
}
|
||||
|
||||
@@ -76,6 +84,10 @@ public final class FollowProcess extends BaritoneProcessHelper implements IFollo
|
||||
if (entity.equals(ctx.player())) {
|
||||
return false;
|
||||
}
|
||||
int maxDist = Baritone.settings().followTargetMaxDistance.value;
|
||||
if (maxDist != 0 && entity.distanceToSqr(ctx.player()) > maxDist * maxDist) {
|
||||
return false;
|
||||
}
|
||||
return ctx.entitiesStream().anyMatch(entity::equals);
|
||||
}
|
||||
|
||||
@@ -110,6 +122,13 @@ public final class FollowProcess extends BaritoneProcessHelper implements IFollo
|
||||
@Override
|
||||
public void follow(Predicate<Entity> filter) {
|
||||
this.filter = filter;
|
||||
this.into = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pickup(Predicate<ItemStack> filter) {
|
||||
this.filter = e -> e instanceof ItemEntity && filter.test(((ItemEntity) e).getItem());
|
||||
this.into = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -77,7 +77,6 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
int curr = ctx.player().getInventory().items.stream()
|
||||
.filter(stack -> filter.has(stack))
|
||||
.mapToInt(ItemStack::getCount).sum();
|
||||
System.out.println("Currently have " + curr + " valid items");
|
||||
if (curr >= desiredQuantity) {
|
||||
logDirect("Have " + curr + " valid items");
|
||||
cancel();
|
||||
@@ -119,7 +118,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
.filter(pos -> pos.getX() == ctx.playerFeet().getX() && pos.getZ() == ctx.playerFeet().getZ())
|
||||
.filter(pos -> pos.getY() >= ctx.playerFeet().getY())
|
||||
.filter(pos -> !(BlockStateInterface.get(ctx, pos).getBlock() instanceof AirBlock)) // after breaking a block, it takes mineGoalUpdateInterval ticks for it to actually update this list =(
|
||||
.min(Comparator.comparingDouble(ctx.playerFeet()::distSqr));
|
||||
.min(Comparator.comparingDouble(ctx.playerFeet().above()::distSqr));
|
||||
baritone.getInputOverrideHandler().clearAllKeys();
|
||||
if (shaft.isPresent() && ctx.player().onGround()) {
|
||||
BlockPos pos = shaft.get();
|
||||
@@ -486,7 +485,11 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
|
||||
|
||||
public static boolean plausibleToBreak(CalculationContext ctx, BlockPos pos) {
|
||||
if (MovementHelper.getMiningDurationTicks(ctx, pos.getX(), pos.getY(), pos.getZ(), ctx.bsi.get0(pos), true) >= COST_INF) {
|
||||
BlockState state = ctx.bsi.get0(pos);
|
||||
if (MovementHelper.getMiningDurationTicks(ctx, pos.getX(), pos.getY(), pos.getZ(), state, true) >= COST_INF) {
|
||||
return false;
|
||||
}
|
||||
if (MovementHelper.avoidBreaking(ctx.bsi, pos.getX(), pos.getY(), pos.getZ(), state)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class BlockStateInterface {
|
||||
}
|
||||
this.useTheRealWorld = !Baritone.settings().pathThroughCachedOnly.value;
|
||||
if (!ctx.minecraft().isSameThread()) {
|
||||
throw new IllegalStateException();
|
||||
throw new IllegalStateException("BlockStateInterface must be constructed on the main thread");
|
||||
}
|
||||
this.isPassableBlockPos = new BlockPos.MutableBlockPos();
|
||||
this.access = new BlockStateInterfaceAccessWrapper(this);
|
||||
|
||||
@@ -68,7 +68,7 @@ public class PathingControlManager implements IPathingControlManager {
|
||||
for (IBaritoneProcess proc : processes) {
|
||||
proc.onLostControl();
|
||||
if (proc.isActive() && !proc.isTemporary()) { // it's okay only for a temporary thing (like combat pause) to maintain control even if you say to cancel
|
||||
throw new IllegalStateException(proc.displayName());
|
||||
throw new IllegalStateException(proc.displayName() + " stayed active after being cancelled");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class PathingControlManager implements IPathingControlManager {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException();
|
||||
throw new IllegalStateException("Unexpected command type " + command.commandType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import baritone.utils.schematic.format.DefaultSchematicFormats;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
@@ -48,4 +49,9 @@ public enum SchematicSystem implements ISchematicSystem {
|
||||
public Optional<ISchematicFormat> getByFile(File file) {
|
||||
return this.registry.stream().filter(format -> format.isFileType(file)).findFirst();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getFileExtensions() {
|
||||
return this.registry.stream().map(ISchematicFormat::getFileExtensions).flatMap(List::stream).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,14 +22,16 @@ import baritone.api.schematic.format.ISchematicFormat;
|
||||
import baritone.utils.schematic.format.defaults.LitematicaSchematic;
|
||||
import baritone.utils.schematic.format.defaults.MCEditSchematic;
|
||||
import baritone.utils.schematic.format.defaults.SpongeSchematic;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtAccounter;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Default implementations of {@link ISchematicFormat}
|
||||
@@ -101,4 +103,9 @@ public enum DefaultSchematicFormats implements ISchematicFormat {
|
||||
public boolean isFileType(File file) {
|
||||
return this.extension.equalsIgnoreCase(FilenameUtils.getExtension(file.getAbsolutePath()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getFileExtensions() {
|
||||
return Collections.singletonList(this.extension);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user