diff --git a/src/main/java/baritone/command/defaults/ExecutionControlCommands.java b/src/main/java/baritone/command/defaults/ExecutionControlCommands.java index 8a53e7d41..eaab75286 100644 --- a/src/main/java/baritone/command/defaults/ExecutionControlCommands.java +++ b/src/main/java/baritone/command/defaults/ExecutionControlCommands.java @@ -79,7 +79,7 @@ public class ExecutionControlCommands { } } ); - pauseCommand = new Command(baritone, "pause", "p") { + pauseCommand = new Command(baritone, "pause", "p", "paws") { @Override public void execute(String label, IArgConsumer args) throws CommandException { args.requireMax(0); @@ -112,7 +112,7 @@ public class ExecutionControlCommands { ); } }; - resumeCommand = new Command(baritone, "resume", "r", "unpause") { + resumeCommand = new Command(baritone, "resume", "r", "unpause", "unpaws") { @Override public void execute(String label, IArgConsumer args) throws CommandException { args.requireMax(0); diff --git a/src/main/java/baritone/command/defaults/FindCommand.java b/src/main/java/baritone/command/defaults/FindCommand.java index 65eb9b5c3..b20f14e98 100644 --- a/src/main/java/baritone/command/defaults/FindCommand.java +++ b/src/main/java/baritone/command/defaults/FindCommand.java @@ -22,14 +22,23 @@ import baritone.api.command.Command; import baritone.api.command.argument.IArgConsumer; import baritone.api.command.datatypes.BlockById; import baritone.api.command.exception.CommandException; +import baritone.api.command.helpers.TabCompleteHelper; import baritone.api.utils.BetterBlockPos; +import baritone.cache.CachedChunk; import net.minecraft.block.Block; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.event.ClickEvent; +import net.minecraft.util.text.event.HoverEvent; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Stream; +import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX; + public class FindCommand extends Command { public FindCommand(IBaritone baritone) { @@ -38,12 +47,13 @@ public class FindCommand extends Command { @Override public void execute(String label, IArgConsumer args) throws CommandException { + args.requireMin(1); List toFind = new ArrayList<>(); while (args.hasAny()) { toFind.add(args.getDatatypeFor(BlockById.INSTANCE)); } BetterBlockPos origin = ctx.playerFeet(); - toFind.stream() + ITextComponent[] components = toFind.stream() .flatMap(block -> ctx.worldData().getCachedWorld().getLocationsOf( Block.REGISTRY.getNameForObject(block).getPath(), @@ -54,13 +64,39 @@ public class FindCommand extends Command { ).stream() ) .map(BetterBlockPos::new) - .map(BetterBlockPos::toString) - .forEach(this::logDirect); + .map(this::positionToComponent) + .toArray(ITextComponent[]::new); + if (components.length > 0) { + Arrays.asList(components).forEach(this::logDirect); + } else { + logDirect("No positions known, are you sure the blocks are cached?"); + } + } + + private ITextComponent positionToComponent(BetterBlockPos pos) { + String positionText = String.format("%s %s %s", pos.x, pos.y, pos.z); + String command = String.format("%sgoal %s", FORCE_COMMAND_PREFIX, positionText); + ITextComponent baseComponent = new TextComponentString(pos.toString()); + ITextComponent hoverComponent = new TextComponentString("Click to set goal to this position"); + baseComponent.getStyle() + .setColor(TextFormatting.GRAY) + .setInsertion(positionText) + .setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command)) + .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent)); + return baseComponent; } @Override - public Stream tabComplete(String label, IArgConsumer args) { - return args.tabCompleteDatatype(BlockById.INSTANCE); + public Stream tabComplete(String label, IArgConsumer args) throws CommandException { + return new TabCompleteHelper() + .append( + CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.stream() + .map(Block.REGISTRY::getNameForObject) + .map(Object::toString) + ) + .filterPrefixNamespaced(args.getString()) + .sortAlphabetically() + .stream(); } @Override @@ -72,9 +108,10 @@ public class FindCommand extends Command { public List getLongDesc() { return Arrays.asList( "The find command searches through Baritone's cache and attempts to find the location of the block.", + "Tab completion will suggest only cached blocks and uncached blocks can not be found.", "", "Usage:", - "> find - Find positions of a certain block" + "> find [...] - Try finding the listed blocks" ); } } diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 7e4f76a3b..17fa788db 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -73,8 +73,8 @@ public class PathExecutor implements IPathExecutor, Helper { private HashSet toPlace = new HashSet<>(); private HashSet toWalkInto = new HashSet<>(); - private PathingBehavior behavior; - private IPlayerContext ctx; + private final PathingBehavior behavior; + private final IPlayerContext ctx; private boolean sprintNextTick; @@ -397,11 +397,20 @@ public class PathExecutor implements IPathExecutor, Helper { return true; } if (canSprintFromDescendInto(ctx, current, next)) { + + if (next instanceof MovementDescend && pathPosition < path.length() - 3) { + IMovement next_next = path.movements().get(pathPosition + 2); + if (next_next instanceof MovementDescend && !canSprintFromDescendInto(ctx, next, next_next)) { + return false; + } + + } if (ctx.playerFeet().equals(current.getDest())) { pathPosition++; onChangeInPathPosition(); onTick(); } + return true; } //logDebug("Turning off sprinting " + movement + " " + next + " " + movement.getDirection() + " " + next.getDirection().down() + " " + next.getDirection().down().equals(movement.getDirection()));