From 86525f98ec9dfdf4531fb115c8e8cd33a5d912b1 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 10 Jun 2019 23:12:37 -0700 Subject: [PATCH 01/39] fix scuffed jumping, fixes #426 --- src/main/java/baritone/process/MineProcess.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index 1e138290c..01a460d4d 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -114,7 +114,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro .filter(pos -> !(BlockStateInterface.get(ctx, pos).getBlock() instanceof BlockAir)) // after breaking a block, it takes mineGoalUpdateInterval ticks for it to actually update this list =( .min(Comparator.comparingDouble(ctx.player()::getDistanceSq)); baritone.getInputOverrideHandler().clearAllKeys(); - if (shaft.isPresent()) { + if (shaft.isPresent() && ctx.player().onGround) { BlockPos pos = shaft.get(); IBlockState state = baritone.bsi.get0(pos); if (!MovementHelper.avoidBreaking(baritone.bsi, pos.getX(), pos.getY(), pos.getZ(), state)) { From eb6c0a39ea9756b3f26a41f74db14988b51769a0 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 11 Jun 2019 23:46:04 -0700 Subject: [PATCH 02/39] codacy wants this --- src/main/java/baritone/process/ExploreProcess.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/baritone/process/ExploreProcess.java b/src/main/java/baritone/process/ExploreProcess.java index aa7e2c2a6..54c2a6987 100644 --- a/src/main/java/baritone/process/ExploreProcess.java +++ b/src/main/java/baritone/process/ExploreProcess.java @@ -122,6 +122,7 @@ public final class ExploreProcess extends BaritoneProcessHelper implements IExpl break; // note: this breaks the switch not the for case EXPLORED: continue; // note: this continues the for + default: } int centerX = ((chunkX + dx) << 4) + 8; int centerZ = ((chunkZ + dz) << 4) + 8; From e785bd13f5624402a25eea5e900581ba41a29696 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 12 Jun 2019 16:41:05 -0700 Subject: [PATCH 03/39] sanity check --- src/main/java/baritone/cache/CachedWorld.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index 7c8e4291e..f07c11483 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -303,6 +303,8 @@ public final class CachedWorld implements ICachedWorld, Helper { } catch (InterruptedException e) { e.printStackTrace(); break; + } catch (Throwable th) { + th.printStackTrace(); } } } From cc015846d27e4388a195df533c686af2de5a2814 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 13 Jun 2019 23:13:40 -0700 Subject: [PATCH 04/39] explain --- src/main/java/baritone/cache/CachedWorld.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index f07c11483..237c460b4 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -304,6 +304,7 @@ public final class CachedWorld implements ICachedWorld, Helper { e.printStackTrace(); break; } catch (Throwable th) { + // in the case of an exception, keep consuming from the queue so as not to leak memory th.printStackTrace(); } } From 7b192f17e85a11a2d0d301ae53d9846f77efa21e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 14 Jun 2019 21:42:11 -0700 Subject: [PATCH 05/39] privatize --- src/main/java/baritone/utils/GuiClick.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/GuiClick.java b/src/main/java/baritone/utils/GuiClick.java index 0b412b925..480da7074 100644 --- a/src/main/java/baritone/utils/GuiClick.java +++ b/src/main/java/baritone/utils/GuiClick.java @@ -121,7 +121,7 @@ public class GuiClick extends GuiScreen { } } - public Vec3d toWorld(double x, double y, double z) { + private Vec3d toWorld(double x, double y, double z) { boolean result = GLU.gluUnProject((float) x, (float) y, (float) z, MODELVIEW, PROJECTION, VIEWPORT, (FloatBuffer) TO_WORLD_BUFFER.clear()); if (result) { return new Vec3d(TO_WORLD_BUFFER.get(0), TO_WORLD_BUFFER.get(1), TO_WORLD_BUFFER.get(2)); From 0fd241a9ba23e48171d70dedd768532b8b607a31 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 15 Jun 2019 11:04:05 -0700 Subject: [PATCH 06/39] crucial performance optimization --- src/main/java/baritone/BaritoneProvider.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/BaritoneProvider.java b/src/main/java/baritone/BaritoneProvider.java index 73e5e6e57..44715f4c5 100644 --- a/src/main/java/baritone/BaritoneProvider.java +++ b/src/main/java/baritone/BaritoneProvider.java @@ -32,6 +32,7 @@ import java.util.List; public final class BaritoneProvider implements IBaritoneProvider { private final Baritone primary = new Baritone(); + private final List all = Collections.singletonList(primary); @Override public IBaritone getPrimaryBaritone() { @@ -40,8 +41,7 @@ public final class BaritoneProvider implements IBaritoneProvider { @Override public List getAllBaritones() { - // TODO return a CopyOnWriteArrayList - return Collections.singletonList(primary); + return all; } @Override From be142d79bce195e9ce2daafea3e55b6e30196994 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Jun 2019 23:06:57 -0700 Subject: [PATCH 07/39] link to the code --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ff6b83ef2..bc1fc94c8 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/a73d037823b64a5faf597a18d71e3400)](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade) [![HitCount](http://hits.dwyl.com/cabaletta/baritone.svg)](http://hits.dwyl.com/cabaletta/baritone) [![GitHub All Releases](https://img.shields.io/github/downloads/cabaletta/baritone/total.svg)](https://github.com/cabaletta/baritone/releases) -[![Minecraft](https://img.shields.io/badge/MC-1.12.2-green.svg)](https://minecraft.gamepedia.com/1.12.2) -[![Minecraft](https://img.shields.io/badge/MC-1.13.2-brightgreen.svg)](https://minecraft.gamepedia.com/1.13.2) +[![Minecraft](https://img.shields.io/badge/MC-1.12.2-green.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/) [![Code of Conduct](https://img.shields.io/badge/%E2%9D%A4-code%20of%20conduct-blue.svg?style=flat)](https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md) [![Known Vulnerabilities](https://snyk.io/test/github/cabaletta/baritone/badge.svg?targetFile=build.gradle)](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle) [![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/cabaletta/baritone/issues) From 96097ab7265f3219efef4231c4ce36b8251ac8ac Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 17 Jun 2019 22:44:38 -0700 Subject: [PATCH 08/39] this counts as a commit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bc1fc94c8..42dba624d 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ [![GitHub contributors](https://img.shields.io/github/contributors/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/graphs/contributors/) [![GitHub commits](https://img.shields.io/github/commits-since/cabaletta/baritone/v1.0.0.svg)](https://github.com/cabaletta/baritone/commit/) [![Impact integration](https://img.shields.io/badge/Impact%20integration-v1.2.6%20/%20v1.3.2-brightgreen.svg)](https://impactdevelopment.github.io/) -[![ForgeHax integration](https://img.shields.io/badge/ForgeHax%20%22integration%22-scuffed-yellow.svg)](https://github.com/fr1kin/ForgeHax) +[![ForgeHax integration](https://img.shields.io/badge/ForgeHax%20%22integration%22-scuffed-yellow.svg)](https://github.com/fr1kin/ForgeHax/) [![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 b3605546ac913072fe7700f83761810732eb60ef Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 18 Jun 2019 23:15:47 -0700 Subject: [PATCH 09/39] golly another missing slash wow --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 42dba624d..9c0808263 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ [![ForgeHax integration](https://img.shields.io/badge/ForgeHax%20%22integration%22-scuffed-yellow.svg)](https://github.com/fr1kin/ForgeHax/) [![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) +[![forthebadge](https://forthebadge.com/images/badges/built-with-swag.svg)](http://forthebadge.com/) [![forthebadge](https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg)](http://forthebadge.com) A Minecraft pathfinder bot. From 2b9084d2f3ce140c5783a3c869422347aa33c926 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 19 Jun 2019 20:41:21 -0700 Subject: [PATCH 10/39] wow --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9c0808263..0a8c713f7 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ [![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/) -[![forthebadge](https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg)](http://forthebadge.com) +[![forthebadge](https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg)](http://forthebadge.com/) A Minecraft pathfinder bot. From f998dce61496002b1810390823511a247f823276 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 20 Jun 2019 23:48:02 -0700 Subject: [PATCH 11/39] wow wow --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0a8c713f7..ad14e1747 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Here are some links to help to get started: # API -The API is heavily documented, you can find the Javadocs for the latest release [here](https://baritone.leijurv.com). +The API is heavily documented, you can find the Javadocs for the latest release [here](https://baritone.leijurv.com/). Please note that usage of anything located outside of the ``baritone.api`` package is not supported by the API release jar. From 4ff61f96dff505e554625a6b2bdcefd0ef066640 Mon Sep 17 00:00:00 2001 From: SylveonBottle Date: Fri, 21 Jun 2019 03:59:10 -0500 Subject: [PATCH 12/39] wow times infinity --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ad14e1747..9a25789a3 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,15 @@ # Baritone -[![Build Status](https://travis-ci.com/cabaletta/baritone.svg?branch=master)](https://travis-ci.com/cabaletta/baritone) -[![Release](https://img.shields.io/github/release/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/releases) +[![Build Status](https://travis-ci.com/cabaletta/baritone.svg?branch=master)](https://travis-ci.com/cabaletta/baritone/) +[![Release](https://img.shields.io/github/release/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/releases/) [![License](https://img.shields.io/badge/license-LGPL--3.0%20with%20anime%20exception-green.svg)](LICENSE) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/a73d037823b64a5faf597a18d71e3400)](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade) -[![HitCount](http://hits.dwyl.com/cabaletta/baritone.svg)](http://hits.dwyl.com/cabaletta/baritone) -[![GitHub All Releases](https://img.shields.io/github/downloads/cabaletta/baritone/total.svg)](https://github.com/cabaletta/baritone/releases) +[![HitCount](http://hits.dwyl.com/cabaletta/baritone.svg)](http://hits.dwyl.com/cabaletta/baritone/) +[![GitHub All Releases](https://img.shields.io/github/downloads/cabaletta/baritone/total.svg)](https://github.com/cabaletta/baritone/releases/) [![Minecraft](https://img.shields.io/badge/MC-1.12.2-green.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/) [![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) +[![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/cabaletta/baritone/issues/) [![Issues](https://img.shields.io/github/issues/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/issues/) [![GitHub issues-closed](https://img.shields.io/github/issues-closed/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/issues?q=is%3Aissue+is%3Aclosed) [![Pull Requests](https://img.shields.io/github/issues-pr/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/pulls/) @@ -44,7 +44,7 @@ Here are some links to help to get started: - [Installation & setup](SETUP.md) -- [API Javadocs](https://baritone.leijurv.com) +- [API Javadocs](https://baritone.leijurv.com/) - [Settings](https://baritone.leijurv.com/baritone/api/Settings.html#field.detail) @@ -73,7 +73,7 @@ That's what it's for, sure! (As long as usage is in compliance with the LGPL 3.0 ## How is it so fast? -Magic. (Hours of [leijurv](https://github.com/leijurv) enduring excruciating pain) +Magic. (Hours of [leijurv](https://github.com/leijurv/) enduring excruciating pain) ## Why is it called Baritone? From 3902b2db3b3cd25029d00b18cc57b703265681dd Mon Sep 17 00:00:00 2001 From: Babbaj Date: Fri, 21 Jun 2019 23:01:37 -0400 Subject: [PATCH 13/39] increase line count and improve readability --- src/main/java/baritone/process/FollowProcess.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/process/FollowProcess.java b/src/main/java/baritone/process/FollowProcess.java index 12188729d..4defff5d5 100644 --- a/src/main/java/baritone/process/FollowProcess.java +++ b/src/main/java/baritone/process/FollowProcess.java @@ -82,7 +82,12 @@ public final class FollowProcess extends BaritoneProcessHelper implements IFollo } private void scanWorld() { - cache = Stream.of(ctx.world().loadedEntityList, ctx.world().playerEntities).flatMap(List::stream).filter(this::followable).filter(this.filter).distinct().collect(Collectors.toCollection(ArrayList::new)); + cache = Stream.of(ctx.world().loadedEntityList, ctx.world().playerEntities) + .flatMap(List::stream) + .filter(this::followable) + .filter(this.filter) + .distinct() + .collect(Collectors.toCollection(ArrayList::new)); } @Override From fa71e7d84fb1c59ea18eb48062cae995edb4c9c9 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 22 Jun 2019 21:11:09 -0700 Subject: [PATCH 14/39] reduce stupidity --- src/main/java/baritone/process/BuilderProcess.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 29f61a7dc..52f21b769 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -154,7 +154,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil continue; // irrelevant } IBlockState curr = bcc.bsi.get0(x, y, z); - if (curr.getBlock() != Blocks.AIR && !valid(curr, desired)) { + if (curr.getBlock() != Blocks.AIR && !(curr.getBlock() instanceof BlockLiquid) && !valid(curr, desired)) { BetterBlockPos pos = new BetterBlockPos(x, y, z); Optional rot = RotationUtils.reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance()); if (rot.isPresent()) { From ce3d3bb244b37646a7fc85540e3a08d2100ad6f1 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 23 Jun 2019 22:49:33 -0700 Subject: [PATCH 15/39] literally no reason to have this --- .../baritone/pathing/path/PathExecutor.java | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 852ac44ee..d219dfc29 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -147,38 +147,6 @@ public class PathExecutor implements IPathExecutor, Helper { cancel(); return false; } - //this commented block is literally cursed. - /*Out.log(actions.get(pathPosition)); - if (pathPosition < actions.size() - 1) {//if there are two ActionBridges in a row and they are at right angles, walk diagonally. This makes it so you walk at 45 degrees along a zigzag path instead of doing inefficient zigging and zagging - if ((actions.get(pathPosition) instanceof ActionBridge) && (actions.get(pathPosition + 1) instanceof ActionBridge)) { - ActionBridge curr = (ActionBridge) actions.get(pathPosition); - ActionBridge next = (ActionBridge) actions.get(pathPosition + 1); - if (curr.dx() != next.dx() || curr.dz() != next.dz()) {//two movement are not parallel, so this is a right angle - if (curr.amIGood() && next.amIGood()) {//nothing in the way - BlockPos cornerToCut1 = new BlockPos(next.to.getX() - next.from.getX() + curr.from.getX(), next.to.getY(), next.to.getZ() - next.from.getZ() + curr.from.getZ()); - BlockPos cornerToCut2 = cornerToCut1.up(); - //Block corner1 = Baritone.get(cornerToCut1).getBlock(); - //Block corner2 = Baritone.get(cornerToCut2).getBlock(); - //Out.gui("Cutting conner " + cornerToCut1 + " " + corner1, Out.Mode.Debug); - if (!Action.avoidWalkingInto(cornerToCut1) && !Action.avoidWalkingInto(cornerToCut2)) { - double x = (next.from.getX() + next.to.getX() + 1.0D) * 0.5D; - double z = (next.from.getZ() + next.to.getZ() + 1.0D) * 0.5D; - MovementManager.clearMovement(); - if (!MovementManager.forward && curr.oneInTen != null && curr.oneInTen) { - MovementManager.clearMovement(); - MovementManager.forward = LookManager.lookAtCoords(x, 0, z, false); - } else { - MovementManager.moveTowardsCoords(x, 0, z); - } - if (MovementManager.forward && !MovementManager.backward) { - thePlayer.setSprinting(true); - } - return false; - } - } - } - } - }*/ //long start = System.nanoTime() / 1000000L; BlockStateInterface bsi = new BlockStateInterface(ctx); for (int i = pathPosition - 10; i < pathPosition + 10; i++) { From f4d2ea7923b0422943040d30066860af1dc25f6f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Jun 2019 10:43:49 -0700 Subject: [PATCH 16/39] fix path canceling at edge of loaded chunks hopefully --- src/main/java/baritone/pathing/path/PathExecutor.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index d219dfc29..7b9ba9ee4 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -188,6 +188,11 @@ public class PathExecutor implements IPathExecutor, Helper { System.out.println("Recalculating break and place took " + (end - start) + "ms"); }*/ IMovement movement = path.movements().get(pathPosition); + if (!behavior.baritone.bsi.worldContainsLoadedChunk(movement.getDest().x, movement.getDest().z)) { + logDebug("Pausing since destination is at edge of loaded chunks"); + clearKeys(); + return true; + } boolean canCancel = movement.safeToCancel(); if (costEstimateIndex == null || costEstimateIndex != pathPosition) { costEstimateIndex = pathPosition; From 9c64067d492e3fdd7d255bdf39092524046f7121 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Jun 2019 17:53:25 -0700 Subject: [PATCH 17/39] vastly improve resilience to lagbacks, fixes #446 --- .../baritone/pathing/movement/Movement.java | 16 +++++-- .../movement/movements/MovementAscend.java | 22 +++++++-- .../movement/movements/MovementDescend.java | 8 ++++ .../movement/movements/MovementDiagonal.java | 19 ++++++-- .../movement/movements/MovementDownward.java | 10 ++++ .../movement/movements/MovementFall.java | 12 +++++ .../movement/movements/MovementParkour.java | 14 ++++++ .../movement/movements/MovementPillar.java | 7 +++ .../movement/movements/MovementTraverse.java | 12 ++++- .../baritone/pathing/path/PathExecutor.java | 46 ++++++++++--------- 10 files changed, 132 insertions(+), 34 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 75c93dcae..6907c426a 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -30,9 +30,7 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; +import java.util.*; public abstract class Movement implements IMovement, MovementHelper { @@ -63,6 +61,8 @@ public abstract class Movement implements IMovement, MovementHelper { public List toPlaceCached = null; public List toWalkIntoCached = null; + private Set validPositionsCached = null; + private Boolean calculatedWhileLoaded; protected Movement(IBaritone baritone, BetterBlockPos src, BetterBlockPos dest, BetterBlockPos[] toBreak, BetterBlockPos toPlace) { @@ -100,6 +100,16 @@ public abstract class Movement implements IMovement, MovementHelper { this.cost = cost; } + protected abstract Set calculateValidPositions(); + + public Set getValidPositions() { + if (validPositionsCached == null) { + validPositionsCached = calculateValidPositions(); + Objects.requireNonNull(validPositionsCached); + } + return validPositionsCached; + } + /** * Handles the execution of the latest Movement * State, and offers a Status to the calling class. diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index 6d5ecd857..24fe2285e 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -27,11 +27,14 @@ import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; +import com.google.common.collect.ImmutableSet; import net.minecraft.block.BlockFalling; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.EnumFacing; +import java.util.Set; + public class MovementAscend extends Movement { private int ticksWithoutPlacement = 0; @@ -51,6 +54,17 @@ public class MovementAscend extends Movement { return cost(context, src.x, src.y, src.z, dest.x, dest.z); } + @Override + protected Set calculateValidPositions() { + BetterBlockPos prior = new BetterBlockPos(src.subtract(getDirection()).up()); // sometimes we back up to place the block, also sprint ascends, also skip descend to straight ascend + return ImmutableSet.of(src, + src.up(), + dest, + prior, + prior.up() + ); + } + public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) { IBlockState toPlace = context.get(destX, y, destZ); double additionalPlacementCost = 0; @@ -143,6 +157,10 @@ public class MovementAscend extends Movement { @Override public MovementState updateState(MovementState state) { + if (ctx.playerFeet().y < src.y) { + // this check should run even when in preparing state (breaking blocks) + return state.setStatus(MovementStatus.UNREACHABLE); + } super.updateState(state); // TODO incorporate some behavior from ActionClimb (specifically how it waited until it was at most 1.2 blocks away before starting to jump // for efficiency in ascending minimal height staircases, which is just repeated MovementAscend, so that it doesn't bonk its head on the ceiling repeatedly) @@ -154,10 +172,6 @@ public class MovementAscend extends Movement { return state.setStatus(MovementStatus.SUCCESS); } - if (ctx.playerFeet().y < src.y) { - return state.setStatus(MovementStatus.UNREACHABLE); - } - IBlockState jumpingOnto = BlockStateInterface.get(ctx, positionToPlace); if (!MovementHelper.canWalkOn(ctx, positionToPlace, jumpingOnto)) { ticksWithoutPlacement++; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index a73ed4fb6..67b7cd95a 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -29,6 +29,7 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; import baritone.utils.pathing.MutableMoveResult; +import com.google.common.collect.ImmutableSet; import net.minecraft.block.Block; import net.minecraft.block.BlockFalling; import net.minecraft.block.state.IBlockState; @@ -37,6 +38,8 @@ import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; +import java.util.Set; + public class MovementDescend extends Movement { private int numTicks = 0; @@ -61,6 +64,11 @@ public class MovementDescend extends Movement { return result.cost; } + @Override + protected Set calculateValidPositions() { + return ImmutableSet.of(src, dest.up(), dest); + } + public static void cost(CalculationContext context, int x, int y, int z, int destX, int destZ, MutableMoveResult res) { double totalCost = 0; IBlockState destDown = context.get(destX, y - 1, destZ); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index 9761f6174..878c9cff6 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -28,6 +28,7 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; import baritone.utils.pathing.MutableMoveResult; +import com.google.common.collect.ImmutableSet; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; @@ -36,6 +37,7 @@ import net.minecraft.util.math.BlockPos; import java.util.ArrayList; import java.util.List; +import java.util.Set; public class MovementDiagonal extends Movement { @@ -64,6 +66,16 @@ public class MovementDiagonal extends Movement { return result.cost; } + @Override + protected Set calculateValidPositions() { + BetterBlockPos diagA = new BetterBlockPos(src.x, src.y, dest.z); + BetterBlockPos diagB = new BetterBlockPos(dest.x, src.y, src.z); + if (dest.y != src.y) { // only if allowDiagonalDescend + return ImmutableSet.of(src, dest.up(), diagA, diagB, dest, diagA.down(), diagB.down()); + } + return ImmutableSet.of(src, dest, diagA, diagB); + } + public static void cost(CalculationContext context, int x, int y, int z, int destX, int destZ, MutableMoveResult res) { IBlockState destInto = context.get(destX, y, destZ); if (!MovementHelper.canWalkThrough(context.bsi, destX, y, destZ, destInto) || !MovementHelper.canWalkThrough(context.bsi, destX, y + 1, destZ)) { @@ -171,8 +183,9 @@ public class MovementDiagonal extends Movement { } if (ctx.playerFeet().equals(dest)) { - state.setStatus(MovementStatus.SUCCESS); - return state; + return state.setStatus(MovementStatus.SUCCESS); + } else if (!getValidPositions().contains(ctx.playerFeet())) { + return state.setStatus(MovementStatus.UNREACHABLE); } if (sprint()) { state.setInput(Input.SPRINT, true); @@ -181,7 +194,7 @@ public class MovementDiagonal extends Movement { return state; } - public boolean sprint() { + private boolean sprint() { if (MovementHelper.isLiquid(ctx, ctx.playerFeet()) && !Baritone.settings().sprintInWater.value) { return false; } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java index 47ed95808..250f34717 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java @@ -24,10 +24,13 @@ import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; +import com.google.common.collect.ImmutableSet; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; +import java.util.Set; + public class MovementDownward extends Movement { private int numTicks = 0; @@ -47,6 +50,11 @@ public class MovementDownward extends Movement { return cost(context, src.x, src.y, src.z); } + @Override + protected Set calculateValidPositions() { + return ImmutableSet.of(src, dest); + } + public static double cost(CalculationContext context, int x, int y, int z) { if (!context.allowDownward) { return COST_INF; @@ -73,6 +81,8 @@ public class MovementDownward extends Movement { if (ctx.playerFeet().equals(dest)) { return state.setStatus(MovementStatus.SUCCESS); + } else if (!getValidPositions().contains(ctx.playerFeet())) { + return state.setStatus(MovementStatus.UNREACHABLE); } double diffX = ctx.player().posX - (dest.getX() + 0.5); double diffZ = ctx.player().posZ - (dest.getZ() + 0.5); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index 0a4c38c7d..b777b0a62 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -42,7 +42,9 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3i; +import java.util.HashSet; import java.util.Optional; +import java.util.Set; public class MovementFall extends Movement { @@ -63,6 +65,16 @@ public class MovementFall extends Movement { return result.cost; } + @Override + protected Set calculateValidPositions() { + Set set = new HashSet<>(); + set.add(src); + for (int y = src.y - dest.y; y >= 0; y--) { + set.add(dest.up(y)); + } + return set; + } + private boolean willPlaceBucket() { CalculationContext context = new CalculationContext(baritone); MutableMoveResult result = new MutableMoveResult(); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index dfa43a051..b9f02c1ac 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -34,6 +34,9 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.EnumFacing; +import java.util.HashSet; +import java.util.Set; + public class MovementParkour extends Movement { private static final BetterBlockPos[] EMPTY = new BetterBlockPos[]{}; @@ -174,6 +177,17 @@ public class MovementParkour extends Movement { return res.cost; } + @Override + protected Set calculateValidPositions() { + Set set = new HashSet<>(); + for (int i = 0; i <= dist; i++) { + for (int y = 0; y < 2; y++) { + set.add(src.offset(direction, i).up(y)); + } + } + return set; + } + @Override public boolean safeToCancel(MovementState state) { // once this movement is instantiated, the state is default to PREPPING diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index 5e4a409f7..c444422ef 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -30,6 +30,7 @@ import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; +import com.google.common.collect.ImmutableSet; import net.minecraft.block.*; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; @@ -37,6 +38,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import java.util.Objects; +import java.util.Set; public class MovementPillar extends Movement { @@ -49,6 +51,11 @@ public class MovementPillar extends Movement { return cost(context, src.x, src.y, src.z); } + @Override + protected Set calculateValidPositions() { + return ImmutableSet.of(src, dest); + } + public static double cost(CalculationContext context, int x, int y, int z) { Block from = context.get(x, y, z).getBlock(); boolean ladder = from == Blocks.LADDER || from == Blocks.VINE; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index b621632c1..03f81e761 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -30,12 +30,15 @@ import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; +import com.google.common.collect.ImmutableSet; import net.minecraft.block.*; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; +import java.util.Set; + public class MovementTraverse extends Movement { /** @@ -58,6 +61,11 @@ public class MovementTraverse extends Movement { return cost(context, src.x, src.y, src.z, dest.x, dest.z); } + @Override + protected Set calculateValidPositions() { + return ImmutableSet.of(src, dest); + } + public static double cost(CalculationContext context, int x, int y, int z, int destX, int destZ) { IBlockState pb0 = context.get(destX, y + 1, destZ); IBlockState pb1 = context.get(destX, y, destZ); @@ -205,8 +213,8 @@ public class MovementTraverse extends Movement { if (pb0.getBlock() instanceof BlockFenceGate || pb1.getBlock() instanceof BlockFenceGate) { BlockPos blocked = !MovementHelper.isGatePassable(ctx, positionsToBreak[0], src.up()) ? positionsToBreak[0] - : !MovementHelper.isGatePassable(ctx, positionsToBreak[1], src) ? positionsToBreak[1] - : null; + : !MovementHelper.isGatePassable(ctx, positionsToBreak[1], src) ? positionsToBreak[1] + : null; if (blocked != null) { return state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), blocked), ctx.playerRotations()), true)) .setInput(Input.CLICK_RIGHT, true); diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 7b9ba9ee4..e92d32734 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -33,7 +33,6 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.movements.*; import baritone.utils.BlockStateInterface; import net.minecraft.block.BlockLiquid; -import net.minecraft.init.Blocks; import net.minecraft.util.Tuple; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -100,14 +99,13 @@ public class PathExecutor implements IPathExecutor, Helper { if (pathPosition >= path.length()) { return true; // stop bugging me, I'm done } - BetterBlockPos whereShouldIBe = path.positions().get(pathPosition); + Movement movement = (Movement) path.movements().get(pathPosition); BetterBlockPos whereAmI = ctx.playerFeet(); - if (!whereShouldIBe.equals(whereAmI) && !Blocks.AIR.equals(BlockStateInterface.getBlock(ctx, whereAmI.down()))) {//do not skip if standing on air, because our position isn't stable to skip - for (int i = 0; i < pathPosition - 1 && i < path.length(); i++) {//this happens for example when you lag out and get teleported back a couple blocks - if (whereAmI.equals(path.positions().get(i))) { - logDebug("Skipping back " + (pathPosition - i) + " steps, to " + i); + if (!movement.getValidPositions().contains(whereAmI)) { + for (int i = 0; i < pathPosition && i < path.length(); i++) {//this happens for example when you lag out and get teleported back a couple blocks + if (((Movement) path.movements().get(i)).getValidPositions().contains(whereAmI)) { int previousPos = pathPosition; - pathPosition = Math.max(i - 1, 0); // previous step might not actually be done + pathPosition = i; for (int j = pathPosition; j <= previousPos; j++) { path.movements().get(j).reset(); } @@ -173,10 +171,10 @@ public class PathExecutor implements IPathExecutor, Helper { HashSet newPlace = new HashSet<>(); HashSet newWalkInto = new HashSet<>(); for (int i = pathPosition; i < path.movements().size(); i++) { - Movement movement = (Movement) path.movements().get(i); - newBreak.addAll(movement.toBreak(bsi)); - newPlace.addAll(movement.toPlace(bsi)); - newWalkInto.addAll(movement.toWalkInto(bsi)); + Movement m = (Movement) path.movements().get(i); + newBreak.addAll(m.toBreak(bsi)); + newPlace.addAll(m.toPlace(bsi)); + newWalkInto.addAll(m.toWalkInto(bsi)); } toBreak = newBreak; toPlace = newPlace; @@ -187,11 +185,13 @@ public class PathExecutor implements IPathExecutor, Helper { if (end - start > 0) { System.out.println("Recalculating break and place took " + (end - start) + "ms"); }*/ - IMovement movement = path.movements().get(pathPosition); - if (!behavior.baritone.bsi.worldContainsLoadedChunk(movement.getDest().x, movement.getDest().z)) { - logDebug("Pausing since destination is at edge of loaded chunks"); - clearKeys(); - return true; + if (pathPosition < path.movements().size() - 1) { + IMovement next = path.movements().get(pathPosition + 1); + if (!behavior.baritone.bsi.worldContainsLoadedChunk(next.getDest().x, next.getDest().z)) { + logDebug("Pausing since destination is at edge of loaded chunks"); + clearKeys(); + return true; + } } boolean canCancel = movement.safeToCancel(); if (costEstimateIndex == null || costEstimateIndex != pathPosition) { @@ -206,7 +206,7 @@ public class PathExecutor implements IPathExecutor, Helper { } } } - double currentCost = ((Movement) movement).recalculateCost(behavior.secretInternalGetCalculationContext()); + double currentCost = movement.recalculateCost(behavior.secretInternalGetCalculationContext()); if (currentCost >= ActionCosts.COST_INF && canCancel) { logDebug("Something has changed in the world and this movement has become impossible. Cancelling."); cancel(); @@ -258,11 +258,13 @@ public class PathExecutor implements IPathExecutor, Helper { private Tuple closestPathPos(IPath path) { double best = -1; BlockPos bestPos = null; - for (BlockPos pos : path.positions()) { - double dist = VecUtils.entityDistanceToCenter(ctx.player(), pos); - if (dist < best || best == -1) { - best = dist; - bestPos = pos; + for (IMovement movement : path.movements()) { + for (BlockPos pos : ((Movement) movement).getValidPositions()) { + double dist = VecUtils.entityDistanceToCenter(ctx.player(), pos); + if (dist < best || best == -1) { + best = dist; + bestPos = pos; + } } } return new Tuple<>(best, bestPos); From fd6923dd2841a90d6fe8d3e7f686e274a5f5ee7c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 24 Jun 2019 20:38:17 -0700 Subject: [PATCH 18/39] ok i forgot falling into water --- .../baritone/pathing/movement/movements/MovementDiagonal.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index 878c9cff6..f17fc18da 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -184,7 +184,7 @@ public class MovementDiagonal extends Movement { if (ctx.playerFeet().equals(dest)) { return state.setStatus(MovementStatus.SUCCESS); - } else if (!getValidPositions().contains(ctx.playerFeet())) { + } else if (!getValidPositions().contains(ctx.playerFeet()) && !(MovementHelper.isLiquid(ctx, src) && getValidPositions().contains(ctx.playerFeet().up()))) { return state.setStatus(MovementStatus.UNREACHABLE); } if (sprint()) { From 36290e4e535a94bbe1542fed71e2c914c926b682 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 25 Jun 2019 22:54:24 -0700 Subject: [PATCH 19/39] crucial encapsulation improvement --- src/main/java/baritone/utils/PlayerMovementInput.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/PlayerMovementInput.java b/src/main/java/baritone/utils/PlayerMovementInput.java index c2e2db2a5..4873d2880 100644 --- a/src/main/java/baritone/utils/PlayerMovementInput.java +++ b/src/main/java/baritone/utils/PlayerMovementInput.java @@ -23,7 +23,7 @@ import net.minecraft.util.MovementInput; public class PlayerMovementInput extends MovementInput { private final InputOverrideHandler handler; - public PlayerMovementInput(InputOverrideHandler handler) { + PlayerMovementInput(InputOverrideHandler handler) { this.handler = handler; } From 4d3d48e96286be148cfd2b439cc57a2a3a60c519 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 26 Jun 2019 23:58:22 -0700 Subject: [PATCH 20/39] crucial documentation oversight --- src/main/java/baritone/utils/PlayerMovementInput.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/PlayerMovementInput.java b/src/main/java/baritone/utils/PlayerMovementInput.java index 4873d2880..f41e0f629 100644 --- a/src/main/java/baritone/utils/PlayerMovementInput.java +++ b/src/main/java/baritone/utils/PlayerMovementInput.java @@ -31,7 +31,7 @@ public class PlayerMovementInput extends MovementInput { this.moveStrafe = 0.0F; this.moveForward = 0.0F; - jump = handler.isInputForcedDown(Input.JUMP); // oppa gangnam + jump = handler.isInputForcedDown(Input.JUMP); // oppa gangnam style if (this.forwardKeyDown = handler.isInputForcedDown(Input.MOVE_FORWARD)) { this.moveForward++; From afff6395d1f50e52f0a4806acb7e670de1d0b740 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 27 Jun 2019 21:02:44 -0700 Subject: [PATCH 21/39] codcacy wants a default --- src/main/java/baritone/process/BackfillProcess.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/baritone/process/BackfillProcess.java b/src/main/java/baritone/process/BackfillProcess.java index 65e5692eb..62ae9640f 100644 --- a/src/main/java/baritone/process/BackfillProcess.java +++ b/src/main/java/baritone/process/BackfillProcess.java @@ -85,6 +85,8 @@ public final class BackfillProcess extends BaritoneProcessHelper { // patience baritone.getLookBehavior().updateTarget(fake.getTarget().getRotation().get(), true); return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE); + default: + throw new IllegalStateException(); } } return new PathingCommand(null, PathingCommandType.DEFER); // cede to other process From fdd78cf110fbb1fb7101ea0965b8c5fbc69e8a3a Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 28 Jun 2019 22:17:31 -0700 Subject: [PATCH 22/39] codcacy wants these to be combined --- .../movement/movements/MovementTraverse.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 03f81e761..d32573c00 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -202,13 +202,12 @@ public class MovementTraverse extends Movement { Block fd = BlockStateInterface.get(ctx, src.down()).getBlock(); boolean ladder = fd == Blocks.LADDER || fd == Blocks.VINE; - if (pb0.getBlock() instanceof BlockDoor || pb1.getBlock() instanceof BlockDoor) { - if ((pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest) - || pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src)) - && !(Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock()))) { - return state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), positionsToBreak[0]), ctx.playerRotations()), true)) - .setInput(Input.CLICK_RIGHT, true); - } + if ((pb0.getBlock() instanceof BlockDoor || pb1.getBlock() instanceof BlockDoor) + && (pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest) + || pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src)) + && !(Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock()))) { + return state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), positionsToBreak[0]), ctx.playerRotations()), true)) + .setInput(Input.CLICK_RIGHT, true); } if (pb0.getBlock() instanceof BlockFenceGate || pb1.getBlock() instanceof BlockFenceGate) { From a8155b4b0b7eeee7ab935a0c47936298f8ff7c53 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 29 Jun 2019 11:56:02 -0700 Subject: [PATCH 23/39] privatize --- src/api/java/baritone/api/utils/SettingsUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/java/baritone/api/utils/SettingsUtil.java b/src/api/java/baritone/api/utils/SettingsUtil.java index 5dee6e884..9c21dcf38 100644 --- a/src/api/java/baritone/api/utils/SettingsUtil.java +++ b/src/api/java/baritone/api/utils/SettingsUtil.java @@ -158,11 +158,11 @@ public class SettingsUtil { private final Settings.Setting setting; - public ParserContext(Settings.Setting setting) { + private ParserContext(Settings.Setting setting) { this.setting = setting; } - final Settings.Setting getSetting() { + private Settings.Setting getSetting() { return this.setting; } } From 199e0e5ed31ff015077845126d6121aebd5ecdc9 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 30 Jun 2019 21:55:32 -0700 Subject: [PATCH 24/39] better comparison --- src/main/java/baritone/utils/PathingControlManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/PathingControlManager.java b/src/main/java/baritone/utils/PathingControlManager.java index 92b66c491..ccded35c1 100644 --- a/src/main/java/baritone/utils/PathingControlManager.java +++ b/src/main/java/baritone/utils/PathingControlManager.java @@ -92,7 +92,7 @@ public class PathingControlManager implements IPathingControlManager { p.secretInternalSetGoal(null); return; } - if (inControlThisTick != inControlLastTick && command.commandType != PathingCommandType.REQUEST_PAUSE && inControlLastTick != null && !inControlLastTick.isTemporary()) { + if (!Objects.equals(inControlThisTick, inControlLastTick) && command.commandType != PathingCommandType.REQUEST_PAUSE && inControlLastTick != null && !inControlLastTick.isTemporary()) { // if control has changed from a real process to another real process, and the new process wants to do something p.cancelSegmentIfSafe(); // get rid of the in progress stuff from the last process From c2f35ae46f8d5059695db2a61e946768c6ad4230 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 1 Jul 2019 10:21:58 -0700 Subject: [PATCH 25/39] dawn of the final month --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ad14e1747..2932de262 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Baritone is the pathfinding system used in [Impact](https://impactdevelopment.gi 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). -Have committed at least once a day for the last 10 months =D 🦀 +Have committed at least once a day for the last 11 months =D 🦀 1Leijurv3DWTrGAfmmiTphjhXLvQiHg7K2 From ab779dc850ac987b2c300110767b8e242bdafb29 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 2 Jul 2019 22:13:17 -0700 Subject: [PATCH 26/39] increase shilling --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2932de262..b2bb31647 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ A Minecraft pathfinder bot. Baritone is the pathfinding system used in [Impact](https://impactdevelopment.github.io/) 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. +The easiest way to install Baritone is to install [Impact](https://impactdevelopment.github.io/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the forge jar from [releases](https://github.com/cabaletta/baritone/releases). Otherwise, see [Installation & setup](SETUP.md). + 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 63ee687cee42f03d23b46ae2b56547b58f564765 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 3 Jul 2019 23:47:47 -0700 Subject: [PATCH 27/39] shill EVEN harder --- SETUP.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SETUP.md b/SETUP.md index 1767e2c5b..65b51ec14 100644 --- a/SETUP.md +++ b/SETUP.md @@ -1,5 +1,7 @@ # Installation +The easiest way to install Baritone is to install [Impact](https://impactdevelopment.github.io/), which comes with Baritone. + ## Prebuilt official releases These releases are not always completely up to date with latest features, and are only released from `master`. (so if you want `backfill-2` branch for example, you'll have to build it yourself) From 6d8914e6c9107291eaa5b9c434fc7e01bb2a68ac Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 4 Jul 2019 15:52:09 -0700 Subject: [PATCH 28/39] spell it out even more --- README.md | 4 ++-- SETUP.md | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b2bb31647..55ef27179 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ A Minecraft pathfinder bot. Baritone is the pathfinding system used in [Impact](https://impactdevelopment.github.io/) 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. -The easiest way to install Baritone is to install [Impact](https://impactdevelopment.github.io/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the forge jar from [releases](https://github.com/cabaletta/baritone/releases). Otherwise, see [Installation & setup](SETUP.md). +The easiest way to install Baritone is to install [Impact](https://impactdevelopment.github.io/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the forge 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. 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). @@ -50,7 +50,7 @@ Here are some links to help to get started: - [Settings](https://baritone.leijurv.com/baritone/api/Settings.html#field.detail) -- [Baritone chat control usage](USAGE.md) +- [Usage (chat control)](USAGE.md) # API diff --git a/SETUP.md b/SETUP.md index 65b51ec14..aca5f6c5a 100644 --- a/SETUP.md +++ b/SETUP.md @@ -2,6 +2,8 @@ The easiest way to install Baritone is to install [Impact](https://impactdevelopment.github.io/), which comes with Baritone. +Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it. + ## Prebuilt official releases These releases are not always completely up to date with latest features, and are only released from `master`. (so if you want `backfill-2` branch for example, you'll have to build it yourself) From 94131fd7056a530274e87625f659b2860b15a32f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 5 Jul 2019 21:19:18 -0700 Subject: [PATCH 29/39] too many newlines --- USAGE.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/USAGE.md b/USAGE.md index ce8924a74..f628d542d 100644 --- a/USAGE.md +++ b/USAGE.md @@ -16,9 +16,6 @@ To disable direct chat control (with no prefix), turn off the `chatControl` sett To toggle a boolean setting, just say its name in chat (for example saying `allowBreak` toggles whether Baritone will consider breaking blocks). For a numeric setting, say its name then the new value (like `primaryTimeoutMS 250`). It's case insensitive. To reset a setting to its default value, say `acceptableThrowawayItems reset`. To reset all settings, say `reset`. To see all settings that have been modified from their default values, say `modified`. - - - Some common examples: - `thisway 1000` then `path` to go in the direction you're facing for a thousand blocks - `goal x y z` or `goal x z` or `goal y`, then `path` to go to a certain coordinate From dd9b84646ae13403d0badd03980952eba9550782 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 6 Jul 2019 17:07:16 -0700 Subject: [PATCH 30/39] disgraceful --- src/main/java/baritone/utils/GuiClick.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/baritone/utils/GuiClick.java b/src/main/java/baritone/utils/GuiClick.java index 480da7074..3e6d0eaf5 100644 --- a/src/main/java/baritone/utils/GuiClick.java +++ b/src/main/java/baritone/utils/GuiClick.java @@ -69,7 +69,6 @@ public class GuiClick extends GuiScreen { currentMouseOver = result.getBlockPos(); } } - } @Override From cbbaf2aa2fbf52ed7d0bb63aedc0671b86450e46 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 6 Jul 2019 20:38:59 -0700 Subject: [PATCH 31/39] unscuff --- src/main/java/baritone/utils/GuiClick.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/GuiClick.java b/src/main/java/baritone/utils/GuiClick.java index 3e6d0eaf5..ce5c28a0c 100644 --- a/src/main/java/baritone/utils/GuiClick.java +++ b/src/main/java/baritone/utils/GuiClick.java @@ -102,7 +102,7 @@ public class GuiClick extends GuiScreen { PathRenderer.drawManySelectionBoxes(e, Collections.singletonList(currentMouseOver), Color.CYAN); if (clickStart != null && !clickStart.equals(currentMouseOver)) { GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); GlStateManager.color(Color.RED.getColorComponents(null)[0], Color.RED.getColorComponents(null)[1], Color.RED.getColorComponents(null)[2], 0.4F); GlStateManager.glLineWidth(Baritone.settings().pathRenderLineWidthPixels.value); GlStateManager.disableTexture2D(); From 8f761f7dff95589818c36600c7c78d8cf1282eaa Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 7 Jul 2019 11:03:43 -0700 Subject: [PATCH 32/39] better skip ahead --- src/main/java/baritone/pathing/path/PathExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index e92d32734..6fbe5063d 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -116,7 +116,7 @@ public class PathExecutor implements IPathExecutor, Helper { } for (int i = pathPosition + 3; i < path.length(); i++) { //dont check pathPosition+1. the movement tells us when it's done (e.g. sneak placing) // also don't check pathPosition+2 because reasons - if (whereAmI.equals(path.positions().get(i))) { + if (((Movement) path.movements().get(i)).getValidPositions().contains(whereAmI)) { if (i - pathPosition > 2) { logDebug("Skipping forward " + (i - pathPosition) + " steps, to " + i); } From 4259764b70bb90d1dd1779e4e4ad37c646acb2e1 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 7 Jul 2019 11:12:32 -0700 Subject: [PATCH 33/39] thank you off by one errors very cool --- src/main/java/baritone/pathing/path/PathExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 6fbe5063d..9202b1638 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -114,7 +114,7 @@ public class PathExecutor implements IPathExecutor, Helper { return false; } } - for (int i = pathPosition + 3; i < path.length(); i++) { //dont check pathPosition+1. the movement tells us when it's done (e.g. sneak placing) + for (int i = pathPosition + 3; i < path.length() - 1; i++) { //dont check pathPosition+1. the movement tells us when it's done (e.g. sneak placing) // also don't check pathPosition+2 because reasons if (((Movement) path.movements().get(i)).getValidPositions().contains(whereAmI)) { if (i - pathPosition > 2) { From b81bcf8c6de90eaa89c7c9d1bac626e529cfa178 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 7 Jul 2019 11:44:56 -0700 Subject: [PATCH 34/39] fix path start in diagonal and downward --- src/main/java/baritone/pathing/movement/Movement.java | 5 +++++ .../pathing/movement/movements/MovementDiagonal.java | 2 +- .../pathing/movement/movements/MovementDownward.java | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 6907c426a..ca4abe9e3 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -23,6 +23,7 @@ import baritone.api.pathing.movement.IMovement; import baritone.api.pathing.movement.MovementStatus; import baritone.api.utils.*; import baritone.api.utils.input.Input; +import baritone.behavior.PathingBehavior; import baritone.utils.BlockStateInterface; import net.minecraft.block.BlockLiquid; import net.minecraft.entity.item.EntityFallingBlock; @@ -110,6 +111,10 @@ public abstract class Movement implements IMovement, MovementHelper { return validPositionsCached; } + protected boolean playerInValidPosition() { + return getValidPositions().contains(ctx.playerFeet()) || getValidPositions().contains(((PathingBehavior) baritone.getPathingBehavior()).pathStart()); + } + /** * Handles the execution of the latest Movement * State, and offers a Status to the calling class. diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index f17fc18da..c036a459d 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -184,7 +184,7 @@ public class MovementDiagonal extends Movement { if (ctx.playerFeet().equals(dest)) { return state.setStatus(MovementStatus.SUCCESS); - } else if (!getValidPositions().contains(ctx.playerFeet()) && !(MovementHelper.isLiquid(ctx, src) && getValidPositions().contains(ctx.playerFeet().up()))) { + } else if (!playerInValidPosition() && !(MovementHelper.isLiquid(ctx, src) && getValidPositions().contains(ctx.playerFeet().up()))) { return state.setStatus(MovementStatus.UNREACHABLE); } if (sprint()) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java index 250f34717..da5e3f893 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java @@ -81,7 +81,7 @@ public class MovementDownward extends Movement { if (ctx.playerFeet().equals(dest)) { return state.setStatus(MovementStatus.SUCCESS); - } else if (!getValidPositions().contains(ctx.playerFeet())) { + } else if (!playerInValidPosition()) { return state.setStatus(MovementStatus.UNREACHABLE); } double diffX = ctx.player().posX - (dest.getX() + 0.5); From cd4205c3610e59d82e99e8931a1f199f1021c171 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 7 Jul 2019 12:07:00 -0700 Subject: [PATCH 35/39] v1.2.7 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 27b0d7a3f..00e35617c 100755 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ */ group 'baritone' -version '1.2.6' +version '1.2.7' buildscript { repositories { From f4dd1003455892a0a4cbaa7178ea32b7a29f9340 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 8 Jul 2019 23:16:26 -0700 Subject: [PATCH 36/39] fix indexof --- src/main/java/baritone/pathing/path/PathExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 9202b1638..e03a20ccd 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -427,7 +427,7 @@ public class PathExecutor implements IPathExecutor, Helper { if (current instanceof MovementFall) { Tuple data = overrideFall((MovementFall) current); if (data != null) { - BlockPos fallDest = data.getSecond(); + BetterBlockPos fallDest = new BetterBlockPos(data.getSecond()); if (!path.positions().contains(fallDest)) { throw new IllegalStateException(); } From eba1011fd6f05b4f86b736f256035688c2b20e78 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 9 Jul 2019 23:47:42 -0700 Subject: [PATCH 37/39] remove scuff --- src/main/java/baritone/utils/PathRenderer.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index 88a181470..b0924cc1d 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -97,8 +97,6 @@ public final class PathRenderer implements Helper { } //drawManySelectionBoxes(player, Collections.singletonList(behavior.pathStart()), partialTicks, Color.WHITE); - //long start = System.nanoTime(); - // Render the current path, if there is one if (current != null && current.getPath() != null) { @@ -109,8 +107,6 @@ public final class PathRenderer implements Helper { drawPath(next.getPath(), 0, renderView, partialTicks, Baritone.settings().colorNextPath.value, Baritone.settings().fadePath.value, 10, 20); } - //long split = System.nanoTime(); - // If there is a path calculation currently running, render the path calculation process behavior.getInProgress().ifPresent(currentlyRunning -> { currentlyRunning.bestPathSoFar().ifPresent(p -> { @@ -122,11 +118,6 @@ public final class PathRenderer implements Helper { drawManySelectionBoxes(renderView, Collections.singletonList(mr.getDest()), Baritone.settings().colorMostRecentConsidered.value); }); }); - //long end = System.nanoTime(); - //System.out.println((end - split) + " " + (split - start)); - // if (end - start > 0) { - // System.out.println("Frame took " + (split - start) + " " + (end - split)); - //} } public static void drawPath(IPath path, int startIndex, Entity player, float partialTicks, Color color, boolean fadeOut, int fadeStart0, int fadeEnd0) { From aa90c8b7cd591b1a47bc523dbcfec1c040a96894 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 10 Jul 2019 22:18:11 -0700 Subject: [PATCH 38/39] address encapsulation conccerns --- src/main/java/baritone/process/BackfillProcess.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/process/BackfillProcess.java b/src/main/java/baritone/process/BackfillProcess.java index 62ae9640f..f025c3933 100644 --- a/src/main/java/baritone/process/BackfillProcess.java +++ b/src/main/java/baritone/process/BackfillProcess.java @@ -92,7 +92,7 @@ public final class BackfillProcess extends BaritoneProcessHelper { return new PathingCommand(null, PathingCommandType.DEFER); // cede to other process } - public void amIBreakingABlockHMMMMMMM() { + private void amIBreakingABlockHMMMMMMM() { if (!ctx.getSelectedBlock().isPresent()) { return; } From 01658286af37b9bb5a7f93019fa0d5d09b574373 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 11 Jul 2019 10:41:24 -0700 Subject: [PATCH 39/39] detect allowbreak false --- src/main/java/baritone/process/MineProcess.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index 01a460d4d..f3b1d20bc 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -99,6 +99,11 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro return null; } } + if (!Baritone.settings().allowBreak.value) { + logDirect("Unable to mine when allowBreak is false!"); + cancel(); + return null; + } int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.value; List curr = new ArrayList<>(knownOreLocations); if (mineGoalUpdateInterval != 0 && tickCount++ % mineGoalUpdateInterval == 0) { // big brain @@ -395,6 +400,10 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro @Override public void mine(int quantity, Block... blocks) { this.mining = blocks == null || blocks.length == 0 ? null : Arrays.asList(blocks); + if (mining != null && !Baritone.settings().allowBreak.value) { + logDirect("Unable to mine when allowBreak is false!"); + mining = null; + } this.desiredQuantity = quantity; this.knownOreLocations = new ArrayList<>(); this.blacklist = new ArrayList<>();