From 82629090639ee9011126b9055b79bf420de4c35f Mon Sep 17 00:00:00 2001 From: kuthy Date: Fri, 3 Jul 2020 15:36:44 +0200 Subject: [PATCH 01/52] Fixing crash after clicking into the air --- src/main/java/baritone/utils/GuiClick.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/utils/GuiClick.java b/src/main/java/baritone/utils/GuiClick.java index 4f89100dc..2f77714cf 100644 --- a/src/main/java/baritone/utils/GuiClick.java +++ b/src/main/java/baritone/utils/GuiClick.java @@ -93,10 +93,16 @@ public class GuiClick extends GuiScreen { Helper.HELPER.logDirect(component); clickStart = null; } else { - BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalTwoBlocks(currentMouseOver)); + if(currentMouseOver != null)//Catch this, or else a click into void will result in a crash + BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalBlock(currentMouseOver)); + else + Helper.HELPER.logDirect("Sorry, I can't go to nothing"); } } else if (mouseButton == 1) { - BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalBlock(currentMouseOver.up())); + if(currentMouseOver != null) + BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalBlock(currentMouseOver.up())); + else + Helper.HELPER.logDirect("Sorry, I can't go to nothing"); } clickStart = null; } From 0055a059f71be48d68d6ad92aaad1712dee3be7a Mon Sep 17 00:00:00 2001 From: kuthy Date: Fri, 3 Jul 2020 16:52:03 +0200 Subject: [PATCH 02/52] Formated Code --- src/main/java/baritone/utils/GuiClick.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/utils/GuiClick.java b/src/main/java/baritone/utils/GuiClick.java index 2f77714cf..00be0635a 100644 --- a/src/main/java/baritone/utils/GuiClick.java +++ b/src/main/java/baritone/utils/GuiClick.java @@ -20,7 +20,6 @@ package baritone.utils; import baritone.Baritone; import baritone.api.BaritoneAPI; import baritone.api.pathing.goals.GoalBlock; -import baritone.api.pathing.goals.GoalTwoBlocks; import baritone.api.utils.BetterBlockPos; import baritone.api.utils.Helper; import net.minecraft.client.gui.GuiScreen; @@ -43,8 +42,8 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.util.Collections; -import static org.lwjgl.opengl.GL11.*; import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX; +import static org.lwjgl.opengl.GL11.*; public class GuiClick extends GuiScreen { @@ -93,13 +92,13 @@ public class GuiClick extends GuiScreen { Helper.HELPER.logDirect(component); clickStart = null; } else { - if(currentMouseOver != null)//Catch this, or else a click into void will result in a crash + if (currentMouseOver != null)//Catch this, or else a click into void will result in a crash BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalBlock(currentMouseOver)); else Helper.HELPER.logDirect("Sorry, I can't go to nothing"); } } else if (mouseButton == 1) { - if(currentMouseOver != null) + if (currentMouseOver != null) BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalBlock(currentMouseOver.up())); else Helper.HELPER.logDirect("Sorry, I can't go to nothing"); From 523f13c430404d2f2910f6ecd0dca7595d9e969f Mon Sep 17 00:00:00 2001 From: RealIndrit <32206640+RealIndrit@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:36:10 +0200 Subject: [PATCH 03/52] =?UTF-8?q?=F0=9F=94=A5=20Get=20yeeted=20unused=20co?= =?UTF-8?q?de?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed an unused function that can't be used anyways, because RayTraceUtils cant detect entity hit... --- src/api/java/baritone/api/utils/IPlayerContext.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/api/java/baritone/api/utils/IPlayerContext.java b/src/api/java/baritone/api/utils/IPlayerContext.java index 8ce3271b2..f746110e5 100644 --- a/src/api/java/baritone/api/utils/IPlayerContext.java +++ b/src/api/java/baritone/api/utils/IPlayerContext.java @@ -97,17 +97,4 @@ public interface IPlayerContext { default boolean isLookingAt(BlockPos pos) { return getSelectedBlock().equals(Optional.of(pos)); } - - /** - * Returns the entity that the crosshair is currently placed over. Updated once per tick. - * - * @return The entity - */ - default Optional getSelectedEntity() { - RayTraceResult result = objectMouseOver(); - if (result != null && result.typeOfHit == RayTraceResult.Type.ENTITY) { - return Optional.of(result.entityHit); - } - return Optional.empty(); - } } From 7f9704592e1aa4765351d1c17637fef840867fa5 Mon Sep 17 00:00:00 2001 From: kuthy Date: Tue, 18 Aug 2020 15:40:12 +0200 Subject: [PATCH 04/52] Made catch function wide --- src/main/java/baritone/utils/GuiClick.java | 40 ++++++++++------------ 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/main/java/baritone/utils/GuiClick.java b/src/main/java/baritone/utils/GuiClick.java index 00be0635a..1716d74b6 100644 --- a/src/main/java/baritone/utils/GuiClick.java +++ b/src/main/java/baritone/utils/GuiClick.java @@ -78,30 +78,26 @@ public class GuiClick extends GuiScreen { @Override protected void mouseReleased(int mouseX, int mouseY, int mouseButton) { - if (mouseButton == 0) { - if (clickStart != null && !clickStart.equals(currentMouseOver)) { - BaritoneAPI.getProvider().getPrimaryBaritone().getSelectionManager().removeAllSelections(); - BaritoneAPI.getProvider().getPrimaryBaritone().getSelectionManager().addSelection(BetterBlockPos.from(clickStart), BetterBlockPos.from(currentMouseOver)); - ITextComponent component = new TextComponentString("Selection made! For usage: " + Baritone.settings().prefix.value + "help sel"); - component.getStyle() - .setColor(TextFormatting.WHITE) - .setClickEvent(new ClickEvent( - ClickEvent.Action.RUN_COMMAND, - FORCE_COMMAND_PREFIX + "help sel" - )); - Helper.HELPER.logDirect(component); - clickStart = null; - } else { - if (currentMouseOver != null)//Catch this, or else a click into void will result in a crash + if (currentMouseOver != null) { //Catch this, or else a click into void will result in a crash + if (mouseButton == 0) { + if (clickStart != null && !clickStart.equals(currentMouseOver)) { + BaritoneAPI.getProvider().getPrimaryBaritone().getSelectionManager().removeAllSelections(); + BaritoneAPI.getProvider().getPrimaryBaritone().getSelectionManager().addSelection(BetterBlockPos.from(clickStart), BetterBlockPos.from(currentMouseOver)); + ITextComponent component = new TextComponentString("Selection made! For usage: " + Baritone.settings().prefix.value + "help sel"); + component.getStyle() + .setColor(TextFormatting.WHITE) + .setClickEvent(new ClickEvent( + ClickEvent.Action.RUN_COMMAND, + FORCE_COMMAND_PREFIX + "help sel" + )); + Helper.HELPER.logDirect(component); + clickStart = null; + } else { BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalBlock(currentMouseOver)); - else - Helper.HELPER.logDirect("Sorry, I can't go to nothing"); - } - } else if (mouseButton == 1) { - if (currentMouseOver != null) + } + } else if (mouseButton == 1) { BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalBlock(currentMouseOver.up())); - else - Helper.HELPER.logDirect("Sorry, I can't go to nothing"); + } } clickStart = null; } From 5f686c1c12e1abfc071fa3bda028da7a9e527183 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Thu, 20 Aug 2020 22:40:16 +0200 Subject: [PATCH 05/52] improve isSafeToCancel in MovementDiagonal even more It did not return true early enough for backfill while cornering over air --- .../movement/movements/MovementDiagonal.java | 34 ++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index 2631af840..1ea0591ce 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -31,6 +31,7 @@ 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.client.entity.EntityPlayerSP; import net.minecraft.init.Blocks; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; @@ -58,11 +59,34 @@ public class MovementDiagonal extends Movement { @Override protected boolean safeToCancel(MovementState state) { - return ctx.playerFeet().equals(src) || (( - MovementHelper.canWalkOn(ctx, new BlockPos(src.x, src.y - 1, dest.z)) - ) && - MovementHelper.canWalkOn(ctx, new BlockPos(dest.x, src.y - 1, src.z))); - } + //too simple. backfill does not work after cornering with this + //return MovementHelper.canWalkOn(ctx, ctx.playerFeet().down()); + EntityPlayerSP player = ctx.player(); + double offset = 0.25; + double x = player.posX; + double y = player.posY - 1; + double z = player.posZ; + //standard + if (ctx.playerFeet().equals(src)){ + return true; + } + //both corners are walkable + if (MovementHelper.canWalkOn(ctx, new BlockPos(src.x, src.y - 1, dest.z)) + && MovementHelper.canWalkOn(ctx, new BlockPos(dest.x, src.y - 1, src.z))){ + return true; + } + //we are in a likely unwalkable corner, check for a supporting block + if (ctx.playerFeet().equals(new BetterBlockPos(src.x, src.y, dest.z)) + || ctx.playerFeet().equals(new BetterBlockPos(dest.x, src.y, src.z))){ + if (MovementHelper.canWalkOn(ctx, new BetterBlockPos(x + offset, y, z + offset)) + || MovementHelper.canWalkOn(ctx, new BetterBlockPos(x + offset, y, z - offset)) + || MovementHelper.canWalkOn(ctx, new BetterBlockPos(x - offset, y, z + offset)) + || MovementHelper.canWalkOn(ctx, new BetterBlockPos(x - offset, y, z - offset))){ + return true; + } + } + return false; + } @Override public double calculateCost(CalculationContext context) { From b7d1ba1fa5187e096356c90c43c780b4481aa4d0 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Thu, 20 Aug 2020 23:11:55 +0200 Subject: [PATCH 06/52] Make Codacity happy --- .../pathing/movement/movements/MovementDiagonal.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index 1ea0591ce..eaaef0a83 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -78,12 +78,11 @@ public class MovementDiagonal extends Movement { //we are in a likely unwalkable corner, check for a supporting block if (ctx.playerFeet().equals(new BetterBlockPos(src.x, src.y, dest.z)) || ctx.playerFeet().equals(new BetterBlockPos(dest.x, src.y, src.z))){ - if (MovementHelper.canWalkOn(ctx, new BetterBlockPos(x + offset, y, z + offset)) + && (MovementHelper.canWalkOn(ctx, new BetterBlockPos(x + offset, y, z + offset)) || MovementHelper.canWalkOn(ctx, new BetterBlockPos(x + offset, y, z - offset)) || MovementHelper.canWalkOn(ctx, new BetterBlockPos(x - offset, y, z + offset)) - || MovementHelper.canWalkOn(ctx, new BetterBlockPos(x - offset, y, z - offset))){ + || MovementHelper.canWalkOn(ctx, new BetterBlockPos(x - offset, y, z - offset))) return true; - } } return false; } From ea35a3478f8b87a10bd440f5638961fdd455d6c5 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Thu, 20 Aug 2020 23:16:59 +0200 Subject: [PATCH 07/52] Codacity again for the same and syntax dab --- .../baritone/pathing/movement/movements/MovementDiagonal.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index eaaef0a83..3fc67e8f1 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -77,11 +77,11 @@ public class MovementDiagonal extends Movement { } //we are in a likely unwalkable corner, check for a supporting block if (ctx.playerFeet().equals(new BetterBlockPos(src.x, src.y, dest.z)) - || ctx.playerFeet().equals(new BetterBlockPos(dest.x, src.y, src.z))){ + || ctx.playerFeet().equals(new BetterBlockPos(dest.x, src.y, src.z))) && (MovementHelper.canWalkOn(ctx, new BetterBlockPos(x + offset, y, z + offset)) || MovementHelper.canWalkOn(ctx, new BetterBlockPos(x + offset, y, z - offset)) || MovementHelper.canWalkOn(ctx, new BetterBlockPos(x - offset, y, z + offset)) - || MovementHelper.canWalkOn(ctx, new BetterBlockPos(x - offset, y, z - offset))) + || MovementHelper.canWalkOn(ctx, new BetterBlockPos(x - offset, y, z - offset))){ return true; } return false; From 3c691bb498395e941830b4eac381ef00abf281eb Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Thu, 20 Aug 2020 23:33:47 +0200 Subject: [PATCH 08/52] But now it's working --- .../baritone/pathing/movement/movements/MovementDiagonal.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index 3fc67e8f1..2e026b877 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -76,12 +76,12 @@ public class MovementDiagonal extends Movement { return true; } //we are in a likely unwalkable corner, check for a supporting block - if (ctx.playerFeet().equals(new BetterBlockPos(src.x, src.y, dest.z)) + if ((ctx.playerFeet().equals(new BetterBlockPos(src.x, src.y, dest.z)) || ctx.playerFeet().equals(new BetterBlockPos(dest.x, src.y, src.z))) && (MovementHelper.canWalkOn(ctx, new BetterBlockPos(x + offset, y, z + offset)) || MovementHelper.canWalkOn(ctx, new BetterBlockPos(x + offset, y, z - offset)) || MovementHelper.canWalkOn(ctx, new BetterBlockPos(x - offset, y, z + offset)) - || MovementHelper.canWalkOn(ctx, new BetterBlockPos(x - offset, y, z - offset))){ + || MovementHelper.canWalkOn(ctx, new BetterBlockPos(x - offset, y, z - offset)))){ return true; } return false; From ed91e2aa7bdb73ddd1d88385aa28b7b58af386d6 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Mon, 24 Aug 2020 22:19:28 +0200 Subject: [PATCH 09/52] Fix "#entity follow " under Forge One of the Forge patches removes EntityList.REGISTRY and provides the getClass method as a replacement. The fix is based on a similar one I found in WorldDownloader Closes #1376 (and duplicates: #1777 and #1815) --- .../api/command/datatypes/EntityClassById.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/command/datatypes/EntityClassById.java b/src/api/java/baritone/api/command/datatypes/EntityClassById.java index aed7cdf41..becc649c1 100644 --- a/src/api/java/baritone/api/command/datatypes/EntityClassById.java +++ b/src/api/java/baritone/api/command/datatypes/EntityClassById.java @@ -32,7 +32,19 @@ public enum EntityClassById implements IDatatypeFor> { public Class get(IDatatypeContext ctx) throws CommandException { ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString()); Class entity; - if ((entity = EntityList.REGISTRY.getObject(id)) == null) { + try { + entity = EntityList.REGISTRY.getObject(id); + } catch(NoSuchFieldError e) { + // Forge removes EntityList.REGISTRY field and provides the getClass method as a replacement + // See https://github.com/MinecraftForge/MinecraftForge/blob/1.12.x/patches/minecraft/net/minecraft/entity/EntityList.java.patch + try { + entity = (Class) EntityList.class.getMethod("getClass", ResourceLocation.class).invoke(null, id); + } catch (Exception ex) { + throw new RuntimeException("EntityList.REGISTRY does not exist and failed to call the Forge-replacement method", ex); + } + } + + if (entity == null) { throw new IllegalArgumentException("no entity found by that id"); } return entity; From 9636e69a6b34778f9ee5c73bef961f9409bc2542 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Mon, 24 Aug 2020 23:06:19 +0200 Subject: [PATCH 10/52] slightly better condition --- .../pathing/movement/movements/MovementDiagonal.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index 2e026b877..b5ea19a9c 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -76,15 +76,14 @@ public class MovementDiagonal extends Movement { return true; } //we are in a likely unwalkable corner, check for a supporting block - if ((ctx.playerFeet().equals(new BetterBlockPos(src.x, src.y, dest.z)) - || ctx.playerFeet().equals(new BetterBlockPos(dest.x, src.y, src.z))) - && (MovementHelper.canWalkOn(ctx, new BetterBlockPos(x + offset, y, z + offset)) + if (ctx.playerFeet().equals(new BetterBlockPos(src.x, src.y, dest.z)) + || ctx.playerFeet().equals(new BetterBlockPos(dest.x, src.y, src.z))){ + return (MovementHelper.canWalkOn(ctx, new BetterBlockPos(x + offset, y, z + offset)) || MovementHelper.canWalkOn(ctx, new BetterBlockPos(x + offset, y, z - offset)) || MovementHelper.canWalkOn(ctx, new BetterBlockPos(x - offset, y, z + offset)) - || MovementHelper.canWalkOn(ctx, new BetterBlockPos(x - offset, y, z - offset)))){ - return true; + || MovementHelper.canWalkOn(ctx, new BetterBlockPos(x - offset, y, z - offset))); } - return false; + return true; } @Override From d7088c8eea51d4abbdf39c07e7eae7e2702848ec Mon Sep 17 00:00:00 2001 From: scorbett123 Date: Mon, 31 Aug 2020 18:48:46 +0100 Subject: [PATCH 11/52] fix typo in java-doc x2 Signed-off-by: scorbett123 --- src/api/java/baritone/api/Settings.java | 2 +- src/api/java/baritone/api/process/IBaritoneProcess.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 6ef5e5d12..46e3fbf5c 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -64,7 +64,7 @@ public final class Settings { /** * Disable baritone's auto-tool at runtime, but still assume that another mod will provide auto tool functionality *

- * Specifically, path calculation will still assume that an auto tool wil run at execution time, even though + * Specifically, path calculation will still assume that an auto tool will run at execution time, even though * Baritone itself will not do that. */ public final Setting assumeExternalAutoTool = new Setting<>(false); diff --git a/src/api/java/baritone/api/process/IBaritoneProcess.java b/src/api/java/baritone/api/process/IBaritoneProcess.java index 726260d82..9c62d203d 100644 --- a/src/api/java/baritone/api/process/IBaritoneProcess.java +++ b/src/api/java/baritone/api/process/IBaritoneProcess.java @@ -75,7 +75,7 @@ public interface IBaritoneProcess { * to start eating this tick. {@code PauseForAutoEatProcess} should only actually right click once onTick is called with * {@code isSafeToCancel} true though. * - * @return Whethor or not if this control is temporary + * @return Whether or not if this control is temporary */ boolean isTemporary(); From bcbfca100fd3ae98c9fb3ae3a52c7a1748d8a05c Mon Sep 17 00:00:00 2001 From: scorbett123 Date: Fri, 4 Sep 2020 10:43:05 +0100 Subject: [PATCH 12/52] add mineOnlyExposedOres setting Signed-off-by: scorbett123 --- src/api/java/baritone/api/Settings.java | 5 +++++ src/main/java/baritone/process/MineProcess.java | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 6ef5e5d12..ba62a1e85 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -726,6 +726,11 @@ public final class Settings { */ public final Setting maxCachedWorldScanCount = new Setting<>(10); + /** + * This will only allow baritone to mine exposed ores, can be used to stop ore obfuscators on servers that use them. + */ + public final Setting allowOnlyExposedOres = new Setting<>(false); + /** * When GetToBlock doesn't know any locations for the desired block, explore randomly instead of giving up. */ diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index 6e8ba245b..01d78b1ef 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -40,6 +40,7 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; import java.util.*; import java.util.stream.Collectors; @@ -409,6 +410,8 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro // remove any that are implausible to mine (encased in bedrock, or touching lava) .filter(pos -> MineProcess.plausibleToBreak(ctx, pos)) + .filter(pos -> isNextToAir(ctx, pos)) + .filter(pos -> !blacklist.contains(pos)) .sorted(Comparator.comparingDouble(ctx.getBaritone().getPlayerContext().player()::getDistanceSq)) @@ -420,6 +423,19 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro return locs; } + public static boolean isNextToAir(CalculationContext ctx, BlockPos pos) { + if (!Baritone.settings().allowOnlyExposedOres.value) { + return true; + } + return (ctx.bsi.get0(pos.down()).getBlock() == Blocks.AIR || + ctx.bsi.get0(pos.up()).getBlock() == Blocks.AIR + || ctx.bsi.get0(pos.north()).getBlock() == Blocks.AIR || + ctx.bsi.get0(pos.south()).getBlock() == Blocks.AIR || + ctx.bsi.get0(pos.east()).getBlock() == Blocks.AIR + || ctx.bsi.get0(pos.west()).getBlock() == Blocks.AIR); + } + + public static boolean plausibleToBreak(CalculationContext ctx, BlockPos pos) { if (MovementHelper.getMiningDurationTicks(ctx, pos.getX(), pos.getY(), pos.getZ(), ctx.bsi.get0(pos), true) >= COST_INF) { return false; From 063f698bd2736388e6e59f9821b9722b31fae681 Mon Sep 17 00:00:00 2001 From: scorbett123 Date: Fri, 4 Sep 2020 18:42:06 +0100 Subject: [PATCH 13/52] need to remove diagonals, however this does most of what you suggest. Signed-off-by: scorbett123 --- src/api/java/baritone/api/Settings.java | 7 ++ .../java/baritone/process/MineProcess.java | 97 +++++++++++++++++-- 2 files changed, 95 insertions(+), 9 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index ba62a1e85..3001ab574 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -731,6 +731,13 @@ public final class Settings { */ public final Setting allowOnlyExposedOres = new Setting<>(false); + /** + * When allowOnlyExposedOres is enabled this is the distance around to search. + *

+ * I recommend keeping this value low as the amount of blocks that need to be scanned increases exponentially. + */ + public final Setting allowOnlyExposedOresDistance = new Setting<>(1); + /** * When GetToBlock doesn't know any locations for the desired block, explore randomly instead of giving up. */ diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index 01d78b1ef..2bf44f06e 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -424,15 +424,8 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro } public static boolean isNextToAir(CalculationContext ctx, BlockPos pos) { - if (!Baritone.settings().allowOnlyExposedOres.value) { - return true; - } - return (ctx.bsi.get0(pos.down()).getBlock() == Blocks.AIR || - ctx.bsi.get0(pos.up()).getBlock() == Blocks.AIR - || ctx.bsi.get0(pos.north()).getBlock() == Blocks.AIR || - ctx.bsi.get0(pos.south()).getBlock() == Blocks.AIR || - ctx.bsi.get0(pos.east()).getBlock() == Blocks.AIR - || ctx.bsi.get0(pos.west()).getBlock() == Blocks.AIR); + //need to remove diagonals + return makeSphere(pos, Baritone.settings().allowOnlyExposedOresDistance.value, ctx); } @@ -468,4 +461,90 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro rescan(new ArrayList<>(), new CalculationContext(baritone)); } } + + public static boolean makeSphere(BlockPos pos, double radius, CalculationContext ctx) { + double radiusX = radius; + double radiusY = radius; + double radiusZ = radius; + radiusX += 0.5; + radiusY += 0.5; + radiusZ += 0.5; + + final double invRadiusX = 1 / radiusX; + final double invRadiusY = 1 / radiusY; + final double invRadiusZ = 1 / radiusZ; + + final int ceilRadiusX = (int) Math.ceil(radiusX); + final int ceilRadiusY = (int) Math.ceil(radiusY); + final int ceilRadiusZ = (int) Math.ceil(radiusZ); + + double nextXn = 0; + forX: + for (int x = 0; x <= ceilRadiusX; ++x) { + final double xn = nextXn; + nextXn = (x + 1) * invRadiusX; + double nextYn = 0; + forY: + for (int y = 0; y <= ceilRadiusY; ++y) { + final double yn = nextYn; + nextYn = (y + 1) * invRadiusY; + double nextZn = 0; + forZ: + for (int z = 0; z <= ceilRadiusZ; ++z) { + final double zn = nextZn; + nextZn = (z + 1) * invRadiusZ; + + double distanceSq = lengthSq(xn, yn, zn); + if (distanceSq > 1) { + if (z == 0) { + if (y == 0) { + break forX; + } + break forY; + } + break forZ; + } + + if (isTransparent(pos.add(x, y, z), ctx)) { + return true; + } + if (isTransparent(pos.add(-x, y, z), ctx)) { + return true; + } + if (isTransparent(pos.add(x, -y, z), ctx)) { + return true; + } + if (isTransparent(pos.add(x, y, -z), ctx)) { + return true; + } + if (isTransparent(pos.add(-x, -y, z), ctx)) { + return true; + } + if (isTransparent(pos.add(x, -y, -z), ctx)) { + return true; + } + if (isTransparent(pos.add(-x, y, -z), ctx)) { + return true; + } + if (isTransparent(pos.add(-x, -y, -z), ctx)) { + return true; + } + } + } + } + + return false; + } + + private static double lengthSq(double x, double y, double z) { + return (x * x) + (y * y) + (z * z); + } + + public static boolean isTransparent(BlockPos pos, CalculationContext ctx) { + IBlockState blockState = ctx.bsi.get0(pos); + return blockState.getBlock() == Blocks.AIR || + blockState.getBlock() == Blocks.FLOWING_LAVA || + blockState.getBlock() == Blocks.FLOWING_WATER || + blockState.getBlock() == Blocks.WATER; + } } From 547db3a6b4dbd624a7f9baf24f26e16624712db3 Mon Sep 17 00:00:00 2001 From: Sam Corbett Date: Sat, 5 Sep 2020 17:07:06 +0100 Subject: [PATCH 14/52] make the ability to turn it off. Signed-off-by: Sam Corbett --- src/api/java/baritone/api/Settings.java | 2 +- src/main/java/baritone/process/MineProcess.java | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 3001ab574..55b5ca888 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -734,7 +734,7 @@ public final class Settings { /** * When allowOnlyExposedOres is enabled this is the distance around to search. *

- * I recommend keeping this value low as the amount of blocks that need to be scanned increases exponentially. + * It is recommended to keep this value low, as it exponentially increases calculation times and also to keep the */ public final Setting allowOnlyExposedOresDistance = new Setting<>(1); diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index 2bf44f06e..c733658b2 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -40,7 +40,7 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3i; +import net.minecraft.util.math.Vec3d; import java.util.*; import java.util.stream.Collectors; @@ -410,7 +410,12 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro // remove any that are implausible to mine (encased in bedrock, or touching lava) .filter(pos -> MineProcess.plausibleToBreak(ctx, pos)) - .filter(pos -> isNextToAir(ctx, pos)) + .filter(pos -> { + if (Baritone.settings().allowOnlyExposedOres.value) + return isNextToAir(ctx, pos); + else + return true; + }) .filter(pos -> !blacklist.contains(pos)) @@ -494,7 +499,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro final double zn = nextZn; nextZn = (z + 1) * invRadiusZ; - double distanceSq = lengthSq(xn, yn, zn); + double distanceSq = new Vec3d(xn, yn, zn).lengthSquared(); if (distanceSq > 1) { if (z == 0) { if (y == 0) { @@ -536,10 +541,6 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro return false; } - private static double lengthSq(double x, double y, double z) { - return (x * x) + (y * y) + (z * z); - } - public static boolean isTransparent(BlockPos pos, CalculationContext ctx) { IBlockState blockState = ctx.bsi.get0(pos); return blockState.getBlock() == Blocks.AIR || From 071243b99a7ea3ff7c64b1171cdbaecf0081ec94 Mon Sep 17 00:00:00 2001 From: Sam Corbett Date: Tue, 8 Sep 2020 17:39:03 +0100 Subject: [PATCH 15/52] move is transparent to movement helper and circle maker --- .../pathing/movement/MovementHelper.java | 7 ++ .../java/baritone/process/MineProcess.java | 96 +++---------------- 2 files changed, 19 insertions(+), 84 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 7165303c4..df8218e86 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -562,4 +562,11 @@ public interface MovementHelper extends ActionCosts, Helper { enum PlaceResult { READY_TO_PLACE, ATTEMPTING, NO_OPTION; } + public static boolean isTransparent(Block b) { + + return b== Blocks.AIR || + b == Blocks.FLOWING_LAVA || + b == Blocks.FLOWING_WATER || + b == Blocks.WATER; + } } diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index c733658b2..2d51daf9e 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -429,8 +429,18 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro } public static boolean isNextToAir(CalculationContext ctx, BlockPos pos) { - //need to remove diagonals - return makeSphere(pos, Baritone.settings().allowOnlyExposedOresDistance.value, ctx); + int radius = Baritone.settings().allowOnlyExposedOresDistance.value; + for (int dx = -radius; dx <= radius; dx++) { + for (int dy = -radius; dy <= radius; dy++) { + for (int dz = -radius; dz <= radius; dz++) { + if (Math.abs(dx) + Math.abs(dy) + Math.abs(dz) <= radius + && MovementHelper.isTransparent(ctx.getBlock(pos.getX()+dx, pos.getY()+dy, pos.getZ()+dz))) { + return true; + } + } + } + } + return false; } @@ -466,86 +476,4 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro rescan(new ArrayList<>(), new CalculationContext(baritone)); } } - - public static boolean makeSphere(BlockPos pos, double radius, CalculationContext ctx) { - double radiusX = radius; - double radiusY = radius; - double radiusZ = radius; - radiusX += 0.5; - radiusY += 0.5; - radiusZ += 0.5; - - final double invRadiusX = 1 / radiusX; - final double invRadiusY = 1 / radiusY; - final double invRadiusZ = 1 / radiusZ; - - final int ceilRadiusX = (int) Math.ceil(radiusX); - final int ceilRadiusY = (int) Math.ceil(radiusY); - final int ceilRadiusZ = (int) Math.ceil(radiusZ); - - double nextXn = 0; - forX: - for (int x = 0; x <= ceilRadiusX; ++x) { - final double xn = nextXn; - nextXn = (x + 1) * invRadiusX; - double nextYn = 0; - forY: - for (int y = 0; y <= ceilRadiusY; ++y) { - final double yn = nextYn; - nextYn = (y + 1) * invRadiusY; - double nextZn = 0; - forZ: - for (int z = 0; z <= ceilRadiusZ; ++z) { - final double zn = nextZn; - nextZn = (z + 1) * invRadiusZ; - - double distanceSq = new Vec3d(xn, yn, zn).lengthSquared(); - if (distanceSq > 1) { - if (z == 0) { - if (y == 0) { - break forX; - } - break forY; - } - break forZ; - } - - if (isTransparent(pos.add(x, y, z), ctx)) { - return true; - } - if (isTransparent(pos.add(-x, y, z), ctx)) { - return true; - } - if (isTransparent(pos.add(x, -y, z), ctx)) { - return true; - } - if (isTransparent(pos.add(x, y, -z), ctx)) { - return true; - } - if (isTransparent(pos.add(-x, -y, z), ctx)) { - return true; - } - if (isTransparent(pos.add(x, -y, -z), ctx)) { - return true; - } - if (isTransparent(pos.add(-x, y, -z), ctx)) { - return true; - } - if (isTransparent(pos.add(-x, -y, -z), ctx)) { - return true; - } - } - } - } - - return false; - } - - public static boolean isTransparent(BlockPos pos, CalculationContext ctx) { - IBlockState blockState = ctx.bsi.get0(pos); - return blockState.getBlock() == Blocks.AIR || - blockState.getBlock() == Blocks.FLOWING_LAVA || - blockState.getBlock() == Blocks.FLOWING_WATER || - blockState.getBlock() == Blocks.WATER; - } } From 612510550f576d22d06582b302e88bc2037f4d32 Mon Sep 17 00:00:00 2001 From: Sam Corbett Date: Tue, 8 Sep 2020 19:00:41 +0100 Subject: [PATCH 16/52] fix javadoc. Signed-off-by: Sam Corbett --- src/api/java/baritone/api/Settings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index c5ba95bc2..9cabe083c 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -734,7 +734,7 @@ public final class Settings { /** * When allowOnlyExposedOres is enabled this is the distance around to search. *

- * It is recommended to keep this value low, as it exponentially increases calculation times and also to keep the + * It is recommended to keep this value low, as it dramatically increases calculation times. */ public final Setting allowOnlyExposedOresDistance = new Setting<>(1); From 96b874c099cdd7fe830c861b9def97602a6aeeb7 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 11 Sep 2020 21:52:43 -0700 Subject: [PATCH 17/52] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 274dbe0f5..c321ce4a9 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ A Minecraft pathfinder bot. -Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. There's a [showcase video](https://youtu.be/CZkLXWo4Fg4) made by @Adovin#0730 on Baritone which I recommend. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a (very old!) video I made showing off what it can do. +Baritone is the pathfinding system used in [Impact](https://impactclient.net/) since 4.4. There's a [showcase video](https://youtu.be/CZkLXWo4Fg4) made by @Adovin#0730 on Baritone which I recommend. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a (very old!) video I made showing off what it can do. [Tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa) The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the v1.2.* `api-forge` jar from [releases](https://github.com/cabaletta/baritone/releases). **For 1.12.2 Forge, just click [here](https://github.com/cabaletta/baritone/releases/download/v1.2.14/baritone-api-forge-1.2.14.jar)**. Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it. From 175df6ce7a68ccc1d606afc64b36123e7b1f2ba8 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 11 Sep 2020 21:54:20 -0700 Subject: [PATCH 18/52] Update USAGE.md --- USAGE.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/USAGE.md b/USAGE.md index d817c24cb..b58744284 100644 --- a/USAGE.md +++ b/USAGE.md @@ -24,6 +24,8 @@ Watch this [showcase video](https://youtu.be/CZkLXWo4Fg4)! # Commands +[Tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa) + **All** of these commands may need a prefix before them, as above ^. `help` From 32ef30686bc1504ccf67c9cdb8308161c3f37b3a Mon Sep 17 00:00:00 2001 From: Babbaj Date: Sun, 13 Sep 2020 18:21:22 -0400 Subject: [PATCH 19/52] Don't call onLostControl on processes that haven't been fully constructed --- src/main/java/baritone/Baritone.java | 16 ++++++++-------- .../baritone/utils/BaritoneProcessHelper.java | 1 - 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index 360a17fd5..32302287b 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -104,14 +104,14 @@ public class Baritone implements IBaritone { this.pathingControlManager = new PathingControlManager(this); { - followProcess = new FollowProcess(this); - mineProcess = new MineProcess(this); - customGoalProcess = new CustomGoalProcess(this); // very high iq - getToBlockProcess = new GetToBlockProcess(this); - builderProcess = new BuilderProcess(this); - exploreProcess = new ExploreProcess(this); - backfillProcess = new BackfillProcess(this); - farmProcess = new FarmProcess(this); + this.getPathingControlManager().registerProcess(followProcess = new FollowProcess(this)); + this.getPathingControlManager().registerProcess(mineProcess = new MineProcess(this)); + this.getPathingControlManager().registerProcess(customGoalProcess = new CustomGoalProcess(this)); // very high iq + this.getPathingControlManager().registerProcess(getToBlockProcess = new GetToBlockProcess(this)); + this.getPathingControlManager().registerProcess(builderProcess = new BuilderProcess(this)); + this.getPathingControlManager().registerProcess(exploreProcess = new ExploreProcess(this)); + this.getPathingControlManager().registerProcess(backfillProcess = new BackfillProcess(this)); + this.getPathingControlManager().registerProcess(farmProcess = new FarmProcess(this)); } this.worldProvider = new WorldProvider(); diff --git a/src/main/java/baritone/utils/BaritoneProcessHelper.java b/src/main/java/baritone/utils/BaritoneProcessHelper.java index 6abec9493..e9ce12736 100644 --- a/src/main/java/baritone/utils/BaritoneProcessHelper.java +++ b/src/main/java/baritone/utils/BaritoneProcessHelper.java @@ -30,7 +30,6 @@ public abstract class BaritoneProcessHelper implements IBaritoneProcess, Helper public BaritoneProcessHelper(Baritone baritone) { this.baritone = baritone; this.ctx = baritone.getPlayerContext(); - baritone.getPathingControlManager().registerProcess(this); } @Override From 234fd3f75e0b3a61da9ae44b9efbf6f4be448893 Mon Sep 17 00:00:00 2001 From: Babbaj Date: Sun, 13 Sep 2020 18:45:50 -0400 Subject: [PATCH 20/52] don't use getter --- src/main/java/baritone/Baritone.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index 32302287b..0ec5583f3 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -104,14 +104,14 @@ public class Baritone implements IBaritone { this.pathingControlManager = new PathingControlManager(this); { - this.getPathingControlManager().registerProcess(followProcess = new FollowProcess(this)); - this.getPathingControlManager().registerProcess(mineProcess = new MineProcess(this)); - this.getPathingControlManager().registerProcess(customGoalProcess = new CustomGoalProcess(this)); // very high iq - this.getPathingControlManager().registerProcess(getToBlockProcess = new GetToBlockProcess(this)); - this.getPathingControlManager().registerProcess(builderProcess = new BuilderProcess(this)); - this.getPathingControlManager().registerProcess(exploreProcess = new ExploreProcess(this)); - this.getPathingControlManager().registerProcess(backfillProcess = new BackfillProcess(this)); - this.getPathingControlManager().registerProcess(farmProcess = new FarmProcess(this)); + this.pathingControlManager.registerProcess(followProcess = new FollowProcess(this)); + this.pathingControlManager.registerProcess(mineProcess = new MineProcess(this)); + this.pathingControlManager.registerProcess(customGoalProcess = new CustomGoalProcess(this)); // very high iq + this.pathingControlManager.registerProcess(getToBlockProcess = new GetToBlockProcess(this)); + this.pathingControlManager.registerProcess(builderProcess = new BuilderProcess(this)); + this.pathingControlManager.registerProcess(exploreProcess = new ExploreProcess(this)); + this.pathingControlManager.registerProcess(backfillProcess = new BackfillProcess(this)); + this.pathingControlManager.registerProcess(farmProcess = new FarmProcess(this)); } this.worldProvider = new WorldProvider(); From 7e4d2c9b28c2c38cf8fdc4805cb7d89b3fb95ae6 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 15 Sep 2020 12:43:34 -0700 Subject: [PATCH 21/52] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index c321ce4a9..803816090 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,6 @@ [![ForgeHax integration](https://img.shields.io/badge/ForgeHax%20%22integration%22-scuffed-yellow.svg)](https://github.com/fr1kin/ForgeHax/) [![Aristois add-on integration](https://img.shields.io/badge/Aristois%20add--on%20integration-v1.3.4%20/%20v1.4.1-green.svg)](https://gitlab.com/emc-mods-indrit/baritone_api) [![rootNET integration](https://img.shields.io/badge/rootNET%20integration-v1.2.11-green.svg)](https://rootnet.dev/) -[![WWE integration](https://img.shields.io/badge/WWE%20%22integration%22-master%3F-green.svg)](https://wweclient.com/) [![Future integration](https://img.shields.io/badge/Future%20integration-v1.2.12%20%2F%20v1.3.6%20%2F%20v1.4.4-red)](https://futureclient.net/) [![RusherHack integration](https://img.shields.io/badge/RusherHack%20integration-v1.2.14-green)](https://rusherhack.org/) [![forthebadge](https://forthebadge.com/images/badges/built-with-swag.svg)](http://forthebadge.com/) From 13ca691f5d1922571cfabaf6198b9b0f59500ade Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Wed, 16 Sep 2020 17:41:46 +0200 Subject: [PATCH 22/52] make `#wp goto` behave like `#goto` It now is a combined `#wp goal` and `#path` just like `#goto` is `#goal` and `#path` --- .../java/baritone/command/defaults/WaypointsCommand.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/command/defaults/WaypointsCommand.java b/src/main/java/baritone/command/defaults/WaypointsCommand.java index 62c74212c..fb15b0537 100644 --- a/src/main/java/baritone/command/defaults/WaypointsCommand.java +++ b/src/main/java/baritone/command/defaults/WaypointsCommand.java @@ -235,6 +235,10 @@ public class WaypointsCommand extends Command { Goal goal = new GoalBlock(waypoint.getLocation()); baritone.getCustomGoalProcess().setGoal(goal); logDirect(String.format("Goal: %s", goal)); + } else if (action == Action.GOTO) { + Goal goal = new GoalBlock(waypoint.getLocation()); + baritone.getCustomGoalProcess().setGoalAndPath(goal); + logDirect(String.format("Going to: %s", goal)); } } } @@ -302,7 +306,8 @@ public class WaypointsCommand extends Command { SAVE("save", "s"), INFO("info", "show", "i"), DELETE("delete", "d"), - GOAL("goal", "goto", "g"); + GOAL("goal", "g"), + GOTO("goto"); private final String[] names; Action(String... names) { From 508dacac639fd9bfc780b320bd1b60cef9107487 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Fri, 18 Sep 2020 22:41:33 +0200 Subject: [PATCH 23/52] directly start pathing after `#home` just like servers directly teleport you after `/home` without waiting for something like `/teleport` --- src/main/java/baritone/command/defaults/DefaultCommands.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/command/defaults/DefaultCommands.java b/src/main/java/baritone/command/defaults/DefaultCommands.java index 67555ed51..a08ff0ff0 100644 --- a/src/main/java/baritone/command/defaults/DefaultCommands.java +++ b/src/main/java/baritone/command/defaults/DefaultCommands.java @@ -63,7 +63,7 @@ public final class DefaultCommands { new ThisWayCommand(baritone), new WaypointsCommand(baritone), new CommandAlias(baritone, "sethome", "Sets your home waypoint", "waypoints save home"), - new CommandAlias(baritone, "home", "Set goal to your home waypoint", "waypoints goal home"), + new CommandAlias(baritone, "home", "Path to your home waypoint", "waypoints goto home"), new SelCommand(baritone) )); ExecutionControlCommands prc = new ExecutionControlCommands(baritone); From 8a572516fcd42158a16870214b560e1844423bb8 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Wed, 23 Sep 2020 22:54:41 +0200 Subject: [PATCH 24/52] Update description of WaypointsCommand --- src/main/java/baritone/command/defaults/WaypointsCommand.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/command/defaults/WaypointsCommand.java b/src/main/java/baritone/command/defaults/WaypointsCommand.java index fb15b0537..67aad3654 100644 --- a/src/main/java/baritone/command/defaults/WaypointsCommand.java +++ b/src/main/java/baritone/command/defaults/WaypointsCommand.java @@ -296,7 +296,8 @@ public class WaypointsCommand extends Command { "> wp - Save the waypoint with the specified name and position.", "> wp - Show info on a waypoint by tag.", "> wp - Delete a waypoint by tag.", - "> wp - Set a goal to a waypoint by tag." + "> wp - Set a goal to a waypoint by tag.", + "> wp - Set a goal to a waypoint by tag and start pathing." ); } From af29ed7146ab49ce2555c14da139eec3244b758f Mon Sep 17 00:00:00 2001 From: CDAGaming Date: Tue, 18 Aug 2020 15:02:43 -0500 Subject: [PATCH 25/52] =?UTF-8?q?=E2=9C=A8=20Added=20a=20top/surface=20com?= =?UTF-8?q?mand?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Superseeds PR #594 --- .../command/defaults/DefaultCommands.java | 1 + .../command/defaults/SurfaceCommand.java | 89 +++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 src/main/java/baritone/command/defaults/SurfaceCommand.java diff --git a/src/main/java/baritone/command/defaults/DefaultCommands.java b/src/main/java/baritone/command/defaults/DefaultCommands.java index a08ff0ff0..41c58b003 100644 --- a/src/main/java/baritone/command/defaults/DefaultCommands.java +++ b/src/main/java/baritone/command/defaults/DefaultCommands.java @@ -60,6 +60,7 @@ public final class DefaultCommands { new FindCommand(baritone), new MineCommand(baritone), new ClickCommand(baritone), + new SurfaceCommand(baritone), new ThisWayCommand(baritone), new WaypointsCommand(baritone), new CommandAlias(baritone, "sethome", "Sets your home waypoint", "waypoints save home"), diff --git a/src/main/java/baritone/command/defaults/SurfaceCommand.java b/src/main/java/baritone/command/defaults/SurfaceCommand.java new file mode 100644 index 000000000..842b8050c --- /dev/null +++ b/src/main/java/baritone/command/defaults/SurfaceCommand.java @@ -0,0 +1,89 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package baritone.command.defaults; + +import baritone.api.IBaritone; +import baritone.api.command.Command; +import baritone.api.command.argument.IArgConsumer; +import baritone.api.command.exception.CommandException; +import baritone.api.pathing.goals.Goal; +import baritone.api.pathing.goals.GoalBlock; +import baritone.api.utils.BetterBlockPos; +import net.minecraft.block.BlockAir; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Stream; + +public class SurfaceCommand extends Command { + + protected SurfaceCommand(IBaritone baritone) { + super(baritone, "surface", "top"); + } + + @Override + public void execute(String label, IArgConsumer args) throws CommandException { + final BetterBlockPos playerPos = baritone.getPlayerContext().playerFeet(); + final int surfaceLevel = baritone.getPlayerContext().world().getSeaLevel(); + final int worldHeight = baritone.getPlayerContext().world().getActualHeight(); + + // Ensure this command will not run if you are above the surface level and the block above you is air + // As this would imply that your are already on the open surface + if (playerPos.getY() > surfaceLevel && mc.world.getBlockState(playerPos.up()).getBlock() instanceof BlockAir) { + logDirect("Already at surface"); + return; + } + + final int startingYPos = Math.max(playerPos.getY(), surfaceLevel); + + for (int currentIteratedY = startingYPos; currentIteratedY < worldHeight; currentIteratedY++) { + final BetterBlockPos newPos = new BetterBlockPos(playerPos.getX(), currentIteratedY, playerPos.getZ()); + + if (!(mc.world.getBlockState(newPos).getBlock() instanceof BlockAir) && newPos.getY() > playerPos.getY()) { + Goal goal = new GoalBlock(newPos.up()); + logDirect(String.format("Going to: %s", goal.toString())); + baritone.getCustomGoalProcess().setGoalAndPath(goal); + return; + } + } + logDirect("No higher location found"); + } + + @Override + public Stream tabComplete(String label, IArgConsumer args) { + return Stream.empty(); + } + + @Override + public String getShortDesc() { + return "Used to get out of caves, mines, ..."; + } + + @Override + public List getLongDesc() { + return Arrays.asList( + "The surface/top command tells Baritone to head towards the closest surface-like area.", + "", + "This can be the surface or the highest available air space, depending on circumstances.", + "", + "Usage:", + "> surface - Used to get out of caves, mines, ...", + "> top - Used to get out of caves, mines, ..." + ); + } +} From d6665f1cd57e8a8846edab137259fe5af9e2d684 Mon Sep 17 00:00:00 2001 From: CDAGaming Date: Tue, 18 Aug 2020 12:20:40 -0500 Subject: [PATCH 26/52] =?UTF-8?q?=E2=9C=A8=20Added=20Toast=20API=20Support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds in a logAsToast and toastTimer option, and is a minified form of Indrit's initial implementation previously used from fabritone --- src/api/java/baritone/api/Settings.java | 12 +++ src/api/java/baritone/api/utils/Helper.java | 97 ++++++++++++++++--- .../baritone/api/utils/gui/BaritoneToast.java | 86 ++++++++++++++++ 3 files changed, 183 insertions(+), 12 deletions(-) create mode 100644 src/api/java/baritone/api/utils/gui/BaritoneToast.java diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 46e3fbf5c..129c32796 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -529,6 +529,18 @@ public final class Settings { */ public final Setting backfill = new Setting<>(false); + /** + * Shows popup message in the upper right corner, similarly to when you make an advancement + */ + public final Setting logAsToast = new Setting<>(false); + + /** + * The time of how long the message in the pop-up will display + *

+ * If below 1000L (1sec), it's better to disable this + */ + public final Setting toastTimer = new Setting<>(5000L); + /** * Print all the debug messages to chat */ diff --git a/src/api/java/baritone/api/utils/Helper.java b/src/api/java/baritone/api/utils/Helper.java index 3cda18343..1fe5b4214 100755 --- a/src/api/java/baritone/api/utils/Helper.java +++ b/src/api/java/baritone/api/utils/Helper.java @@ -18,6 +18,7 @@ package baritone.api.utils; import baritone.api.BaritoneAPI; +import baritone.api.utils.gui.BaritoneToast; import net.minecraft.client.Minecraft; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; @@ -63,6 +64,35 @@ public interface Helper { return prefix; } + /** + * Send a message to display as a toast popup + * + * @param title The title to display in the popup + * @param message The message to display in the popup + */ + default void logToast(ITextComponent title, ITextComponent message) { + BaritoneToast.addOrUpdate(mc.getToastGui(), title, message, BaritoneAPI.getSettings().toastTimer.value); + } + + /** + * Send a message to display as a toast popup + * + * @param title The title to display in the popup + * @param message The message to display in the popup + */ + default void logToast(String title, String message) { + logToast(new TextComponentString(title), new TextComponentString(message)); + } + + /** + * Send a message to display as a toast popup + * + * @param message The message to display in the popup + */ + default void logToast(String message) { + logToast(Helper.getPrefix(), new TextComponentString(message)); + } + /** * Send a message to chat only if chatDebug is on * @@ -74,7 +104,31 @@ public interface Helper { //System.out.println(message); return; } - logDirect(message); + // We won't log debug chat into toasts + // Because only a madman would want that extreme spam -_- + logDirect(message, false); + } + + /** + * Send components to chat with the [Baritone] prefix + * + * @param logAsToast Whether to log as a toast notification + * @param components The components to send + */ + default void logDirect(boolean logAsToast, ITextComponent... components) { + ITextComponent component = new TextComponentString(""); + if (!logAsToast) { + // If we are not logging as a Toast + // Append the prefix to the base component line + component.appendSibling(getPrefix()); + component.appendSibling(new TextComponentString(" ")); + } + Arrays.asList(components).forEach(component::appendSibling); + if (logAsToast) { + logToast(getPrefix(), component); + } else { + mc.addScheduledTask(() -> BaritoneAPI.getSettings().logger.value.accept(component)); + } } /** @@ -83,11 +137,23 @@ public interface Helper { * @param components The components to send */ default void logDirect(ITextComponent... components) { - ITextComponent component = new TextComponentString(""); - component.appendSibling(getPrefix()); - component.appendSibling(new TextComponentString(" ")); - Arrays.asList(components).forEach(component::appendSibling); - Minecraft.getMinecraft().addScheduledTask(() -> BaritoneAPI.getSettings().logger.value.accept(component)); + logDirect(BaritoneAPI.getSettings().logAsToast.value, components); + } + + /** + * Send a message to chat regardless of chatDebug (should only be used for critically important messages, or as a + * direct response to a chat command) + * + * @param message The message to display in chat + * @param color The color to print that message in + * @param logAsToast Whether to log as a toast notification + */ + default void logDirect(String message, TextFormatting color, boolean logAsToast) { + Stream.of(message.split("\n")).forEach(line -> { + ITextComponent component = new TextComponentString(line.replace("\t", " ")); + component.getStyle().setColor(color); + logDirect(logAsToast, component); + }); } /** @@ -98,11 +164,18 @@ public interface Helper { * @param color The color to print that message in */ default void logDirect(String message, TextFormatting color) { - Stream.of(message.split("\n")).forEach(line -> { - ITextComponent component = new TextComponentString(line.replace("\t", " ")); - component.getStyle().setColor(color); - logDirect(component); - }); + logDirect(message, color, BaritoneAPI.getSettings().logAsToast.value); + } + + /** + * Send a message to chat regardless of chatDebug (should only be used for critically important messages, or as a + * direct response to a chat command) + * + * @param message The message to display in chat + * @param logAsToast Whether to log as a toast notification + */ + default void logDirect(String message, boolean logAsToast) { + logDirect(message, TextFormatting.GRAY, logAsToast); } /** @@ -112,6 +185,6 @@ public interface Helper { * @param message The message to display in chat */ default void logDirect(String message) { - logDirect(message, TextFormatting.GRAY); + logDirect(message, BaritoneAPI.getSettings().logAsToast.value); } } diff --git a/src/api/java/baritone/api/utils/gui/BaritoneToast.java b/src/api/java/baritone/api/utils/gui/BaritoneToast.java new file mode 100644 index 000000000..fa3d77399 --- /dev/null +++ b/src/api/java/baritone/api/utils/gui/BaritoneToast.java @@ -0,0 +1,86 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package baritone.api.utils.gui; + +import net.minecraft.client.gui.toasts.GuiToast; +import net.minecraft.client.gui.toasts.IToast; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.text.ITextComponent; + +public class BaritoneToast implements IToast +{ + private String title; + private String subtitle; + private long firstDrawTime; + private boolean newDisplay; + private long totalShowTime; + + public BaritoneToast(ITextComponent titleComponent, ITextComponent subtitleComponent, long totalShowTime) + { + this.title = titleComponent.getFormattedText(); + this.subtitle = subtitleComponent == null ? null : subtitleComponent.getFormattedText(); + this.totalShowTime = totalShowTime; + } + + public Visibility draw(GuiToast toastGui, long delta) + { + if (this.newDisplay) + { + this.firstDrawTime = delta; + this.newDisplay = false; + } + + toastGui.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("textures/gui/toasts.png")); + GlStateManager.color(1.0F, 1.0F, 1.0F, 255.0f); + toastGui.drawTexturedModalRect(0, 0, 0, 32, 160, 32); + + if (this.subtitle == null) + { + toastGui.getMinecraft().fontRenderer.drawString(this.title, 18, 12, -11534256); + } + else + { + toastGui.getMinecraft().fontRenderer.drawString(this.title, 18, 7, -11534256); + toastGui.getMinecraft().fontRenderer.drawString(this.subtitle, 18, 18, -16777216); + } + + return delta - this.firstDrawTime < totalShowTime ? Visibility.SHOW : Visibility.HIDE; + } + + public void setDisplayedText(ITextComponent titleComponent, ITextComponent subtitleComponent) + { + this.title = titleComponent.getFormattedText(); + this.subtitle = subtitleComponent == null ? null : subtitleComponent.getFormattedText(); + this.newDisplay = true; + } + + public static void addOrUpdate(GuiToast toast, ITextComponent title, ITextComponent subtitle, long totalShowTime) + { + BaritoneToast baritonetoast = toast.getToast(BaritoneToast.class, new Object()); + + if (baritonetoast == null) + { + toast.add(new BaritoneToast(title, subtitle, totalShowTime)); + } + else + { + baritonetoast.setDisplayedText(title, subtitle); + } + } +} From 918f009e8a02fcfa1edbf0cda360429da6f62083 Mon Sep 17 00:00:00 2001 From: CDAGaming Date: Mon, 12 Oct 2020 12:52:05 -0500 Subject: [PATCH 27/52] =?UTF-8?q?=F0=9F=90=9B=20Fix=20a=20Rendering=20Conf?= =?UTF-8?q?lict=20with=20some=20other=20Mods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In testing within Fabritone, it was found that these two lines (Which were previously used for an unknown optifine workaround) are no longer needed, and had no known side effects as of writing. This can be backported as needed, but details are unknown how far this can go down Future me PS: This PR is a superseed of my last one, erased during repo refactors, so now it lives on master branch. Testing recommended and can be up-ported/down-ported as you wish. --- src/main/java/baritone/utils/IRenderer.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/baritone/utils/IRenderer.java b/src/main/java/baritone/utils/IRenderer.java index 0078f2276..e5a5ee907 100644 --- a/src/main/java/baritone/utils/IRenderer.java +++ b/src/main/java/baritone/utils/IRenderer.java @@ -45,7 +45,6 @@ public interface IRenderer { static void startLines(Color color, float alpha, float lineWidth, boolean ignoreDepth) { GlStateManager.enableBlend(); - GlStateManager.disableLighting(); GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); glColor(color, alpha); GlStateManager.glLineWidth(lineWidth); @@ -68,7 +67,6 @@ public interface IRenderer { GlStateManager.depthMask(true); GlStateManager.enableTexture2D(); - GlStateManager.enableLighting(); GlStateManager.disableBlend(); } From d2c625e1c9bf710c15007a31f5b32437026b8a6a Mon Sep 17 00:00:00 2001 From: CDAGaming Date: Wed, 14 Oct 2020 13:14:23 -0500 Subject: [PATCH 28/52] Apply Review Comments --- src/api/java/baritone/api/utils/Helper.java | 2 +- .../baritone/api/utils/gui/BaritoneToast.java | 32 ++++++------------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/api/java/baritone/api/utils/Helper.java b/src/api/java/baritone/api/utils/Helper.java index 1fe5b4214..324efbefe 100755 --- a/src/api/java/baritone/api/utils/Helper.java +++ b/src/api/java/baritone/api/utils/Helper.java @@ -71,7 +71,7 @@ public interface Helper { * @param message The message to display in the popup */ default void logToast(ITextComponent title, ITextComponent message) { - BaritoneToast.addOrUpdate(mc.getToastGui(), title, message, BaritoneAPI.getSettings().toastTimer.value); + mc.addScheduledTask(() -> BaritoneToast.addOrUpdate(mc.getToastGui(), title, message, BaritoneAPI.getSettings().toastTimer.value)); } /** diff --git a/src/api/java/baritone/api/utils/gui/BaritoneToast.java b/src/api/java/baritone/api/utils/gui/BaritoneToast.java index fa3d77399..82df67413 100644 --- a/src/api/java/baritone/api/utils/gui/BaritoneToast.java +++ b/src/api/java/baritone/api/utils/gui/BaritoneToast.java @@ -23,25 +23,21 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; -public class BaritoneToast implements IToast -{ +public class BaritoneToast implements IToast { private String title; private String subtitle; private long firstDrawTime; private boolean newDisplay; private long totalShowTime; - public BaritoneToast(ITextComponent titleComponent, ITextComponent subtitleComponent, long totalShowTime) - { + public BaritoneToast(ITextComponent titleComponent, ITextComponent subtitleComponent, long totalShowTime) { this.title = titleComponent.getFormattedText(); this.subtitle = subtitleComponent == null ? null : subtitleComponent.getFormattedText(); this.totalShowTime = totalShowTime; } - public Visibility draw(GuiToast toastGui, long delta) - { - if (this.newDisplay) - { + public Visibility draw(GuiToast toastGui, long delta) { + if (this.newDisplay) { this.firstDrawTime = delta; this.newDisplay = false; } @@ -50,12 +46,9 @@ public class BaritoneToast implements IToast GlStateManager.color(1.0F, 1.0F, 1.0F, 255.0f); toastGui.drawTexturedModalRect(0, 0, 0, 32, 160, 32); - if (this.subtitle == null) - { + if (this.subtitle == null) { toastGui.getMinecraft().fontRenderer.drawString(this.title, 18, 12, -11534256); - } - else - { + } else { toastGui.getMinecraft().fontRenderer.drawString(this.title, 18, 7, -11534256); toastGui.getMinecraft().fontRenderer.drawString(this.subtitle, 18, 18, -16777216); } @@ -63,23 +56,18 @@ public class BaritoneToast implements IToast return delta - this.firstDrawTime < totalShowTime ? Visibility.SHOW : Visibility.HIDE; } - public void setDisplayedText(ITextComponent titleComponent, ITextComponent subtitleComponent) - { + public void setDisplayedText(ITextComponent titleComponent, ITextComponent subtitleComponent) { this.title = titleComponent.getFormattedText(); this.subtitle = subtitleComponent == null ? null : subtitleComponent.getFormattedText(); this.newDisplay = true; } - public static void addOrUpdate(GuiToast toast, ITextComponent title, ITextComponent subtitle, long totalShowTime) - { + public static void addOrUpdate(GuiToast toast, ITextComponent title, ITextComponent subtitle, long totalShowTime) { BaritoneToast baritonetoast = toast.getToast(BaritoneToast.class, new Object()); - if (baritonetoast == null) - { + if (baritonetoast == null) { toast.add(new BaritoneToast(title, subtitle, totalShowTime)); - } - else - { + } else { baritonetoast.setDisplayedText(title, subtitle); } } From 39cfebeb344c321eae105b4dff8e460a7c9c2ace Mon Sep 17 00:00:00 2001 From: scorbett123 Date: Wed, 14 Oct 2020 19:56:09 +0100 Subject: [PATCH 29/52] fix formatting Signed-off-by: scorbett123 --- .../java/baritone/pathing/movement/MovementHelper.java | 4 ++-- src/main/java/baritone/process/MineProcess.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index df8218e86..8caa382bc 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -562,9 +562,9 @@ public interface MovementHelper extends ActionCosts, Helper { enum PlaceResult { READY_TO_PLACE, ATTEMPTING, NO_OPTION; } - public static boolean isTransparent(Block b) { + static boolean isTransparent(Block b) { - return b== Blocks.AIR || + return b == Blocks.AIR || b == Blocks.FLOWING_LAVA || b == Blocks.FLOWING_WATER || b == Blocks.WATER; diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index 2d51daf9e..b8474e2f3 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -40,7 +40,6 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; import java.util.*; import java.util.stream.Collectors; @@ -411,10 +410,11 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro .filter(pos -> MineProcess.plausibleToBreak(ctx, pos)) .filter(pos -> { - if (Baritone.settings().allowOnlyExposedOres.value) + if (Baritone.settings().allowOnlyExposedOres.value) { return isNextToAir(ctx, pos); - else + } else { return true; + } }) .filter(pos -> !blacklist.contains(pos)) @@ -434,7 +434,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro for (int dy = -radius; dy <= radius; dy++) { for (int dz = -radius; dz <= radius; dz++) { if (Math.abs(dx) + Math.abs(dy) + Math.abs(dz) <= radius - && MovementHelper.isTransparent(ctx.getBlock(pos.getX()+dx, pos.getY()+dy, pos.getZ()+dz))) { + && MovementHelper.isTransparent(ctx.getBlock(pos.getX() + dx, pos.getY() + dy, pos.getZ() + dz))) { return true; } } From bfb530e02b7ad72fb660f3b2df02b52e883fbdb4 Mon Sep 17 00:00:00 2001 From: Sam Corbett Date: Fri, 16 Oct 2020 17:02:02 +0100 Subject: [PATCH 30/52] add a minimum Y level. Signed-off-by: Sam Corbett --- src/api/java/baritone/api/Settings.java | 5 +++++ src/main/java/baritone/process/MineProcess.java | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 86cb75c13..96e4c5790 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -738,6 +738,11 @@ public final class Settings { */ public final Setting maxCachedWorldScanCount = new Setting<>(10); + /** + * Sets the minimum y level whilst mining - set to 0 to turn off. + */ + public final Setting minYLevelWhileMining = new Setting<>(0); + /** * This will only allow baritone to mine exposed ores, can be used to stop ore obfuscators on servers that use them. */ diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index b8474e2f3..5bce121d8 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -417,6 +417,8 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro } }) + .filter(pos -> pos.getY() > Baritone.settings().minYLevelWhileMining.value) + .filter(pos -> !blacklist.contains(pos)) .sorted(Comparator.comparingDouble(ctx.getBaritone().getPlayerContext().player()::getDistanceSq)) From 5d3522ca0a91ae83920c7c8000a13d14e8b1a591 Mon Sep 17 00:00:00 2001 From: millennIumAMbiguity <37588844+millennIumAMbiguity@users.noreply.github.com> Date: Fri, 16 Oct 2020 23:32:53 +0200 Subject: [PATCH 31/52] Added range argument to farm --- src/api/java/baritone/api/process/IFarmProcess.java | 4 +++- .../java/baritone/command/defaults/FarmCommand.java | 13 ++++++++++--- src/main/java/baritone/process/FarmProcess.java | 12 +++++++++++- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/api/java/baritone/api/process/IFarmProcess.java b/src/api/java/baritone/api/process/IFarmProcess.java index 6ced16fba..c9295b765 100644 --- a/src/api/java/baritone/api/process/IFarmProcess.java +++ b/src/api/java/baritone/api/process/IFarmProcess.java @@ -17,7 +17,9 @@ package baritone.api.process; +import net.minecraft.util.math.BlockPos; + public interface IFarmProcess extends IBaritoneProcess { - void farm(); + void farm(int range, BlockPos pos); } diff --git a/src/main/java/baritone/command/defaults/FarmCommand.java b/src/main/java/baritone/command/defaults/FarmCommand.java index 786d01249..89a173d1b 100644 --- a/src/main/java/baritone/command/defaults/FarmCommand.java +++ b/src/main/java/baritone/command/defaults/FarmCommand.java @@ -21,6 +21,7 @@ import baritone.api.IBaritone; import baritone.api.command.Command; import baritone.api.command.exception.CommandException; import baritone.api.command.argument.IArgConsumer; +import baritone.api.utils.BetterBlockPos; import java.util.Arrays; import java.util.List; @@ -34,8 +35,13 @@ public class FarmCommand extends Command { @Override public void execute(String label, IArgConsumer args) throws CommandException { - args.requireMax(0); - baritone.getFarmProcess().farm(); + args.requireMax(1); + int range = 0; + if (args.hasExactly(1)) { + range = args.getAs(Integer.class); + } + BetterBlockPos origin = baritone.getPlayerContext().playerFeet(); + baritone.getFarmProcess().farm(range, origin); logDirect("Farming"); } @@ -55,7 +61,8 @@ public class FarmCommand extends Command { "The farm command starts farming nearby plants. It harvests mature crops and plants new ones.", "", "Usage:", - "> farm" + "> farm - farms every crop it can find.", + "> farm 100 - farm crops within a 100 block radius from the starting position." ); } } diff --git a/src/main/java/baritone/process/FarmProcess.java b/src/main/java/baritone/process/FarmProcess.java index 407157b37..599fa6df8 100644 --- a/src/main/java/baritone/process/FarmProcess.java +++ b/src/main/java/baritone/process/FarmProcess.java @@ -61,6 +61,9 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro private List locations; private int tickCount; + private int range; + private BlockPos center; + private static final List FARMLAND_PLANTABLE = Arrays.asList( Items.BEETROOT_SEEDS, Items.MELON_SEEDS, @@ -97,7 +100,9 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro } @Override - public void farm() { + public void farm(int range, BlockPos pos) { + center = pos; + this.range = range; active = true; locations = null; } @@ -191,6 +196,11 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro List bonemealable = new ArrayList<>(); List openSoulsand = new ArrayList<>(); for (BlockPos pos : locations) { + //check if the target block is out of range. + if (range != 0 && pos.getDistance(center.getX(), center.getY(), center.getZ()) > range) { + continue; + } + IBlockState state = ctx.world().getBlockState(pos); boolean airAbove = ctx.world().getBlockState(pos.up()).getBlock() instanceof BlockAir; if (state.getBlock() == Blocks.FARMLAND) { From 65a5677b33defb80c1d5c26026fdb5c2cc086468 Mon Sep 17 00:00:00 2001 From: millennIumAMbiguity <37588844+millennIumAMbiguity@users.noreply.github.com> Date: Thu, 22 Oct 2020 00:36:19 +0200 Subject: [PATCH 32/52] Added the feature to only farm within range of a waypoint. --- .../command/defaults/FarmCommand.java | 54 +++++++++++++++++-- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/command/defaults/FarmCommand.java b/src/main/java/baritone/command/defaults/FarmCommand.java index 89a173d1b..37c6a78ef 100644 --- a/src/main/java/baritone/command/defaults/FarmCommand.java +++ b/src/main/java/baritone/command/defaults/FarmCommand.java @@ -18,15 +18,23 @@ package baritone.command.defaults; import baritone.api.IBaritone; +import baritone.api.cache.IWaypoint; import baritone.api.command.Command; +import baritone.api.command.datatypes.ForWaypoints; import baritone.api.command.exception.CommandException; import baritone.api.command.argument.IArgConsumer; +import baritone.api.command.exception.CommandInvalidStateException; +import baritone.api.command.helpers.Paginator; +import baritone.api.pathing.goals.Goal; +import baritone.api.pathing.goals.GoalBlock; import baritone.api.utils.BetterBlockPos; import java.util.Arrays; import java.util.List; import java.util.stream.Stream; +import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX; + public class FarmCommand extends Command { public FarmCommand(IBaritone baritone) { @@ -35,12 +43,49 @@ public class FarmCommand extends Command { @Override public void execute(String label, IArgConsumer args) throws CommandException { - args.requireMax(1); + args.requireMax(2); int range = 0; - if (args.hasExactly(1)) { + BetterBlockPos origin; + //range + if (args.has(1)) { range = args.getAs(Integer.class); } - BetterBlockPos origin = baritone.getPlayerContext().playerFeet(); + //waypoint + if (args.hasExactly(1)){ + IWaypoint[] waypoints = args.getDatatypeFor(ForWaypoints.INSTANCE); + IWaypoint waypoint = null; + if (args.hasAny() && args.peekString().equals("@")) { + long timestamp = args.getAs(Long.class); + for (IWaypoint iWaypoint : waypoints) { + if (iWaypoint.getCreationTimestamp() == timestamp) { + waypoint = iWaypoint; + break; + } + } + if (waypoint == null) { + throw new CommandInvalidStateException("Timestamp was specified but no waypoint was found"); + } + } else { + switch (waypoints.length) { + case 0: + throw new CommandInvalidStateException("No waypoints found"); + case 1: + waypoint = waypoints[0]; + break; + default: + break; + } + } + if (waypoint == null) { + throw new CommandInvalidStateException("Multiple waypoints were found"); + } else { + origin = waypoint.getLocation(); + } + } else { + origin = baritone.getPlayerContext().playerFeet(); + } + + baritone.getFarmProcess().farm(range, origin); logDirect("Farming"); } @@ -62,7 +107,8 @@ public class FarmCommand extends Command { "", "Usage:", "> farm - farms every crop it can find.", - "> farm 100 - farm crops within a 100 block radius from the starting position." + "> farm - farm crops within range from the starting position.", + "> farm - farm crops within range from waypoint." ); } } From 7032efcc05fe2280f57208129af4d37cef9ec68c Mon Sep 17 00:00:00 2001 From: GameCenterJerry <61768561+GameCenterJerry@users.noreply.github.com> Date: Thu, 22 Oct 2020 13:09:56 +1100 Subject: [PATCH 33/52] added jdk 8 instructions for macOS added necessary commands and download links --- SETUP.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/SETUP.md b/SETUP.md index ff16acbb9..ad1f3316f 100644 --- a/SETUP.md +++ b/SETUP.md @@ -49,6 +49,27 @@ On Mac OSX and Linux, use `./gradlew` instead of `gradlew`. If you have errors with a package missing please make sure you have setup your environment, and are using Oracle JDK 8. +To check which java you are using do +`java -version` in a command prompt or terminal. +If you are using Oracle JDK 8+ it will not work because the Java distributions above JDK 8 using may not have the needed javax classes. + +Oracle JDK 8 download: https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html +#### macOS guide +In order to get JDK 8, run the following command: +`% /usr/libexec/java_home -V` +If you see something like + +`% 1.8.0_202, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home` + +in the list then you've got JDK 8 installed. +In order to get JDK 8 running in the **current terminal window** you will have to run this command: + +`% export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)` + +You will have to compile the file in the same terminal window. + +#### Windows 10 guide (currently working on it) + Setting up the Environment: ``` From 07704b3ec7876cbf2704f44f65d9c4cac2699b71 Mon Sep 17 00:00:00 2001 From: GameCenterJerry <61768561+GameCenterJerry@users.noreply.github.com> Date: Thu, 22 Oct 2020 13:14:53 +1100 Subject: [PATCH 34/52] Update SETUP.md --- SETUP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SETUP.md b/SETUP.md index ad1f3316f..b23798a39 100644 --- a/SETUP.md +++ b/SETUP.md @@ -53,7 +53,7 @@ To check which java you are using do `java -version` in a command prompt or terminal. If you are using Oracle JDK 8+ it will not work because the Java distributions above JDK 8 using may not have the needed javax classes. -Oracle JDK 8 download: https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html +Open JDK 8 download: https://openjdk.java.net/install/ #### macOS guide In order to get JDK 8, run the following command: `% /usr/libexec/java_home -V` From cafb810a1f54cb30e7ca0e097824cf21bee7a23d Mon Sep 17 00:00:00 2001 From: GameCenterJerry <61768561+GameCenterJerry@users.noreply.github.com> Date: Thu, 22 Oct 2020 13:28:18 +1100 Subject: [PATCH 35/52] Update SETUP.md --- SETUP.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/SETUP.md b/SETUP.md index b23798a39..5e41432b1 100644 --- a/SETUP.md +++ b/SETUP.md @@ -51,23 +51,24 @@ If you have errors with a package missing please make sure you have setup your e To check which java you are using do `java -version` in a command prompt or terminal. -If you are using Oracle JDK 8+ it will not work because the Java distributions above JDK 8 using may not have the needed javax classes. +If you are using OpenJDK 8+ it will not work because the Java distributions above JDK 8 using may not have the needed javax classes. Open JDK 8 download: https://openjdk.java.net/install/ #### macOS guide -In order to get JDK 8, run the following command: +In order to get JDK 8, Try running the following command: `% /usr/libexec/java_home -V` +If it doesn't work try this guide: https://stackoverflow.com/questions/46513639/how-to-downgrade-java-from-9-to-8-on-a-macos-eclipse-is-not-running-with-java-9 + If you see something like -`% 1.8.0_202, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home` +`% 1.8.0_VERSION, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_VERSION.jdk/Contents/Home` in the list then you've got JDK 8 installed. In order to get JDK 8 running in the **current terminal window** you will have to run this command: `% export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)` -You will have to compile the file in the same terminal window. - +To add OpenJDK 8 to your PATH try this guide: http://www.sajeconsultants.com/how-to-set-java_home-on-mac-os-x/?utm_source=rss&utm_medium=rss&utm_campaign=how-to-set-java_home-on-mac-os-x. If you're using bash change the .bachrc and if you're using zsh change the .zshrc #### Windows 10 guide (currently working on it) Setting up the Environment: From 0bfd0bca0cd26e11dd45871480be9ead42a9ca01 Mon Sep 17 00:00:00 2001 From: GameCenterJerry <61768561+GameCenterJerry@users.noreply.github.com> Date: Thu, 22 Oct 2020 13:47:50 +1100 Subject: [PATCH 36/52] Update SETUP.md --- SETUP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SETUP.md b/SETUP.md index 5e41432b1..c09ad3682 100644 --- a/SETUP.md +++ b/SETUP.md @@ -68,7 +68,7 @@ In order to get JDK 8 running in the **current terminal window** you will have t `% export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)` -To add OpenJDK 8 to your PATH try this guide: http://www.sajeconsultants.com/how-to-set-java_home-on-mac-os-x/?utm_source=rss&utm_medium=rss&utm_campaign=how-to-set-java_home-on-mac-os-x. If you're using bash change the .bachrc and if you're using zsh change the .zshrc +To add OpenJDK 8 to your PATH add the export line to the end of your `.zshrc / .bashrc` if you want it to apply to each new terminal. If you're using bash change the .bachrc and if you're using zsh change the .zshrc #### Windows 10 guide (currently working on it) Setting up the Environment: From 14b75973b03735338d0644d07568423e5748feb8 Mon Sep 17 00:00:00 2001 From: GameCenterJerry <61768561+GameCenterJerry@users.noreply.github.com> Date: Thu, 22 Oct 2020 15:02:17 +1100 Subject: [PATCH 37/52] Update SETUP.md --- SETUP.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SETUP.md b/SETUP.md index c09ad3682..9d581aeed 100644 --- a/SETUP.md +++ b/SETUP.md @@ -51,7 +51,7 @@ If you have errors with a package missing please make sure you have setup your e To check which java you are using do `java -version` in a command prompt or terminal. -If you are using OpenJDK 8+ it will not work because the Java distributions above JDK 8 using may not have the needed javax classes. +If you are using anything above OpenJDK 8, it might not work because the Java distributions above JDK 8 using may not have the needed javax classes. Open JDK 8 download: https://openjdk.java.net/install/ #### macOS guide @@ -69,7 +69,6 @@ In order to get JDK 8 running in the **current terminal window** you will have t `% export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)` To add OpenJDK 8 to your PATH add the export line to the end of your `.zshrc / .bashrc` if you want it to apply to each new terminal. If you're using bash change the .bachrc and if you're using zsh change the .zshrc -#### Windows 10 guide (currently working on it) Setting up the Environment: From 9ca95e8e14ff76dd704b1cd138a61bbd7d0f8c98 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Wed, 28 Oct 2020 01:19:20 +0100 Subject: [PATCH 38/52] don't make non-forge jars valid mods (fixes #2124) --- build.gradle | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.gradle b/build.gradle index a91926ddb..0f9805469 100755 --- a/build.gradle +++ b/build.gradle @@ -117,6 +117,12 @@ javadoc { jar { from sourceSets.launch.output, sourceSets.api.output + + if (!getProject().hasProperty("baritone.forge_build")) { + exclude "**/BaritoneForgeModXD.class" + exclude "**/mods.toml" + } + preserveFileTimestamps = false reproducibleFileOrder = true From 320a5d64a3347a45b7b20055c16224506337331d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 30 Oct 2020 22:39:30 -0700 Subject: [PATCH 39/52] well i guess technically there could be an ore at bedrock level lmao --- 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 5bce121d8..ea35fd566 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -417,7 +417,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro } }) - .filter(pos -> pos.getY() > Baritone.settings().minYLevelWhileMining.value) + .filter(pos -> pos.getY() >= Baritone.settings().minYLevelWhileMining.value) .filter(pos -> !blacklist.contains(pos)) From 7218a46211c6e1e7a44625e1d1b1b5c4d4d03273 Mon Sep 17 00:00:00 2001 From: millennIumAMbiguity <37588844+millennIumAMbiguity@users.noreply.github.com> Date: Mon, 2 Nov 2020 00:33:31 +0100 Subject: [PATCH 40/52] Added defaults and javadocs --- .../baritone/api/process/IFarmProcess.java | 20 +++++++++++++++++++ .../command/defaults/FarmCommand.java | 5 +---- .../java/baritone/process/FarmProcess.java | 6 +++++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/api/java/baritone/api/process/IFarmProcess.java b/src/api/java/baritone/api/process/IFarmProcess.java index c9295b765..224307afa 100644 --- a/src/api/java/baritone/api/process/IFarmProcess.java +++ b/src/api/java/baritone/api/process/IFarmProcess.java @@ -21,5 +21,25 @@ import net.minecraft.util.math.BlockPos; public interface IFarmProcess extends IBaritoneProcess { + /** + * Begin to search for crops to farm with in specified aria + * from specified location. + * + * @param range The distance from center to farm from + * @param pos The center position to base the range from + */ void farm(int range, BlockPos pos); + + /** + * Begin to search for nearby crops to farm. + */ + default void farm() {farm(0, null);} + + /** + * Begin to search for crops to farm with in specified aria + * from the position the command was executed. + * + * @param range The distance to search for crops to farm + */ + default void farm(int range) {farm(range, null);} } diff --git a/src/main/java/baritone/command/defaults/FarmCommand.java b/src/main/java/baritone/command/defaults/FarmCommand.java index 37c6a78ef..9f841acdf 100644 --- a/src/main/java/baritone/command/defaults/FarmCommand.java +++ b/src/main/java/baritone/command/defaults/FarmCommand.java @@ -45,7 +45,7 @@ public class FarmCommand extends Command { public void execute(String label, IArgConsumer args) throws CommandException { args.requireMax(2); int range = 0; - BetterBlockPos origin; + BetterBlockPos origin = null; //range if (args.has(1)) { range = args.getAs(Integer.class); @@ -81,11 +81,8 @@ public class FarmCommand extends Command { } else { origin = waypoint.getLocation(); } - } else { - origin = baritone.getPlayerContext().playerFeet(); } - baritone.getFarmProcess().farm(range, origin); logDirect("Farming"); } diff --git a/src/main/java/baritone/process/FarmProcess.java b/src/main/java/baritone/process/FarmProcess.java index 599fa6df8..a8806d2ba 100644 --- a/src/main/java/baritone/process/FarmProcess.java +++ b/src/main/java/baritone/process/FarmProcess.java @@ -101,7 +101,11 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro @Override public void farm(int range, BlockPos pos) { - center = pos; + if (pos == null) { + center = baritone.getPlayerContext().playerFeet(); + } else { + center = pos; + } this.range = range; active = true; locations = null; From f4706fff18f73f171843dfd35fb041a6b5451d7f Mon Sep 17 00:00:00 2001 From: millennIumAMbiguity <37588844+millennIumAMbiguity@users.noreply.github.com> Date: Mon, 2 Nov 2020 01:25:25 +0100 Subject: [PATCH 41/52] Simplified and optimised code --- .../command/defaults/FarmCommand.java | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/main/java/baritone/command/defaults/FarmCommand.java b/src/main/java/baritone/command/defaults/FarmCommand.java index 9f841acdf..cae884b71 100644 --- a/src/main/java/baritone/command/defaults/FarmCommand.java +++ b/src/main/java/baritone/command/defaults/FarmCommand.java @@ -51,30 +51,17 @@ public class FarmCommand extends Command { range = args.getAs(Integer.class); } //waypoint - if (args.hasExactly(1)){ + if (args.has(1)){ IWaypoint[] waypoints = args.getDatatypeFor(ForWaypoints.INSTANCE); IWaypoint waypoint = null; - if (args.hasAny() && args.peekString().equals("@")) { - long timestamp = args.getAs(Long.class); - for (IWaypoint iWaypoint : waypoints) { - if (iWaypoint.getCreationTimestamp() == timestamp) { - waypoint = iWaypoint; - break; - } - } - if (waypoint == null) { - throw new CommandInvalidStateException("Timestamp was specified but no waypoint was found"); - } - } else { - switch (waypoints.length) { - case 0: - throw new CommandInvalidStateException("No waypoints found"); - case 1: - waypoint = waypoints[0]; - break; - default: - break; - } + switch (waypoints.length) { + case 0: + throw new CommandInvalidStateException("No waypoints found"); + case 1: + waypoint = waypoints[0]; + break; + default: + break; } if (waypoint == null) { throw new CommandInvalidStateException("Multiple waypoints were found"); From 853b5ca77175d74f5e21699c3c7d2b46b8ec0f23 Mon Sep 17 00:00:00 2001 From: millennIumAMbiguity <37588844+millennIumAMbiguity@users.noreply.github.com> Date: Mon, 2 Nov 2020 01:44:12 +0100 Subject: [PATCH 42/52] Moved throw up into the default: --- src/main/java/baritone/command/defaults/FarmCommand.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/command/defaults/FarmCommand.java b/src/main/java/baritone/command/defaults/FarmCommand.java index cae884b71..1903f89f3 100644 --- a/src/main/java/baritone/command/defaults/FarmCommand.java +++ b/src/main/java/baritone/command/defaults/FarmCommand.java @@ -61,13 +61,9 @@ public class FarmCommand extends Command { waypoint = waypoints[0]; break; default: - break; - } - if (waypoint == null) { - throw new CommandInvalidStateException("Multiple waypoints were found"); - } else { - origin = waypoint.getLocation(); + throw new CommandInvalidStateException("Multiple waypoints were found"); } + origin = waypoint.getLocation(); } baritone.getFarmProcess().farm(range, origin); From c491d679252887e2d5153a6acfc3751c28419a8d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 11 Nov 2020 17:53:11 -0800 Subject: [PATCH 43/52] add setting to just skip layers that the builder fails to construct --- src/api/java/baritone/api/Settings.java | 5 +++++ src/main/java/baritone/process/BuilderProcess.java | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 96e4c5790..69b7e5527 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -814,6 +814,11 @@ public final class Settings { */ public final Setting startAtLayer = new Setting<>(0); + /** + * If a layer is unable to be constructed, just skip it. + */ + public final Setting skipFailedLayers = new Setting<>(false); + /** * How far to move before repeating the build. 0 to disable repeating on a certain axis, 0,0,0 to disable entirely */ diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index e0dbe4c7c..00d3831ce 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -484,6 +484,11 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil if (goal == null) { goal = assemble(bcc, approxPlaceable); // we're far away, so assume that we have our whole inventory to recalculate placeable properly if (goal == null) { + if (Baritone.settings().skipFailedLayers.value && Baritone.settings().buildInLayers.value && layer < realSchematic.heightY()) { + logDirect("Skipping layer that I cannot construct! Layer #" + layer); + layer++; + return onTick(calcFailed, isSafeToCancel); + } logDirect("Unable to do it. Pausing. resume to resume, cancel to cancel"); paused = true; return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE); From a99206b6c206f9cc4a62b31cec0977fc273d2902 Mon Sep 17 00:00:00 2001 From: unrootexe <37210633+unrootexe@users.noreply.github.com> Date: Mon, 16 Nov 2020 17:18:32 +0000 Subject: [PATCH 44/52] Update rootNET's supported version rootNET supports the latest version of Baritone, this change reflects that --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 803816090..f95d37cca 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ [![KAMI Blue integration](https://img.shields.io/badge/KAMI%20Blue%20integration-v1.2.14--master-green)](https://github.com/kami-blue/client) [![ForgeHax integration](https://img.shields.io/badge/ForgeHax%20%22integration%22-scuffed-yellow.svg)](https://github.com/fr1kin/ForgeHax/) [![Aristois add-on integration](https://img.shields.io/badge/Aristois%20add--on%20integration-v1.3.4%20/%20v1.4.1-green.svg)](https://gitlab.com/emc-mods-indrit/baritone_api) -[![rootNET integration](https://img.shields.io/badge/rootNET%20integration-v1.2.11-green.svg)](https://rootnet.dev/) +[![rootNET integration](https://img.shields.io/badge/rootNET%20integration-v1.2.14-green.svg)](https://rootnet.dev/) [![Future integration](https://img.shields.io/badge/Future%20integration-v1.2.12%20%2F%20v1.3.6%20%2F%20v1.4.4-red)](https://futureclient.net/) [![RusherHack integration](https://img.shields.io/badge/RusherHack%20integration-v1.2.14-green)](https://rusherhack.org/) [![forthebadge](https://forthebadge.com/images/badges/built-with-swag.svg)](http://forthebadge.com/) From 16cfcb36a3cf7ce4063740498cf45efcd6f1c463 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 29 Nov 2020 20:04:44 -0800 Subject: [PATCH 45/52] Update USAGE.md --- USAGE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/USAGE.md b/USAGE.md index b58744284..813746d75 100644 --- a/USAGE.md +++ b/USAGE.md @@ -41,7 +41,7 @@ Some common examples: - `cancel` or `stop` to stop everything - `goto portal` or `goto ender_chest` or `goto block_type` to go to a block. (in Impact, `.goto` is an alias for `.b goto` for the most part) - `mine diamond_ore iron_ore` to mine diamond ore or iron ore (turn on the setting `legitMine` to only mine ores that it can actually see. It will explore randomly around y=11 until it finds them.) An amount of blocks can also be specified, for example, `mine diamond_ore 64`. -- `click` to click your destination on the screen. Right click path to on top of the block, left click to path into it (either at foot level or eye level), and left click and drag to clear all blocks from an area. +- `click` to click your destination on the screen. Right click path to on top of the block, left click to path into it (either at foot level or eye level), and left click and drag to select an area (`#help sel` to see what you can do with that selection). - `follow player playerName` to follow a player. `follow players` to follow any players in range (combine with Kill Aura for a fun time). `follow entities` to follow any entities. `follow entity pig` to follow entities of a specific type. - `wp` for waypoints. A "tag" is like "home" (created automatically on right clicking a bed) or "death" (created automatically on death) or "user" (has to be created manually). So you might want `#wp save user coolbiome`, then to set the goal `#wp goal coolbiome` then `#path` to path to it. For death, `#wp goal death` will list waypoints under the "death" tag (remember stuff is clickable!) - `build` to build a schematic. `build blah.schematic` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah.schematic x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420). From dc70d810c96af5554992a31ecea4e029ae146986 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 24 Dec 2020 21:33:11 -0800 Subject: [PATCH 46/52] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f95d37cca..5ef290188 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,8 @@ The easiest way to install Baritone is to install [Impact](https://impactclient. For 1.15.2, [click here](https://www.youtube.com/watch?v=j1qKtCZFURM) and see description. If you need Forge 1.15.2, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.5.3), follow the instructions, and get the `api-forge` jar. +For 1.16.4, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. If you need Forge 1.14.4, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.6.2) and get the `api-forge` jar. + This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/), the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 through 1.15.2. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). From b6265036d4fb8a251d16ee93937da9e81bec4d95 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 24 Dec 2020 21:33:29 -0800 Subject: [PATCH 47/52] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5ef290188..29e9e5fa3 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ The easiest way to install Baritone is to install [Impact](https://impactclient. For 1.15.2, [click here](https://www.youtube.com/watch?v=j1qKtCZFURM) and see description. If you need Forge 1.15.2, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.5.3), follow the instructions, and get the `api-forge` jar. -For 1.16.4, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. If you need Forge 1.14.4, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.6.2) and get the `api-forge` jar. +For 1.16.4, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. If you need Forge 1.16.4, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.6.2) and get the `api-forge` jar. This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/), the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 through 1.15.2. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). From 72cf9392b16884005ffc2d83c68dacc39832723c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 24 Dec 2020 21:34:02 -0800 Subject: [PATCH 48/52] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 29e9e5fa3..f709a3d81 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ [![Minecraft](https://img.shields.io/badge/MC-1.13.2-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.13.2/) [![Minecraft](https://img.shields.io/badge/MC-1.14.4-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.14.4/) [![Minecraft](https://img.shields.io/badge/MC-1.15.2-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.15.2/) +[![Minecraft](https://img.shields.io/badge/MC-1.16.4-brightgreen.svg)](https://github.com/cabaletta/baritone/tree/1.16.4/) [![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/) @@ -42,7 +43,7 @@ For 1.15.2, [click here](https://www.youtube.com/watch?v=j1qKtCZFURM) and see de For 1.16.4, [click here](https://www.youtube.com/watch?v=_4eVJ9Qz2J8) and see description. If you need Forge 1.16.4, look [here](https://github.com/cabaletta/baritone/releases/tag/v1.6.2) and get the `api-forge` jar. This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/), -the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 through 1.15.2. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). +the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 through 1.16.4. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). Have committed at least once a day from Aug 1, 2018, to Aug 1, 2019. From 79e0f4ba2380df55b713205fdd755eb28ccfdb3f Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Fri, 15 Jan 2021 12:52:25 +0100 Subject: [PATCH 49/52] Log blocks it can't place --- .../java/baritone/process/BuilderProcess.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 00d3831ce..deccf5041 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -58,6 +58,7 @@ import net.minecraft.util.math.*; import java.io.File; import java.io.FileInputStream; import java.util.*; +import java.util.stream.Collectors; import static baritone.api.pathing.movement.ActionCosts.COST_INF; @@ -482,7 +483,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil Goal goal = assemble(bcc, approxPlaceable.subList(0, 9)); if (goal == null) { - goal = assemble(bcc, approxPlaceable); // we're far away, so assume that we have our whole inventory to recalculate placeable properly + goal = assemble(bcc, approxPlaceable, true); // we're far away, so assume that we have our whole inventory to recalculate placeable properly if (goal == null) { if (Baritone.settings().skipFailedLayers.value && Baritone.settings().buildInLayers.value && layer < realSchematic.heightY()) { logDirect("Skipping layer that I cannot construct! Layer #" + layer); @@ -586,14 +587,23 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil } private Goal assemble(BuilderCalculationContext bcc, List approxPlaceable) { + return assemble(bcc, approxPlaceable, false); + } + + private Goal assemble(BuilderCalculationContext bcc, List approxPlaceable, boolean logMissing) { List placeable = new ArrayList<>(); List breakable = new ArrayList<>(); List sourceLiquids = new ArrayList<>(); + List flowingLiquids = new ArrayList<>(); + Map missing = new HashMap<>(); incorrectPositions.forEach(pos -> { IBlockState state = bcc.bsi.get0(pos); if (state.getBlock() instanceof BlockAir) { if (approxPlaceable.contains(bcc.getSchematic(pos.x, pos.y, pos.z, state))) { placeable.add(pos); + } else { + IBlockState desired = bcc.getSchematic(pos.x, pos.y, pos.z, state); + missing.put(desired, 1 + missing.getOrDefault(desired, 0)); } } else { if (state.getBlock() instanceof BlockLiquid) { @@ -602,6 +612,8 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil if (!MovementHelper.possiblyFlowing(state)) { // if it's a source block then we want to replace it with a throwaway sourceLiquids.add(pos); + } else { + flowingLiquids.add(pos); } } else { breakable.add(pos); @@ -622,6 +634,18 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil return new JankyGoalComposite(new GoalComposite(toPlace.toArray(new Goal[0])), new GoalComposite(toBreak.toArray(new Goal[0]))); } if (toBreak.isEmpty()) { + if (logMissing && !missing.isEmpty()) { + logDirect("Missing materials for at least:"); + logDirect(missing.entrySet().stream() + .map(e -> String.format("%sx %s", e.getValue(), e.getKey())) + .collect(Collectors.joining("\n"))); + } + if (logMissing && !flowingLiquids.isEmpty()) { + logDirect("Unreplaceable liquids at at least:"); + logDirect(flowingLiquids.stream() + .map(p -> String.format("%s %s %s", p.x, p.y, p.z)) + .collect(Collectors.joining("\n"))); + } return null; } return new GoalComposite(toBreak.toArray(new Goal[0])); From 33d007eea5fb9ba5b87de3e6134ccf98a7828d39 Mon Sep 17 00:00:00 2001 From: Bram Avontuur Date: Sat, 16 Jan 2021 11:34:12 -0500 Subject: [PATCH 50/52] Add instructions to build with forge for minecraft 1.15+ --- SETUP.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/SETUP.md b/SETUP.md index 9d581aeed..8e18eddb7 100644 --- a/SETUP.md +++ b/SETUP.md @@ -83,6 +83,12 @@ Building Baritone: $ gradlew build ``` +For minecrat 1.15.2+, run the following instead to include the Forge jars: + +``` +$ gradlew build -Pbaritone.forge_build +``` + Running Baritone: ``` From 0222c47113369d23eea7c1aca951a07bd7105c66 Mon Sep 17 00:00:00 2001 From: Bram Avontuur Date: Sun, 17 Jan 2021 11:40:52 -0500 Subject: [PATCH 51/52] Typo fix --- SETUP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SETUP.md b/SETUP.md index 8e18eddb7..e7ef6c274 100644 --- a/SETUP.md +++ b/SETUP.md @@ -83,7 +83,7 @@ Building Baritone: $ gradlew build ``` -For minecrat 1.15.2+, run the following instead to include the Forge jars: +For minecraft 1.15.2+, run the following instead to include the Forge jars: ``` $ gradlew build -Pbaritone.forge_build From 364b7b54383f7d98e72bee156c07cd09541d7a57 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Thu, 21 Jan 2021 15:39:37 +0100 Subject: [PATCH 52/52] Correct usage for mining a specific amount Found and fixed by @CesiumCs --- USAGE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/USAGE.md b/USAGE.md index 813746d75..35aa90a7b 100644 --- a/USAGE.md +++ b/USAGE.md @@ -40,7 +40,7 @@ Some common examples: - `goal clear` to clear the goal - `cancel` or `stop` to stop everything - `goto portal` or `goto ender_chest` or `goto block_type` to go to a block. (in Impact, `.goto` is an alias for `.b goto` for the most part) -- `mine diamond_ore iron_ore` to mine diamond ore or iron ore (turn on the setting `legitMine` to only mine ores that it can actually see. It will explore randomly around y=11 until it finds them.) An amount of blocks can also be specified, for example, `mine diamond_ore 64`. +- `mine diamond_ore iron_ore` to mine diamond ore or iron ore (turn on the setting `legitMine` to only mine ores that it can actually see. It will explore randomly around y=11 until it finds them.) An amount of blocks can also be specified, for example, `mine 64 diamond_ore`. - `click` to click your destination on the screen. Right click path to on top of the block, left click to path into it (either at foot level or eye level), and left click and drag to select an area (`#help sel` to see what you can do with that selection). - `follow player playerName` to follow a player. `follow players` to follow any players in range (combine with Kill Aura for a fun time). `follow entities` to follow any entities. `follow entity pig` to follow entities of a specific type. - `wp` for waypoints. A "tag" is like "home" (created automatically on right clicking a bed) or "death" (created automatically on death) or "user" (has to be created manually). So you might want `#wp save user coolbiome`, then to set the goal `#wp goal coolbiome` then `#path` to path to it. For death, `#wp goal death` will list waypoints under the "death" tag (remember stuff is clickable!)