From e8e6a9bc5cf87a8bd775fb588dfb15a9f2d82a44 Mon Sep 17 00:00:00 2001 From: Moondarker Date: Sat, 20 Jun 2020 23:11:16 +0300 Subject: [PATCH 001/155] Allow multi-artifact building for Jitpack and local Maven repos --- build.gradle | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/build.gradle b/build.gradle index a91926ddb..5f6031b92 100755 --- a/build.gradle +++ b/build.gradle @@ -42,6 +42,7 @@ import baritone.gradle.task.CreateDistTask import baritone.gradle.task.ProguardTask apply plugin: 'java' +apply plugin: 'maven' apply plugin: 'net.minecraftforge.gradle.tweaker-client' apply plugin: 'org.spongepowered.mixin' @@ -138,3 +139,25 @@ task proguard(type: ProguardTask) { task createDist(type: CreateDistTask, dependsOn: proguard) build.finalizedBy(createDist) + +install { + def jarApiName = String.format("%s-api-%s", rootProject.name, version.toString()) + def jarApiForgeName = String.format("%s-api-forge-%s", rootProject.name, version.toString()) + def jarSAName = String.format("%s-standalone-%s", rootProject.name, version.toString()) + def jarSAForgeName = String.format("%s-standalone-forge-%s", rootProject.name, version.toString()) + + artifacts { + archives file("$buildDir/libs/"+jarApiName+".jar") + archives file("$buildDir/libs/"+jarApiForgeName+".jar") + archives file("$buildDir/libs/"+jarSAName+".jar") + archives file("$buildDir/libs/"+jarSAForgeName+".jar") + } + repositories.mavenInstaller { + addFilter('api') { artifact, file -> artifact.name == "baritone-api" } + addFilter('api-forge') { artifact, file -> artifact.name == "baritone-api-forge" } + addFilter('standalone') { artifact, file -> artifact.name == "baritone-standalone" } + addFilter('standalone-forge') { artifact, file -> artifact.name == "baritone-standalone-forge" } + } +} + +install.dependsOn(build) From 8fe05c9119c0c6ff2a9397a88d954b889af5a459 Mon Sep 17 00:00:00 2001 From: Moondarker Date: Sat, 20 Jun 2020 23:16:20 +0300 Subject: [PATCH 002/155] fixup! Allow multi-artifact building for Jitpack and local Maven repos --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 5f6031b92..df7957877 100755 --- a/build.gradle +++ b/build.gradle @@ -154,8 +154,8 @@ install { } repositories.mavenInstaller { addFilter('api') { artifact, file -> artifact.name == "baritone-api" } - addFilter('api-forge') { artifact, file -> artifact.name == "baritone-api-forge" } - addFilter('standalone') { artifact, file -> artifact.name == "baritone-standalone" } + addFilter('api-forge') { artifact, file -> artifact.name == "baritone-api-forge" } + addFilter('standalone') { artifact, file -> artifact.name == "baritone-standalone" } addFilter('standalone-forge') { artifact, file -> artifact.name == "baritone-standalone-forge" } } } From b628d67961615ef59351769254ea4b295738794c Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Wed, 26 Aug 2020 23:52:44 +0200 Subject: [PATCH 003/155] =?UTF-8?q?=E2=9C=A8=20Add=20ETA=20for=20full=20pa?= =?UTF-8?q?th?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../baritone/api/behavior/IPathingBehavior.java | 9 +++++++++ .../java/baritone/behavior/PathingBehavior.java | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/api/java/baritone/api/behavior/IPathingBehavior.java b/src/api/java/baritone/api/behavior/IPathingBehavior.java index 5444bb838..83db7ab3a 100644 --- a/src/api/java/baritone/api/behavior/IPathingBehavior.java +++ b/src/api/java/baritone/api/behavior/IPathingBehavior.java @@ -58,6 +58,15 @@ public interface IPathingBehavior extends IBehavior { return Optional.of(current.getPath().ticksRemainingFrom(start)); } + /** + * Returns the estimated remaining ticks to the current goal. + * Given that the return type is an optional, {@link Optional#empty()} + * will be returned in the case that there is no current goal. + * + * @return The estimated remaining ticks to the current goal. + */ + Optional estimatedTicksToGoal(); + /** * @return The current pathing goal */ diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 50ca7425f..4f47a8323 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -52,6 +52,10 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, private Goal goal; private CalculationContext context; + /*eta*/ + private int ticksElapsedSoFar; + private BetterBlockPos startPosition; + private boolean safeToCancel; private boolean pauseRequestedLastTick; private boolean unpausedLastTick; @@ -98,6 +102,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, expectedSegmentStart = pathStart(); baritone.getPathingControlManager().preTick(); tickPath(); + ticksElapsedSoFar++; dispatchEvents(); } @@ -372,6 +377,16 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, return context; } + public Optional estimatedTicksToGoal(){ + if (goal == null){ + return Optional.empty(); + } + BetterBlockPos currentPos = ctx.playerFeet(); + double current = goal.heuristic(currentPos.x, currentPos.y, currentPos.z); + double start = goal.heuristic(startPosition.x, startPosition.y, startPosition.z); + return Optional.of(current * ticksElapsedSoFar / (start - current)); + } + /** * See issue #209 * @@ -468,6 +483,8 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, if (executor.get().getPath().positions().contains(expectedSegmentStart)) { queuePathEvent(PathEvent.CALC_FINISHED_NOW_EXECUTING); current = executor.get(); + ticksElapsedSoFar = 0; + startPosition = expectedSegmentStart; } else { logDebug("Warning: discarding orphan path segment with incorrect start"); } From 56f13d314a525b41055c71d0ea5fb270bcaa6042 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Wed, 26 Aug 2020 23:53:02 +0200 Subject: [PATCH 004/155] =?UTF-8?q?=E2=9C=A8=20Add=20eta=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command/defaults/DefaultCommands.java | 1 + .../baritone/command/defaults/EtaCommand.java | 78 +++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 src/main/java/baritone/command/defaults/EtaCommand.java diff --git a/src/main/java/baritone/command/defaults/DefaultCommands.java b/src/main/java/baritone/command/defaults/DefaultCommands.java index 67555ed51..08b8a627f 100644 --- a/src/main/java/baritone/command/defaults/DefaultCommands.java +++ b/src/main/java/baritone/command/defaults/DefaultCommands.java @@ -38,6 +38,7 @@ public final class DefaultCommands { new GotoCommand(baritone), new PathCommand(baritone), new ProcCommand(baritone), + new EtaCommand(baritone), new VersionCommand(baritone), new RepackCommand(baritone), new BuildCommand(baritone), diff --git a/src/main/java/baritone/command/defaults/EtaCommand.java b/src/main/java/baritone/command/defaults/EtaCommand.java new file mode 100644 index 000000000..b953bd9af --- /dev/null +++ b/src/main/java/baritone/command/defaults/EtaCommand.java @@ -0,0 +1,78 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package baritone.command.defaults; + +import baritone.api.IBaritone; +import baritone.api.pathing.calc.IPathingControlManager; +import baritone.api.process.IBaritoneProcess; +import baritone.api.behavior.IPathingBehavior; +import baritone.api.command.Command; +import baritone.api.command.exception.CommandException; +import baritone.api.command.exception.CommandInvalidStateException; +import baritone.api.command.argument.IArgConsumer; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Stream; + +public class EtaCommand extends Command { + + public EtaCommand(IBaritone baritone) { + super(baritone, "eta"); + } + + @Override + public void execute(String label, IArgConsumer args) throws CommandException { + args.requireMax(0); + IPathingControlManager pathingControlManager = baritone.getPathingControlManager(); + IBaritoneProcess process = pathingControlManager.mostRecentInControl().orElse(null); + if (process == null) { + throw new CommandInvalidStateException("No process in control"); + } + IPathingBehavior pathingBehavior = baritone.getPathingBehavior(); + logDirect(String.format( + "Next segment: %.2f\n" + + "Goal: %.2f", + pathingBehavior.ticksRemainingInSegment().orElse(-1.0), + pathingBehavior.estimatedTicksToGoal().orElse(-1.0) + )); + } + + @Override + public Stream tabComplete(String label, IArgConsumer args) { + return Stream.empty(); + } + + @Override + public String getShortDesc() { + return "View the current eta"; + } + + @Override + public List getLongDesc() { + return Arrays.asList( + "The eta command provides information about the estimated time until the next segment.", + "and the goal", + "", + "Be aware that the eta to your goal is really unprecise", + "", + "Usage:", + "> proc - View eta, if present" + ); + } +} From 71dd6c633372834938f50825d2d4d5c5fb06a6ef Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Thu, 27 Aug 2020 01:16:17 +0200 Subject: [PATCH 005/155] =?UTF-8?q?=F0=9F=91=8Cformatting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/baritone/behavior/PathingBehavior.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 4f47a8323..0026e8106 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -377,8 +377,8 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, return context; } - public Optional estimatedTicksToGoal(){ - if (goal == null){ + public Optional estimatedTicksToGoal() { + if (goal == null) { return Optional.empty(); } BetterBlockPos currentPos = ctx.playerFeet(); From d9cecb35cb1fc5240f534214ad588d8dd3f19b73 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Fri, 28 Aug 2020 00:52:55 +0200 Subject: [PATCH 006/155] rename Eta to ETA --- .../baritone/command/defaults/DefaultCommands.java | 2 +- .../defaults/{EtaCommand.java => ETACommand.java} | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) rename src/main/java/baritone/command/defaults/{EtaCommand.java => ETACommand.java} (89%) diff --git a/src/main/java/baritone/command/defaults/DefaultCommands.java b/src/main/java/baritone/command/defaults/DefaultCommands.java index 08b8a627f..9e17468fa 100644 --- a/src/main/java/baritone/command/defaults/DefaultCommands.java +++ b/src/main/java/baritone/command/defaults/DefaultCommands.java @@ -38,7 +38,7 @@ public final class DefaultCommands { new GotoCommand(baritone), new PathCommand(baritone), new ProcCommand(baritone), - new EtaCommand(baritone), + new ETACommand(baritone), new VersionCommand(baritone), new RepackCommand(baritone), new BuildCommand(baritone), diff --git a/src/main/java/baritone/command/defaults/EtaCommand.java b/src/main/java/baritone/command/defaults/ETACommand.java similarity index 89% rename from src/main/java/baritone/command/defaults/EtaCommand.java rename to src/main/java/baritone/command/defaults/ETACommand.java index b953bd9af..dd56ada30 100644 --- a/src/main/java/baritone/command/defaults/EtaCommand.java +++ b/src/main/java/baritone/command/defaults/ETACommand.java @@ -30,9 +30,9 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Stream; -public class EtaCommand extends Command { +public class ETACommand extends Command { - public EtaCommand(IBaritone baritone) { + public ETACommand(IBaritone baritone) { super(baritone, "eta"); } @@ -60,19 +60,19 @@ public class EtaCommand extends Command { @Override public String getShortDesc() { - return "View the current eta"; + return "View the current ETA"; } @Override public List getLongDesc() { return Arrays.asList( - "The eta command provides information about the estimated time until the next segment.", + "The ETA command provides information about the estimated time until the next segment.", "and the goal", "", - "Be aware that the eta to your goal is really unprecise", + "Be aware that the ETA to your goal is really unprecise", "", "Usage:", - "> proc - View eta, if present" + "> proc - View ETA, if present" ); } } From d29b3ee893f42bef3c975a67f4e6a1003da4f5a3 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Fri, 28 Aug 2020 01:19:06 +0200 Subject: [PATCH 007/155] Fix copy/paste mistake in ETACommand.getLongDesc() --- src/main/java/baritone/command/defaults/ETACommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/command/defaults/ETACommand.java b/src/main/java/baritone/command/defaults/ETACommand.java index dd56ada30..3c16bd113 100644 --- a/src/main/java/baritone/command/defaults/ETACommand.java +++ b/src/main/java/baritone/command/defaults/ETACommand.java @@ -72,7 +72,7 @@ public class ETACommand extends Command { "Be aware that the ETA to your goal is really unprecise", "", "Usage:", - "> proc - View ETA, if present" + "> eta - View ETA, if present" ); } } From 695954bdb08986ca1cd487927bd04216d97baaa8 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Fri, 28 Aug 2020 23:37:23 +0200 Subject: [PATCH 008/155] no eta after 0 ticks or with division by 0 --- src/main/java/baritone/behavior/PathingBehavior.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 0026e8106..ad2df5320 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -378,12 +378,15 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, } public Optional estimatedTicksToGoal() { - if (goal == null) { + if (goal == null || ticksElapsedSoFar == 0) { return Optional.empty(); } BetterBlockPos currentPos = ctx.playerFeet(); double current = goal.heuristic(currentPos.x, currentPos.y, currentPos.z); double start = goal.heuristic(startPosition.x, startPosition.y, startPosition.z); + if (current == start) {//can't check above because current and start can be equal even if currentPos and startPosition are not + return Optional.empty(); + } return Optional.of(current * ticksElapsedSoFar / (start - current)); } From 35f3be9296ef3e384413a92caf2787186f58512d Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Wed, 2 Sep 2020 22:59:13 +0200 Subject: [PATCH 009/155] get rid of negative ETAs the lazy way --- src/main/java/baritone/behavior/PathingBehavior.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index ad2df5320..65ee41127 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -387,7 +387,11 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, if (current == start) {//can't check above because current and start can be equal even if currentPos and startPosition are not return Optional.empty(); } - return Optional.of(current * ticksElapsedSoFar / (start - current)); + double eta = current * ticksElapsedSoFar / (start - current); + if (eta < 0 || current < 0){ + return Optional.empty(); + } + return Optional.of(eta); } /** From 303aa79ffb311d53a7915f1b0e63d6db1c3a08e1 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Fri, 4 Sep 2020 23:56:01 +0200 Subject: [PATCH 010/155] Update ETA formula, assuming heuritic at goal is 0 --- src/main/java/baritone/behavior/PathingBehavior.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 65ee41127..832337e69 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -387,7 +387,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, if (current == start) {//can't check above because current and start can be equal even if currentPos and startPosition are not return Optional.empty(); } - double eta = current * ticksElapsedSoFar / (start - current); + double eta = Math.abs(current) * ticksElapsedSoFar / Math.abs(start - current); if (eta < 0 || current < 0){ return Optional.empty(); } From 10e3a5afc4f7b0bc79196b956ff56995cc462e1c Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sat, 5 Sep 2020 22:13:05 +0200 Subject: [PATCH 011/155] negative ETAs are actually impossible now --- src/main/java/baritone/behavior/PathingBehavior.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 832337e69..5cc9520c7 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -388,9 +388,6 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, return Optional.empty(); } double eta = Math.abs(current) * ticksElapsedSoFar / Math.abs(start - current); - if (eta < 0 || current < 0){ - return Optional.empty(); - } return Optional.of(eta); } From 45dc8b949d0196f5bc4bb3e4796e0deccb4d62cd Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sat, 5 Sep 2020 22:32:38 +0200 Subject: [PATCH 012/155] add a method to get the heuristic at the goal this alows the ETA to work with goals not ending with a heuristic of 0 GoalComposite, GoalRunAway and GoalNear are still missing --- src/api/java/baritone/api/pathing/goals/Goal.java | 14 ++++++++++++++ .../baritone/api/pathing/goals/GoalInverted.java | 5 +++++ .../api/pathing/goals/GoalStrictDirection.java | 5 +++++ .../java/baritone/behavior/PathingBehavior.java | 2 +- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/pathing/goals/Goal.java b/src/api/java/baritone/api/pathing/goals/Goal.java index acee68db8..7d8f42220 100644 --- a/src/api/java/baritone/api/pathing/goals/Goal.java +++ b/src/api/java/baritone/api/pathing/goals/Goal.java @@ -54,4 +54,18 @@ public interface Goal { default double heuristic(BlockPos pos) { return heuristic(pos.getX(), pos.getY(), pos.getZ()); } + + /** + * Returns the heuristic at the goal. + * i.e. {@code heuristic() == heuristic(x,y,z)} + * when {@code isInGoal(x,y,z) == true} + * This is needed by {@code PathingBehavior#estimatedTicksToGoal} because + * some Goals actually do not have a heuristic of 0 when that condition is met + * + * @return The estimate number of ticks to satisfy the goal when the goal + * is already satisfied + */ + default double heuristic() { + return 0; + } } diff --git a/src/api/java/baritone/api/pathing/goals/GoalInverted.java b/src/api/java/baritone/api/pathing/goals/GoalInverted.java index 197369241..354e2ce39 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalInverted.java +++ b/src/api/java/baritone/api/pathing/goals/GoalInverted.java @@ -45,6 +45,11 @@ public class GoalInverted implements Goal { return -origin.heuristic(x, y, z); } + @Override + public double heuristic() { + return Double.NEGATIVE_INFINITY; + } + @Override public String toString() { return String.format("GoalInverted{%s}", origin.toString()); diff --git a/src/api/java/baritone/api/pathing/goals/GoalStrictDirection.java b/src/api/java/baritone/api/pathing/goals/GoalStrictDirection.java index b48a029ad..e93f47ac0 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalStrictDirection.java +++ b/src/api/java/baritone/api/pathing/goals/GoalStrictDirection.java @@ -64,6 +64,11 @@ public class GoalStrictDirection implements Goal { return heuristic; } + @Override + public double heuristic() { + return Double.NEGATIVE_INFINITY; + } + @Override public String toString() { return String.format( diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 5cc9520c7..5f69aabe7 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -387,7 +387,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, if (current == start) {//can't check above because current and start can be equal even if currentPos and startPosition are not return Optional.empty(); } - double eta = Math.abs(current) * ticksElapsedSoFar / Math.abs(start - current); + double eta = Math.abs(current - goal.heuristic()) * ticksElapsedSoFar / Math.abs(start - current); return Optional.of(eta); } From 7255ccbdaac3fc339fb36a93dfb8d7813411f646 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sun, 6 Sep 2020 16:42:05 +0200 Subject: [PATCH 013/155] add heuristic(no args) to GoalComposite GoalNear and GoalRunAway are still missing it --- .../java/baritone/api/pathing/goals/GoalComposite.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/api/java/baritone/api/pathing/goals/GoalComposite.java b/src/api/java/baritone/api/pathing/goals/GoalComposite.java index 415f74e56..fd4e672b0 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalComposite.java +++ b/src/api/java/baritone/api/pathing/goals/GoalComposite.java @@ -57,6 +57,16 @@ public class GoalComposite implements Goal { return min; } + @Override + public double heuristic() { + double min = Double.MAX_VALUE; + for (Goal g: goals) { + //just take the highest value that is guaranteed to be inside the goal + min = Math.min(min, g.heuristic()); + } + return min; + } + @Override public String toString() { return "GoalComposite" + Arrays.toString(goals); From 411b2a0accfd7ca04f93592acd1cfa2618667b42 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Fri, 18 Sep 2020 23:16:56 +0200 Subject: [PATCH 014/155] =?UTF-8?q?=F0=9F=94=A8move=20ETA=20reset=20to=20i?= =?UTF-8?q?t's=20own=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/baritone/behavior/PathingBehavior.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 5f69aabe7..22513985c 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -391,6 +391,19 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, return Optional.of(eta); } + private void resetEstimatedTicksToGoal() { + resetEstimatedTicksToGoal(expectedSegmentStart); + } + + private void resetEstimatedTicksToGoal(BlockPos start) { + resetEstimatedTicksToGoal(new BetterBlockPos(start)); + } + + private void resetEstimatedTicksToGoal(BetterBlockPos start) { + ticksElapsedSoFar = 0; + startPosition = start; + } + /** * See issue #209 * @@ -487,8 +500,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, if (executor.get().getPath().positions().contains(expectedSegmentStart)) { queuePathEvent(PathEvent.CALC_FINISHED_NOW_EXECUTING); current = executor.get(); - ticksElapsedSoFar = 0; - startPosition = expectedSegmentStart; + resetEstimatedTicksToGoal(start); } else { logDebug("Warning: discarding orphan path segment with incorrect start"); } From 46a12754e9a104b47c17c3523f505d5e0d69f011 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Fri, 18 Sep 2020 23:24:47 +0200 Subject: [PATCH 015/155] =?UTF-8?q?=F0=9F=90=9BReset=20ETA=20and=20return?= =?UTF-8?q?=200=20if=20we=20are=20already=20there=20not=20doing=20this=20c?= =?UTF-8?q?aused=20a=20continuously=20increasing=20ETA=20when=20standing?= =?UTF-8?q?=20inside=20a=20`GoalNear`=20from=20`FollowProcess`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/baritone/behavior/PathingBehavior.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 22513985c..acda243a6 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -378,7 +378,14 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, } public Optional estimatedTicksToGoal() { - if (goal == null || ticksElapsedSoFar == 0) { + if (goal == null) { + return Optional.empty(); + } + if (goal.isInGoal(ctx.playerFeet())) { + resetEstimatedTicksToGoal(); + return Optional.of(0.0); + } + if (ticksElapsedSoFar == 0) { return Optional.empty(); } BetterBlockPos currentPos = ctx.playerFeet(); From b4d7f0516522c12bbdcb0ccc9802d0bda93772ce Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sat, 19 Sep 2020 00:31:58 +0200 Subject: [PATCH 016/155] =?UTF-8?q?=F0=9F=90=9B=20fix=20two=20NPEs=20in=20?= =?UTF-8?q?estimatedTickToGoal=20apparently=20`ctx.playerFeet()`=20and=20`?= =?UTF-8?q?startPosition`=20can=20be=20`null`=20before=20pathing=20the=20f?= =?UTF-8?q?irst=20time?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/baritone/behavior/PathingBehavior.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index acda243a6..967df1b33 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -378,7 +378,8 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, } public Optional estimatedTicksToGoal() { - if (goal == null) { + BetterBlockPos currentPos = ctx.playerFeet(); + if (goal == null || currentPos == null || startPosition == null) { return Optional.empty(); } if (goal.isInGoal(ctx.playerFeet())) { @@ -388,7 +389,6 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, if (ticksElapsedSoFar == 0) { return Optional.empty(); } - BetterBlockPos currentPos = ctx.playerFeet(); double current = goal.heuristic(currentPos.x, currentPos.y, currentPos.z); double start = goal.heuristic(startPosition.x, startPosition.y, startPosition.z); if (current == start) {//can't check above because current and start can be equal even if currentPos and startPosition are not From b20e0956835c516116aa59e3b5b77e46eee07da1 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sun, 20 Sep 2020 00:29:31 +0200 Subject: [PATCH 017/155] add heuristic(no args) to GoalNear and GoalRunAway not really a good solution but better than nothing --- .../baritone/api/pathing/goals/GoalNear.java | 24 +++++++++++ .../api/pathing/goals/GoalRunAway.java | 42 +++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/src/api/java/baritone/api/pathing/goals/GoalNear.java b/src/api/java/baritone/api/pathing/goals/GoalNear.java index 73d64ed9f..6f493fa54 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalNear.java +++ b/src/api/java/baritone/api/pathing/goals/GoalNear.java @@ -21,6 +21,9 @@ import baritone.api.utils.SettingsUtil; import baritone.api.utils.interfaces.IGoalRenderPos; import net.minecraft.util.math.BlockPos; +import java.util.Collections; +import java.util.HashSet; + public class GoalNear implements Goal, IGoalRenderPos { private final int x; @@ -51,6 +54,27 @@ public class GoalNear implements Goal, IGoalRenderPos { return GoalBlock.calculate(xDiff, yDiff, zDiff); } + @Override + public double heuristic() {//TODO less hacky solution + int range = (int)Math.ceil(Math.abs(Math.sqrt(rangeSq))); + HashSet maybeAlwaysInside = new HashSet<>(); + HashSet sometimesOutside = new HashSet<>(); + for (int dx = -range; dx <= range; dx++) { + for (int dy = -range; dy <= range; dy++) { + for (int dz = -range; dz <= range; dz++) { + double h = heuristic(x+dx, y+dy, z+dz); + if (!sometimesOutside.contains(h) && isInGoal(x+dx, y+dy, z+dz)) { + maybeAlwaysInside.add(h); + } else { + maybeAlwaysInside.remove(h); + sometimesOutside.add(h); + } + } + } + } + return Collections.max(maybeAlwaysInside); + } + @Override public BlockPos getGoalPos() { return new BlockPos(x, y, z); diff --git a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java index a1a153780..3955de1e9 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java +++ b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java @@ -21,6 +21,9 @@ import baritone.api.utils.SettingsUtil; import net.minecraft.util.math.BlockPos; import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.NoSuchElementException; /** * Useful for automated combat (retreating specifically) @@ -80,6 +83,45 @@ public class GoalRunAway implements Goal { return min; } + @Override + public double heuristic() {//TODO less hacky solution + int distance = (int)Math.ceil(Math.abs(Math.sqrt(distanceSq))); + int minX = from[0].getX() - distance; + int minY = from[0].getY() - distance; + int minZ = from[0].getZ() - distance; + int maxX = from[0].getX() + distance; + int maxY = from[0].getY() + distance; + int maxZ = from[0].getZ() + distance; + for (BlockPos p : from) { + minX = Math.min(minX, p.getX() - distance); + minY = Math.min(minY, p.getY() - distance); + minZ = Math.min(minZ, p.getZ() - distance); + maxX = Math.max(minX, p.getX() + distance); + maxY = Math.max(minY, p.getY() + distance); + maxZ = Math.max(minZ, p.getZ() + distance); + } + HashSet maybeAlwaysInside = new HashSet<>(); + HashSet sometimesOutside = new HashSet<>(); + for (int x = minX; x <= maxX; x++) { + for (int y = minX; y <= maxX; y++) { + for (int z = minX; z <= maxX; z++) { + double h = heuristic(x, y, z); + if (!sometimesOutside.contains(h) && isInGoal(x, y, z)) { + maybeAlwaysInside.add(h); + } else { + maybeAlwaysInside.remove(h); + sometimesOutside.add(h); + } + } + } + } + try { + return Collections.max(maybeAlwaysInside); + } catch (NoSuchElementException e) { + return Double.NEGATIVE_INFINITY; + } + } + @Override public String toString() { if (maintainY != null) { From 85cc86346cef57c0052d4ddc3b3f0f2074d2ed08 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sun, 20 Sep 2020 22:20:24 +0200 Subject: [PATCH 018/155] Actually use Y and Z bounds for Y and Z --- src/api/java/baritone/api/pathing/goals/GoalRunAway.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java index 3955de1e9..76f7110cc 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java +++ b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java @@ -103,8 +103,8 @@ public class GoalRunAway implements Goal { HashSet maybeAlwaysInside = new HashSet<>(); HashSet sometimesOutside = new HashSet<>(); for (int x = minX; x <= maxX; x++) { - for (int y = minX; y <= maxX; y++) { - for (int z = minX; z <= maxX; z++) { + for (int y = minY; y <= maxY; y++) { + for (int z = minZ; z <= maxZ; z++) { double h = heuristic(x, y, z); if (!sometimesOutside.contains(h) && isInGoal(x, y, z)) { maybeAlwaysInside.add(h); From aebfbba20ecfef60af5c45ddb855a49042be0bd9 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sun, 20 Sep 2020 22:39:48 +0200 Subject: [PATCH 019/155] Also override heuristic(no args) when overriding isInGoal() --- src/main/java/baritone/process/GetToBlockProcess.java | 4 ++++ src/main/java/baritone/process/MineProcess.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/main/java/baritone/process/GetToBlockProcess.java b/src/main/java/baritone/process/GetToBlockProcess.java index 00ec26091..78df95883 100644 --- a/src/main/java/baritone/process/GetToBlockProcess.java +++ b/src/main/java/baritone/process/GetToBlockProcess.java @@ -77,6 +77,10 @@ public final class GetToBlockProcess extends BaritoneProcessHelper implements IG public boolean isInGoal(int x, int y, int z) { return false; } + @Override + public double heuristic() { + return Double.NEGATIVE_INFINITY; + } }, PathingCommandType.FORCE_REVALIDATE_GOAL_AND_PATH); } logDirect("No known locations of " + gettingTo + ", canceling GetToBlock"); diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index 6e8ba245b..f976f71b5 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -211,6 +211,10 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro public boolean isInGoal(int x, int y, int z) { return false; } + @Override + public double heuristic() { + return Double.NEGATIVE_INFINITY; + } }; } return new PathingCommand(branchPointRunaway, PathingCommandType.REVALIDATE_GOAL_AND_PATH); From e529438c7ef8f4f5593f6fbff6c41d2d81abdd71 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Wed, 14 Oct 2020 21:14:17 +0200 Subject: [PATCH 020/155] Don't use Abs on Sqrt --- src/api/java/baritone/api/pathing/goals/GoalNear.java | 2 +- src/api/java/baritone/api/pathing/goals/GoalRunAway.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/java/baritone/api/pathing/goals/GoalNear.java b/src/api/java/baritone/api/pathing/goals/GoalNear.java index 6f493fa54..c7e932e23 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalNear.java +++ b/src/api/java/baritone/api/pathing/goals/GoalNear.java @@ -56,7 +56,7 @@ public class GoalNear implements Goal, IGoalRenderPos { @Override public double heuristic() {//TODO less hacky solution - int range = (int)Math.ceil(Math.abs(Math.sqrt(rangeSq))); + int range = (int)Math.ceil(Math.sqrt(rangeSq)); HashSet maybeAlwaysInside = new HashSet<>(); HashSet sometimesOutside = new HashSet<>(); for (int dx = -range; dx <= range; dx++) { diff --git a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java index 76f7110cc..9ee1b1510 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java +++ b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java @@ -85,7 +85,7 @@ public class GoalRunAway implements Goal { @Override public double heuristic() {//TODO less hacky solution - int distance = (int)Math.ceil(Math.abs(Math.sqrt(distanceSq))); + int distance = (int)Math.ceil(Math.sqrt(distanceSq)); int minX = from[0].getX() - distance; int minY = from[0].getY() - distance; int minZ = from[0].getZ() - distance; From 0c7741120a10ff617583ffb6bf6eb65f3a4fe3f9 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Thu, 15 Oct 2020 00:05:54 +0200 Subject: [PATCH 021/155] =?UTF-8?q?=F0=9F=91=8Cformatting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/baritone/api/pathing/goals/Goal.java | 18 +++++++++--------- .../api/pathing/goals/GoalComposite.java | 2 +- .../baritone/api/pathing/goals/GoalNear.java | 6 +++--- .../api/pathing/goals/GoalRunAway.java | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/api/java/baritone/api/pathing/goals/Goal.java b/src/api/java/baritone/api/pathing/goals/Goal.java index 7d8f42220..95462f961 100644 --- a/src/api/java/baritone/api/pathing/goals/Goal.java +++ b/src/api/java/baritone/api/pathing/goals/Goal.java @@ -56,15 +56,15 @@ public interface Goal { } /** - * Returns the heuristic at the goal. - * i.e. {@code heuristic() == heuristic(x,y,z)} - * when {@code isInGoal(x,y,z) == true} - * This is needed by {@code PathingBehavior#estimatedTicksToGoal} because - * some Goals actually do not have a heuristic of 0 when that condition is met - * - * @return The estimate number of ticks to satisfy the goal when the goal - * is already satisfied - */ + * Returns the heuristic at the goal. + * i.e. {@code heuristic() == heuristic(x,y,z)} + * when {@code isInGoal(x,y,z) == true} + * This is needed by {@code PathingBehavior#estimatedTicksToGoal} because + * some Goals actually do not have a heuristic of 0 when that condition is met + * + * @return The estimate number of ticks to satisfy the goal when the goal + * is already satisfied + */ default double heuristic() { return 0; } diff --git a/src/api/java/baritone/api/pathing/goals/GoalComposite.java b/src/api/java/baritone/api/pathing/goals/GoalComposite.java index fd4e672b0..ebaf38eda 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalComposite.java +++ b/src/api/java/baritone/api/pathing/goals/GoalComposite.java @@ -60,7 +60,7 @@ public class GoalComposite implements Goal { @Override public double heuristic() { double min = Double.MAX_VALUE; - for (Goal g: goals) { + for (Goal g : goals) { //just take the highest value that is guaranteed to be inside the goal min = Math.min(min, g.heuristic()); } diff --git a/src/api/java/baritone/api/pathing/goals/GoalNear.java b/src/api/java/baritone/api/pathing/goals/GoalNear.java index c7e932e23..0657c1724 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalNear.java +++ b/src/api/java/baritone/api/pathing/goals/GoalNear.java @@ -56,14 +56,14 @@ public class GoalNear implements Goal, IGoalRenderPos { @Override public double heuristic() {//TODO less hacky solution - int range = (int)Math.ceil(Math.sqrt(rangeSq)); + int range = (int) Math.ceil(Math.sqrt(rangeSq)); HashSet maybeAlwaysInside = new HashSet<>(); HashSet sometimesOutside = new HashSet<>(); for (int dx = -range; dx <= range; dx++) { for (int dy = -range; dy <= range; dy++) { for (int dz = -range; dz <= range; dz++) { - double h = heuristic(x+dx, y+dy, z+dz); - if (!sometimesOutside.contains(h) && isInGoal(x+dx, y+dy, z+dz)) { + double h = heuristic(x + dx, y + dy, z + dz); + if (!sometimesOutside.contains(h) && isInGoal(x + dx, y + dy, z + dz)) { maybeAlwaysInside.add(h); } else { maybeAlwaysInside.remove(h); diff --git a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java index 9ee1b1510..7983d6fcc 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java +++ b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java @@ -85,7 +85,7 @@ public class GoalRunAway implements Goal { @Override public double heuristic() {//TODO less hacky solution - int distance = (int)Math.ceil(Math.sqrt(distanceSq)); + int distance = (int) Math.ceil(Math.sqrt(distanceSq)); int minX = from[0].getX() - distance; int minY = from[0].getY() - distance; int minZ = from[0].getZ() - distance; From 3cdbc4cb83fa161380b31a0089d019b2b9f3ebd1 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Thu, 15 Oct 2020 21:48:17 +0200 Subject: [PATCH 022/155] =?UTF-8?q?=F0=9F=91=8Cformatting=20in=20of=20comm?= =?UTF-8?q?ents?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/java/baritone/api/pathing/goals/GoalComposite.java | 2 +- src/api/java/baritone/api/pathing/goals/GoalNear.java | 2 +- src/api/java/baritone/api/pathing/goals/GoalRunAway.java | 4 ++-- src/main/java/baritone/behavior/PathingBehavior.java | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/api/java/baritone/api/pathing/goals/GoalComposite.java b/src/api/java/baritone/api/pathing/goals/GoalComposite.java index ebaf38eda..47522492b 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalComposite.java +++ b/src/api/java/baritone/api/pathing/goals/GoalComposite.java @@ -61,7 +61,7 @@ public class GoalComposite implements Goal { public double heuristic() { double min = Double.MAX_VALUE; for (Goal g : goals) { - //just take the highest value that is guaranteed to be inside the goal + // just take the highest value that is guaranteed to be inside the goal min = Math.min(min, g.heuristic()); } return min; diff --git a/src/api/java/baritone/api/pathing/goals/GoalNear.java b/src/api/java/baritone/api/pathing/goals/GoalNear.java index 0657c1724..2ae2decc2 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalNear.java +++ b/src/api/java/baritone/api/pathing/goals/GoalNear.java @@ -55,7 +55,7 @@ public class GoalNear implements Goal, IGoalRenderPos { } @Override - public double heuristic() {//TODO less hacky solution + public double heuristic() {// TODO less hacky solution int range = (int) Math.ceil(Math.sqrt(rangeSq)); HashSet maybeAlwaysInside = new HashSet<>(); HashSet sometimesOutside = new HashSet<>(); diff --git a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java index 7983d6fcc..e66cbb828 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java +++ b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java @@ -68,7 +68,7 @@ public class GoalRunAway implements Goal { } @Override - public double heuristic(int x, int y, int z) {//mostly copied from GoalBlock + public double heuristic(int x, int y, int z) {// mostly copied from GoalBlock double min = Double.MAX_VALUE; for (BlockPos p : from) { double h = GoalXZ.calculate(p.getX() - x, p.getZ() - z); @@ -84,7 +84,7 @@ public class GoalRunAway implements Goal { } @Override - public double heuristic() {//TODO less hacky solution + public double heuristic() {// TODO less hacky solution int distance = (int) Math.ceil(Math.sqrt(distanceSq)); int minX = from[0].getX() - distance; int minY = from[0].getY() - distance; diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 967df1b33..f9c56c5a4 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -391,7 +391,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, } double current = goal.heuristic(currentPos.x, currentPos.y, currentPos.z); double start = goal.heuristic(startPosition.x, startPosition.y, startPosition.z); - if (current == start) {//can't check above because current and start can be equal even if currentPos and startPosition are not + if (current == start) {// can't check above because current and start can be equal even if currentPos and startPosition are not return Optional.empty(); } double eta = Math.abs(current - goal.heuristic()) * ticksElapsedSoFar / Math.abs(start - current); From 939319203611aed1dd5e699b7324d313c88e786a Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Fri, 16 Oct 2020 01:30:04 +0200 Subject: [PATCH 023/155] Slight change to heuristic(no args) --- src/api/java/baritone/api/pathing/goals/GoalNear.java | 7 +++---- src/api/java/baritone/api/pathing/goals/GoalRunAway.java | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/api/java/baritone/api/pathing/goals/GoalNear.java b/src/api/java/baritone/api/pathing/goals/GoalNear.java index 2ae2decc2..272636ac5 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalNear.java +++ b/src/api/java/baritone/api/pathing/goals/GoalNear.java @@ -58,16 +58,15 @@ public class GoalNear implements Goal, IGoalRenderPos { public double heuristic() {// TODO less hacky solution int range = (int) Math.ceil(Math.sqrt(rangeSq)); HashSet maybeAlwaysInside = new HashSet<>(); - HashSet sometimesOutside = new HashSet<>(); + double minOutside = Double.POSITIVE_INFINITY; for (int dx = -range; dx <= range; dx++) { for (int dy = -range; dy <= range; dy++) { for (int dz = -range; dz <= range; dz++) { double h = heuristic(x + dx, y + dy, z + dz); - if (!sometimesOutside.contains(h) && isInGoal(x + dx, y + dy, z + dz)) { + if (h < minOutside && isInGoal(x + dx, y + dy, z + dz)) { maybeAlwaysInside.add(h); } else { - maybeAlwaysInside.remove(h); - sometimesOutside.add(h); + minOutside = Math.min(minOutside, h); } } } diff --git a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java index e66cbb828..36797617e 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java +++ b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java @@ -101,16 +101,15 @@ public class GoalRunAway implements Goal { maxZ = Math.max(minZ, p.getZ() + distance); } HashSet maybeAlwaysInside = new HashSet<>(); - HashSet sometimesOutside = new HashSet<>(); + double minOutside = Double.POSITIVE_INFINITY; for (int x = minX; x <= maxX; x++) { for (int y = minY; y <= maxY; y++) { for (int z = minZ; z <= maxZ; z++) { double h = heuristic(x, y, z); - if (!sometimesOutside.contains(h) && isInGoal(x, y, z)) { + if (h < minOutside && isInGoal(x, y, z)) { maybeAlwaysInside.add(h); } else { - maybeAlwaysInside.remove(h); - sometimesOutside.add(h); + minOutside = Math.min(minOutside, h); } } } From 4aa52d2f2ef02875c73f1ff258ddc39b9651ebf7 Mon Sep 17 00:00:00 2001 From: scorbett123 Date: Sat, 24 Oct 2020 18:03:29 +0100 Subject: [PATCH 024/155] add itemSaver setting. Signed-off-by: scorbett123 --- src/api/java/baritone/api/Settings.java | 5 +++++ src/main/java/baritone/utils/ToolSet.java | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 9cabe083c..129c418d2 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -684,6 +684,11 @@ public final class Settings { */ public final Setting censorRanCommands = new Setting<>(false); + /** + * Stop using tools just before they are going to break. + */ + public final Setting itemSaver = new Setting<>(false); + /** * Always prefer silk touch tools over regular tools. This will not sacrifice speed, but it will always prefer silk * touch tools over other tools of the same speed. This includes always choosing ANY silk touch tool over your hand. diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index aa8819cef..798420f9e 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -18,6 +18,7 @@ package baritone.utils; import baritone.Baritone; +import baritone.api.utils.Helper; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.entity.EntityPlayerSP; @@ -124,6 +125,9 @@ public class ToolSet { IBlockState blockState = b.getDefaultState(); for (int i = 0; i < 9; i++) { ItemStack itemStack = player.inventory.getStackInSlot(i); + if (itemStack.getItemDamage() >= itemStack.getMaxDamage() - 1 && Baritone.settings().itemSaver.value) { + continue; + } double speed = calculateSpeedVsBlock(itemStack, blockState); boolean silkTouch = hasSilkTouch(itemStack); if (speed > highestSpeed) { From 99223825814f2182e69232ee76e7dc4468436b12 Mon Sep 17 00:00:00 2001 From: Sam Corbett Date: Wed, 28 Oct 2020 08:44:40 +0000 Subject: [PATCH 025/155] don't fall back onto the first slot if it has a low durability item in the slot. Signed-off-by: Sam Corbett --- src/main/java/baritone/behavior/InventoryBehavior.java | 2 +- src/main/java/baritone/utils/ToolSet.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/behavior/InventoryBehavior.java b/src/main/java/baritone/behavior/InventoryBehavior.java index b21cec033..ce41e3bc3 100644 --- a/src/main/java/baritone/behavior/InventoryBehavior.java +++ b/src/main/java/baritone/behavior/InventoryBehavior.java @@ -114,7 +114,7 @@ public final class InventoryBehavior extends Behavior { } if (cla$$.isInstance(stack.getItem())) { double speed = ToolSet.calculateSpeedVsBlock(stack, against.getDefaultState()); // takes into account enchants - if (speed > bestSpeed) { + if (speed > bestSpeed && !(stack.getItemDamage() >= stack.getMaxDamage() && Baritone.settings().itemSaver.value && stack.getMaxDamage() > 1)) { bestSpeed = speed; bestInd = i; } diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index 798420f9e..7e88de8dd 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -18,7 +18,6 @@ package baritone.utils; import baritone.Baritone; -import baritone.api.utils.Helper; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.entity.EntityPlayerSP; @@ -125,7 +124,7 @@ public class ToolSet { IBlockState blockState = b.getDefaultState(); for (int i = 0; i < 9; i++) { ItemStack itemStack = player.inventory.getStackInSlot(i); - if (itemStack.getItemDamage() >= itemStack.getMaxDamage() - 1 && Baritone.settings().itemSaver.value) { + if (itemStack.getItemDamage() >= itemStack.getMaxDamage() && Baritone.settings().itemSaver.value && itemStack.getMaxDamage() > 1) { continue; } double speed = calculateSpeedVsBlock(itemStack, blockState); From 49bc96dc7ea80c1ef854ee5b128f4535a0388dea Mon Sep 17 00:00:00 2001 From: scorbett123 Date: Sun, 1 Nov 2020 16:12:38 +0000 Subject: [PATCH 026/155] add useSwordToMine setting. Signed-off-by: scorbett123 --- src/api/java/baritone/api/Settings.java | 5 +++++ src/main/java/baritone/utils/ToolSet.java | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 96e4c5790..7e009b376 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -1108,6 +1108,11 @@ public final class Settings { */ public final Setting renderSelectionCorners = new Setting<>(true); + /** + * Use sword to mine. + */ + public final Setting useSwordToMine = new Setting<>(true); + /** * Desktop notifications */ diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index aa8819cef..1cc5ca4c5 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -26,6 +26,7 @@ import net.minecraft.init.Enchantments; import net.minecraft.init.MobEffects; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; import net.minecraft.item.ItemTool; import java.util.HashMap; @@ -124,6 +125,8 @@ public class ToolSet { IBlockState blockState = b.getDefaultState(); for (int i = 0; i < 9; i++) { ItemStack itemStack = player.inventory.getStackInSlot(i); + if (!Baritone.settings().useSwordToMine.value && itemStack.getItem() instanceof ItemSword) + continue; double speed = calculateSpeedVsBlock(itemStack, blockState); boolean silkTouch = hasSilkTouch(itemStack); if (speed > highestSpeed) { From 60f81fb89d6bb0c4c3adbf419a55878bf4b9831d Mon Sep 17 00:00:00 2001 From: scorbett123 Date: Sun, 1 Nov 2020 17:18:31 +0000 Subject: [PATCH 027/155] notify users that their death position has been saved. Signed-off-by: scorbett123 --- .../baritone/behavior/MemoryBehavior.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/main/java/baritone/behavior/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java index 66ab10f31..061677d52 100644 --- a/src/main/java/baritone/behavior/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/MemoryBehavior.java @@ -25,6 +25,7 @@ import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.TickEvent; import baritone.api.event.events.type.EventState; import baritone.api.utils.BetterBlockPos; +import baritone.api.utils.Helper; import baritone.cache.ContainerMemory; import baritone.utils.BlockStateInterface; import net.minecraft.block.Block; @@ -40,13 +41,20 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityLockable; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentTranslation; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.event.ClickEvent; +import net.minecraft.util.text.event.HoverEvent; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.*; +import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX; + /** * doesn't work for horse inventories :^) * @@ -166,7 +174,26 @@ public final class MemoryBehavior extends Behavior { @Override public void onPlayerDeath() { + Waypoint deathWaypoint = new Waypoint("death", Waypoint.Tag.DEATH, ctx.playerFeet()); baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("death", Waypoint.Tag.DEATH, ctx.playerFeet())); + ITextComponent component = new TextComponentString("Death position saved."); + component.getStyle() + .setColor(TextFormatting.WHITE) + .setHoverEvent(new HoverEvent( + HoverEvent.Action.SHOW_TEXT, + new TextComponentString("Click to goto death") + )) + .setClickEvent(new ClickEvent( + ClickEvent.Action.RUN_COMMAND, + String.format( + "%s%s goto %s @ %d", + FORCE_COMMAND_PREFIX, + "wp", + deathWaypoint.getTag().getName(), + deathWaypoint.getCreationTimestamp() + ) + )); + Helper.HELPER.logDirect(component); } From c0f7d5ab44b362f5bea045c77bca0514ea841b50 Mon Sep 17 00:00:00 2001 From: scorbett123 Date: Sun, 1 Nov 2020 17:30:53 +0000 Subject: [PATCH 028/155] fix error made while copying and pasting. Signed-off-by: scorbett123 --- src/main/java/baritone/behavior/MemoryBehavior.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/behavior/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java index 061677d52..b7d31223a 100644 --- a/src/main/java/baritone/behavior/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/MemoryBehavior.java @@ -175,7 +175,7 @@ public final class MemoryBehavior extends Behavior { @Override public void onPlayerDeath() { Waypoint deathWaypoint = new Waypoint("death", Waypoint.Tag.DEATH, ctx.playerFeet()); - baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("death", Waypoint.Tag.DEATH, ctx.playerFeet())); + baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(deathWaypoint); ITextComponent component = new TextComponentString("Death position saved."); component.getStyle() .setColor(TextFormatting.WHITE) From b9eeab06a13589fd9d1a18df074bd6a077e5b1bc Mon Sep 17 00:00:00 2001 From: Sam Corbett Date: Mon, 2 Nov 2020 07:47:36 +0000 Subject: [PATCH 029/155] change useSwordToMine to default to false. Signed-off-by: Sam Corbett --- src/api/java/baritone/api/Settings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 7e009b376..283d17cc0 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -1111,7 +1111,7 @@ public final class Settings { /** * Use sword to mine. */ - public final Setting useSwordToMine = new Setting<>(true); + public final Setting useSwordToMine = new Setting<>(false); /** * Desktop notifications From 7988274d616a19d487d52739547edaa440806941 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Tue, 12 Jan 2021 23:59:11 +0100 Subject: [PATCH 030/155] =?UTF-8?q?=E2=9C=A8=20add=20buildSkipBlocks=20set?= =?UTF-8?q?ting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/java/baritone/api/Settings.java | 9 +++++++++ src/main/java/baritone/process/BuilderProcess.java | 3 +++ 2 files changed, 12 insertions(+) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 69b7e5527..2de53e607 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -206,6 +206,15 @@ public final class Settings { ))); + /** + * A list of blocks to be treated as correct. + *

+ * If a schematic asks for any block on this list at a certain position, it will be treated as correct, regardless of what it currently is. + */ + public final Setting> buildSkipBlocks = new Setting<>(new ArrayList<>(Arrays.asList( + + ))); + /** * A list of blocks to become air *

diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 00d3831ce..1d08a0f19 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -794,6 +794,9 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil if (!(current.getBlock() instanceof BlockAir) && Baritone.settings().buildIgnoreExisting.value && !itemVerify) { return true; } + if (Baritone.settings().buildSkipBlocks.value.contains(desired.getBlock())) { + return true; + } return current.equals(desired); } From dba186347c192c12eeb764e55be8751143d1728d Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Wed, 13 Jan 2021 22:45:59 +0100 Subject: [PATCH 031/155] remove likely useless code breaking buildSkipBlocks --- src/api/java/baritone/api/schematic/FillSchematic.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/api/java/baritone/api/schematic/FillSchematic.java b/src/api/java/baritone/api/schematic/FillSchematic.java index de9ccf970..edb1d6113 100644 --- a/src/api/java/baritone/api/schematic/FillSchematic.java +++ b/src/api/java/baritone/api/schematic/FillSchematic.java @@ -44,8 +44,6 @@ public class FillSchematic extends AbstractSchematic { public IBlockState desiredState(int x, int y, int z, IBlockState current, List approxPlaceable) { if (bom.matches(current)) { return current; - } else if (current.getBlock() != Blocks.AIR) { - return Blocks.AIR.getDefaultState(); } for (IBlockState placeable : approxPlaceable) { if (bom.matches(placeable)) { From 5e4f31f39e337bd70fe01c9b15b74a527cd318b3 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sat, 16 Jan 2021 02:05:59 +0100 Subject: [PATCH 032/155] proper place/break costs for skipped blocks --- src/main/java/baritone/process/BuilderProcess.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 1d08a0f19..9e76b04ba 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -794,7 +794,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil if (!(current.getBlock() instanceof BlockAir) && Baritone.settings().buildIgnoreExisting.value && !itemVerify) { return true; } - if (Baritone.settings().buildSkipBlocks.value.contains(desired.getBlock())) { + if (Baritone.settings().buildSkipBlocks.value.contains(desired.getBlock()) && !itemVerify) { return true; } return current.equals(desired); @@ -834,7 +834,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil return COST_INF; } IBlockState sch = getSchematic(x, y, z, current); - if (sch != null) { + if (sch != null && !Baritone.settings().buildSkipBlocks.value.contains(sch.getBlock())) { // TODO this can return true even when allowPlace is off.... is that an issue? if (sch.getBlock() == Blocks.AIR) { // we want this to be air, but they're asking if they can place here @@ -868,7 +868,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil return COST_INF; } IBlockState sch = getSchematic(x, y, z, current); - if (sch != null) { + if (sch != null && !Baritone.settings().buildSkipBlocks.value.contains(sch.getBlock())) { if (sch.getBlock() == Blocks.AIR) { // it should be air // regardless of current contents, we can break it From d375d1abc97b77a12c2d61408b9fd351d2b29595 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sun, 17 Jan 2021 00:16:34 +0100 Subject: [PATCH 033/155] Add setting parser for mappings --- .../java/baritone/api/utils/SettingsUtil.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/api/java/baritone/api/utils/SettingsUtil.java b/src/api/java/baritone/api/utils/SettingsUtil.java index f9cb71361..48c8ee4df 100644 --- a/src/api/java/baritone/api/utils/SettingsUtil.java +++ b/src/api/java/baritone/api/utils/SettingsUtil.java @@ -35,6 +35,7 @@ import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.function.Consumer; import java.util.function.Function; @@ -261,6 +262,36 @@ public class SettingsUtil { public boolean accepts(Type type) { return List.class.isAssignableFrom(TypeUtils.resolveBaseClass(type)); } + }, + MAPPING() { + @Override + public Object parse(ParserContext context, String raw) { + Type keyType = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[0]; + Type valueType = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[1]; + Parser keyParser = Parser.getParser(keyType); + Parser valueParser = Parser.getParser(valueType); + + return Stream.of(raw.split(",(?=[^,]*->)")) + .map(s -> s.split("->")) + .collect(Collectors.toMap(s -> keyParser.parse(context, s[0]), s -> valueParser.parse(context, s[1]))); + } + + @Override + public String toString(ParserContext context, Object value) { + Type keyType = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[0]; + Type valueType = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[1]; + Parser keyParser = Parser.getParser(keyType); + Parser valueParser = Parser.getParser(valueType); + + return ((Map) value).entrySet().stream() + .map(o -> keyParser.toString(context, o.getKey()) + "->" + valueParser.toString(context, o.getValue())) + .collect(Collectors.joining(",")); + } + + @Override + public boolean accepts(Type type) { + return Map.class.isAssignableFrom(TypeUtils.resolveBaseClass(type)); + } }; private final Class cla$$; From 13547781d2088b63c1fab6803e3ddb75b1b0865c Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sun, 17 Jan 2021 00:53:50 +0100 Subject: [PATCH 034/155] add buildValidSubstitutes setting to builder --- src/api/java/baritone/api/Settings.java | 7 +++++++ src/main/java/baritone/process/BuilderProcess.java | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 2de53e607..1b9b173a1 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -215,6 +215,13 @@ public final class Settings { ))); + /** + * A mapping of blocks to blocks treated as correct in their position + *

+ * If a schematic asks for a block on this mapping, all blocks on the mapped list will be accepted at that location as well + */ + public final Setting>> buildValidSubstitutes = new Setting<>(new HashMap<>()); + /** * A list of blocks to become air *

diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 9e76b04ba..77f0ef1c3 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -797,6 +797,9 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil if (Baritone.settings().buildSkipBlocks.value.contains(desired.getBlock()) && !itemVerify) { return true; } + if (Baritone.settings().buildValidSubstitutes.value.getOrDefault(desired.getBlock(), Arrays.asList()).contains(current.getBlock()) && !itemVerify) { + return true; + } return current.equals(desired); } From fc1a2a61126201f14f41891a868f67546999c993 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sun, 17 Jan 2021 02:45:40 +0100 Subject: [PATCH 035/155] Add buildSubstitutes setting to builder --- src/api/java/baritone/api/Settings.java | 7 ++ .../api/schematic/SubstituteSchematic.java | 71 +++++++++++++++++++ .../java/baritone/process/BuilderProcess.java | 4 ++ 3 files changed, 82 insertions(+) create mode 100644 src/api/java/baritone/api/schematic/SubstituteSchematic.java diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 1b9b173a1..0641ff8ab 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -222,6 +222,13 @@ public final class Settings { */ public final Setting>> buildValidSubstitutes = new Setting<>(new HashMap<>()); + /** + * A mapping of blocks to blocks to be built instead + *

+ * If a schematic asks for a block on this mapping, Baritone will place the first placeable block in the mapped list + */ + public final Setting>> buildSubstitutes = new Setting<>(new HashMap<>()); + /** * A list of blocks to become air *

diff --git a/src/api/java/baritone/api/schematic/SubstituteSchematic.java b/src/api/java/baritone/api/schematic/SubstituteSchematic.java new file mode 100644 index 000000000..fbd19da8a --- /dev/null +++ b/src/api/java/baritone/api/schematic/SubstituteSchematic.java @@ -0,0 +1,71 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package baritone.api.schematic; + +import baritone.api.utils.BlockOptionalMetaLookup; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import java.util.List; +import java.util.Map; + +public class SubstituteSchematic extends AbstractSchematic { + + private final ISchematic schematic; + private final Map> substitutions; + + public SubstituteSchematic(ISchematic schematic, Map> substitutions) { + super(schematic.widthX(), schematic.heightY(), schematic.lengthZ()); + this.schematic = schematic; + this.substitutions = substitutions; + } + + @Override + public boolean inSchematic(int x, int y, int z, IBlockState currentState) { + return schematic.inSchematic(x, y, z, currentState); + } + + @Override + public IBlockState desiredState(int x, int y, int z, IBlockState current, List approxPlaceable) { + IBlockState desired = schematic.desiredState(x, y, z, current, approxPlaceable); + Block desiredBlock = desired.getBlock(); + if (!substitutions.containsKey(desiredBlock)) { + return desired; + } + List substitutes = substitutions.get(desiredBlock); + if (substitutes.contains(current.getBlock()) && !current.getBlock().equals(Blocks.AIR)) {// don't preserve air, it's almost always there and almost never wanted + System.out.println(String.format("%s is already placed", current)); + return current; + } + for (Block substitute : substitutes) { + if (substitute.equals(Blocks.AIR)) { + System.out.println("air, lol"); + return Blocks.AIR.getDefaultState(); // can always "place" air + } + for (IBlockState placeable : approxPlaceable) { + if (substitute.equals(placeable.getBlock())) { + System.out.println(String.format("%s can be placed", placeable)); + return placeable; + } + } + System.out.println(String.format("%s is not an option", substitute)); + } + System.out.println(String.format("%s fail", substitutes.get(0).getDefaultState())); + return substitutes.get(0).getDefaultState(); + } +} diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 77f0ef1c3..c5be76f03 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -26,6 +26,7 @@ import baritone.api.process.IBuilderProcess; import baritone.api.process.PathingCommand; import baritone.api.process.PathingCommandType; import baritone.api.schematic.FillSchematic; +import baritone.api.schematic.SubstituteSchematic; import baritone.api.schematic.ISchematic; import baritone.api.schematic.IStaticSchematic; import baritone.api.schematic.format.ISchematicFormat; @@ -84,6 +85,9 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil this.name = name; this.schematic = schematic; this.realSchematic = null; + if (!Baritone.settings().buildSubstitutes.value.isEmpty()) { + this.schematic = new SubstituteSchematic(this.schematic, Baritone.settings().buildSubstitutes.value); + } int x = origin.getX(); int y = origin.getY(); int z = origin.getZ(); From f6d4a315c7f306d0468638e894a0a9fe74daa83f Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Mon, 18 Jan 2021 11:58:42 +0100 Subject: [PATCH 036/155] Remove debug log --- src/api/java/baritone/api/schematic/SubstituteSchematic.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/api/java/baritone/api/schematic/SubstituteSchematic.java b/src/api/java/baritone/api/schematic/SubstituteSchematic.java index fbd19da8a..675ccbff9 100644 --- a/src/api/java/baritone/api/schematic/SubstituteSchematic.java +++ b/src/api/java/baritone/api/schematic/SubstituteSchematic.java @@ -49,23 +49,18 @@ public class SubstituteSchematic extends AbstractSchematic { } List substitutes = substitutions.get(desiredBlock); if (substitutes.contains(current.getBlock()) && !current.getBlock().equals(Blocks.AIR)) {// don't preserve air, it's almost always there and almost never wanted - System.out.println(String.format("%s is already placed", current)); return current; } for (Block substitute : substitutes) { if (substitute.equals(Blocks.AIR)) { - System.out.println("air, lol"); return Blocks.AIR.getDefaultState(); // can always "place" air } for (IBlockState placeable : approxPlaceable) { if (substitute.equals(placeable.getBlock())) { - System.out.println(String.format("%s can be placed", placeable)); return placeable; } } - System.out.println(String.format("%s is not an option", substitute)); } - System.out.println(String.format("%s fail", substitutes.get(0).getDefaultState())); return substitutes.get(0).getDefaultState(); } } From 8c1a9f460defa29c9086ed467aeded8fbce1f661 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Mon, 18 Jan 2021 12:06:50 +0100 Subject: [PATCH 037/155] Simple blockstate preservation for buildSubstitutes --- .../api/schematic/SubstituteSchematic.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/api/java/baritone/api/schematic/SubstituteSchematic.java b/src/api/java/baritone/api/schematic/SubstituteSchematic.java index 675ccbff9..fbc075805 100644 --- a/src/api/java/baritone/api/schematic/SubstituteSchematic.java +++ b/src/api/java/baritone/api/schematic/SubstituteSchematic.java @@ -19,8 +19,10 @@ package baritone.api.schematic; import baritone.api.utils.BlockOptionalMetaLookup; import net.minecraft.block.Block; +import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; +import java.util.Collection; import java.util.List; import java.util.Map; @@ -49,7 +51,7 @@ public class SubstituteSchematic extends AbstractSchematic { } List substitutes = substitutions.get(desiredBlock); if (substitutes.contains(current.getBlock()) && !current.getBlock().equals(Blocks.AIR)) {// don't preserve air, it's almost always there and almost never wanted - return current; + return withBlock(desired, current.getBlock()); } for (Block substitute : substitutes) { if (substitute.equals(Blocks.AIR)) { @@ -57,10 +59,25 @@ public class SubstituteSchematic extends AbstractSchematic { } for (IBlockState placeable : approxPlaceable) { if (substitute.equals(placeable.getBlock())) { - return placeable; + return withBlock(desired, placeable.getBlock()); } } } return substitutes.get(0).getDefaultState(); } + + private IBlockState withBlock(IBlockState state, Block block) { + Collection> properties = state.getPropertyKeys(); + IBlockState newState = block.getDefaultState(); + for (IProperty property : properties) { + try { + newState = copySingleProp(state, newState, property); + } catch (IllegalArgumentException e) { //property does not exist for target block + } + } + return newState; + } + private > IBlockState copySingleProp(IBlockState fromState, IBlockState toState, IProperty prop) { + return toState.withProperty(prop, fromState.getValue(prop)); + } } From fd6120770969b43a1880f6eb55c4ee89d6c01074 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Thu, 28 Jan 2021 01:27:27 +0100 Subject: [PATCH 038/155] Fix heuristic(no args) returning wrong values --- src/api/java/baritone/api/pathing/goals/GoalNear.java | 8 +++++++- .../java/baritone/api/pathing/goals/GoalRunAway.java | 11 ++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/api/java/baritone/api/pathing/goals/GoalNear.java b/src/api/java/baritone/api/pathing/goals/GoalNear.java index 272636ac5..7f87e8b92 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalNear.java +++ b/src/api/java/baritone/api/pathing/goals/GoalNear.java @@ -71,7 +71,13 @@ public class GoalNear implements Goal, IGoalRenderPos { } } } - return Collections.max(maybeAlwaysInside); + double maxInside = Double.NEGATIVE_INFINITY; + for (double inside : maybeAlwaysInside) { + if (inside < minOutside) { + maxInside = Math.max(maxInside, inside); + } + } + return maxInside; } @Override diff --git a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java index 36797617e..b9c41aeaf 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java +++ b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java @@ -23,7 +23,6 @@ import net.minecraft.util.math.BlockPos; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; -import java.util.NoSuchElementException; /** * Useful for automated combat (retreating specifically) @@ -114,11 +113,13 @@ public class GoalRunAway implements Goal { } } } - try { - return Collections.max(maybeAlwaysInside); - } catch (NoSuchElementException e) { - return Double.NEGATIVE_INFINITY; + double maxInside = Double.NEGATIVE_INFINITY; + for (double inside : maybeAlwaysInside) { + if (inside < minOutside) { + maxInside = Math.max(maxInside, inside); + } } + return maxInside; } @Override From 8f863bf19b807f6992e1746c91ead103e4ed4c88 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 5 Feb 2021 20:08:46 -0800 Subject: [PATCH 039/155] empty From adff60b1181e3a09652537eb3caaccc7268e3888 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 5 Feb 2021 22:41:52 -0800 Subject: [PATCH 040/155] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f709a3d81..1b0751ca1 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,9 @@ [![Minecraft](https://img.shields.io/badge/MC-1.13.2-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.13.2/) [![Minecraft](https://img.shields.io/badge/MC-1.14.4-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.14.4/) [![Minecraft](https://img.shields.io/badge/MC-1.15.2-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.15.2/) +[![Minecraft](https://img.shields.io/badge/MC-1.16.4-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.16.2/) [![Minecraft](https://img.shields.io/badge/MC-1.16.4-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.16.4/) +[![Minecraft](https://img.shields.io/badge/MC-1.16.4-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.16.5/) [![Code of Conduct](https://img.shields.io/badge/%E2%9D%A4-code%20of%20conduct-blue.svg?style=flat)](https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md) [![Known Vulnerabilities](https://snyk.io/test/github/cabaletta/baritone/badge.svg?targetFile=build.gradle)](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle) [![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/cabaletta/baritone/issues/) @@ -40,10 +42,10 @@ The easiest way to install Baritone is to install [Impact](https://impactclient. For 1.15.2, [click here](https://www.youtube.com/watch?v=j1qKtCZFURM) and see description. If you need Forge 1.15.2, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.5.3), follow the instructions, and get the `api-forge` jar. -For 1.16.4, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. If you need Forge 1.16.4, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.6.2) and get the `api-forge` jar. +For 1.16.5, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. If you need Forge or Fabric 1.16.5, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.6.3) and get the `api-forge` or `api-fabric` jar. **For 1.16.5 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.6.3/baritone-api-fabric-1.6.3.jar)**. This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/), -the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 through 1.16.4. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). +the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 through 1.16.5. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). Have committed at least once a day from Aug 1, 2018, to Aug 1, 2019. From fb8826caf41f030287564feea0d3c98f570a48c5 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 5 Feb 2021 22:42:03 -0800 Subject: [PATCH 041/155] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1b0751ca1..5de42e790 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,9 @@ [![Minecraft](https://img.shields.io/badge/MC-1.13.2-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.13.2/) [![Minecraft](https://img.shields.io/badge/MC-1.14.4-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.14.4/) [![Minecraft](https://img.shields.io/badge/MC-1.15.2-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.15.2/) -[![Minecraft](https://img.shields.io/badge/MC-1.16.4-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.16.2/) +[![Minecraft](https://img.shields.io/badge/MC-1.16.2-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.16.2/) [![Minecraft](https://img.shields.io/badge/MC-1.16.4-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.16.4/) -[![Minecraft](https://img.shields.io/badge/MC-1.16.4-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.16.5/) +[![Minecraft](https://img.shields.io/badge/MC-1.16.5-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.16.5/) [![Code of Conduct](https://img.shields.io/badge/%E2%9D%A4-code%20of%20conduct-blue.svg?style=flat)](https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md) [![Known Vulnerabilities](https://snyk.io/test/github/cabaletta/baritone/badge.svg?targetFile=build.gradle)](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle) [![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/cabaletta/baritone/issues/) From be132c531ec6931121dad1b445b2a2fd81bfded0 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 5 Feb 2021 22:53:44 -0800 Subject: [PATCH 042/155] Update SETUP.md --- SETUP.md | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/SETUP.md b/SETUP.md index e7ef6c274..7a43faa62 100644 --- a/SETUP.md +++ b/SETUP.md @@ -2,7 +2,7 @@ The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone. -You can also use a custom version json for Minecraft, with the [1.14.4](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1) version or the [1.15.2](https://www.dropbox.com/s/8rx6f0kts9hvd4f/1.15.2-Baritone.zip?dl=1) version +You can also use a custom version json for Minecraft, with the [1.14.4](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1) version or the [1.15.2](https://www.dropbox.com/s/8rx6f0kts9hvd4f/1.15.2-Baritone.zip?dl=1) version or the [1.16.5](https://www.dropbox.com/s/i6f292o2i7o9acp/1.16.5-Baritone.zip?dl=1) version. Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it. @@ -11,9 +11,9 @@ These releases are not always completely up to date with latest features, and ar Link to the releases page: [Releases](https://github.com/cabaletta/baritone/releases) -v1.2.* is for 1.12.2, v1.3.* is for 1.13.2 +v1.2.* is for 1.12.2, v1.3.* is for 1.13.2, v1.4.* is for 1.14.4, v1.5.* is for 1.15.2, v1.6.* is for 1.16.2 or 1.16.4 or 1.16.5 (LOL) -Any official release will be GPG signed by leijurv (44A3EA646EADAC6A) and ZeroMemes (73A788379A197567). Please verify that the hash of the file you download is in `checksums.txt` and that `checksums_signed.asc` is a valid signature by those two public keys of `checksums.txt`. +Any official release will be GPG signed by leijurv (44A3EA646EADAC6A). Please verify that the hash of the file you download is in `checksums.txt` and that `checksums_signed.asc` is a valid signature by that public keys of `checksums.txt`. The build is fully deterministic and reproducible, and you can verify Travis did it properly by running `docker build --no-cache -t cabaletta/baritone .` yourself and comparing the shasum. This works identically on Travis, Mac, and Linux (if you have docker on Windows, I'd be grateful if you could let me know if it works there too). @@ -32,11 +32,6 @@ If another one of your Forge mods has a Baritone integration, you want `baritone - **Forge Standalone**: Same as Standalone, but packaged for Forge. This should be used when Baritone is your only Forge mod, or none of your other Forge mods integrate with Baritone. - **Unoptimized**: Nothing is obfuscated. This shouldn't be used ever in production. -## More Info -To replace out Impact 4.5's Baritone build with a customized one, build Baritone as above then copy & **rename** `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/1.2/baritone-api-1.2.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.5/1.12.2-Impact_4.5.json`, find the line `"name": "cabaletta:baritone-api:1.2"`, remove the comma from the end, and **entirely remove the NEXT line** (starts with `"url"`). **Restart your launcher** then load as normal. - -You can verify whether or not it worked by running `.b version` in chat (only valid in Impact). It should print out the version that you downloaded. Note: The version that comes with 4.5 is `v1.2.3`. - ## Build it yourself - Clone or download Baritone From 711037b61999319fcc0a14deb385fc11d8f797a0 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 6 Feb 2021 13:36:24 -0800 Subject: [PATCH 043/155] rearrange for consistency --- src/main/java/baritone/behavior/InventoryBehavior.java | 5 ++++- src/main/java/baritone/utils/ToolSet.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/behavior/InventoryBehavior.java b/src/main/java/baritone/behavior/InventoryBehavior.java index ce41e3bc3..22ef3a64f 100644 --- a/src/main/java/baritone/behavior/InventoryBehavior.java +++ b/src/main/java/baritone/behavior/InventoryBehavior.java @@ -112,9 +112,12 @@ public final class InventoryBehavior extends Behavior { if (stack.isEmpty()) { continue; } + if (Baritone.settings().itemSaver.value && stack.getItemDamage() >= stack.getMaxDamage() && stack.getMaxDamage() > 1) { + continue; + } if (cla$$.isInstance(stack.getItem())) { double speed = ToolSet.calculateSpeedVsBlock(stack, against.getDefaultState()); // takes into account enchants - if (speed > bestSpeed && !(stack.getItemDamage() >= stack.getMaxDamage() && Baritone.settings().itemSaver.value && stack.getMaxDamage() > 1)) { + if (speed > bestSpeed) { bestSpeed = speed; bestInd = i; } diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index 7e88de8dd..2ffe8c312 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -124,7 +124,7 @@ public class ToolSet { IBlockState blockState = b.getDefaultState(); for (int i = 0; i < 9; i++) { ItemStack itemStack = player.inventory.getStackInSlot(i); - if (itemStack.getItemDamage() >= itemStack.getMaxDamage() && Baritone.settings().itemSaver.value && itemStack.getMaxDamage() > 1) { + if (Baritone.settings().itemSaver.value && itemStack.getItemDamage() >= itemStack.getMaxDamage() && itemStack.getMaxDamage() > 1) { continue; } double speed = calculateSpeedVsBlock(itemStack, blockState); From 1f10199e64ed69b8475069b82da437f5d08d1143 Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Mon, 8 Feb 2021 08:34:31 +0000 Subject: [PATCH 044/155] Change use sword to mine to default to true. Signed-off-by: scorbett123 <50634068+scorbett123@users.noreply.github.com> --- src/api/java/baritone/api/Settings.java | 2 +- src/main/java/baritone/utils/ToolSet.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 5275e2f9b..431f0c404 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -1121,7 +1121,7 @@ public final class Settings { /** * Use sword to mine. */ - public final Setting useSwordToMine = new Setting<>(false); + public final Setting useSwordToMine = new Setting<>(true); /** * Desktop notifications diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index 7888f8c6b..c05dc187e 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -125,14 +125,13 @@ public class ToolSet { IBlockState blockState = b.getDefaultState(); for (int i = 0; i < 9; i++) { ItemStack itemStack = player.inventory.getStackInSlot(i); - if (!Baritone.settings().useSwordToMine.value && itemStack.getItem() instanceof ItemSword){ + if (!Baritone.settings().useSwordToMine.value && itemStack.getItem() instanceof ItemSword) { continue; } if (Baritone.settings().itemSaver.value && itemStack.getItemDamage() >= itemStack.getMaxDamage() && itemStack.getMaxDamage() > 1) { continue; } - double speed = calculateSpeedVsBlock(itemStack, blockState); boolean silkTouch = hasSilkTouch(itemStack); if (speed > highestSpeed) { From ff068d374fb56fd7d9ead0ee9ef530ee1ab26fe7 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Wed, 10 Feb 2021 00:29:45 +0100 Subject: [PATCH 045/155] Don't box doubles --- src/api/java/baritone/api/pathing/goals/GoalNear.java | 11 ++++++----- .../java/baritone/api/pathing/goals/GoalRunAway.java | 10 ++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/api/java/baritone/api/pathing/goals/GoalNear.java b/src/api/java/baritone/api/pathing/goals/GoalNear.java index 7f87e8b92..1897d7743 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalNear.java +++ b/src/api/java/baritone/api/pathing/goals/GoalNear.java @@ -19,11 +19,10 @@ package baritone.api.pathing.goals; import baritone.api.utils.SettingsUtil; import baritone.api.utils.interfaces.IGoalRenderPos; +import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet; +import it.unimi.dsi.fastutil.doubles.DoubleIterator; import net.minecraft.util.math.BlockPos; -import java.util.Collections; -import java.util.HashSet; - public class GoalNear implements Goal, IGoalRenderPos { private final int x; @@ -57,7 +56,7 @@ public class GoalNear implements Goal, IGoalRenderPos { @Override public double heuristic() {// TODO less hacky solution int range = (int) Math.ceil(Math.sqrt(rangeSq)); - HashSet maybeAlwaysInside = new HashSet<>(); + DoubleOpenHashSet maybeAlwaysInside = new DoubleOpenHashSet(); double minOutside = Double.POSITIVE_INFINITY; for (int dx = -range; dx <= range; dx++) { for (int dy = -range; dy <= range; dy++) { @@ -72,7 +71,9 @@ public class GoalNear implements Goal, IGoalRenderPos { } } double maxInside = Double.NEGATIVE_INFINITY; - for (double inside : maybeAlwaysInside) { + DoubleIterator it = maybeAlwaysInside.iterator(); + while(it.hasNext()) { + double inside = it.nextDouble(); if (inside < minOutside) { maxInside = Math.max(maxInside, inside); } diff --git a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java index b9c41aeaf..b85cb23ee 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java +++ b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java @@ -18,11 +18,11 @@ package baritone.api.pathing.goals; import baritone.api.utils.SettingsUtil; +import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet; +import it.unimi.dsi.fastutil.doubles.DoubleIterator; import net.minecraft.util.math.BlockPos; import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; /** * Useful for automated combat (retreating specifically) @@ -99,7 +99,7 @@ public class GoalRunAway implements Goal { maxY = Math.max(minY, p.getY() + distance); maxZ = Math.max(minZ, p.getZ() + distance); } - HashSet maybeAlwaysInside = new HashSet<>(); + DoubleOpenHashSet maybeAlwaysInside = new DoubleOpenHashSet(); double minOutside = Double.POSITIVE_INFINITY; for (int x = minX; x <= maxX; x++) { for (int y = minY; y <= maxY; y++) { @@ -114,7 +114,9 @@ public class GoalRunAway implements Goal { } } double maxInside = Double.NEGATIVE_INFINITY; - for (double inside : maybeAlwaysInside) { + DoubleIterator it = maybeAlwaysInside.iterator(); + while(it.hasNext()) { + double inside = it.nextDouble(); if (inside < minOutside) { maxInside = Math.max(maxInside, inside); } From 5926369a56fb853788774ec45223d87beed42cb5 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Wed, 10 Feb 2021 10:15:14 +0100 Subject: [PATCH 046/155] formatting and comments --- src/api/java/baritone/api/pathing/goals/GoalNear.java | 4 ++-- src/api/java/baritone/api/pathing/goals/GoalRunAway.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/java/baritone/api/pathing/goals/GoalNear.java b/src/api/java/baritone/api/pathing/goals/GoalNear.java index 1897d7743..6a8226fb4 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalNear.java +++ b/src/api/java/baritone/api/pathing/goals/GoalNear.java @@ -56,7 +56,7 @@ public class GoalNear implements Goal, IGoalRenderPos { @Override public double heuristic() {// TODO less hacky solution int range = (int) Math.ceil(Math.sqrt(rangeSq)); - DoubleOpenHashSet maybeAlwaysInside = new DoubleOpenHashSet(); + DoubleOpenHashSet maybeAlwaysInside = new DoubleOpenHashSet(); // see pull request #1978 double minOutside = Double.POSITIVE_INFINITY; for (int dx = -range; dx <= range; dx++) { for (int dy = -range; dy <= range; dy++) { @@ -72,7 +72,7 @@ public class GoalNear implements Goal, IGoalRenderPos { } double maxInside = Double.NEGATIVE_INFINITY; DoubleIterator it = maybeAlwaysInside.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { double inside = it.nextDouble(); if (inside < minOutside) { maxInside = Math.max(maxInside, inside); diff --git a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java index b85cb23ee..a1b2fe1cd 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java +++ b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java @@ -99,7 +99,7 @@ public class GoalRunAway implements Goal { maxY = Math.max(minY, p.getY() + distance); maxZ = Math.max(minZ, p.getZ() + distance); } - DoubleOpenHashSet maybeAlwaysInside = new DoubleOpenHashSet(); + DoubleOpenHashSet maybeAlwaysInside = new DoubleOpenHashSet(); // see pull request #1978 double minOutside = Double.POSITIVE_INFINITY; for (int x = minX; x <= maxX; x++) { for (int y = minY; y <= maxY; y++) { @@ -115,7 +115,7 @@ public class GoalRunAway implements Goal { } double maxInside = Double.NEGATIVE_INFINITY; DoubleIterator it = maybeAlwaysInside.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { double inside = it.nextDouble(); if (inside < minOutside) { maxInside = Math.max(maxInside, inside); From 132cc0e13130c457c619a5e76f61ab0f463a9b93 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Wed, 10 Feb 2021 10:25:17 +0100 Subject: [PATCH 047/155] make range initialization more readable --- .../java/baritone/api/pathing/goals/GoalRunAway.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java index a1b2fe1cd..152b1c273 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java +++ b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java @@ -85,12 +85,12 @@ public class GoalRunAway implements Goal { @Override public double heuristic() {// TODO less hacky solution int distance = (int) Math.ceil(Math.sqrt(distanceSq)); - int minX = from[0].getX() - distance; - int minY = from[0].getY() - distance; - int minZ = from[0].getZ() - distance; - int maxX = from[0].getX() + distance; - int maxY = from[0].getY() + distance; - int maxZ = from[0].getZ() + distance; + int minX = Integer.MAX_VALUE; + int minY = Integer.MAX_VALUE; + int minZ = Integer.MAX_VALUE; + int maxX = Integer.MIN_VALUE; + int maxY = Integer.MIN_VALUE; + int maxZ = Integer.MIN_VALUE; for (BlockPos p : from) { minX = Math.min(minX, p.getX() - distance); minY = Math.min(minY, p.getY() - distance); From 6b9c1f0a22f82dfd3d2fbda60e528a597d53721c Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Wed, 10 Feb 2021 16:00:44 +0000 Subject: [PATCH 048/155] Improve #modified command to include original setting value. Signed-off-by: scorbett123 <50634068+scorbett123@users.noreply.github.com> --- src/main/java/baritone/command/defaults/SetCommand.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/command/defaults/SetCommand.java b/src/main/java/baritone/command/defaults/SetCommand.java index 19f1243b2..49064c5c3 100644 --- a/src/main/java/baritone/command/defaults/SetCommand.java +++ b/src/main/java/baritone/command/defaults/SetCommand.java @@ -40,8 +40,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX; -import static baritone.api.utils.SettingsUtil.settingTypeToString; -import static baritone.api.utils.SettingsUtil.settingValueToString; +import static baritone.api.utils.SettingsUtil.*; public class SetCommand extends Command { @@ -88,6 +87,7 @@ public class SetCommand extends Command { hoverComponent.appendText(setting.getName()); hoverComponent.appendText(String.format("\nType: %s", settingTypeToString(setting))); hoverComponent.appendText(String.format("\n\nValue:\n%s", settingValueToString(setting))); + hoverComponent.appendText(String.format("\n\nDefault Value:\n%s", settingDefaultToString(setting))); String commandSuggestion = Baritone.settings().prefix.value + String.format("set %s ", setting.getName()); ITextComponent component = new TextComponentString(setting.getName()); component.getStyle().setColor(TextFormatting.GRAY); From 34606415d75eb78e8e191c5ed93eabf2d66e34bc Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sun, 24 Jan 2021 23:44:43 +0100 Subject: [PATCH 049/155] Don't mark skipped blocks as invalid just because they are far away --- src/main/java/baritone/process/BuilderProcess.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index c5be76f03..f6a69a0ee 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -576,7 +576,8 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil continue; } // this is not in render distance - if (!observedCompleted.contains(BetterBlockPos.longHash(blockX, blockY, blockZ))) { + if (!observedCompleted.contains(BetterBlockPos.longHash(blockX, blockY, blockZ)) + && !Baritone.settings().buildSkipBlocks.value.contains(schematic.desiredState(x, y, z, current, this.approxPlaceable).getBlock())) { // and we've never seen this position be correct // therefore mark as incorrect incorrectPositions.add(new BetterBlockPos(blockX, blockY, blockZ)); From 113d26937d2a8dc3b2a872266ee71b75c2c10146 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Thu, 11 Feb 2021 01:08:33 +0100 Subject: [PATCH 050/155] remove unused imports --- src/api/java/baritone/api/schematic/FillSchematic.java | 1 - src/api/java/baritone/api/schematic/SubstituteSchematic.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/api/java/baritone/api/schematic/FillSchematic.java b/src/api/java/baritone/api/schematic/FillSchematic.java index edb1d6113..f2fb203cd 100644 --- a/src/api/java/baritone/api/schematic/FillSchematic.java +++ b/src/api/java/baritone/api/schematic/FillSchematic.java @@ -19,7 +19,6 @@ package baritone.api.schematic; import baritone.api.utils.BlockOptionalMeta; import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; import java.util.List; diff --git a/src/api/java/baritone/api/schematic/SubstituteSchematic.java b/src/api/java/baritone/api/schematic/SubstituteSchematic.java index fbc075805..c1cb5a18a 100644 --- a/src/api/java/baritone/api/schematic/SubstituteSchematic.java +++ b/src/api/java/baritone/api/schematic/SubstituteSchematic.java @@ -17,7 +17,6 @@ package baritone.api.schematic; -import baritone.api.utils.BlockOptionalMetaLookup; import net.minecraft.block.Block; import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.IBlockState; From 84e2efd42c5be1307de11f3c444b8bcfa4f6332f Mon Sep 17 00:00:00 2001 From: Biscuit <20166775+biscuut@users.noreply.github.com> Date: Mon, 15 Feb 2021 14:21:03 -0500 Subject: [PATCH 051/155] Fixed incorrect block pos world coordinates Fix block pos being incorrect when converting chunk coordinates to world coordinates because of order of operations. --- src/main/java/baritone/cache/ChunkPacker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index bfeeabd77..ebd2fdaf8 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -123,7 +123,7 @@ public final class ChunkPacker { return PathingBlockType.AVOID; } if (x == 0 || x == 15 || z == 0 || z == 15) { - if (BlockLiquid.getSlopeAngle(chunk.getWorld(), new BlockPos(x + chunk.x << 4, y, z + chunk.z << 4), state.getMaterial(), state) == -1000.0F) { + if (BlockLiquid.getSlopeAngle(chunk.getWorld(), new BlockPos(x + (chunk.x << 4), y, z + (chunk.z << 4)), state.getMaterial(), state) == -1000.0F) { return PathingBlockType.WATER; } return PathingBlockType.AVOID; From 13422ef7ce91e6ca86f6ca2bef52dc5b6e0d85b4 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Wed, 17 Feb 2021 01:19:16 +0100 Subject: [PATCH 052/155] lag > crash --- src/main/java/baritone/process/BuilderProcess.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 012b290e2..15d88bdd5 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -343,6 +343,13 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil @Override public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) { + return onTick(calcFailed, isSafeToCancel, 0); + } + + public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel, int recursions) { + if (recursions > 1000) { // onTick calls itself, don't crash + return new PathingCommand(null, PathingCommandType.SET_GOAL_AND_PATH); + } approxPlaceable = approxPlaceable(36); if (baritone.getInputOverrideHandler().isInputForcedDown(Input.CLICK_LEFT)) { ticks = 5; @@ -401,7 +408,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil if (Baritone.settings().buildInLayers.value && layer < realSchematic.heightY()) { logDirect("Starting layer " + layer); layer++; - return onTick(calcFailed, isSafeToCancel); + return onTick(calcFailed, isSafeToCancel, recursions + 1); } Vec3i repeat = Baritone.settings().buildRepeat.value; int max = Baritone.settings().buildRepeatCount.value; @@ -418,7 +425,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil layer = 0; origin = new BlockPos(origin).add(repeat); logDirect("Repeating build in vector " + repeat + ", new origin is " + origin); - return onTick(calcFailed, isSafeToCancel); + return onTick(calcFailed, isSafeToCancel, recursions + 1); } if (Baritone.settings().distanceTrim.value) { trim(); @@ -488,7 +495,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil if (Baritone.settings().skipFailedLayers.value && Baritone.settings().buildInLayers.value && layer < realSchematic.heightY()) { logDirect("Skipping layer that I cannot construct! Layer #" + layer); layer++; - return onTick(calcFailed, isSafeToCancel); + return onTick(calcFailed, isSafeToCancel, recursions + 1); } logDirect("Unable to do it. Pausing. resume to resume, cancel to cancel"); paused = true; From c880f71dc8d4299080b9e3636c82ad5d04887825 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Wed, 17 Feb 2021 01:59:23 +0100 Subject: [PATCH 053/155] Clear caches of schematics when moving them --- src/api/java/baritone/api/Settings.java | 7 +++++++ .../baritone/api/schematic/CompositeSchematic.java | 9 +++++++++ src/api/java/baritone/api/schematic/ISchematic.java | 5 +++++ .../baritone/api/schematic/ReplaceSchematic.java | 12 ++++++++++++ src/main/java/baritone/process/BuilderProcess.java | 10 ++++++++++ 5 files changed, 43 insertions(+) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 9773fc0fe..fe1f19aea 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -834,6 +834,13 @@ public final class Settings { */ public final Setting buildRepeatCount = new Setting<>(-1); + /** + * Don't notify schematics that they are moved. + * e.g. replacing will replace the same spots for every repetition + * Mainly for backward compatibility. + */ + public final Setting buildRepeatSneaky = new Setting<>(true); + /** * Allow standing above a block while mining it, in BuilderProcess *

diff --git a/src/api/java/baritone/api/schematic/CompositeSchematic.java b/src/api/java/baritone/api/schematic/CompositeSchematic.java index 2f119de1b..17d31689f 100644 --- a/src/api/java/baritone/api/schematic/CompositeSchematic.java +++ b/src/api/java/baritone/api/schematic/CompositeSchematic.java @@ -71,4 +71,13 @@ public class CompositeSchematic extends AbstractSchematic { } return entry.schematic.desiredState(x - entry.x, y - entry.y, z - entry.z, current, approxPlaceable); } + + @Override + public void reset(){ + for (CompositeSchematicEntry entry : schematicArr){ + if (!(entry.schematic instanceof IStaticSchematic)) { + entry.schematic.reset(); + } + } + } } diff --git a/src/api/java/baritone/api/schematic/ISchematic.java b/src/api/java/baritone/api/schematic/ISchematic.java index 88cfc8999..82d712845 100644 --- a/src/api/java/baritone/api/schematic/ISchematic.java +++ b/src/api/java/baritone/api/schematic/ISchematic.java @@ -73,6 +73,11 @@ public interface ISchematic { */ IBlockState desiredState(int x, int y, int z, IBlockState current, List approxPlaceable); + /** + * Resets possible caches to avoid wrong behavior when moving the schematic around + */ + default void reset(){} + /** * @return The width (X axis length) of this schematic */ diff --git a/src/api/java/baritone/api/schematic/ReplaceSchematic.java b/src/api/java/baritone/api/schematic/ReplaceSchematic.java index f064435e0..b9979b24a 100644 --- a/src/api/java/baritone/api/schematic/ReplaceSchematic.java +++ b/src/api/java/baritone/api/schematic/ReplaceSchematic.java @@ -31,6 +31,18 @@ public class ReplaceSchematic extends MaskSchematic { this.cache = new Boolean[widthX()][heightY()][lengthZ()]; } + @Override + public void reset(){ + // it's final, can't use this.cache = new Boolean[widthX()][heightY()][lengthZ()] + for (int x = 0; x < cache.length; x++){ + for (int y = 0; y < cache[0].length; y++){ + for (int z = 0; z < cache[0][0].length; z++){ + cache[x][y][z] = null; + } + } + } + } + @Override protected boolean partOfMask(int x, int y, int z, IBlockState currentState) { if (cache[x][y][z] == null) { diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 012b290e2..18241fbad 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -380,6 +380,13 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil return ISchematic.super.inSchematic(x, y, z, currentState) && y >= minYInclusive && y <= maxYInclusive && realSchematic.inSchematic(x, y, z, currentState); } + @Override + public void reset(){ + if (!(realSchematic instanceof IStaticSchematic)){ + realSchematic.reset(); + } + } + @Override public int widthX() { return realSchematic.widthX(); @@ -417,6 +424,9 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil // build repeat time layer = 0; origin = new BlockPos(origin).add(repeat); + if (!(schematic instanceof IStaticSchematic) && !Baritone.settings().buildRepeatSneaky.value){ + schematic.reset(); + } logDirect("Repeating build in vector " + repeat + ", new origin is " + origin); return onTick(calcFailed, isSafeToCancel); } From 5a926bf169c5d71ce05511da4beed6ba8866804a Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Fri, 19 Feb 2021 23:52:18 +0100 Subject: [PATCH 054/155] formatting --- .../java/baritone/api/schematic/CompositeSchematic.java | 4 ++-- src/api/java/baritone/api/schematic/ISchematic.java | 6 +++--- src/api/java/baritone/api/schematic/ReplaceSchematic.java | 8 ++++---- src/main/java/baritone/process/BuilderProcess.java | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/api/java/baritone/api/schematic/CompositeSchematic.java b/src/api/java/baritone/api/schematic/CompositeSchematic.java index 17d31689f..fab049b51 100644 --- a/src/api/java/baritone/api/schematic/CompositeSchematic.java +++ b/src/api/java/baritone/api/schematic/CompositeSchematic.java @@ -73,8 +73,8 @@ public class CompositeSchematic extends AbstractSchematic { } @Override - public void reset(){ - for (CompositeSchematicEntry entry : schematicArr){ + public void reset() { + for (CompositeSchematicEntry entry : schematicArr) { if (!(entry.schematic instanceof IStaticSchematic)) { entry.schematic.reset(); } diff --git a/src/api/java/baritone/api/schematic/ISchematic.java b/src/api/java/baritone/api/schematic/ISchematic.java index 82d712845..deb811828 100644 --- a/src/api/java/baritone/api/schematic/ISchematic.java +++ b/src/api/java/baritone/api/schematic/ISchematic.java @@ -74,9 +74,9 @@ public interface ISchematic { IBlockState desiredState(int x, int y, int z, IBlockState current, List approxPlaceable); /** - * Resets possible caches to avoid wrong behavior when moving the schematic around - */ - default void reset(){} + * Resets possible caches to avoid wrong behavior when moving the schematic around + */ + default void reset() {} /** * @return The width (X axis length) of this schematic diff --git a/src/api/java/baritone/api/schematic/ReplaceSchematic.java b/src/api/java/baritone/api/schematic/ReplaceSchematic.java index b9979b24a..f8cd6656b 100644 --- a/src/api/java/baritone/api/schematic/ReplaceSchematic.java +++ b/src/api/java/baritone/api/schematic/ReplaceSchematic.java @@ -32,11 +32,11 @@ public class ReplaceSchematic extends MaskSchematic { } @Override - public void reset(){ + public void reset() { // it's final, can't use this.cache = new Boolean[widthX()][heightY()][lengthZ()] - for (int x = 0; x < cache.length; x++){ - for (int y = 0; y < cache[0].length; y++){ - for (int z = 0; z < cache[0][0].length; z++){ + for (int x = 0; x < cache.length; x++) { + for (int y = 0; y < cache[0].length; y++) { + for (int z = 0; z < cache[0][0].length; z++) { cache[x][y][z] = null; } } diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 18241fbad..c0519b557 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -381,8 +381,8 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil } @Override - public void reset(){ - if (!(realSchematic instanceof IStaticSchematic)){ + public void reset() { + if (!(realSchematic instanceof IStaticSchematic)) { realSchematic.reset(); } } @@ -424,7 +424,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil // build repeat time layer = 0; origin = new BlockPos(origin).add(repeat); - if (!(schematic instanceof IStaticSchematic) && !Baritone.settings().buildRepeatSneaky.value){ + if (!(schematic instanceof IStaticSchematic) && !Baritone.settings().buildRepeatSneaky.value) { schematic.reset(); } logDirect("Repeating build in vector " + repeat + ", new origin is " + origin); From 971b75860f39693a04086bf3a542d170d78555e3 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Fri, 19 Feb 2021 23:57:33 +0100 Subject: [PATCH 055/155] Call reset() on static schematics as well --- src/api/java/baritone/api/schematic/CompositeSchematic.java | 4 +--- src/main/java/baritone/process/BuilderProcess.java | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/api/java/baritone/api/schematic/CompositeSchematic.java b/src/api/java/baritone/api/schematic/CompositeSchematic.java index fab049b51..234f1d4fe 100644 --- a/src/api/java/baritone/api/schematic/CompositeSchematic.java +++ b/src/api/java/baritone/api/schematic/CompositeSchematic.java @@ -75,9 +75,7 @@ public class CompositeSchematic extends AbstractSchematic { @Override public void reset() { for (CompositeSchematicEntry entry : schematicArr) { - if (!(entry.schematic instanceof IStaticSchematic)) { - entry.schematic.reset(); - } + entry.schematic.reset(); } } } diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index c0519b557..336eb8d2b 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -382,9 +382,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil @Override public void reset() { - if (!(realSchematic instanceof IStaticSchematic)) { - realSchematic.reset(); - } + realSchematic.reset(); } @Override @@ -424,7 +422,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil // build repeat time layer = 0; origin = new BlockPos(origin).add(repeat); - if (!(schematic instanceof IStaticSchematic) && !Baritone.settings().buildRepeatSneaky.value) { + if (!Baritone.settings().buildRepeatSneaky.value) { schematic.reset(); } logDirect("Repeating build in vector " + repeat + ", new origin is " + origin); From 363519db029b8fcc63103eb73a5d68dc6b0d09f9 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Tue, 9 Mar 2021 11:53:43 +0100 Subject: [PATCH 056/155] treat all airs as air --- .../java/baritone/api/schematic/SubstituteSchematic.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/api/java/baritone/api/schematic/SubstituteSchematic.java b/src/api/java/baritone/api/schematic/SubstituteSchematic.java index c1cb5a18a..439ba2445 100644 --- a/src/api/java/baritone/api/schematic/SubstituteSchematic.java +++ b/src/api/java/baritone/api/schematic/SubstituteSchematic.java @@ -18,6 +18,7 @@ package baritone.api.schematic; import net.minecraft.block.Block; +import net.minecraft.block.BlockAir; import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; @@ -49,12 +50,12 @@ public class SubstituteSchematic extends AbstractSchematic { return desired; } List substitutes = substitutions.get(desiredBlock); - if (substitutes.contains(current.getBlock()) && !current.getBlock().equals(Blocks.AIR)) {// don't preserve air, it's almost always there and almost never wanted + if (substitutes.contains(current.getBlock()) && !(current.getBlock() instanceof BlockAir)) {// don't preserve air, it's almost always there and almost never wanted return withBlock(desired, current.getBlock()); } for (Block substitute : substitutes) { - if (substitute.equals(Blocks.AIR)) { - return Blocks.AIR.getDefaultState(); // can always "place" air + if (substitute instanceof BlockAir) { + return current.getBlock() instanceof BlockAir ? current : Blocks.AIR.getDefaultState(); // can always "place" air } for (IBlockState placeable : approxPlaceable) { if (substitute.equals(placeable.getBlock())) { From 61e0525ee86475a67b461e6174e99f94116d855a Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Tue, 9 Mar 2021 12:26:47 +0100 Subject: [PATCH 057/155] Don't copy block state properties every time --- .../java/baritone/api/schematic/SubstituteSchematic.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/api/java/baritone/api/schematic/SubstituteSchematic.java b/src/api/java/baritone/api/schematic/SubstituteSchematic.java index 439ba2445..72787c243 100644 --- a/src/api/java/baritone/api/schematic/SubstituteSchematic.java +++ b/src/api/java/baritone/api/schematic/SubstituteSchematic.java @@ -23,6 +23,7 @@ import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -30,6 +31,7 @@ public class SubstituteSchematic extends AbstractSchematic { private final ISchematic schematic; private final Map> substitutions; + private final Map> blockStateCache = new HashMap<>(); public SubstituteSchematic(ISchematic schematic, Map> substitutions) { super(schematic.widthX(), schematic.heightY(), schematic.lengthZ()); @@ -67,6 +69,9 @@ public class SubstituteSchematic extends AbstractSchematic { } private IBlockState withBlock(IBlockState state, Block block) { + if (blockStateCache.containsKey(state) && blockStateCache.get(state).containsKey(block)) { + return blockStateCache.get(state).get(block); + } Collection> properties = state.getPropertyKeys(); IBlockState newState = block.getDefaultState(); for (IProperty property : properties) { @@ -75,6 +80,7 @@ public class SubstituteSchematic extends AbstractSchematic { } catch (IllegalArgumentException e) { //property does not exist for target block } } + blockStateCache.computeIfAbsent(state, s -> new HashMap()).put(block, newState); return newState; } private > IBlockState copySingleProp(IBlockState fromState, IBlockState toState, IProperty prop) { From 67d9ae881f066891128e84295a219ef7704bfadc Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Tue, 9 Mar 2021 12:31:02 +0100 Subject: [PATCH 058/155] don't allocate tons of empty lists --- src/main/java/baritone/process/BuilderProcess.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index f6a69a0ee..08df9bad9 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -802,7 +802,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil if (Baritone.settings().buildSkipBlocks.value.contains(desired.getBlock()) && !itemVerify) { return true; } - if (Baritone.settings().buildValidSubstitutes.value.getOrDefault(desired.getBlock(), Arrays.asList()).contains(current.getBlock()) && !itemVerify) { + if (Baritone.settings().buildValidSubstitutes.value.getOrDefault(desired.getBlock(), Collections.emptyList()).contains(current.getBlock()) && !itemVerify) { return true; } return current.equals(desired); From ccc55562cdcd5dfe5c79f50adc98e8835d4a94f3 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 21 Mar 2021 13:52:27 -0700 Subject: [PATCH 059/155] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5de42e790..8370cc1f6 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,9 @@ [![forthebadge](https://forthebadge.com/images/badges/built-with-swag.svg)](http://forthebadge.com/) [![forthebadge](https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg)](http://forthebadge.com/) -A Minecraft pathfinder bot. +A Minecraft pathfinder bot. + +[**Baritone Discord Server**](http://discord.gg/RhQnrYXH96) Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. There's a [showcase video](https://youtu.be/CZkLXWo4Fg4) made by @Adovin#0730 on Baritone which I recommend. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a (very old!) video I made showing off what it can do. [Tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa) From 6d9600d1324b1c1468d74db2c93e5f481b3e2437 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 21 Mar 2021 13:59:00 -0700 Subject: [PATCH 060/155] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8370cc1f6..234690877 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ A Minecraft pathfinder bot. -[**Baritone Discord Server**](http://discord.gg/RhQnrYXH96) +[**Baritone Discord Server**](http://discord.gg/s6fRBAUpmr) Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. There's a [showcase video](https://youtu.be/CZkLXWo4Fg4) made by @Adovin#0730 on Baritone which I recommend. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a (very old!) video I made showing off what it can do. [Tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa) From 14149aa6b196781ec38d098cd6fc8862fef57f54 Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Tue, 23 Mar 2021 19:35:11 +0000 Subject: [PATCH 061/155] fix typo --- src/api/java/baritone/api/Settings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 95682d32c..ad0d487fb 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -664,7 +664,7 @@ public final class Settings { /** * When GetToBlockProcess or MineProcess fails to calculate a path, instead of just giving up, mark the closest instance - * of that block as "unreachable" and go towards the next closest. GetToBlock expands this seaarch to the whole "vein"; MineProcess does not. + * of that block as "unreachable" and go towards the next closest. GetToBlock expands this search to the whole "vein"; MineProcess does not. * This is because MineProcess finds individual impossible blocks (like one block in a vein that has gravel on top then lava, so it can't break) * Whereas GetToBlock should blacklist the whole "vein" if it can't get to any of them. */ From c07a636db2f58ed2a8b9ce1f338fca592ce7c8dd Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 23 Mar 2021 22:41:59 -1000 Subject: [PATCH 062/155] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 234690877..44ad74e9e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,12 @@ # Baritone + +

+ [![HitCount](http://hits.dwyl.com/cabaletta/baritone.svg)](http://hits.dwyl.com/cabaletta/baritone/) [![GitHub All Releases](https://img.shields.io/github/downloads/cabaletta/baritone/total.svg)](https://github.com/cabaletta/baritone/releases/) +

+ [![Build Status](https://travis-ci.com/cabaletta/baritone.svg?branch=master)](https://travis-ci.com/cabaletta/baritone/) [![Release](https://img.shields.io/github/release/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/releases/) [![License](https://img.shields.io/badge/license-LGPL--3.0%20with%20anime%20exception-green.svg)](LICENSE) From dcef6b556c8fdcfaf10faf4aef27a03a9096e944 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 23 Mar 2021 22:42:39 -1000 Subject: [PATCH 063/155] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 44ad74e9e..cb53d790c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Baritone -

+

[![HitCount](http://hits.dwyl.com/cabaletta/baritone.svg)](http://hits.dwyl.com/cabaletta/baritone/) [![GitHub All Releases](https://img.shields.io/github/downloads/cabaletta/baritone/total.svg)](https://github.com/cabaletta/baritone/releases/) From 5cbe0a8230320634a912f3f2f5f23a14edc5126e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 23 Mar 2021 22:44:03 -1000 Subject: [PATCH 064/155] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cb53d790c..72cefd502 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Baritone -

+

[![HitCount](http://hits.dwyl.com/cabaletta/baritone.svg)](http://hits.dwyl.com/cabaletta/baritone/) [![GitHub All Releases](https://img.shields.io/github/downloads/cabaletta/baritone/total.svg)](https://github.com/cabaletta/baritone/releases/) From ef6435a02a67f879989ffaa8cd9f778042553f45 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 23 Mar 2021 22:44:20 -1000 Subject: [PATCH 065/155] whatever i don't care --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index 72cefd502..234690877 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,7 @@ # Baritone - -

- [![HitCount](http://hits.dwyl.com/cabaletta/baritone.svg)](http://hits.dwyl.com/cabaletta/baritone/) [![GitHub All Releases](https://img.shields.io/github/downloads/cabaletta/baritone/total.svg)](https://github.com/cabaletta/baritone/releases/) -

- [![Build Status](https://travis-ci.com/cabaletta/baritone.svg?branch=master)](https://travis-ci.com/cabaletta/baritone/) [![Release](https://img.shields.io/github/release/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/releases/) [![License](https://img.shields.io/badge/license-LGPL--3.0%20with%20anime%20exception-green.svg)](LICENSE) From 8ebb8a04fa7c65b35fbc253ed8c8ed12740f9d8e Mon Sep 17 00:00:00 2001 From: flurr <1414bot1@gmail.com> Date: Thu, 25 Mar 2021 11:51:18 -0700 Subject: [PATCH 066/155] Center badges and other stuff -center the badges -re-arrange them to be more organized -update the Aristois/Impact badges to the correct versions and fix broken link --- README.md | 79 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 234690877..c40cbebf0 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,51 @@ # Baritone -[![HitCount](http://hits.dwyl.com/cabaletta/baritone.svg)](http://hits.dwyl.com/cabaletta/baritone/) -[![GitHub All Releases](https://img.shields.io/github/downloads/cabaletta/baritone/total.svg)](https://github.com/cabaletta/baritone/releases/) +

+ HitCount + GitHub All Releases +

-[![Build Status](https://travis-ci.com/cabaletta/baritone.svg?branch=master)](https://travis-ci.com/cabaletta/baritone/) -[![Release](https://img.shields.io/github/release/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/releases/) -[![License](https://img.shields.io/badge/license-LGPL--3.0%20with%20anime%20exception-green.svg)](LICENSE) -[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a73d037823b64a5faf597a18d71e3400)](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade) -[![Minecraft](https://img.shields.io/badge/MC-1.12.2-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/master/) -[![Minecraft](https://img.shields.io/badge/MC-1.13.2-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.13.2/) -[![Minecraft](https://img.shields.io/badge/MC-1.14.4-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.14.4/) -[![Minecraft](https://img.shields.io/badge/MC-1.15.2-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.15.2/) -[![Minecraft](https://img.shields.io/badge/MC-1.16.2-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.16.2/) -[![Minecraft](https://img.shields.io/badge/MC-1.16.4-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.16.4/) -[![Minecraft](https://img.shields.io/badge/MC-1.16.5-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.16.5/) -[![Code of Conduct](https://img.shields.io/badge/%E2%9D%A4-code%20of%20conduct-blue.svg?style=flat)](https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md) -[![Known Vulnerabilities](https://snyk.io/test/github/cabaletta/baritone/badge.svg?targetFile=build.gradle)](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle) -[![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/cabaletta/baritone/issues/) -[![Issues](https://img.shields.io/github/issues/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/issues/) -[![GitHub issues-closed](https://img.shields.io/github/issues-closed/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/issues?q=is%3Aissue+is%3Aclosed) -[![Pull Requests](https://img.shields.io/github/issues-pr/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/pulls/) -![Code size](https://img.shields.io/github/languages/code-size/cabaletta/baritone.svg) -![GitHub repo size](https://img.shields.io/github/repo-size/cabaletta/baritone.svg) -![Lines of Code](https://tokei.rs/b1/github/cabaletta/baritone?category=code) -[![GitHub contributors](https://img.shields.io/github/contributors/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/graphs/contributors/) -[![GitHub commits](https://img.shields.io/github/commits-since/cabaletta/baritone/v1.0.0.svg)](https://github.com/cabaletta/baritone/commit/) -[![Impact integration](https://img.shields.io/badge/Impact%20integration-v1.2.14%20/%20v1.3.8%20/%20v1.4.6%20/%20v1.5.3-brightgreen.svg)](https://impactclient.net/) -[![KAMI Blue integration](https://img.shields.io/badge/KAMI%20Blue%20integration-v1.2.14--master-green)](https://github.com/kami-blue/client) -[![ForgeHax integration](https://img.shields.io/badge/ForgeHax%20%22integration%22-scuffed-yellow.svg)](https://github.com/fr1kin/ForgeHax/) -[![Aristois add-on integration](https://img.shields.io/badge/Aristois%20add--on%20integration-v1.3.4%20/%20v1.4.1-green.svg)](https://gitlab.com/emc-mods-indrit/baritone_api) -[![rootNET integration](https://img.shields.io/badge/rootNET%20integration-v1.2.14-green.svg)](https://rootnet.dev/) -[![Future integration](https://img.shields.io/badge/Future%20integration-v1.2.12%20%2F%20v1.3.6%20%2F%20v1.4.4-red)](https://futureclient.net/) -[![RusherHack integration](https://img.shields.io/badge/RusherHack%20integration-v1.2.14-green)](https://rusherhack.org/) -[![forthebadge](https://forthebadge.com/images/badges/built-with-swag.svg)](http://forthebadge.com/) -[![forthebadge](https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg)](http://forthebadge.com/) +

+ Minecraft + Minecraft + Minecraft + Minecraft + Minecraft + Minecraft + Minecraft +

+ +

+ Build Status + Release + License + Codacy Badge + Code of Conduct + Known Vulnerabilities + Contributions welcome + Issues + GitHub issues-closed + Pull Requests + GitHub contributors + GitHub commits + Code size + GitHub repo size + Lines of Code +

+ +

+ Impact integration + KAMI Blue integration + ForgeHax integration + Aristois add-on integration + rootNET integration + Future integration + RusherHack integration +

+ +

+ forthebadge + forthebadge +

A Minecraft pathfinder bot. From c1794dd0ca5e642e050f309f70407cb6206c53e0 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 25 Mar 2021 10:41:16 -1000 Subject: [PATCH 067/155] reduce useless links --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c40cbebf0..44c032295 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,11 @@

- Minecraft - Minecraft - Minecraft - Minecraft - Minecraft - Minecraft - Minecraft + Minecraft + Minecraft + Minecraft + Minecraft + Minecraft

From 9d1b97931830f0aa6090b148ea579d26883a823c Mon Sep 17 00:00:00 2001 From: wagyourtail Date: Sun, 28 Mar 2021 21:32:48 -0700 Subject: [PATCH 068/155] fix replaymod crash --- src/main/java/baritone/cache/WorldProvider.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/cache/WorldProvider.java b/src/main/java/baritone/cache/WorldProvider.java index c277a0d06..a7756137c 100644 --- a/src/main/java/baritone/cache/WorldProvider.java +++ b/src/main/java/baritone/cache/WorldProvider.java @@ -77,7 +77,14 @@ public class WorldProvider implements IWorldProvider, Helper { directory = new File(directory, "baritone"); readme = directory; } else { // Otherwise, the server must be remote... - String folderName = mc.getCurrentServerData().serverIP; + String folderName; + if (mc.getCurrentServerData() != null) { + folderName = mc.getCurrentServerData().serverIP; + } else { + //replaymod causes null currentServerData and false singleplayer. + currentWorld = null; + return; + } if (SystemUtils.IS_OS_WINDOWS) { folderName = folderName.replace(":", "_"); } From 43d5458a25f5f570e556cd1668b7f0d84c58d697 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 3 Apr 2021 16:41:45 -0700 Subject: [PATCH 069/155] fix weird behavior where allowBreak false broke #goto --- .../baritone/process/GetToBlockProcess.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/process/GetToBlockProcess.java b/src/main/java/baritone/process/GetToBlockProcess.java index 78df95883..f6764d4c8 100644 --- a/src/main/java/baritone/process/GetToBlockProcess.java +++ b/src/main/java/baritone/process/GetToBlockProcess.java @@ -30,6 +30,7 @@ import baritone.api.utils.input.Input; import baritone.pathing.movement.CalculationContext; import baritone.utils.BaritoneProcessHelper; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.inventory.ContainerPlayer; import net.minecraft.util.math.BlockPos; @@ -57,7 +58,7 @@ public final class GetToBlockProcess extends BaritoneProcessHelper implements IG start = ctx.playerFeet(); blacklist = new ArrayList<>(); arrivalTickCount = 0; - rescan(new ArrayList<>(), new CalculationContext(baritone)); + rescan(new ArrayList<>(), new GetToBlockCalculationContext(false)); } @Override @@ -68,7 +69,7 @@ public final class GetToBlockProcess extends BaritoneProcessHelper implements IG @Override public synchronized PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) { if (knownLocations == null) { - rescan(new ArrayList<>(), new CalculationContext(baritone)); + rescan(new ArrayList<>(), new GetToBlockCalculationContext(false)); } if (knownLocations.isEmpty()) { if (Baritone.settings().exploreForBlocks.value && !calcFailed) { @@ -77,6 +78,7 @@ public final class GetToBlockProcess extends BaritoneProcessHelper implements IG public boolean isInGoal(int x, int y, int z) { return false; } + @Override public double heuristic() { return Double.NEGATIVE_INFINITY; @@ -106,7 +108,7 @@ public final class GetToBlockProcess extends BaritoneProcessHelper implements IG int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.value; if (mineGoalUpdateInterval != 0 && tickCount++ % mineGoalUpdateInterval == 0) { // big brain List current = new ArrayList<>(knownLocations); - CalculationContext context = new CalculationContext(baritone, true); + CalculationContext context = new GetToBlockCalculationContext(true); Baritone.getExecutor().execute(() -> rescan(current, context)); } if (goal.isInGoal(ctx.playerFeet()) && goal.isInGoal(baritone.getPathingBehavior().pathStart()) && isSafeToCancel) { @@ -151,6 +153,20 @@ public final class GetToBlockProcess extends BaritoneProcessHelper implements IG return !newBlacklist.isEmpty(); } + // this is to signal to MineProcess that we don't care about the allowBreak setting + // it is NOT to be used to actually calculate a path + public class GetToBlockCalculationContext extends CalculationContext { + + public GetToBlockCalculationContext(boolean forUseOnAnotherThread) { + super(GetToBlockProcess.super.baritone, forUseOnAnotherThread); + } + + @Override + public double breakCostMultiplierAt(int x, int y, int z, IBlockState current) { + return 1; + } + } + // safer than direct double comparison from distanceSq private boolean areAdjacent(BlockPos posA, BlockPos posB) { int diffX = Math.abs(posA.getX() - posB.getX()); From 861bb7a00a25b1cd08b834d9b52a708689589d35 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 3 Apr 2021 16:50:01 -0700 Subject: [PATCH 070/155] v1.2.15 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0c67c3321..b922fc900 100755 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ */ group 'baritone' -version '1.2.14' +version '1.2.15' buildscript { repositories { From 2cb6402189c2f0bff79dec944d05444b0969e013 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 3 Apr 2021 16:56:26 -0700 Subject: [PATCH 071/155] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 44c032295..1cf67f86d 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ A Minecraft pathfinder bot. Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. There's a [showcase video](https://youtu.be/CZkLXWo4Fg4) made by @Adovin#0730 on Baritone which I recommend. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a (very old!) video I made showing off what it can do. [Tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa) -The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the v1.2.* `api-forge` jar from [releases](https://github.com/cabaletta/baritone/releases). **For 1.12.2 Forge, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.2.14/baritone-api-forge-1.2.14.jar)**. Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it. +The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the v1.2.* `api-forge` jar from [releases](https://github.com/cabaletta/baritone/releases). **For 1.12.2 Forge, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.2.15/baritone-api-forge-1.2.15.jar)**. Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it. For 1.15.2, [click here](https://www.youtube.com/watch?v=j1qKtCZFURM) and see description. If you need Forge 1.15.2, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.5.3), follow the instructions, and get the `api-forge` jar. From bdb98b487f87a773ae559cf68558c51e73ec448c Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sun, 4 Apr 2021 03:17:35 +0200 Subject: [PATCH 072/155] fix typo --- src/main/java/baritone/command/defaults/SchematicaCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/command/defaults/SchematicaCommand.java b/src/main/java/baritone/command/defaults/SchematicaCommand.java index ae5cac47f..842a30131 100644 --- a/src/main/java/baritone/command/defaults/SchematicaCommand.java +++ b/src/main/java/baritone/command/defaults/SchematicaCommand.java @@ -51,7 +51,7 @@ public class SchematicaCommand extends Command { @Override public List getLongDesc() { return Arrays.asList( - "Builds the schematica currently open in Schematica.", + "Builds the schematic currently open in Schematica.", "", "Usage:", "> schematica" From f348a200350ed9fcfe773dacd23e35b4eebae862 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sun, 4 Apr 2021 03:34:10 +0200 Subject: [PATCH 073/155] invert disableAutoTool to autoTool --- src/api/java/baritone/api/Settings.java | 2 +- src/main/java/baritone/pathing/movement/MovementHelper.java | 2 +- src/main/java/baritone/utils/ToolSet.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index ad0d487fb..a3a767a85 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -72,7 +72,7 @@ public final class Settings { /** * If this setting is on, no auto tool will occur at all, not at calculation time nor execution time */ - public final Setting disableAutoTool = new Setting<>(false); + public final Setting autoTool = new Setting<>(true); /** * It doesn't actually take twenty ticks to place a block, this cost is so high diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 6438ae2f4..69e846a2c 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -432,7 +432,7 @@ public interface MovementHelper extends ActionCosts, Helper { * @param ts previously calculated ToolSet */ static void switchToBestToolFor(IPlayerContext ctx, IBlockState b, ToolSet ts, boolean preferSilkTouch) { - if (!Baritone.settings().disableAutoTool.value && !Baritone.settings().assumeExternalAutoTool.value) { + if (Baritone.settings().autoTool.value && !Baritone.settings().assumeExternalAutoTool.value) { ctx.player().inventory.currentItem = ts.getBestSlot(b.getBlock(), preferSilkTouch); } } diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index c05dc187e..0e153e77f 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -114,7 +114,7 @@ public class ToolSet { If we actually want know what efficiency our held item has instead of the best one possible, this lets us make pathing depend on the actual tool to be used (if auto tool is disabled) */ - if (Baritone.settings().disableAutoTool.value && pathingCalculation) { + if (!Baritone.settings().autoTool.value && pathingCalculation) { return player.inventory.currentItem; } From 0a27c0b6e42f5aa8d0e57ed7cf54c83d25a84d73 Mon Sep 17 00:00:00 2001 From: millennIumAMbiguity <37588844+millennIumAMbiguity@users.noreply.github.com> Date: Wed, 7 Apr 2021 18:12:47 +0200 Subject: [PATCH 074/155] Added missing information to USAGE.md Added missing information about the `farm` command. --- USAGE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/USAGE.md b/USAGE.md index 35aa90a7b..f896ad012 100644 --- a/USAGE.md +++ b/USAGE.md @@ -47,7 +47,7 @@ Some common examples: - `build` to build a schematic. `build blah.schematic` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah.schematic x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420). - `schematica` to build the schematic that is currently open in schematica - `tunnel` to dig and make a tunnel, 1x2. It will only deviate from the straight line if necessary such as to avoid lava. For a dumber tunnel that is really just cleararea, you can `tunnel 3 2 100`, to clear an area 3 high, 2 wide, and 100 deep. -- `farm` to automatically harvest, replant, or bone meal crops +- `farm` to automatically harvest, replant, or bone meal crops. Use `farm ` or `farm ` to limit the max distance from the starting point or a waypoint. - `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120). - `explore x z` to explore the world from the origin of x,z. Leave out x and z to default to player feet. This will continually path towards the closest chunk to the origin that it's never seen before. `explorefilter filter.json` with optional invert can be used to load in a list of chunks to load. - `invert` to invert the current goal and path. This gets as far away from it as possible, instead of as close as possible. For example, do `goal` then `invert` to run as far as possible from where you're standing at the start. From cbc5fc8d08b7127f64f674191a6f745f00ac933d Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Thu, 8 Apr 2021 18:36:46 +0100 Subject: [PATCH 075/155] switch from forge mods to just other mods. --- .github/ISSUE_TEMPLATE/bug.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index 34487ff75..b686a589f 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -11,7 +11,7 @@ Operating system: Java version: Minecraft version: Baritone version: -Forge mods (if used): +Other mods (if used): ## Exception, error or logs Please find your `latest.log` or `debug.log` in this folder and attach it to the issue From a4f06a9e1e608b7b7a910814d130e5fd762f5431 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sat, 10 Apr 2021 23:56:30 +0200 Subject: [PATCH 076/155] Update javadoc as well --- src/api/java/baritone/api/Settings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index a3a767a85..527e3d364 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -70,7 +70,7 @@ public final class Settings { public final Setting assumeExternalAutoTool = new Setting<>(false); /** - * If this setting is on, no auto tool will occur at all, not at calculation time nor execution time + * Automatically select the best available tool */ public final Setting autoTool = new Setting<>(true); From c13cf4f29cf7c0d6685356f5ea2eb81b09d22187 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Tue, 13 Apr 2021 23:09:54 +0200 Subject: [PATCH 077/155] Add setting to only build selected part of schematica schematic --- src/api/java/baritone/api/Settings.java | 5 ++ .../java/baritone/process/BuilderProcess.java | 8 ++- .../utils/schematic/SelectionSchematic.java | 56 +++++++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 src/main/java/baritone/utils/schematic/SelectionSchematic.java diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index ad0d487fb..3756b0ee5 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -847,6 +847,11 @@ public final class Settings { */ public final Setting skipFailedLayers = new Setting<>(false); + /** + * Only build the selected part of the schematic when using #schematica + */ + public final Setting schematicaOnlyBuildSelection = new Setting<>(false); + /** * How far to move before repeating the build. 0 to disable repeating on a certain axis, 0,0,0 to disable entirely */ diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index ca8ca534a..b9f1c27c2 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -43,6 +43,7 @@ import baritone.utils.BlockStateInterface; import baritone.utils.NotificationHelper; import baritone.utils.PathingCommandContext; import baritone.utils.schematic.MapArtSchematic; +import baritone.utils.schematic.SelectionSchematic; import baritone.utils.schematic.SchematicSystem; import baritone.utils.schematic.schematica.SchematicaHelper; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; @@ -150,10 +151,13 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil Optional> schematic = SchematicaHelper.getOpenSchematic(); if (schematic.isPresent()) { IStaticSchematic s = schematic.get().getFirst(); + BlockPos origin = schematic.get().getSecond(); + ISchematic schem = Baritone.settings().mapArtMode.value ? new MapArtSchematic(s) : s; + schem = Baritone.settings().schematicaOnlyBuildSelection.value ? new SelectionSchematic(schem, origin, baritone.getSelectionManager().getSelections()) : schem; this.build( schematic.get().getFirst().toString(), - Baritone.settings().mapArtMode.value ? new MapArtSchematic(s) : s, - schematic.get().getSecond() + schem, + origin ); } else { logDirect("No schematic currently open"); diff --git a/src/main/java/baritone/utils/schematic/SelectionSchematic.java b/src/main/java/baritone/utils/schematic/SelectionSchematic.java new file mode 100644 index 000000000..81a381a34 --- /dev/null +++ b/src/main/java/baritone/utils/schematic/SelectionSchematic.java @@ -0,0 +1,56 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package baritone.utils.schematic; + +import baritone.api.schematic.ISchematic; +import baritone.api.schematic.MaskSchematic; +import baritone.api.selection.ISelection; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; + +import java.util.stream.Stream; + +public class SelectionSchematic extends MaskSchematic { + + private final ISelection[] selections; + + public SelectionSchematic(ISchematic schematic, BlockPos origin, ISelection[] selections) { + super(schematic); + baritone.api.utils.Helper.HELPER.logDirect(String.format("%s", selections[0].min())); + this.selections = Stream.of(selections).map( + sel -> sel + .shift(EnumFacing.WEST, origin.getX()) + .shift(EnumFacing.DOWN, origin.getY()) + .shift(EnumFacing.NORTH, origin.getZ())) + .toArray(ISelection[]::new); + baritone.api.utils.Helper.HELPER.logDirect(String.format("%s", this.selections[0].min())); + baritone.api.utils.Helper.HELPER.logDirect(String.format("%s", origin)); + } + + @Override + protected boolean partOfMask(int x, int y, int z, IBlockState currentState) { + for (ISelection selection : selections) { + if (x >= selection.min().x && y >= selection.min().y && z >= selection.min().z + && x <= selection.max().x && y <= selection.max().y && z <= selection.max().z) { + return true; + } + } + return false; + } +} From 46066d4cacc4d3076b95699dc2ea261bc04a34d4 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Wed, 14 Apr 2021 23:36:16 +0200 Subject: [PATCH 078/155] Misc * Rename schematicaOnlyBuildSelection to buildOnlySelection * Make it useable with #build as well * remove debugging code I forgot --- src/api/java/baritone/api/Settings.java | 4 ++-- src/main/java/baritone/process/BuilderProcess.java | 9 ++++++++- .../baritone/utils/schematic/SelectionSchematic.java | 7 ++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 3756b0ee5..3481200c3 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -848,9 +848,9 @@ public final class Settings { public final Setting skipFailedLayers = new Setting<>(false); /** - * Only build the selected part of the schematic when using #schematica + * Only build the selected part of schematics */ - public final Setting schematicaOnlyBuildSelection = new Setting<>(false); + public final Setting buildOnlySelection = new Setting<>(false); /** * How far to move before repeating the build. 0 to disable repeating on a certain axis, 0,0,0 to disable entirely diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index b9f1c27c2..cf5c0193a 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -141,6 +141,11 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil parsed = new MapArtSchematic((IStaticSchematic) parsed); } + if (Baritone.settings().buildOnlySelection.value) { + parsed = new SelectionSchematic(parsed, origin, baritone.getSelectionManager().getSelections()); + } + + build(name, parsed, origin); return true; } @@ -153,7 +158,9 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil IStaticSchematic s = schematic.get().getFirst(); BlockPos origin = schematic.get().getSecond(); ISchematic schem = Baritone.settings().mapArtMode.value ? new MapArtSchematic(s) : s; - schem = Baritone.settings().schematicaOnlyBuildSelection.value ? new SelectionSchematic(schem, origin, baritone.getSelectionManager().getSelections()) : schem; + if (Baritone.settings().buildOnlySelection.value) { + schem = new SelectionSchematic(schem, origin, baritone.getSelectionManager().getSelections()); + } this.build( schematic.get().getFirst().toString(), schem, diff --git a/src/main/java/baritone/utils/schematic/SelectionSchematic.java b/src/main/java/baritone/utils/schematic/SelectionSchematic.java index 81a381a34..243a3d4d0 100644 --- a/src/main/java/baritone/utils/schematic/SelectionSchematic.java +++ b/src/main/java/baritone/utils/schematic/SelectionSchematic.java @@ -22,7 +22,7 @@ import baritone.api.schematic.MaskSchematic; import baritone.api.selection.ISelection; import net.minecraft.block.state.IBlockState; import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; import java.util.stream.Stream; @@ -30,17 +30,14 @@ public class SelectionSchematic extends MaskSchematic { private final ISelection[] selections; - public SelectionSchematic(ISchematic schematic, BlockPos origin, ISelection[] selections) { + public SelectionSchematic(ISchematic schematic, Vec3i origin, ISelection[] selections) { super(schematic); - baritone.api.utils.Helper.HELPER.logDirect(String.format("%s", selections[0].min())); this.selections = Stream.of(selections).map( sel -> sel .shift(EnumFacing.WEST, origin.getX()) .shift(EnumFacing.DOWN, origin.getY()) .shift(EnumFacing.NORTH, origin.getZ())) .toArray(ISelection[]::new); - baritone.api.utils.Helper.HELPER.logDirect(String.format("%s", this.selections[0].min())); - baritone.api.utils.Helper.HELPER.logDirect(String.format("%s", origin)); } @Override From dc9ae6765775ed0d671b1bb34f85f56ac6a75561 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sun, 9 May 2021 23:15:34 +0200 Subject: [PATCH 079/155] Move NotificationHelper to api and give Helper some methods for notifications --- src/api/java/baritone/api/utils/Helper.java | 43 +++++++++++++++++++ .../api}/utils/NotificationHelper.java | 2 +- .../pathing/calc/AbstractNodeCostSearch.java | 5 +-- .../java/baritone/process/BuilderProcess.java | 5 +-- .../baritone/process/CustomGoalProcess.java | 5 +-- .../java/baritone/process/ExploreProcess.java | 9 ++-- .../java/baritone/process/FarmProcess.java | 5 +-- .../java/baritone/process/MineProcess.java | 13 +++--- 8 files changed, 61 insertions(+), 26 deletions(-) rename src/{main/java/baritone => api/java/baritone/api}/utils/NotificationHelper.java (99%) diff --git a/src/api/java/baritone/api/utils/Helper.java b/src/api/java/baritone/api/utils/Helper.java index f423c4f4c..336b410e8 100755 --- a/src/api/java/baritone/api/utils/Helper.java +++ b/src/api/java/baritone/api/utils/Helper.java @@ -19,6 +19,7 @@ package baritone.api.utils; import baritone.api.BaritoneAPI; import baritone.api.utils.gui.BaritoneToast; +import baritone.api.utils.NotificationHelper; import net.minecraft.client.Minecraft; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; @@ -93,6 +94,48 @@ public interface Helper { logToast(Helper.getPrefix(), new TextComponentString(message)); } + /** + * Send a message as a desktop notification + * + * @param message The message to display in the notification + */ + default void logNotification(String message) { + logNotification(message, false); + } + + /** + * Send a message as a desktop notification + * + * @param message The message to display in the notification + * @param error Whether to log as an error + */ + default void logNotification(String message, boolean error) { + if (BaritoneAPI.getSettings().desktopNotifications.value) { + logNotificationDirect(message, error); + } + } + + /** + * Send a message as a desktop notification regardless of desktopNotifications + * (should only be used for critically important messages) + * + * @param message The message to display in the notification + */ + default void logNotificationDirect(String message) { + logNotificationDirect(message, false); + } + + /** + * Send a message as a desktop notification regardless of desktopNotifications + * (should only be used for critically important messages) + * + * @param message The message to display in the notification + * @param error Whether to log as an error + */ + default void logNotificationDirect(String message, boolean error) { + NotificationHelper.notify(message, error); + } + /** * Send a message to chat only if chatDebug is on * diff --git a/src/main/java/baritone/utils/NotificationHelper.java b/src/api/java/baritone/api/utils/NotificationHelper.java similarity index 99% rename from src/main/java/baritone/utils/NotificationHelper.java rename to src/api/java/baritone/api/utils/NotificationHelper.java index 54abbf87f..f0ec336dd 100644 --- a/src/main/java/baritone/utils/NotificationHelper.java +++ b/src/api/java/baritone/api/utils/NotificationHelper.java @@ -15,7 +15,7 @@ * along with Baritone. If not, see . */ -package baritone.utils; +package baritone.api.utils; import org.apache.commons.lang3.SystemUtils; diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index c54216568..d20b519dc 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -25,7 +25,6 @@ import baritone.api.utils.BetterBlockPos; import baritone.api.utils.Helper; import baritone.api.utils.PathCalculationResult; import baritone.pathing.movement.CalculationContext; -import baritone.utils.NotificationHelper; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import java.util.Optional; @@ -217,9 +216,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder, Helper { if (logInfo) { logDebug("Even with a cost coefficient of " + COEFFICIENTS[COEFFICIENTS.length - 1] + ", I couldn't get more than " + Math.sqrt(bestDist) + " blocks"); logDebug("No path found =("); - if (Baritone.settings().desktopNotifications.value) { - NotificationHelper.notify("No path found =(", true); - } + logNotification("No path found =(", true); } return Optional.empty(); } diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index ca8ca534a..7d1affea1 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -40,7 +40,6 @@ import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.utils.BaritoneProcessHelper; import baritone.utils.BlockStateInterface; -import baritone.utils.NotificationHelper; import baritone.utils.PathingCommandContext; import baritone.utils.schematic.MapArtSchematic; import baritone.utils.schematic.SchematicSystem; @@ -424,8 +423,8 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil numRepeats++; if (repeat.equals(new Vec3i(0, 0, 0)) || (max != -1 && numRepeats >= max)) { logDirect("Done building"); - if (Baritone.settings().desktopNotifications.value && Baritone.settings().notificationOnBuildFinished.value) { - NotificationHelper.notify("Done building", false); + if (Baritone.settings().notificationOnBuildFinished.value) { + logNotification("Done building", false); } onLostControl(); return null; diff --git a/src/main/java/baritone/process/CustomGoalProcess.java b/src/main/java/baritone/process/CustomGoalProcess.java index f925bec79..ea9ff2092 100644 --- a/src/main/java/baritone/process/CustomGoalProcess.java +++ b/src/main/java/baritone/process/CustomGoalProcess.java @@ -23,7 +23,6 @@ import baritone.api.process.ICustomGoalProcess; import baritone.api.process.PathingCommand; import baritone.api.process.PathingCommandType; import baritone.utils.BaritoneProcessHelper; -import baritone.utils.NotificationHelper; /** * As set by ExampleBaritoneControl or something idk @@ -94,8 +93,8 @@ public final class CustomGoalProcess extends BaritoneProcessHelper implements IC if (Baritone.settings().disconnectOnArrival.value) { ctx.world().sendQuittingDisconnectingPacket(); } - if (Baritone.settings().desktopNotifications.value && Baritone.settings().notificationOnPathComplete.value) { - NotificationHelper.notify("Pathing complete", false); + if (Baritone.settings().notificationOnPathComplete.value) { + logNotification("Pathing complete", false); } return new PathingCommand(this.goal, PathingCommandType.CANCEL_AND_SET_GOAL); } diff --git a/src/main/java/baritone/process/ExploreProcess.java b/src/main/java/baritone/process/ExploreProcess.java index c42ece0e5..3664d4188 100644 --- a/src/main/java/baritone/process/ExploreProcess.java +++ b/src/main/java/baritone/process/ExploreProcess.java @@ -29,7 +29,6 @@ import baritone.api.process.PathingCommandType; import baritone.api.utils.MyChunkPos; import baritone.cache.CachedWorld; import baritone.utils.BaritoneProcessHelper; -import baritone.utils.NotificationHelper; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; @@ -84,8 +83,8 @@ public final class ExploreProcess extends BaritoneProcessHelper implements IExpl public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) { if (calcFailed) { logDirect("Failed"); - if (Baritone.settings().desktopNotifications.value && Baritone.settings().notificationOnExploreFinished.value) { - NotificationHelper.notify("Exploration failed", true); + if (Baritone.settings().notificationOnExploreFinished.value) { + logNotification("Exploration failed", true); } onLostControl(); return null; @@ -93,8 +92,8 @@ public final class ExploreProcess extends BaritoneProcessHelper implements IExpl IChunkFilter filter = calcFilter(); if (!Baritone.settings().disableCompletionCheck.value && filter.countRemain() == 0) { logDirect("Explored all chunks"); - if (Baritone.settings().desktopNotifications.value && Baritone.settings().notificationOnExploreFinished.value) { - NotificationHelper.notify("Explored all chunks", false); + if (Baritone.settings().notificationOnExploreFinished.value) { + logNotification("Explored all chunks", false); } onLostControl(); return null; diff --git a/src/main/java/baritone/process/FarmProcess.java b/src/main/java/baritone/process/FarmProcess.java index a8806d2ba..0ef85f07d 100644 --- a/src/main/java/baritone/process/FarmProcess.java +++ b/src/main/java/baritone/process/FarmProcess.java @@ -31,7 +31,6 @@ import baritone.api.utils.input.Input; import baritone.cache.WorldScanner; import baritone.pathing.movement.MovementHelper; import baritone.utils.BaritoneProcessHelper; -import baritone.utils.NotificationHelper; import net.minecraft.block.*; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; @@ -272,8 +271,8 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro if (calcFailed) { logDirect("Farm failed"); - if (Baritone.settings().desktopNotifications.value && Baritone.settings().notificationOnFarmFail.value) { - NotificationHelper.notify("Farm failed", true); + if (Baritone.settings().notificationOnFarmFail.value) { + logNotification("Farm failed", true); } onLostControl(); return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE); diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index 8b0b5bac0..6d938e9d2 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -30,7 +30,6 @@ import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.MovementHelper; import baritone.utils.BaritoneProcessHelper; import baritone.utils.BlockStateInterface; -import baritone.utils.NotificationHelper; import net.minecraft.block.Block; import net.minecraft.block.BlockAir; import net.minecraft.block.BlockFalling; @@ -89,15 +88,15 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro if (calcFailed) { if (!knownOreLocations.isEmpty() && Baritone.settings().blacklistClosestOnFailure.value) { logDirect("Unable to find any path to " + filter + ", blacklisting presumably unreachable closest instance..."); - if (Baritone.settings().desktopNotifications.value && Baritone.settings().notificationOnMineFail.value) { - NotificationHelper.notify("Unable to find any path to " + filter + ", blacklisting presumably unreachable closest instance...", true); + if (Baritone.settings().notificationOnMineFail.value) { + logNotification("Unable to find any path to " + filter + ", blacklisting presumably unreachable closest instance...", true); } knownOreLocations.stream().min(Comparator.comparingDouble(ctx.player()::getDistanceSq)).ifPresent(blacklist::add); knownOreLocations.removeIf(blacklist::contains); } else { logDirect("Unable to find any path to " + filter + ", canceling mine"); - if (Baritone.settings().desktopNotifications.value && Baritone.settings().notificationOnMineFail.value) { - NotificationHelper.notify("Unable to find any path to " + filter + ", canceling mine", true); + if (Baritone.settings().notificationOnMineFail.value) { + logNotification("Unable to find any path to " + filter + ", canceling mine", true); } cancel(); return null; @@ -232,8 +231,8 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro locs.addAll(dropped); if (locs.isEmpty()) { logDirect("No locations for " + filter + " known, cancelling"); - if (Baritone.settings().desktopNotifications.value && Baritone.settings().notificationOnMineFail.value) { - NotificationHelper.notify("No locations for " + filter + " known, cancelling", true); + if (Baritone.settings().notificationOnMineFail.value) { + logNotification("No locations for " + filter + " known, cancelling", true); } cancel(); return; From 522de3d4b73daa7ff8b847b6caf75947ab739e1a Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Mon, 10 May 2021 00:31:37 +0200 Subject: [PATCH 080/155] Add callback settings for toast pop-ups and desktop notifications --- src/api/java/baritone/api/Settings.java | 17 +++++++++++++++++ src/api/java/baritone/api/utils/Helper.java | 6 ++---- .../baritone/api/utils/gui/BaritoneToast.java | 4 ++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index ad0d487fb..50b11580e 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -17,8 +17,10 @@ package baritone.api; +import baritone.api.utils.NotificationHelper; import baritone.api.utils.SettingsUtil; import baritone.api.utils.TypeUtils; +import baritone.api.utils.gui.BaritoneToast; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.init.Blocks; @@ -33,6 +35,7 @@ import java.lang.reflect.Type; import java.util.List; import java.util.*; import java.util.function.Consumer; +import java.util.function.BiConsumer; /** * Baritone's settings. Settings apply to all Baritone instances. @@ -1058,6 +1061,20 @@ public final class Settings { */ public final Setting> logger = new Setting<>(Minecraft.getMinecraft().ingameGUI.getChatGUI()::printChatMessage); + /** + * The function that is called when Baritone will send a desktop notification. This function can be added to + * via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting + * {@link Setting#value}; + */ + public final Setting> notifier = new Setting<>(NotificationHelper::notify); + + /** + * The function that is called when Baritone will show a toast. This function can be added to + * via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting + * {@link Setting#value}; + */ + public final Setting> toaster = new Setting<>(BaritoneToast::addOrUpdate); + /** * The size of the box that is rendered when the current goal is a GoalYLevel */ diff --git a/src/api/java/baritone/api/utils/Helper.java b/src/api/java/baritone/api/utils/Helper.java index 336b410e8..9bed37383 100755 --- a/src/api/java/baritone/api/utils/Helper.java +++ b/src/api/java/baritone/api/utils/Helper.java @@ -18,8 +18,6 @@ package baritone.api.utils; import baritone.api.BaritoneAPI; -import baritone.api.utils.gui.BaritoneToast; -import baritone.api.utils.NotificationHelper; import net.minecraft.client.Minecraft; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; @@ -72,7 +70,7 @@ public interface Helper { * @param message The message to display in the popup */ default void logToast(ITextComponent title, ITextComponent message) { - mc.addScheduledTask(() -> BaritoneToast.addOrUpdate(mc.getToastGui(), title, message, BaritoneAPI.getSettings().toastTimer.value)); + mc.addScheduledTask(() -> BaritoneAPI.getSettings().toaster.value.accept(title, message)); } /** @@ -133,7 +131,7 @@ public interface Helper { * @param error Whether to log as an error */ default void logNotificationDirect(String message, boolean error) { - NotificationHelper.notify(message, error); + mc.addScheduledTask(() -> BaritoneAPI.getSettings().notifier.value.accept(message, error)); } /** diff --git a/src/api/java/baritone/api/utils/gui/BaritoneToast.java b/src/api/java/baritone/api/utils/gui/BaritoneToast.java index 82df67413..eb6361478 100644 --- a/src/api/java/baritone/api/utils/gui/BaritoneToast.java +++ b/src/api/java/baritone/api/utils/gui/BaritoneToast.java @@ -71,4 +71,8 @@ public class BaritoneToast implements IToast { baritonetoast.setDisplayedText(title, subtitle); } } + + public static void addOrUpdate(ITextComponent title, ITextComponent subtitle) { + addOrUpdate(net.minecraft.client.Minecraft.getMinecraft().getToastGui(), title, subtitle, baritone.api.BaritoneAPI.getSettings().toastTimer.value); + } } From 253fbad3dbe689bd0ba75f680e8e77f4982d1692 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Mon, 10 May 2021 22:37:35 +0200 Subject: [PATCH 081/155] Make MineProcess respect exploreForBlocks --- src/api/java/baritone/api/Settings.java | 2 +- src/main/java/baritone/process/MineProcess.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 24d644b61..453d369cb 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -784,7 +784,7 @@ public final class Settings { public final Setting allowOnlyExposedOresDistance = new Setting<>(1); /** - * When GetToBlock doesn't know any locations for the desired block, explore randomly instead of giving up. + * When GetToBlock or Mine doesn't know any locations for the desired block, explore randomly instead of giving up. */ public final Setting exploreForBlocks = new Setting<>(true); diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index 8b0b5bac0..ec5f35ad2 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -188,10 +188,10 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro return new PathingCommand(goal, legit ? PathingCommandType.FORCE_REVALIDATE_GOAL_AND_PATH : PathingCommandType.REVALIDATE_GOAL_AND_PATH); } // we don't know any ore locations at the moment - if (!legit) { + if (!Baritone.settings().exploreForBlocks.value) { return null; } - // only in non-Xray mode (aka legit mode) do we do this + // only when we should explore for blocks we do this int y = Baritone.settings().legitMineYLevel.value; if (branchPoint == null) { /*if (!baritone.getPathingBehavior().isPathing() && playerFeet().y == y) { @@ -230,7 +230,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro List dropped = droppedItemsScan(); List locs = searchWorld(context, filter, ORE_LOCATIONS_COUNT, already, blacklist, dropped); locs.addAll(dropped); - if (locs.isEmpty()) { + if (locs.isEmpty() && !Baritone.settings().exploreForBlocks.value) { logDirect("No locations for " + filter + " known, cancelling"); if (Baritone.settings().desktopNotifications.value && Baritone.settings().notificationOnMineFail.value) { NotificationHelper.notify("No locations for " + filter + " known, cancelling", true); From 7b5f4197136f16d92de72b2c971644a134aa4f4b Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Mon, 24 May 2021 03:14:33 +0200 Subject: [PATCH 082/155] Treat the new callbacks like the old one --- .../command/helpers/TabCompleteHelper.java | 2 +- .../java/baritone/api/utils/SettingsUtil.java | 22 ++++++++++++++++--- .../command/ExampleBaritoneControl.java | 2 +- .../baritone/command/defaults/SetCommand.java | 2 +- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/api/java/baritone/api/command/helpers/TabCompleteHelper.java b/src/api/java/baritone/api/command/helpers/TabCompleteHelper.java index 54ae9e8c4..e438da308 100644 --- a/src/api/java/baritone/api/command/helpers/TabCompleteHelper.java +++ b/src/api/java/baritone/api/command/helpers/TabCompleteHelper.java @@ -253,8 +253,8 @@ public class TabCompleteHelper { public TabCompleteHelper addSettings() { return append( BaritoneAPI.getSettings().allSettings.stream() + .filter(s -> !SettingsUtil.javaOnlySetting(s)) .map(Settings.Setting::getName) - .filter(s -> !s.equalsIgnoreCase("logger")) .sorted(String.CASE_INSENSITIVE_ORDER) ); } diff --git a/src/api/java/baritone/api/utils/SettingsUtil.java b/src/api/java/baritone/api/utils/SettingsUtil.java index 48c8ee4df..0e95965f9 100644 --- a/src/api/java/baritone/api/utils/SettingsUtil.java +++ b/src/api/java/baritone/api/utils/SettingsUtil.java @@ -50,6 +50,7 @@ public class SettingsUtil { private static final Path SETTINGS_PATH = getMinecraft().gameDir.toPath().resolve("baritone").resolve("settings.txt"); private static final Pattern SETTING_PATTERN = Pattern.compile("^(?[^ ]+) +(?.+)"); // key and value split by the first space + private static final String[] JAVA_ONLY_SETTINGS = {"logger", "notifier", "toaster"}; private static boolean isComment(String line) { return line.startsWith("#") || line.startsWith("//"); @@ -111,7 +112,7 @@ public class SettingsUtil { System.out.println("NULL SETTING?" + setting.getName()); continue; } - if (setting.getName().equals("logger")) { + if (javaOnlySetting(setting)) { continue; // NO } if (setting.value == setting.defaultValue) { @@ -165,13 +166,28 @@ public class SettingsUtil { } public static String settingToString(Settings.Setting setting) throws IllegalStateException { - if (setting.getName().equals("logger")) { - return "logger"; + if (javaOnlySetting(setting)) { + return setting.getName(); } return setting.getName() + " " + settingValueToString(setting); } + /** + * This should always be the same as whether the setting can be parsed from or serialized to a string + * + * @param the setting + * @return true if the setting can not be set or read by the user + */ + public static boolean javaOnlySetting(Settings.Setting setting) { + for (String name : JAVA_ONLY_SETTINGS) { // no JAVA_ONLY_SETTINGS.contains(...) because that would be case sensitive + if (setting.getName().equalsIgnoreCase(name)) { + return true; + } + } + return false; + } + public static void parseAndApply(Settings settings, String settingName, String settingValue) throws IllegalStateException, NumberFormatException { Settings.Setting setting = settings.byLowerName.get(settingName); if (setting == null) { diff --git a/src/main/java/baritone/command/ExampleBaritoneControl.java b/src/main/java/baritone/command/ExampleBaritoneControl.java index 8d737941a..e00b8db71 100644 --- a/src/main/java/baritone/command/ExampleBaritoneControl.java +++ b/src/main/java/baritone/command/ExampleBaritoneControl.java @@ -124,7 +124,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener } } else if (argc.hasExactlyOne()) { for (Settings.Setting setting : settings.allSettings) { - if (setting.getName().equals("logger")) { + if (SettingsUtil.javaOnlySetting(setting)) { continue; } if (setting.getName().equalsIgnoreCase(pair.getFirst())) { diff --git a/src/main/java/baritone/command/defaults/SetCommand.java b/src/main/java/baritone/command/defaults/SetCommand.java index 49064c5c3..5ef0b28a1 100644 --- a/src/main/java/baritone/command/defaults/SetCommand.java +++ b/src/main/java/baritone/command/defaults/SetCommand.java @@ -64,7 +64,7 @@ public class SetCommand extends Command { args.requireMax(1); List toPaginate = (viewModified ? SettingsUtil.modifiedSettings(Baritone.settings()) : Baritone.settings().allSettings).stream() - .filter(s -> !s.getName().equals("logger")) + .filter(s -> !javaOnlySetting(s)) .filter(s -> s.getName().toLowerCase(Locale.US).contains(search.toLowerCase(Locale.US))) .sorted((s1, s2) -> String.CASE_INSENSITIVE_ORDER.compare(s1.getName(), s2.getName())) .collect(Collectors.toList()); From 638fcd393ac3488338bda2b099155413675158ce Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Mon, 24 May 2021 03:20:31 +0200 Subject: [PATCH 083/155] Don't try to tab complete hidden settings --- src/main/java/baritone/command/ExampleBaritoneControl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/command/ExampleBaritoneControl.java b/src/main/java/baritone/command/ExampleBaritoneControl.java index e00b8db71..7050bf302 100644 --- a/src/main/java/baritone/command/ExampleBaritoneControl.java +++ b/src/main/java/baritone/command/ExampleBaritoneControl.java @@ -177,7 +177,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener .stream(); } Settings.Setting setting = settings.byLowerName.get(argc.getString().toLowerCase(Locale.US)); - if (setting != null) { + if (setting != null && !SettingsUtil.javaOnlySetting(setting)) { if (setting.getValueClass() == Boolean.class) { TabCompleteHelper helper = new TabCompleteHelper(); if ((Boolean) setting.value) { From dbc43b445b80be448ffe1c75e15b3e262e7ee6aa Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Mon, 24 May 2021 03:38:14 +0200 Subject: [PATCH 084/155] Replace unhandled exception with a helpful message --- src/main/java/baritone/command/defaults/SetCommand.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/baritone/command/defaults/SetCommand.java b/src/main/java/baritone/command/defaults/SetCommand.java index 5ef0b28a1..e9e35d413 100644 --- a/src/main/java/baritone/command/defaults/SetCommand.java +++ b/src/main/java/baritone/command/defaults/SetCommand.java @@ -23,6 +23,7 @@ import baritone.api.Settings; import baritone.api.command.Command; import baritone.api.command.argument.IArgConsumer; import baritone.api.command.exception.CommandException; +import baritone.api.command.exception.CommandInvalidStateException; import baritone.api.command.exception.CommandInvalidTypeException; import baritone.api.command.helpers.Paginator; import baritone.api.command.helpers.TabCompleteHelper; @@ -128,6 +129,12 @@ public class SetCommand extends Command { if (setting == null) { throw new CommandInvalidTypeException(args.consumed(), "a valid setting"); } + if (javaOnlySetting(setting)) { + // ideally it would act as if the setting didn't exist + // but users will see it in Settings.java or its javadoc + // so at some point we have to tell them or they will see it as a bug + throw new CommandInvalidStateException(String.format("Setting %s can only be used via the api.", setting.getName())); + } if (!doingSomething && !args.hasAny()) { logDirect(String.format("Value of setting %s:", setting.getName())); logDirect(settingValueToString(setting)); From 3fc36cf7988835c94d3d6ba218f25d609a711f33 Mon Sep 17 00:00:00 2001 From: Tabbs Date: Tue, 25 May 2021 12:34:17 -0500 Subject: [PATCH 085/155] fix y to 1 if animation is disabled --- src/api/java/baritone/api/Settings.java | 5 +++++ src/main/java/baritone/utils/PathRenderer.java | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 24d644b61..bd27f3253 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -595,6 +595,11 @@ public final class Settings { */ public final Setting renderGoal = new Setting<>(true); + /** + * Render the goal as just a box instead of sick animated thingy + */ + public final Setting renderGoalAsBox = new Setting<>(false); + /** * Render selection boxes */ diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index cc11f4e64..739d4a9c3 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -207,8 +207,13 @@ public final class PathRenderer implements IRenderer { double minX, maxX; double minZ, maxZ; double minY, maxY; - double y1, y2; - double y = MathHelper.cos((float) (((float) ((System.nanoTime() / 100000L) % 20000L)) / 20000F * Math.PI * 2)); + double y, y1, y2; + if (settings.renderGoalAsBox.value) { + y = 1; + } + else { + y = MathHelper.cos((float) (((float) ((System.nanoTime() / 100000L) % 20000L)) / 20000F * Math.PI * 2)); + } if (goal instanceof IGoalRenderPos) { BlockPos goalPos = ((IGoalRenderPos) goal).getGoalPos(); minX = goalPos.getX() + 0.002 - renderPosX; From 73e0700ea35da6fa292b6415f88cbfc976ba00b2 Mon Sep 17 00:00:00 2001 From: Tabbs Date: Tue, 25 May 2021 12:41:36 -0500 Subject: [PATCH 086/155] fix weird rendering issue --- src/main/java/baritone/utils/PathRenderer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index 739d4a9c3..e403e3fe1 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -209,7 +209,8 @@ public final class PathRenderer implements IRenderer { double minY, maxY; double y, y1, y2; if (settings.renderGoalAsBox.value) { - y = 1; + // y = 1 causes rendering issues when the player is at the same y as the top of a block for some reason + y = .999F; } else { y = MathHelper.cos((float) (((float) ((System.nanoTime() / 100000L) % 20000L)) / 20000F * Math.PI * 2)); From 7d144dd07600b7aee9b48c88b22ded1ae94f545b Mon Sep 17 00:00:00 2001 From: Larson Date: Tue, 25 May 2021 14:33:13 -0500 Subject: [PATCH 087/155] fix decimal Co-authored-by: scorbett123 <50634068+scorbett123@users.noreply.github.com> --- src/main/java/baritone/utils/PathRenderer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index e403e3fe1..0985e4d98 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -210,7 +210,7 @@ public final class PathRenderer implements IRenderer { double y, y1, y2; if (settings.renderGoalAsBox.value) { // y = 1 causes rendering issues when the player is at the same y as the top of a block for some reason - y = .999F; + y = 0.999F; } else { y = MathHelper.cos((float) (((float) ((System.nanoTime() / 100000L) % 20000L)) / 20000F * Math.PI * 2)); From dda4928693e77626e69e4767c599a0af5cb2f085 Mon Sep 17 00:00:00 2001 From: Tabbs Date: Tue, 25 May 2021 14:43:32 -0500 Subject: [PATCH 088/155] change name to renderGoalAnimated --- src/api/java/baritone/api/Settings.java | 2 +- src/main/java/baritone/utils/PathRenderer.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index bd27f3253..de40d03f7 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -598,7 +598,7 @@ public final class Settings { /** * Render the goal as just a box instead of sick animated thingy */ - public final Setting renderGoalAsBox = new Setting<>(false); + public final Setting renderGoalAnimated = new Setting<>(true); /** * Render selection boxes diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index e403e3fe1..0785134ea 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -208,7 +208,7 @@ public final class PathRenderer implements IRenderer { double minZ, maxZ; double minY, maxY; double y, y1, y2; - if (settings.renderGoalAsBox.value) { + if (!settings.renderGoalAnimated.value) { // y = 1 causes rendering issues when the player is at the same y as the top of a block for some reason y = .999F; } From 546493ba45f22c848281cf244daa83f2ee6b0fc8 Mon Sep 17 00:00:00 2001 From: Tabbs Date: Tue, 25 May 2021 14:44:54 -0500 Subject: [PATCH 089/155] do our best to stop beacon animating The game seems to animate the beacons anyway, so it does shake a little bit. --- src/main/java/baritone/utils/PathRenderer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index 0785134ea..6ee6bc581 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -249,9 +249,9 @@ public final class PathRenderer implements IRenderer { goalPos.getX() - renderPosX, -renderPosY, goalPos.getZ() - renderPosZ, - partialTicks, + settings.renderGoalAnimated.value ? partialTicks : 0, 1.0, - player.world.getTotalWorldTime(), + settings.renderGoalAnimated.value ? player.world.getTotalWorldTime() : 0, 0, 256, color.getColorComponents(null) From dcc27a7447a9426d0b50f849c2998d863235c44d Mon Sep 17 00:00:00 2001 From: Tabbs Date: Tue, 25 May 2021 14:52:16 -0500 Subject: [PATCH 090/155] oops forgot the javadoc --- src/api/java/baritone/api/Settings.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index de40d03f7..f1d50925d 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -596,7 +596,8 @@ public final class Settings { public final Setting renderGoal = new Setting<>(true); /** - * Render the goal as just a box instead of sick animated thingy + * Render the goal as a sick animated thingy instead of just a box + * (also controls animation of GoalXZ if {@link #renderGoalXZBeacon} is enabled) */ public final Setting renderGoalAnimated = new Setting<>(true); From f99bf0d000364b2301c2b1b5903605258f288eb9 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Fri, 28 May 2021 22:18:33 +0200 Subject: [PATCH 091/155] Make legitMode always explore --- src/api/java/baritone/api/Settings.java | 3 ++- src/main/java/baritone/process/MineProcess.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 453d369cb..edbb3de7b 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -784,7 +784,7 @@ public final class Settings { public final Setting allowOnlyExposedOresDistance = new Setting<>(1); /** - * When GetToBlock or Mine doesn't know any locations for the desired block, explore randomly instead of giving up. + * When GetToBlock or non-legit Mine doesn't know any locations for the desired block, explore randomly instead of giving up. */ public final Setting exploreForBlocks = new Setting<>(true); @@ -977,6 +977,7 @@ public final class Settings { * Disallow MineBehavior from using X-Ray to see where the ores are. Turn this option on to force it to mine "legit" * where it will only mine an ore once it can actually see it, so it won't do or know anything that a normal player * couldn't. If you don't want it to look like you're X-Raying, turn this on + * This will always explore, regardless of exploreForBlocks */ public final Setting legitMine = new Setting<>(false); diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index ec5f35ad2..b6a80c778 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -188,10 +188,10 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro return new PathingCommand(goal, legit ? PathingCommandType.FORCE_REVALIDATE_GOAL_AND_PATH : PathingCommandType.REVALIDATE_GOAL_AND_PATH); } // we don't know any ore locations at the moment - if (!Baritone.settings().exploreForBlocks.value) { + if (!legit && !Baritone.settings().exploreForBlocks.value) { return null; } - // only when we should explore for blocks we do this + // only when we should explore for blocks or are in legit mode we do this int y = Baritone.settings().legitMineYLevel.value; if (branchPoint == null) { /*if (!baritone.getPathingBehavior().isPathing() && playerFeet().y == y) { From 8bfe32eeefa7af4a630d6e2823f0899bd1e5c359 Mon Sep 17 00:00:00 2001 From: mankool <8884398+mankool0@users.noreply.github.com> Date: Wed, 9 Jun 2021 10:34:45 -0700 Subject: [PATCH 092/155] Added itemSaverThreshold --- src/api/java/baritone/api/Settings.java | 5 +++++ src/main/java/baritone/behavior/InventoryBehavior.java | 2 +- src/main/java/baritone/utils/ToolSet.java | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index ba4b4c52a..2e1315883 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -733,6 +733,11 @@ public final class Settings { */ public final Setting itemSaver = new Setting<>(false); + /** + * Durability to leave on the tool when using itemSaver + */ + public final Setting itemSaverThreshold = new Setting<>(10); + /** * Always prefer silk touch tools over regular tools. This will not sacrifice speed, but it will always prefer silk * touch tools over other tools of the same speed. This includes always choosing ANY silk touch tool over your hand. diff --git a/src/main/java/baritone/behavior/InventoryBehavior.java b/src/main/java/baritone/behavior/InventoryBehavior.java index 22ef3a64f..c9e18eb76 100644 --- a/src/main/java/baritone/behavior/InventoryBehavior.java +++ b/src/main/java/baritone/behavior/InventoryBehavior.java @@ -112,7 +112,7 @@ public final class InventoryBehavior extends Behavior { if (stack.isEmpty()) { continue; } - if (Baritone.settings().itemSaver.value && stack.getItemDamage() >= stack.getMaxDamage() && stack.getMaxDamage() > 1) { + if (Baritone.settings().itemSaver.value && (stack.getItemDamage() + Baritone.settings().itemSaverThreshold.value) >= stack.getMaxDamage() && stack.getMaxDamage() > 1) { continue; } if (cla$$.isInstance(stack.getItem())) { diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index 0e153e77f..e5e96e341 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -129,7 +129,7 @@ public class ToolSet { continue; } - if (Baritone.settings().itemSaver.value && itemStack.getItemDamage() >= itemStack.getMaxDamage() && itemStack.getMaxDamage() > 1) { + if (Baritone.settings().itemSaver.value && (itemStack.getItemDamage() + Baritone.settings().itemSaverThreshold.value) >= itemStack.getMaxDamage() && itemStack.getMaxDamage() > 1) { continue; } double speed = calculateSpeedVsBlock(itemStack, blockState); From e66bb7a14b5a97ff8c53043680210be244b7079b Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Sat, 12 Jun 2021 11:14:59 +0100 Subject: [PATCH 093/155] Make proguard output the mapping. --- scripts/proguard.pro | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/proguard.pro b/scripts/proguard.pro index af920a590..ce92b30aa 100644 --- a/scripts/proguard.pro +++ b/scripts/proguard.pro @@ -381,3 +381,5 @@ public java.lang.String substring(int); public java.lang.String substring(int,int); } + +-printmapping mapping.txt From 8f45718b758b3451b5079364c649b3bf285b93cf Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Sat, 12 Jun 2021 11:27:27 +0100 Subject: [PATCH 094/155] Try to create github actions An attempt at github actions. --- .github/workflows/gradle_build.yml | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/gradle_build.yml diff --git a/.github/workflows/gradle_build.yml b/.github/workflows/gradle_build.yml new file mode 100644 index 000000000..4f537a1ef --- /dev/null +++ b/.github/workflows/gradle_build.yml @@ -0,0 +1,39 @@ +# This workflow will build a Java project with Gradle +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Java CI with Gradle + +on: + push: + pull_request: + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew build + + - name: Archive Artifacts + uses: actions/upload-artifact@v2 + with: + name: Artifacts + path: dist/ + + - name: Archive mapping.txt + uses: actions/upload-artifact@v2 + with: + name: Mappings + path: build/tmp/proguard/mapping.txt From 64b6e0fd56613e1f4d0da691e129ae2857493a36 Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Sat, 12 Jun 2021 13:49:59 +0100 Subject: [PATCH 095/155] Remove broken hit count badge --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 1cf67f86d..85f3bf84e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # Baritone

- HitCount GitHub All Releases

From 260989bda6e1778e4e62263f301916b54406c306 Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Sat, 12 Jun 2021 13:52:56 +0100 Subject: [PATCH 096/155] Update build java version for github actions. --- .github/workflows/gradle_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gradle_build.yml b/.github/workflows/gradle_build.yml index 4f537a1ef..75708eef2 100644 --- a/.github/workflows/gradle_build.yml +++ b/.github/workflows/gradle_build.yml @@ -17,7 +17,7 @@ jobs: - name: Set up JDK 11 uses: actions/setup-java@v2 with: - java-version: '11' + java-version: '8' distribution: 'adopt' - name: Grant execute permission for gradlew From 065470cecbbf7bf8805d93824cb0c2389c9bf624 Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Sat, 12 Jun 2021 14:02:31 +0100 Subject: [PATCH 097/155] update mapping.txt location --- .github/workflows/gradle_build.yml | 2 +- scripts/proguard.pro | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gradle_build.yml b/.github/workflows/gradle_build.yml index 75708eef2..60020c31d 100644 --- a/.github/workflows/gradle_build.yml +++ b/.github/workflows/gradle_build.yml @@ -36,4 +36,4 @@ jobs: uses: actions/upload-artifact@v2 with: name: Mappings - path: build/tmp/proguard/mapping.txt + path: dist/mapping.txt diff --git a/scripts/proguard.pro b/scripts/proguard.pro index ce92b30aa..8ee6fec08 100644 --- a/scripts/proguard.pro +++ b/scripts/proguard.pro @@ -382,4 +382,4 @@ public java.lang.String substring(int,int); } --printmapping mapping.txt +-printmapping ../../../dist/mapping.txt From 6adc923bcb027f3fcd38c1615e92e0e98584c9f4 Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Sat, 12 Jun 2021 14:07:35 +0100 Subject: [PATCH 098/155] Revert "update mapping.txt location" This reverts commit 065470ce Github doesn't seem to support ../ --- .github/workflows/gradle_build.yml | 2 +- scripts/proguard.pro | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gradle_build.yml b/.github/workflows/gradle_build.yml index 60020c31d..75708eef2 100644 --- a/.github/workflows/gradle_build.yml +++ b/.github/workflows/gradle_build.yml @@ -36,4 +36,4 @@ jobs: uses: actions/upload-artifact@v2 with: name: Mappings - path: dist/mapping.txt + path: build/tmp/proguard/mapping.txt diff --git a/scripts/proguard.pro b/scripts/proguard.pro index 8ee6fec08..ce92b30aa 100644 --- a/scripts/proguard.pro +++ b/scripts/proguard.pro @@ -382,4 +382,4 @@ public java.lang.String substring(int,int); } --printmapping ../../../dist/mapping.txt +-printmapping mapping.txt From 37e129bfb9a853dc5f0bb9f143d2fc8ba26fccb4 Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Sat, 12 Jun 2021 14:08:04 +0100 Subject: [PATCH 099/155] Create run_tests.yml --- .github/workflows/run_tests.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/workflows/run_tests.yml diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/.github/workflows/run_tests.yml @@ -0,0 +1 @@ + From cc488ccff0d50f4b7460fdbf5d52fdf1e14c5699 Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Sat, 12 Jun 2021 14:09:50 +0100 Subject: [PATCH 100/155] Make actions run tests as well. --- .github/workflows/run_tests.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 8b1378917..4e28ed804 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -1 +1,26 @@ +name: Tests + +on: + push: + pull_request: + +jobs: + test: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 9 + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew test + From 95910bc6cb816e4636c75be0fbd346e1ee578cd0 Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Sat, 12 Jun 2021 14:13:39 +0100 Subject: [PATCH 101/155] Cleanup - travis.org is now deprecated and can no longer be used. --- .github/workflows/gradle_build.yml | 2 +- .github/workflows/run_tests.yml | 2 +- .travis.yml | 28 ---------------------------- 3 files changed, 2 insertions(+), 30 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/gradle_build.yml b/.github/workflows/gradle_build.yml index 75708eef2..34e93bff2 100644 --- a/.github/workflows/gradle_build.yml +++ b/.github/workflows/gradle_build.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 11 + - name: Set up JDK 8 uses: actions/setup-java@v2 with: java-version: '8' diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 4e28ed804..1af26a476 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -21,6 +21,6 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Build with Gradle + - name: Executing tests run: ./gradlew test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 75d14ffc2..000000000 --- a/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -language: java - -sudo: required - -services: -- docker - -install: -- travis_retry docker build -t cabaletta/baritone . - -script: -- docker run --name baritone cabaletta/baritone ./gradlew javadoc -- docker cp baritone:/code/dist dist -- ls dist -- cat dist/checksums.txt - -deploy: - provider: releases - api_key: - secure: YOuiXoJNpB4bW89TQoY2IGXg0tqOKls55YMXsSPU6Mx8WzRu8CjjO/A8KA9nGfNrKM+NucjiKr/h53O2Dp2uyy0i0SLvav/G0MaBMeB1NlPRwFopi6tVPNaoZsvr8NW4BIURhspckYLpOTYWnfmOkIv8q7AxrjUZWPKDlq0dte20UxEqUE6msHJ7U9XlKo/4fX40kvWMfwGI2hTyAtL0cRT1QPsd+uW3OQjAPcQj+jKaWld46V8pBK8g9Qde9mo8HC9NBv97zw1bBF1EFkynW569kElHvaS2Opl2QLGaf66guDbpnqDpGHMhQrDdxsZHJ4RksyITn+8A9UArmbkU35BxKqBeQqOWxod2+M0axdLh1pvX43Q1t9n7RiZBf7GvV8vkXL5Sjf8v6Y4LqkJGhvQkTUwpH+0knwrE761DMCtBC34AiWG70D4u7msmhurkflr9kmRHSj/3lyJ1Q2lkt8L+FOAlQBVs64vXTsfgc6Yge7N0O3UD5hCkrDNoz3BzhNBdCkbdxdKCGip71UZgUNkPy9o3ui8jATNj9ypx3+U8ovqP0XWlJqUZmyeXyNGW9NrLeCkRLTlLnZ/dv6OPONa1oAu4TwF1w5A+TGRFZcZjH/PnZKZDQ1OYQOR6drLKRYdr2unvuf5KUKUGqZ7aYtLGhP0rBvGWddRV7DSmX/s= - all_branches: true - file_glob: true - file: - - dist/* - skip_cleanup: true - on: - tags: true - repo: cabaletta/baritone From f09f1e7f851a4f5286bd209bbc88e097c65eb1cb Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Sat, 12 Jun 2021 15:04:36 +0100 Subject: [PATCH 102/155] Make farm use inventory when allowInventory is enabled. --- .../baritone/behavior/InventoryBehavior.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/baritone/behavior/InventoryBehavior.java b/src/main/java/baritone/behavior/InventoryBehavior.java index 22ef3a64f..3741b088f 100644 --- a/src/main/java/baritone/behavior/InventoryBehavior.java +++ b/src/main/java/baritone/behavior/InventoryBehavior.java @@ -18,6 +18,7 @@ package baritone.behavior; import baritone.Baritone; +import baritone.api.BaritoneAPI; import baritone.api.event.events.TickEvent; import baritone.utils.ToolSet; import net.minecraft.block.Block; @@ -152,6 +153,10 @@ public final class InventoryBehavior extends Behavior { } public boolean throwaway(boolean select, Predicate desired) { + return throwaway(select, desired, BaritoneAPI.getSettings().allowInventory.value); + } + + public boolean throwaway(boolean select, Predicate desired, boolean allowInventory) { EntityPlayerSP p = ctx.player(); NonNullList inv = p.inventory.mainInventory; for (int i = 0; i < 9; i++) { @@ -184,6 +189,19 @@ public final class InventoryBehavior extends Behavior { } } } + + if (allowInventory) { + for (int i = 9; i < 36; i++) { + if (desired.test(inv.get(i))) { + swapWithHotBar(i, 7); + if (select) { + p.inventory.currentItem = 7; + } + return true; + } + } + } + return false; } } From cec44e3668d87d1e9ed2c0eb688de43813eb0e13 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sun, 13 Jun 2021 00:21:52 +0200 Subject: [PATCH 103/155] =?UTF-8?q?=E2=9C=A8=20Add=20a=20clipboard=20to=20?= =?UTF-8?q?#sel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../baritone/command/defaults/SelCommand.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/main/java/baritone/command/defaults/SelCommand.java b/src/main/java/baritone/command/defaults/SelCommand.java index 0eab8a9a9..659a31835 100644 --- a/src/main/java/baritone/command/defaults/SelCommand.java +++ b/src/main/java/baritone/command/defaults/SelCommand.java @@ -37,6 +37,9 @@ import baritone.api.utils.BetterBlockPos; import baritone.api.utils.BlockOptionalMeta; import baritone.api.utils.BlockOptionalMetaLookup; import baritone.utils.IRenderer; +import baritone.utils.BlockStateInterface; +import baritone.utils.schematic.StaticSchematic; +import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; @@ -53,6 +56,8 @@ public class SelCommand extends Command { private ISelectionManager manager = baritone.getSelectionManager(); private BetterBlockPos pos1 = null; + private ISchematic clipboard = null; + private Vec3i clipboardOffset = null; public SelCommand(IBaritone baritone) { super(baritone, "sel", "selection", "s"); @@ -158,6 +163,56 @@ public class SelCommand extends Command { } baritone.getBuilderProcess().build("Fill", composite, origin); logDirect("Filling now"); + } else if (action == Action.COPY) { + BetterBlockPos playerPos = mc.getRenderViewEntity() != null ? BetterBlockPos.from(new BlockPos(mc.getRenderViewEntity())) : ctx.playerFeet(); + BetterBlockPos pos = args.hasAny() ? args.getDatatypePost(RelativeBlockPos.INSTANCE, playerPos) : playerPos; + args.requireMax(0); + ISelection[] selections = manager.getSelections(); + if (selections.length < 1) { + throw new CommandInvalidStateException("No selections"); + } + BlockStateInterface bsi = new BlockStateInterface(ctx); + BetterBlockPos origin = selections[0].min(); + CompositeSchematic composite = new CompositeSchematic(0, 0, 0); + for (ISelection selection : selections) { + BetterBlockPos min = selection.min(); + origin = new BetterBlockPos( + Math.min(origin.x, min.x), + Math.min(origin.y, min.y), + Math.min(origin.z, min.z) + ); + } + for (ISelection selection : selections) { + Vec3i size = selection.size(); + BetterBlockPos min = selection.min(); + IBlockState[][][] blockstates = new IBlockState[size.getX()][size.getZ()][size.getY()]; + for (int x = 0; x < size.getX(); x++) { + for (int y = 0; y < size.getY(); y++) { + for (int z = 0; z < size.getZ(); z++) { + blockstates[x][z][y] = bsi.get0(min.x + x, min.y + y, min.z + z); + } + } + } + ISchematic schematic = new StaticSchematic(){{ + states = blockstates; + x = size.getX(); + y = size.getY(); + z = size.getZ(); + }}; + composite.put(schematic, min.x - origin.x, min.y - origin.y, min.z - origin.z); + } + clipboard = composite; + clipboardOffset = origin.subtract(pos); + logDirect("Selection copied"); + } else if (action == Action.PASTE) { + BetterBlockPos playerPos = mc.getRenderViewEntity() != null ? BetterBlockPos.from(new BlockPos(mc.getRenderViewEntity())) : ctx.playerFeet(); + BetterBlockPos pos = args.hasAny() ? args.getDatatypePost(RelativeBlockPos.INSTANCE, playerPos) : playerPos; + args.requireMax(0); + if (clipboard == null) { + throw new CommandInvalidStateException("You need to copy a selection first"); + } + baritone.getBuilderProcess().build("Fill", clipboard, pos.add(clipboardOffset)); + logDirect("Building now"); } else if (action == Action.EXPAND || action == Action.CONTRACT || action == Action.SHIFT) { args.requireExactly(3); TransformTarget transformTarget = TransformTarget.getByName(args.getString()); @@ -252,6 +307,8 @@ public class SelCommand extends Command { "> sel shell/shl [block] - The same as walls, but fills in a ceiling and floor too.", "> sel cleararea/ca - Basically 'set air'.", "> sel replace/r - Replaces blocks with another block.", + "> sel copy/cp - Copy the selected area relative to the specified or your position.", + "> sel paste/p - Build the copied area relative to the specified or your position.", "", "> sel expand - Expand the targets.", "> sel contract - Contract the targets.", @@ -270,6 +327,8 @@ public class SelCommand extends Command { CLEARAREA("cleararea", "ca"), REPLACE("replace", "r"), EXPAND("expand", "ex"), + COPY("copy", "cp"), + PASTE("paste", "p"), CONTRACT("contract", "ct"), SHIFT("shift", "sh"); private final String[] names; From 64ba96daf2029f7cc70188faf15ecc96517f3903 Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Mon, 14 Jun 2021 20:44:32 +0100 Subject: [PATCH 104/155] Do edit suggested by leijurv --- src/main/java/baritone/behavior/InventoryBehavior.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/behavior/InventoryBehavior.java b/src/main/java/baritone/behavior/InventoryBehavior.java index 3741b088f..4fcde5a78 100644 --- a/src/main/java/baritone/behavior/InventoryBehavior.java +++ b/src/main/java/baritone/behavior/InventoryBehavior.java @@ -153,7 +153,7 @@ public final class InventoryBehavior extends Behavior { } public boolean throwaway(boolean select, Predicate desired) { - return throwaway(select, desired, BaritoneAPI.getSettings().allowInventory.value); + return throwaway(select, desired, Baritone.settings().allowInventory.value); } public boolean throwaway(boolean select, Predicate desired, boolean allowInventory) { From 199d5d57d5155de566777964673cf619639fb747 Mon Sep 17 00:00:00 2001 From: Harry Date: Mon, 21 Jun 2021 09:49:18 +1000 Subject: [PATCH 105/155] Update .gitignore --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index bd3b054a3..84a7e4319 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,12 @@ classes/ *.iws /logs/ +# Eclipse Files +.classpath +.project +.settings/ +baritone_Client.launch + # Copyright Files !/.idea/copyright/Baritone.xml !/.idea/copyright/profiles_settings.xml From 051325e10fc541604a1d4a3e86f0986bcc69abcb Mon Sep 17 00:00:00 2001 From: Harry Date: Mon, 21 Jun 2021 10:58:11 +1000 Subject: [PATCH 106/155] allow smaller parkour place jumps allows 2 and 1 block parkour place jumps --- .../movement/movements/MovementParkour.java | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index b9a0fd446..55930a046 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -124,7 +124,7 @@ public class MovementParkour extends Movement { return; } IBlockState landingOn = context.bsi.get0(destX, y - 1, destZ); - // farmland needs to be canwalkon otherwise farm can never work at all, but we want to specifically disallow ending a jumy on farmland haha + // farmland needs to be canWalkOn otherwise farm can never work at all, but we want to specifically disallow ending a jump on farmland haha if (landingOn.getBlock() != Blocks.FARMLAND && MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, landingOn)) { if (checkOvershootSafety(context.bsi, destX + xDiff, y, destZ + zDiff)) { res.x = destX; @@ -138,39 +138,39 @@ public class MovementParkour extends Movement { return; } } - if (maxJump != 4) { - return; - } + // parkour place starts here if (!context.allowParkourPlace) { return; } - // time 2 pop off with that dank skynet parkour place - int destX = x + 4 * xDiff; - int destZ = z + 4 * zDiff; - IBlockState toReplace = context.get(destX, y - 1, destZ); - double placeCost = context.costOfPlacingAt(destX, y - 1, destZ, toReplace); - if (placeCost >= COST_INF) { - return; - } - if (!MovementHelper.isReplaceable(destX, y - 1, destZ, toReplace, context.bsi)) { - return; - } - if (!checkOvershootSafety(context.bsi, destX + xDiff, y, destZ + zDiff)) { - return; - } - for (int i = 0; i < 5; i++) { - int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset(); - int againstY = y - 1 + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getYOffset(); - int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getZOffset(); - if (againstX == x + xDiff * 3 && againstZ == z + zDiff * 3) { // we can't turn around that fast - continue; + // check parkour jumps from largest to smallest + for (int i = maxJump; i > 1; i--) { + int destX = x + i * xDiff; + int destZ = z + i * zDiff; + IBlockState toReplace = context.get(destX, y - 1, destZ); + double placeCost = context.costOfPlacingAt(destX, y - 1, destZ, toReplace); + if (placeCost >= COST_INF) { + continue; } - if (MovementHelper.canPlaceAgainst(context.bsi, againstX, againstY, againstZ)) { - res.x = destX; - res.y = y; - res.z = destZ; - res.cost = costFromJumpDistance(4) + placeCost + context.jumpPenalty; - return; + if (!MovementHelper.isReplaceable(destX, y - 1, destZ, toReplace, context.bsi)) { + continue; + } + if (!checkOvershootSafety(context.bsi, destX + xDiff, y, destZ + zDiff)) { + continue; + } + for (int j = 0; j < 5; j++) { + int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[j].getXOffset(); + int againstY = y - 1 + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[j].getYOffset(); + int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[j].getZOffset(); + if (againstX == x + xDiff * 3 && againstZ == z + zDiff * 3) { // we can't turn around that fast + continue; + } + if (MovementHelper.canPlaceAgainst(context.bsi, againstX, againstY, againstZ)) { + res.x = destX; + res.y = y; + res.z = destZ; + res.cost = costFromJumpDistance(i) + placeCost + context.jumpPenalty; + return; + } } } } From 3142387e455c2d8e8c41841d36be9105bc286fb7 Mon Sep 17 00:00:00 2001 From: Harry Date: Wed, 23 Jun 2021 06:25:10 +1000 Subject: [PATCH 107/155] Fix collision early return not tested yet - fixes early returns --- .../movement/movements/MovementParkour.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 55930a046..162c20cc3 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -108,10 +108,12 @@ public class MovementParkour extends Movement { int destX = x + xDiff * i; int destZ = z + zDiff * i; if (!MovementHelper.fullyPassable(context, destX, y + 1, destZ)) { - return; + maxJump = i - 1; + break; } if (!MovementHelper.fullyPassable(context, destX, y + 2, destZ)) { - return; + maxJump = i - 1; + break; } IBlockState destInto = context.bsi.get0(destX, y, destZ); if (!MovementHelper.fullyPassable(context.bsi.access, context.bsi.isPassableBlockPos.setPos(destX, y, destZ), destInto)) { @@ -120,8 +122,10 @@ public class MovementParkour extends Movement { res.y = y + 1; res.z = destZ; res.cost = i * SPRINT_ONE_BLOCK_COST + context.jumpPenalty; + return; } - return; + maxJump = i - 1; + break; } IBlockState landingOn = context.bsi.get0(destX, y - 1, destZ); // farmland needs to be canWalkOn otherwise farm can never work at all, but we want to specifically disallow ending a jump on farmland haha @@ -131,11 +135,14 @@ public class MovementParkour extends Movement { res.y = y; res.z = destZ; res.cost = costFromJumpDistance(i) + context.jumpPenalty; + return; } - return; + maxJump = i - 1; + break; } if (!MovementHelper.fullyPassable(context, destX, y + 3, destZ)) { - return; + maxJump = i - 1; + break; } } // parkour place starts here From ab3a015d6120407d5f6d5b3beb75ea6e41b95629 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Thu, 24 Jun 2021 23:33:48 +0200 Subject: [PATCH 108/155] =?UTF-8?q?=E2=9C=A8=20Add=20layerHeight=20setting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/java/baritone/api/Settings.java | 5 +++++ src/main/java/baritone/process/BuilderProcess.java | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 2e1315883..2d9ad3fb3 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -850,6 +850,11 @@ public final class Settings { */ public final Setting layerOrder = new Setting<>(false); + /** + * How high should the individual layers be? + */ + public final Setting layerHeight = new Setting<>(1); + /** * Start building the schematic at a specific layer. * Can help on larger builds when schematic wants to break things its already built diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index e08aa9450..89226fed2 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -385,9 +385,9 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil // layer = realSchematic.heightY() should be everything if (Baritone.settings().layerOrder.value) { // top to bottom maxYInclusive = realSchematic.heightY() - 1; - minYInclusive = realSchematic.heightY() - layer; + minYInclusive = realSchematic.heightY() - layer * Baritone.settings().layerHeight.value; } else { - maxYInclusive = layer - 1; + maxYInclusive = layer * Baritone.settings().layerHeight.value - 1; minYInclusive = 0; } schematic = new ISchematic() { @@ -424,7 +424,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil } BuilderCalculationContext bcc = new BuilderCalculationContext(); if (!recalc(bcc)) { - if (Baritone.settings().buildInLayers.value && layer < realSchematic.heightY()) { + if (Baritone.settings().buildInLayers.value && layer * Baritone.settings().layerHeight.value < realSchematic.heightY()) { logDirect("Starting layer " + layer); layer++; return onTick(calcFailed, isSafeToCancel, recursions + 1); @@ -514,7 +514,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil if (goal == null) { goal = assemble(bcc, approxPlaceable, true); // we're far away, so assume that we have our whole inventory to recalculate placeable properly if (goal == null) { - if (Baritone.settings().skipFailedLayers.value && Baritone.settings().buildInLayers.value && layer < realSchematic.heightY()) { + if (Baritone.settings().skipFailedLayers.value && Baritone.settings().buildInLayers.value && layer * Baritone.settings().layerHeight.value < realSchematic.heightY()) { logDirect("Skipping layer that I cannot construct! Layer #" + layer); layer++; return onTick(calcFailed, isSafeToCancel, recursions + 1); From 2159773723c7b392a8ec2c67c57cca50e4ffb3d9 Mon Sep 17 00:00:00 2001 From: Harry Date: Thu, 1 Jul 2021 10:09:06 +1000 Subject: [PATCH 109/155] requested changes - tabs changed to 4 spaces - fixed checking if block place is behind player --- .../pathing/movement/movements/MovementParkour.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 162c20cc3..f7b84b58e 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -156,19 +156,19 @@ public class MovementParkour extends Movement { IBlockState toReplace = context.get(destX, y - 1, destZ); double placeCost = context.costOfPlacingAt(destX, y - 1, destZ, toReplace); if (placeCost >= COST_INF) { - continue; + continue; } if (!MovementHelper.isReplaceable(destX, y - 1, destZ, toReplace, context.bsi)) { - continue; + continue; } if (!checkOvershootSafety(context.bsi, destX + xDiff, y, destZ + zDiff)) { - continue; + continue; } for (int j = 0; j < 5; j++) { int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[j].getXOffset(); int againstY = y - 1 + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[j].getYOffset(); int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[j].getZOffset(); - if (againstX == x + xDiff * 3 && againstZ == z + zDiff * 3) { // we can't turn around that fast + if (againstX == destX - xDiff && againstZ == destZ - zDiff) { // we can't turn around that fast continue; } if (MovementHelper.canPlaceAgainst(context.bsi, againstX, againstY, againstZ)) { From 7a7b050615e9d16654cf4f08edb0580bd3e61880 Mon Sep 17 00:00:00 2001 From: Harry Date: Sat, 17 Jul 2021 12:34:58 +1000 Subject: [PATCH 110/155] weird verifiedMaxJump --- .../movement/movements/MovementParkour.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index f7b84b58e..416c90725 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -104,17 +104,23 @@ public class MovementParkour extends Movement { maxJump = 3; } } + + // check parkour jumps from smallest to largest for obstacles/walls and landing positions + int verifiedMaxJump = -1; for (int i = 2; i <= maxJump; i++) { + verifiedMaxJump = i - 1; int destX = x + xDiff * i; int destZ = z + zDiff * i; + + // check head/feet if (!MovementHelper.fullyPassable(context, destX, y + 1, destZ)) { - maxJump = i - 1; break; } if (!MovementHelper.fullyPassable(context, destX, y + 2, destZ)) { - maxJump = i - 1; break; } + + // check for ascend landing position IBlockState destInto = context.bsi.get0(destX, y, destZ); if (!MovementHelper.fullyPassable(context.bsi.access, context.bsi.isPassableBlockPos.setPos(destX, y, destZ), destInto)) { if (i <= 3 && context.allowParkourAscend && context.canSprint && MovementHelper.canWalkOn(context.bsi, destX, y, destZ, destInto) && checkOvershootSafety(context.bsi, destX + xDiff, y + 1, destZ + zDiff)) { @@ -124,9 +130,10 @@ public class MovementParkour extends Movement { res.cost = i * SPRINT_ONE_BLOCK_COST + context.jumpPenalty; return; } - maxJump = i - 1; break; } + + // check for flat landing position IBlockState landingOn = context.bsi.get0(destX, y - 1, destZ); // farmland needs to be canWalkOn otherwise farm can never work at all, but we want to specifically disallow ending a jump on farmland haha if (landingOn.getBlock() != Blocks.FARMLAND && MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, landingOn)) { @@ -137,20 +144,23 @@ public class MovementParkour extends Movement { res.cost = costFromJumpDistance(i) + context.jumpPenalty; return; } - maxJump = i - 1; break; } + if (!MovementHelper.fullyPassable(context, destX, y + 3, destZ)) { - maxJump = i - 1; break; } + + // reset verifiedMaxJump so that if we exit out of the for loop here it is not changed + verifiedMaxJump = maxJump; } + // parkour place starts here if (!context.allowParkourPlace) { return; } - // check parkour jumps from largest to smallest - for (int i = maxJump; i > 1; i--) { + // check parkour jumps from largest to smallest for positions to place blocks + for (int i = verifiedMaxJump; i > 1; i--) { int destX = x + i * xDiff; int destZ = z + i * zDiff; IBlockState toReplace = context.get(destX, y - 1, destZ); From 335cb7016e11eb232fa5bab502c4a8201c955416 Mon Sep 17 00:00:00 2001 From: Harry Date: Sat, 17 Jul 2021 13:28:12 +1000 Subject: [PATCH 111/155] fix verifiedMaxJump - remove redundant assignment by changing some values - testing Co-Authors Co-Authored-By: Leijurv --- .../pathing/movement/movements/MovementParkour.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 416c90725..e5d17b9ac 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -106,9 +106,8 @@ public class MovementParkour extends Movement { } // check parkour jumps from smallest to largest for obstacles/walls and landing positions - int verifiedMaxJump = -1; + int verifiedMaxJump = 1; // i - 1 (when i = 2) for (int i = 2; i <= maxJump; i++) { - verifiedMaxJump = i - 1; int destX = x + xDiff * i; int destZ = z + zDiff * i; @@ -151,8 +150,7 @@ public class MovementParkour extends Movement { break; } - // reset verifiedMaxJump so that if we exit out of the for loop here it is not changed - verifiedMaxJump = maxJump; + verifiedMaxJump = i; } // parkour place starts here From c3085ae34ff3b1be995407d8d408b7d137ec0309 Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Sun, 18 Jul 2021 18:37:20 +0100 Subject: [PATCH 112/155] Fix proguard Signed-off-by: scorbett123 <50634068+scorbett123@users.noreply.github.com> --- scripts/proguard.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/proguard.pro b/scripts/proguard.pro index ce92b30aa..9adc5174c 100644 --- a/scripts/proguard.pro +++ b/scripts/proguard.pro @@ -81,7 +81,7 @@ -libraryjars 'tempLibraries/netty-all-4.1.9.Final.jar' -libraryjars 'tempLibraries/oshi-core-1.1.jar' --libraryjars 'tempLibraries/patchy-1.1.jar' +-libraryjars 'tempLibraries/patchy-1.2.jar' -libraryjars 'tempLibraries/platform-3.4.0.jar' -libraryjars 'tempLibraries/realms-1.10.22.jar' -libraryjars 'tempLibraries/soundsystem-20120107.jar' From 3db5f2a67fb5e10137f51e8039528dbc0893313a Mon Sep 17 00:00:00 2001 From: StylexTV <56502218+StylexTV@users.noreply.github.com> Date: Sun, 22 Aug 2021 10:28:42 +0200 Subject: [PATCH 113/155] Update GoalBlock.java --- src/api/java/baritone/api/pathing/goals/GoalBlock.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/pathing/goals/GoalBlock.java b/src/api/java/baritone/api/pathing/goals/GoalBlock.java index c85e5cadd..0b7ff3207 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalBlock.java +++ b/src/api/java/baritone/api/pathing/goals/GoalBlock.java @@ -89,7 +89,7 @@ public class GoalBlock implements Goal, IGoalRenderPos { // if yDiff is 1 that means that pos.getY()-this.y==1 which means that we're 1 block below where we should be // therefore going from 0,0,0 to a GoalYLevel of pos.getY()-this.y is accurate - heuristic += GoalYLevel.calculate(yDiff, 0); + heuristic += GoalYLevel.calculate(0, yDiff); //use the pythagorean and manhattan mixture from GoalXZ heuristic += GoalXZ.calculate(xDiff, zDiff); From 5e0fe6d89759854e98278a312542ad0c5f70cbe1 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 25 Aug 2021 22:18:23 -0700 Subject: [PATCH 114/155] fix the comment explaining the sign flip bug originates from august 17 2018 in https://github.com/cabaletta/baritone/commit/f3d9ada6750db5969ea70ef8d60259deb302acf4#diff-b9b328a67abb41c2f842f367f83d95a2793c95cba83ab2e4542b31ed4c157819R101-R103 absolutely wild how long this took to notice, see PR #2954 --- src/api/java/baritone/api/pathing/goals/GoalBlock.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/java/baritone/api/pathing/goals/GoalBlock.java b/src/api/java/baritone/api/pathing/goals/GoalBlock.java index 0b7ff3207..7a612deda 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalBlock.java +++ b/src/api/java/baritone/api/pathing/goals/GoalBlock.java @@ -87,8 +87,8 @@ public class GoalBlock implements Goal, IGoalRenderPos { public static double calculate(double xDiff, int yDiff, double zDiff) { double heuristic = 0; - // if yDiff is 1 that means that pos.getY()-this.y==1 which means that we're 1 block below where we should be - // therefore going from 0,0,0 to a GoalYLevel of pos.getY()-this.y is accurate + // if yDiff is 1 that means that pos.getY()-this.y==1 which means that we're 1 block above where we should be + // therefore going from 0,pos.getY()-this.y,0 to a GoalYLevel of 0 is accurate heuristic += GoalYLevel.calculate(0, yDiff); //use the pythagorean and manhattan mixture from GoalXZ From 14178fcd14f245a21da0240c3fa4b507a8a00446 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 25 Aug 2021 22:20:13 -0700 Subject: [PATCH 115/155] rewrite comment since we haven't used pos.getY() in literally YEARS --- src/api/java/baritone/api/pathing/goals/GoalBlock.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/java/baritone/api/pathing/goals/GoalBlock.java b/src/api/java/baritone/api/pathing/goals/GoalBlock.java index 7a612deda..bd339549b 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalBlock.java +++ b/src/api/java/baritone/api/pathing/goals/GoalBlock.java @@ -87,8 +87,8 @@ public class GoalBlock implements Goal, IGoalRenderPos { public static double calculate(double xDiff, int yDiff, double zDiff) { double heuristic = 0; - // if yDiff is 1 that means that pos.getY()-this.y==1 which means that we're 1 block above where we should be - // therefore going from 0,pos.getY()-this.y,0 to a GoalYLevel of 0 is accurate + // if yDiff is 1 that means that currentY-goalY==1 which means that we're 1 block above where we should be + // therefore going from 0,yDiff,0 to a GoalYLevel of 0 is accurate heuristic += GoalYLevel.calculate(0, yDiff); //use the pythagorean and manhattan mixture from GoalXZ From 89c960c455cde2cdef747ff16ebe067fbf5f3696 Mon Sep 17 00:00:00 2001 From: wagyourtail Date: Fri, 8 Oct 2021 14:58:17 -0600 Subject: [PATCH 116/155] better follow command error handling --- .../command/defaults/FollowCommand.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/command/defaults/FollowCommand.java b/src/main/java/baritone/command/defaults/FollowCommand.java index a3df5387f..3374d223d 100644 --- a/src/main/java/baritone/command/defaults/FollowCommand.java +++ b/src/main/java/baritone/command/defaults/FollowCommand.java @@ -20,11 +20,15 @@ package baritone.command.defaults; import baritone.KeepName; import baritone.api.IBaritone; import baritone.api.command.Command; +import baritone.api.command.ICommand; import baritone.api.command.argument.IArgConsumer; +import baritone.api.command.argument.ICommandArgument; import baritone.api.command.datatypes.EntityClassById; import baritone.api.command.datatypes.IDatatypeFor; import baritone.api.command.datatypes.NearbyPlayer; +import baritone.api.command.exception.CommandErrorMessageException; import baritone.api.command.exception.CommandException; +import baritone.api.command.exception.CommandInvalidArgumentException; import baritone.api.command.helpers.TabCompleteHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; @@ -60,7 +64,7 @@ public class FollowCommand extends Command { if (gotten instanceof Class) { //noinspection unchecked classes.add((Class) gotten); - } else { + } else if (gotten != null) { entities.add((Entity) gotten); } } @@ -73,12 +77,14 @@ public class FollowCommand extends Command { if (group != null) { logDirect(String.format("Following all %s", group.name().toLowerCase(Locale.US))); } else { - logDirect("Following these types of entities:"); if (classes.isEmpty()) { + if (entities.isEmpty()) throw new NoEntitiesException(); + logDirect("Following these entities:"); entities.stream() .map(Entity::toString) .forEach(this::logDirect); } else { + logDirect("Following these types of entities:"); classes.stream() .map(EntityList::getKey) .map(Objects::requireNonNull) @@ -155,4 +161,12 @@ public class FollowCommand extends Command { this.datatype = datatype; } } + + public static class NoEntitiesException extends CommandErrorMessageException { + + protected NoEntitiesException() { + super("no valid entites in range!"); + } + + } } From ba0b5f929f07406bd8e710fd47b9809a6790d917 Mon Sep 17 00:00:00 2001 From: wagyourtail Date: Fri, 8 Oct 2021 15:49:22 -0600 Subject: [PATCH 117/155] cleanup --- src/main/java/baritone/command/defaults/FollowCommand.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/baritone/command/defaults/FollowCommand.java b/src/main/java/baritone/command/defaults/FollowCommand.java index 3374d223d..a6e7cc5b2 100644 --- a/src/main/java/baritone/command/defaults/FollowCommand.java +++ b/src/main/java/baritone/command/defaults/FollowCommand.java @@ -20,15 +20,12 @@ package baritone.command.defaults; import baritone.KeepName; import baritone.api.IBaritone; import baritone.api.command.Command; -import baritone.api.command.ICommand; import baritone.api.command.argument.IArgConsumer; -import baritone.api.command.argument.ICommandArgument; import baritone.api.command.datatypes.EntityClassById; import baritone.api.command.datatypes.IDatatypeFor; import baritone.api.command.datatypes.NearbyPlayer; import baritone.api.command.exception.CommandErrorMessageException; import baritone.api.command.exception.CommandException; -import baritone.api.command.exception.CommandInvalidArgumentException; import baritone.api.command.helpers.TabCompleteHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; @@ -165,7 +162,7 @@ public class FollowCommand extends Command { public static class NoEntitiesException extends CommandErrorMessageException { protected NoEntitiesException() { - super("no valid entites in range!"); + super("No valid entities in range!"); } } From 4dc4795cb703b3d6ebd2d1d6c06243efbeff7a5f Mon Sep 17 00:00:00 2001 From: wagyourtail Date: Fri, 15 Oct 2021 00:00:48 -0600 Subject: [PATCH 118/155] AvoidBreak means never. --- src/api/java/baritone/api/Settings.java | 5 +++++ src/main/java/baritone/utils/ToolSet.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 2d9ad3fb3..c8dc1b9e2 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -200,6 +200,11 @@ public final class Settings { Blocks.WALL_SIGN ))); + /** + * make {@link #blocksToAvoidBreaking} mean the block is never broken instead of just strongly discouraging it. + */ + public final Setting avoidBreakingMeansNever = new Setting(false); + /** * A list of blocks to be treated as if they're air. *

diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index e5e96e341..31046a875 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -165,7 +165,7 @@ public class ToolSet { } private double avoidanceMultiplier(Block b) { - return Baritone.settings().blocksToAvoidBreaking.value.contains(b) ? 0.1 : 1; + return Baritone.settings().blocksToAvoidBreaking.value.contains(b) ? Baritone.settings().avoidBreakingMeansNever.value ? 0 : 0.1 : 1; } /** From 1ca736692d889bf3ed2fbdd8225b84995724b824 Mon Sep 17 00:00:00 2001 From: wagyourtail Date: Fri, 15 Oct 2021 17:58:13 -0600 Subject: [PATCH 119/155] more closely match the existing docs and add discourageBreaking --- src/api/java/baritone/api/Settings.java | 11 +++++++++-- .../baritone/pathing/movement/MovementHelper.java | 3 ++- src/main/java/baritone/utils/ToolSet.java | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index c8dc1b9e2..7ca050cea 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -201,9 +201,16 @@ public final class Settings { ))); /** - * make {@link #blocksToAvoidBreaking} mean the block is never broken instead of just strongly discouraging it. + * blocks that baritone shouldn't break, but can if it needs to. */ - public final Setting avoidBreakingMeansNever = new Setting(false); + public final Setting> blocksToDiscourageBreaking = new Setting<>(new ArrayList<>(Arrays.asList( + + ))); + + /** + * this multiplies the break speed, if set above 1 it's "encourage breaking" instead + */ + public final Setting discourageBreakingMultiplier = new Setting<>(.1); /** * A list of blocks to be treated as if they're air. diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 69e846a2c..64528ddd6 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -50,7 +50,8 @@ public interface MovementHelper extends ActionCosts, Helper { static boolean avoidBreaking(BlockStateInterface bsi, int x, int y, int z, IBlockState state) { Block b = state.getBlock(); - return b == Blocks.ICE // ice becomes water, and water can mess up the path + return Baritone.settings().blocksToAvoidBreaking.value.contains(b) + || b == Blocks.ICE // ice becomes water, and water can mess up the path || b instanceof BlockSilverfish // obvious reasons // call context.get directly with x,y,z. no need to make 5 new BlockPos for no reason || avoidAdjacentBreaking(bsi, x, y + 1, z, true) diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index 31046a875..d99adbb3f 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -165,7 +165,7 @@ public class ToolSet { } private double avoidanceMultiplier(Block b) { - return Baritone.settings().blocksToAvoidBreaking.value.contains(b) ? Baritone.settings().avoidBreakingMeansNever.value ? 0 : 0.1 : 1; + return Baritone.settings().blocksToDiscourageBreaking.value.contains(b) ? Baritone.settings().discourageBreakingMultiplier.value : 1; } /** From 1b04386b01dee65d672d4d1c8861d875903c02d6 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sun, 17 Oct 2021 13:53:55 +0200 Subject: [PATCH 120/155] Allow saving unnamed waypoints by position --- src/main/java/baritone/command/defaults/WaypointsCommand.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/command/defaults/WaypointsCommand.java b/src/main/java/baritone/command/defaults/WaypointsCommand.java index 5d964da42..c07575185 100644 --- a/src/main/java/baritone/command/defaults/WaypointsCommand.java +++ b/src/main/java/baritone/command/defaults/WaypointsCommand.java @@ -129,7 +129,7 @@ public class WaypointsCommand extends Command { if (tag == null) { throw new CommandInvalidStateException(String.format("'%s' is not a tag ", args.consumedString())); } - String name = args.hasAny() ? args.getString() : ""; + String name = (args.hasExactlyOne() || args.hasExactly(4)) ? args.getString() : ""; BetterBlockPos pos = args.hasAny() ? args.getDatatypePost(RelativeBlockPos.INSTANCE, ctx.playerFeet()) : ctx.playerFeet(); @@ -292,6 +292,7 @@ public class WaypointsCommand extends Command { "Usage:", "> wp [l/list] - List all waypoints.", "> wp - Save your current position as an unnamed waypoint with the specified tag.", + "> wp - Save an unnamed waypoint with the specified tag and position.", "> wp - Save the waypoint with the specified name.", "> wp - Save the waypoint with the specified name and position.", "> wp - Show info on a waypoint by tag.", From 3e69281d61e9920ef5e11c6651412dde21afe903 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sun, 17 Oct 2021 14:06:07 +0200 Subject: [PATCH 121/155] Update usage of #waypoint It now properly reports when either a tag or name can be specified and includes the clear subcommand --- .../baritone/command/defaults/WaypointsCommand.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/command/defaults/WaypointsCommand.java b/src/main/java/baritone/command/defaults/WaypointsCommand.java index c07575185..c484a5ec2 100644 --- a/src/main/java/baritone/command/defaults/WaypointsCommand.java +++ b/src/main/java/baritone/command/defaults/WaypointsCommand.java @@ -291,14 +291,16 @@ public class WaypointsCommand extends Command { "", "Usage:", "> wp [l/list] - List all waypoints.", + "> wp - List all waypoints by tag.", "> wp - Save your current position as an unnamed waypoint with the specified tag.", "> wp - Save an unnamed waypoint with the specified tag and position.", "> wp - Save the waypoint with the specified name.", "> wp - Save the waypoint with the specified name and position.", - "> wp - Show info on a waypoint by tag.", - "> wp - Delete a waypoint by tag.", - "> wp - Set a goal to a waypoint by tag.", - "> wp - Set a goal to a waypoint by tag and start pathing." + "> wp - Show info on a waypoint by tag or name.", + "> wp - Delete a waypoint by tag or name.", + "> wp - Delete all waypoints with the specified tag.", + "> wp - Set a goal to a waypoint by tag or name.", + "> wp - Set a goal to a waypoint by tag or name and start pathing." ); } From 3b480dabdb628fdd025406bdf30fee44ef6c0df0 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sun, 17 Oct 2021 14:47:03 +0200 Subject: [PATCH 122/155] Make the tag argument optional, defaulting to USER Listing all possible combinations in the usage as done before would have beed 8 lines just for the save command so I made it one special case, one combined line and a line explaining the defaults in the general waypoint help. Also tab completion does not work when omitting either tag or name, because it starting to tab complete a position right from the first argument would probably only cause confusion and would be harder to implement because of the variable start position (names can even be numbers so it's impossible to do it 100% correctly) --- .../command/defaults/WaypointsCommand.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/command/defaults/WaypointsCommand.java b/src/main/java/baritone/command/defaults/WaypointsCommand.java index c484a5ec2..a90828ba9 100644 --- a/src/main/java/baritone/command/defaults/WaypointsCommand.java +++ b/src/main/java/baritone/command/defaults/WaypointsCommand.java @@ -125,9 +125,11 @@ public class WaypointsCommand extends Command { ); } } else if (action == Action.SAVE) { - IWaypoint.Tag tag = IWaypoint.Tag.getByName(args.getString()); + IWaypoint.Tag tag = args.hasAny() ? IWaypoint.Tag.getByName(args.peekString()) : null; if (tag == null) { - throw new CommandInvalidStateException(String.format("'%s' is not a tag ", args.consumedString())); + tag = IWaypoint.Tag.USER; + } else { + args.get(); } String name = (args.hasExactlyOne() || args.hasExactly(4)) ? args.getString() : ""; BetterBlockPos pos = args.hasAny() @@ -289,13 +291,13 @@ public class WaypointsCommand extends Command { "", "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.", "", + "Missing arguments for the save command use the USER tag, creating an unnamed waypoint and your current position as defaults.", + "", "Usage:", "> wp [l/list] - List all waypoints.", "> wp - List all waypoints by tag.", - "> wp - Save your current position as an unnamed waypoint with the specified tag.", - "> wp - Save an unnamed waypoint with the specified tag and position.", - "> wp - Save the waypoint with the specified name.", - "> wp - Save the waypoint with the specified name and position.", + "> wp - Save an unnamed USER waypoint at your current position", + "> wp [tag] [name] [pos] - Save a waypoint with the specified tag, name and position.", "> wp - Show info on a waypoint by tag or name.", "> wp - Delete a waypoint by tag or name.", "> wp - Delete all waypoints with the specified tag.", From 6669d49636ee29903f52f36af047bb0dca0f91d2 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sun, 17 Oct 2021 15:03:27 +0200 Subject: [PATCH 123/155] Add a way to get the creation command for a waypoint --- .../command/defaults/WaypointsCommand.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/baritone/command/defaults/WaypointsCommand.java b/src/main/java/baritone/command/defaults/WaypointsCommand.java index a90828ba9..e3cd9fcc1 100644 --- a/src/main/java/baritone/command/defaults/WaypointsCommand.java +++ b/src/main/java/baritone/command/defaults/WaypointsCommand.java @@ -17,6 +17,7 @@ package baritone.command.defaults; +import baritone.Baritone; import baritone.api.IBaritone; import baritone.api.cache.IWaypoint; import baritone.api.cache.Waypoint; @@ -218,6 +219,20 @@ public class WaypointsCommand extends Command { waypoint.getCreationTimestamp() ) )); + ITextComponent recreateComponent = new TextComponentString("Click to show a command to recreate this waypoint"); + recreateComponent.getStyle().setClickEvent(new ClickEvent( + ClickEvent.Action.SUGGEST_COMMAND, + String.format( + "%s%s save %s %s %s %s %s", + Baritone.settings().prefix.value, // This uses the normal prefix because it is run by the user. + label, + waypoint.getTag().getName(), + waypoint.getName(), + waypoint.getLocation().x, + waypoint.getLocation().y, + waypoint.getLocation().z + ) + )); ITextComponent backComponent = new TextComponentString("Click to return to the waypoints list"); backComponent.getStyle().setClickEvent(new ClickEvent( ClickEvent.Action.RUN_COMMAND, @@ -229,6 +244,7 @@ public class WaypointsCommand extends Command { )); logDirect(deleteComponent); logDirect(goalComponent); + logDirect(recreateComponent); logDirect(backComponent); } else if (action == Action.DELETE) { ForWaypoints.waypoints(this.baritone).removeWaypoint(waypoint); From c8966d22baaadcd1e380bef2bc6eb0a5231bf481 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sun, 17 Oct 2021 23:44:21 +0200 Subject: [PATCH 124/155] Don't create a new waypoint every time a bed is clicked. Just the first time and always for the head part. --- .../java/baritone/behavior/MemoryBehavior.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/behavior/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java index b7d31223a..ee8bf0e43 100644 --- a/src/main/java/baritone/behavior/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/MemoryBehavior.java @@ -18,6 +18,7 @@ package baritone.behavior; import baritone.Baritone; +import baritone.api.cache.IWaypoint; import baritone.api.cache.Waypoint; import baritone.api.event.events.BlockInteractEvent; import baritone.api.event.events.PacketEvent; @@ -30,6 +31,7 @@ import baritone.cache.ContainerMemory; import baritone.utils.BlockStateInterface; import net.minecraft.block.Block; import net.minecraft.block.BlockBed; +import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.network.Packet; @@ -167,8 +169,19 @@ public final class MemoryBehavior extends Behavior { @Override public void onBlockInteract(BlockInteractEvent event) { - if (event.getType() == BlockInteractEvent.Type.USE && BlockStateInterface.getBlock(ctx, event.getPos()) instanceof BlockBed) { - baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("bed", Waypoint.Tag.BED, BetterBlockPos.from(event.getPos()))); + if (event.getType() == BlockInteractEvent.Type.USE) { + BetterBlockPos pos = BetterBlockPos.from(event.getPos()); + IBlockState state = BlockStateInterface.get(ctx, pos); + if (state.getBlock() instanceof BlockBed) { + if (state.getValue(BlockBed.PART) == BlockBed.EnumPartType.FOOT) { + pos = pos.offset(state.getValue(BlockBed.FACING)); + } + Set waypoints = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getByTag(IWaypoint.Tag.BED); + boolean exists = waypoints.stream().map(IWaypoint::getLocation).filter(pos::equals).findFirst().isPresent(); + if (!exists) { + baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("bed", Waypoint.Tag.BED, pos)); + } + } } } From 3244b102ad4476b50274226c2df0d3709ed7d7ce Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Mon, 18 Oct 2021 02:42:58 +0200 Subject: [PATCH 125/155] Add a way to restore deleted waypoints Makes using the clickable text less dangerous when there are others writing in chat. --- .../command/defaults/WaypointsCommand.java | 56 ++++++++++++++++++- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/command/defaults/WaypointsCommand.java b/src/main/java/baritone/command/defaults/WaypointsCommand.java index e3cd9fcc1..727d24af6 100644 --- a/src/main/java/baritone/command/defaults/WaypointsCommand.java +++ b/src/main/java/baritone/command/defaults/WaypointsCommand.java @@ -42,12 +42,15 @@ import net.minecraft.util.text.event.HoverEvent; import java.util.*; import java.util.function.BiFunction; import java.util.function.Function; +import java.util.stream.Collectors; import java.util.stream.Stream; import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX; public class WaypointsCommand extends Command { + private List deletedWaypoints = new ArrayList<>(); + public WaypointsCommand(IBaritone baritone) { super(baritone, "waypoints", "waypoint", "wp"); } @@ -150,7 +153,41 @@ public class WaypointsCommand extends Command { for (IWaypoint waypoint : waypoints) { ForWaypoints.waypoints(this.baritone).removeWaypoint(waypoint); } - logDirect(String.format("Cleared %d waypoints", waypoints.length)); + deletedWaypoints.addAll(Arrays.asList(waypoints)); + ITextComponent textComponent = new TextComponentString(String.format("Cleared %d waypoints, click to restore them", waypoints.length)); + textComponent.getStyle().setClickEvent(new ClickEvent( + ClickEvent.Action.RUN_COMMAND, + String.format( + "%s%s restore @ %s", + FORCE_COMMAND_PREFIX, + label, + Stream.of(waypoints).map(wp -> Long.toString(wp.getCreationTimestamp())).collect(Collectors.joining(" ")) + ) + )); + logDirect(textComponent); + } else if (action == Action.RESTORE) { + List waypoints = new ArrayList<>(); + if (args.peekString().equals("@")) { + args.get(); + // no args.requireMin(1) because if the user clears an empty tag there is nothing to restore + while (args.hasAny()) { + long timestamp = args.getAs(Long.class); + for (IWaypoint waypoint : deletedWaypoints) { + if (waypoint.getCreationTimestamp() == timestamp) { + waypoints.add(waypoint); + break; + } + } + } + } else { + args.requireExactly(1); + int size = deletedWaypoints.size(); + int amount = Math.min(size, args.getAs(Integer.class)); + waypoints = new ArrayList<>(deletedWaypoints.subList(size - amount, size)); + } + waypoints.forEach(ForWaypoints.waypoints(this.baritone)::addWaypoint); + deletedWaypoints.removeIf(waypoints::contains); + logDirect(String.format("Restored %d waypoints", waypoints.size())); } else { IWaypoint[] waypoints = args.getDatatypeFor(ForWaypoints.INSTANCE); IWaypoint waypoint = null; @@ -248,7 +285,18 @@ public class WaypointsCommand extends Command { logDirect(backComponent); } else if (action == Action.DELETE) { ForWaypoints.waypoints(this.baritone).removeWaypoint(waypoint); - logDirect("That waypoint has successfully been deleted"); + deletedWaypoints.add(waypoint); + ITextComponent textComponent = new TextComponentString("That waypoint has successfully been deleted, click to restore it"); + textComponent.getStyle().setClickEvent(new ClickEvent( + ClickEvent.Action.RUN_COMMAND, + String.format( + "%s%s restore @ %s", + FORCE_COMMAND_PREFIX, + label, + waypoint.getCreationTimestamp() + ) + )); + logDirect(textComponent); } else if (action == Action.GOAL) { Goal goal = new GoalBlock(waypoint.getLocation()); baritone.getCustomGoalProcess().setGoal(goal); @@ -280,6 +328,8 @@ public class WaypointsCommand extends Command { .sortAlphabetically() .filterPrefix(args.getString()) .stream(); + } else if (action == Action.RESTORE) { + return Stream.empty(); } else { return args.tabCompleteDatatype(ForWaypoints.INSTANCE); } @@ -316,6 +366,7 @@ public class WaypointsCommand extends Command { "> wp [tag] [name] [pos] - Save a waypoint with the specified tag, name and position.", "> wp - Show info on a waypoint by tag or name.", "> wp - Delete a waypoint by tag or name.", + "> wp - Restore the last n deleted waypoints.", "> wp - Delete all waypoints with the specified tag.", "> wp - Set a goal to a waypoint by tag or name.", "> wp - Set a goal to a waypoint by tag or name and start pathing." @@ -328,6 +379,7 @@ public class WaypointsCommand extends Command { SAVE("save", "s"), INFO("info", "show", "i"), DELETE("delete", "d"), + RESTORE("restore"), GOAL("goal", "g"), GOTO("goto"); private final String[] names; From 724162f37f1489bbdfd8b6220facd8e83b4c1b2f Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Tue, 19 Oct 2021 01:17:23 +0200 Subject: [PATCH 126/155] Store deleted waypoints per world Different dimensions are actually different worlds and the user might expect the wapoints to be restorable until they leave the server, so discrading them when the world changes would be too early. --- .../java/baritone/command/defaults/WaypointsCommand.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/command/defaults/WaypointsCommand.java b/src/main/java/baritone/command/defaults/WaypointsCommand.java index 727d24af6..5a45686a3 100644 --- a/src/main/java/baritone/command/defaults/WaypointsCommand.java +++ b/src/main/java/baritone/command/defaults/WaypointsCommand.java @@ -21,6 +21,7 @@ import baritone.Baritone; import baritone.api.IBaritone; import baritone.api.cache.IWaypoint; import baritone.api.cache.Waypoint; +import baritone.api.cache.IWorldData; import baritone.api.command.Command; import baritone.api.command.argument.IArgConsumer; import baritone.api.command.datatypes.ForWaypoints; @@ -49,7 +50,7 @@ import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX; public class WaypointsCommand extends Command { - private List deletedWaypoints = new ArrayList<>(); + private Map> deletedWaypoints = new HashMap<>(); public WaypointsCommand(IBaritone baritone) { super(baritone, "waypoints", "waypoint", "wp"); @@ -153,7 +154,7 @@ public class WaypointsCommand extends Command { for (IWaypoint waypoint : waypoints) { ForWaypoints.waypoints(this.baritone).removeWaypoint(waypoint); } - deletedWaypoints.addAll(Arrays.asList(waypoints)); + deletedWaypoints.computeIfAbsent(baritone.getWorldProvider().getCurrentWorld(), k -> new ArrayList<>()).addAll(Arrays.asList(waypoints)); ITextComponent textComponent = new TextComponentString(String.format("Cleared %d waypoints, click to restore them", waypoints.length)); textComponent.getStyle().setClickEvent(new ClickEvent( ClickEvent.Action.RUN_COMMAND, @@ -167,6 +168,7 @@ public class WaypointsCommand extends Command { logDirect(textComponent); } else if (action == Action.RESTORE) { List waypoints = new ArrayList<>(); + List deletedWaypoints = this.deletedWaypoints.getOrDefault(baritone.getWorldProvider().getCurrentWorld(), Collections.emptyList()); if (args.peekString().equals("@")) { args.get(); // no args.requireMin(1) because if the user clears an empty tag there is nothing to restore @@ -285,7 +287,7 @@ public class WaypointsCommand extends Command { logDirect(backComponent); } else if (action == Action.DELETE) { ForWaypoints.waypoints(this.baritone).removeWaypoint(waypoint); - deletedWaypoints.add(waypoint); + deletedWaypoints.computeIfAbsent(baritone.getWorldProvider().getCurrentWorld(), k -> new ArrayList<>()).add(waypoint); ITextComponent textComponent = new TextComponentString("That waypoint has successfully been deleted, click to restore it"); textComponent.getStyle().setClickEvent(new ClickEvent( ClickEvent.Action.RUN_COMMAND, From 1c27b9b71238395fa4f833ee2e280662422fcd0f Mon Sep 17 00:00:00 2001 From: wagyourtail Date: Tue, 26 Oct 2021 13:34:10 -0600 Subject: [PATCH 127/155] Update src/api/java/baritone/api/Settings.java --- src/api/java/baritone/api/Settings.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 7ca050cea..0f829c9e3 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -204,7 +204,6 @@ public final class Settings { * blocks that baritone shouldn't break, but can if it needs to. */ public final Setting> blocksToDiscourageBreaking = new Setting<>(new ArrayList<>(Arrays.asList( - ))); /** From 084798bd1b766d8f08329c1d1142b769a42737be Mon Sep 17 00:00:00 2001 From: wagyourtail Date: Tue, 26 Oct 2021 13:41:24 -0600 Subject: [PATCH 128/155] Update src/api/java/baritone/api/Settings.java --- src/api/java/baritone/api/Settings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 0f829c9e3..4c32d537f 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -203,7 +203,7 @@ public final class Settings { /** * blocks that baritone shouldn't break, but can if it needs to. */ - public final Setting> blocksToDiscourageBreaking = new Setting<>(new ArrayList<>(Arrays.asList( + public final Setting> blocksToDiscourageBreaking = new Setting<>(new ArrayList<>(Arrays.asList( ))); /** From 2980bb03205df8566661346c28055cda2a71f5bc Mon Sep 17 00:00:00 2001 From: Wagyourtail Date: Wed, 27 Oct 2021 13:45:30 -0600 Subject: [PATCH 129/155] match leij's backwards compat suggestion --- src/api/java/baritone/api/Settings.java | 23 ++++++++++--------- .../pathing/movement/MovementHelper.java | 2 +- src/main/java/baritone/utils/ToolSet.java | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 4c32d537f..2af87de14 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -190,26 +190,27 @@ public final class Settings { /** * Blocks that Baritone is not allowed to break */ - public final Setting> blocksToAvoidBreaking = new Setting<>(new ArrayList<>(Arrays.asList( // TODO can this be a HashSet or ImmutableSet? - Blocks.CRAFTING_TABLE, - Blocks.FURNACE, - Blocks.LIT_FURNACE, - Blocks.CHEST, - Blocks.TRAPPED_CHEST, - Blocks.STANDING_SIGN, - Blocks.WALL_SIGN - ))); + public final Setting> blocksToDisallowBreaking = new Setting<>(new ArrayList<>( + // Leave Empty by Default + )); /** * blocks that baritone shouldn't break, but can if it needs to. */ - public final Setting> blocksToDiscourageBreaking = new Setting<>(new ArrayList<>(Arrays.asList( + public final Setting> blocksToAvoidBreaking = new Setting<>(new ArrayList<>(Arrays.asList( // TODO can this be a HashSet or ImmutableSet? + Blocks.CRAFTING_TABLE, + Blocks.FURNACE, + Blocks.LIT_FURNACE, + Blocks.CHEST, + Blocks.TRAPPED_CHEST, + Blocks.STANDING_SIGN, + Blocks.WALL_SIGN ))); /** * this multiplies the break speed, if set above 1 it's "encourage breaking" instead */ - public final Setting discourageBreakingMultiplier = new Setting<>(.1); + public final Setting avoidBreakingMultiplier = new Setting<>(.1); /** * A list of blocks to be treated as if they're air. diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 64528ddd6..f5f565e39 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -50,7 +50,7 @@ public interface MovementHelper extends ActionCosts, Helper { static boolean avoidBreaking(BlockStateInterface bsi, int x, int y, int z, IBlockState state) { Block b = state.getBlock(); - return Baritone.settings().blocksToAvoidBreaking.value.contains(b) + return Baritone.settings().blocksToDisallowBreaking.value.contains(b) || b == Blocks.ICE // ice becomes water, and water can mess up the path || b instanceof BlockSilverfish // obvious reasons // call context.get directly with x,y,z. no need to make 5 new BlockPos for no reason diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index d99adbb3f..4d17b4ea1 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -165,7 +165,7 @@ public class ToolSet { } private double avoidanceMultiplier(Block b) { - return Baritone.settings().blocksToDiscourageBreaking.value.contains(b) ? Baritone.settings().discourageBreakingMultiplier.value : 1; + return Baritone.settings().blocksToAvoidBreaking.value.contains(b) ? Baritone.settings().avoidBreakingMultiplier.value : 1; } /** From 9dc9edbbee8ca571773cfc296f167a2ad07b0198 Mon Sep 17 00:00:00 2001 From: Wagyourtail Date: Wed, 27 Oct 2021 13:53:13 -0600 Subject: [PATCH 130/155] fix tabbing --- src/api/java/baritone/api/Settings.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 2af87de14..a3147292e 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -198,13 +198,13 @@ public final class Settings { * blocks that baritone shouldn't break, but can if it needs to. */ public final Setting> blocksToAvoidBreaking = new Setting<>(new ArrayList<>(Arrays.asList( // TODO can this be a HashSet or ImmutableSet? - Blocks.CRAFTING_TABLE, - Blocks.FURNACE, - Blocks.LIT_FURNACE, - Blocks.CHEST, - Blocks.TRAPPED_CHEST, - Blocks.STANDING_SIGN, - Blocks.WALL_SIGN + Blocks.CRAFTING_TABLE, + Blocks.FURNACE, + Blocks.LIT_FURNACE, + Blocks.CHEST, + Blocks.TRAPPED_CHEST, + Blocks.STANDING_SIGN, + Blocks.WALL_SIGN ))); /** From 21534d1c0bafb5d27dadb97ae1144a54e9a2d19f Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Thu, 18 Nov 2021 00:21:12 +0100 Subject: [PATCH 131/155] Fix chat error messages being obfuscated for block type arguments --- scripts/proguard.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/proguard.pro b/scripts/proguard.pro index 9adc5174c..6f797771f 100644 --- a/scripts/proguard.pro +++ b/scripts/proguard.pro @@ -22,6 +22,7 @@ -keep class baritone.api.IBaritoneProvider -keep class baritone.api.utils.MyChunkPos { *; } # even in standalone we need to keep this for gson reflect +-keepname class baritone.api.utils.BlockOptionalMeta # this name is exposed to the user, so we need to keep it in all builds # Keep any class or member annotated with @KeepName so we dont have to put everything in the script -keep,allowobfuscation @interface baritone.KeepName From 04802fbb15b3cb59cf6470d17cc47211b7352fd8 Mon Sep 17 00:00:00 2001 From: wagyourtail Date: Sun, 5 Dec 2021 22:54:37 -0700 Subject: [PATCH 132/155] LEIJURV STOP BEING LAZY --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 85f3bf84e..42733fbd4 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,10 @@ For 1.15.2, [click here](https://www.youtube.com/watch?v=j1qKtCZFURM) and see de For 1.16.5, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. If you need Forge or Fabric 1.16.5, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.6.3) and get the `api-forge` or `api-fabric` jar. **For 1.16.5 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.6.3/baritone-api-fabric-1.6.3.jar)**. +For 1.17.1 leijurv is to lazy to actually create a release so you can login to github and download the jars in the `artifacts` zip [here](https://github.com/cabaletta/baritone/actions/runs/1451572684) + +For 1.18.1 leijurv is to lazy to actually create a release so you can login to github and download the jars in the `artifacts` zip [here](https://github.com/cabaletta/baritone/actions/runs/1472825778) + This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/), the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 through 1.16.5. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). From 90fcffdf2a5f12c028dc9059f109d0cbbae5276b Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Sun, 12 Dec 2021 19:50:27 +0000 Subject: [PATCH 133/155] Remove container memory Signed-off-by: scorbett123 <50634068+scorbett123@users.noreply.github.com> --- src/api/java/baritone/api/Settings.java | 7 - .../baritone/api/cache/IContainerMemory.java | 44 --- .../api/cache/IRememberedInventory.java | 39 -- .../java/baritone/api/cache/IWorldData.java | 5 - src/main/java/baritone/Baritone.java | 6 - .../baritone/behavior/MemoryBehavior.java | 332 ------------------ .../java/baritone/cache/ContainerMemory.java | 183 ---------- src/main/java/baritone/cache/WorldData.java | 17 - .../command/defaults/ChestsCommand.java | 83 ----- .../command/defaults/DefaultCommands.java | 1 - 10 files changed, 717 deletions(-) delete mode 100644 src/api/java/baritone/api/cache/IContainerMemory.java delete mode 100644 src/api/java/baritone/api/cache/IRememberedInventory.java delete mode 100644 src/main/java/baritone/behavior/MemoryBehavior.java delete mode 100644 src/main/java/baritone/cache/ContainerMemory.java delete mode 100644 src/main/java/baritone/command/defaults/ChestsCommand.java diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index a3147292e..5611a4f93 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -555,13 +555,6 @@ public final class Settings { */ public final Setting pruneRegionsFromRAM = new Setting<>(true); - /** - * Remember the contents of containers (chests, echests, furnaces) - *

- * Really buggy since the packet stuff is multithreaded badly thanks to brady - */ - public final Setting containerMemory = new Setting<>(false); - /** * Fill in blocks behind you */ diff --git a/src/api/java/baritone/api/cache/IContainerMemory.java b/src/api/java/baritone/api/cache/IContainerMemory.java deleted file mode 100644 index 5c19d43b9..000000000 --- a/src/api/java/baritone/api/cache/IContainerMemory.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Baritone is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Baritone. If not, see . - */ - -package baritone.api.cache; - -import net.minecraft.util.math.BlockPos; - -import java.util.Map; - -/** - * @author Brady - * @since 9/23/2018 - */ -public interface IContainerMemory { - - /** - * Gets a remembered inventory by its block position. - * - * @param pos The position of the container block - * @return The remembered inventory - */ - IRememberedInventory getInventoryByPos(BlockPos pos); - - /** - * Gets the map of all block positions to their remembered inventories. - * - * @return Map of block positions to their respective remembered inventories - */ - Map getRememberedInventories(); -} diff --git a/src/api/java/baritone/api/cache/IRememberedInventory.java b/src/api/java/baritone/api/cache/IRememberedInventory.java deleted file mode 100644 index a7890fe3a..000000000 --- a/src/api/java/baritone/api/cache/IRememberedInventory.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Baritone is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Baritone. If not, see . - */ - -package baritone.api.cache; - -import net.minecraft.item.ItemStack; - -import java.util.List; - -/** - * @author Brady - * @since 9/23/2018 - */ -public interface IRememberedInventory { - - /** - * @return The contents of this inventory - */ - List getContents(); - - /** - * @return The number of slots in this inventory - */ - int getSize(); -} diff --git a/src/api/java/baritone/api/cache/IWorldData.java b/src/api/java/baritone/api/cache/IWorldData.java index 1eaade4c0..200771935 100644 --- a/src/api/java/baritone/api/cache/IWorldData.java +++ b/src/api/java/baritone/api/cache/IWorldData.java @@ -37,9 +37,4 @@ public interface IWorldData { */ IWaypointCollection getWaypoints(); - /** - * @return The {@link IContainerMemory} instance - * @see IContainerMemory - */ - IContainerMemory getContainerMemory(); } diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index d03953fd9..82451514f 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -68,7 +68,6 @@ public class Baritone implements IBaritone { private PathingBehavior pathingBehavior; private LookBehavior lookBehavior; - private MemoryBehavior memoryBehavior; private InventoryBehavior inventoryBehavior; private InputOverrideHandler inputOverrideHandler; @@ -100,7 +99,6 @@ public class Baritone implements IBaritone { // the Behavior constructor calls baritone.registerBehavior(this) so this populates the behaviors arraylist pathingBehavior = new PathingBehavior(this); lookBehavior = new LookBehavior(this); - memoryBehavior = new MemoryBehavior(this); inventoryBehavior = new InventoryBehavior(this); inputOverrideHandler = new InputOverrideHandler(this); } @@ -151,10 +149,6 @@ public class Baritone implements IBaritone { return this.playerContext; } - public MemoryBehavior getMemoryBehavior() { - return this.memoryBehavior; - } - @Override public FollowProcess getFollowProcess() { return this.followProcess; diff --git a/src/main/java/baritone/behavior/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java deleted file mode 100644 index ee8bf0e43..000000000 --- a/src/main/java/baritone/behavior/MemoryBehavior.java +++ /dev/null @@ -1,332 +0,0 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Baritone is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Baritone. If not, see . - */ - -package baritone.behavior; - -import baritone.Baritone; -import baritone.api.cache.IWaypoint; -import baritone.api.cache.Waypoint; -import baritone.api.event.events.BlockInteractEvent; -import baritone.api.event.events.PacketEvent; -import baritone.api.event.events.PlayerUpdateEvent; -import baritone.api.event.events.TickEvent; -import baritone.api.event.events.type.EventState; -import baritone.api.utils.BetterBlockPos; -import baritone.api.utils.Helper; -import baritone.cache.ContainerMemory; -import baritone.utils.BlockStateInterface; -import net.minecraft.block.Block; -import net.minecraft.block.BlockBed; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.network.Packet; -import net.minecraft.network.play.client.CPacketCloseWindow; -import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock; -import net.minecraft.network.play.server.SPacketCloseWindow; -import net.minecraft.network.play.server.SPacketOpenWindow; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityLockable; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextComponentTranslation; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.util.text.event.ClickEvent; -import net.minecraft.util.text.event.HoverEvent; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.*; - -import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX; - -/** - * doesn't work for horse inventories :^) - * - * @author Brady - * @since 8/6/2018 - */ -public final class MemoryBehavior extends Behavior { - - private final List futureInventories = new ArrayList<>(); // this is per-bot - - private Integer enderChestWindowId; // nae nae - - public MemoryBehavior(Baritone baritone) { - super(baritone); - } - - @Override - public synchronized void onTick(TickEvent event) { - if (!Baritone.settings().containerMemory.value) { - return; - } - if (event.getType() == TickEvent.Type.OUT) { - enderChestWindowId = null; - futureInventories.clear(); - } - } - - @Override - public synchronized void onPlayerUpdate(PlayerUpdateEvent event) { - if (event.getState() == EventState.PRE) { - updateInventory(); - } - } - - @Override - public synchronized void onSendPacket(PacketEvent event) { - if (!Baritone.settings().containerMemory.value) { - return; - } - Packet p = event.getPacket(); - - if (event.getState() == EventState.PRE) { - if (p instanceof CPacketPlayerTryUseItemOnBlock) { - CPacketPlayerTryUseItemOnBlock packet = event.cast(); - - TileEntity tileEntity = ctx.world().getTileEntity(packet.getPos()); - // if tileEntity is an ender chest, we don't need to do anything. ender chests are treated the same regardless of what coordinate right clicked - - // Ensure the TileEntity is a container of some sort - if (tileEntity instanceof TileEntityLockable) { - - TileEntityLockable lockable = (TileEntityLockable) tileEntity; - int size = lockable.getSizeInventory(); - BetterBlockPos position = BetterBlockPos.from(tileEntity.getPos()); - BetterBlockPos adj = BetterBlockPos.from(neighboringConnectedBlock(position)); - System.out.println(position + " " + adj); - if (adj != null) { - size *= 2; // double chest or double trapped chest - if (adj.getX() < position.getX() || adj.getZ() < position.getZ()) { - position = adj; // standardize on the lower coordinate, regardless of which side of the large chest we right clicked - } - } - - this.futureInventories.add(new FutureInventory(System.nanoTime() / 1000000L, size, lockable.getGuiID(), position)); - } - } - - if (p instanceof CPacketCloseWindow) { - getCurrent().save(); - } - } - } - - @Override - public synchronized void onReceivePacket(PacketEvent event) { - if (!Baritone.settings().containerMemory.value) { - return; - } - Packet p = event.getPacket(); - - if (event.getState() == EventState.PRE) { - if (p instanceof SPacketOpenWindow) { - SPacketOpenWindow packet = event.cast(); - // Remove any entries that were created over a second ago, this should make up for INSANE latency - futureInventories.removeIf(i -> System.nanoTime() / 1000000L - i.time > 1000); - - System.out.println("Received packet " + packet.getGuiId() + " " + packet.getEntityId() + " " + packet.getSlotCount() + " " + packet.getWindowId()); - System.out.println(packet.getWindowTitle()); - if (packet.getWindowTitle() instanceof TextComponentTranslation && ((TextComponentTranslation) packet.getWindowTitle()).getKey().equals("container.enderchest")) { - // title is not customized (i.e. this isn't just a renamed shulker) - enderChestWindowId = packet.getWindowId(); - return; - } - futureInventories.stream() - .filter(i -> i.type.equals(packet.getGuiId()) && i.slots == packet.getSlotCount()) - .findFirst().ifPresent(matched -> { - // Remove the future inventory - futureInventories.remove(matched); - - // Setup the remembered inventory - getCurrentContainer().setup(matched.pos, packet.getWindowId(), packet.getSlotCount()); - }); - } - - if (p instanceof SPacketCloseWindow) { - getCurrent().save(); - } - } - } - - @Override - public void onBlockInteract(BlockInteractEvent event) { - if (event.getType() == BlockInteractEvent.Type.USE) { - BetterBlockPos pos = BetterBlockPos.from(event.getPos()); - IBlockState state = BlockStateInterface.get(ctx, pos); - if (state.getBlock() instanceof BlockBed) { - if (state.getValue(BlockBed.PART) == BlockBed.EnumPartType.FOOT) { - pos = pos.offset(state.getValue(BlockBed.FACING)); - } - Set waypoints = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getByTag(IWaypoint.Tag.BED); - boolean exists = waypoints.stream().map(IWaypoint::getLocation).filter(pos::equals).findFirst().isPresent(); - if (!exists) { - baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("bed", Waypoint.Tag.BED, pos)); - } - } - } - } - - @Override - public void onPlayerDeath() { - Waypoint deathWaypoint = new Waypoint("death", Waypoint.Tag.DEATH, ctx.playerFeet()); - baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(deathWaypoint); - ITextComponent component = new TextComponentString("Death position saved."); - component.getStyle() - .setColor(TextFormatting.WHITE) - .setHoverEvent(new HoverEvent( - HoverEvent.Action.SHOW_TEXT, - new TextComponentString("Click to goto death") - )) - .setClickEvent(new ClickEvent( - ClickEvent.Action.RUN_COMMAND, - String.format( - "%s%s goto %s @ %d", - FORCE_COMMAND_PREFIX, - "wp", - deathWaypoint.getTag().getName(), - deathWaypoint.getCreationTimestamp() - ) - )); - Helper.HELPER.logDirect(component); - } - - - private void updateInventory() { - if (!Baritone.settings().containerMemory.value) { - return; - } - int windowId = ctx.player().openContainer.windowId; - if (enderChestWindowId != null) { - if (windowId == enderChestWindowId) { - getCurrent().contents = ctx.player().openContainer.getInventory().subList(0, 27); - } else { - getCurrent().save(); - enderChestWindowId = null; - } - } - if (getCurrentContainer() != null) { - getCurrentContainer().getInventoryFromWindow(windowId).ifPresent(inventory -> inventory.updateFromOpenWindow(ctx)); - } - } - - private ContainerMemory getCurrentContainer() { - if (baritone.getWorldProvider().getCurrentWorld() == null) { - return null; - } - return (ContainerMemory) baritone.getWorldProvider().getCurrentWorld().getContainerMemory(); - } - - private BlockPos neighboringConnectedBlock(BlockPos in) { - BlockStateInterface bsi = baritone.bsi; - Block block = bsi.get0(in).getBlock(); - if (block != Blocks.TRAPPED_CHEST && block != Blocks.CHEST) { - return null; // other things that have contents, but can be placed adjacent without combining - } - for (int i = 0; i < 4; i++) { - BlockPos adj = in.offset(EnumFacing.byHorizontalIndex(i)); - if (bsi.get0(adj).getBlock() == block) { - return adj; - } - } - return null; - } - - /** - * An inventory that we are not yet fully aware of, but are expecting to exist at some point in the future. - */ - private static final class FutureInventory { - - /** - * The time that we initially expected the inventory to be provided, in milliseconds - */ - private final long time; - - /** - * The amount of slots in the inventory - */ - private final int slots; - - /** - * The type of inventory - */ - private final String type; - - /** - * The position of the inventory container - */ - private final BlockPos pos; - - private FutureInventory(long time, int slots, String type, BlockPos pos) { - this.time = time; - this.slots = slots; - this.type = type; - this.pos = pos; - // betterblockpos has censoring - System.out.println("Future inventory created " + time + " " + slots + " " + type + " " + BetterBlockPos.from(pos)); - } - } - - public Optional> echest() { - return Optional.ofNullable(getCurrent().contents).map(Collections::unmodifiableList); - } - - public EnderChestMemory getCurrent() { - Path path = baritone.getWorldProvider().getCurrentWorld().directory; - return EnderChestMemory.getByServerAndPlayer(path.getParent(), ctx.player().getUniqueID()); - } - - public static class EnderChestMemory { - - private static final Map memory = new HashMap<>(); - private final Path enderChest; - private List contents; - - private EnderChestMemory(Path enderChest) { - this.enderChest = enderChest; - System.out.println("Echest storing in " + enderChest); - try { - this.contents = ContainerMemory.readItemStacks(Files.readAllBytes(enderChest)); - } catch (IOException e) { - e.printStackTrace(); - System.out.println("CANNOT read echest =( =("); - this.contents = null; - } - } - - public synchronized void save() { - System.out.println("Saving"); - if (contents != null) { - try { - enderChest.getParent().toFile().mkdir(); - Files.write(enderChest, ContainerMemory.writeItemStacks(contents)); - } catch (IOException e) { - e.printStackTrace(); - System.out.println("CANNOT save echest =( =("); - } - } - } - - private static synchronized EnderChestMemory getByServerAndPlayer(Path serverStorage, UUID player) { - return memory.computeIfAbsent(serverStorage.resolve("echests").resolve(player.toString()), EnderChestMemory::new); - } - } -} diff --git a/src/main/java/baritone/cache/ContainerMemory.java b/src/main/java/baritone/cache/ContainerMemory.java deleted file mode 100644 index e79435e3a..000000000 --- a/src/main/java/baritone/cache/ContainerMemory.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Baritone is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Baritone. If not, see . - */ - -package baritone.cache; - -import baritone.Baritone; -import baritone.api.cache.IContainerMemory; -import baritone.api.cache.IRememberedInventory; -import baritone.api.utils.IPlayerContext; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.BlockPos; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.NoSuchFileException; -import java.nio.file.Path; -import java.util.*; - -public class ContainerMemory implements IContainerMemory { - - private final Path saveTo; - /** - * The current remembered inventories - */ - private final Map inventories = new HashMap<>(); - - - public ContainerMemory(Path saveTo) { - this.saveTo = saveTo; - try { - read(Files.readAllBytes(saveTo)); - } catch (NoSuchFileException ignored) { - inventories.clear(); - } catch (Exception ex) { - ex.printStackTrace(); - inventories.clear(); - } - } - - private void read(byte[] bytes) throws IOException { - PacketBuffer in = new PacketBuffer(Unpooled.wrappedBuffer(bytes)); - int chests = in.readInt(); - for (int i = 0; i < chests; i++) { - int x = in.readInt(); - int y = in.readInt(); - int z = in.readInt(); - RememberedInventory rem = new RememberedInventory(); - rem.items.addAll(readItemStacks(in)); - rem.size = rem.items.size(); - rem.windowId = -1; - if (rem.items.isEmpty()) { - continue; // this only happens if the list has no elements, not if the list has elements that are all empty item stacks - } - inventories.put(new BlockPos(x, y, z), rem); - } - } - - public synchronized void save() throws IOException { - if (!Baritone.settings().containerMemory.value) { - return; - } - ByteBuf buf = Unpooled.buffer(0, Integer.MAX_VALUE); - PacketBuffer out = new PacketBuffer(buf); - out.writeInt(inventories.size()); - for (Map.Entry entry : inventories.entrySet()) { - out = new PacketBuffer(out.writeInt(entry.getKey().getX())); - out = new PacketBuffer(out.writeInt(entry.getKey().getY())); - out = new PacketBuffer(out.writeInt(entry.getKey().getZ())); - out = writeItemStacks(entry.getValue().getContents(), out); - } - Files.write(saveTo, out.array()); - } - - public synchronized void setup(BlockPos pos, int windowId, int slotCount) { - RememberedInventory inventory = inventories.computeIfAbsent(pos, x -> new RememberedInventory()); - inventory.windowId = windowId; - inventory.size = slotCount; - } - - public synchronized Optional getInventoryFromWindow(int windowId) { - return inventories.values().stream().filter(i -> i.windowId == windowId).findFirst(); - } - - @Override - public final synchronized RememberedInventory getInventoryByPos(BlockPos pos) { - return inventories.get(pos); - } - - @Override - public final synchronized Map getRememberedInventories() { - // make a copy since this map is modified from the packet thread - return new HashMap<>(inventories); - } - - public static List readItemStacks(byte[] bytes) throws IOException { - PacketBuffer in = new PacketBuffer(Unpooled.wrappedBuffer(bytes)); - return readItemStacks(in); - } - - public static List readItemStacks(PacketBuffer in) throws IOException { - int count = in.readInt(); - List result = new ArrayList<>(); - for (int i = 0; i < count; i++) { - result.add(in.readItemStack()); - } - return result; - } - - public static byte[] writeItemStacks(List write) { - ByteBuf buf = Unpooled.buffer(0, Integer.MAX_VALUE); - PacketBuffer out = new PacketBuffer(buf); - out = writeItemStacks(write, out); - return out.array(); - } - - public static PacketBuffer writeItemStacks(List write, PacketBuffer out2) { - PacketBuffer out = out2; // avoid reassigning an argument LOL - out = new PacketBuffer(out.writeInt(write.size())); - for (ItemStack stack : write) { - out = out.writeItemStack(stack); - } - return out; - } - - /** - * An inventory that we are aware of. - *

- * Associated with a {@link BlockPos} in {@link ContainerMemory#inventories}. - */ - public static class RememberedInventory implements IRememberedInventory { - - /** - * The list of items in the inventory - */ - private final List items; - - /** - * The last known window ID of the inventory - */ - private int windowId; - - /** - * The size of the inventory - */ - private int size; - - private RememberedInventory() { - this.items = new ArrayList<>(); - } - - @Override - public final List getContents() { - return Collections.unmodifiableList(this.items); - } - - @Override - public final int getSize() { - return this.size; - } - - public void updateFromOpenWindow(IPlayerContext ctx) { - items.clear(); - items.addAll(ctx.player().openContainer.getInventory().subList(0, size)); - } - } -} diff --git a/src/main/java/baritone/cache/WorldData.java b/src/main/java/baritone/cache/WorldData.java index 30fe8bd0d..cbdda3687 100644 --- a/src/main/java/baritone/cache/WorldData.java +++ b/src/main/java/baritone/cache/WorldData.java @@ -19,7 +19,6 @@ package baritone.cache; import baritone.Baritone; import baritone.api.cache.ICachedWorld; -import baritone.api.cache.IContainerMemory; import baritone.api.cache.IWaypointCollection; import baritone.api.cache.IWorldData; @@ -35,7 +34,6 @@ public class WorldData implements IWorldData { public final CachedWorld cache; private final WaypointCollection waypoints; - private final ContainerMemory containerMemory; //public final MapData map; public final Path directory; public final int dimension; @@ -44,7 +42,6 @@ public class WorldData implements IWorldData { this.directory = directory; this.cache = new CachedWorld(directory.resolve("cache"), dimension); this.waypoints = new WaypointCollection(directory.resolve("waypoints")); - this.containerMemory = new ContainerMemory(directory.resolve("containers")); this.dimension = dimension; } @@ -53,15 +50,6 @@ public class WorldData implements IWorldData { System.out.println("Started saving the world in a new thread"); cache.save(); }); - Baritone.getExecutor().execute(() -> { - System.out.println("Started saving saved containers in a new thread"); - try { - containerMemory.save(); - } catch (IOException e) { - e.printStackTrace(); - System.out.println("Failed to save saved containers"); - } - }); } @Override @@ -73,9 +61,4 @@ public class WorldData implements IWorldData { public IWaypointCollection getWaypoints() { return this.waypoints; } - - @Override - public IContainerMemory getContainerMemory() { - return this.containerMemory; - } } diff --git a/src/main/java/baritone/command/defaults/ChestsCommand.java b/src/main/java/baritone/command/defaults/ChestsCommand.java deleted file mode 100644 index b4dcda749..000000000 --- a/src/main/java/baritone/command/defaults/ChestsCommand.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Baritone is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Baritone. If not, see . - */ - -package baritone.command.defaults; - -import baritone.api.IBaritone; -import baritone.api.cache.IRememberedInventory; -import baritone.api.command.Command; -import baritone.api.command.argument.IArgConsumer; -import baritone.api.command.exception.CommandException; -import baritone.api.command.exception.CommandInvalidStateException; -import baritone.api.utils.BetterBlockPos; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Stream; - -public class ChestsCommand extends Command { - - public ChestsCommand(IBaritone baritone) { - super(baritone, "chests"); - } - - @Override - public void execute(String label, IArgConsumer args) throws CommandException { - args.requireMax(0); - Set> entries = - ctx.worldData().getContainerMemory().getRememberedInventories().entrySet(); - if (entries.isEmpty()) { - throw new CommandInvalidStateException("No remembered inventories"); - } - for (Map.Entry entry : entries) { - // betterblockpos has censoring - BetterBlockPos pos = new BetterBlockPos(entry.getKey()); - IRememberedInventory inv = entry.getValue(); - logDirect(pos.toString()); - for (ItemStack item : inv.getContents()) { - ITextComponent component = item.getTextComponent(); - component.appendText(String.format(" x %d", item.getCount())); - logDirect(component); - } - } - } - - @Override - public Stream tabComplete(String label, IArgConsumer args) { - return Stream.empty(); - } - - @Override - public String getShortDesc() { - return "Display remembered inventories"; - } - - @Override - public List getLongDesc() { - return Arrays.asList( - "The chests command lists remembered inventories, I guess?", - "", - "Usage:", - "> chests" - ); - } -} diff --git a/src/main/java/baritone/command/defaults/DefaultCommands.java b/src/main/java/baritone/command/defaults/DefaultCommands.java index 17f338046..e998dcc97 100644 --- a/src/main/java/baritone/command/defaults/DefaultCommands.java +++ b/src/main/java/baritone/command/defaults/DefaultCommands.java @@ -51,7 +51,6 @@ public final class DefaultCommands { new TunnelCommand(baritone), new RenderCommand(baritone), new FarmCommand(baritone), - new ChestsCommand(baritone), new FollowCommand(baritone), new ExploreFilterCommand(baritone), new ReloadAllCommand(baritone), From 3adfa16db8305a07200b29bcde32e3912699ee79 Mon Sep 17 00:00:00 2001 From: Entropy5 <44469915+Entropy5@users.noreply.github.com> Date: Fri, 17 Dec 2021 06:24:34 +0100 Subject: [PATCH 134/155] Option to ignore direction of certain blocks during building (because otherwise baritone just keeps breaking and replacing the same block) --- src/api/java/baritone/api/Settings.java | 5 +++++ src/main/java/baritone/process/BuilderProcess.java | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index a3147292e..554853716 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -258,6 +258,11 @@ public final class Settings { */ public final Setting buildIgnoreExisting = new Setting<>(false); + /** + * If this is true, the builder will ignore directionality of certain blocks like glazed terracotta. + */ + public final Setting buildIgnoreDirection = new Setting<>(false); + /** * If this setting is true, Baritone will never break a block that is adjacent to an unsupported falling block. *

diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 89226fed2..fc7687524 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -48,6 +48,9 @@ import baritone.utils.schematic.schematica.SchematicaHelper; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import net.minecraft.block.BlockAir; import net.minecraft.block.BlockLiquid; +import net.minecraft.block.BlockGlazedTerracotta; +import net.minecraft.block.BlockBone; +import net.minecraft.block.BlockHay; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; @@ -836,6 +839,10 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil if (desired == null) { return true; } + if ((current.getBlock() instanceof BlockGlazedTerracotta || current.getBlock() instanceof BlockBone || current.getBlock() instanceof BlockHay) + && Baritone.settings().buildIgnoreDirection.value && current.getBlock() == desired.getBlock()) { + return true; + } if (current.getBlock() instanceof BlockLiquid && Baritone.settings().okIfWater.value) { return true; } From c2f4e0031481ff600deb1d0175cde436257f830e Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sat, 18 Dec 2021 00:31:21 +0100 Subject: [PATCH 135/155] Make rightClickContainerOnArrival click lit furnaces --- src/main/java/baritone/process/GetToBlockProcess.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/process/GetToBlockProcess.java b/src/main/java/baritone/process/GetToBlockProcess.java index f6764d4c8..16fc3dda5 100644 --- a/src/main/java/baritone/process/GetToBlockProcess.java +++ b/src/main/java/baritone/process/GetToBlockProcess.java @@ -242,7 +242,7 @@ public final class GetToBlockProcess extends BaritoneProcessHelper implements IG if (!Baritone.settings().rightClickContainerOnArrival.value) { return false; } - return block == Blocks.CRAFTING_TABLE || block == Blocks.FURNACE || block == Blocks.ENDER_CHEST || block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST; + return block == Blocks.CRAFTING_TABLE || block == Blocks.FURNACE || block == Blocks.LIT_FURNACE || block == Blocks.ENDER_CHEST || block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST; } private boolean blockOnTopMustBeRemoved(Block block) { From 1919f7b2a7337dc4e8ed4974392dda6f1ed3d9c1 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 20 Dec 2021 22:31:06 -1000 Subject: [PATCH 136/155] fix build again --- scripts/proguard.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/proguard.pro b/scripts/proguard.pro index 9adc5174c..f0aaa665b 100644 --- a/scripts/proguard.pro +++ b/scripts/proguard.pro @@ -81,7 +81,7 @@ -libraryjars 'tempLibraries/netty-all-4.1.9.Final.jar' -libraryjars 'tempLibraries/oshi-core-1.1.jar' --libraryjars 'tempLibraries/patchy-1.2.jar' +-libraryjars 'tempLibraries/patchy-1.3.9.jar' -libraryjars 'tempLibraries/platform-3.4.0.jar' -libraryjars 'tempLibraries/realms-1.10.22.jar' -libraryjars 'tempLibraries/soundsystem-20120107.jar' From 54617bf634e5fad0617801796c202a1a72810bbd Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 21 Dec 2021 01:32:47 -1000 Subject: [PATCH 137/155] reorder for performance --- src/main/java/baritone/process/BuilderProcess.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index fc7687524..1212c12b0 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -839,8 +839,8 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil if (desired == null) { return true; } - if ((current.getBlock() instanceof BlockGlazedTerracotta || current.getBlock() instanceof BlockBone || current.getBlock() instanceof BlockHay) - && Baritone.settings().buildIgnoreDirection.value && current.getBlock() == desired.getBlock()) { + if (Baritone.settings().buildIgnoreDirection.value && current.getBlock() == desired.getBlock() && + (current.getBlock() instanceof BlockGlazedTerracotta || current.getBlock() instanceof BlockBone || current.getBlock() instanceof BlockHay)) { return true; } if (current.getBlock() instanceof BlockLiquid && Baritone.settings().okIfWater.value) { From 32a7657c4ffd933cba4ed8d289e4e6bb32b6cd39 Mon Sep 17 00:00:00 2001 From: Entropy5 <44469915+Entropy5@users.noreply.github.com> Date: Tue, 21 Dec 2021 12:42:39 +0100 Subject: [PATCH 138/155] Zac suggested this option to work universally, regardless of block type --- src/main/java/baritone/process/BuilderProcess.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index fc7687524..49f1564a2 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -839,10 +839,6 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil if (desired == null) { return true; } - if ((current.getBlock() instanceof BlockGlazedTerracotta || current.getBlock() instanceof BlockBone || current.getBlock() instanceof BlockHay) - && Baritone.settings().buildIgnoreDirection.value && current.getBlock() == desired.getBlock()) { - return true; - } if (current.getBlock() instanceof BlockLiquid && Baritone.settings().okIfWater.value) { return true; } @@ -861,7 +857,10 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil if (Baritone.settings().buildValidSubstitutes.value.getOrDefault(desired.getBlock(), Collections.emptyList()).contains(current.getBlock()) && !itemVerify) { return true; } - return current.equals(desired); + if (current.equals(desired)) { + return true; + } + return Baritone.settings().buildIgnoreDirection.value && current.getBlock() == desired.getBlock(); } public class BuilderCalculationContext extends CalculationContext { From 9c3882e91fd1b790109a56cc64ac194cc2ff8ec4 Mon Sep 17 00:00:00 2001 From: Entropy5 <44469915+Entropy5@users.noreply.github.com> Date: Tue, 21 Dec 2021 12:49:44 +0100 Subject: [PATCH 139/155] to lazy to spell --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 42733fbd4..635ffdf5f 100644 --- a/README.md +++ b/README.md @@ -56,9 +56,9 @@ For 1.15.2, [click here](https://www.youtube.com/watch?v=j1qKtCZFURM) and see de For 1.16.5, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. If you need Forge or Fabric 1.16.5, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.6.3) and get the `api-forge` or `api-fabric` jar. **For 1.16.5 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.6.3/baritone-api-fabric-1.6.3.jar)**. -For 1.17.1 leijurv is to lazy to actually create a release so you can login to github and download the jars in the `artifacts` zip [here](https://github.com/cabaletta/baritone/actions/runs/1451572684) +For 1.17.1 leijurv is too lazy to actually create a release so you can login to github and download the jars in the `artifacts` zip [here](https://github.com/cabaletta/baritone/actions/runs/1451572684) -For 1.18.1 leijurv is to lazy to actually create a release so you can login to github and download the jars in the `artifacts` zip [here](https://github.com/cabaletta/baritone/actions/runs/1472825778) +For 1.18.1 leijurv is too lazy to actually create a release so you can login to github and download the jars in the `artifacts` zip [here](https://github.com/cabaletta/baritone/actions/runs/1472825778) This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/), the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 through 1.16.5. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). From b3ff3d24665e1ed782c66647b8617366dc87d351 Mon Sep 17 00:00:00 2001 From: Entropy5 <44469915+Entropy5@users.noreply.github.com> Date: Tue, 21 Dec 2021 20:09:22 +0100 Subject: [PATCH 140/155] universal buildignoredirection --- .../java/baritone/process/BuilderProcess.java | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 49f1564a2..e837c4a77 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -45,12 +45,12 @@ import baritone.utils.schematic.MapArtSchematic; import baritone.utils.schematic.SelectionSchematic; import baritone.utils.schematic.SchematicSystem; import baritone.utils.schematic.schematica.SchematicaHelper; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; -import net.minecraft.block.BlockAir; -import net.minecraft.block.BlockLiquid; -import net.minecraft.block.BlockGlazedTerracotta; -import net.minecraft.block.BlockBone; -import net.minecraft.block.BlockHay; +import net.minecraft.block.*; +import net.minecraft.block.properties.IProperty; +import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; @@ -835,6 +835,25 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil return result; } + public static final Set> orientationProps = + ImmutableSet.of(BlockRotatedPillar.AXIS, BlockLog.LOG_AXIS, BlockHorizontal.FACING, + BlockStairs.FACING, BlockStairs.HALF, BlockStairs.SHAPE, + BlockPane.NORTH, BlockPane.EAST, BlockPane.SOUTH, BlockPane.WEST, BlockVine.UP, + BlockTrapDoor.OPEN, BlockTrapDoor.HALF + ); + + private boolean sameWithoutOrientation(IBlockState first, IBlockState second) { + if (first.getBlock() != second.getBlock() + ) {return false;} + ImmutableMap, Comparable> map1 = first.getProperties(); + ImmutableMap, Comparable> map2 = second.getProperties(); + for (IProperty prop : map1.keySet()) { + if (map1.get(prop) != map2.get(prop) && !orientationProps.contains(prop) + ) {return false;} + } + return true; + } + private boolean valid(IBlockState current, IBlockState desired, boolean itemVerify) { if (desired == null) { return true; @@ -860,7 +879,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil if (current.equals(desired)) { return true; } - return Baritone.settings().buildIgnoreDirection.value && current.getBlock() == desired.getBlock(); + return Baritone.settings().buildIgnoreDirection.value && sameWithoutOrientation(current, desired); } public class BuilderCalculationContext extends CalculationContext { From 9d13bcfe119d2e5ffc8cd0e486b93b12d1784b7c Mon Sep 17 00:00:00 2001 From: Entropy5 <44469915+Entropy5@users.noreply.github.com> Date: Wed, 22 Dec 2021 00:20:21 +0100 Subject: [PATCH 141/155] formatting --- src/main/java/baritone/process/BuilderProcess.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index e837c4a77..05de59ca8 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -843,13 +843,15 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil ); private boolean sameWithoutOrientation(IBlockState first, IBlockState second) { - if (first.getBlock() != second.getBlock() - ) {return false;} + if (first.getBlock() != second.getBlock()) { + return false; + } ImmutableMap, Comparable> map1 = first.getProperties(); ImmutableMap, Comparable> map2 = second.getProperties(); for (IProperty prop : map1.keySet()) { - if (map1.get(prop) != map2.get(prop) && !orientationProps.contains(prop) - ) {return false;} + if (map1.get(prop) != map2.get(prop) && !orientationProps.contains(prop)) { + return false; + } } return true; } From d97346be6cea71c01e5a1b4925f2a36350cc370e Mon Sep 17 00:00:00 2001 From: Entropy5 <44469915+Entropy5@users.noreply.github.com> Date: Thu, 23 Dec 2021 13:39:13 +0100 Subject: [PATCH 142/155] check union of keys --- src/main/java/baritone/process/BuilderProcess.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 05de59ca8..438f7a4e0 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -50,7 +50,6 @@ import com.google.common.collect.ImmutableSet; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import net.minecraft.block.*; import net.minecraft.block.properties.IProperty; -import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; @@ -848,7 +847,9 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil } ImmutableMap, Comparable> map1 = first.getProperties(); ImmutableMap, Comparable> map2 = second.getProperties(); - for (IProperty prop : map1.keySet()) { + HashSet> keys = new HashSet<>(first.getPropertyKeys()); + keys.addAll(second.getPropertyKeys()); + for (IProperty prop : keys) { if (map1.get(prop) != map2.get(prop) && !orientationProps.contains(prop)) { return false; } From 90c59d5b8e30ea45b5f6f7869790a1d640432300 Mon Sep 17 00:00:00 2001 From: Entropy5 <44469915+Entropy5@users.noreply.github.com> Date: Thu, 23 Dec 2021 21:59:20 +0100 Subject: [PATCH 143/155] undo --- src/main/java/baritone/process/BuilderProcess.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 438f7a4e0..604dbb2bc 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -847,9 +847,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil } ImmutableMap, Comparable> map1 = first.getProperties(); ImmutableMap, Comparable> map2 = second.getProperties(); - HashSet> keys = new HashSet<>(first.getPropertyKeys()); - keys.addAll(second.getPropertyKeys()); - for (IProperty prop : keys) { + for (IProperty prop : map1.keySet()) { if (map1.get(prop) != map2.get(prop) && !orientationProps.contains(prop)) { return false; } From bb8e4bd737149ed4c5582a026eedbb581ff383e1 Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Sun, 2 Jan 2022 12:45:03 +0000 Subject: [PATCH 144/155] Add unpause as an alias for resume Some people can't seem to find out what to do to unpause baritone, so this should hopefully help them figure it out, as for some reason unpause makes more sense to people than resume. --- .../baritone/command/defaults/ExecutionControlCommands.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/command/defaults/ExecutionControlCommands.java b/src/main/java/baritone/command/defaults/ExecutionControlCommands.java index 1b024c3b8..8a53e7d41 100644 --- a/src/main/java/baritone/command/defaults/ExecutionControlCommands.java +++ b/src/main/java/baritone/command/defaults/ExecutionControlCommands.java @@ -112,7 +112,7 @@ public class ExecutionControlCommands { ); } }; - resumeCommand = new Command(baritone, "resume", "r") { + resumeCommand = new Command(baritone, "resume", "r", "unpause") { @Override public void execute(String label, IArgConsumer args) throws CommandException { args.requireMax(0); From 3fcc032547cab7f5d4f89efc42c12e5838137bb6 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 2 Feb 2022 00:49:51 -0800 Subject: [PATCH 145/155] readme updates for new release --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 635ffdf5f..1e9b249bc 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ Minecraft Minecraft Minecraft + Minecraft + Minecraft

@@ -56,9 +58,9 @@ For 1.15.2, [click here](https://www.youtube.com/watch?v=j1qKtCZFURM) and see de For 1.16.5, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. If you need Forge or Fabric 1.16.5, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.6.3) and get the `api-forge` or `api-fabric` jar. **For 1.16.5 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.6.3/baritone-api-fabric-1.6.3.jar)**. -For 1.17.1 leijurv is too lazy to actually create a release so you can login to github and download the jars in the `artifacts` zip [here](https://github.com/cabaletta/baritone/actions/runs/1451572684) +For 1.17.1, if you need Forge or Fabric 1.17.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.7.1) and get the `api-forge` or `api-fabric` jar. **For 1.17.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.7.1/baritone-api-fabric-1.7.1.jar)**. -For 1.18.1 leijurv is too lazy to actually create a release so you can login to github and download the jars in the `artifacts` zip [here](https://github.com/cabaletta/baritone/actions/runs/1472825778) +For 1.18.1, if you need Forge or Fabric 1.18.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.8.1) and get the `api-forge` or `api-fabric` jar. **For 1.18.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.8.1/baritone-api-fabric-1.8.1.jar)**. This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/), the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 through 1.16.5. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). From ad14226c5c4ba4c6622f91ae66f586ace073a923 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 2 Feb 2022 00:50:48 -0800 Subject: [PATCH 146/155] lets not keep updating this --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1e9b249bc..17826c3e9 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ For 1.17.1, if you need Forge or Fabric 1.17.1, look [here](https://github.com/c For 1.18.1, if you need Forge or Fabric 1.18.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.8.1) and get the `api-forge` or `api-fabric` jar. **For 1.18.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.8.1/baritone-api-fabric-1.8.1.jar)**. This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/), -the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 through 1.16.5. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). +the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 onwards. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). Have committed at least once a day from Aug 1, 2018, to Aug 1, 2019. From 0908e509a1905d30683ecf6115206de5c4568c0e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 2 Feb 2022 00:51:24 -0800 Subject: [PATCH 147/155] simplify a bit more --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 17826c3e9..86aab720b 100644 --- a/README.md +++ b/README.md @@ -58,9 +58,9 @@ For 1.15.2, [click here](https://www.youtube.com/watch?v=j1qKtCZFURM) and see de For 1.16.5, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. If you need Forge or Fabric 1.16.5, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.6.3) and get the `api-forge` or `api-fabric` jar. **For 1.16.5 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.6.3/baritone-api-fabric-1.6.3.jar)**. -For 1.17.1, if you need Forge or Fabric 1.17.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.7.1) and get the `api-forge` or `api-fabric` jar. **For 1.17.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.7.1/baritone-api-fabric-1.7.1.jar)**. +If you need Forge or Fabric 1.17.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.7.1) and get the `api-forge` or `api-fabric` jar. **For 1.17.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.7.1/baritone-api-fabric-1.7.1.jar)**. -For 1.18.1, if you need Forge or Fabric 1.18.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.8.1) and get the `api-forge` or `api-fabric` jar. **For 1.18.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.8.1/baritone-api-fabric-1.8.1.jar)**. +If you need Forge or Fabric 1.18.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.8.1) and get the `api-forge` or `api-fabric` jar. **For 1.18.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.8.1/baritone-api-fabric-1.8.1.jar)**. This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/), the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 onwards. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). From 74ea803651c2e4d73c813ea38d2c790e26c209e0 Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Wed, 2 Feb 2022 20:33:47 +0000 Subject: [PATCH 148/155] Add world border checks to MovementHelper --- .../java/baritone/pathing/movement/CalculationContext.java | 1 - src/main/java/baritone/pathing/movement/MovementHelper.java | 6 ++++++ src/main/java/baritone/utils/BlockStateInterface.java | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/CalculationContext.java b/src/main/java/baritone/pathing/movement/CalculationContext.java index 124e6f109..fca6bc990 100644 --- a/src/main/java/baritone/pathing/movement/CalculationContext.java +++ b/src/main/java/baritone/pathing/movement/CalculationContext.java @@ -143,7 +143,6 @@ public class CalculationContext { return COST_INF; } if (!worldBorder.canPlaceAt(x, z)) { - // TODO perhaps MovementHelper.canPlaceAgainst could also use this? return COST_INF; } return placeBlockCost; diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index f5f565e39..23c261446 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -49,6 +49,9 @@ import static baritone.pathing.movement.Movement.HORIZONTALS_BUT_ALSO_DOWN_____S public interface MovementHelper extends ActionCosts, Helper { static boolean avoidBreaking(BlockStateInterface bsi, int x, int y, int z, IBlockState state) { + if (!bsi.worldBorder.canPlaceAt(x, y)) { + return false; + } Block b = state.getBlock(); return Baritone.settings().blocksToDisallowBreaking.value.contains(b) || b == Blocks.ICE // ice becomes water, and water can mess up the path @@ -368,6 +371,9 @@ public interface MovementHelper extends ActionCosts, Helper { } static boolean canPlaceAgainst(BlockStateInterface bsi, int x, int y, int z, IBlockState state) { + if (!bsi.worldBorder.canPlaceAt(x, z)) { + return false; + } // can we look at the center of a side face of this block and likely be able to place? // (thats how this check is used) // therefore dont include weird things that we technically could place against (like carpet) but practically can't diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index 4f5f26899..f451c2f1d 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -22,6 +22,7 @@ import baritone.api.utils.IPlayerContext; import baritone.cache.CachedRegion; import baritone.cache.WorldData; import baritone.utils.accessor.IChunkProviderClient; +import baritone.utils.pathing.BetterWorldBorder; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import net.minecraft.block.Block; @@ -46,6 +47,7 @@ public class BlockStateInterface { protected final IBlockAccess world; public final BlockPos.MutableBlockPos isPassableBlockPos; public final IBlockAccess access; + public final BetterWorldBorder worldBorder; private Chunk prev = null; private CachedRegion prevCached = null; @@ -64,6 +66,7 @@ public class BlockStateInterface { public BlockStateInterface(World world, WorldData worldData, boolean copyLoadedChunks) { this.world = world; + this.worldBorder = new BetterWorldBorder(world.getWorldBorder()); this.worldData = worldData; Long2ObjectMap worldLoaded = ((IChunkProviderClient) world.getChunkProvider()).loadedChunks(); if (copyLoadedChunks) { From 2d0f10c79fe4441d40bdefbc54a599037e543e5b Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 2 Feb 2022 15:53:09 -0800 Subject: [PATCH 149/155] link to branches --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 86aab720b..eec452ba4 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,13 @@

- Minecraft - Minecraft - Minecraft - Minecraft - Minecraft - Minecraft - Minecraft + Minecraft + Minecraft + Minecraft + Minecraft + Minecraft + Minecraft + Minecraft

From 25de3324920fa375dad903f9386eabe496d291a6 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 2 Feb 2022 15:53:43 -0800 Subject: [PATCH 150/155] mfw this also needs to be in master --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 84a7e4319..d4c25ad90 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ baritone_Client.launch # Copyright Files !/.idea/copyright/Baritone.xml !/.idea/copyright/profiles_settings.xml + +.vscode/launch.json + From e0a53144db0889eb9d279ce248b7a279600ccc8c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 2 Feb 2022 16:10:14 -0800 Subject: [PATCH 151/155] bump most recent jars --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eec452ba4..381e3f126 100644 --- a/README.md +++ b/README.md @@ -58,9 +58,9 @@ For 1.15.2, [click here](https://www.youtube.com/watch?v=j1qKtCZFURM) and see de For 1.16.5, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. If you need Forge or Fabric 1.16.5, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.6.3) and get the `api-forge` or `api-fabric` jar. **For 1.16.5 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.6.3/baritone-api-fabric-1.6.3.jar)**. -If you need Forge or Fabric 1.17.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.7.1) and get the `api-forge` or `api-fabric` jar. **For 1.17.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.7.1/baritone-api-fabric-1.7.1.jar)**. +If you need Forge or Fabric 1.17.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.7.2) and get the `api-forge` or `api-fabric` jar. **For 1.17.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.7.2/baritone-api-fabric-1.7.2.jar)**. -If you need Forge or Fabric 1.18.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.8.1) and get the `api-forge` or `api-fabric` jar. **For 1.18.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.8.1/baritone-api-fabric-1.8.1.jar)**. +If you need Forge or Fabric 1.18.1, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.8.2) and get the `api-forge` or `api-fabric` jar. **For 1.18.1 Fabric, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.8.2/baritone-api-fabric-1.8.2.jar)**. This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/), the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 onwards. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). From 9b70ace1807baef93782bc34cfb37ab01359e091 Mon Sep 17 00:00:00 2001 From: Wagyourtail Date: Wed, 2 Feb 2022 22:04:15 -0700 Subject: [PATCH 152/155] fix getting stuck on cauldrons (fixes #3099) --- src/main/java/baritone/pathing/movement/MovementHelper.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index f5f565e39..48ebd3c28 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -134,7 +134,9 @@ public interface MovementHelper extends ActionCosts, Helper { } return block == Blocks.WATER || block == Blocks.FLOWING_WATER; } - + if (block instanceof BlockCauldron) { + return false; + } return block.isPassable(bsi.access, bsi.isPassableBlockPos.setPos(x, y, z)); } From 49357790f1e48186949b82f97d27b842e5ffd3e9 Mon Sep 17 00:00:00 2001 From: scorbett123 <50634068+scorbett123@users.noreply.github.com> Date: Thu, 3 Feb 2022 08:06:01 +0000 Subject: [PATCH 153/155] fix world border checks Signed-off-by: scorbett123 <50634068+scorbett123@users.noreply.github.com> --- src/main/java/baritone/pathing/movement/MovementHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 23c261446..2990b7f20 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -50,7 +50,7 @@ public interface MovementHelper extends ActionCosts, Helper { static boolean avoidBreaking(BlockStateInterface bsi, int x, int y, int z, IBlockState state) { if (!bsi.worldBorder.canPlaceAt(x, y)) { - return false; + return true; } Block b = state.getBlock(); return Baritone.settings().blocksToDisallowBreaking.value.contains(b) From 7052fe62250c48bf4021857ceb8b44066887dc58 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 7 Feb 2022 22:03:31 -0800 Subject: [PATCH 154/155] put this on its own line --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 381e3f126..b125edf6e 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,9 @@ A Minecraft pathfinder bot. [**Baritone Discord Server**](http://discord.gg/s6fRBAUpmr) -Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. There's a [showcase video](https://youtu.be/CZkLXWo4Fg4) made by @Adovin#0730 on Baritone which I recommend. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a (very old!) video I made showing off what it can do. [Tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa) +Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. There's a [showcase video](https://youtu.be/CZkLXWo4Fg4) made by @Adovin#0730 on Baritone which I recommend. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a (very old!) video I made showing off what it can do. + +[Tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa) The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the v1.2.* `api-forge` jar from [releases](https://github.com/cabaletta/baritone/releases). **For 1.12.2 Forge, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.2.15/baritone-api-forge-1.2.15.jar)**. Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it. From 0ade37f14f8af914c50046a5d681f1ffff3635c0 Mon Sep 17 00:00:00 2001 From: ehylo <1487662ehylo@gmail.com> Date: Tue, 8 Feb 2022 21:13:51 -0800 Subject: [PATCH 155/155] Update Setup and Usage guides Also fix 2 settings that just don't have a description for some reason, and add some information to the find command because that also for some reason did not have anything there. The descriptions I put may not be detailed enough so please let me know if things should change --- README.md | 2 +- SETUP.md | 21 ++++++++++++------- USAGE.md | 16 ++++++++++---- src/api/java/baritone/api/Settings.java | 6 ++++++ .../command/defaults/FindCommand.java | 4 ++-- 5 files changed, 35 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index b125edf6e..7222e4d89 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ jar. Below is an example of basic usage for changing some settings, and then pathing to an X/Z goal. -``` +```java BaritoneAPI.getSettings().allowSprint.value = true; BaritoneAPI.getSettings().primaryTimeoutMS.value = 2000L; diff --git a/SETUP.md b/SETUP.md index 7a43faa62..57866b192 100644 --- a/SETUP.md +++ b/SETUP.md @@ -11,7 +11,7 @@ These releases are not always completely up to date with latest features, and ar Link to the releases page: [Releases](https://github.com/cabaletta/baritone/releases) -v1.2.* is for 1.12.2, v1.3.* is for 1.13.2, v1.4.* is for 1.14.4, v1.5.* is for 1.15.2, v1.6.* is for 1.16.2 or 1.16.4 or 1.16.5 (LOL) +v1.2.* is for 1.12.2, v1.3.* is for 1.13.2, v1.4.* is for 1.14.4, v1.5.* is for 1.15.2, v1.6.* is for 1.16.5, v1.7.* is for 1.17.1, v1.8.* is for 1.18.1 Any official release will be GPG signed by leijurv (44A3EA646EADAC6A). Please verify that the hash of the file you download is in `checksums.txt` and that `checksums_signed.asc` is a valid signature by that public keys of `checksums.txt`. @@ -22,15 +22,16 @@ The build is fully deterministic and reproducible, and you can verify Travis did Building Baritone will result in 5 artifacts created in the ``dist`` directory. These are the same as the artifacts created in the [releases](https://github.com/cabaletta/baritone/releases). -**The Forge release can simply be added as a Forge mod.** +**The Forge and Fabric releases can simply be added as a Forge/Fabric mods.** If another one of your Forge mods has a Baritone integration, you want `baritone-api-forge-VERSION.jar`. Otherwise, you want `baritone-standalone-forge-VERSION.jar` - **API**: Only the non-api packages are obfuscated. This should be used in environments where other mods would like to use Baritone's features. -- **Forge API**: Same as API, but packaged for Forge. This should be used where another mod has a Baritone integration. +- **Forge/Fabric API**: Same as API, but packaged for Forge/Fabric. This should be used where another mod has a Baritone integration. - **Standalone**: Everything is obfuscated. This should be used in environments where there are no other mods present that would like to use Baritone's features. -- **Forge Standalone**: Same as Standalone, but packaged for Forge. This should be used when Baritone is your only Forge mod, or none of your other Forge mods integrate with Baritone. +- **Forge/Fabric Standalone**: Same as Standalone, but packaged for Forge/Fabric. This should be used when Baritone is your only Forge/Fabric mod, or none of your other Forge/Fabric mods integrate with Baritone. - **Unoptimized**: Nothing is obfuscated. This shouldn't be used ever in production. +- **Forge/Fabric Unoptimized**: Same as Unoptimized, but packaged for Forge/Fabric. ## Build it yourself - Clone or download Baritone @@ -42,13 +43,13 @@ If another one of your Forge mods has a Baritone integration, you want `baritone ## Command Line On Mac OSX and Linux, use `./gradlew` instead of `gradlew`. -If you have errors with a package missing please make sure you have setup your environment, and are using Oracle JDK 8. +If you have errors with a package missing please make sure you have setup your environment, and are using Oracle JDK 8 for 1.12.2-1.16.5, JDK 16 for 1.17.1, and JDK 17 for 1.18.1. To check which java you are using do `java -version` in a command prompt or terminal. -If you are using anything above OpenJDK 8, it might not work because the Java distributions above JDK 8 using may not have the needed javax classes. +If you are using anything above OpenJDK 8 for 1.12.2-1.16.5, it might not work because the Java distributions above JDK 8 using may not have the needed javax classes. -Open JDK 8 download: https://openjdk.java.net/install/ +Open JDK download: https://openjdk.java.net/install/ #### macOS guide In order to get JDK 8, Try running the following command: `% /usr/libexec/java_home -V` @@ -84,6 +85,12 @@ For minecraft 1.15.2+, run the following instead to include the Forge jars: $ gradlew build -Pbaritone.forge_build ``` +Do this instead for Fabric jars: + +``` +$ gradlew build -Pbaritone.fabric_build +``` + Running Baritone: ``` diff --git a/USAGE.md b/USAGE.md index f896ad012..46241e3fe 100644 --- a/USAGE.md +++ b/USAGE.md @@ -32,13 +32,13 @@ Watch this [showcase video](https://youtu.be/CZkLXWo4Fg4)! To toggle a boolean setting, just say its name in chat (for example saying `allowBreak` toggles whether Baritone will consider breaking blocks). For a numeric setting, say its name then the new value (like `primaryTimeoutMS 250`). It's case insensitive. To reset a setting to its default value, say `acceptableThrowawayItems reset`. To reset all settings, say `reset`. To see all settings that have been modified from their default values, say `modified`. -Some common examples: +Commands in Baritone: - `thisway 1000` then `path` to go in the direction you're facing for a thousand blocks - `goal x y z` or `goal x z` or `goal y`, then `path` to set a goal to a certain coordinate then path to it - `goto x y z` or `goto x z` or `goto y` to go to a certain coordinate (in a single step, starts going immediately) - `goal` to set the goal to your player's feet - `goal clear` to clear the goal -- `cancel` or `stop` to stop everything +- `cancel` or `stop` to stop everything, `forcecancel` is also an option - `goto portal` or `goto ender_chest` or `goto block_type` to go to a block. (in Impact, `.goto` is an alias for `.b goto` for the most part) - `mine diamond_ore iron_ore` to mine diamond ore or iron ore (turn on the setting `legitMine` to only mine ores that it can actually see. It will explore randomly around y=11 until it finds them.) An amount of blocks can also be specified, for example, `mine 64 diamond_ore`. - `click` to click your destination on the screen. Right click path to on top of the block, left click to path into it (either at foot level or eye level), and left click and drag to select an area (`#help sel` to see what you can do with that selection). @@ -51,11 +51,19 @@ Some common examples: - `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120). - `explore x z` to explore the world from the origin of x,z. Leave out x and z to default to player feet. This will continually path towards the closest chunk to the origin that it's never seen before. `explorefilter filter.json` with optional invert can be used to load in a list of chunks to load. - `invert` to invert the current goal and path. This gets as far away from it as possible, instead of as close as possible. For example, do `goal` then `invert` to run as far as possible from where you're standing at the start. +- `come` tells Baritone to head towards your camera, useful when freecam doesn't move your player position. +- `blacklist` will stop baritone from going to the closest block so it won't attempt to get to it. +- `eta` to get information about the estimated time until the next segment and the goal, be aware that the ETA to your goal is really unprecise. +- `proc` to view miscellaneous information about the process currently controlling Baritone. +- `repack` to re-cache the chunks around you. +- `gc` to call `System.gc()` which may free up some memory. +- `render` to fix glitched chunk rendering without having to reload all of them. +- `reloadall` to reload Baritone's world cache or `saveall` to save Baritone's world cache. +- `find` to search through Baritone's cache and attempt to find the location of the block. +- `surface` or `top` to tell Baritone to head towards the closest surface-like area, this can be the surface or highest available air space. - `version` to get the version of Baritone you're running - `damn` daniel -For the rest of the commands, you can take a look at the code [here](https://baritone.leijurv.com/baritone/api/Settings.html). - All the settings and documentation are here. If you find HTML easier to read than Javadoc, you can look here. There are about a hundred settings, but here are some fun / interesting / important ones that you might want to look at changing in normal usage of Baritone. The documentation for each can be found at the above links. diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index c3ea4225a..b0eda7489 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -385,6 +385,9 @@ public final class Settings { */ public final Setting mobSpawnerAvoidanceCoefficient = new Setting<>(2.0); + /** + * Distance to avoid mob spawners. + */ public final Setting mobSpawnerAvoidanceRadius = new Setting<>(16); /** @@ -394,6 +397,9 @@ public final class Settings { */ public final Setting mobAvoidanceCoefficient = new Setting<>(1.5); + /** + * Distance to avoid mobs. + */ public final Setting mobAvoidanceRadius = new Setting<>(8); /** diff --git a/src/main/java/baritone/command/defaults/FindCommand.java b/src/main/java/baritone/command/defaults/FindCommand.java index 22e6815be..65eb9b5c3 100644 --- a/src/main/java/baritone/command/defaults/FindCommand.java +++ b/src/main/java/baritone/command/defaults/FindCommand.java @@ -71,10 +71,10 @@ public class FindCommand extends Command { @Override public List getLongDesc() { return Arrays.asList( - "", + "The find command searches through Baritone's cache and attempts to find the location of the block.", "", "Usage:", - "> " + "> find - Find positions of a certain block" ); } }