From 86525f98ec9dfdf4531fb115c8e8cd33a5d912b1 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 10 Jun 2019 23:12:37 -0700 Subject: [PATCH 01/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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 c7e1c917c34cf96e6c6ab18dbf9a01c51e5fb678 Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 8 Jul 2019 19:21:09 -0500 Subject: [PATCH 36/75] Fix Baritone thinking it can walk through wall-placed skulls Fixes #485 --- src/main/java/baritone/pathing/movement/MovementHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index eff91e123..0f66ce23d 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -94,7 +94,7 @@ public interface MovementHelper extends ActionCosts, Helper { if (block instanceof BlockAir) { // early return for most common case return true; } - if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.COBWEB || block == Blocks.END_PORTAL || block == Blocks.COCOA || block instanceof BlockSkull || block == Blocks.BUBBLE_COLUMN || block instanceof BlockShulkerBox || block instanceof BlockSlab || block instanceof BlockTrapDoor) { + if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.COBWEB || block == Blocks.END_PORTAL || block == Blocks.COCOA || block instanceof BlockAbstractSkull || block == Blocks.BUBBLE_COLUMN || block instanceof BlockShulkerBox || block instanceof BlockSlab || block instanceof BlockTrapDoor) { return false; } if (Baritone.settings().blocksToAvoid.value.contains(block)) { From f4dd1003455892a0a4cbaa7178ea32b7a29f9340 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 8 Jul 2019 23:16:26 -0700 Subject: [PATCH 37/75] 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 38/75] 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 39/75] 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 40/75] 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<>(); From d70243b4c03719a842f4b1e46e121670175d090d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 11 Jul 2019 11:08:45 -0700 Subject: [PATCH 41/75] leijurv would never do this --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index 702af3744..db5be4c23 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,7 @@ [![Pull Requests](https://img.shields.io/github/issues-pr/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/pulls/) ![Code size](https://img.shields.io/github/languages/code-size/cabaletta/baritone.svg) ![GitHub repo size](https://img.shields.io/github/repo-size/cabaletta/baritone.svg) -<<<<<<< HEAD -![](https://tokei.rs/b1/github/cabaletta/baritone?category=code) -[![Minecraft](https://img.shields.io/badge/MC-1.13.2-brightgreen.svg)](https://minecraft.gamepedia.com/1.13.2) -======= ![Lines of Code](https://tokei.rs/b1/github/cabaletta/baritone?category=code) ->>>>>>> master [![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/) From 1427cf57a816b25746bd1d4b5a157f1f5573b071 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 11 Jul 2019 11:56:44 -0700 Subject: [PATCH 42/75] randomlooking --- src/api/java/baritone/api/Settings.java | 5 +++++ src/main/java/baritone/behavior/LookBehavior.java | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 373fd08eb..36db4400c 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -231,6 +231,11 @@ public final class Settings { */ public final Setting rightClickSpeed = new Setting<>(4); + /** + * How many degrees to randomize the yaw every tick. Set to 0 to disable + */ + public final Setting randomLooking = new Setting<>(2d); + /** * This is the big A* setting. * As long as your cost heuristic is an *underestimate*, it's guaranteed to find you the best path. diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java index d6833a58f..2a8a4935b 100644 --- a/src/main/java/baritone/behavior/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -50,6 +50,13 @@ public final class LookBehavior extends Behavior implements ILookBehavior { @Override public void updateTarget(Rotation target, boolean force) { this.target = target; + if (!force) { + double rand = Math.random() - 0.5; + if (Math.abs(rand) < 0.1) { + rand *= 4; + } + this.target = new Rotation(this.target.getYaw() + (float) (rand * Baritone.settings().randomLooking.value), this.target.getPitch()); + } this.force = force || !Baritone.settings().freeLook.value; } From 1390af20b6c4f487e1e93521f0485235eda5a90a Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 11 Jul 2019 12:46:24 -0700 Subject: [PATCH 43/75] fix parkour and multithread farm --- .../pathing/movement/movements/MovementParkour.java | 2 +- src/main/java/baritone/process/FarmProcess.java | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index ebfb589a8..b0854e6bb 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -227,7 +227,7 @@ public class MovementParkour extends Movement { state.setStatus(MovementStatus.SUCCESS); } } else if (!ctx.playerFeet().equals(src)) { - if (ctx.playerFeet().equals(src.offset(direction)) || ctx.player().posY - ctx.playerFeet().getY() > 0.0001) { + if (ctx.playerFeet().equals(src.offset(direction)) || ctx.player().posY - src.y > 0.0001) { if (!MovementHelper.canWalkOn(ctx, dest.down()) && !ctx.player().onGround && MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), true) == PlaceResult.READY_TO_PLACE) { // go in the opposite order to check DOWN before all horizontals -- down is preferable because you don't have to look to the side while in midair, which could mess up the trajectory state.setInput(Input.CLICK_RIGHT, true); diff --git a/src/main/java/baritone/process/FarmProcess.java b/src/main/java/baritone/process/FarmProcess.java index a783cb495..c8dc2ef2d 100644 --- a/src/main/java/baritone/process/FarmProcess.java +++ b/src/main/java/baritone/process/FarmProcess.java @@ -52,6 +52,9 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro private boolean active; + private List locations; + private int tickCount; + private static final List FARMLAND_PLANTABLE = Arrays.asList( Items.BEETROOT_SEEDS, Items.MELON_SEEDS, @@ -91,6 +94,7 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro @Override public void farm() { active = true; + locations = null; } private enum Harvest { @@ -162,9 +166,12 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro if (Baritone.settings().replantNetherWart.value) { scan.add(Blocks.SOUL_SAND); } - - List locations = WorldScanner.INSTANCE.scanChunkRadius(ctx, scan, 256, 10, 4); - + if (Baritone.settings().mineGoalUpdateInterval.value != 0 && tickCount++ % Baritone.settings().mineGoalUpdateInterval.value == 0) { + Baritone.getExecutor().execute(() -> locations = WorldScanner.INSTANCE.scanChunkRadius(ctx, scan, 256, 10, 10)); + } + if (locations == null) { + return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE); + } List toBreak = new ArrayList<>(); List openFarmland = new ArrayList<>(); List bonemealable = new ArrayList<>(); From 1a4635df16acb15ccfe257bd0017d86e59b57180 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 11 Jul 2019 12:47:44 -0700 Subject: [PATCH 44/75] v1.3.3 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b5a96f160..c144f8d67 100755 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ */ group 'baritone' -version '1.3.2' +version '1.3.3' buildscript { repositories { From ce4b1e09edf44f08107b405bf8dd121c8fa38550 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 11 Jul 2019 12:46:24 -0700 Subject: [PATCH 45/75] fix parkour and multithread farm --- .../pathing/movement/movements/MovementParkour.java | 2 +- src/main/java/baritone/process/FarmProcess.java | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index b9f02c1ac..88ffb1d92 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -226,7 +226,7 @@ public class MovementParkour extends Movement { state.setStatus(MovementStatus.SUCCESS); } } else if (!ctx.playerFeet().equals(src)) { - if (ctx.playerFeet().equals(src.offset(direction)) || ctx.player().posY - ctx.playerFeet().getY() > 0.0001) { + if (ctx.playerFeet().equals(src.offset(direction)) || ctx.player().posY - src.y > 0.0001) { if (!MovementHelper.canWalkOn(ctx, dest.down()) && !ctx.player().onGround && MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), true) == PlaceResult.READY_TO_PLACE) { // go in the opposite order to check DOWN before all horizontals -- down is preferable because you don't have to look to the side while in midair, which could mess up the trajectory state.setInput(Input.CLICK_RIGHT, true); diff --git a/src/main/java/baritone/process/FarmProcess.java b/src/main/java/baritone/process/FarmProcess.java index 9593a192b..a2d32f78c 100644 --- a/src/main/java/baritone/process/FarmProcess.java +++ b/src/main/java/baritone/process/FarmProcess.java @@ -54,6 +54,9 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro private boolean active; + private List locations; + private int tickCount; + private static final List FARMLAND_PLANTABLE = Arrays.asList( Items.BEETROOT_SEEDS, Items.MELON_SEEDS, @@ -93,6 +96,7 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro @Override public void farm() { active = true; + locations = null; } private enum Harvest { @@ -164,9 +168,12 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro if (Baritone.settings().replantNetherWart.value) { scan.add(Blocks.SOUL_SAND); } - - List locations = WorldScanner.INSTANCE.scanChunkRadius(ctx, scan, 256, 10, 4); - + if (Baritone.settings().mineGoalUpdateInterval.value != 0 && tickCount++ % Baritone.settings().mineGoalUpdateInterval.value == 0) { + Baritone.getExecutor().execute(() -> locations = WorldScanner.INSTANCE.scanChunkRadius(ctx, scan, 256, 10, 10)); + } + if (locations == null) { + return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE); + } List toBreak = new ArrayList<>(); List openFarmland = new ArrayList<>(); List bonemealable = new ArrayList<>(); From b16f9edd2c8d950e8ce7ec4e1cad81201288c921 Mon Sep 17 00:00:00 2001 From: Baddeveloper Date: Fri, 12 Jul 2019 19:12:00 +0200 Subject: [PATCH 46/75] Added EntitySpider and EntityPigZombie conditions --- src/main/java/baritone/utils/pathing/Avoidance.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/baritone/utils/pathing/Avoidance.java b/src/main/java/baritone/utils/pathing/Avoidance.java index c4b12336e..c7b6a854f 100644 --- a/src/main/java/baritone/utils/pathing/Avoidance.java +++ b/src/main/java/baritone/utils/pathing/Avoidance.java @@ -22,6 +22,8 @@ import baritone.api.utils.BetterBlockPos; import baritone.api.utils.IPlayerContext; import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; import net.minecraft.entity.monster.EntityMob; +import net.minecraft.entity.monster.EntityPigZombie; +import net.minecraft.entity.monster.EntitySpider; import net.minecraft.util.math.BlockPos; import java.util.ArrayList; @@ -70,6 +72,8 @@ public class Avoidance { if (mobCoeff != 1.0D) { ctx.world().loadedEntityList.stream() .filter(entity -> entity instanceof EntityMob) + .filter(entity -> (!(entity instanceof EntitySpider)) || ctx.player().getBrightness() < 0.5) + .filter(entity -> !(entity instanceof EntityPigZombie) || ((EntityPigZombie) entity).isAngry()) .forEach(entity -> res.add(new Avoidance(new BlockPos(entity), mobCoeff, Baritone.settings().mobAvoidanceRadius.value))); } return res; From 6bb87d0a64d77435f6e26433e22cf3daa851c41b Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 12 Jul 2019 23:27:02 -0700 Subject: [PATCH 47/75] address an absolutely critical gap in documentation --- src/api/java/baritone/api/IBaritone.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/api/java/baritone/api/IBaritone.java b/src/api/java/baritone/api/IBaritone.java index a356922cc..2c892d982 100644 --- a/src/api/java/baritone/api/IBaritone.java +++ b/src/api/java/baritone/api/IBaritone.java @@ -128,5 +128,8 @@ public interface IBaritone { */ IEventBus getGameEventHandler(); + /** + * Open click + */ void openClick(); } From 2b41012c5ba4ff8fe3374467fbb2214e3f5665c8 Mon Sep 17 00:00:00 2001 From: StijnSimons Date: Sat, 13 Jul 2019 17:17:10 +0200 Subject: [PATCH 48/75] Enderman angry condition --- src/main/java/baritone/utils/pathing/Avoidance.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/baritone/utils/pathing/Avoidance.java b/src/main/java/baritone/utils/pathing/Avoidance.java index c7b6a854f..11b4a73f4 100644 --- a/src/main/java/baritone/utils/pathing/Avoidance.java +++ b/src/main/java/baritone/utils/pathing/Avoidance.java @@ -21,6 +21,7 @@ import baritone.Baritone; import baritone.api.utils.BetterBlockPos; import baritone.api.utils.IPlayerContext; import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; +import net.minecraft.entity.monster.EntityEnderman; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.monster.EntityPigZombie; import net.minecraft.entity.monster.EntitySpider; @@ -74,6 +75,7 @@ public class Avoidance { .filter(entity -> entity instanceof EntityMob) .filter(entity -> (!(entity instanceof EntitySpider)) || ctx.player().getBrightness() < 0.5) .filter(entity -> !(entity instanceof EntityPigZombie) || ((EntityPigZombie) entity).isAngry()) + .filter(entity -> !(entity instanceof EntityEnderman) || ((EntityEnderman) entity).isScreaming()) .forEach(entity -> res.add(new Avoidance(new BlockPos(entity), mobCoeff, Baritone.settings().mobAvoidanceRadius.value))); } return res; From 38602dd141512fbd04f3eee30ceebad15609d741 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 14 Jul 2019 11:13:51 -0700 Subject: [PATCH 49/75] verify top side of block, fixes #541 --- src/main/java/baritone/process/FarmProcess.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/process/FarmProcess.java b/src/main/java/baritone/process/FarmProcess.java index a2d32f78c..2702442bd 100644 --- a/src/main/java/baritone/process/FarmProcess.java +++ b/src/main/java/baritone/process/FarmProcess.java @@ -24,6 +24,7 @@ import baritone.api.pathing.goals.GoalComposite; import baritone.api.process.IFarmProcess; import baritone.api.process.PathingCommand; import baritone.api.process.PathingCommandType; +import baritone.api.utils.RayTraceUtils; import baritone.api.utils.Rotation; import baritone.api.utils.RotationUtils; import baritone.api.utils.input.Input; @@ -40,7 +41,9 @@ import net.minecraft.item.EnumDyeColor; import net.minecraft.item.Item; import net.minecraft.item.ItemDye; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; @@ -223,11 +226,14 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro boolean soulsand = openSoulsand.contains(pos); Optional rot = RotationUtils.reachableOffset(ctx.player(), pos, new Vec3d(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5), ctx.playerController().getBlockReachDistance()); if (rot.isPresent() && isSafeToCancel && baritone.getInventoryBehavior().throwaway(true, soulsand ? this::isNetherWart : this::isPlantable)) { - baritone.getLookBehavior().updateTarget(rot.get(), true); - if (ctx.isLookingAt(pos)) { - baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true); + RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot.get(), ctx.playerController().getBlockReachDistance()); + if (result.typeOfHit == RayTraceResult.Type.BLOCK && result.sideHit == EnumFacing.UP) { + baritone.getLookBehavior().updateTarget(rot.get(), true); + if (ctx.isLookingAt(pos)) { + baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true); + } + return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE); } - return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE); } } for (BlockPos pos : bonemealable) { From b51a261bd10483a0ec10527f92db2171f4b7f9fc Mon Sep 17 00:00:00 2001 From: StijnSimons Date: Mon, 15 Jul 2019 22:31:55 +0200 Subject: [PATCH 50/75] Added entityfollow Hey look i can cntrl + c v --- .../api/utils/ExampleBaritoneControl.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 2445f6341..29e2e9d17 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -411,6 +411,24 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener logDirect("Following any players"); return true; } + if (msg.startsWith("followentity")) { + String name = msg.substring(12).trim(); + Optional toFollow = Optional.empty(); + for (Entity entity : ctx.world().loadedEntityList) { + String entityName = entity.getName().trim().toLowerCase(); + if (entityName.contains(name) || name.contains(entityName)) { + toFollow = Optional.of(entity); + } + } + if (!toFollow.isPresent()) { + logDirect("Entity not found"); + return true; + } + Entity effectivelyFinal = toFollow.get(); + baritone.getFollowProcess().follow(effectivelyFinal::equals); + logDirect("Following entity " + toFollow.get()); + return true; + } if (msg.startsWith("follow")) { String name = msg.substring(6).trim(); Optional toFollow = Optional.empty(); From 3ba8824eb003aedec9edc334f2ec59c991ecad3b Mon Sep 17 00:00:00 2001 From: StijnSimons Date: Mon, 15 Jul 2019 22:34:52 +0200 Subject: [PATCH 51/75] More copy paste --- src/api/java/baritone/api/utils/ExampleBaritoneControl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 29e2e9d17..1b47c8a56 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -406,6 +406,11 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener } return true; } + if (msg.startsWith("followentities")) { + baritone.getFollowProcess().follow(Entity.class::isInstance); + logDirect("Following any entities"); + return true; + } if (msg.startsWith("followplayers")) { baritone.getFollowProcess().follow(EntityPlayer.class::isInstance); // O P P A logDirect("Following any players"); From 72be046f34d703bb05497ab38177405a57385816 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 15 Jul 2019 14:44:16 -0700 Subject: [PATCH 52/75] Update ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index e9a3c7cc1..877b6260c 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1 +1,28 @@ - +# Bug report + +## Some information +Operating system: +Java version: +Minecraft version: +Baritone version: +Forge mods (if used): + +## Exception, error or logs +You can find your logs in `%appdata%/.minecraft/logs/` (Windows) or `/Library/Application\ Support/minecraft/logs` (Mac). + +## How to reproduce +Add your steps to reproduce here. + +## Final checklist +- [ ] I have included the version of Minecraft I'm running, baritone's version and forge mods (if used). +- [ ] I have included logs, exceptions and / or steps to reproduce the issue. +- [ ] I have not used any OwO's or UwU's in this issue. + +# Suggestion +Give some information about your suggestion. + +## New features +Add feature ideas here. + +## New options +Add option ideas here. From e034437c633584c9d0893dc5a4201dfd02ac09bf Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 15 Jul 2019 17:55:15 -0500 Subject: [PATCH 53/75] Separate templates --- .../bug.md} | 21 ++++++++----------- .github/ISSUE_TEMPLATE/suggestion.md | 19 +++++++++++++++++ 2 files changed, 28 insertions(+), 12 deletions(-) rename .github/{ISSUE_TEMPLATE.md => ISSUE_TEMPLATE/bug.md} (64%) create mode 100644 .github/ISSUE_TEMPLATE/suggestion.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE/bug.md similarity index 64% rename from .github/ISSUE_TEMPLATE.md rename to .github/ISSUE_TEMPLATE/bug.md index 877b6260c..55e5ad06f 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -1,4 +1,10 @@ -# Bug report +--- +name: Bug report +about: Please file a separate report for each issue +title: Please add a brief but descriptive title +labels: bug +assignees: '' +--- ## Some information Operating system: @@ -11,18 +17,9 @@ Forge mods (if used): You can find your logs in `%appdata%/.minecraft/logs/` (Windows) or `/Library/Application\ Support/minecraft/logs` (Mac). ## How to reproduce -Add your steps to reproduce here. +Add your steps to reproduce the issue/bug experienced here. ## Final checklist - [ ] I have included the version of Minecraft I'm running, baritone's version and forge mods (if used). - [ ] I have included logs, exceptions and / or steps to reproduce the issue. -- [ ] I have not used any OwO's or UwU's in this issue. - -# Suggestion -Give some information about your suggestion. - -## New features -Add feature ideas here. - -## New options -Add option ideas here. +- [ ] I have not used any OwO's or UwU's in this issue. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/suggestion.md b/.github/ISSUE_TEMPLATE/suggestion.md new file mode 100644 index 000000000..da61c638d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/suggestion.md @@ -0,0 +1,19 @@ +--- +name: Suggestion +about: Please file a separate report for each suggestion +title: Please add a brief but descriptive title +labels: enhancement +assignees: '' +--- + +## Describe your suggestion +With as much detail as possible, describe what your suggestion would do for Baritone. + +## Settings +If applicable, what settings/customizability should be offered to tweak the functionality of your suggestion. + +## Context +Describe how your suggestion would improve Baritone, or the reason behind it being added. + +## Final checklist +- [ ] I have not used any OwO's or UwU's in this issue. \ No newline at end of file From 0d9f233e33a8951df0e023d9879cfe21e4ee93bb Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 15 Jul 2019 18:00:51 -0500 Subject: [PATCH 54/75] Add question template --- .github/ISSUE_TEMPLATE/question.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/question.md diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 000000000..2482fd4c3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,13 @@ +--- +name: Question +about: Please file a separate report for each question +title: Please add a brief but descriptive title +labels: question +assignees: '' +--- + +## What do you need help with? +With as much detail as possible, describe your question and what you may need help with. + +## Final checklist +- [ ] I have not used any OwO's or UwU's in this issue. \ No newline at end of file From 09239f8180c725d21d5167bc24014c479b885eea Mon Sep 17 00:00:00 2001 From: ZakME <35682140+ZakME@users.noreply.github.com> Date: Tue, 16 Jul 2019 23:50:03 -0600 Subject: [PATCH 55/75] PICKUP_DROPPED - Remove 2nd Items.WHEAT PICKUP_DROPPED: Remove 2nd Items.WHEAT Re-order a few items for neatness --- src/main/java/baritone/process/FarmProcess.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/process/FarmProcess.java b/src/main/java/baritone/process/FarmProcess.java index 2702442bd..350b1ac81 100644 --- a/src/main/java/baritone/process/FarmProcess.java +++ b/src/main/java/baritone/process/FarmProcess.java @@ -71,17 +71,16 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro private static final List PICKUP_DROPPED = Arrays.asList( Items.BEETROOT_SEEDS, - Items.WHEAT, + Items.BEETROOT, Items.MELON_SEEDS, Items.MELON, + Item.getItemFromBlock(Blocks.MELON_BLOCK), Items.WHEAT_SEEDS, Items.WHEAT, Items.PUMPKIN_SEEDS, + Item.getItemFromBlock(Blocks.PUMPKIN), Items.POTATO, Items.CARROT, - Items.BEETROOT, - Item.getItemFromBlock(Blocks.PUMPKIN), - Item.getItemFromBlock(Blocks.MELON_BLOCK), Items.NETHER_WART, Items.REEDS, Item.getItemFromBlock(Blocks.CACTUS) From f32147d9d521ce3db1175463dd28fa44f160353c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 17 Jul 2019 22:41:09 -0700 Subject: [PATCH 56/75] privatize --- src/main/java/baritone/utils/BlockBreakHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/BlockBreakHelper.java b/src/main/java/baritone/utils/BlockBreakHelper.java index 36e2dfeac..95d021c29 100644 --- a/src/main/java/baritone/utils/BlockBreakHelper.java +++ b/src/main/java/baritone/utils/BlockBreakHelper.java @@ -38,7 +38,7 @@ public final class BlockBreakHelper implements Helper { this.playerContext = playerContext; } - public void tryBreakBlock(BlockPos pos, EnumFacing side) { + private void tryBreakBlock(BlockPos pos, EnumFacing side) { if (playerContext.playerController().onPlayerDamageBlock(pos, side)) { playerContext.player().swingArm(EnumHand.MAIN_HAND); } From 81514446713e22faf85ee76e917e0120c05ea355 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 18 Jul 2019 14:15:53 -0700 Subject: [PATCH 57/75] privatize this too --- 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 ccded35c1..14d921d0f 100644 --- a/src/main/java/baritone/utils/PathingControlManager.java +++ b/src/main/java/baritone/utils/PathingControlManager.java @@ -126,7 +126,7 @@ public class PathingControlManager implements IPathingControlManager { } } - public void postTick() { + private void postTick() { // if we did this in pretick, it would suck // we use the time between ticks as calculation time // therefore, we only cancel and recalculate after the tick for the current path has executed From af943a8253f538761b6421bb7a8bb2f2cbe19938 Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 18 Jul 2019 21:18:02 -0500 Subject: [PATCH 58/75] Fix issue opening fence gates in some scenarios If there are 2 fence gates at the player height, and they are approached diagonally, there is a slight chance that Baritone will be caught in an infinite loop of opening and closing the upper fence gate, being unable to interact with the bottom one. --- .../movement/movements/MovementTraverse.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index d32573c00..4eab7144f 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -37,6 +37,7 @@ import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; +import java.util.Optional; import java.util.Set; public class MovementTraverse extends Movement { @@ -202,12 +203,15 @@ 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) - && (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) { + + boolean notPassable = pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest) || pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src); + boolean canOpen = !(Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock())); + + if (notPassable && canOpen) { + 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) { @@ -215,8 +219,10 @@ public class MovementTraverse extends Movement { : !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); + Optional rotation = RotationUtils.reachable(ctx, blocked); + if (rotation.isPresent()) { + return state.setTarget(new MovementState.MovementTarget(rotation.get(), true)).setInput(Input.CLICK_RIGHT, true); + } } } From 8b43d9325916d78e5ccdb5800eed97d7eaf24437 Mon Sep 17 00:00:00 2001 From: StijnSimons Date: Sat, 20 Jul 2019 01:37:43 +0200 Subject: [PATCH 59/75] i forgot players and items were entities too --- src/api/java/baritone/api/utils/ExampleBaritoneControl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 1b47c8a56..0f2e08156 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -35,6 +35,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ChunkProviderClient; import net.minecraft.crash.CrashReport; import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ReportedException; @@ -421,7 +422,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener Optional toFollow = Optional.empty(); for (Entity entity : ctx.world().loadedEntityList) { String entityName = entity.getName().trim().toLowerCase(); - if (entityName.contains(name) || name.contains(entityName)) { + if ((entityName.contains(name) || name.contains(entityName)) && !(entity instanceof EntityItem || entity instanceof EntityPlayer)) { // We dont want it following players while `#follow` exists. toFollow = Optional.of(entity); } } From df900c9e64d80492391cef5860952ef7a3bebb79 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 19 Jul 2019 18:55:32 -0700 Subject: [PATCH 60/75] use origin --- src/main/java/baritone/pathing/movement/MovementHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 60b361195..97a768abe 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -134,7 +134,7 @@ public interface MovementHelper extends ActionCosts, Helper { // every block that overrides isPassable with anything more complicated than a "return true;" or "return false;" // has already been accounted for above // therefore it's safe to not construct a blockpos from our x, y, z ints and instead just pass null - return block.isPassable(null, null); + return block.isPassable(null, BlockPos.ORIGIN); } /** From ed4753e968b14ac18cc16ee01b41ff41aeda1ad7 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 19 Jul 2019 22:33:08 -0700 Subject: [PATCH 61/75] now that impact locks to specific baritone versions this hack can finally be removed yay --- src/api/java/baritone/api/utils/BlockUtils.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/api/java/baritone/api/utils/BlockUtils.java b/src/api/java/baritone/api/utils/BlockUtils.java index fd376c9a8..f7d0d9f6b 100644 --- a/src/api/java/baritone/api/utils/BlockUtils.java +++ b/src/api/java/baritone/api/utils/BlockUtils.java @@ -39,9 +39,6 @@ public class BlockUtils { } public static Block stringToBlockRequired(String name) { - if (name.equals("lit_redstone_ore")) { // workaround for Impact 4.6 only - return stringToBlockRequired("redstone_ore"); - } Block block = stringToBlockNullable(name); Objects.requireNonNull(block); return block; From 4d127acb9aae88ea17e34f0ef0b272a4138489eb Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 20 Jul 2019 23:47:51 -0700 Subject: [PATCH 62/75] reformat --- src/api/java/baritone/api/utils/ExampleBaritoneControl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 0f2e08156..96d6ad2fc 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -610,7 +610,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener } if (msg.startsWith("delete")) { String name = msg.substring(6).trim(); - IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getAllWaypoints().stream().filter(w -> w.getTag() == IWaypoint.Tag.USER && w.getName().equalsIgnoreCase(name)).findFirst().orElse(null); + IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getAllWaypoints().stream().filter(w -> w.getTag() == IWaypoint.Tag.USER && w.getName().equalsIgnoreCase(name)).findFirst().orElse(null); if (waypoint == null) { logDirect("No user defined position under the name '" + name + "' found."); return true; @@ -714,7 +714,6 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener goal = new GoalBlock(playerFeet); break; case 1: - goal = new GoalYLevel(parseOrDefault(params[0], playerFeet.y)); break; case 2: From 9dd68568720d5f62d1526484ed443f932e5d547e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 21 Jul 2019 14:36:02 -0700 Subject: [PATCH 63/75] get called out --- src/main/java/baritone/pathing/movement/MovementHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 0f66ce23d..bc8d0c2eb 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -142,7 +142,7 @@ public interface MovementHelper extends ActionCosts, Helper { // every block that overrides isPassable with anything more complicated than a "return true;" or "return false;" // has already been accounted for above // therefore it's safe to not construct a blockpos from our x, y, z ints and instead just pass null - return state.allowsMovement(null, null, PathType.LAND); + return state.allowsMovement(null, BlockPos.ORIGIN, PathType.LAND); // workaround for future compatibility =P } /** From d505ec4f9f031a982d2c93ef40d675e396be75d9 Mon Sep 17 00:00:00 2001 From: Babbaj Date: Sun, 21 Jul 2019 20:54:02 -0400 Subject: [PATCH 64/75] build the schematic schematica has open --- build.gradle | 8 +++ scripts/proguard.pro | 5 ++ .../baritone/api/process/IBuilderProcess.java | 2 + .../api/utils/ExampleBaritoneControl.java | 4 ++ .../java/baritone/process/BuilderProcess.java | 15 ++++++ .../schematica/SchematicAdapter.java | 54 +++++++++++++++++++ .../schematica/SchematicaHelper.java | 50 +++++++++++++++++ .../lunatrius/core/util/math/MBlockPos.java | 30 +++++++++++ .../lunatrius/schematica/Schematica.java | 24 +++++++++ .../lunatrius/schematica/api/ISchematic.java | 31 +++++++++++ .../client/world/SchematicWorld.java | 32 +++++++++++ .../schematica/proxy/ClientProxy.java | 29 ++++++++++ .../schematica/proxy/CommonProxy.java | 20 +++++++ 13 files changed, 304 insertions(+) create mode 100644 src/main/java/baritone/utils/schematic/schematica/SchematicAdapter.java create mode 100644 src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java create mode 100644 src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java create mode 100644 src/schematica_api/java/com/github/lunatrius/schematica/Schematica.java create mode 100644 src/schematica_api/java/com/github/lunatrius/schematica/api/ISchematic.java create mode 100644 src/schematica_api/java/com/github/lunatrius/schematica/client/world/SchematicWorld.java create mode 100644 src/schematica_api/java/com/github/lunatrius/schematica/proxy/ClientProxy.java create mode 100644 src/schematica_api/java/com/github/lunatrius/schematica/proxy/CommonProxy.java diff --git a/build.gradle b/build.gradle index 00e35617c..1264f0fe1 100755 --- a/build.gradle +++ b/build.gradle @@ -55,6 +55,14 @@ sourceSets { launch { compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output } + + schematica_api { + compileClasspath += main.compileClasspath + } + + main { + compileClasspath += schematica_api.output + } } minecraft { diff --git a/scripts/proguard.pro b/scripts/proguard.pro index bb8df2aed..2e10986df 100644 --- a/scripts/proguard.pro +++ b/scripts/proguard.pro @@ -31,6 +31,11 @@ # need to keep mixin names -keep class baritone.launch.** { *; } +#try to keep usage of schematica in separate classes +-keep class baritone.utils.schematic.schematica.* +#proguard doesnt like it when it cant find our fake schematica classes +-dontwarn baritone.utils.schematic.schematica.* + # copy all necessary libraries into tempLibraries to build # The correct jar will be copied from the forgegradle cache based on the mapping type being compiled with diff --git a/src/api/java/baritone/api/process/IBuilderProcess.java b/src/api/java/baritone/api/process/IBuilderProcess.java index d9397786b..f73f0e746 100644 --- a/src/api/java/baritone/api/process/IBuilderProcess.java +++ b/src/api/java/baritone/api/process/IBuilderProcess.java @@ -54,6 +54,8 @@ public interface IBuilderProcess extends IBaritoneProcess { return build(schematicFile, file, origin); } + void buildOpenSchematic(); + void pause(); void resume(); diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 96d6ad2fc..463001501 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -295,6 +295,10 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener logDirect(success ? "Loaded" : "Unable to load"); return true; } + if (msg.startsWith("schematica")) { + baritone.getBuilderProcess().buildOpenSchematic(); + return true; + } if (msg.equals("come")) { customGoalProcess.setGoalAndPath(new GoalBlock(new BlockPos(Helper.mc.getRenderViewEntity()))); logDirect("Coming"); diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 52f21b769..5317c39aa 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -35,6 +35,7 @@ import baritone.utils.BlockStateInterface; import baritone.utils.PathingCommandContext; import baritone.utils.schematic.AirSchematic; import baritone.utils.schematic.Schematic; +import baritone.utils.schematic.schematica.SchematicaHelper; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import net.minecraft.block.BlockAir; import net.minecraft.block.BlockLiquid; @@ -106,6 +107,20 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil return true; } + @Override + public void buildOpenSchematic() { + if (SchematicaHelper.isSchematicaPresent()) { + Optional> schematic = SchematicaHelper.getOpenSchematic(); + if (schematic.isPresent()) { + this.build(schematic.get().getFirst().toString(), schematic.get().getFirst(), schematic.get().getSecond()); + } else { + logDirect("No schematic currently open"); + } + } else { + logDirect("Schematica is not present"); + } + } + public void clearArea(BlockPos corner1, BlockPos corner2) { BlockPos origin = new BlockPos(Math.min(corner1.getX(), corner2.getX()), Math.min(corner1.getY(), corner2.getY()), Math.min(corner1.getZ(), corner2.getZ())); int widthX = Math.abs(corner1.getX() - corner2.getX()) + 1; diff --git a/src/main/java/baritone/utils/schematic/schematica/SchematicAdapter.java b/src/main/java/baritone/utils/schematic/schematica/SchematicAdapter.java new file mode 100644 index 000000000..4e399348c --- /dev/null +++ b/src/main/java/baritone/utils/schematic/schematica/SchematicAdapter.java @@ -0,0 +1,54 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package baritone.utils.schematic.schematica; + +import baritone.api.utils.ISchematic; + +import com.github.lunatrius.schematica.client.world.SchematicWorld; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.math.BlockPos; + +// TODO: this only works for the default rotation +public final class SchematicAdapter implements ISchematic { + private final SchematicWorld schematic; + + + public SchematicAdapter(SchematicWorld schematicWorld) { + this.schematic = schematicWorld; + } + + @Override + public IBlockState desiredState(int x, int y, int z) { + return schematic.getSchematic().getBlockState(new BlockPos(x, y, z)); + } + + @Override + public int widthX() { + return schematic.getSchematic().getWidth(); + } + + @Override + public int heightY() { + return schematic.getSchematic().getHeight(); + } + + @Override + public int lengthZ() { + return schematic.getSchematic().getLength(); + } +} diff --git a/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java new file mode 100644 index 000000000..bf5d4678d --- /dev/null +++ b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java @@ -0,0 +1,50 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package baritone.utils.schematic.schematica; + +import baritone.api.utils.ISchematic; +import com.github.lunatrius.core.util.math.MBlockPos; +import com.github.lunatrius.schematica.Schematica; +import com.github.lunatrius.schematica.proxy.ClientProxy; +import net.minecraft.util.Tuple; +import net.minecraft.util.math.BlockPos; + +import java.util.Optional; + +public enum SchematicaHelper { + ; + + public static boolean isSchematicaPresent() { + try { + Class.forName(Schematica.class.getName()); + return true; + } catch (ClassNotFoundException ex) { + return false; + } + } + + public static Optional> getOpenSchematic() { + return Optional.ofNullable(ClientProxy.schematic) + .map(world -> { + MBlockPos poz = world.position; + return new Tuple<>(new SchematicAdapter(world), new BlockPos(poz.field_177962_a, poz.field_177960_b, poz.field_177961_c)); + }); + } + + private static void meme(Class clazz) throws ClassNotFoundException {} +} diff --git a/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java b/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java new file mode 100644 index 000000000..60cf6fae2 --- /dev/null +++ b/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java @@ -0,0 +1,30 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package com.github.lunatrius.core.util.math; + +import net.minecraft.util.math.BlockPos; + +public class MBlockPos extends BlockPos { + public int field_177962_a; // x + public int field_177960_b; // y + public int field_177961_c; // z + + private MBlockPos() { + super(6, 6, 6); + } +} diff --git a/src/schematica_api/java/com/github/lunatrius/schematica/Schematica.java b/src/schematica_api/java/com/github/lunatrius/schematica/Schematica.java new file mode 100644 index 000000000..7d786dbd4 --- /dev/null +++ b/src/schematica_api/java/com/github/lunatrius/schematica/Schematica.java @@ -0,0 +1,24 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package com.github.lunatrius.schematica; + +import com.github.lunatrius.schematica.proxy.CommonProxy; + +public class Schematica { + public static CommonProxy proxy; +} diff --git a/src/schematica_api/java/com/github/lunatrius/schematica/api/ISchematic.java b/src/schematica_api/java/com/github/lunatrius/schematica/api/ISchematic.java new file mode 100644 index 000000000..6430dbfcc --- /dev/null +++ b/src/schematica_api/java/com/github/lunatrius/schematica/api/ISchematic.java @@ -0,0 +1,31 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package com.github.lunatrius.schematica.api; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.math.BlockPos; + +public interface ISchematic { + IBlockState getBlockState(BlockPos var1); + + int getWidth(); + + int getHeight(); + + int getLength(); +} diff --git a/src/schematica_api/java/com/github/lunatrius/schematica/client/world/SchematicWorld.java b/src/schematica_api/java/com/github/lunatrius/schematica/client/world/SchematicWorld.java new file mode 100644 index 000000000..fc4b89f9a --- /dev/null +++ b/src/schematica_api/java/com/github/lunatrius/schematica/client/world/SchematicWorld.java @@ -0,0 +1,32 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package com.github.lunatrius.schematica.client.world; + +import com.github.lunatrius.core.util.math.MBlockPos; +import com.github.lunatrius.schematica.api.ISchematic; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.math.BlockPos; + +public class SchematicWorld { + private ISchematic schematic; + public final MBlockPos position = (MBlockPos)(Object)"cringe"; + + public ISchematic getSchematic() { + throw new LinkageError("LOL"); + } +} diff --git a/src/schematica_api/java/com/github/lunatrius/schematica/proxy/ClientProxy.java b/src/schematica_api/java/com/github/lunatrius/schematica/proxy/ClientProxy.java new file mode 100644 index 000000000..e58e76b56 --- /dev/null +++ b/src/schematica_api/java/com/github/lunatrius/schematica/proxy/ClientProxy.java @@ -0,0 +1,29 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package com.github.lunatrius.schematica.proxy; + +import com.github.lunatrius.schematica.client.world.SchematicWorld; +import net.minecraft.util.EnumFacing; + +public class ClientProxy extends CommonProxy { + public static SchematicWorld schematic; + + public static EnumFacing orientation; + public static EnumFacing axisFlip; + public static EnumFacing axisRotation; +} diff --git a/src/schematica_api/java/com/github/lunatrius/schematica/proxy/CommonProxy.java b/src/schematica_api/java/com/github/lunatrius/schematica/proxy/CommonProxy.java new file mode 100644 index 000000000..eb3c034e8 --- /dev/null +++ b/src/schematica_api/java/com/github/lunatrius/schematica/proxy/CommonProxy.java @@ -0,0 +1,20 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package com.github.lunatrius.schematica.proxy; + +public abstract class CommonProxy {} From 074ec333cf49a9382e7e8141aeb8717abc18243d Mon Sep 17 00:00:00 2001 From: Babbaj Date: Sun, 21 Jul 2019 21:57:59 -0400 Subject: [PATCH 65/75] clean up a bit --- scripts/proguard.pro | 4 ++-- .../baritone/utils/schematic/schematica/SchematicAdapter.java | 2 -- .../baritone/utils/schematic/schematica/SchematicaHelper.java | 1 - .../lunatrius/schematica/client/world/SchematicWorld.java | 3 --- 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/scripts/proguard.pro b/scripts/proguard.pro index 2e10986df..4ac0f7233 100644 --- a/scripts/proguard.pro +++ b/scripts/proguard.pro @@ -32,9 +32,9 @@ -keep class baritone.launch.** { *; } #try to keep usage of schematica in separate classes --keep class baritone.utils.schematic.schematica.* +-keep class baritone.utils.schematic.schematica.** #proguard doesnt like it when it cant find our fake schematica classes --dontwarn baritone.utils.schematic.schematica.* +-dontwarn baritone.utils.schematic.schematica.** # copy all necessary libraries into tempLibraries to build diff --git a/src/main/java/baritone/utils/schematic/schematica/SchematicAdapter.java b/src/main/java/baritone/utils/schematic/schematica/SchematicAdapter.java index 4e399348c..fd0ace8ca 100644 --- a/src/main/java/baritone/utils/schematic/schematica/SchematicAdapter.java +++ b/src/main/java/baritone/utils/schematic/schematica/SchematicAdapter.java @@ -23,11 +23,9 @@ import com.github.lunatrius.schematica.client.world.SchematicWorld; import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; -// TODO: this only works for the default rotation public final class SchematicAdapter implements ISchematic { private final SchematicWorld schematic; - public SchematicAdapter(SchematicWorld schematicWorld) { this.schematic = schematicWorld; } diff --git a/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java index bf5d4678d..e929d0811 100644 --- a/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java +++ b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java @@ -46,5 +46,4 @@ public enum SchematicaHelper { }); } - private static void meme(Class clazz) throws ClassNotFoundException {} } diff --git a/src/schematica_api/java/com/github/lunatrius/schematica/client/world/SchematicWorld.java b/src/schematica_api/java/com/github/lunatrius/schematica/client/world/SchematicWorld.java index fc4b89f9a..80c1b2a21 100644 --- a/src/schematica_api/java/com/github/lunatrius/schematica/client/world/SchematicWorld.java +++ b/src/schematica_api/java/com/github/lunatrius/schematica/client/world/SchematicWorld.java @@ -19,11 +19,8 @@ package com.github.lunatrius.schematica.client.world; import com.github.lunatrius.core.util.math.MBlockPos; import com.github.lunatrius.schematica.api.ISchematic; -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.math.BlockPos; public class SchematicWorld { - private ISchematic schematic; public final MBlockPos position = (MBlockPos)(Object)"cringe"; public ISchematic getSchematic() { From 8bf977060e1c379b130d02e08b59f5d6bf4147bf Mon Sep 17 00:00:00 2001 From: Babbaj Date: Sun, 21 Jul 2019 22:06:36 -0400 Subject: [PATCH 66/75] dont need the fields --- .../baritone/utils/schematic/schematica/SchematicaHelper.java | 2 +- .../java/com/github/lunatrius/core/util/math/MBlockPos.java | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java index e929d0811..9120c5ac6 100644 --- a/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java +++ b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java @@ -42,7 +42,7 @@ public enum SchematicaHelper { return Optional.ofNullable(ClientProxy.schematic) .map(world -> { MBlockPos poz = world.position; - return new Tuple<>(new SchematicAdapter(world), new BlockPos(poz.field_177962_a, poz.field_177960_b, poz.field_177961_c)); + return new Tuple<>(new SchematicAdapter(world), new BlockPos(poz.getX(), poz.getY(), poz.getZ())); }); } diff --git a/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java b/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java index 60cf6fae2..338e3be47 100644 --- a/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java +++ b/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java @@ -20,10 +20,6 @@ package com.github.lunatrius.core.util.math; import net.minecraft.util.math.BlockPos; public class MBlockPos extends BlockPos { - public int field_177962_a; // x - public int field_177960_b; // y - public int field_177961_c; // z - private MBlockPos() { super(6, 6, 6); } From 21e9c0b7c11f158e4f47d474defd7f939a9110af Mon Sep 17 00:00:00 2001 From: Babbaj Date: Sun, 21 Jul 2019 22:17:21 -0400 Subject: [PATCH 67/75] add get functions --- .../lunatrius/core/util/math/MBlockPos.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java b/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java index 338e3be47..80c296cc1 100644 --- a/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java +++ b/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java @@ -23,4 +23,19 @@ public class MBlockPos extends BlockPos { private MBlockPos() { super(6, 6, 6); } + + @Override + public int getX() { + throw new LinkageError("LOL"); + } + + @Override + public int getY() { + throw new LinkageError("LOL"); + } + + @Override + public int getZ() { + throw new LinkageError("LOL"); + } } From fe54372a5362a351155a3ad3193573aac37804a0 Mon Sep 17 00:00:00 2001 From: Babbaj Date: Sun, 21 Jul 2019 22:33:22 -0400 Subject: [PATCH 68/75] resolve the issue --- .../java/com/github/lunatrius/core/util/math/MBlockPos.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java b/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java index 80c296cc1..280b38a6a 100644 --- a/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java +++ b/src/schematica_api/java/com/github/lunatrius/core/util/math/MBlockPos.java @@ -20,7 +20,7 @@ package com.github.lunatrius.core.util.math; import net.minecraft.util.math.BlockPos; public class MBlockPos extends BlockPos { - private MBlockPos() { + MBlockPos() { super(6, 6, 6); } From 6b9737eb3fcfa4f2adc0e12b16f75324aac0af14 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 21 Jul 2019 22:04:15 -0700 Subject: [PATCH 69/75] fix double jump on paused overshot sprint ascend --- .../baritone/pathing/movement/movements/MovementAscend.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index 24fe2285e..cbc8cdd86 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -168,7 +168,7 @@ public class MovementAscend extends Movement { return state; } - if (ctx.playerFeet().equals(dest)) { + if (ctx.playerFeet().equals(dest) || ctx.playerFeet().equals(dest.add(getDirection().down()))) { return state.setStatus(MovementStatus.SUCCESS); } From 61147536e59f6689e3e159b7c0bbcc5d7d1add15 Mon Sep 17 00:00:00 2001 From: Babbaj Date: Mon, 22 Jul 2019 16:51:09 -0400 Subject: [PATCH 70/75] ok --- .../utils/schematic/schematica/SchematicaHelper.java | 6 +----- .../com/github/lunatrius/schematica/proxy/ClientProxy.java | 5 ----- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java index 9120c5ac6..f7df0a4f7 100644 --- a/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java +++ b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java @@ -18,7 +18,6 @@ package baritone.utils.schematic.schematica; import baritone.api.utils.ISchematic; -import com.github.lunatrius.core.util.math.MBlockPos; import com.github.lunatrius.schematica.Schematica; import com.github.lunatrius.schematica.proxy.ClientProxy; import net.minecraft.util.Tuple; @@ -40,10 +39,7 @@ public enum SchematicaHelper { public static Optional> getOpenSchematic() { return Optional.ofNullable(ClientProxy.schematic) - .map(world -> { - MBlockPos poz = world.position; - return new Tuple<>(new SchematicAdapter(world), new BlockPos(poz.getX(), poz.getY(), poz.getZ())); - }); + .map(world -> new Tuple<>(new SchematicAdapter(world), world.position)); } } diff --git a/src/schematica_api/java/com/github/lunatrius/schematica/proxy/ClientProxy.java b/src/schematica_api/java/com/github/lunatrius/schematica/proxy/ClientProxy.java index e58e76b56..191d01109 100644 --- a/src/schematica_api/java/com/github/lunatrius/schematica/proxy/ClientProxy.java +++ b/src/schematica_api/java/com/github/lunatrius/schematica/proxy/ClientProxy.java @@ -18,12 +18,7 @@ package com.github.lunatrius.schematica.proxy; import com.github.lunatrius.schematica.client.world.SchematicWorld; -import net.minecraft.util.EnumFacing; public class ClientProxy extends CommonProxy { public static SchematicWorld schematic; - - public static EnumFacing orientation; - public static EnumFacing axisFlip; - public static EnumFacing axisRotation; } From 4338e34734323d203bba13cd0f5edcede350f87d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 22 Jul 2019 23:37:43 -0700 Subject: [PATCH 71/75] while this is cool, nothing will ever conceivably use it --- .../utils/pathing/SegmentedCalculator.java | 110 ------------------ 1 file changed, 110 deletions(-) delete mode 100644 src/main/java/baritone/utils/pathing/SegmentedCalculator.java diff --git a/src/main/java/baritone/utils/pathing/SegmentedCalculator.java b/src/main/java/baritone/utils/pathing/SegmentedCalculator.java deleted file mode 100644 index c1753a8b2..000000000 --- a/src/main/java/baritone/utils/pathing/SegmentedCalculator.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * This file is part of Baritone. - * - * Baritone is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Baritone is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Baritone. If not, see . - */ - -package baritone.utils.pathing; - -import baritone.Baritone; -import baritone.api.pathing.calc.IPath; -import baritone.api.pathing.goals.Goal; -import baritone.api.utils.BetterBlockPos; -import baritone.api.utils.PathCalculationResult; -import baritone.cache.CachedWorld; -import baritone.pathing.calc.AStarPathFinder; -import baritone.pathing.calc.AbstractNodeCostSearch; -import baritone.pathing.movement.CalculationContext; -import baritone.pathing.path.SplicedPath; -import net.minecraft.util.EnumFacing; - -import java.util.Optional; -import java.util.function.Consumer; - -/** - * Calculate and splice many path segments to reach a goal - * - * @author leijurv - */ -public class SegmentedCalculator { - private final BetterBlockPos start; - private final Goal goal; - private final CalculationContext context; - - private SegmentedCalculator(BetterBlockPos start, Goal goal, CalculationContext context) { - this.start = start; - this.goal = goal; - this.context = context; - } - - private Optional doCalc() { - Optional soFar = Optional.empty(); - while (true) { - PathCalculationResult result = segment(soFar.orElse(null)); - switch (result.getType()) { - case SUCCESS_SEGMENT: - case SUCCESS_TO_GOAL: - break; - case FAILURE: // if path calculation failed, we're done - case EXCEPTION: // if path calculation threw an exception, we're done - return soFar; - default: // CANCELLATION and null should not be possible, nothing else has access to this, so it can't have been canceled - throw new IllegalStateException(); - } - IPath segment = result.getPath().orElseThrow(IllegalStateException::new); // path calculation result type is SUCCESS_SEGMENT, so the path must be present - IPath combined = soFar.map(previous -> (IPath) SplicedPath.trySplice(previous, segment, true).orElseThrow(IllegalStateException::new)).orElse(segment); - loadAdjacent(combined.getDest().getX(), combined.getDest().getZ()); - soFar = Optional.of(combined); - if (result.getType() == PathCalculationResult.Type.SUCCESS_TO_GOAL) { - return soFar; - } - } - } - - private void loadAdjacent(int blockX, int blockZ) { - BetterBlockPos bp = new BetterBlockPos(blockX, 64, blockZ); - CachedWorld cached = (CachedWorld) context.getBaritone().getPlayerContext().worldData().getCachedWorld(); - for (int i = 0; i < 4; i++) { - // pathing thread is not allowed to load new cached regions from disk - // it checks if every chunk is loaded before getting blocks from it - // so you see path segments ending at multiples of 512 (plus or minus one) on either x or z axis - // this loads every adjacent chunk to the segment end, so it can continue into the next cached region - BetterBlockPos toLoad = bp.offset(EnumFacing.byHorizontalIndex(i), 16); - cached.tryLoadFromDisk(toLoad.x >> 9, toLoad.z >> 9); - } - } - - private PathCalculationResult segment(IPath previous) { - BetterBlockPos segmentStart = previous != null ? previous.getDest() : start; - AbstractNodeCostSearch search = new AStarPathFinder(segmentStart.x, segmentStart.y, segmentStart.z, goal, new Favoring(previous, context), context); // this is on another thread, so cannot include mob avoidances. - return search.calculate(Baritone.settings().primaryTimeoutMS.value, Baritone.settings().failureTimeoutMS.value); // use normal time settings, not the plan ahead settings, so as to not overwhelm the computer - } - - public static void calculateSegmentsThreaded(BetterBlockPos start, Goal goal, CalculationContext context, Consumer onCompletion, Runnable onFailure) { - Baritone.getExecutor().execute(() -> { - Optional result; - try { - result = new SegmentedCalculator(start, goal, context).doCalc(); - } catch (Exception ex) { - ex.printStackTrace(); - result = Optional.empty(); - } - if (result.isPresent()) { - onCompletion.accept(result.get()); - } else { - onFailure.run(); - } - }); - } -} From 784bc52d6df3dc7c1e494f8b34d6e4e5750e72b3 Mon Sep 17 00:00:00 2001 From: Babbaj Date: Tue, 23 Jul 2019 02:46:53 -0400 Subject: [PATCH 72/75] add to usage.md --- USAGE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/USAGE.md b/USAGE.md index f628d542d..916adc72e 100644 --- a/USAGE.md +++ b/USAGE.md @@ -28,6 +28,7 @@ Some common examples: - `follow playerName` to follow a player. `follow` to follow the entity you're looking at (only works if it hitting range). `followplayers` to follow any players in range (combine with Kill Aura for a fun time). - `save waypointName` to save a waypoint. `goto waypointName` to go to it. - `build` to build a schematic. `build blah` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420). +- 'schematica' to build the schematic that is currently open in schematica - `tunnel` to dig just straight ahead and make a tunnel - `farm` to automatically harvest, replant, or bone meal crops - `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120). From 821e73c1d34b44c1e801fb34ebf502db7ae68060 Mon Sep 17 00:00:00 2001 From: Babbaj Date: Tue, 23 Jul 2019 02:48:40 -0400 Subject: [PATCH 73/75] fix usage.md --- USAGE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/USAGE.md b/USAGE.md index 916adc72e..865670b63 100644 --- a/USAGE.md +++ b/USAGE.md @@ -28,7 +28,7 @@ Some common examples: - `follow playerName` to follow a player. `follow` to follow the entity you're looking at (only works if it hitting range). `followplayers` to follow any players in range (combine with Kill Aura for a fun time). - `save waypointName` to save a waypoint. `goto waypointName` to go to it. - `build` to build a schematic. `build blah` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420). -- 'schematica' to build the schematic that is currently open in schematica +- `schematica` to build the schematic that is currently open in schematica - `tunnel` to dig just straight ahead and make a tunnel - `farm` to automatically harvest, replant, or bone meal crops - `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120). From 7000b6cda2399cac853f1cf68896d88d8c1d2c74 Mon Sep 17 00:00:00 2001 From: Babbaj Date: Tue, 23 Jul 2019 02:56:24 -0400 Subject: [PATCH 74/75] fix crash --- .../baritone/utils/schematic/schematica/SchematicaHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java index f7df0a4f7..63b85670b 100644 --- a/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java +++ b/src/main/java/baritone/utils/schematic/schematica/SchematicaHelper.java @@ -32,7 +32,7 @@ public enum SchematicaHelper { try { Class.forName(Schematica.class.getName()); return true; - } catch (ClassNotFoundException ex) { + } catch (ClassNotFoundException | NoClassDefFoundError ex) { return false; } } From 0e51a731496474b73fe772936c3041c38e91d19c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 23 Jul 2019 11:53:21 -0700 Subject: [PATCH 75/75] instanceof BlockLiquid checks this --- src/main/java/baritone/pathing/movement/MovementHelper.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 97a768abe..520baa81c 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -254,7 +254,6 @@ public interface MovementHelper extends ActionCosts, Helper { static boolean avoidWalkingInto(Block block) { return block instanceof BlockLiquid - || block instanceof BlockDynamicLiquid || block == Blocks.MAGMA || block == Blocks.CACTUS || block == Blocks.FIRE