From bd345ae041d789673f01986baa90e657cbc3d70d Mon Sep 17 00:00:00 2001 From: Xennex <55858288+Xephorix@users.noreply.github.com> Date: Mon, 7 Oct 2019 09:50:10 -0600 Subject: [PATCH 01/41] Update USAGE.md added a few commands to the list of "fun / interesting / important ones that you might want to look at" --- USAGE.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/USAGE.md b/USAGE.md index 25fef11e8..76da07cb4 100644 --- a/USAGE.md +++ b/USAGE.md @@ -65,6 +65,8 @@ There are about a hundred settings, but here are some fun / interesting / import - `worldExploringChunkOffset` - `acceptableThrowawayItems` - `blocksToAvoidBreaking` +- `mineScanDroppedItems` +- `allowDiagonalAscend` From fb22cf05ebe539cb6f8510e12bc58c3597cb8199 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 4 Jan 2020 21:57:16 -0800 Subject: [PATCH 02/41] v1.2.11 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 117f1d63d..9912a92a1 100755 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ */ group 'baritone' -version '1.2.10' +version '1.2.11' buildscript { repositories { From 710170ef2d2c8909e3fbdd67108f5b57f447d25f Mon Sep 17 00:00:00 2001 From: Brady Date: Fri, 10 Jan 2020 20:10:16 -0600 Subject: [PATCH 03/41] Fix RelativeGoalXZ coordinate mix-up Basically for many months now RelativeGoalXZ produced (~X, ~Y), not (~X, ~Z). --- src/api/java/baritone/api/command/datatypes/RelativeGoalXZ.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/command/datatypes/RelativeGoalXZ.java b/src/api/java/baritone/api/command/datatypes/RelativeGoalXZ.java index cd3977b6f..c50aab015 100644 --- a/src/api/java/baritone/api/command/datatypes/RelativeGoalXZ.java +++ b/src/api/java/baritone/api/command/datatypes/RelativeGoalXZ.java @@ -37,7 +37,7 @@ public enum RelativeGoalXZ implements IDatatypePost { final IArgConsumer consumer = ctx.getConsumer(); return new GoalXZ( MathHelper.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.x)), - MathHelper.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.y)) + MathHelper.floor(consumer.getDatatypePost(RelativeCoordinate.INSTANCE, (double) origin.z)) ); } From 539b8ef973537e633eb954a0008a370582f24721 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 25 Jan 2020 22:34:55 -0800 Subject: [PATCH 04/41] fix oversight in coordinate censorship --- src/main/java/baritone/cache/CachedWorld.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index e74053901..23d7ca8c8 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -184,7 +184,9 @@ public final class CachedWorld implements ICachedWorld, Helper { int distZ = ((region.getZ() << 9) + 256) - pruneCenter.getZ(); double dist = Math.sqrt(distX * distX + distZ * distZ); if (dist > 1024) { - logDebug("Deleting cached region " + region.getX() + "," + region.getZ() + " from ram"); + if (!Baritone.settings().censorCoordinates.value) { + logDebug("Deleting cached region " + region.getX() + "," + region.getZ() + " from ram"); + } cachedRegions.remove(getRegionID(region.getX(), region.getZ())); } } From b3de840e04568f5c21a3e0a80b490f326e5ea9b9 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 26 Jan 2020 12:41:15 -0800 Subject: [PATCH 05/41] no reason for this now that impact is 1.14.4 for all --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 043aed085..87d35d2fa 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,6 @@ Baritone is the pathfinding system used in [Impact](https://impactclient.net/) s 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.* forge api jar from [releases](https://github.com/cabaletta/baritone/releases). Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it. -For 1.14.4, [click here](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1). Or [with optifine](https://github.com/cabaletta/baritone/issues/797). - 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 and 1.13.2. 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 17a06621f5149c1f76e52a7b946e7774ccf0cc95 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 1 Feb 2020 16:42:14 -0800 Subject: [PATCH 06/41] rootnet shill --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 87d35d2fa..6067610bf 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ [![Impact integration](https://img.shields.io/badge/Impact%20integration-v1.2.10%20/%20v1.3.5%20/%20v1.4.3-brightgreen.svg)](https://impactclient.net/) [![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.11-green.svg)](https://rootnet.dev/) [![WWE integration](https://img.shields.io/badge/WWE%20%22integration%22-master%3F-green.svg)](https://wweclient.com/) [![Future integration](https://img.shields.io/badge/Future%20integration-Soon™%3F%3F%3F-red.svg)](https://futureclient.net/) [![forthebadge](https://forthebadge.com/images/badges/built-with-swag.svg)](http://forthebadge.com/) From de89da20b23a616ae889d10967f011643ea2a0a5 Mon Sep 17 00:00:00 2001 From: Bella Who Date: Sun, 9 Feb 2020 17:44:50 -0500 Subject: [PATCH 07/41] Update bug.md --- .github/ISSUE_TEMPLATE/bug.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index 55e5ad06f..ced6b51ef 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -20,6 +20,7 @@ You can find your logs in `%appdata%/.minecraft/logs/` (Windows) or `/Library/Ap Add your steps to reproduce the issue/bug experienced here. ## Final checklist +- [x] I know how to properly use check boxes - [ ] I have included the version of Minecraft I'm running, baritone's version and forge mods (if used). - [ ] I have included logs, exceptions and / or steps to reproduce the issue. -- [ ] I have not used any OwO's or UwU's in this issue. \ No newline at end of file +- [ ] I have not used any OwO's or UwU's in this issue. From de68e6630eb4c7e6d3b5d627dac317ca73df211b Mon Sep 17 00:00:00 2001 From: Bella Who Date: Sun, 9 Feb 2020 17:45:09 -0500 Subject: [PATCH 08/41] Update question.md --- .github/ISSUE_TEMPLATE/question.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md index 2482fd4c3..b5de2dfd3 100644 --- a/.github/ISSUE_TEMPLATE/question.md +++ b/.github/ISSUE_TEMPLATE/question.md @@ -10,4 +10,5 @@ assignees: '' With as much detail as possible, describe your question and what you may need help with. ## Final checklist -- [ ] I have not used any OwO's or UwU's in this issue. \ No newline at end of file +- [x] I know how to properly use check boxes +- [ ] I have not used any OwO's or UwU's in this issue. From 7cdbc4acca78f8737ceb28dca32a6265861b8c55 Mon Sep 17 00:00:00 2001 From: Bella Who Date: Sun, 9 Feb 2020 17:45:28 -0500 Subject: [PATCH 09/41] Update suggestion.md --- .github/ISSUE_TEMPLATE/suggestion.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/suggestion.md b/.github/ISSUE_TEMPLATE/suggestion.md index da61c638d..9f7a30bf7 100644 --- a/.github/ISSUE_TEMPLATE/suggestion.md +++ b/.github/ISSUE_TEMPLATE/suggestion.md @@ -16,4 +16,5 @@ If applicable, what settings/customizability should be offered to tweak the func Describe how your suggestion would improve Baritone, or the reason behind it being added. ## Final checklist -- [ ] I have not used any OwO's or UwU's in this issue. \ No newline at end of file +- [x] I know how to properly use check boxes +- [ ] I have not used any OwO's or UwU's in this issue. From 656dd910040e13ce2653c416b772693eff13d678 Mon Sep 17 00:00:00 2001 From: Bella Who Date: Sun, 9 Feb 2020 19:12:40 -0500 Subject: [PATCH 10/41] Update bug.md --- .github/ISSUE_TEMPLATE/bug.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index ced6b51ef..dc6eb2261 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -14,7 +14,13 @@ Baritone version: Forge mods (if used): ## Exception, error or logs -You can find your logs in `%appdata%/.minecraft/logs/` (Windows) or `/Library/Application\ Support/minecraft/logs` (Mac). +Please find your `latest.log` or `debug.log` in this folder and attach it to the issue + +Linux: `~/.minecraft/logs/` + +Windows: `%appdata%/.minecraft/logs/` + +Mac:`/Library/Application\ Support/minecraft/logs/` ## How to reproduce Add your steps to reproduce the issue/bug experienced here. From e66d8616ceeb520009bc5ef1ac0b578f8f1dcdb2 Mon Sep 17 00:00:00 2001 From: Bella Who Date: Sun, 9 Feb 2020 19:28:19 -0500 Subject: [PATCH 11/41] fixed space --- .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 dc6eb2261..e2b8874c6 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -20,7 +20,7 @@ Linux: `~/.minecraft/logs/` Windows: `%appdata%/.minecraft/logs/` -Mac:`/Library/Application\ Support/minecraft/logs/` +Mac: `/Library/Application\ Support/minecraft/logs/` ## How to reproduce Add your steps to reproduce the issue/bug experienced here. From e0985d3b68ee10e1cbb0560fac5fdb293b2d8305 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 14 Feb 2020 13:49:15 -0800 Subject: [PATCH 12/41] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6067610bf..4d9900b50 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ Baritone is the pathfinding system used in [Impact](https://impactclient.net/) s 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.* forge api jar from [releases](https://github.com/cabaletta/baritone/releases). 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. + 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 and 1.13.2. 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 01ba712d339f6dc5d48c15bdc5cbc5cb8fca1e38 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 14 Feb 2020 13:49:53 -0800 Subject: [PATCH 13/41] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4d9900b50..7de14bebb 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ [![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/) [![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/) @@ -37,7 +38,7 @@ 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. 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 and 1.13.2. 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.15.2. 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 80955cad8bd381e9d658f75f6780c3d2fa36aa8b Mon Sep 17 00:00:00 2001 From: Bella Who Date: Mon, 17 Feb 2020 17:42:05 -0500 Subject: [PATCH 14/41] Make setup instructions more clear --- SETUP.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/SETUP.md b/SETUP.md index 1fcaf1d2b..7efab34ff 100644 --- a/SETUP.md +++ b/SETUP.md @@ -47,6 +47,8 @@ You can verify whether or not it worked by running `.b version` in chat (only va ## 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. + Setting up the Environment: ``` @@ -54,6 +56,12 @@ $ gradlew setupDecompWorkspace $ gradlew --refresh-dependencies ``` +Building Baritone: + +``` +$ gradlew build +``` + Running Baritone: ``` @@ -87,16 +95,6 @@ For information on how to build baritone, see [Building Baritone](#building-bari ![Image](https://i.imgur.com/hrLhG9u.png) -# Building - -Make sure that you have properly [setup](#setup) the environment before trying to build it. - -## Command Line - -``` -$ gradlew build -``` - ## IntelliJ - Navigate to the gradle tasks on the right tab as follows From 85d63c9d7fe484bfc501f02ae4421a08bcad9e1a Mon Sep 17 00:00:00 2001 From: Babbaj Date: Thu, 20 Feb 2020 20:29:36 -0500 Subject: [PATCH 15/41] Exceptions are side effects --- scripts/proguard.pro | 48 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/scripts/proguard.pro b/scripts/proguard.pro index 4ac0f7233..52b843ddf 100644 --- a/scripts/proguard.pro +++ b/scripts/proguard.pro @@ -181,19 +181,19 @@ -assumenosideeffects public class java.lang.* extends java.lang.Number { public static java.lang.String toString(byte); public static java.lang.Byte valueOf(byte); - public static byte parseByte(java.lang.String); - public static byte parseByte(java.lang.String,int); - public static java.lang.Byte valueOf(java.lang.String,int); - public static java.lang.Byte valueOf(java.lang.String); - public static java.lang.Byte decode(java.lang.String); +# public static byte parseByte(java.lang.String); +# public static byte parseByte(java.lang.String,int); +# public static java.lang.Byte valueOf(java.lang.String,int); +# public static java.lang.Byte valueOf(java.lang.String); +# public static java.lang.Byte decode(java.lang.String); public int compareTo(java.lang.Byte); public static java.lang.String toString(short); - public static short parseShort(java.lang.String); - public static short parseShort(java.lang.String,int); - public static java.lang.Short valueOf(java.lang.String,int); - public static java.lang.Short valueOf(java.lang.String); +# public static short parseShort(java.lang.String); +# public static short parseShort(java.lang.String,int); +# public static java.lang.Short valueOf(java.lang.String,int); +# public static java.lang.Short valueOf(java.lang.String); public static java.lang.Short valueOf(short); - public static java.lang.Short decode(java.lang.String); +# public static java.lang.Short decode(java.lang.String); public static short reverseBytes(short); public int compareTo(java.lang.Short); public static java.lang.String toString(int,int); @@ -201,10 +201,10 @@ public static java.lang.String toOctalString(int); public static java.lang.String toBinaryString(int); public static java.lang.String toString(int); - public static int parseInt(java.lang.String,int); - public static int parseInt(java.lang.String); - public static java.lang.Integer valueOf(java.lang.String,int); - public static java.lang.Integer valueOf(java.lang.String); +# public static int parseInt(java.lang.String,int); +# public static int parseInt(java.lang.String); +# public static java.lang.Integer valueOf(java.lang.String,int); +# public static java.lang.Integer valueOf(java.lang.String); public static java.lang.Integer valueOf(int); public static java.lang.Integer getInteger(java.lang.String); public static java.lang.Integer getInteger(java.lang.String,int); @@ -226,12 +226,12 @@ public static java.lang.String toOctalString(long); public static java.lang.String toBinaryString(long); public static java.lang.String toString(long); - public static long parseLong(java.lang.String,int); - public static long parseLong(java.lang.String); - public static java.lang.Long valueOf(java.lang.String,int); - public static java.lang.Long valueOf(java.lang.String); +# public static long parseLong(java.lang.String,int); +# public static long parseLong(java.lang.String); +# public static java.lang.Long valueOf(java.lang.String,int); +# public static java.lang.Long valueOf(java.lang.String); public static java.lang.Long valueOf(long); - public static java.lang.Long decode(java.lang.String); +# public static java.lang.Long decode(java.lang.String); public static java.lang.Long getLong(java.lang.String); public static java.lang.Long getLong(java.lang.String,long); public static java.lang.Long getLong(java.lang.String,java.lang.Long); @@ -248,9 +248,9 @@ public int compareTo(java.lang.Long); public static java.lang.String toString(float); public static java.lang.String toHexString(float); - public static java.lang.Float valueOf(java.lang.String); +# public static java.lang.Float valueOf(java.lang.String); public static java.lang.Float valueOf(float); - public static float parseFloat(java.lang.String); +# public static float parseFloat(java.lang.String); public static boolean isNaN(float); public static boolean isInfinite(float); public static int floatToIntBits(float); @@ -262,9 +262,9 @@ public int compareTo(java.lang.Float); public static java.lang.String toString(double); public static java.lang.String toHexString(double); - public static java.lang.Double valueOf(java.lang.String); - public static java.lang.Double valueOf(double); - public static double parseDouble(java.lang.String); +# public static java.lang.Double valueOf(java.lang.String); +# public static java.lang.Double valueOf(double); +# public static double parseDouble(java.lang.String); public static boolean isNaN(double); public static boolean isInfinite(double); public static long doubleToLongBits(double); From 2d2571cff5aa30d2142b5d809f74cf85c267a0e9 Mon Sep 17 00:00:00 2001 From: aUniqueUser Date: Sat, 22 Feb 2020 18:31:41 -0500 Subject: [PATCH 16/41] Desktop Notification System --- src/api/java/baritone/api/Settings.java | 4 ++ .../pathing/calc/AbstractNodeCostSearch.java | 3 + .../baritone/utils/NotificationHelper.java | 72 +++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 src/main/java/baritone/utils/NotificationHelper.java diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 69bcabcb6..1bbde3b2b 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -1046,6 +1046,10 @@ public final class Settings { */ public final Setting renderSelectionCorners = new Setting<>(true); + /** + * Desktop Notifications + */ + public final Setting desktopNotifications = new Setting<>(false); /** * A map of lowercase setting field names to their respective setting diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index a67384acc..baaeed8bb 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -26,6 +26,7 @@ import baritone.api.utils.Helper; import baritone.api.utils.PathCalculationResult; import baritone.pathing.movement.CalculationContext; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; +import baritone.utils.NotificationHelper; import java.util.Optional; @@ -216,6 +217,8 @@ 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); } return Optional.empty(); } diff --git a/src/main/java/baritone/utils/NotificationHelper.java b/src/main/java/baritone/utils/NotificationHelper.java new file mode 100644 index 000000000..927befb08 --- /dev/null +++ b/src/main/java/baritone/utils/NotificationHelper.java @@ -0,0 +1,72 @@ +/* + * 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; + +import java.awt.*; +import java.io.IOException; + +public class NotificationHelper { + public static void notify(String text, boolean error) { + if (System.getProperty("os.name").contains("Linux")) + linux(text); + else + notification(text, error); + } + + public static void notification(String text, boolean error) { + if (SystemTray.isSupported()) { + try { + SystemTray tray = SystemTray.getSystemTray(); + Image image = Toolkit.getDefaultToolkit().createImage(""); + // Replace with some logo + + TrayIcon trayIcon = new TrayIcon(image, "Baritone"); + trayIcon.setImageAutoSize(true); + trayIcon.setToolTip("Baritone"); + tray.add(trayIcon); + + if(error) + trayIcon.displayMessage("Baritone", text, TrayIcon.MessageType.ERROR); + else + trayIcon.displayMessage("Baritone", text, TrayIcon.MessageType.INFO); + } + catch (Exception e) { + e.printStackTrace(); + } + } + else { + System.out.println("SystemTray is not supported"); + } + } + + /* + * The only way to display notifications on linux is to use the java-gnome library, or send notify-send to shell with a ProcessBuilder + * Unfortunately the java-gnome library is licenced under the GPL, see: (https://en.wikipedia.org/wiki/Java-gnome) + */ + + public static void linux(String text) { + ProcessBuilder processBuilder = new ProcessBuilder(); + processBuilder.command("notify-send", "-a", "Baritone", text); + try { + processBuilder.start(); + } catch (IOException e) { + e.printStackTrace(); + } + + } +} From 0dcb9d4b6968584f9cf3c15f1089bfcff055034e Mon Sep 17 00:00:00 2001 From: aUniqueUser Date: Sat, 22 Feb 2020 20:12:43 -0500 Subject: [PATCH 17/41] Formatting --- .../pathing/calc/AbstractNodeCostSearch.java | 3 +- .../baritone/utils/NotificationHelper.java | 30 +++++++++++-------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index baaeed8bb..eea23905e 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -217,8 +217,9 @@ 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) + if (Baritone.settings().desktopNotifications.value) { NotificationHelper.notify("No path found =(", true); + } } return Optional.empty(); } diff --git a/src/main/java/baritone/utils/NotificationHelper.java b/src/main/java/baritone/utils/NotificationHelper.java index 927befb08..9ab0b545a 100644 --- a/src/main/java/baritone/utils/NotificationHelper.java +++ b/src/main/java/baritone/utils/NotificationHelper.java @@ -20,12 +20,20 @@ package baritone.utils; import java.awt.*; import java.io.IOException; +/** + * This class is not called from the main game thread. + * Do not refer to any Minecraft classes, it wouldn't be thread safe. + * + * @author aUniqueUser + */ public class NotificationHelper { + public static void notify(String text, boolean error) { - if (System.getProperty("os.name").contains("Linux")) + if (System.getProperty("os.name").contains("Linux")) { linux(text); - else + } else { notification(text, error); + } } public static void notification(String text, boolean error) { @@ -33,30 +41,29 @@ public class NotificationHelper { try { SystemTray tray = SystemTray.getSystemTray(); Image image = Toolkit.getDefaultToolkit().createImage(""); - // Replace with some logo TrayIcon trayIcon = new TrayIcon(image, "Baritone"); trayIcon.setImageAutoSize(true); trayIcon.setToolTip("Baritone"); tray.add(trayIcon); - if(error) + if (error) { trayIcon.displayMessage("Baritone", text, TrayIcon.MessageType.ERROR); - else + } else { trayIcon.displayMessage("Baritone", text, TrayIcon.MessageType.INFO); - } - catch (Exception e) { + } + } catch (Exception e) { e.printStackTrace(); } - } - else { + } else { System.out.println("SystemTray is not supported"); } } /* - * The only way to display notifications on linux is to use the java-gnome library, or send notify-send to shell with a ProcessBuilder - * Unfortunately the java-gnome library is licenced under the GPL, see: (https://en.wikipedia.org/wiki/Java-gnome) + * The only way to display notifications on linux is to use the java-gnome library, + * or send notify-send to shell with a ProcessBuilder. Unfortunately the java-gnome + * library is licenced under the GPL, see (https://en.wikipedia.org/wiki/Java-gnome) */ public static void linux(String text) { @@ -67,6 +74,5 @@ public class NotificationHelper { } catch (IOException e) { e.printStackTrace(); } - } } From cf691118b90c3b13de13f851cc28ef55cfa11bc3 Mon Sep 17 00:00:00 2001 From: aUniqueUser Date: Sat, 22 Feb 2020 20:19:25 -0500 Subject: [PATCH 18/41] comment fixed --- src/main/java/baritone/utils/NotificationHelper.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/utils/NotificationHelper.java b/src/main/java/baritone/utils/NotificationHelper.java index 9ab0b545a..76cd5b1cc 100644 --- a/src/main/java/baritone/utils/NotificationHelper.java +++ b/src/main/java/baritone/utils/NotificationHelper.java @@ -60,12 +60,9 @@ public class NotificationHelper { } } - /* - * The only way to display notifications on linux is to use the java-gnome library, - * or send notify-send to shell with a ProcessBuilder. Unfortunately the java-gnome - * library is licenced under the GPL, see (https://en.wikipedia.org/wiki/Java-gnome) - */ - + // The only way to display notifications on linux is to use the java-gnome library, + // or send notify-send to shell with a ProcessBuilder. Unfortunately the java-gnome + // library is licenced under the GPL, see (https://en.wikipedia.org/wiki/Java-gnome) public static void linux(String text) { ProcessBuilder processBuilder = new ProcessBuilder(); processBuilder.command("notify-send", "-a", "Baritone", text); From 25b85f17a30bf71133fdcefebc2b693576d528f1 Mon Sep 17 00:00:00 2001 From: aUniqueUser Date: Sat, 22 Feb 2020 20:41:06 -0500 Subject: [PATCH 19/41] mfw --- src/main/java/baritone/utils/NotificationHelper.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/utils/NotificationHelper.java b/src/main/java/baritone/utils/NotificationHelper.java index 76cd5b1cc..3e7b22ae1 100644 --- a/src/main/java/baritone/utils/NotificationHelper.java +++ b/src/main/java/baritone/utils/NotificationHelper.java @@ -60,9 +60,11 @@ public class NotificationHelper { } } - // The only way to display notifications on linux is to use the java-gnome library, - // or send notify-send to shell with a ProcessBuilder. Unfortunately the java-gnome - // library is licenced under the GPL, see (https://en.wikipedia.org/wiki/Java-gnome) + /* + * The only way to display notifications on linux is to use the java-gnome library, + * or send notify-send to shell with a ProcessBuilder. Unfortunately the java-gnome + * library is licenced under the GPL, see (https://en.wikipedia.org/wiki/Java-gnome) + */ public static void linux(String text) { ProcessBuilder processBuilder = new ProcessBuilder(); processBuilder.command("notify-send", "-a", "Baritone", text); From a8645afbdb8c8d376ff3ca510771c84c4d43cd8a Mon Sep 17 00:00:00 2001 From: aUniqueUser Date: Sat, 22 Feb 2020 21:09:36 -0500 Subject: [PATCH 20/41] Revert "mfw" This reverts commit 25b85f17a30bf71133fdcefebc2b693576d528f1. --- src/main/java/baritone/utils/NotificationHelper.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/baritone/utils/NotificationHelper.java b/src/main/java/baritone/utils/NotificationHelper.java index 3e7b22ae1..76cd5b1cc 100644 --- a/src/main/java/baritone/utils/NotificationHelper.java +++ b/src/main/java/baritone/utils/NotificationHelper.java @@ -60,11 +60,9 @@ public class NotificationHelper { } } - /* - * The only way to display notifications on linux is to use the java-gnome library, - * or send notify-send to shell with a ProcessBuilder. Unfortunately the java-gnome - * library is licenced under the GPL, see (https://en.wikipedia.org/wiki/Java-gnome) - */ + // The only way to display notifications on linux is to use the java-gnome library, + // or send notify-send to shell with a ProcessBuilder. Unfortunately the java-gnome + // library is licenced under the GPL, see (https://en.wikipedia.org/wiki/Java-gnome) public static void linux(String text) { ProcessBuilder processBuilder = new ProcessBuilder(); processBuilder.command("notify-send", "-a", "Baritone", text); From 042b1ed6d7e706c8f228d13de84519090196a41a Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 22 Feb 2020 18:37:10 -0800 Subject: [PATCH 21/41] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7de14bebb..26c700256 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,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://www.youtube.com/watch?v=yI8hgW_m6dQ) made by @Adovin#3153 on Baritone's integration into Impact. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a video I made showing off what it can do. +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 video I made showing off what it can do. 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.* forge api jar from [releases](https://github.com/cabaletta/baritone/releases). Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it. From b1f5429db98b1c6ab711671627ea0541ac6bd832 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 22 Feb 2020 18:37:29 -0800 Subject: [PATCH 22/41] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 26c700256..c07add8fa 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,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 video I made showing off what it can do. +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. 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.* forge api jar from [releases](https://github.com/cabaletta/baritone/releases). Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it. From 27440fc1478aa7029e470f90ddda06a2418a5fe1 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 22 Feb 2020 22:42:22 -0800 Subject: [PATCH 23/41] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index c07add8fa..9bc29c667 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,10 @@ Here are some links to help to get started: - [Usage (chat control)](USAGE.md) +## Stars over time + +[![Stargazers over time](https://starchart.cc/cabaletta/baritone.svg)](https://starchart.cc/cabaletta/baritone) + # API The API is heavily documented, you can find the Javadocs for the latest release [here](https://baritone.leijurv.com/). From c578d5c1a3a01cdc83a60d7ed502ce40bc18eca0 Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 23 Feb 2020 12:51:14 -0600 Subject: [PATCH 24/41] Fix additional TrayIcon creation and support Mac notifs --- .../baritone/utils/NotificationHelper.java | 46 ++++++++++++------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/src/main/java/baritone/utils/NotificationHelper.java b/src/main/java/baritone/utils/NotificationHelper.java index 76cd5b1cc..54abbf87f 100644 --- a/src/main/java/baritone/utils/NotificationHelper.java +++ b/src/main/java/baritone/utils/NotificationHelper.java @@ -17,6 +17,8 @@ package baritone.utils; +import org.apache.commons.lang3.SystemUtils; + import java.awt.*; import java.io.IOException; @@ -28,30 +30,32 @@ import java.io.IOException; */ public class NotificationHelper { + private static TrayIcon trayIcon; + public static void notify(String text, boolean error) { - if (System.getProperty("os.name").contains("Linux")) { + if (SystemUtils.IS_OS_WINDOWS) { + windows(text, error); + } else if (SystemUtils.IS_OS_MAC_OSX) { + mac(text); + } else if (SystemUtils.IS_OS_LINUX) { linux(text); - } else { - notification(text, error); } } - public static void notification(String text, boolean error) { + private static void windows(String text, boolean error) { if (SystemTray.isSupported()) { try { - SystemTray tray = SystemTray.getSystemTray(); - Image image = Toolkit.getDefaultToolkit().createImage(""); + if (trayIcon == null) { + SystemTray tray = SystemTray.getSystemTray(); + Image image = Toolkit.getDefaultToolkit().createImage(""); - TrayIcon trayIcon = new TrayIcon(image, "Baritone"); - trayIcon.setImageAutoSize(true); - trayIcon.setToolTip("Baritone"); - tray.add(trayIcon); - - if (error) { - trayIcon.displayMessage("Baritone", text, TrayIcon.MessageType.ERROR); - } else { - trayIcon.displayMessage("Baritone", text, TrayIcon.MessageType.INFO); + trayIcon = new TrayIcon(image, "Baritone"); + trayIcon.setImageAutoSize(true); + trayIcon.setToolTip("Baritone"); + tray.add(trayIcon); } + + trayIcon.displayMessage("Baritone", text, error ? TrayIcon.MessageType.ERROR : TrayIcon.MessageType.INFO); } catch (Exception e) { e.printStackTrace(); } @@ -60,10 +64,20 @@ public class NotificationHelper { } } + private static void mac(String text) { + ProcessBuilder processBuilder = new ProcessBuilder(); + processBuilder.command("osascript", "-e", "display notification \"" + text + "\" with title \"Baritone\""); + try { + processBuilder.start(); + } catch (IOException e) { + e.printStackTrace(); + } + } + // The only way to display notifications on linux is to use the java-gnome library, // or send notify-send to shell with a ProcessBuilder. Unfortunately the java-gnome // library is licenced under the GPL, see (https://en.wikipedia.org/wiki/Java-gnome) - public static void linux(String text) { + private static void linux(String text) { ProcessBuilder processBuilder = new ProcessBuilder(); processBuilder.command("notify-send", "-a", "Baritone", text); try { From 07c406aa1615cf08e0e0e74cba284c4e47a3e2d7 Mon Sep 17 00:00:00 2001 From: Babbaj Date: Sun, 23 Feb 2020 21:48:15 -0500 Subject: [PATCH 25/41] baritoe --- src/api/java/baritone/api/utils/Helper.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/utils/Helper.java b/src/api/java/baritone/api/utils/Helper.java index 994d8c7b5..2f821a39d 100755 --- a/src/api/java/baritone/api/utils/Helper.java +++ b/src/api/java/baritone/api/utils/Helper.java @@ -24,6 +24,7 @@ import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextFormatting; import java.util.Arrays; +import java.util.Calendar; import java.util.stream.Stream; /** @@ -47,7 +48,9 @@ public interface Helper { static ITextComponent getPrefix() { // Inner text component - ITextComponent baritone = new TextComponentString(BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : "Baritone"); + final Calendar now = Calendar.getInstance(); + final boolean xd = now.get(Calendar.MONTH) == Calendar.APRIL && now.get(Calendar.DAY_OF_MONTH) == 1; + ITextComponent baritone = new TextComponentString(BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : (xd ? "Baritoe" : "Baritone")); baritone.getStyle().setColor(TextFormatting.LIGHT_PURPLE); // Outer brackets From ee33666b38eb2207f1f739dc30a9307603740643 Mon Sep 17 00:00:00 2001 From: Babbaj Date: Sun, 23 Feb 2020 21:54:18 -0500 Subject: [PATCH 26/41] 3 days --- src/api/java/baritone/api/utils/Helper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/utils/Helper.java b/src/api/java/baritone/api/utils/Helper.java index 2f821a39d..7e85725f8 100755 --- a/src/api/java/baritone/api/utils/Helper.java +++ b/src/api/java/baritone/api/utils/Helper.java @@ -49,7 +49,7 @@ public interface Helper { static ITextComponent getPrefix() { // Inner text component final Calendar now = Calendar.getInstance(); - final boolean xd = now.get(Calendar.MONTH) == Calendar.APRIL && now.get(Calendar.DAY_OF_MONTH) == 1; + final boolean xd = now.get(Calendar.MONTH) == Calendar.APRIL && now.get(Calendar.DAY_OF_MONTH) <= 3; ITextComponent baritone = new TextComponentString(BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : (xd ? "Baritoe" : "Baritone")); baritone.getStyle().setColor(TextFormatting.LIGHT_PURPLE); From 888b2723e0f2bd887f9496e06abd3ecb38295a3a Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 23 Feb 2020 21:13:51 -0600 Subject: [PATCH 27/41] Fix critical prefix tag bug --- src/api/java/baritone/api/utils/Helper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/utils/Helper.java b/src/api/java/baritone/api/utils/Helper.java index 7e85725f8..3cda18343 100755 --- a/src/api/java/baritone/api/utils/Helper.java +++ b/src/api/java/baritone/api/utils/Helper.java @@ -50,7 +50,7 @@ public interface Helper { // Inner text component final Calendar now = Calendar.getInstance(); final boolean xd = now.get(Calendar.MONTH) == Calendar.APRIL && now.get(Calendar.DAY_OF_MONTH) <= 3; - ITextComponent baritone = new TextComponentString(BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : (xd ? "Baritoe" : "Baritone")); + ITextComponent baritone = new TextComponentString(xd ? "Baritoe" : BaritoneAPI.getSettings().shortBaritonePrefix.value ? "B" : "Baritone"); baritone.getStyle().setColor(TextFormatting.LIGHT_PURPLE); // Outer brackets From 393a3a87b6ee6fa282446fe5b0ae7ae055939215 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Feb 2020 12:20:13 -0800 Subject: [PATCH 28/41] Update USAGE.md --- USAGE.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/USAGE.md b/USAGE.md index 0f911efaa..5a63c05ee 100644 --- a/USAGE.md +++ b/USAGE.md @@ -20,6 +20,8 @@ Try `#help` I promise it won't just send you back here =) just look at `#help` lmao +Watch this [showcase video](https://youtu.be/CZkLXWo4Fg4)! + # Commands **All** of these commands may need a prefix before them, as above ^. From e854bf59f83b92bc548a18efb12cf072c415abb5 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Feb 2020 18:31:42 -0800 Subject: [PATCH 29/41] fix sneaking based issues --- .../baritone/api/utils/IPlayerContext.java | 4 +++ .../baritone/api/utils/RayTraceUtils.java | 15 +++++++- .../baritone/api/utils/RotationUtils.java | 34 ++++++++++++++----- .../baritone/pathing/movement/Movement.java | 2 +- .../pathing/movement/MovementHelper.java | 12 +++++-- .../movement/movements/MovementAscend.java | 2 +- .../movement/movements/MovementDescend.java | 2 +- .../movement/movements/MovementParkour.java | 2 +- .../movement/movements/MovementPillar.java | 2 +- .../movement/movements/MovementTraverse.java | 2 +- .../baritone/process/BackfillProcess.java | 2 +- .../java/baritone/process/FarmProcess.java | 2 +- 12 files changed, 61 insertions(+), 20 deletions(-) diff --git a/src/api/java/baritone/api/utils/IPlayerContext.java b/src/api/java/baritone/api/utils/IPlayerContext.java index b461c3891..8ce3271b2 100644 --- a/src/api/java/baritone/api/utils/IPlayerContext.java +++ b/src/api/java/baritone/api/utils/IPlayerContext.java @@ -77,6 +77,10 @@ public interface IPlayerContext { return new Rotation(player().rotationYaw, player().rotationPitch); } + static double eyeHeight(boolean ifSneaking) { + return ifSneaking ? 1.54 : 1.62; + } + /** * Returns the block that the crosshair is currently placed over. Updated once per tick. * diff --git a/src/api/java/baritone/api/utils/RayTraceUtils.java b/src/api/java/baritone/api/utils/RayTraceUtils.java index 0fd1e4e01..4f763e392 100644 --- a/src/api/java/baritone/api/utils/RayTraceUtils.java +++ b/src/api/java/baritone/api/utils/RayTraceUtils.java @@ -40,7 +40,16 @@ public final class RayTraceUtils { * @return The calculated raytrace result */ public static RayTraceResult rayTraceTowards(Entity entity, Rotation rotation, double blockReachDistance) { - Vec3d start = entity.getPositionEyes(1.0F); + return rayTraceTowards(entity, rotation, blockReachDistance, false); + } + + public static RayTraceResult rayTraceTowards(Entity entity, Rotation rotation, double blockReachDistance, boolean wouldSneak) { + Vec3d start; + if (wouldSneak) { + start = inferSneakingEyePosition(entity); + } else { + start = entity.getPositionEyes(1.0F); // do whatever is correct + } Vec3d direction = RotationUtils.calcVec3dFromRotation(rotation); Vec3d end = start.add( direction.x * blockReachDistance, @@ -49,4 +58,8 @@ public final class RayTraceUtils { ); return entity.world.rayTraceBlocks(start, end, false, false, true); } + + public static Vec3d inferSneakingEyePosition(Entity entity) { + return new Vec3d(entity.posX, entity.posY + IPlayerContext.eyeHeight(true), entity.posZ); + } } diff --git a/src/api/java/baritone/api/utils/RotationUtils.java b/src/api/java/baritone/api/utils/RotationUtils.java index e19f531df..39e68fd4f 100644 --- a/src/api/java/baritone/api/utils/RotationUtils.java +++ b/src/api/java/baritone/api/utils/RotationUtils.java @@ -140,6 +140,10 @@ public final class RotationUtils { return reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance()); } + public static Optional reachable(IPlayerContext ctx, BlockPos pos, boolean wouldSneak) { + return reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance(), wouldSneak); + } + /** * Determines if the specified entity is able to reach the center of any of the sides * of the specified block. It first checks if the block center is reachable, and if so, @@ -153,6 +157,10 @@ public final class RotationUtils { * @return The optional rotation */ public static Optional reachable(EntityPlayerSP entity, BlockPos pos, double blockReachDistance) { + return reachable(entity, pos, blockReachDistance, false); + } + + public static Optional reachable(EntityPlayerSP entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) { IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer(entity); if (baritone.getPlayerContext().isLookingAt(pos)) { /* @@ -165,9 +173,18 @@ public final class RotationUtils { * * or if you're a normal person literally all this does it ensure that we don't nudge the pitch to a normal level */ - return Optional.of(new Rotation(entity.rotationYaw, entity.rotationPitch + 0.0001F)); + Rotation hypothetical = new Rotation(entity.rotationYaw, entity.rotationPitch + 0.0001F); + if (wouldSneak) { + // the concern here is: what if we're looking at it now, but as soon as we start sneaking we no longer are + RayTraceResult result = RayTraceUtils.rayTraceTowards(entity, hypothetical, blockReachDistance, true); + if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK && result.getBlockPos().equals(pos)) { + return Optional.of(hypothetical); // yes, if we sneaked we would still be looking at the block + } + } else { + return Optional.of(hypothetical); + } } - Optional possibleRotation = reachableCenter(entity, pos, blockReachDistance); + Optional possibleRotation = reachableCenter(entity, pos, blockReachDistance, wouldSneak); //System.out.println("center: " + possibleRotation); if (possibleRotation.isPresent()) { return possibleRotation; @@ -179,7 +196,7 @@ public final class RotationUtils { double xDiff = aabb.minX * sideOffset.x + aabb.maxX * (1 - sideOffset.x); double yDiff = aabb.minY * sideOffset.y + aabb.maxY * (1 - sideOffset.y); double zDiff = aabb.minZ * sideOffset.z + aabb.maxZ * (1 - sideOffset.z); - possibleRotation = reachableOffset(entity, pos, new Vec3d(pos).add(xDiff, yDiff, zDiff), blockReachDistance); + possibleRotation = reachableOffset(entity, pos, new Vec3d(pos).add(xDiff, yDiff, zDiff), blockReachDistance, wouldSneak); if (possibleRotation.isPresent()) { return possibleRotation; } @@ -198,9 +215,10 @@ public final class RotationUtils { * @param blockReachDistance The block reach distance of the entity * @return The optional rotation */ - public static Optional reachableOffset(Entity entity, BlockPos pos, Vec3d offsetPos, double blockReachDistance) { - Rotation rotation = calcRotationFromVec3d(entity.getPositionEyes(1.0F), offsetPos, new Rotation(entity.rotationYaw, entity.rotationPitch)); - RayTraceResult result = RayTraceUtils.rayTraceTowards(entity, rotation, blockReachDistance); + public static Optional reachableOffset(Entity entity, BlockPos pos, Vec3d offsetPos, double blockReachDistance, boolean wouldSneak) { + Vec3d eyes = wouldSneak ? RayTraceUtils.inferSneakingEyePosition(entity) : entity.getPositionEyes(1.0F); + Rotation rotation = calcRotationFromVec3d(eyes, offsetPos, new Rotation(entity.rotationYaw, entity.rotationPitch)); + RayTraceResult result = RayTraceUtils.rayTraceTowards(entity, rotation, blockReachDistance, wouldSneak); //System.out.println(result); if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK) { if (result.getBlockPos().equals(pos)) { @@ -222,7 +240,7 @@ public final class RotationUtils { * @param blockReachDistance The block reach distance of the entity * @return The optional rotation */ - public static Optional reachableCenter(Entity entity, BlockPos pos, double blockReachDistance) { - return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.world, pos), blockReachDistance); + public static Optional reachableCenter(Entity entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) { + return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.world, pos), blockReachDistance, wouldSneak); } } diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index ca4abe9e3..c46b24dea 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -177,7 +177,7 @@ public abstract class Movement implements IMovement, MovementHelper { //i'm doing it anyway //i dont care if theres snow in the way!!!!!!! //you dont own me!!!! - state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.player().getPositionEyes(1.0F), + state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(blockPos), ctx.playerRotations()), true) ); // don't check selectedblock on this one, this is a fallback when we can't see any face directly, it's intended to be breaking the "incorrect" block diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 31a1de7a6..7e1c567a3 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -502,9 +502,9 @@ public interface MovementHelper extends ActionCosts, Helper { } - static PlaceResult attemptToPlaceABlock(MovementState state, IBaritone baritone, BlockPos placeAt, boolean preferDown) { + static PlaceResult attemptToPlaceABlock(MovementState state, IBaritone baritone, BlockPos placeAt, boolean preferDown, boolean wouldSneak) { IPlayerContext ctx = baritone.getPlayerContext(); - Optional direct = RotationUtils.reachable(ctx, placeAt); // we assume that if there is a block there, it must be replacable + Optional direct = RotationUtils.reachable(ctx, placeAt, wouldSneak); // we assume that if there is a block there, it must be replacable boolean found = false; if (direct.isPresent()) { state.setTarget(new MovementState.MovementTarget(direct.get(), true)); @@ -522,7 +522,7 @@ public interface MovementHelper extends ActionCosts, Helper { double faceY = (placeAt.getY() + against1.getY() + 0.5D) * 0.5D; double faceZ = (placeAt.getZ() + against1.getZ() + 1.0D) * 0.5D; Rotation place = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(faceX, faceY, faceZ), ctx.playerRotations()); - RayTraceResult res = RayTraceUtils.rayTraceTowards(ctx.player(), place, ctx.playerController().getBlockReachDistance()); + RayTraceResult res = RayTraceUtils.rayTraceTowards(ctx.player(), place, ctx.playerController().getBlockReachDistance(), wouldSneak); if (res != null && res.typeOfHit == RayTraceResult.Type.BLOCK && res.getBlockPos().equals(against1) && res.getBlockPos().offset(res.sideHit).equals(placeAt)) { state.setTarget(new MovementState.MovementTarget(place, true)); found = true; @@ -540,11 +540,17 @@ public interface MovementHelper extends ActionCosts, Helper { EnumFacing side = ctx.objectMouseOver().sideHit; // only way for selectedBlock.equals(placeAt) to be true is if it's replacable if (selectedBlock.equals(placeAt) || (MovementHelper.canPlaceAgainst(ctx, selectedBlock) && selectedBlock.offset(side).equals(placeAt))) { + if (wouldSneak) { + state.setInput(Input.SNEAK, true); + } ((Baritone) baritone).getInventoryBehavior().selectThrowawayForLocation(true, placeAt.getX(), placeAt.getY(), placeAt.getZ()); return PlaceResult.READY_TO_PLACE; } } if (found) { + if (wouldSneak) { + state.setInput(Input.SNEAK, true); + } ((Baritone) baritone).getInventoryBehavior().selectThrowawayForLocation(true, placeAt.getX(), placeAt.getY(), placeAt.getZ()); return PlaceResult.ATTEMPTING; } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index 4f35ef8eb..161ffdacd 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -175,7 +175,7 @@ public class MovementAscend extends Movement { IBlockState jumpingOnto = BlockStateInterface.get(ctx, positionToPlace); if (!MovementHelper.canWalkOn(ctx, positionToPlace, jumpingOnto)) { ticksWithoutPlacement++; - if (MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false) == PlaceResult.READY_TO_PLACE) { + if (MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false, true) == PlaceResult.READY_TO_PLACE) { state.setInput(Input.SNEAK, true); if (ctx.player().isSneaking()) { state.setInput(Input.CLICK_RIGHT, true); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index 67b7cd95a..128d1bf99 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -224,7 +224,7 @@ public class MovementDescend extends Movement { double destZ = (src.getZ() + 0.5) * 0.17 + (dest.getZ() + 0.5) * 0.83; EntityPlayerSP player = ctx.player(); state.setTarget(new MovementState.MovementTarget( - new Rotation(RotationUtils.calcRotationFromVec3d(player.getPositionEyes(1.0F), + new Rotation(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(destX, dest.getY(), destZ), new Rotation(player.rotationYaw, player.rotationPitch)).getYaw(), player.rotationPitch), false diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 3d3426da2..b9a0fd446 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -250,7 +250,7 @@ public class MovementParkour extends Movement { } } else if (!ctx.playerFeet().equals(src)) { if (ctx.playerFeet().equals(src.offset(direction)) || ctx.player().posY - src.y > 0.0001) { - if (!MovementHelper.canWalkOn(ctx, dest.down()) && !ctx.player().onGround && MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), true) == PlaceResult.READY_TO_PLACE) { + if (!MovementHelper.canWalkOn(ctx, dest.down()) && !ctx.player().onGround && MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), true, false) == PlaceResult.READY_TO_PLACE) { // go in the opposite order to check DOWN before all horizontals -- down is preferable because you don't have to look to the side while in midair, which could mess up the trajectory state.setInput(Input.CLICK_RIGHT, true); } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index f6f8fc0d6..b9d599334 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -184,7 +184,7 @@ public class MovementPillar extends Movement { } boolean ladder = fromDown.getBlock() == Blocks.LADDER || fromDown.getBlock() == Blocks.VINE; boolean vine = fromDown.getBlock() == Blocks.VINE; - Rotation rotation = RotationUtils.calcRotationFromVec3d(ctx.player().getPositionEyes(1.0F), + Rotation rotation = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(positionToPlace), new Rotation(ctx.player().rotationYaw, ctx.player().rotationPitch)); if (!ladder) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 9990ed742..1ecf0f92c 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -280,7 +280,7 @@ public class MovementTraverse extends Movement { } } double dist1 = Math.max(Math.abs(ctx.player().posX - (dest.getX() + 0.5D)), Math.abs(ctx.player().posZ - (dest.getZ() + 0.5D))); - PlaceResult p = MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false); + PlaceResult p = MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false, true); if ((p == PlaceResult.READY_TO_PLACE || dist1 < 0.6) && !Baritone.settings().assumeSafeWalk.value) { state.setInput(Input.SNEAK, true); } diff --git a/src/main/java/baritone/process/BackfillProcess.java b/src/main/java/baritone/process/BackfillProcess.java index f025c3933..04b3ca78b 100644 --- a/src/main/java/baritone/process/BackfillProcess.java +++ b/src/main/java/baritone/process/BackfillProcess.java @@ -75,7 +75,7 @@ public final class BackfillProcess extends BaritoneProcessHelper { baritone.getInputOverrideHandler().clearAllKeys(); for (BlockPos toPlace : toFillIn()) { MovementState fake = new MovementState(); - switch (MovementHelper.attemptToPlaceABlock(fake, baritone, toPlace, false)) { + switch (MovementHelper.attemptToPlaceABlock(fake, baritone, toPlace, false, false)) { case NO_OPTION: continue; case READY_TO_PLACE: diff --git a/src/main/java/baritone/process/FarmProcess.java b/src/main/java/baritone/process/FarmProcess.java index 00273a9f4..a91fda60c 100644 --- a/src/main/java/baritone/process/FarmProcess.java +++ b/src/main/java/baritone/process/FarmProcess.java @@ -232,7 +232,7 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro both.addAll(openSoulsand); for (BlockPos pos : both) { boolean soulsand = openSoulsand.contains(pos); - Optional rot = RotationUtils.reachableOffset(ctx.player(), pos, new Vec3d(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5), ctx.playerController().getBlockReachDistance()); + Optional rot = RotationUtils.reachableOffset(ctx.player(), pos, new Vec3d(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5), ctx.playerController().getBlockReachDistance(), false); if (rot.isPresent() && isSafeToCancel && baritone.getInventoryBehavior().throwaway(true, soulsand ? this::isNetherWart : this::isPlantable)) { RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot.get(), ctx.playerController().getBlockReachDistance()); if (result.typeOfHit == RayTraceResult.Type.BLOCK && result.sideHit == EnumFacing.UP) { From 61563c93594186976070611dce19b832be99791a Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Feb 2020 19:27:11 -0800 Subject: [PATCH 30/41] builderprocess should use hypothetical sneaking --- 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 4efa2c954..5af434923 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -278,8 +278,8 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil double placeX = placeAgainstPos.x + aabb.minX * placementMultiplier.x + aabb.maxX * (1 - placementMultiplier.x); double placeY = placeAgainstPos.y + aabb.minY * placementMultiplier.y + aabb.maxY * (1 - placementMultiplier.y); double placeZ = placeAgainstPos.z + aabb.minZ * placementMultiplier.z + aabb.maxZ * (1 - placementMultiplier.z); - Rotation rot = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(placeX, placeY, placeZ), ctx.playerRotations()); - RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot, ctx.playerController().getBlockReachDistance()); + Rotation rot = RotationUtils.calcRotationFromVec3d(RayTraceUtils.inferSneakingEyePosition(ctx.player()), new Vec3d(placeX, placeY, placeZ), ctx.playerRotations()); + RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot, ctx.playerController().getBlockReachDistance(), true); if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK && result.getBlockPos().equals(placeAgainstPos) && result.sideHit == against.getOpposite()) { OptionalInt hotbar = hasAnyItemThatWouldPlace(toPlace, result, rot); if (hotbar.isPresent()) { From 4b526f724281d970ebb297b8e1c4cba5ad625f80 Mon Sep 17 00:00:00 2001 From: aUniqueUser Date: Tue, 25 Feb 2020 21:13:20 -0500 Subject: [PATCH 31/41] Custom Tunneling --- .../command/defaults/TunnelCommand.java | 64 +++++++++++++++---- 1 file changed, 52 insertions(+), 12 deletions(-) diff --git a/src/main/java/baritone/command/defaults/TunnelCommand.java b/src/main/java/baritone/command/defaults/TunnelCommand.java index 991a7ff81..3a24ca3ab 100644 --- a/src/main/java/baritone/command/defaults/TunnelCommand.java +++ b/src/main/java/baritone/command/defaults/TunnelCommand.java @@ -18,11 +18,13 @@ package baritone.command.defaults; import baritone.api.IBaritone; +import baritone.api.command.Command; +import baritone.api.command.argument.IArgConsumer; +import baritone.api.command.exception.CommandException; import baritone.api.pathing.goals.Goal; import baritone.api.pathing.goals.GoalStrictDirection; -import baritone.api.command.Command; -import baritone.api.command.exception.CommandException; -import baritone.api.command.argument.IArgConsumer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import java.util.Arrays; import java.util.List; @@ -36,13 +38,50 @@ public class TunnelCommand extends Command { @Override public void execute(String label, IArgConsumer args) throws CommandException { - args.requireMax(0); - Goal goal = new GoalStrictDirection( - ctx.playerFeet(), - ctx.player().getHorizontalFacing() - ); - baritone.getCustomGoalProcess().setGoalAndPath(goal); - logDirect(String.format("Goal: %s", goal.toString())); + args.requireMax(3); + if (args.hasExactly(3)) { + boolean cont = true; + int depth = Integer.parseInt(args.peekString(0))-1; + int height = Integer.parseInt(args.peekString(1))-1; + int width = Integer.parseInt(args.peekString(2))-1; + + if (width < 1 || height < 2) { + logDirect("Width must at least be 1 block, Height must at least be 2 blocks"); + cont = false; + } + + if (cont) { + BlockPos corner1 = null, corner2 = null; + EnumFacing enumfacing = ctx.player().getHorizontalFacing(); + int addition = ((width % 2 == 0) ? 0 : 1); + switch (enumfacing) { + case EAST: + corner1 = new BlockPos(ctx.playerFeet().x, ctx.playerFeet().y, ctx.playerFeet().z - width / 2); + corner2 = new BlockPos(ctx.playerFeet().x + depth, ctx.playerFeet().y + height, ctx.playerFeet().z + width / 2 + addition); + break; + case WEST: + corner1 = new BlockPos(ctx.playerFeet().x, ctx.playerFeet().y, ctx.playerFeet().z + width / 2 + addition); + corner2 = new BlockPos(ctx.playerFeet().x - depth, ctx.playerFeet().y + height, ctx.playerFeet().z - width / 2); + break; + case NORTH: + corner1 = new BlockPos(ctx.playerFeet().x - width / 2, ctx.playerFeet().y, ctx.playerFeet().z); + corner2 = new BlockPos(ctx.playerFeet().x + width / 2 + addition, ctx.playerFeet().y + height, ctx.playerFeet().z - depth); + break; + case SOUTH: + corner1 = new BlockPos(ctx.playerFeet().x + width / 2 + addition, ctx.playerFeet().y, ctx.playerFeet().z); + corner2 = new BlockPos(ctx.playerFeet().x - width / 2, ctx.playerFeet().y + height, ctx.playerFeet().z + depth); + break; + } + baritone.getBuilderProcess().clearArea(corner1, corner2); + } + } else { + Goal goal = new GoalStrictDirection( + ctx.playerFeet(), + ctx.player().getHorizontalFacing() + ); + baritone.getCustomGoalProcess().setGoalAndPath(goal); + logDirect(String.format("Goal: %s", goal.toString())); + } } @Override @@ -61,7 +100,8 @@ public class TunnelCommand extends Command { "The tunnel command sets a goal that tells Baritone to mine completely straight in the direction that you're facing.", "", "Usage:", - "> tunnel" + "> tunnel - No arguments, mines in a 1x2 radius.", + "> tunnel depth/height/width - Tunnels in a user defined depth, height and width." ); } -} +} \ No newline at end of file From 3c2838df9eb584dc75acbb0af42bd0dbb3512590 Mon Sep 17 00:00:00 2001 From: aUniqueUser Date: Tue, 25 Feb 2020 21:22:35 -0500 Subject: [PATCH 32/41] lol --- src/main/java/baritone/command/defaults/TunnelCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/command/defaults/TunnelCommand.java b/src/main/java/baritone/command/defaults/TunnelCommand.java index 3a24ca3ab..2831675b9 100644 --- a/src/main/java/baritone/command/defaults/TunnelCommand.java +++ b/src/main/java/baritone/command/defaults/TunnelCommand.java @@ -41,7 +41,7 @@ public class TunnelCommand extends Command { args.requireMax(3); if (args.hasExactly(3)) { boolean cont = true; - int depth = Integer.parseInt(args.peekString(0))-1; + int depth = Integer.parseInt(args.peekString(0)); int height = Integer.parseInt(args.peekString(1))-1; int width = Integer.parseInt(args.peekString(2))-1; From acd9bcceeba16fac47f19a2bcf47a074fd246a46 Mon Sep 17 00:00:00 2001 From: aUniqueUser Date: Tue, 25 Feb 2020 21:47:35 -0500 Subject: [PATCH 33/41] Codacy --- src/main/java/baritone/command/defaults/TunnelCommand.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/command/defaults/TunnelCommand.java b/src/main/java/baritone/command/defaults/TunnelCommand.java index 2831675b9..3972a3254 100644 --- a/src/main/java/baritone/command/defaults/TunnelCommand.java +++ b/src/main/java/baritone/command/defaults/TunnelCommand.java @@ -51,7 +51,8 @@ public class TunnelCommand extends Command { } if (cont) { - BlockPos corner1 = null, corner2 = null; + BlockPos corner1; + BlockPos corner2; EnumFacing enumfacing = ctx.player().getHorizontalFacing(); int addition = ((width % 2 == 0) ? 0 : 1); switch (enumfacing) { @@ -71,6 +72,8 @@ public class TunnelCommand extends Command { corner1 = new BlockPos(ctx.playerFeet().x + width / 2 + addition, ctx.playerFeet().y, ctx.playerFeet().z); corner2 = new BlockPos(ctx.playerFeet().x - width / 2, ctx.playerFeet().y + height, ctx.playerFeet().z + depth); break; + default: + throw new IllegalStateException("Unexpected value: " + enumfacing); } baritone.getBuilderProcess().clearArea(corner1, corner2); } From 6f136a90a28db9527fbbec7cd5db90194d9d6df9 Mon Sep 17 00:00:00 2001 From: CDAGaming Date: Wed, 26 Feb 2020 07:55:21 -0600 Subject: [PATCH 34/41] [Change] Adjustments --- .../command/defaults/TunnelCommand.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/baritone/command/defaults/TunnelCommand.java b/src/main/java/baritone/command/defaults/TunnelCommand.java index 3972a3254..6121679ae 100644 --- a/src/main/java/baritone/command/defaults/TunnelCommand.java +++ b/src/main/java/baritone/command/defaults/TunnelCommand.java @@ -41,21 +41,21 @@ public class TunnelCommand extends Command { args.requireMax(3); if (args.hasExactly(3)) { boolean cont = true; - int depth = Integer.parseInt(args.peekString(0)); - int height = Integer.parseInt(args.peekString(1))-1; - int width = Integer.parseInt(args.peekString(2))-1; + int depth = Integer.parseInt(args.getArgs().get(0).getValue()); + int height = Integer.parseInt(args.getArgs().get(1).getValue()); + int width = Integer.parseInt(args.getArgs().get(2).getValue()); - if (width < 1 || height < 2) { - logDirect("Width must at least be 1 block, Height must at least be 2 blocks"); + if (width < 1 || height < 2 || depth < 1) { + logDirect("Width and depth must at least be 1 block; Height must at least be 2 blocks"); cont = false; } if (cont) { BlockPos corner1; BlockPos corner2; - EnumFacing enumfacing = ctx.player().getHorizontalFacing(); + EnumFacing enumFacing = ctx.player().getHorizontalFacing(); int addition = ((width % 2 == 0) ? 0 : 1); - switch (enumfacing) { + switch (enumFacing) { case EAST: corner1 = new BlockPos(ctx.playerFeet().x, ctx.playerFeet().y, ctx.playerFeet().z - width / 2); corner2 = new BlockPos(ctx.playerFeet().x + depth, ctx.playerFeet().y + height, ctx.playerFeet().z + width / 2 + addition); @@ -73,8 +73,9 @@ public class TunnelCommand extends Command { corner2 = new BlockPos(ctx.playerFeet().x - width / 2, ctx.playerFeet().y + height, ctx.playerFeet().z + depth); break; default: - throw new IllegalStateException("Unexpected value: " + enumfacing); + throw new IllegalStateException("Unexpected value: " + enumFacing); } + logDirect(String.format("Creating a tunnel %s block(s) deep, %s block(s) wide, and %s block(s) high", depth, width, height)); baritone.getBuilderProcess().clearArea(corner1, corner2); } } else { @@ -107,4 +108,4 @@ public class TunnelCommand extends Command { "> tunnel depth/height/width - Tunnels in a user defined depth, height and width." ); } -} \ No newline at end of file +} From e3b91c884a8e3664a72a4c5c36518d6e6b099b09 Mon Sep 17 00:00:00 2001 From: aUniqueUser Date: Wed, 26 Feb 2020 12:30:07 -0500 Subject: [PATCH 35/41] More logical argument order --- .../baritone/command/defaults/TunnelCommand.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/command/defaults/TunnelCommand.java b/src/main/java/baritone/command/defaults/TunnelCommand.java index 6121679ae..e404f23b4 100644 --- a/src/main/java/baritone/command/defaults/TunnelCommand.java +++ b/src/main/java/baritone/command/defaults/TunnelCommand.java @@ -41,16 +41,18 @@ public class TunnelCommand extends Command { args.requireMax(3); if (args.hasExactly(3)) { boolean cont = true; - int depth = Integer.parseInt(args.getArgs().get(0).getValue()); - int height = Integer.parseInt(args.getArgs().get(1).getValue()); - int width = Integer.parseInt(args.getArgs().get(2).getValue()); + int height = Integer.parseInt(args.getArgs().get(0).getValue()); + int width = Integer.parseInt(args.getArgs().get(1).getValue()); + int depth = Integer.parseInt(args.getArgs().get(2).getValue()); - if (width < 1 || height < 2 || depth < 1) { - logDirect("Width and depth must at least be 1 block; Height must at least be 2 blocks"); + if (width < 1 || height < 2 || depth < 1 || height > 255) { + logDirect("Width and depth must at least be 1 block; Height must at least be 2 blocks, and cannot be greater than the build limit."); cont = false; } if (cont) { + height--; + width--; BlockPos corner1; BlockPos corner2; EnumFacing enumFacing = ctx.player().getHorizontalFacing(); @@ -75,7 +77,7 @@ public class TunnelCommand extends Command { default: throw new IllegalStateException("Unexpected value: " + enumFacing); } - logDirect(String.format("Creating a tunnel %s block(s) deep, %s block(s) wide, and %s block(s) high", depth, width, height)); + logDirect(String.format("Creating a tunnel %s block(s) high, %s block(s) wide, and %s block(s) deep", height+1, width+1, depth)); baritone.getBuilderProcess().clearArea(corner1, corner2); } } else { From 628ec0f2b570248a372d7240e5e4198e0354225a Mon Sep 17 00:00:00 2001 From: aUniqueUser Date: Wed, 26 Feb 2020 13:04:10 -0500 Subject: [PATCH 36/41] updated longDesc --- src/main/java/baritone/command/defaults/TunnelCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/command/defaults/TunnelCommand.java b/src/main/java/baritone/command/defaults/TunnelCommand.java index e404f23b4..d346e9df7 100644 --- a/src/main/java/baritone/command/defaults/TunnelCommand.java +++ b/src/main/java/baritone/command/defaults/TunnelCommand.java @@ -107,7 +107,7 @@ public class TunnelCommand extends Command { "", "Usage:", "> tunnel - No arguments, mines in a 1x2 radius.", - "> tunnel depth/height/width - Tunnels in a user defined depth, height and width." + "> tunnel height/width/depth - Tunnels in a user defined height, width and depth." ); } } From f1f4adf8a6c04f262458813c872af33365d74500 Mon Sep 17 00:00:00 2001 From: Bella Who Date: Thu, 27 Feb 2020 17:42:12 -0500 Subject: [PATCH 37/41] Update USAGE.md as per #1332 --- USAGE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/USAGE.md b/USAGE.md index d1592acd5..ce761b8ea 100644 --- a/USAGE.md +++ b/USAGE.md @@ -44,7 +44,7 @@ Some common examples: - `save waypointName` to save a waypoint. `goto waypointName` to go to it. - `build` to build a schematic. `build blah` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah 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 just straight ahead and make a tunnel +- `tunnel height/width/depth` to dig and make a tunnel. If you don't supply numbers then it just digs a 1x2 tunnel. - `farm` to automatically harvest, replant, or bone meal crops - `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. From 9fb46946b57c110df8aacb37fad70e27fc886b05 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 27 Feb 2020 18:05:05 -0800 Subject: [PATCH 38/41] fix sprint while paused bug, fixes #1331 --- src/launch/java/baritone/launch/mixins/MixinMinecraft.java | 2 +- src/main/java/baritone/behavior/PathingBehavior.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/launch/java/baritone/launch/mixins/MixinMinecraft.java b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java index 3de4a0f54..51e9959f3 100644 --- a/src/launch/java/baritone/launch/mixins/MixinMinecraft.java +++ b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java @@ -145,7 +145,7 @@ public class MixinMinecraft { ) private boolean isAllowUserInput(GuiScreen screen) { // allow user input is only the primary baritone - return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().getCurrent() != null && player != null) || screen.allowUserInput; + return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing() && player != null) || screen.allowUserInput; } @Inject( diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 86fd95055..50ca7425f 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -103,7 +103,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, @Override public void onPlayerSprintState(SprintStateEvent event) { - if (current != null) { + if (isPathing()) { event.setState(current.isSprinting()); } } From 17c691b1cfa4f05e97906ff7abf64c7d1e06b692 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 27 Feb 2020 18:06:11 -0800 Subject: [PATCH 39/41] the whole point is its better to do something nonsensical than to crash, so lets continue in that direction --- .../baritone/utils/BlockStateInterfaceAccessWrapper.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/utils/BlockStateInterfaceAccessWrapper.java b/src/main/java/baritone/utils/BlockStateInterfaceAccessWrapper.java index 6ce70193f..6dded1dd5 100644 --- a/src/main/java/baritone/utils/BlockStateInterfaceAccessWrapper.java +++ b/src/main/java/baritone/utils/BlockStateInterfaceAccessWrapper.java @@ -19,6 +19,7 @@ package baritone.utils; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Biomes; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; @@ -44,12 +45,12 @@ public final class BlockStateInterfaceAccessWrapper implements IBlockAccess { @Nullable @Override public TileEntity getTileEntity(BlockPos pos) { - throw new UnsupportedOperationException("getTileEntity not supported by BlockStateInterfaceAccessWrapper"); + return null; } @Override public int getCombinedLight(BlockPos pos, int lightValue) { - throw new UnsupportedOperationException("getCombinedLight not supported by BlockStateInterfaceAccessWrapper"); + return 0; } @Override @@ -65,12 +66,12 @@ public final class BlockStateInterfaceAccessWrapper implements IBlockAccess { @Override public Biome getBiome(BlockPos pos) { - throw new UnsupportedOperationException("getBiome not supported by BlockStateInterfaceAccessWrapper"); + return Biomes.FOREST; } @Override public int getStrongPower(BlockPos pos, EnumFacing direction) { - throw new UnsupportedOperationException("getStrongPower not supported by BlockStateInterfaceAccessWrapper"); + return 0; } @Override From 0ca3c496de110b71aa8031b0bc1d856dcb7b88cf Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 2 Mar 2020 13:40:43 -0600 Subject: [PATCH 40/41] Fix tunnel command usage --- src/main/java/baritone/command/defaults/TunnelCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/command/defaults/TunnelCommand.java b/src/main/java/baritone/command/defaults/TunnelCommand.java index d346e9df7..6f7304a6a 100644 --- a/src/main/java/baritone/command/defaults/TunnelCommand.java +++ b/src/main/java/baritone/command/defaults/TunnelCommand.java @@ -107,7 +107,7 @@ public class TunnelCommand extends Command { "", "Usage:", "> tunnel - No arguments, mines in a 1x2 radius.", - "> tunnel height/width/depth - Tunnels in a user defined height, width and depth." + "> tunnel - Tunnels in a user defined height, width and depth." ); } } From 96a8bb90c9444a3e15f91ad8be6f656703d1d6bb Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 2 Mar 2020 13:41:21 -0600 Subject: [PATCH 41/41] Fix tunnel usage in USAGE.md --- USAGE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/USAGE.md b/USAGE.md index ce761b8ea..681298b01 100644 --- a/USAGE.md +++ b/USAGE.md @@ -44,7 +44,7 @@ Some common examples: - `save waypointName` to save a waypoint. `goto waypointName` to go to it. - `build` to build a schematic. `build blah` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah 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 height/width/depth` to dig and make a tunnel. If you don't supply numbers then it just digs a 1x2 tunnel. +- `tunnel height width depth` to dig and make a tunnel. If you don't supply numbers then it just digs a 1x2 tunnel. - `farm` to automatically harvest, replant, or bone meal crops - `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.