From 60d6791f0c9aa695d5afcd75a4b9ae767b5fe2c1 Mon Sep 17 00:00:00 2001 From: Babbaj Date: Wed, 16 Aug 2023 00:27:23 -0400 Subject: [PATCH 01/27] proguard: get java from gradle runtime before JAVA_HOME --- .../src/main/java/baritone/gradle/task/ProguardTask.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java b/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java index 435eabcf3..810d5ef27 100644 --- a/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java +++ b/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java @@ -114,6 +114,9 @@ public class ProguardTask extends BaritoneGradleTask { ex.printStackTrace(); } + path = findJavaByGradleCurrentRuntime(); + if (path != null) return path; + try { path = findJavaByJavaHome(); if (path != null) return path; @@ -122,10 +125,6 @@ public class ProguardTask extends BaritoneGradleTask { ex.printStackTrace(); } - - path = findJavaByGradleCurrentRuntime(); - if (path != null) return path; - throw new Exception("Unable to find java to determine ProGuard libraryjars. Please specify forkOptions.executable in javaCompile," + " JAVA_HOME environment variable, or make sure to run Gradle with the correct JDK (a v1.8 only)"); } From 8a2a20a1b353170162499bb678c86b9231cc04cf Mon Sep 17 00:00:00 2001 From: leijurv Date: Thu, 17 Aug 2023 14:40:26 -0700 Subject: [PATCH 02/27] 1.16 and 1.18 deprecated --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bc3552c5a..dc97c1fc6 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ Minecraft Minecraft Minecraft - Minecraft + Minecraft Minecraft - Minecraft + Minecraft Minecraft Minecraft Minecraft From d4b95110f52398971af17a380ebd0fa05f272365 Mon Sep 17 00:00:00 2001 From: leijurv Date: Thu, 17 Aug 2023 16:56:22 -0700 Subject: [PATCH 03/27] fml --- src/main/java/baritone/command/defaults/ElytraCommand.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/baritone/command/defaults/ElytraCommand.java b/src/main/java/baritone/command/defaults/ElytraCommand.java index 5895c36ad..879a6eabf 100644 --- a/src/main/java/baritone/command/defaults/ElytraCommand.java +++ b/src/main/java/baritone/command/defaults/ElytraCommand.java @@ -177,7 +177,6 @@ public class ElytraCommand extends Command { } private boolean detectOn2b2t() { - if (true) return true; ServerData data = ctx.minecraft().getCurrentServerData(); return data != null && data.serverIP.toLowerCase().contains("2b2t.org"); } From d9cb2d91a06501c5bcba2181509d0df80361f413 Mon Sep 17 00:00:00 2001 From: leijurv Date: Thu, 17 Aug 2023 16:57:11 -0700 Subject: [PATCH 04/27] v1.2.19 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b91dcf43c..888a818ac 100755 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ */ group 'baritone' -version '1.2.18' +version '1.2.19' buildscript { repositories { From 75b8554a11759e8057ba2a936cf5d8e848259f8e Mon Sep 17 00:00:00 2001 From: leijurv Date: Thu, 17 Aug 2023 17:14:33 -0700 Subject: [PATCH 05/27] bump readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dc97c1fc6..11a12e822 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Baritone is the pathfinding system used in [Impact](https://impactclient.net/) s | Forge | Fabric | |---------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------| -| [1.12.2 Forge](https://github.com/cabaletta/baritone/releases/download/v1.2.18/baritone-api-forge-1.2.18.jar) | | +| [1.12.2 Forge](https://github.com/cabaletta/baritone/releases/download/v1.2.19/baritone-api-forge-1.2.19.jar) | | | [1.16.5 Forge](https://github.com/cabaletta/baritone/releases/download/v1.6.5/baritone-api-forge-1.6.5.jar) | [1.16.5 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.6.5/baritone-api-fabric-1.6.5.jar) | | [1.17.1 Forge](https://github.com/cabaletta/baritone/releases/download/v1.7.3/baritone-api-forge-1.7.3.jar) | [1.17.1 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.7.3/baritone-api-fabric-1.7.3.jar) | | [1.18.2 Forge](https://github.com/cabaletta/baritone/releases/download/v1.8.5/baritone-api-forge-1.8.5.jar) | [1.18.2 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.8.5/baritone-api-fabric-1.8.5.jar) | From c2308c650a1dc2d712d8a1ea7b7530dd67836e64 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 18 Aug 2023 14:35:02 -0700 Subject: [PATCH 06/27] mapping --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 5b420a0e4..03a2f7d64 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,5 @@ baritone_Client.launch libs/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar libs/java-objc-bridge-1.1.jar + +mapping From 4efa2b1272e9e4244eada40130080fd490ccf560 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 18 Aug 2023 15:02:13 -0700 Subject: [PATCH 07/27] fix backtracking bad behavior when render distance is tiny --- .../baritone/process/elytra/ElytraBehavior.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/process/elytra/ElytraBehavior.java b/src/main/java/baritone/process/elytra/ElytraBehavior.java index 709d22334..c6207b08f 100644 --- a/src/main/java/baritone/process/elytra/ElytraBehavior.java +++ b/src/main/java/baritone/process/elytra/ElytraBehavior.java @@ -330,12 +330,19 @@ public final class ElytraBehavior implements Helper { } if (!ElytraBehavior.this.clearView(this.path.getVec(i), this.path.getVec(i + 1), false)) { // obstacle. where do we return to pathing? - // find the next valid segment + // if the end of render distance is closer to goal, then that's fine, otherwise we'd be "digging our hole deeper" and making an already bad backtrack worse + int rejoinMainPathAt; + if (this.path.get(rangeEndExcl - 1).distanceSq(this.path.get(path.size() - 1)) < ctx.playerFeet().distanceSq(this.path.get(path.size() - 1))) { + rejoinMainPathAt = rangeEndExcl - 1; // rejoin after current render distance + } else { + rejoinMainPathAt = path.size() - 1; // large backtrack detected. ignore render distance, rejoin later on + } + final BetterBlockPos blockage = this.path.get(i); - final double distance = ctx.playerFeet().distanceTo(this.path.get(rangeEndExcl - 1)); + final double distance = ctx.playerFeet().distanceTo(this.path.get(rejoinMainPathAt)); final long start = System.nanoTime(); - this.pathRecalcSegment(rangeEndExcl - 1) + this.pathRecalcSegment(rejoinMainPathAt) .thenRun(() -> { logDirect(String.format("Recalculated segment around path blockage near %s %s %s (next %.1f blocks in %.4f seconds)", SettingsUtil.maybeCensor(blockage.x), From 3bdd0a81a5b0975cfb59c54cb1d1766098663949 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 18 Aug 2023 17:49:37 -0700 Subject: [PATCH 08/27] rm debug --- src/main/java/baritone/behavior/LookBehavior.java | 1 - src/main/java/baritone/process/ElytraProcess.java | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java index e694a8ee0..98e12aeff 100644 --- a/src/main/java/baritone/behavior/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -82,7 +82,6 @@ public final class LookBehavior extends Behavior implements ILookBehavior { @Override public void onPlayerUpdate(PlayerUpdateEvent event) { - System.out.println(event.getState() + " " + ctx.player().getXRot() + " " + ctx.player().getYRot() + " " + ctx.player().xRotO + " " + ctx.player().yRotO); if (this.target == null) { return; diff --git a/src/main/java/baritone/process/ElytraProcess.java b/src/main/java/baritone/process/ElytraProcess.java index e0b6a1a03..d1e10a5cf 100644 --- a/src/main/java/baritone/process/ElytraProcess.java +++ b/src/main/java/baritone/process/ElytraProcess.java @@ -405,8 +405,6 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro @Override public void onRenderPass(RenderEvent event) { - System.out.println(event.getPartialTicks() + " " + ctx.player().getXRot() + " " + ctx.player().getYRot() + " " + ctx.player().xRotO + " " + ctx.player().yRotO); - if (this.behavior != null) this.behavior.onRenderPass(event); } From c18fa512ef1acd2df266653f20e6bea8dad80d83 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 18 Aug 2023 17:53:44 -0700 Subject: [PATCH 09/27] 1.19 defaults --- src/api/java/baritone/api/Settings.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 177c8988d..adbbd6eaa 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -743,7 +743,7 @@ public final class Settings { /** * Automatically elytra fly without having to force the client-sided rotations. */ - public final Setting elytraFreeLook = new Setting<>(false); + public final Setting elytraFreeLook = new Setting<>(true); /** * Forces the client-sided yaw rotation to an average of the last {@link #smoothLookTicks} of server-sided rotations. @@ -753,7 +753,7 @@ public final class Settings { /** * Same as {@link #smoothLook} but for elytra flying. */ - public final Setting elytraSmoothLook = new Setting<>(true); + public final Setting elytraSmoothLook = new Setting<>(false); /** * The number of ticks to average across for {@link #smoothLook}; @@ -1426,7 +1426,7 @@ public final class Settings { * Whether nether-pathfinder should generate terrain based on {@link #elytraNetherSeed}. * If false all chunks that haven't been loaded are assumed to be air. */ - public final Setting elytraPredictTerrain = new Setting<>(true); + public final Setting elytraPredictTerrain = new Setting<>(false); /** * Automatically swap the current elytra with a new one when the durability gets too low From 58d6b80f4f1ae2d0f20ac493fe9a1d6a5c19f857 Mon Sep 17 00:00:00 2001 From: leijurv Date: Fri, 18 Aug 2023 19:21:50 -0700 Subject: [PATCH 10/27] baritone elytra selling --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 11a12e822..c990292fc 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ Baritone is the pathfinding system used in [Impact](https://impactclient.net/) s | [1.19.4 Forge](https://github.com/cabaletta/baritone/releases/download/v1.9.3/baritone-api-forge-1.9.3.jar) | [1.19.4 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.9.3/baritone-api-fabric-1.9.3.jar) | | [1.20.1 Forge](https://github.com/cabaletta/baritone/releases/download/v1.10.1/baritone-api-forge-1.10.1.jar) | [1.20.1 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.10.1/baritone-api-fabric-1.10.1.jar) | -**Message for 2b2t players looking for 1.19/1.20 Baritone** Download it from right above ^. But also please check back in a few days for Baritone Elytra ([vid 1](https://youtu.be/4bGGPo8yiHo) [vid 2](https://www.youtube.com/watch?v=pUN9nmINe3I)), which will be ported to 1.19/1.20 soon! It will work on 2b2t with its anticheat, that was the whole point of Baritone Elytra (it's fully vanilla compatible). Also join [**the discord**](http://discord.gg/s6fRBAUpmr). Thanks! +**Message for 2b2t players looking for 1.19/1.20 Baritone** If you like, please try the beta for Baritone Elytra for 2b2t 1.19.4, find it in #announcements of [the Baritone discord](http://discord.gg/s6fRBAUpmr). If you have to see it to believe it, watch [this YouTube video](https://youtu.be/NnSlQi-68eQ). **How to immediately get started:** Type `#goto 1000 500` in chat to go to x=1000 z=500. Type `#mine diamond_ore` to mine diamond ore. Type `#stop` to stop. For more, read [the usage page](USAGE.md) and/or watch this [tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa). Also try `#elytra` for Elytra flying in the Nether using fireworks. From e063475ebd5dc180880846ad1a3c7e10a0a209bb Mon Sep 17 00:00:00 2001 From: leijurv Date: Fri, 18 Aug 2023 19:22:40 -0700 Subject: [PATCH 11/27] list 1.20 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c990292fc..3f2923f92 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ Baritone is the pathfinding system used in [Impact](https://impactclient.net/) s | [1.19.4 Forge](https://github.com/cabaletta/baritone/releases/download/v1.9.3/baritone-api-forge-1.9.3.jar) | [1.19.4 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.9.3/baritone-api-fabric-1.9.3.jar) | | [1.20.1 Forge](https://github.com/cabaletta/baritone/releases/download/v1.10.1/baritone-api-forge-1.10.1.jar) | [1.20.1 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.10.1/baritone-api-fabric-1.10.1.jar) | -**Message for 2b2t players looking for 1.19/1.20 Baritone** If you like, please try the beta for Baritone Elytra for 2b2t 1.19.4, find it in #announcements of [the Baritone discord](http://discord.gg/s6fRBAUpmr). If you have to see it to believe it, watch [this YouTube video](https://youtu.be/NnSlQi-68eQ). +**Message for 2b2t players looking for 1.19/1.20 Baritone** If you like, please try the beta for Baritone Elytra for 2b2t, find it in #announcements of [the Baritone discord](http://discord.gg/s6fRBAUpmr). It supports 1.19.4 and 1.20.1, Forge or Fabric. If you have to see it to believe it, watch [this YouTube video](https://youtu.be/NnSlQi-68eQ). **How to immediately get started:** Type `#goto 1000 500` in chat to go to x=1000 z=500. Type `#mine diamond_ore` to mine diamond ore. Type `#stop` to stop. For more, read [the usage page](USAGE.md) and/or watch this [tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa). Also try `#elytra` for Elytra flying in the Nether using fireworks. From aee36e4d85ce46838acbe4493d6ebed97981d385 Mon Sep 17 00:00:00 2001 From: leijurv Date: Fri, 18 Aug 2023 19:35:30 -0700 Subject: [PATCH 12/27] deprecate 1.12.2 --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 11a12e822..3167deb3d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ +# Warning: Old Branch!! + +**This branch (`master`) is Baritone for Minecraft 1.12.2. This is the original version of Minecraft that Baritone was written for, and it was the primary development branch for over 5 years. As such, it's quite mature, and arguably more reliable than Baritone for newer versions of Minecraft. Nevertheless, as of August 2023, with [2b2t's update from 1.12.2 to 1.19.4](https://2b2t.org/update/), I decided to move Baritone's primary development branch accordingly. PRs should now be made against the `1.19.4` branch going forward. This branch might see some fixes going forward, particularly to newer features such as `#elytra`, but it won't be the primary focus anymore.** + +The other intermediary branches (`1.13.2`, `1.14.4`, `1.15.2`, `1.16.5`, `1.17.1`, `1.18.2`, `1.19.2`, and `1.19.3`) will probably not receive any updates at all. You can find their last releases in the releases tab, or in the quick download links table. + +For `1.16.5` and `1.18.2`, the latest release is fully up to date with the code. ZacSharp merged master into some of those versions even after they were deprecated, if you are for some reason really interested in the latest Baritone bugfixes on these versions of Minecraft, you can build from source as of these commits: [1.13.2](https://github.com/cabaletta/baritone/commit/be54b8ee5b5639f80e3d6809ed1abd52444d8a08), [1.14.4](https://github.com/cabaletta/baritone/commit/be54b8ee5b5639f80e3d6809ed1abd52444d8a08), [1.15.2](https://github.com/cabaletta/baritone/commit/45abbb7fa1062cefc26abbb006a02a4edd6faa32), [1.17.1](https://github.com/cabaletta/baritone/commit/cbf0d79c9c5f7454071dc0a5289261ec9ca4373f), [1.19.2](https://github.com/cabaletta/baritone/commit/217dca53633610edc9483fda7a234e46c839fd99). For `1.19.3`, merging [this](https://github.com/cabaletta/baritone/commit/217dca53633610edc9483fda7a234e46c839fd99) commit into it is trivial and is left as an exercise for the reader. For other versions in between these (for example people always ask in the Discord for 1.16.1), you'll have to figure it out yourself. + # Baritone

GitHub All Releases From 301ad403508139cb2ee09bd44896ae6a251849ab Mon Sep 17 00:00:00 2001 From: leijurv Date: Fri, 18 Aug 2023 19:36:12 -0700 Subject: [PATCH 13/27] link to latest --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3167deb3d..2847001a3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Warning: Old Branch!! +**Click [here](https://github.com/cabaletta/baritone) to go to the current Baritone readme.** + **This branch (`master`) is Baritone for Minecraft 1.12.2. This is the original version of Minecraft that Baritone was written for, and it was the primary development branch for over 5 years. As such, it's quite mature, and arguably more reliable than Baritone for newer versions of Minecraft. Nevertheless, as of August 2023, with [2b2t's update from 1.12.2 to 1.19.4](https://2b2t.org/update/), I decided to move Baritone's primary development branch accordingly. PRs should now be made against the `1.19.4` branch going forward. This branch might see some fixes going forward, particularly to newer features such as `#elytra`, but it won't be the primary focus anymore.** The other intermediary branches (`1.13.2`, `1.14.4`, `1.15.2`, `1.16.5`, `1.17.1`, `1.18.2`, `1.19.2`, and `1.19.3`) will probably not receive any updates at all. You can find their last releases in the releases tab, or in the quick download links table. From 5f5567f283a0e51eb2b74b117abf448ce0f684e7 Mon Sep 17 00:00:00 2001 From: Babbaj Date: Sat, 19 Aug 2023 15:33:12 -0400 Subject: [PATCH 14/27] recover from flying into lava (and fix ignoreLava) --- .../java/baritone/process/elytra/ElytraBehavior.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/process/elytra/ElytraBehavior.java b/src/main/java/baritone/process/elytra/ElytraBehavior.java index 127f90131..7334f10b4 100644 --- a/src/main/java/baritone/process/elytra/ElytraBehavior.java +++ b/src/main/java/baritone/process/elytra/ElytraBehavior.java @@ -24,6 +24,7 @@ import baritone.api.behavior.look.ITickableAimProcessor; import baritone.api.event.events.*; import baritone.api.pathing.goals.GoalBlock; import baritone.api.utils.*; +import baritone.api.utils.input.Input; import baritone.process.ElytraProcess; import baritone.utils.BlockStateInterface; import baritone.utils.IRenderer; @@ -601,6 +602,11 @@ public final class ElytraBehavior implements Helper { this.deployedFireworkLastTick = false; } + final boolean inLava = ctx.player().isInLava(); + if (inLava) { + baritone.getInputOverrideHandler().setInputForceState(Input.JUMP, true); + } + if (solution == null) { logDirect("no solution"); return; @@ -619,7 +625,7 @@ public final class ElytraBehavior implements Helper { solution.context.start, solution.goingTo, solution.context.boost.isBoosted(), - solution.forceUseFirework + solution.forceUseFirework || inLava ); } @@ -1001,7 +1007,7 @@ public final class ElytraBehavior implements Helper { // if start == dest then the cpp raytracer dies clear = start.equals(dest) || this.context.raytrace(start, dest); } else { - clear = ctx.world().clip(new ClipContext(start, dest, ClipContext.Block.COLLIDER, ClipContext.Fluid.ANY, ctx.player())).getType() == HitResult.Type.MISS; + clear = ctx.world().clip(new ClipContext(start, dest, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, ctx.player())).getType() == HitResult.Type.MISS; } if (Baritone.settings().elytraRenderRaytraces.value) { From c4f33b72c24d658ccc569994d62004afdebcaa90 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 20 Aug 2023 11:53:54 -0700 Subject: [PATCH 15/27] check chunk load in sepples --- build.gradle | 2 +- src/main/java/baritone/process/elytra/ElytraBehavior.java | 3 ++- .../java/baritone/process/elytra/NetherPathfinderContext.java | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index b981972d3..75d17fb02 100755 --- a/build.gradle +++ b/build.gradle @@ -77,7 +77,7 @@ allprojects { // The following line declares the yarn mappings you may select this one as well. // mappings "net.fabricmc:yarn:1.17.1+build.32:v2" //launchImplementation('dev.babbaj:nether-pathfinder:1.3.0') - implementation 'dev.babbaj:nether-pathfinder:1.3.0' + implementation 'dev.babbaj:nether-pathfinder:1.4' } tasks.withType(JavaCompile).configureEach { diff --git a/src/main/java/baritone/process/elytra/ElytraBehavior.java b/src/main/java/baritone/process/elytra/ElytraBehavior.java index 127f90131..a0763095d 100644 --- a/src/main/java/baritone/process/elytra/ElytraBehavior.java +++ b/src/main/java/baritone/process/elytra/ElytraBehavior.java @@ -42,6 +42,7 @@ import net.minecraft.world.entity.projectile.FireworkRocketEntity; import net.minecraft.world.inventory.ClickType; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.chunk.ChunkSource; import net.minecraft.world.level.chunk.LevelChunk; @@ -302,7 +303,7 @@ public final class ElytraBehavior implements Helper { int rangeStartIncl = playerNear; int rangeEndExcl = playerNear; - while (rangeEndExcl < path.size() && ctx.world().isLoaded(path.get(rangeEndExcl))) { + while (rangeEndExcl < path.size() && context.hasChunk(new ChunkPos(path.get(rangeEndExcl)))) { rangeEndExcl++; } // rangeEndExcl now represents an index either not in the path, or just outside render distance diff --git a/src/main/java/baritone/process/elytra/NetherPathfinderContext.java b/src/main/java/baritone/process/elytra/NetherPathfinderContext.java index de666a0a8..aa9f4965a 100644 --- a/src/main/java/baritone/process/elytra/NetherPathfinderContext.java +++ b/src/main/java/baritone/process/elytra/NetherPathfinderContext.java @@ -60,6 +60,10 @@ public final class NetherPathfinderContext { this.executor = Executors.newSingleThreadExecutor(); } + public boolean hasChunk(ChunkPos pos) { + return NetherPathfinder.hasChunkFromJava(this.context, pos.x, pos.z); + } + public void queueCacheCulling(int chunkX, int chunkZ, int maxDistanceBlocks, BlockStateOctreeInterface boi) { this.executor.execute(() -> { synchronized (this.cullingLock) { From e492e5f830aeefd0105d877e6d53f988b484bbc2 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 20 Aug 2023 13:36:45 -0700 Subject: [PATCH 16/27] bump nether pathfinder --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 75d17fb02..9371211b0 100755 --- a/build.gradle +++ b/build.gradle @@ -77,7 +77,7 @@ allprojects { // The following line declares the yarn mappings you may select this one as well. // mappings "net.fabricmc:yarn:1.17.1+build.32:v2" //launchImplementation('dev.babbaj:nether-pathfinder:1.3.0') - implementation 'dev.babbaj:nether-pathfinder:1.4' + implementation 'dev.babbaj:nether-pathfinder:1.4.1' } tasks.withType(JavaCompile).configureEach { @@ -142,4 +142,4 @@ javadoc { options.encoding "UTF-8" // allow emoji in comments :^) source = sourceSets.api.allJava classpath += sourceSets.api.compileClasspath -} \ No newline at end of file +} From f2679bea294e51e3d2e83bda562451f8f9d2cf5a Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 22 Aug 2023 13:28:11 -0700 Subject: [PATCH 17/27] hopefully actually fix backtracking --- .../process/elytra/ElytraBehavior.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/baritone/process/elytra/ElytraBehavior.java b/src/main/java/baritone/process/elytra/ElytraBehavior.java index c6207b08f..29f63f96c 100644 --- a/src/main/java/baritone/process/elytra/ElytraBehavior.java +++ b/src/main/java/baritone/process/elytra/ElytraBehavior.java @@ -98,7 +98,7 @@ public final class ElytraBehavior implements Helper { private BlockStateInterface bsi; private final BlockStateOctreeInterface boi; - public final BlockPos destination; + public final BetterBlockPos destination; private final boolean appendDestination; private final ExecutorService solverExecutor; @@ -119,7 +119,7 @@ public final class ElytraBehavior implements Helper { this.blockedLines = new CopyOnWriteArrayList<>(); this.pathManager = this.new PathManager(); this.process = process; - this.destination = destination; + this.destination = new BetterBlockPos(destination); this.appendDestination = appendDestination; this.solverExecutor = Executors.newSingleThreadExecutor(); this.nextTickBoostCounter = new int[2]; @@ -188,16 +188,16 @@ public final class ElytraBehavior implements Helper { }); } - public CompletableFuture pathRecalcSegment(final int upToIncl) { + public CompletableFuture pathRecalcSegment(final OptionalInt upToIncl) { if (this.recalculating) { throw new IllegalStateException("already recalculating"); } this.recalculating = true; - final List after = this.path.subList(upToIncl + 1, this.path.size()); + final List after = upToIncl.isPresent() ? this.path.subList(upToIncl.getAsInt() + 1, this.path.size()) : Collections.emptyList(); final boolean complete = this.completePath; - return this.path0(ctx.playerFeet(), this.path.get(upToIncl), segment -> segment.append(after.stream(), complete)) + return this.path0(ctx.playerFeet(), upToIncl.isPresent() ? this.path.get(upToIncl.getAsInt()) : ElytraBehavior.this.destination, segment -> segment.append(after.stream(), complete || (segment.isFinished() && !upToIncl.isPresent()))) .whenComplete((result, ex) -> { this.recalculating = false; if (ex != null) { @@ -315,7 +315,7 @@ public final class ElytraBehavior implements Helper { } if (ElytraBehavior.this.process.state != ElytraProcess.State.LANDING && this.ticksNearUnchanged > 100) { - this.pathRecalcSegment(rangeEndExcl - 1) + this.pathRecalcSegment(OptionalInt.of(rangeEndExcl - 1)) .thenRun(() -> { logDirect("Recalculating segment, no progress in last 100 ticks"); }); @@ -331,15 +331,15 @@ public final class ElytraBehavior implements Helper { if (!ElytraBehavior.this.clearView(this.path.getVec(i), this.path.getVec(i + 1), false)) { // obstacle. where do we return to pathing? // if the end of render distance is closer to goal, then that's fine, otherwise we'd be "digging our hole deeper" and making an already bad backtrack worse - int rejoinMainPathAt; - if (this.path.get(rangeEndExcl - 1).distanceSq(this.path.get(path.size() - 1)) < ctx.playerFeet().distanceSq(this.path.get(path.size() - 1))) { - rejoinMainPathAt = rangeEndExcl - 1; // rejoin after current render distance + OptionalInt rejoinMainPathAt; + if (this.path.get(rangeEndExcl - 1).distanceSq(ElytraBehavior.this.destination) < ctx.playerFeet().distanceSq(ElytraBehavior.this.destination)) { + rejoinMainPathAt = OptionalInt.of(rangeEndExcl - 1); // rejoin after current render distance } else { - rejoinMainPathAt = path.size() - 1; // large backtrack detected. ignore render distance, rejoin later on + rejoinMainPathAt = OptionalInt.empty(); // large backtrack detected. ignore render distance, rejoin later on } final BetterBlockPos blockage = this.path.get(i); - final double distance = ctx.playerFeet().distanceTo(this.path.get(rejoinMainPathAt)); + final double distance = ctx.playerFeet().distanceTo(this.path.get(rejoinMainPathAt.orElse(path.size() - 1))); final long start = System.nanoTime(); this.pathRecalcSegment(rejoinMainPathAt) @@ -356,7 +356,7 @@ public final class ElytraBehavior implements Helper { } } if (!canSeeAny && rangeStartIncl < rangeEndExcl - 2 && process.state != ElytraProcess.State.GET_TO_JUMP) { - this.pathRecalcSegment(rangeEndExcl - 1).thenRun(() -> logDirect("Recalculated segment since no path points were visible")); + this.pathRecalcSegment(OptionalInt.of(rangeEndExcl - 1)).thenRun(() -> logDirect("Recalculated segment since no path points were visible")); } } From 2cd5c6b0af433b6c4dfef17b3000834c630551ba Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 22 Aug 2023 13:28:45 -0700 Subject: [PATCH 18/27] delete master stuff --- README.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/README.md b/README.md index f9797fafd..3f2923f92 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,3 @@ -# Warning: Old Branch!! - -**Click [here](https://github.com/cabaletta/baritone) to go to the current Baritone readme.** - -**This branch (`master`) is Baritone for Minecraft 1.12.2. This is the original version of Minecraft that Baritone was written for, and it was the primary development branch for over 5 years. As such, it's quite mature, and arguably more reliable than Baritone for newer versions of Minecraft. Nevertheless, as of August 2023, with [2b2t's update from 1.12.2 to 1.19.4](https://2b2t.org/update/), I decided to move Baritone's primary development branch accordingly. PRs should now be made against the `1.19.4` branch going forward. This branch might see some fixes going forward, particularly to newer features such as `#elytra`, but it won't be the primary focus anymore.** - -The other intermediary branches (`1.13.2`, `1.14.4`, `1.15.2`, `1.16.5`, `1.17.1`, `1.18.2`, `1.19.2`, and `1.19.3`) will probably not receive any updates at all. You can find their last releases in the releases tab, or in the quick download links table. - -For `1.16.5` and `1.18.2`, the latest release is fully up to date with the code. ZacSharp merged master into some of those versions even after they were deprecated, if you are for some reason really interested in the latest Baritone bugfixes on these versions of Minecraft, you can build from source as of these commits: [1.13.2](https://github.com/cabaletta/baritone/commit/be54b8ee5b5639f80e3d6809ed1abd52444d8a08), [1.14.4](https://github.com/cabaletta/baritone/commit/be54b8ee5b5639f80e3d6809ed1abd52444d8a08), [1.15.2](https://github.com/cabaletta/baritone/commit/45abbb7fa1062cefc26abbb006a02a4edd6faa32), [1.17.1](https://github.com/cabaletta/baritone/commit/cbf0d79c9c5f7454071dc0a5289261ec9ca4373f), [1.19.2](https://github.com/cabaletta/baritone/commit/217dca53633610edc9483fda7a234e46c839fd99). For `1.19.3`, merging [this](https://github.com/cabaletta/baritone/commit/217dca53633610edc9483fda7a234e46c839fd99) commit into it is trivial and is left as an exercise for the reader. For other versions in between these (for example people always ask in the Discord for 1.16.1), you'll have to figure it out yourself. - # Baritone

GitHub All Releases From 81932069d98eebb6e0cf81efe9aeb279594c1c40 Mon Sep 17 00:00:00 2001 From: leijurv Date: Wed, 13 Sep 2023 21:25:59 -0700 Subject: [PATCH 19/27] remove footgun --- src/main/java/baritone/cache/CachedWorld.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index e456382e6..aed1faeb5 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -196,9 +196,7 @@ 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) { - if (!Baritone.settings().censorCoordinates.value) { - logDebug("Deleting cached region " + region.getX() + "," + region.getZ() + " from ram"); - } + logDebug("Deleting cached region from ram"); cachedRegions.remove(getRegionID(region.getX(), region.getZ())); } } From 9ad273a46c689cb469b3da1fd870615b7c805ebe Mon Sep 17 00:00:00 2001 From: Babbaj Date: Sat, 23 Sep 2023 17:00:11 -0400 Subject: [PATCH 20/27] silence elytra chat spam --- fabric/build.gradle | 2 +- src/api/java/baritone/api/Settings.java | 5 +++ .../java/baritone/process/ElytraProcess.java | 20 ++++++------ .../process/elytra/ElytraBehavior.java | 32 +++++++++++-------- 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/fabric/build.gradle b/fabric/build.gradle index c88ff80ef..30ed3926d 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -103,4 +103,4 @@ publishing { repositories { // Add repositories to publish to here. } -} \ No newline at end of file +} diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index adbbd6eaa..9171a3d68 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -1468,6 +1468,11 @@ public final class Settings { */ public final Setting elytraTermsAccepted = new Setting<>(false); + /** + * Verbose chat logging in elytra mode + */ + public final Setting elytraChatSpam = new Setting<>(false); + /** * A map of lowercase setting field names to their respective setting */ diff --git a/src/main/java/baritone/process/ElytraProcess.java b/src/main/java/baritone/process/ElytraProcess.java index d1e10a5cf..2c57c6f55 100644 --- a/src/main/java/baritone/process/ElytraProcess.java +++ b/src/main/java/baritone/process/ElytraProcess.java @@ -69,6 +69,16 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro private ElytraBehavior behavior; private boolean predictingTerrain; + @Override + public void onLostControl() { + this.state = State.START_FLYING; // TODO: null state? + this.goingToLandingSpot = false; + this.landingSpot = null; + this.reachedGoal = false; + this.goal = null; + destroyBehaviorAsync(); + } + private ElytraProcess(Baritone baritone) { super(baritone); baritone.getGameEventHandler().registerEventListener(this); @@ -276,16 +286,6 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro this.state = State.FLYING; } - @Override - public void onLostControl() { - this.goal = null; - this.goingToLandingSpot = false; - this.landingSpot = null; - this.reachedGoal = false; - this.state = State.START_FLYING; // TODO: null state? - destroyBehaviorAsync(); - } - private void destroyBehaviorAsync() { ElytraBehavior behavior = this.behavior; if (behavior != null) { diff --git a/src/main/java/baritone/process/elytra/ElytraBehavior.java b/src/main/java/baritone/process/elytra/ElytraBehavior.java index 501c6a22b..d4913f466 100644 --- a/src/main/java/baritone/process/elytra/ElytraBehavior.java +++ b/src/main/java/baritone/process/elytra/ElytraBehavior.java @@ -174,9 +174,9 @@ public final class ElytraBehavior implements Helper { .thenRun(() -> { final double distance = this.path.get(0).distanceTo(this.path.get(this.path.size() - 1)); if (this.completePath) { - logDirect(String.format("Computed path (%.1f blocks in %.4f seconds)", distance, (System.nanoTime() - start) / 1e9d)); + logVerbose(String.format("Computed path (%.1f blocks in %.4f seconds)", distance, (System.nanoTime() - start) / 1e9d)); } else { - logDirect(String.format("Computed segment (Next %.1f blocks in %.4f seconds)", distance, (System.nanoTime() - start) / 1e9d)); + logVerbose(String.format("Computed segment (Next %.1f blocks in %.4f seconds)", distance, (System.nanoTime() - start) / 1e9d)); } }) .whenComplete((result, ex) -> { @@ -231,9 +231,9 @@ public final class ElytraBehavior implements Helper { final double distance = this.path.get(0).distanceTo(this.path.get(recompute)); if (this.completePath) { - logDirect(String.format("Computed path (%.1f blocks in %.4f seconds)", distance, (System.nanoTime() - start) / 1e9d)); + logVerbose(String.format("Computed path (%.1f blocks in %.4f seconds)", distance, (System.nanoTime() - start) / 1e9d)); } else { - logDirect(String.format("Computed segment (Next %.1f blocks in %.4f seconds)", distance, (System.nanoTime() - start) / 1e9d)); + logVerbose(String.format("Computed segment (Next %.1f blocks in %.4f seconds)", distance, (System.nanoTime() - start) / 1e9d)); } }) .whenComplete((result, ex) -> { @@ -243,7 +243,7 @@ public final class ElytraBehavior implements Helper { if (cause instanceof PathCalculationException) { logDirect("Failed to compute next segment"); if (ctx.player().distanceToSqr(pathStart.getCenter()) < 16 * 16) { - logDirect("Player is near the segment start, therefore repeating this calculation is pointless. Marking as complete"); + logVerbose("Player is near the segment start, therefore repeating this calculation is pointless. Marking as complete"); completePath = true; } } else { @@ -321,7 +321,7 @@ public final class ElytraBehavior implements Helper { if (ElytraBehavior.this.process.state != ElytraProcess.State.LANDING && this.ticksNearUnchanged > 100) { this.pathRecalcSegment(OptionalInt.of(rangeEndExcl - 1)) .thenRun(() -> { - logDirect("Recalculating segment, no progress in last 100 ticks"); + logVerbose("Recalculating segment, no progress in last 100 ticks"); }); this.ticksNearUnchanged = 0; return; @@ -348,7 +348,7 @@ public final class ElytraBehavior implements Helper { final long start = System.nanoTime(); this.pathRecalcSegment(rejoinMainPathAt) .thenRun(() -> { - logDirect(String.format("Recalculated segment around path blockage near %s %s %s (next %.1f blocks in %.4f seconds)", + logVerbose(String.format("Recalculated segment around path blockage near %s %s %s (next %.1f blocks in %.4f seconds)", SettingsUtil.maybeCensor(blockage.x), SettingsUtil.maybeCensor(blockage.y), SettingsUtil.maybeCensor(blockage.z), @@ -360,7 +360,7 @@ public final class ElytraBehavior implements Helper { } } if (!canSeeAny && rangeStartIncl < rangeEndExcl - 2 && process.state != ElytraProcess.State.GET_TO_JUMP) { - this.pathRecalcSegment(OptionalInt.of(rangeEndExcl - 1)).thenRun(() -> logDirect("Recalculated segment since no path points were visible")); + this.pathRecalcSegment(OptionalInt.of(rangeEndExcl - 1)).thenRun(() -> logVerbose("Recalculated segment since no path points were visible")); } } @@ -581,10 +581,10 @@ public final class ElytraBehavior implements Helper { trySwapElytra(); if (ctx.player().horizontalCollision) { - logDirect("hbonk"); + logVerbose("hbonk"); } if (ctx.player().verticalCollision) { - logDirect("vbonk"); + logVerbose("vbonk"); } final SolverContext solverContext = this.new SolverContext(false); @@ -609,14 +609,14 @@ public final class ElytraBehavior implements Helper { } if (solution == null) { - logDirect("no solution"); + logVerbose("no solution"); return; } baritone.getLookBehavior().updateTarget(solution.rotation, false); if (!solution.solvedPitch) { - logDirect("no pitch solution, probably gonna crash in a few ticks LOL!!!"); + logVerbose("no pitch solution, probably gonna crash in a few ticks LOL!!!"); return; } else { this.aimPos = new BetterBlockPos(solution.goingTo.x, solution.goingTo.y, solution.goingTo.z); @@ -758,7 +758,7 @@ public final class ElytraBehavior implements Helper { logDirect("no fireworks"); return; } - logDirect("attempting to use firework" + (forceUseFirework ? " (forced)" : "")); + logVerbose("attempting to use firework" + (forceUseFirework ? " (forced)" : "")); ctx.playerController().processRightClick(ctx.player(), ctx.world(), InteractionHand.MAIN_HAND); this.minimumBoostTicks = 10 * (1 + getFireworkBoost(ctx.player().getItemInHand(InteractionHand.MAIN_HAND)).orElse(0)); this.remainingFireworkTicks = 10; @@ -1317,4 +1317,10 @@ public final class ElytraBehavior implements Helper { queueWindowClick(ctx.player().inventoryMenu.containerId, slotId, 0, ClickType.PICKUP); } } + + void logVerbose(String message) { + if (Baritone.settings().elytraChatSpam.value) { + logDebug(message); + } + } } From 91588caf7dfbded6cd5f80e2e5a12524be54dd0b Mon Sep 17 00:00:00 2001 From: leijurv Date: Thu, 28 Sep 2023 20:42:08 -0700 Subject: [PATCH 21/27] oh my GOD --- src/main/java/baritone/utils/BlockStateInterface.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index 2931b9392..095694db9 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -132,7 +132,7 @@ public class BlockStateInterface { prevCached = region; cached = region; } - BlockState type = cached.getBlock(x & 511, y, z & 511); + BlockState type = cached.getBlock(x & 511, y + world.dimensionType().minY(), z & 511); if (type == null) { return AIR; } From 74457db125737aa4ae0b84eaf9ad3c45c8864be8 Mon Sep 17 00:00:00 2001 From: Wagyourtail Date: Wed, 4 Oct 2023 19:24:09 -0600 Subject: [PATCH 22/27] actually fix mine under 0 height --- src/main/java/baritone/cache/FasterWorldScanner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/cache/FasterWorldScanner.java b/src/main/java/baritone/cache/FasterWorldScanner.java index e1c8589e7..65e56975a 100644 --- a/src/main/java/baritone/cache/FasterWorldScanner.java +++ b/src/main/java/baritone/cache/FasterWorldScanner.java @@ -151,7 +151,7 @@ public enum FasterWorldScanner implements IWorldScanner { long chunkX = (long) pos.x << 4; long chunkZ = (long) pos.z << 4; - int playerSectionY = ctx.playerFeet().y >> 4; + int playerSectionY = (ctx.playerFeet().y - ctx.world().getMinBuildHeight()) >> 4; return collectChunkSections(lookup, chunkProvider.getChunk(pos.x, pos.z, false), chunkX, chunkZ, playerSectionY).stream(); } From 3332ec9e1ff60f985cde0d1bd120025b795d6e24 Mon Sep 17 00:00:00 2001 From: Xiaodown Date: Wed, 11 Oct 2023 19:25:51 -0700 Subject: [PATCH 23/27] Adds git to the Dockerfile apt install I saw in setup.md "(if you have docker on Windows, I'd be grateful if you could let me know if it works there too)". So I went to build it on Windows. I use Windows Subsystem for Linux, which is (mostly) Ubuntu but not really (there's no init). But Docker Desktop has an integration for WSL2. For me, gradle wouldn't build the image without forcing git to install in the container. I'll attach screenshots to the pull request. It just looks like whatever ubuntu:focal my docker system grabbed doesn't have git installed by default. Anyway, this fixes it, and shouldn't screw anything even if git is installed by default. I tested it on my M1 Mac pro and it still works fine. --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 9023e2020..8a00fc3da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,7 @@ RUN apt update -y RUN apt install \ openjdk-17-jdk \ + git \ --assume-yes COPY . /code From 1dd2a334d6747ff8575ae54deabb217496c312af Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Wed, 18 Oct 2023 12:33:15 +0200 Subject: [PATCH 24/27] Handle duplicate palette entries --- .../baritone/cache/FasterWorldScanner.java | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/main/java/baritone/cache/FasterWorldScanner.java b/src/main/java/baritone/cache/FasterWorldScanner.java index 65e56975a..b6d3d8963 100644 --- a/src/main/java/baritone/cache/FasterWorldScanner.java +++ b/src/main/java/baritone/cache/FasterWorldScanner.java @@ -20,6 +20,7 @@ package baritone.cache; import baritone.api.cache.ICachedWorld; import baritone.api.cache.IWorldScanner; import baritone.api.utils.BetterBlockPos; +import baritone.api.utils.BlockOptionalMeta; import baritone.api.utils.BlockOptionalMetaLookup; import baritone.api.utils.IPlayerContext; import baritone.utils.accessor.IPalettedContainer; @@ -45,6 +46,9 @@ import java.util.stream.Stream; public enum FasterWorldScanner implements IWorldScanner { INSTANCE; + + private static final BlockState[] PALETTE_REGISTRY_SENTINEL = new BlockState[0]; + @Override public List scanChunkRadius(IPlayerContext ctx, BlockOptionalMetaLookup filter, int max, int yLevelThreshold, int maxSearchRadius) { assert ctx.world() != null; @@ -219,13 +223,18 @@ public enum FasterWorldScanner implements IWorldScanner { private boolean[] getIncludedFilterIndices(BlockOptionalMetaLookup lookup, Palette palette) { boolean commonBlockFound = false; - IdMapper paletteMap = getPalette(palette); - int size = paletteMap.size(); + BlockState[] paletteMap = getPalette(palette); + + if (paletteMap == PALETTE_REGISTRY_SENTINEL) { + return getIncludedFilterIndicesFromRegistry(lookup); + } + + int size = paletteMap.length; boolean[] isInFilter = new boolean[size]; for (int i = 0; i < size; i++) { - BlockState state = paletteMap.byId(i); + BlockState state = paletteMap[i]; if (lookup.has(state)) { isInFilter[i] = true; commonBlockFound = true; @@ -240,21 +249,34 @@ public enum FasterWorldScanner implements IWorldScanner { return isInFilter; } + private boolean[] getIncludedFilterIndicesFromRegistry(BlockOptionalMetaLookup lookup) { + boolean[] isInFilter = new boolean[Block.BLOCK_STATE_REGISTRY.size()]; + + for (BlockOptionalMeta bom : lookup.blocks()) { + for (BlockState state : bom.getAllBlockStates()) { + isInFilter[Block.BLOCK_STATE_REGISTRY.getId(state)] = true; + } + } + + return isInFilter; + } + /** * cheats to get the actual map of id -> blockstate from the various palette implementations */ - private static IdMapper getPalette(Palette palette) { + private static BlockState[] getPalette(Palette palette) { if (palette instanceof GlobalPalette) { - return Block.BLOCK_STATE_REGISTRY; + // copying the entire registry is not nice so we treat it as a special case + return PALETTE_REGISTRY_SENTINEL; } else { FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer()); palette.write(buf); int size = buf.readVarInt(); - IdMapper states = new IdMapper<>(); + BlockState[] states = new BlockState[size]; for (int i = 0; i < size; i++) { BlockState state = Block.BLOCK_STATE_REGISTRY.byId(buf.readVarInt()); assert state != null; - states.addMapping(state, i); + states[i] = state; } return states; } From 0ca81b14bf438351725072cfd3deb3ac41f8df9c Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:34:25 +0200 Subject: [PATCH 25/27] Restore `buildIgnoreExisting` --- src/main/java/baritone/process/BuilderProcess.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 86378bbbc..0ae796e6e 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -1063,6 +1063,9 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil if (desired.getBlock() instanceof AirBlock && Baritone.settings().buildIgnoreBlocks.value.contains(current.getBlock())) { return true; } + if (!(current.getBlock() instanceof AirBlock) && Baritone.settings().buildIgnoreExisting.value && !itemVerify) { + return true; + } if (Baritone.settings().buildSkipBlocks.value.contains(desired.getBlock()) && !itemVerify) { return true; } From 20d62c68bfacbac3173dfa8f819b4d05e40d4a68 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sun, 15 Oct 2023 20:50:23 +0200 Subject: [PATCH 26/27] Slightly better version strings --- .github/workflows/gradle_build.yml | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gradle_build.yml b/.github/workflows/gradle_build.yml index 08e9ab1d3..9d4ed379b 100644 --- a/.github/workflows/gradle_build.yml +++ b/.github/workflows/gradle_build.yml @@ -28,7 +28,7 @@ jobs: run: chmod +x gradlew - name: Build with Gradle - run: ./gradlew build -Pmod_version="$(git describe --always --tags | cut -c2-)" + run: ./gradlew build -Pmod_version="$(git describe --always --tags --first-parent | cut -c2-)" - name: Archive Artifacts uses: actions/upload-artifact@v3 diff --git a/build.gradle b/build.gradle index 9371211b0..b8cc58196 100755 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ allprojects { apply plugin: "maven-publish" archivesBaseName = rootProject.archives_base_name - def vers = 'git describe --always --tags --dirty'.execute().text.trim() + def vers = 'git describe --always --tags --first-parent --dirty'.execute().text.trim() if (!vers.startsWith("v")) { println "git doesn't appear to be installed!" println "using version number: " + rootProject.mod_version From 9accb2bfb0bea36cfe63940f2cc20f39af73517c Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Sun, 15 Oct 2023 20:51:17 +0200 Subject: [PATCH 27/27] Don't crash the build if git is not available --- build.gradle | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index b8cc58196..dbbc2cebb 100755 --- a/build.gradle +++ b/build.gradle @@ -21,13 +21,18 @@ allprojects { apply plugin: "maven-publish" archivesBaseName = rootProject.archives_base_name - def vers = 'git describe --always --tags --first-parent --dirty'.execute().text.trim() + def vers = "" + try { + vers = 'git describe --always --tags --first-parent --dirty'.execute().text.trim() + } catch (Exception e) { + println "Version detection failed: " + e + } if (!vers.startsWith("v")) { - println "git doesn't appear to be installed!" println "using version number: " + rootProject.mod_version version = rootProject.mod_version } else { version = vers.substring(1) + println "Detected version " + version } group = rootProject.maven_group