This commit is contained in:
Leijurv
2019-09-19 12:53:15 -07:00
parent 0504a1d4bf
commit 396a96d604
77 changed files with 658 additions and 683 deletions

View File

@@ -19,11 +19,7 @@ package baritone.api.cache;
import baritone.api.utils.BetterBlockPos; import baritone.api.utils.BetterBlockPos;
import java.util.Arrays; import java.util.*;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;

View File

@@ -18,7 +18,6 @@
package baritone.api.cache; package baritone.api.cache;
import baritone.api.utils.BetterBlockPos; import baritone.api.utils.BetterBlockPos;
import net.minecraft.util.math.BlockPos;
import java.util.Date; import java.util.Date;
@@ -82,10 +81,10 @@ public class Waypoint implements IWaypoint {
@Override @Override
public String toString() { public String toString() {
return String.format( return String.format(
"%s %s %s", "%s %s %s",
name, name,
BetterBlockPos.from(location).toString(), BetterBlockPos.from(location).toString(),
new Date(creationTimestamp).toString() new Date(creationTimestamp).toString()
); );
} }

View File

@@ -44,9 +44,9 @@ public class Overrideable<T> {
@Override @Override
public String toString() { public String toString() {
return String.format( return String.format(
"Overrideable{modified=%b,value=%s}", "Overrideable{modified=%b,value=%s}",
modified, modified,
value.toString() value.toString()
); );
} }
} }

View File

@@ -40,10 +40,10 @@ public interface AbstractGameEventListener extends IGameEventListener {
default void onSendChatMessage(ChatEvent event) {} default void onSendChatMessage(ChatEvent event) {}
@Override @Override
default void onPreTabComplete(TabCompleteEvent.Pre event) {}; default void onPreTabComplete(TabCompleteEvent.Pre event) {}
@Override @Override
default void onPostTabComplete(TabCompleteEvent.Post event) {}; default void onPostTabComplete(TabCompleteEvent.Post event) {}
@Override @Override
default void onChunkEvent(ChunkEvent event) {} default void onChunkEvent(ChunkEvent event) {}

View File

@@ -69,10 +69,10 @@ public class GoalBlock implements Goal, IGoalRenderPos {
@Override @Override
public String toString() { public String toString() {
return String.format( return String.format(
"GoalBlock{x=%s,y=%s,z=%s}", "GoalBlock{x=%s,y=%s,z=%s}",
SettingsUtil.maybeCensor(x), SettingsUtil.maybeCensor(x),
SettingsUtil.maybeCensor(y), SettingsUtil.maybeCensor(y),
SettingsUtil.maybeCensor(z) SettingsUtil.maybeCensor(z)
); );
} }

View File

@@ -63,10 +63,10 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos {
@Override @Override
public String toString() { public String toString() {
return String.format( return String.format(
"GoalGetToBlock{x=%s,y=%s,z=%s}", "GoalGetToBlock{x=%s,y=%s,z=%s}",
SettingsUtil.maybeCensor(x), SettingsUtil.maybeCensor(x),
SettingsUtil.maybeCensor(y), SettingsUtil.maybeCensor(y),
SettingsUtil.maybeCensor(z) SettingsUtil.maybeCensor(z)
); );
} }
} }

View File

@@ -19,7 +19,7 @@ package baritone.api.pathing.goals;
/** /**
* Invert any goal. * Invert any goal.
* * <p>
* In the old chat control system, #invert just tried to pick a {@link GoalRunAway} that <i>effectively</i> inverted the * In the old chat control system, #invert just tried to pick a {@link GoalRunAway} that <i>effectively</i> inverted the
* current goal. This goal just reverses the heuristic to act as a TRUE invert. Inverting a Y level? Baritone tries to * current goal. This goal just reverses the heuristic to act as a TRUE invert. Inverting a Y level? Baritone tries to
* get away from that Y level. Inverting a GoalBlock? Baritone will try to make distance whether it's in the X, Y or Z * get away from that Y level. Inverting a GoalBlock? Baritone will try to make distance whether it's in the X, Y or Z

View File

@@ -58,11 +58,11 @@ public class GoalNear implements Goal, IGoalRenderPos {
@Override @Override
public String toString() { public String toString() {
return String.format( return String.format(
"GoalNear{x=%s, y=%s, z=%s, rangeSq=%d}", "GoalNear{x=%s, y=%s, z=%s, rangeSq=%d}",
SettingsUtil.maybeCensor(x), SettingsUtil.maybeCensor(x),
SettingsUtil.maybeCensor(y), SettingsUtil.maybeCensor(y),
SettingsUtil.maybeCensor(z), SettingsUtil.maybeCensor(z),
rangeSq rangeSq
); );
} }
} }

View File

@@ -84,9 +84,9 @@ public class GoalRunAway implements Goal {
public String toString() { public String toString() {
if (maintainY != null) { if (maintainY != null) {
return String.format( return String.format(
"GoalRunAwayFromMaintainY y=%s, %s", "GoalRunAwayFromMaintainY y=%s, %s",
SettingsUtil.maybeCensor(maintainY), SettingsUtil.maybeCensor(maintainY),
Arrays.asList(from) Arrays.asList(from)
); );
} else { } else {
return "GoalRunAwayFrom" + Arrays.asList(from); return "GoalRunAwayFrom" + Arrays.asList(from);

View File

@@ -66,12 +66,12 @@ public class GoalStrictDirection implements Goal {
@Override @Override
public String toString() { public String toString() {
return String.format( return String.format(
"GoalStrictDirection{x=%s, y=%s, z=%s, dx=%s, dz=%s}", "GoalStrictDirection{x=%s, y=%s, z=%s, dx=%s, dz=%s}",
SettingsUtil.maybeCensor(x), SettingsUtil.maybeCensor(x),
SettingsUtil.maybeCensor(y), SettingsUtil.maybeCensor(y),
SettingsUtil.maybeCensor(z), SettingsUtil.maybeCensor(z),
SettingsUtil.maybeCensor(dx), SettingsUtil.maybeCensor(dx),
SettingsUtil.maybeCensor(dz) SettingsUtil.maybeCensor(dz)
); );
} }
} }

View File

@@ -75,10 +75,10 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos {
@Override @Override
public String toString() { public String toString() {
return String.format( return String.format(
"GoalTwoBlocks{x=%s,y=%s,z=%s}", "GoalTwoBlocks{x=%s,y=%s,z=%s}",
SettingsUtil.maybeCensor(x), SettingsUtil.maybeCensor(x),
SettingsUtil.maybeCensor(y), SettingsUtil.maybeCensor(y),
SettingsUtil.maybeCensor(z) SettingsUtil.maybeCensor(z)
); );
} }
} }

View File

@@ -67,9 +67,9 @@ public class GoalXZ implements Goal {
@Override @Override
public String toString() { public String toString() {
return String.format( return String.format(
"GoalXZ{x=%s,z=%s}", "GoalXZ{x=%s,z=%s}",
SettingsUtil.maybeCensor(x), SettingsUtil.maybeCensor(x),
SettingsUtil.maybeCensor(z) SettingsUtil.maybeCensor(z)
); );
} }

View File

@@ -61,8 +61,8 @@ public class GoalYLevel implements Goal, ActionCosts {
@Override @Override
public String toString() { public String toString() {
return String.format( return String.format(
"GoalYLevel{y=%s}", "GoalYLevel{y=%s}",
SettingsUtil.maybeCensor(level) SettingsUtil.maybeCensor(level)
); );
} }
} }

View File

@@ -92,9 +92,9 @@ public interface IMineProcess extends IBaritoneProcess {
*/ */
default void mine(int quantity, Block... blocks) { default void mine(int quantity, Block... blocks) {
mine(quantity, new BlockOptionalMetaLookup( mine(quantity, new BlockOptionalMetaLookup(
Arrays.stream(blocks) Arrays.stream(blocks)
.map(BlockOptionalMeta::new) .map(BlockOptionalMeta::new)
.toArray(BlockOptionalMeta[]::new) .toArray(BlockOptionalMeta[]::new)
)); ));
} }

View File

@@ -51,7 +51,7 @@ public class CompositeSchematic extends AbstractSchematic {
private CompositeSchematicEntry getSchematic(int x, int y, int z, IBlockState currentState) { private CompositeSchematicEntry getSchematic(int x, int y, int z, IBlockState currentState) {
for (CompositeSchematicEntry entry : schematicArr) { for (CompositeSchematicEntry entry : schematicArr) {
if (x >= entry.x && y >= entry.y && z >= entry.z && if (x >= entry.x && y >= entry.y && z >= entry.z &&
entry.schematic.inSchematic(x - entry.x, y - entry.y, z - entry.z, currentState)) { entry.schematic.inSchematic(x - entry.x, y - entry.y, z - entry.z, currentState)) {
return entry; return entry;
} }
} }

View File

@@ -68,7 +68,7 @@ public interface ISelection {
/** /**
* Returns a new {@link ISelection} contracted in the specified direction by the specified number of blocks. * Returns a new {@link ISelection} contracted in the specified direction by the specified number of blocks.
* * <p>
* Note that, for example, if the direction specified is UP, the bottom of the selection will be shifted up. If it * Note that, for example, if the direction specified is UP, the bottom of the selection will be shifted up. If it
* is DOWN, the top of the selection will be shifted down. * is DOWN, the top of the selection will be shifted down.
* *

View File

@@ -91,7 +91,7 @@ public interface ISelectionManager {
/** /**
* Replaces the specified {@link ISelection} with one contracted in the specified direction by the specified number * Replaces the specified {@link ISelection} with one contracted in the specified direction by the specified number
* of blocks. * of blocks.
* * <p>
* Note that, for example, if the direction specified is UP, the bottom of the selection will be shifted up. If it * Note that, for example, if the direction specified is UP, the bottom of the selection will be shifted up. If it
* is DOWN, the top of the selection will be shifted down. * is DOWN, the top of the selection will be shifted down.
* *

View File

@@ -203,10 +203,10 @@ public final class BetterBlockPos extends BlockPos {
@Nonnull @Nonnull
public String toString() { public String toString() {
return String.format( return String.format(
"BetterBlockPos{x=%s,y=%s,z=%s}", "BetterBlockPos{x=%s,y=%s,z=%s}",
SettingsUtil.maybeCensor(x), SettingsUtil.maybeCensor(x),
SettingsUtil.maybeCensor(y), SettingsUtil.maybeCensor(y),
SettingsUtil.maybeCensor(z) SettingsUtil.maybeCensor(z)
); );
} }
} }

View File

@@ -35,20 +35,20 @@ public class BlockOptionalMetaLookup {
public BlockOptionalMetaLookup(Block... blocks) { public BlockOptionalMetaLookup(Block... blocks) {
this.boms = Arrays.stream(blocks) this.boms = Arrays.stream(blocks)
.map(BlockOptionalMeta::new) .map(BlockOptionalMeta::new)
.toArray(BlockOptionalMeta[]::new); .toArray(BlockOptionalMeta[]::new);
} }
public BlockOptionalMetaLookup(List<Block> blocks) { public BlockOptionalMetaLookup(List<Block> blocks) {
this.boms = blocks.stream() this.boms = blocks.stream()
.map(BlockOptionalMeta::new) .map(BlockOptionalMeta::new)
.toArray(BlockOptionalMeta[]::new); .toArray(BlockOptionalMeta[]::new);
} }
public BlockOptionalMetaLookup(String... blocks) { public BlockOptionalMetaLookup(String... blocks) {
this.boms = Arrays.stream(blocks) this.boms = Arrays.stream(blocks)
.map(BlockOptionalMeta::new) .map(BlockOptionalMeta::new)
.toArray(BlockOptionalMeta[]::new); .toArray(BlockOptionalMeta[]::new);
} }
public boolean has(Block block) { public boolean has(Block block) {
@@ -88,8 +88,8 @@ public class BlockOptionalMetaLookup {
@Override @Override
public String toString() { public String toString() {
return String.format( return String.format(
"BlockOptionalMetaLookup{%s}", "BlockOptionalMetaLookup{%s}",
Arrays.toString(boms) Arrays.toString(boms)
); );
} }
} }

View File

@@ -123,7 +123,7 @@ public class SettingsUtil {
/** /**
* Gets the type of a setting and returns it as a string, with package names stripped. * Gets the type of a setting and returns it as a string, with package names stripped.
* * <p>
* For example, if the setting type is {@code java.util.List<java.lang.String>}, this function returns * For example, if the setting type is {@code java.util.List<java.lang.String>}, this function returns
* {@code List<String>}. * {@code List<String>}.
* *
@@ -132,7 +132,7 @@ public class SettingsUtil {
*/ */
public static String settingTypeToString(Settings.Setting setting) { public static String settingTypeToString(Settings.Setting setting) {
return setting.getType().getTypeName() return setting.getType().getTypeName()
.replaceAll("(?:\\w+\\.)+(\\w+)", "$1"); .replaceAll("(?:\\w+\\.)+(\\w+)", "$1");
} }
public static <T> String settingValueToString(Settings.Setting<T> setting, T value) throws IllegalArgumentException { public static <T> String settingValueToString(Settings.Setting<T> setting, T value) throws IllegalArgumentException {

View File

@@ -39,19 +39,19 @@ import java.util.stream.Stream;
* The {@link ArgConsumer} is how {@link Command}s read the arguments passed to them. This class has many benefits: * The {@link ArgConsumer} is how {@link Command}s read the arguments passed to them. This class has many benefits:
* *
* <ul> * <ul>
* <li>Mutability. The whole concept of the {@link ArgConsumer} is to let you gradually consume arguments in any way * <li>Mutability. The whole concept of the {@link ArgConsumer} is to let you gradually consume arguments in any way
* you'd like. You can change your consumption based on earlier arguments, for subcommands for example.</li> * you'd like. You can change your consumption based on earlier arguments, for subcommands for example.</li>
* <li>You don't need to keep track of your consumption. The {@link ArgConsumer} keeps track of the arguments you * <li>You don't need to keep track of your consumption. The {@link ArgConsumer} keeps track of the arguments you
* consume so that it can throw detailed exceptions whenever something is out of the ordinary. Additionally, if you * consume so that it can throw detailed exceptions whenever something is out of the ordinary. Additionally, if you
* need to retrieve an argument after you've already consumed it - look no further than {@link #consumed()}!</li> * need to retrieve an argument after you've already consumed it - look no further than {@link #consumed()}!</li>
* <li>Easy retrieval of many different types. If you need to retrieve an instance of an int or float for example, * <li>Easy retrieval of many different types. If you need to retrieve an instance of an int or float for example,
* look no further than {@link #getAs(Class)}. If you need a more powerful way of retrieving data, try out the many * look no further than {@link #getAs(Class)}. If you need a more powerful way of retrieving data, try out the many
* {@link #getDatatype(Class)} methods.</li> * {@link #getDatatype(Class)} methods.</li>
* <li>It's very easy to throw detailed exceptions. The {@link ArgConsumer} has many different methods that can * <li>It's very easy to throw detailed exceptions. The {@link ArgConsumer} has many different methods that can
* enforce the number of arguments, the type of arguments, and more, throwing different types of * enforce the number of arguments, the type of arguments, and more, throwing different types of
* {@link CommandException}s if something seems off. You're recommended to do all validation and store all needed * {@link CommandException}s if something seems off. You're recommended to do all validation and store all needed
* data in variables BEFORE logging any data to chat via {@link Helper#logDirect(String)}, so that the error * data in variables BEFORE logging any data to chat via {@link Helper#logDirect(String)}, so that the error
* handlers can do their job and log the error to chat.</li> * handlers can do their job and log the error to chat.</li>
* </ul> * </ul>
*/ */
public class ArgConsumer implements Cloneable { public class ArgConsumer implements Cloneable {
@@ -913,11 +913,11 @@ public class ArgConsumer implements Cloneable {
* into three {@link CommandArgument}s {@code "arg1"}, {@code "arg2"}, and {@code "arg3"}: * into three {@link CommandArgument}s {@code "arg1"}, {@code "arg2"}, and {@code "arg3"}:
* *
* <ul> * <ul>
* <li>{@code rawRest()} would return <code>arg1 arg2&nbsp;&nbsp;arg3</code></li> * <li>{@code rawRest()} would return <code>arg1 arg2&nbsp;&nbsp;arg3</code></li>
* <li>After calling {@link #get()}, {@code rawRest()} would return <code>arg2&nbsp;&nbsp;arg3</code> (note the * <li>After calling {@link #get()}, {@code rawRest()} would return <code>arg2&nbsp;&nbsp;arg3</code> (note the
* double space - it is preserved!)</li> * double space - it is preserved!)</li>
* <li>After calling {@link #get()} again, {@code rawRest()} would return {@code "arg3"}</li> * <li>After calling {@link #get()} again, {@code rawRest()} would return {@code "arg3"}</li>
* <li>After calling {@link #get()} one last time, {@code rawRest()} would return {@code ""}</li> * <li>After calling {@link #get()} one last time, {@code rawRest()} would return {@code ""}</li>
* </ul> * </ul>
* *
* @return The "raw rest" of the string. * @return The "raw rest" of the string.

View File

@@ -40,13 +40,13 @@ import java.util.stream.Stream;
* <p> * <p>
* The recommended way to use this class is: * The recommended way to use this class is:
* <ul> * <ul>
* <li>Create a new instance with the empty constructor</li> * <li>Create a new instance with the empty constructor</li>
* <li>Use {@code append}, {@code prepend} or {@code add<something>} methods to add completions</li> * <li>Use {@code append}, {@code prepend} or {@code add<something>} methods to add completions</li>
* <li>Sort using {@link #sort(Comparator)} or {@link #sortAlphabetically()} and then filter by prefix using * <li>Sort using {@link #sort(Comparator)} or {@link #sortAlphabetically()} and then filter by prefix using
* {@link #filterPrefix(String)}</li> * {@link #filterPrefix(String)}</li>
* <li>Get the stream using {@link #stream()}</li> * <li>Get the stream using {@link #stream()}</li>
* <li>Pass it up to whatever's calling your tab complete function (i.e. * <li>Pass it up to whatever's calling your tab complete function (i.e.
* {@link CommandManager#tabComplete(CommandExecution)} or {@link ArgConsumer#tabCompleteDatatype(Class)})</li> * {@link CommandManager#tabComplete(CommandExecution)} or {@link ArgConsumer#tabCompleteDatatype(Class)})</li>
* </ul> * </ul>
* <p> * <p>
* For advanced users: if you're intercepting {@link TabCompleteEvent}s directly, use {@link #build()} instead for an * For advanced users: if you're intercepting {@link TabCompleteEvent}s directly, use {@link #build()} instead for an

View File

@@ -26,17 +26,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(GuiChat.ChatTabCompleter.class) @Mixin(GuiChat.ChatTabCompleter.class)
public abstract class MixinChatTabCompleter extends MixinTabCompleter { public abstract class MixinChatTabCompleter extends MixinTabCompleter {
@Inject( @Inject(
method = "<init>*", method = "<init>*",
at = @At("RETURN") at = @At("RETURN")
) )
private void onConstruction(CallbackInfo ci) { private void onConstruction(CallbackInfo ci) {
isChatCompleter = true; isChatCompleter = true;
} }
@Inject( @Inject(
method = "complete", method = "complete",
at = @At("HEAD"), at = @At("HEAD"),
cancellable = true cancellable = true
) )
private void onComplete(CallbackInfo ci) { private void onComplete(CallbackInfo ci) {
if (dontComplete) { if (dontComplete) {

View File

@@ -32,9 +32,9 @@ public abstract class MixinGuiChat implements net.minecraft.util.ITabCompleter {
private TabCompleter tabCompleter; private TabCompleter tabCompleter;
@Inject( @Inject(
method = "setCompletions", method = "setCompletions",
at = @At("HEAD"), at = @At("HEAD"),
cancellable = true cancellable = true
) )
private void onSetCompletions(String[] newCompl, CallbackInfo ci) { private void onSetCompletions(String[] newCompl, CallbackInfo ci) {
if (((ITabCompleter) tabCompleter).onGuiChatSetCompletions(newCompl)) { if (((ITabCompleter) tabCompleter).onGuiChatSetCompletions(newCompl)) {

View File

@@ -45,16 +45,16 @@ public abstract class MixinItemStack implements IItemStack {
} }
@Inject( @Inject(
method = "<init>*", method = "<init>*",
at = @At("RETURN") at = @At("RETURN")
) )
private void onInit(CallbackInfo ci) { private void onInit(CallbackInfo ci) {
recalculateHash(); recalculateHash();
} }
@Inject( @Inject(
method = "setItemDamage", method = "setItemDamage",
at = @At("TAIL") at = @At("TAIL")
) )
private void onItemDamageSet(CallbackInfo ci) { private void onItemDamageSet(CallbackInfo ci) {
recalculateHash(); recalculateHash();

View File

@@ -19,11 +19,7 @@ package baritone.launch.mixins;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@@ -41,8 +37,8 @@ public abstract class MixinStateImplementation {
private int hashCode; private int hashCode;
@Inject( @Inject(
method = "<init>*", method = "<init>*",
at = @At("RETURN") at = @At("RETURN")
) )
private void onInit(CallbackInfo ci) { private void onInit(CallbackInfo ci) {
hashCode = properties.hashCode(); hashCode = properties.hashCode();

View File

@@ -21,7 +21,6 @@ import baritone.api.BaritoneAPI;
import baritone.api.IBaritone; import baritone.api.IBaritone;
import baritone.api.event.events.TabCompleteEvent; import baritone.api.event.events.TabCompleteEvent;
import baritone.utils.accessor.ITabCompleter; import baritone.utils.accessor.ITabCompleter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.gui.GuiTextField;
import net.minecraft.util.TabCompleter; import net.minecraft.util.TabCompleter;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
@@ -64,9 +63,9 @@ public abstract class MixinTabCompleter implements ITabCompleter {
} }
@Inject( @Inject(
method = "requestCompletions", method = "requestCompletions",
at = @At("HEAD"), at = @At("HEAD"),
cancellable = true cancellable = true
) )
private void onRequestCompletions(String prefix, CallbackInfo ci) { private void onRequestCompletions(String prefix, CallbackInfo ci) {
if (!isChatCompleter) { if (!isChatCompleter) {

View File

@@ -21,17 +21,14 @@ import baritone.api.BaritoneAPI;
import baritone.api.IBaritone; import baritone.api.IBaritone;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.event.listener.IEventBus; import baritone.api.event.listener.IEventBus;
import baritone.api.utils.command.BaritoneChatControl;
import baritone.api.utils.Helper; import baritone.api.utils.Helper;
import baritone.api.utils.IPlayerContext; import baritone.api.utils.IPlayerContext;
import baritone.api.utils.command.manager.CommandManager;
import baritone.behavior.*; import baritone.behavior.*;
import baritone.cache.WorldProvider; import baritone.cache.WorldProvider;
import baritone.event.GameEventHandler; import baritone.event.GameEventHandler;
import baritone.process.*; import baritone.process.*;
import baritone.selection.SelectionManager; import baritone.selection.SelectionManager;
import baritone.utils.*; import baritone.utils.*;
import baritone.utils.command.defaults.DefaultCommands;
import baritone.utils.player.PrimaryPlayerContext; import baritone.utils.player.PrimaryPlayerContext;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;

View File

@@ -28,7 +28,6 @@ import net.minecraft.inventory.ClickType;
import net.minecraft.item.*; import net.minecraft.item.*;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.OptionalInt; import java.util.OptionalInt;

View File

@@ -19,11 +19,7 @@ package baritone.behavior;
import baritone.Baritone; import baritone.Baritone;
import baritone.api.behavior.IPathingBehavior; import baritone.api.behavior.IPathingBehavior;
import baritone.api.event.events.PathEvent; import baritone.api.event.events.*;
import baritone.api.event.events.PlayerUpdateEvent;
import baritone.api.event.events.RenderEvent;
import baritone.api.event.events.SprintStateEvent;
import baritone.api.event.events.TickEvent;
import baritone.api.pathing.calc.IPath; import baritone.api.pathing.calc.IPath;
import baritone.api.pathing.goals.Goal; import baritone.api.pathing.goals.Goal;
import baritone.api.pathing.goals.GoalXZ; import baritone.api.pathing.goals.GoalXZ;
@@ -137,8 +133,8 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
BetterBlockPos calcFrom = inProgress.getStart(); BetterBlockPos calcFrom = inProgress.getStart();
Optional<IPath> currentBest = inProgress.bestPathSoFar(); Optional<IPath> currentBest = inProgress.bestPathSoFar();
if ((current == null || !current.getPath().getDest().equals(calcFrom)) // if current ends in inProgress's start, then we're ok if ((current == null || !current.getPath().getDest().equals(calcFrom)) // if current ends in inProgress's start, then we're ok
&& !calcFrom.equals(ctx.playerFeet()) && !calcFrom.equals(expectedSegmentStart) // if current starts in our playerFeet or pathStart, then we're ok && !calcFrom.equals(ctx.playerFeet()) && !calcFrom.equals(expectedSegmentStart) // if current starts in our playerFeet or pathStart, then we're ok
&& (!currentBest.isPresent() || (!currentBest.get().positions().contains(ctx.playerFeet()) && !currentBest.get().positions().contains(expectedSegmentStart))) // if && (!currentBest.isPresent() || (!currentBest.get().positions().contains(ctx.playerFeet()) && !currentBest.get().positions().contains(expectedSegmentStart))) // if
) { ) {
// when it was *just* started, currentBest will be empty so we need to also check calcFrom since that's always present // when it was *just* started, currentBest will be empty so we need to also check calcFrom since that's always present
inProgress.cancel(); // cancellation doesn't dispatch any events inProgress.cancel(); // cancellation doesn't dispatch any events

View File

@@ -88,7 +88,8 @@ public final class ChunkPacker {
IBlockState[] blocks = new IBlockState[256]; IBlockState[] blocks = new IBlockState[256];
for (int z = 0; z < 16; z++) { for (int z = 0; z < 16; z++) {
https://www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html https:
//www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
for (int y = 255; y >= 0; y--) { for (int y = 255; y >= 0; y--) {
int index = CachedChunk.getPositionIndex(x, y, z); int index = CachedChunk.getPositionIndex(x, y, z);

View File

@@ -21,7 +21,6 @@ import baritone.api.cache.IWaypoint;
import baritone.api.cache.IWaypointCollection; import baritone.api.cache.IWaypointCollection;
import baritone.api.cache.Waypoint; import baritone.api.cache.Waypoint;
import baritone.api.utils.BetterBlockPos; import baritone.api.utils.BetterBlockPos;
import net.minecraft.util.math.BlockPos;
import java.io.*; import java.io.*;
import java.nio.file.Files; import java.nio.file.Files;

View File

@@ -31,11 +31,7 @@ import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage; import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import static java.util.Objects.nonNull; import static java.util.Objects.nonNull;
@@ -89,8 +85,8 @@ public enum WorldScanner implements IWorldScanner {
} }
} }
if ((allUnloaded && foundChunks) if ((allUnloaded && foundChunks)
|| (res.size() >= max || (res.size() >= max
&& (searchRadiusSq > maxSearchRadiusSq || (searchRadiusSq > 1 && foundWithinY))) && (searchRadiusSq > maxSearchRadiusSq || (searchRadiusSq > 1 && foundWithinY)))
) { ) {
return res; return res;
} }

View File

@@ -29,7 +29,6 @@ import baritone.utils.BaritoneProcessHelper;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -83,11 +82,11 @@ public final class FollowProcess extends BaritoneProcessHelper implements IFollo
private void scanWorld() { private void scanWorld() {
cache = Stream.of(ctx.world().loadedEntityList, ctx.world().playerEntities) cache = Stream.of(ctx.world().loadedEntityList, ctx.world().playerEntities)
.flatMap(List::stream) .flatMap(List::stream)
.filter(this::followable) .filter(this::followable)
.filter(this.filter) .filter(this.filter)
.distinct() .distinct()
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@Override @Override

View File

@@ -33,7 +33,10 @@ import net.minecraft.init.Blocks;
import net.minecraft.inventory.ContainerPlayer; import net.minecraft.inventory.ContainerPlayer;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import java.util.*; import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
public final class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBlockProcess { public final class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBlockProcess {

View File

@@ -19,21 +19,21 @@ public class Selection implements ISelection {
this.pos2 = pos2; this.pos2 = pos2;
this.min = new BetterBlockPos( this.min = new BetterBlockPos(
Math.min(pos1.x, pos2.x), Math.min(pos1.x, pos2.x),
Math.min(pos1.y, pos2.y), Math.min(pos1.y, pos2.y),
Math.min(pos1.z, pos2.z) Math.min(pos1.z, pos2.z)
); );
this.max = new BetterBlockPos( this.max = new BetterBlockPos(
Math.max(pos1.x, pos2.x), Math.max(pos1.x, pos2.x),
Math.max(pos1.y, pos2.y), Math.max(pos1.y, pos2.y),
Math.max(pos1.z, pos2.z) Math.max(pos1.z, pos2.z)
); );
this.size = new Vec3i( this.size = new Vec3i(
max.x - min.x + 1, max.x - min.x + 1,
max.y - min.y + 1, max.y - min.y + 1,
max.z - min.z + 1 max.z - min.z + 1
); );
this.aabb = new AxisAlignedBB(this.min, this.max.add(1, 1, 1)); this.aabb = new AxisAlignedBB(this.min, this.max.add(1, 1, 1));
@@ -81,7 +81,7 @@ public class Selection implements ISelection {
/** /**
* Since it might not be immediately obvious what this does, let me explain. * Since it might not be immediately obvious what this does, let me explain.
* * <p>
* Let's say you specify EnumFacing.UP, this functions returns if pos2 is the highest BlockPos. * Let's say you specify EnumFacing.UP, this functions returns if pos2 is the highest BlockPos.
* If you specify EnumFacing.DOWN, it returns if pos2 is the lowest BlockPos. * If you specify EnumFacing.DOWN, it returns if pos2 is the lowest BlockPos.
* *

View File

@@ -28,7 +28,7 @@ import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import java.awt.Color; import java.awt.*;
import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL11.*;

View File

@@ -36,7 +36,7 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import java.awt.Color; import java.awt.*;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;

View File

@@ -118,7 +118,7 @@ public class ToolSet {
} else if (speed == highestSpeed) { } else if (speed == highestSpeed) {
int cost = getMaterialCost(itemStack); int cost = getMaterialCost(itemStack);
if ((cost < lowestCost && (silkTouch || !bestSilkTouch)) || if ((cost < lowestCost && (silkTouch || !bestSilkTouch)) ||
(preferSilkTouch && !bestSilkTouch && silkTouch)) { (preferSilkTouch && !bestSilkTouch && silkTouch)) {
highestSpeed = speed; highestSpeed = speed;
best = i; best = i;
lowestCost = cost; lowestCost = cost;

View File

@@ -54,10 +54,10 @@ public class AxisCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"The axis command sets a goal that tells Baritone to head towards the nearest axis. That is, X=0 or Z=0.", "The axis command sets a goal that tells Baritone to head towards the nearest axis. That is, X=0 or Z=0.",
"", "",
"Usage:", "Usage:",
"> axis" "> axis"
); );
} }
} }

View File

@@ -62,10 +62,10 @@ public class BlacklistCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"While, for example, mining, this command blacklists the closest block so that Baritone won't attempt to get to it.", "While, for example, mining, this command blacklists the closest block so that Baritone won't attempt to get to it.",
"", "",
"Usage:", "Usage:",
"> blacklist" "> blacklist"
); );
} }
} }

View File

@@ -89,11 +89,11 @@ public class BuildCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"Build a schematic from a file.", "Build a schematic from a file.",
"", "",
"Usage:", "Usage:",
"> build <filename> - Loads and builds '<filename>.schematic'", "> build <filename> - Loads and builds '<filename>.schematic'",
"> build <filename> <x> <y> <z> - Custom position" "> build <filename> <x> <y> <z> - Custom position"
); );
} }
} }

View File

@@ -51,10 +51,10 @@ public class CancelCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"The cancel command tells Baritons to stop whatever it's currently doing.", "The cancel command tells Baritons to stop whatever it's currently doing.",
"", "",
"Usage:", "Usage:",
"> cancel" "> cancel"
); );
} }
} }

View File

@@ -43,7 +43,7 @@ public class ChestsCommand extends Command {
protected void executed(String label, ArgConsumer args, Settings settings) { protected void executed(String label, ArgConsumer args, Settings settings) {
args.requireMax(0); args.requireMax(0);
Set<Map.Entry<BlockPos, IRememberedInventory>> entries = Set<Map.Entry<BlockPos, IRememberedInventory>> entries =
ctx.worldData().getContainerMemory().getRememberedInventories().entrySet(); ctx.worldData().getContainerMemory().getRememberedInventories().entrySet();
if (entries.isEmpty()) { if (entries.isEmpty()) {
throw new CommandInvalidStateException("No remembered inventories"); throw new CommandInvalidStateException("No remembered inventories");
@@ -77,10 +77,10 @@ public class ChestsCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"The chests command lists remembered inventories, I guess?", "The chests command lists remembered inventories, I guess?",
"", "",
"Usage:", "Usage:",
"> chests" "> chests"
); );
} }
} }

View File

@@ -73,11 +73,11 @@ public class ClearareaCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"Clear an area of all blocks.", "Clear an area of all blocks.",
"", "",
"Usage:", "Usage:",
"> cleararea - Clears the area marked by your current position and the current GoalBlock", "> cleararea - Clears the area marked by your current position and the current GoalBlock",
"> cleararea <x> <y> <z> - Custom second corner rather than your goal" "> cleararea <x> <y> <z> - Custom second corner rather than your goal"
); );
} }
} }

View File

@@ -51,10 +51,10 @@ public class ClickCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"Opens click dude", "Opens click dude",
"", "",
"Usage:", "Usage:",
"> click" "> click"
); );
} }
} }

View File

@@ -62,12 +62,12 @@ public class ComeCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"The come command tells Baritone to head towards your camera.", "The come command tells Baritone to head towards your camera.",
"", "",
"This can be useful in hacked clients where freecam doesn't move your player position.", "This can be useful in hacked clients where freecam doesn't move your player position.",
"", "",
"Usage:", "Usage:",
"> come" "> come"
); );
} }
} }

View File

@@ -26,44 +26,44 @@ import static java.util.Arrays.asList;
public class DefaultCommands { public class DefaultCommands {
public static final List<Command> COMMANDS = Collections.unmodifiableList(asList( public static final List<Command> COMMANDS = Collections.unmodifiableList(asList(
new HelpCommand(), new HelpCommand(),
new SetCommand(), new SetCommand(),
new CommandAlias(asList("modified", "mod", "baritone", "modifiedsettings"), "List modified settings", "set modified"), new CommandAlias(asList("modified", "mod", "baritone", "modifiedsettings"), "List modified settings", "set modified"),
new CommandAlias("reset", "Reset all settings or just one", "set reset"), new CommandAlias("reset", "Reset all settings or just one", "set reset"),
new GoalCommand(), new GoalCommand(),
new PathCommand(), new PathCommand(),
new ProcCommand(), new ProcCommand(),
new VersionCommand(), new VersionCommand(),
new RepackCommand(), new RepackCommand(),
new BuildCommand(), new BuildCommand(),
new SchematicaCommand(), new SchematicaCommand(),
new ComeCommand(), new ComeCommand(),
new AxisCommand(), new AxisCommand(),
new CancelCommand(), new CancelCommand(),
new ForceCancelCommand(), new ForceCancelCommand(),
new GcCommand(), new GcCommand(),
new InvertCommand(), new InvertCommand(),
new ClearareaCommand(), new ClearareaCommand(),
PauseResumeCommands.pauseCommand, PauseResumeCommands.pauseCommand,
PauseResumeCommands.resumeCommand, PauseResumeCommands.resumeCommand,
PauseResumeCommands.pausedCommand, PauseResumeCommands.pausedCommand,
new TunnelCommand(), new TunnelCommand(),
new RenderCommand(), new RenderCommand(),
new FarmCommand(), new FarmCommand(),
new ChestsCommand(), new ChestsCommand(),
new FollowCommand(), new FollowCommand(),
new ExploreFilterCommand(), new ExploreFilterCommand(),
new ReloadAllCommand(), new ReloadAllCommand(),
new SaveAllCommand(), new SaveAllCommand(),
new ExploreCommand(), new ExploreCommand(),
new BlacklistCommand(), new BlacklistCommand(),
new FindCommand(), new FindCommand(),
new MineCommand(), new MineCommand(),
new ClickCommand(), new ClickCommand(),
new ThisWayCommand(), new ThisWayCommand(),
new WaypointsCommand(), new WaypointsCommand(),
new CommandAlias("sethome", "Sets your home waypoint", "waypoints save home"), new CommandAlias("sethome", "Sets your home waypoint", "waypoints save home"),
new CommandAlias("home", "Set goal to your home waypoint", "waypoints goal home"), new CommandAlias("home", "Set goal to your home waypoint", "waypoints goal home"),
new SelCommand() new SelCommand()
)); ));
} }

View File

@@ -49,10 +49,10 @@ public class EmptyCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"", "",
"", "",
"Usage:", "Usage:",
"> " "> "
); );
} }
} }

View File

@@ -42,8 +42,8 @@ public class ExploreCommand extends Command {
} }
GoalXZ goal = args.has() GoalXZ goal = args.has()
? args.getDatatypePost(RelativeGoalXZ.class, ctx.playerFeet()) ? args.getDatatypePost(RelativeGoalXZ.class, ctx.playerFeet())
: new GoalXZ(ctx.playerFeet()); : new GoalXZ(ctx.playerFeet());
baritone.getExploreProcess().explore(goal.getX(), goal.getZ()); baritone.getExploreProcess().explore(goal.getX(), goal.getZ());
logDirect(String.format("Exploring from %s", goal.toString())); logDirect(String.format("Exploring from %s", goal.toString()));
@@ -66,11 +66,11 @@ public class ExploreCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"Tell Baritone to explore randomly. If you used explorefilter before this, it will be applied.", "Tell Baritone to explore randomly. If you used explorefilter before this, it will be applied.",
"", "",
"Usage:", "Usage:",
"> explore - Explore from your current position.", "> explore - Explore from your current position.",
"> explore <x> <z> - Explore from the specified X and Z position." "> explore <x> <z> - Explore from the specified X and Z position."
); );
} }
} }

View File

@@ -81,14 +81,14 @@ public class ExploreFilterCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"Apply an explore filter before using explore, which tells the explore process which chunks have been explored/not explored.", "Apply an explore filter before using explore, which tells the explore process which chunks have been explored/not explored.",
"", "",
"The JSON file will follow this format: [{\"x\":0,\"z\":0},...]", "The JSON file will follow this format: [{\"x\":0,\"z\":0},...]",
"", "",
"If 'invert' is specified, the chunks listed will be considered NOT explored, rather than explored.", "If 'invert' is specified, the chunks listed will be considered NOT explored, rather than explored.",
"", "",
"Usage:", "Usage:",
"> explorefilter <path> [invert] - Load the JSON file referenced by the specified path. If invert is specified, it must be the literal word 'invert'." "> explorefilter <path> [invert] - Load the JSON file referenced by the specified path. If invert is specified, it must be the literal word 'invert'."
); );
} }
} }

View File

@@ -51,10 +51,10 @@ public class FarmCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"The farm command starts farming nearby plants. It harvests mature crops and plants new ones.", "The farm command starts farming nearby plants. It harvests mature crops and plants new ones.",
"", "",
"Usage:", "Usage:",
"> farm" "> farm"
); );
} }
} }

View File

@@ -46,18 +46,18 @@ public class FindCommand extends Command {
BetterBlockPos origin = ctx.playerFeet(); BetterBlockPos origin = ctx.playerFeet();
toFind.stream() toFind.stream()
.flatMap(block -> .flatMap(block ->
ctx.worldData().getCachedWorld().getLocationsOf( ctx.worldData().getCachedWorld().getLocationsOf(
Block.REGISTRY.getNameForObject(block).getPath(), Block.REGISTRY.getNameForObject(block).getPath(),
Integer.MAX_VALUE, Integer.MAX_VALUE,
origin.x, origin.x,
origin.y, origin.y,
4 4
).stream() ).stream()
) )
.map(BetterBlockPos::new) .map(BetterBlockPos::new)
.map(BetterBlockPos::toString) .map(BetterBlockPos::toString)
.forEach(this::logDirect); .forEach(this::logDirect);
} }
@Override @Override
@@ -73,10 +73,10 @@ public class FindCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"", "",
"", "",
"Usage:", "Usage:",
"> " "> "
); );
} }
} }

View File

@@ -77,9 +77,9 @@ public class FollowCommand extends Command {
} }
baritone.getFollowProcess().follow( baritone.getFollowProcess().follow(
classes.isEmpty() classes.isEmpty()
? entities::contains ? entities::contains
: e -> classes.stream().anyMatch(c -> c.isInstance(e)) : e -> classes.stream().anyMatch(c -> c.isInstance(e))
); );
} }
@@ -90,14 +90,14 @@ public class FollowCommand extends Command {
if (classes.isEmpty()) { if (classes.isEmpty()) {
entities.stream() entities.stream()
.map(Entity::toString) .map(Entity::toString)
.forEach(this::logDirect); .forEach(this::logDirect);
} else { } else {
classes.stream() classes.stream()
.map(EntityList::getKey) .map(EntityList::getKey)
.map(Objects::requireNonNull) .map(Objects::requireNonNull)
.map(ResourceLocation::toString) .map(ResourceLocation::toString)
.forEach(this::logDirect); .forEach(this::logDirect);
} }
} }
} }
@@ -106,10 +106,10 @@ public class FollowCommand extends Command {
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) { protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
if (args.hasExactlyOne()) { if (args.hasExactlyOne()) {
return new TabCompleteHelper() return new TabCompleteHelper()
.append(FollowGroup.class) .append(FollowGroup.class)
.append(FollowList.class) .append(FollowList.class)
.filterPrefix(args.getString()) .filterPrefix(args.getString())
.stream(); .stream();
} else { } else {
Class<? extends IDatatype> followType; Class<? extends IDatatype> followType;
@@ -139,13 +139,13 @@ public class FollowCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"The follow command tells Baritone to follow certain kinds of entities.", "The follow command tells Baritone to follow certain kinds of entities.",
"", "",
"Usage:", "Usage:",
"> follow entities - Follows all entities.", "> follow entities - Follows all entities.",
"> follow entity <entity1> <entity2> <...> - Follow certain entities (for example 'skeleton', 'horse' etc.)", "> follow entity <entity1> <entity2> <...> - Follow certain entities (for example 'skeleton', 'horse' etc.)",
"> follow players - Follow players", "> follow players - Follow players",
"> follow player <username1> <username2> <...> - Follow certain players" "> follow player <username1> <username2> <...> - Follow certain players"
); );
} }

View File

@@ -54,10 +54,10 @@ public class ForceCancelCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"Like cancel, but more forceful.", "Like cancel, but more forceful.",
"", "",
"Usage:", "Usage:",
"> forcecancel" "> forcecancel"
); );
} }
} }

View File

@@ -53,10 +53,10 @@ public class GcCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"Calls System.gc().", "Calls System.gc().",
"", "",
"Usage:", "Usage:",
"> gc" "> gc"
); );
} }
} }

View File

@@ -94,16 +94,16 @@ public class GoalCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"The goal command allows you to set or clear Baritone's goal.", "The goal command allows you to set or clear Baritone's goal.",
"", "",
"Wherever a coordinate is expected, you can use ~ just like in regular Minecraft commands. Or, you can just use regular numbers.", "Wherever a coordinate is expected, you can use ~ just like in regular Minecraft commands. Or, you can just use regular numbers.",
"", "",
"Usage:", "Usage:",
"> goal - Set the goal to your current position", "> goal - Set the goal to your current position",
"> goal <reset/clear/none> - Erase the goal", "> goal <reset/clear/none> - Erase the goal",
"> goal <y> - Set the goal to a Y level", "> goal <y> - Set the goal to a Y level",
"> goal <x> <z> - Set the goal to an X,Z position", "> goal <x> <z> - Set the goal to an X,Z position",
"> goal <x> <y> <z> - Set the goal to an X,Y,Z position" "> goal <x> <y> <z> - Set the goal to an X,Y,Z position"
); );
} }
} }

View File

@@ -50,38 +50,38 @@ public class HelpCommand extends Command {
if (!args.has() || args.is(Integer.class)) { if (!args.has() || args.is(Integer.class)) {
Paginator.paginate( Paginator.paginate(
args, new Paginator<>( args, new Paginator<>(
CommandManager.REGISTRY.descendingStream() CommandManager.REGISTRY.descendingStream()
.filter(command -> !command.hiddenFromHelp()) .filter(command -> !command.hiddenFromHelp())
.collect(Collectors.toList()) .collect(Collectors.toList())
), ),
() -> logDirect("All Baritone commands (clickable):"), () -> logDirect("All Baritone commands (clickable):"),
command -> { command -> {
String names = String.join("/", command.names); String names = String.join("/", command.names);
String name = command.names.get(0); String name = command.names.get(0);
ITextComponent shortDescComponent = new TextComponentString(" - " + command.getShortDesc()); ITextComponent shortDescComponent = new TextComponentString(" - " + command.getShortDesc());
shortDescComponent.getStyle().setColor(TextFormatting.DARK_GRAY); shortDescComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
ITextComponent namesComponent = new TextComponentString(names); ITextComponent namesComponent = new TextComponentString(names);
namesComponent.getStyle().setColor(TextFormatting.WHITE); namesComponent.getStyle().setColor(TextFormatting.WHITE);
ITextComponent hoverComponent = new TextComponentString(""); ITextComponent hoverComponent = new TextComponentString("");
hoverComponent.getStyle().setColor(TextFormatting.GRAY); hoverComponent.getStyle().setColor(TextFormatting.GRAY);
hoverComponent.appendSibling(namesComponent); hoverComponent.appendSibling(namesComponent);
hoverComponent.appendText("\n" + command.getShortDesc()); hoverComponent.appendText("\n" + command.getShortDesc());
hoverComponent.appendText("\n\nClick to view full help"); 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.names.get(0));
ITextComponent component = new TextComponentString(name); ITextComponent component = new TextComponentString(name);
component.getStyle().setColor(TextFormatting.GRAY); component.getStyle().setColor(TextFormatting.GRAY);
component.appendSibling(shortDescComponent); component.appendSibling(shortDescComponent);
component.getStyle() component.getStyle()
.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent)) .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent))
.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, clickCommand)); .setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, clickCommand));
return component; return component;
}, },
FORCE_COMMAND_PREFIX + label FORCE_COMMAND_PREFIX + label
); );
} else { } else {
String commandName = args.getString().toLowerCase(); String commandName = args.getString().toLowerCase();
@@ -98,8 +98,8 @@ public class HelpCommand extends Command {
ITextComponent returnComponent = new TextComponentString("Click to return to the help menu"); ITextComponent returnComponent = new TextComponentString("Click to return to the help menu");
returnComponent.getStyle().setClickEvent(new ClickEvent( returnComponent.getStyle().setClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND, ClickEvent.Action.RUN_COMMAND,
FORCE_COMMAND_PREFIX + label FORCE_COMMAND_PREFIX + label
)); ));
logDirect(returnComponent); logDirect(returnComponent);
@@ -123,11 +123,11 @@ public class HelpCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"Using this command, you can view detailed help information on how to use certain commands of Baritone.", "Using this command, you can view detailed help information on how to use certain commands of Baritone.",
"", "",
"Usage:", "Usage:",
"> help - Lists all commands and their short descriptions.", "> help - Lists all commands and their short descriptions.",
"> help <command> - Displays help information on a specific command." "> help <command> - Displays help information on a specific command."
); );
} }
} }

View File

@@ -70,10 +70,10 @@ public class InvertCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"The invert command tells Baritone to head away from the current goal rather than towards it.", "The invert command tells Baritone to head away from the current goal rather than towards it.",
"", "",
"Usage:", "Usage:",
"> invert - Invert the current goal." "> invert - Invert the current goal."
); );
} }
} }

View File

@@ -64,16 +64,16 @@ public class MineCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"The mine command allows you to tell Baritone to search for and mine individual blocks.", "The mine command allows you to tell Baritone to search for and mine individual blocks.",
"", "",
"The specified blocks can be ores (which are commonly cached), or any other block.", "The specified blocks can be ores (which are commonly cached), or any other block.",
"", "",
"Also see the legitMine settings (see #set l legitMine).", "Also see the legitMine settings (see #set l legitMine).",
"", "",
"Usage:", "Usage:",
"> mine diamond_ore - Mines all diamonds it can find.", "> mine diamond_ore - Mines all diamonds it can find.",
"> mine redstone_ore lit_redstone_ore - Mines redstone ore.", "> mine redstone_ore lit_redstone_ore - Mines redstone ore.",
"> mine log:0 - Mines only oak logs." "> mine log:0 - Mines only oak logs."
); );
} }
} }

View File

@@ -69,9 +69,9 @@ public class PathCommand extends Command {
if (!args.has(2)) { if (!args.has(2)) {
return new TabCompleteHelper() return new TabCompleteHelper()
.append("~") .append("~")
.filterPrefix(args.getString()) .filterPrefix(args.getString())
.stream(); .stream();
} }
} }
} }
@@ -87,13 +87,13 @@ public class PathCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"The path command tells Baritone to head towards the current goal.", "The path command tells Baritone to head towards the current goal.",
"", "",
"Usage:", "Usage:",
"> path - Start the pathing.", "> path - Start the pathing.",
"> path <y>", "> path <y>",
"> path <x> <z>", "> path <x> <z>",
"> path <x> <y> <z> - Define the goal here" "> path <x> <y> <z> - Define the goal here"
); );
} }
} }

View File

@@ -33,7 +33,7 @@ import static java.util.Arrays.asList;
/** /**
* Contains the pause, resume, and paused commands. * Contains the pause, resume, and paused commands.
* * <p>
* This thing is scoped to hell, private so far you can't even access it using reflection, because you AREN'T SUPPOSED * This thing is scoped to hell, private so far you can't even access it using reflection, because you AREN'T SUPPOSED
* TO USE THIS to pause and resume Baritone. Make your own process that returns {@link PathingCommandType#REQUEST_PAUSE * TO USE THIS to pause and resume Baritone. Make your own process that returns {@link PathingCommandType#REQUEST_PAUSE
* REQUEST_PAUSE} as needed. * REQUEST_PAUSE} as needed.
@@ -48,35 +48,35 @@ public class PauseResumeCommands {
final boolean[] paused = {false}; final boolean[] paused = {false};
BaritoneAPI.getProvider().getPrimaryBaritone().getPathingControlManager().registerProcess( BaritoneAPI.getProvider().getPrimaryBaritone().getPathingControlManager().registerProcess(
new IBaritoneProcess() { new IBaritoneProcess() {
@Override @Override
public boolean isActive() { public boolean isActive() {
return paused[0]; return paused[0];
} }
@Override @Override
public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) { public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE); return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
} }
@Override @Override
public boolean isTemporary() { public boolean isTemporary() {
return true; return true;
} }
@Override @Override
public void onLostControl() {} public void onLostControl() {}
@Override @Override
public double priority() { public double priority() {
return DEFAULT_PRIORITY + 1; return DEFAULT_PRIORITY + 1;
} }
@Override @Override
public String displayName0() { public String displayName0() {
return "Pause/Resume Commands"; return "Pause/Resume Commands";
}
} }
}
); );
pauseCommand = new Command("pause") { pauseCommand = new Command("pause") {
@@ -105,12 +105,12 @@ public class PauseResumeCommands {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"The pause command tells Baritone to temporarily stop whatever it's doing.", "The pause command tells Baritone to temporarily stop whatever it's doing.",
"", "",
"This can be used to pause pathing, building, following, whatever. A single use of the resume command will start it right back up again!", "This can be used to pause pathing, building, following, whatever. A single use of the resume command will start it right back up again!",
"", "",
"Usage:", "Usage:",
"> pause" "> pause"
); );
} }
}; };
@@ -141,10 +141,10 @@ public class PauseResumeCommands {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"The resume command tells Baritone to resume whatever it was doing when you last used pause.", "The resume command tells Baritone to resume whatever it was doing when you last used pause.",
"", "",
"Usage:", "Usage:",
"> resume" "> resume"
); );
} }
}; };
@@ -170,10 +170,10 @@ public class PauseResumeCommands {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"The paused command tells you if Baritone is currently paused by use of the pause command.", "The paused command tells you if Baritone is currently paused by use of the pause command.",
"", "",
"Usage:", "Usage:",
"> paused" "> paused"
); );
} }
}; };

View File

@@ -48,19 +48,19 @@ public class ProcCommand extends Command {
} }
logDirect(String.format( logDirect(String.format(
"Class: %s\n" + "Class: %s\n" +
"Priority: %f\n" + "Priority: %f\n" +
"Temporary: %b\n" + "Temporary: %b\n" +
"Display name: %s\n" + "Display name: %s\n" +
"Last command: %s", "Last command: %s",
process.getClass().getTypeName(), process.getClass().getTypeName(),
process.priority(), process.priority(),
process.isTemporary(), process.isTemporary(),
process.displayName(), process.displayName(),
pathingControlManager pathingControlManager
.mostRecentCommand() .mostRecentCommand()
.map(PathingCommand::toString) .map(PathingCommand::toString)
.orElse("None") .orElse("None")
)); ));
} }
@@ -77,12 +77,12 @@ public class ProcCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"The proc command provides miscellaneous information about the process currently controlling Baritone.", "The proc command provides miscellaneous information about the process currently controlling Baritone.",
"", "",
"You are not expected to understand this if you aren't familiar with how Baritone works.", "You are not expected to understand this if you aren't familiar with how Baritone works.",
"", "",
"Usage:", "Usage:",
"> proc - View process information, if present" "> proc - View process information, if present"
); );
} }
} }

View File

@@ -51,10 +51,10 @@ public class ReloadAllCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"The reloadall command reloads Baritone's world cache.", "The reloadall command reloads Baritone's world cache.",
"", "",
"Usage:", "Usage:",
"> reloadall" "> reloadall"
); );
} }
} }

View File

@@ -39,12 +39,12 @@ public class RenderCommand extends Command {
BetterBlockPos origin = ctx.playerFeet(); BetterBlockPos origin = ctx.playerFeet();
int renderDistance = (MC.gameSettings.renderDistanceChunks + 1) * 16; int renderDistance = (MC.gameSettings.renderDistanceChunks + 1) * 16;
MC.renderGlobal.markBlockRangeForRenderUpdate( MC.renderGlobal.markBlockRangeForRenderUpdate(
origin.x - renderDistance, origin.x - renderDistance,
0, 0,
origin.z - renderDistance, origin.z - renderDistance,
origin.x + renderDistance, origin.x + renderDistance,
255, 255,
origin.z + renderDistance origin.z + renderDistance
); );
logDirect("Done"); logDirect("Done");
@@ -63,10 +63,10 @@ public class RenderCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"The render command fixes glitched chunk rendering without having to reload all of them.", "The render command fixes glitched chunk rendering without having to reload all of them.",
"", "",
"Usage:", "Usage:",
"> render" "> render"
); );
} }
} }

View File

@@ -51,10 +51,10 @@ public class RepackCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"Repack chunks around you. This basically re-caches them.", "Repack chunks around you. This basically re-caches them.",
"", "",
"Usage:", "Usage:",
"> repack - Repack chunks." "> repack - Repack chunks."
); );
} }
} }

View File

@@ -51,10 +51,10 @@ public class SaveAllCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"The saveall command saves Baritone's world cache.", "The saveall command saves Baritone's world cache.",
"", "",
"Usage:", "Usage:",
"> saveall" "> saveall"
); );
} }
} }

View File

@@ -50,10 +50,10 @@ public class SchematicaCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"Builds the schematica currently open in Schematica.", "Builds the schematica currently open in Schematica.",
"", "",
"Usage:", "Usage:",
"> schematica" "> schematica"
); );
} }
} }

View File

@@ -19,11 +19,7 @@ package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.event.events.RenderEvent; import baritone.api.event.events.RenderEvent;
import baritone.api.schematic.CompositeSchematic; import baritone.api.schematic.*;
import baritone.api.schematic.FillSchematic;
import baritone.api.schematic.ReplaceSchematic;
import baritone.api.schematic.ShellSchematic;
import baritone.api.schematic.WallsSchematic;
import baritone.api.selection.ISelection; import baritone.api.selection.ISelection;
import baritone.api.selection.ISelectionManager; import baritone.api.selection.ISelectionManager;
import baritone.api.utils.BetterBlockPos; import baritone.api.utils.BetterBlockPos;
@@ -44,7 +40,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.Vec3i; import net.minecraft.util.math.Vec3i;
import java.awt.Color; import java.awt.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@@ -109,8 +105,8 @@ public class SelCommand extends Command {
} }
} else if (action == Action.SET || action == Action.WALLS || action == Action.SHELL || action == Action.CLEARAREA || action == Action.REPLACE) { } else if (action == Action.SET || action == Action.WALLS || action == Action.SHELL || action == Action.CLEARAREA || action == Action.REPLACE) {
BlockOptionalMeta type = action == Action.CLEARAREA BlockOptionalMeta type = action == Action.CLEARAREA
? new BlockOptionalMeta(Blocks.AIR) ? new BlockOptionalMeta(Blocks.AIR)
: args.getDatatypeFor(ForBlockOptionalMeta.class); : args.getDatatypeFor(ForBlockOptionalMeta.class);
BlockOptionalMetaLookup replaces = null; BlockOptionalMetaLookup replaces = null;
if (action == Action.REPLACE) { if (action == Action.REPLACE) {
@@ -142,9 +138,9 @@ public class SelCommand extends Command {
for (ISelection selection : selections) { for (ISelection selection : selections) {
BetterBlockPos min = selection.min(); BetterBlockPos min = selection.min();
origin = new BetterBlockPos( origin = new BetterBlockPos(
Math.min(origin.x, min.x), Math.min(origin.x, min.x),
Math.min(origin.y, min.y), Math.min(origin.y, min.y),
Math.min(origin.z, min.z) Math.min(origin.z, min.z)
); );
} }
@@ -204,10 +200,10 @@ public class SelCommand extends Command {
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) { protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
if (args.hasExactlyOne()) { if (args.hasExactlyOne()) {
return new TabCompleteHelper() return new TabCompleteHelper()
.append(Action.getAllNames()) .append(Action.getAllNames())
.filterPrefix(args.getString()) .filterPrefix(args.getString())
.sortAlphabetically() .sortAlphabetically()
.stream(); .stream();
} else { } else {
Action action = Action.getByName(args.getString()); Action action = Action.getByName(args.getString());
@@ -227,10 +223,10 @@ public class SelCommand extends Command {
} else if (action == Action.EXPAND || action == Action.CONTRACT || action == Action.SHIFT) { } else if (action == Action.EXPAND || action == Action.CONTRACT || action == Action.SHIFT) {
if (args.hasExactlyOne()) { if (args.hasExactlyOne()) {
return new TabCompleteHelper() return new TabCompleteHelper()
.append(TransformTarget.getAllNames()) .append(TransformTarget.getAllNames())
.filterPrefix(args.getString()) .filterPrefix(args.getString())
.sortAlphabetically() .sortAlphabetically()
.stream(); .stream();
} else { } else {
TransformTarget target = TransformTarget.getByName(args.getString()); TransformTarget target = TransformTarget.getByName(args.getString());
@@ -253,29 +249,29 @@ public class SelCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"The sel command allows you to manipulate Baritone's selections, similarly to WorldEdit.", "The sel command allows you to manipulate Baritone's selections, similarly to WorldEdit.",
"", "",
"Using these selections, you can clear areas, fill them with blocks, or something else.", "Using these selections, you can clear areas, fill them with blocks, or something else.",
"", "",
"The expand/contract/shift commands use a kind of selector to choose which selections to target. Supported ones are a/all, n/newest, and o/oldest.", "The expand/contract/shift commands use a kind of selector to choose which selections to target. Supported ones are a/all, n/newest, and o/oldest.",
"", "",
"Usage:", "Usage:",
"> sel pos1/p1/1 - Set position 1 to your current position.", "> sel pos1/p1/1 - Set position 1 to your current position.",
"> sel pos1/p1/1 <x> <y> <z> - Set position 1 to a relative position.", "> sel pos1/p1/1 <x> <y> <z> - Set position 1 to a relative position.",
"> sel pos2/p2/2 - Set position 2 to your current position.", "> sel pos2/p2/2 - Set position 2 to your current position.",
"> sel pos2/p2/2 <x> <y> <z> - Set position 2 to a relative position.", "> sel pos2/p2/2 <x> <y> <z> - Set position 2 to a relative position.",
"", "",
"> sel clear/c - Clear the selection.", "> sel clear/c - Clear the selection.",
"> sel undo/u - Undo the last action (setting positions, creating selections, etc.)", "> sel undo/u - Undo the last action (setting positions, creating selections, etc.)",
"> sel set/fill/s/f [block] - Completely fill all selections with a block.", "> sel set/fill/s/f [block] - Completely fill all selections with a block.",
"> sel walls/w [block] - Fill in the walls of the selection with a specified block.", "> sel walls/w [block] - Fill in the walls of the selection with a specified block.",
"> sel shell/shl [block] - The same as walls, but fills in a ceiling and floor too.", "> sel shell/shl [block] - The same as walls, but fills in a ceiling and floor too.",
"> sel cleararea/ca - Basically 'set air'.", "> sel cleararea/ca - Basically 'set air'.",
"> sel replace/r <blocks...> <with> - Replaces blocks with another block.", "> sel replace/r <blocks...> <with> - Replaces blocks with another block.",
"", "",
"> sel expand <target> <direction> <blocks> - Expand the targets.", "> sel expand <target> <direction> <blocks> - Expand the targets.",
"> sel contract <target> <direction> <blocks> - Contract the targets.", "> sel contract <target> <direction> <blocks> - Contract the targets.",
"> sel shift <target> <direction> <blocks> - Shift the targets (does not resize)." "> sel shift <target> <direction> <blocks> - Shift the targets (does not resize)."
); );
} }
@@ -327,8 +323,8 @@ public class SelCommand extends Command {
enum TransformTarget { enum TransformTarget {
ALL(sels -> sels, "all", "a"), ALL(sels -> sels, "all", "a"),
NEWEST(sels -> new ISelection[] {sels[sels.length - 1]}, "newest", "n"), NEWEST(sels -> new ISelection[]{sels[sels.length - 1]}, "newest", "n"),
OLDEST(sels -> new ISelection[] {sels[0]}, "oldest", "o"); OLDEST(sels -> new ISelection[]{sels[0]}, "oldest", "o");
private final Function<ISelection[], ISelection[]> transform; private final Function<ISelection[], ISelection[]> transform;
private final String[] names; private final String[] names;

View File

@@ -66,44 +66,44 @@ public class SetCommand extends Command {
args.requireMax(1); args.requireMax(1);
List<? extends Settings.Setting> toPaginate = List<? extends Settings.Setting> toPaginate =
(viewModified ? SettingsUtil.modifiedSettings(settings) : settings.allSettings).stream() (viewModified ? SettingsUtil.modifiedSettings(settings) : settings.allSettings).stream()
.filter(s -> !s.getName().equals("logger")) .filter(s -> !s.getName().equals("logger"))
.filter(s -> s.getName().toLowerCase(Locale.US).contains(search.toLowerCase(Locale.US))) .filter(s -> s.getName().toLowerCase(Locale.US).contains(search.toLowerCase(Locale.US)))
.sorted((s1, s2) -> String.CASE_INSENSITIVE_ORDER.compare(s1.getName(), s2.getName())) .sorted((s1, s2) -> String.CASE_INSENSITIVE_ORDER.compare(s1.getName(), s2.getName()))
.collect(Collectors.toList()); .collect(Collectors.toList());
Paginator.paginate( Paginator.paginate(
args, args,
new Paginator<>(toPaginate), new Paginator<>(toPaginate),
() -> logDirect( () -> logDirect(
!search.isEmpty() !search.isEmpty()
? String.format("All %ssettings containing the string '%s':", viewModified ? "modified " : "", search) ? String.format("All %ssettings containing the string '%s':", viewModified ? "modified " : "", search)
: String.format("All %ssettings:", viewModified ? "modified " : "") : String.format("All %ssettings:", viewModified ? "modified " : "")
), ),
setting -> { setting -> {
ITextComponent typeComponent = new TextComponentString(String.format( ITextComponent typeComponent = new TextComponentString(String.format(
" (%s)", " (%s)",
settingTypeToString(setting) settingTypeToString(setting)
)); ));
typeComponent.getStyle().setColor(TextFormatting.DARK_GRAY); typeComponent.getStyle().setColor(TextFormatting.DARK_GRAY);
ITextComponent hoverComponent = new TextComponentString(""); ITextComponent hoverComponent = new TextComponentString("");
hoverComponent.getStyle().setColor(TextFormatting.GRAY); hoverComponent.getStyle().setColor(TextFormatting.GRAY);
hoverComponent.appendText(setting.getName()); hoverComponent.appendText(setting.getName());
hoverComponent.appendText(String.format("\nType: %s", settingTypeToString(setting))); hoverComponent.appendText(String.format("\nType: %s", settingTypeToString(setting)));
hoverComponent.appendText(String.format("\n\nValue:\n%s", settingValueToString(setting))); hoverComponent.appendText(String.format("\n\nValue:\n%s", settingValueToString(setting)));
String commandSuggestion = settings.prefix.value + String.format("set %s ", setting.getName()); String commandSuggestion = settings.prefix.value + String.format("set %s ", setting.getName());
ITextComponent component = new TextComponentString(setting.getName()); ITextComponent component = new TextComponentString(setting.getName());
component.getStyle().setColor(TextFormatting.GRAY); component.getStyle().setColor(TextFormatting.GRAY);
component.appendSibling(typeComponent); component.appendSibling(typeComponent);
component.getStyle() component.getStyle()
.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent)) .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent))
.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, commandSuggestion)); .setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, commandSuggestion));
return component; return component;
}, },
FORCE_COMMAND_PREFIX + "set " + arg + " " + search FORCE_COMMAND_PREFIX + "set " + arg + " " + search
); );
return; return;
@@ -135,9 +135,9 @@ public class SetCommand extends Command {
String settingName = doingSomething ? args.getString() : arg; String settingName = doingSomething ? args.getString() : arg;
Settings.Setting<?> setting = settings.allSettings.stream() Settings.Setting<?> setting = settings.allSettings.stream()
.filter(s -> s.getName().equalsIgnoreCase(settingName)) .filter(s -> s.getName().equalsIgnoreCase(settingName))
.findFirst() .findFirst()
.orElse(null); .orElse(null);
if (isNull(setting)) { if (isNull(setting)) {
throw new CommandInvalidTypeException(args.consumed(), "a valid setting"); throw new CommandInvalidTypeException(args.consumed(), "a valid setting");
@@ -160,9 +160,9 @@ public class SetCommand extends Command {
((Settings.Setting<Boolean>) setting).value ^= true; ((Settings.Setting<Boolean>) setting).value ^= true;
logDirect(String.format( logDirect(String.format(
"Toggled setting %s to %s", "Toggled setting %s to %s",
setting.getName(), setting.getName(),
Boolean.toString((Boolean) setting.value) Boolean.toString((Boolean) setting.value)
)); ));
} else { } else {
String newValue = args.getString(); String newValue = args.getString();
@@ -177,29 +177,29 @@ public class SetCommand extends Command {
if (!toggling) { if (!toggling) {
logDirect(String.format( logDirect(String.format(
"Successfully %s %s to %s", "Successfully %s %s to %s",
resetting ? "reset" : "set", resetting ? "reset" : "set",
setting.getName(), setting.getName(),
settingValueToString(setting) settingValueToString(setting)
)); ));
} }
ITextComponent oldValueComponent = new TextComponentString(String.format("Old value: %s", oldValue)); ITextComponent oldValueComponent = new TextComponentString(String.format("Old value: %s", oldValue));
oldValueComponent.getStyle() oldValueComponent.getStyle()
.setColor(TextFormatting.GRAY) .setColor(TextFormatting.GRAY)
.setHoverEvent(new HoverEvent( .setHoverEvent(new HoverEvent(
HoverEvent.Action.SHOW_TEXT, HoverEvent.Action.SHOW_TEXT,
new TextComponentString("Click to set the setting back to this value") new TextComponentString("Click to set the setting back to this value")
)) ))
.setClickEvent(new ClickEvent( .setClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND, ClickEvent.Action.RUN_COMMAND,
FORCE_COMMAND_PREFIX + String.format("set %s %s", setting.getName(), oldValue) FORCE_COMMAND_PREFIX + String.format("set %s %s", setting.getName(), oldValue)
)); ));
logDirect(oldValueComponent); logDirect(oldValueComponent);
if ((setting.getName().equals("chatControl") && !(Boolean) setting.value && !settings.chatControlAnyway.value) || if ((setting.getName().equals("chatControl") && !(Boolean) setting.value && !settings.chatControlAnyway.value) ||
setting.getName().equals("chatControlAnyway") && !(Boolean) setting.value && !settings.chatControl.value) { setting.getName().equals("chatControlAnyway") && !(Boolean) setting.value && !settings.chatControl.value) {
logDirect("Warning: Chat commands will no longer work. If you want to revert this change, use prefix control (if enabled) or click the old value listed above.", TextFormatting.RED); logDirect("Warning: Chat commands will no longer work. If you want to revert this change, use prefix control (if enabled) or click the old value listed above.", TextFormatting.RED);
} else if (setting.getName().equals("prefixControl") && !(Boolean) setting.value) { } else if (setting.getName().equals("prefixControl") && !(Boolean) setting.value) {
logDirect("Warning: Prefixed commands will no longer work. If you want to revert this change, use chat control (if enabled) or click the old value listed above.", TextFormatting.RED); logDirect("Warning: Prefixed commands will no longer work. If you want to revert this change, use chat control (if enabled) or click the old value listed above.", TextFormatting.RED);
@@ -217,15 +217,15 @@ public class SetCommand extends Command {
if (args.hasExactlyOne() && !asList("s", "save").contains(args.peekString().toLowerCase(Locale.US))) { if (args.hasExactlyOne() && !asList("s", "save").contains(args.peekString().toLowerCase(Locale.US))) {
if (arg.equalsIgnoreCase("reset")) { if (arg.equalsIgnoreCase("reset")) {
return new TabCompleteHelper() return new TabCompleteHelper()
.addModifiedSettings() .addModifiedSettings()
.prepend("all") .prepend("all")
.filterPrefix(args.getString()) .filterPrefix(args.getString())
.stream(); .stream();
} else if (arg.equalsIgnoreCase("toggle")) { } else if (arg.equalsIgnoreCase("toggle")) {
return new TabCompleteHelper() return new TabCompleteHelper()
.addToggleableSettings() .addToggleableSettings()
.filterPrefix(args.getString()) .filterPrefix(args.getString())
.stream(); .stream();
} }
Settings.Setting setting = settings.byLowerName.get(arg.toLowerCase(Locale.US)); Settings.Setting setting = settings.byLowerName.get(arg.toLowerCase(Locale.US));
@@ -247,11 +247,11 @@ public class SetCommand extends Command {
} }
} else if (!args.has()) { } else if (!args.has()) {
return new TabCompleteHelper() return new TabCompleteHelper()
.addSettings() .addSettings()
.sortAlphabetically() .sortAlphabetically()
.prepend("list", "modified", "reset", "toggle", "save") .prepend("list", "modified", "reset", "toggle", "save")
.filterPrefix(arg) .filterPrefix(arg)
.stream(); .stream();
} }
} }
@@ -266,18 +266,18 @@ public class SetCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"Using the set command, you can manage all of Baritone's settings. Almost every aspect is controlled by these settings - go wild!", "Using the set command, you can manage all of Baritone's settings. Almost every aspect is controlled by these settings - go wild!",
"", "",
"Usage:", "Usage:",
"> set - Same as `set list`", "> set - Same as `set list`",
"> set list [page] - View all settings", "> set list [page] - View all settings",
"> set modified [page] - View modified settings", "> set modified [page] - View modified settings",
"> set <setting> - View the current value of a setting", "> set <setting> - View the current value of a setting",
"> set <setting> <value> - Set the value of a setting", "> set <setting> <value> - Set the value of a setting",
"> set reset all - Reset ALL SETTINGS to their defaults", "> set reset all - Reset ALL SETTINGS to their defaults",
"> set reset <setting> - Reset a setting to its default", "> set reset <setting> - Reset a setting to its default",
"> set toggle <setting> - Toggle a boolean setting", "> set toggle <setting> - Toggle a boolean setting",
"> set save - Save all settings (this is automatic tho)" "> set save - Save all settings (this is automatic tho)"
); );
} }
} }

View File

@@ -37,9 +37,9 @@ public class ThisWayCommand extends Command {
args.requireExactly(1); args.requireExactly(1);
GoalXZ goal = GoalXZ.fromDirection( GoalXZ goal = GoalXZ.fromDirection(
ctx.playerFeetAsVec(), ctx.playerFeetAsVec(),
ctx.player().rotationYawHead, ctx.player().rotationYawHead,
args.getAs(Double.class) args.getAs(Double.class)
); );
baritone.getCustomGoalProcess().setGoal(goal); baritone.getCustomGoalProcess().setGoal(goal);
@@ -59,10 +59,10 @@ public class ThisWayCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"Creates a GoalXZ some amount of blocks in the direction you're currently looking", "Creates a GoalXZ some amount of blocks in the direction you're currently looking",
"", "",
"Usage:", "Usage:",
"> thisway <distance> - makes a GoalXZ distance blocks in front of you" "> thisway <distance> - makes a GoalXZ distance blocks in front of you"
); );
} }
} }

View File

@@ -38,8 +38,8 @@ public class TunnelCommand extends Command {
args.requireMax(0); args.requireMax(0);
Goal goal = new GoalStrictDirection( Goal goal = new GoalStrictDirection(
ctx.playerFeet(), ctx.playerFeet(),
ctx.player().getHorizontalFacing() ctx.player().getHorizontalFacing()
); );
baritone.getCustomGoalProcess().setGoal(goal); baritone.getCustomGoalProcess().setGoal(goal);
@@ -59,10 +59,10 @@ public class TunnelCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"The tunnel command sets a goal that tells Baritone to mine completely straight in the direction that you're facing.", "The tunnel command sets a goal that tells Baritone to mine completely straight in the direction that you're facing.",
"", "",
"Usage:", "Usage:",
"> tunnel" "> tunnel"
); );
} }
} }

View File

@@ -59,10 +59,10 @@ public class VersionCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"The version command prints the version of Baritone you're currently running.", "The version command prints the version of Baritone you're currently running.",
"", "",
"Usage:", "Usage:",
"> version - View version information, if present" "> version - View version information, if present"
); );
} }
} }

View File

@@ -76,27 +76,27 @@ public class WaypointsCommand extends Command {
component.appendSibling(nameComponent); component.appendSibling(nameComponent);
component.appendSibling(timestamp); component.appendSibling(timestamp);
component.getStyle() component.getStyle()
.setHoverEvent(new HoverEvent( .setHoverEvent(new HoverEvent(
HoverEvent.Action.SHOW_TEXT, HoverEvent.Action.SHOW_TEXT,
new TextComponentString("Click to select") new TextComponentString("Click to select")
))
.setClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,
String.format(
"%s%s %s %s @ %d",
FORCE_COMMAND_PREFIX,
label,
_action.names[0],
waypoint.getTag().getName(),
waypoint.getCreationTimestamp()
)) ))
); .setClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,
String.format(
"%s%s %s %s @ %d",
FORCE_COMMAND_PREFIX,
label,
_action.names[0],
waypoint.getTag().getName(),
waypoint.getCreationTimestamp()
))
);
return component; return component;
}; };
Function<IWaypoint, ITextComponent> transform = waypoint -> Function<IWaypoint, ITextComponent> transform = waypoint ->
toComponent.apply(waypoint, action == Action.LIST ? Action.INFO : action); toComponent.apply(waypoint, action == Action.LIST ? Action.INFO : action);
if (action == Action.LIST) { if (action == Action.LIST) {
IWaypoint.Tag tag = args.has() ? IWaypoint.Tag.getByName(args.peekString()) : null; IWaypoint.Tag tag = args.has() ? IWaypoint.Tag.getByName(args.peekString()) : null;
@@ -106,34 +106,34 @@ public class WaypointsCommand extends Command {
} }
IWaypoint[] waypoints = tag != null IWaypoint[] waypoints = tag != null
? ForWaypoints.getWaypointsByTag(tag) ? ForWaypoints.getWaypointsByTag(tag)
: ForWaypoints.getWaypoints(); : ForWaypoints.getWaypoints();
if (waypoints.length > 0) { if (waypoints.length > 0) {
args.requireMax(1); args.requireMax(1);
Paginator.paginate( Paginator.paginate(
args, args,
waypoints, waypoints,
() -> logDirect( () -> logDirect(
tag != null tag != null
? String.format("All waypoints by tag %s:", tag.name()) ? String.format("All waypoints by tag %s:", tag.name())
: "All waypoints:" : "All waypoints:"
), ),
transform, transform,
String.format( String.format(
"%s%s %s%s", "%s%s %s%s",
FORCE_COMMAND_PREFIX, FORCE_COMMAND_PREFIX,
label, label,
action.names[0], action.names[0],
tag != null ? " " + tag.getName() : "" tag != null ? " " + tag.getName() : ""
) )
); );
} else { } else {
args.requireMax(0); args.requireMax(0);
throw new CommandInvalidStateException( throw new CommandInvalidStateException(
tag != null tag != null
? "No waypoints found by that tag" ? "No waypoints found by that tag"
: "No waypoints found" : "No waypoints found"
); );
} }
} else if (action == Action.SAVE) { } else if (action == Action.SAVE) {
@@ -145,8 +145,8 @@ public class WaypointsCommand extends Command {
String name = args.has() ? args.getString() : ""; String name = args.has() ? args.getString() : "";
BetterBlockPos pos = args.has() BetterBlockPos pos = args.has()
? args.getDatatypePost(RelativeBlockPos.class, ctx.playerFeet()) ? args.getDatatypePost(RelativeBlockPos.class, ctx.playerFeet())
: ctx.playerFeet(); : ctx.playerFeet();
args.requireMax(0); args.requireMax(0);
@@ -198,17 +198,17 @@ public class WaypointsCommand extends Command {
if (waypoint == null) { if (waypoint == null) {
args.requireMax(1); args.requireMax(1);
Paginator.paginate( Paginator.paginate(
args, args,
waypoints, waypoints,
() -> logDirect("Multiple waypoints were found:"), () -> logDirect("Multiple waypoints were found:"),
transform, transform,
String.format( String.format(
"%s%s %s %s", "%s%s %s %s",
FORCE_COMMAND_PREFIX, FORCE_COMMAND_PREFIX,
label, label,
action.names[0], action.names[0],
args.consumedString() args.consumedString()
) )
); );
} else { } else {
if (action == Action.INFO) { if (action == Action.INFO) {
@@ -216,34 +216,34 @@ public class WaypointsCommand extends Command {
logDirect(String.format("Position: %s", waypoint.getLocation())); logDirect(String.format("Position: %s", waypoint.getLocation()));
ITextComponent deleteComponent = new TextComponentString("Click to delete this waypoint"); ITextComponent deleteComponent = new TextComponentString("Click to delete this waypoint");
deleteComponent.getStyle().setClickEvent(new ClickEvent( deleteComponent.getStyle().setClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND, ClickEvent.Action.RUN_COMMAND,
String.format( String.format(
"%s%s delete %s @ %d", "%s%s delete %s @ %d",
FORCE_COMMAND_PREFIX, FORCE_COMMAND_PREFIX,
label, label,
waypoint.getTag().getName(), waypoint.getTag().getName(),
waypoint.getCreationTimestamp() waypoint.getCreationTimestamp()
) )
)); ));
ITextComponent goalComponent = new TextComponentString("Click to set goal to this waypoint"); ITextComponent goalComponent = new TextComponentString("Click to set goal to this waypoint");
goalComponent.getStyle().setClickEvent(new ClickEvent( goalComponent.getStyle().setClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND, ClickEvent.Action.RUN_COMMAND,
String.format( String.format(
"%s%s goal %s @ %d", "%s%s goal %s @ %d",
FORCE_COMMAND_PREFIX, FORCE_COMMAND_PREFIX,
label, label,
waypoint.getTag().getName(), waypoint.getTag().getName(),
waypoint.getCreationTimestamp() waypoint.getCreationTimestamp()
) )
)); ));
ITextComponent backComponent = new TextComponentString("Click to return to the waypoints list"); ITextComponent backComponent = new TextComponentString("Click to return to the waypoints list");
backComponent.getStyle().setClickEvent(new ClickEvent( backComponent.getStyle().setClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND, ClickEvent.Action.RUN_COMMAND,
String.format( String.format(
"%s%s list", "%s%s list",
FORCE_COMMAND_PREFIX, FORCE_COMMAND_PREFIX,
label label
) )
)); ));
logDirect(deleteComponent); logDirect(deleteComponent);
logDirect(goalComponent); logDirect(goalComponent);
@@ -265,20 +265,20 @@ public class WaypointsCommand extends Command {
if (args.has()) { if (args.has()) {
if (args.hasExactlyOne()) { if (args.hasExactlyOne()) {
return new TabCompleteHelper() return new TabCompleteHelper()
.append(Action.getAllNames()) .append(Action.getAllNames())
.sortAlphabetically() .sortAlphabetically()
.filterPrefix(args.getString()) .filterPrefix(args.getString())
.stream(); .stream();
} else { } else {
Action action = Action.getByName(args.getString()); Action action = Action.getByName(args.getString());
if (args.hasExactlyOne()) { if (args.hasExactlyOne()) {
if (action == Action.LIST || action == Action.SAVE || action == Action.CLEAR) { if (action == Action.LIST || action == Action.SAVE || action == Action.CLEAR) {
return new TabCompleteHelper() return new TabCompleteHelper()
.append(IWaypoint.Tag.getAllNames()) .append(IWaypoint.Tag.getAllNames())
.sortAlphabetically() .sortAlphabetically()
.filterPrefix(args.getString()) .filterPrefix(args.getString())
.stream(); .stream();
} else { } else {
return args.tabCompleteDatatype(ForWaypoints.class); return args.tabCompleteDatatype(ForWaypoints.class);
} }
@@ -301,20 +301,20 @@ public class WaypointsCommand extends Command {
@Override @Override
public List<String> getLongDesc() { public List<String> getLongDesc() {
return asList( return asList(
"The waypoint command allows you to manage Baritone's waypoints.", "The waypoint command allows you to manage Baritone's waypoints.",
"", "",
"Waypoints can be used to mark positions for later. Waypoints are each given a tag and an optional name.", "Waypoints can be used to mark positions for later. Waypoints are each given a tag and an optional name.",
"", "",
"Note that the info, delete, and goal commands let you specify a waypoint by tag. If there is more than one waypoint with a certain tag, then they will let you select which waypoint you mean.", "Note that the info, delete, and goal commands let you specify a waypoint by tag. If there is more than one waypoint with a certain tag, then they will let you select which waypoint you mean.",
"", "",
"Usage:", "Usage:",
"> wp [l/list] - List all waypoints.", "> wp [l/list] - List all waypoints.",
"> wp <s/save> <tag> - Save your current position as an unnamed waypoint with the specified tag.", "> wp <s/save> <tag> - Save your current position as an unnamed waypoint with the specified tag.",
"> wp <s/save> <tag> <name> - Save the waypoint with the specified name.", "> wp <s/save> <tag> <name> - Save the waypoint with the specified name.",
"> wp <s/save> <tag> <name> <pos> - Save the waypoint with the specified name and position.", "> wp <s/save> <tag> <name> <pos> - Save the waypoint with the specified name and position.",
"> wp <i/info/show> <tag> - Show info on a waypoint by tag.", "> wp <i/info/show> <tag> - Show info on a waypoint by tag.",
"> wp <d/delete> <tag> - Delete a waypoint by tag.", "> wp <d/delete> <tag> - Delete a waypoint by tag.",
"> wp <g/goal/goto> <tag> - Set a goal to a waypoint by tag." "> wp <g/goal/goto> <tag> - Set a goal to a waypoint by tag."
); );
} }

View File

@@ -18,7 +18,6 @@
package baritone.utils.schematic.schematica; package baritone.utils.schematic.schematica;
import baritone.api.utils.ISchematic; import baritone.api.utils.ISchematic;
import com.github.lunatrius.schematica.client.world.SchematicWorld; import com.github.lunatrius.schematica.client.world.SchematicWorld;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;

View File

@@ -39,7 +39,7 @@ public enum SchematicaHelper {
public static Optional<Tuple<ISchematic, BlockPos>> getOpenSchematic() { public static Optional<Tuple<ISchematic, BlockPos>> getOpenSchematic() {
return Optional.ofNullable(ClientProxy.schematic) return Optional.ofNullable(ClientProxy.schematic)
.map(world -> new Tuple<>(new SchematicAdapter(world), world.position)); .map(world -> new Tuple<>(new SchematicAdapter(world), world.position));
} }
} }

View File

@@ -21,7 +21,7 @@ import com.github.lunatrius.core.util.math.MBlockPos;
import com.github.lunatrius.schematica.api.ISchematic; import com.github.lunatrius.schematica.api.ISchematic;
public class SchematicWorld { public class SchematicWorld {
public final MBlockPos position = (MBlockPos)(Object)"cringe"; public final MBlockPos position = (MBlockPos) (Object) "cringe";
public ISchematic getSchematic() { public ISchematic getSchematic() {
throw new LinkageError("LOL"); throw new LinkageError("LOL");