From 7d9b8ee4f3ef7138366270771f3e685ffba5c237 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 28 Apr 2019 21:38:10 -0700 Subject: [PATCH 01/45] that was too high tbh lol --- 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 afd6a0db..cfade96a 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -84,7 +84,7 @@ public final class Settings { /** * Walking on water uses up hunger really quick, so penalize it */ - public final Setting walkOnWaterOnePenalty = new Setting<>(5D); + public final Setting walkOnWaterOnePenalty = new Setting<>(3D); /** * Allow Baritone to fall arbitrary distances and place a water bucket beneath it. From b338dcc9de32f56e245420a86584ef799defa8d3 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 29 Apr 2019 11:46:21 -0700 Subject: [PATCH 02/45] add path splice option --- src/api/java/baritone/api/Settings.java | 10 ++++++++++ src/main/java/baritone/behavior/PathingBehavior.java | 4 +++- src/main/java/baritone/pathing/path/PathExecutor.java | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index cfade96a..53634e35 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -572,6 +572,16 @@ public final class Settings { */ public final Setting walkWhileBreaking = new Setting<>(true); + /** + * When a new segment is calculated that doesn't overlap with the current one, but simply begins where the current segment ends, + * splice it on and make a longer combined path. If this setting is off, any planned segment will not be spliced and will instead + * be the "next path" in PathingBehavior, and will only start after this one ends. Turning this off hurts planning ahead, + * because the next segment will exist even if it's very short. + * + * @see #planningTickLookahead + */ + public final Setting splicePath = new Setting<>(true); + /** * If we are more than 300 movements into the current path, discard the oldest segments, as they are no longer useful */ diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index e0031c8c..fbe48ad8 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -195,7 +195,9 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, current.onTick(); return; } - current = current.trySplice(next); + if (Baritone.settings().splicePath.value) { + current = current.trySplice(next); + } if (next != null && current.getPath().getDest().equals(next.getPath().getDest())) { next = null; } diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index c848f42b..852ac44e 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -610,7 +610,7 @@ public class PathExecutor implements IPathExecutor, Helper { ret.costEstimateIndex = costEstimateIndex; ret.ticksOnCurrent = ticksOnCurrent; return ret; - }).orElse(cutIfTooLong()); + }).orElseGet(this::cutIfTooLong); // dont actually call cutIfTooLong every tick if we won't actually use it, use a method reference } private PathExecutor cutIfTooLong() { From 85eb7d804351b3873cb180026fc272fc78069631 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 29 Apr 2019 14:55:14 -0700 Subject: [PATCH 03/45] remember beyond render distance what is completed --- .../java/baritone/process/BuilderProcess.java | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 6185b300..7988ff15 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -35,6 +35,7 @@ import baritone.utils.BlockStateInterface; import baritone.utils.PathingCommandContext; import baritone.utils.schematic.AirSchematic; import baritone.utils.schematic.Schematic; +import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; @@ -56,6 +57,7 @@ import static baritone.api.pathing.movement.ActionCosts.COST_INF; public class BuilderProcess extends BaritoneProcessHelper implements IBuilderProcess { private HashSet incorrectPositions; + private LongOpenHashSet observedCompleted; // positions that are completed even if they're out of render distance and we can't make sure right now private String name; private ISchematic realSchematic; private ISchematic schematic; @@ -76,6 +78,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro this.origin = origin; this.paused = false; this.layer = 0; + this.observedCompleted = new LongOpenHashSet(); } public void resume() { @@ -447,10 +450,13 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro IBlockState desired = bcc.getSchematic(x, y, z); if (desired != null) { // we care about this position + BetterBlockPos pos = new BetterBlockPos(x, y, z); if (valid(bcc.bsi.get0(x, y, z), desired)) { - incorrectPositions.remove(new BetterBlockPos(x, y, z)); + incorrectPositions.remove(pos); + observedCompleted.add(BetterBlockPos.longHash(pos)); } else { - incorrectPositions.add(new BetterBlockPos(x, y, z)); + incorrectPositions.add(pos); + observedCompleted.rem(BetterBlockPos.longHash(pos)); } } } @@ -463,8 +469,27 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro for (int y = 0; y < schematic.heightY(); y++) { for (int z = 0; z < schematic.lengthZ(); z++) { for (int x = 0; x < schematic.widthX(); x++) { - if (schematic.inSchematic(x, y, z) && !valid(bcc.bsi.get0(x + origin.getX(), y + origin.getY(), z + origin.getZ()), schematic.desiredState(x, y, z))) { - incorrectPositions.add(new BetterBlockPos(x + origin.getX(), y + origin.getY(), z + origin.getZ())); + if (!schematic.inSchematic(x, y, z)) { + continue; + } + int blockX = x + origin.getX(); + int blockY = y + origin.getY(); + int blockZ = z + origin.getZ(); + if (bcc.bsi.worldContainsLoadedChunk(blockX, blockZ)) { // check if its in render distance, not if its in cache + // we can directly observe this block, it is in render distance + if (valid(bcc.bsi.get0(blockX, blockY, blockZ), schematic.desiredState(x, y, z))) { + observedCompleted.add(BetterBlockPos.longHash(blockX, blockY, blockZ)); + } else { + incorrectPositions.add(new BetterBlockPos(blockX, blockY, blockZ)); + observedCompleted.rem(BetterBlockPos.longHash(blockX, blockY, blockZ)); + } + continue; + } + // this is not in render distance + if (!observedCompleted.contains(BetterBlockPos.longHash(blockX, blockY, blockZ))) { + // and we've never seen this position be correct + // therefore mark as incorrect + incorrectPositions.add(new BetterBlockPos(blockX, blockY, blockZ)); } } } @@ -587,6 +612,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro realSchematic = null; layer = 0; paused = false; + observedCompleted = null; } @Override From 9bf3a041d47ab89578bc2ee0da3dc86c52d4637d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 29 Apr 2019 14:59:25 -0700 Subject: [PATCH 04/45] might as well privatize --- .../java/baritone/process/BuilderProcess.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 7988ff15..fa7c9912 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -135,9 +135,8 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro } return state; } - - - public Optional> toBreakNearPlayer(BuilderCalculationContext bcc) { + + private Optional> toBreakNearPlayer(BuilderCalculationContext bcc) { BetterBlockPos center = ctx.playerFeet(); for (int dx = -5; dx <= 5; dx++) { for (int dy = 0; dy <= 5; dy++) { @@ -177,7 +176,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro } } - public Optional searchForPlacables(BuilderCalculationContext bcc, List desirableOnHotbar) { + private Optional searchForPlacables(BuilderCalculationContext bcc, List desirableOnHotbar) { BetterBlockPos center = ctx.playerFeet(); for (int dx = -5; dx <= 5; dx++) { for (int dy = -5; dy <= 1; dy++) { @@ -206,7 +205,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro return Optional.empty(); } - public Optional possibleToPlace(IBlockState toPlace, int x, int y, int z, BlockStateInterface bsi) { + private Optional possibleToPlace(IBlockState toPlace, int x, int y, int z, BlockStateInterface bsi) { for (EnumFacing against : EnumFacing.values()) { BetterBlockPos placeAgainstPos = new BetterBlockPos(x, y, z).offset(against); IBlockState placeAgainstState = bsi.get0(placeAgainstPos); @@ -234,8 +233,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro return Optional.empty(); } - - public OptionalInt hasAnyItemThatWouldPlace(IBlockState desired, RayTraceResult result, Rotation rot) { + private OptionalInt hasAnyItemThatWouldPlace(IBlockState desired, RayTraceResult result, Rotation rot) { for (int i = 0; i < 9; i++) { ItemStack stack = ctx.player().inventory.mainInventory.get(i); if (stack.isEmpty() || !(stack.getItem() instanceof ItemBlock)) { @@ -416,7 +414,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro return new PathingCommandContext(goal, PathingCommandType.FORCE_REVALIDATE_GOAL_AND_PATH, bcc); } - public boolean recalc(BuilderCalculationContext bcc) { + private boolean recalc(BuilderCalculationContext bcc) { if (incorrectPositions == null) { incorrectPositions = new HashSet<>(); fullRecalc(bcc); @@ -431,7 +429,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro return !incorrectPositions.isEmpty(); } - public void trim(BuilderCalculationContext bcc) { + private void trim(BuilderCalculationContext bcc) { HashSet copy = new HashSet<>(incorrectPositions); copy.removeIf(pos -> pos.distanceSq(ctx.player().posX, ctx.player().posY, ctx.player().posZ) > 200); if (!copy.isEmpty()) { @@ -439,7 +437,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro } } - public void recalcNearby(BuilderCalculationContext bcc) { + private void recalcNearby(BuilderCalculationContext bcc) { BetterBlockPos center = ctx.playerFeet(); for (int dx = -5; dx <= 5; dx++) { for (int dy = -5; dy <= 5; dy++) { @@ -464,7 +462,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro } } - public void fullRecalc(BuilderCalculationContext bcc) { + private void fullRecalc(BuilderCalculationContext bcc) { incorrectPositions = new HashSet<>(); for (int y = 0; y < schematic.heightY(); y++) { for (int z = 0; z < schematic.lengthZ(); z++) { @@ -553,7 +551,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro } } - public Goal placementgoal(BlockPos pos, BuilderCalculationContext bcc) { + private Goal placementgoal(BlockPos pos, BuilderCalculationContext bcc) { if (ctx.world().getBlockState(pos).getBlock() != Blocks.AIR) { return new GoalPlace(pos); } @@ -620,7 +618,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro return paused ? "Builder Paused" : "Building " + name; } - public List placable(int size) { + private List placable(int size) { List result = new ArrayList<>(); for (int i = 0; i < size; i++) { ItemStack stack = ctx.player().inventory.mainInventory.get(i); @@ -635,7 +633,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro return result; } - public boolean valid(IBlockState current, IBlockState desired) { + private boolean valid(IBlockState current, IBlockState desired) { // TODO more complicated comparison logic I guess return desired == null || current.equals(desired); } From f7a577e1632273942a42d977da65531695b0f987 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 29 Apr 2019 16:02:44 -0700 Subject: [PATCH 05/45] break from above --- src/api/java/baritone/api/Settings.java | 14 ++++++++ .../java/baritone/process/BuilderProcess.java | 32 +++++++++++++++---- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 53634e35..8f2b31b1 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -654,6 +654,20 @@ public final class Settings { */ public final Setting buildRepeatDirection = new Setting<>(EnumFacing.NORTH); + /** + * Allow standing above a block while mining it, in BuilderProcess + *

+ * Experimental + */ + public final Setting breakFromAbove = new Setting<>(false); + + /** + * As well as breaking from above, set a goal to up and to the side of all blocks to break. + *

+ * Never turn this on without also turning on breakFromAbove. + */ + public final Setting goalBreakFromAbove = new Setting<>(false); + /** * While mining, should it also consider dropped items of the correct type as a pathing destination (as well as ore blocks)? */ diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index fa7c9912..9f49c595 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -36,6 +36,7 @@ import baritone.utils.PathingCommandContext; import baritone.utils.schematic.AirSchematic; import baritone.utils.schematic.Schematic; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; +import net.minecraft.block.BlockAir; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; @@ -135,15 +136,19 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro } return state; } - + private Optional> toBreakNearPlayer(BuilderCalculationContext bcc) { BetterBlockPos center = ctx.playerFeet(); + BetterBlockPos pathStart = baritone.getPathingBehavior().pathStart(); for (int dx = -5; dx <= 5; dx++) { - for (int dy = 0; dy <= 5; dy++) { + for (int dy = Baritone.settings().breakFromAbove.value ? -1 : 0; dy <= 5; dy++) { for (int dz = -5; dz <= 5; dz++) { int x = center.x + dx; int y = center.y + dy; int z = center.z + dz; + if (dy == -1 && x == pathStart.x && z == pathStart.z) { + continue; // dont mine what we're supported by, but not directly standing on + } IBlockState desired = bcc.getSchematic(x, y, z); if (desired == null) { continue; // irrelevant @@ -496,8 +501,8 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro private Goal assemble(BuilderCalculationContext bcc, List approxPlacable) { List placable = incorrectPositions.stream().filter(pos -> bcc.bsi.get0(pos).getBlock() == Blocks.AIR && approxPlacable.contains(bcc.getSchematic(pos.x, pos.y, pos.z))).collect(Collectors.toList()); - Goal[] toBreak = incorrectPositions.stream().filter(pos -> bcc.bsi.get0(pos).getBlock() != Blocks.AIR).map(GoalBreak::new).toArray(Goal[]::new); - Goal[] toPlace = placable.stream().filter(pos -> !placable.contains(pos.down()) && !placable.contains(pos.down(2))).map(pos -> placementgoal(pos, bcc)).toArray(Goal[]::new); + Goal[] toBreak = incorrectPositions.stream().filter(pos -> bcc.bsi.get0(pos).getBlock() != Blocks.AIR).map(pos -> breakGoal(pos, bcc)).toArray(Goal[]::new); + Goal[] toPlace = placable.stream().filter(pos -> !placable.contains(pos.down()) && !placable.contains(pos.down(2))).map(pos -> placementGoal(pos, bcc)).toArray(Goal[]::new); if (toPlace.length != 0) { return new JankyGoalComposite(new GoalComposite(toPlace), new GoalComposite(toBreak)); @@ -551,8 +556,8 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro } } - private Goal placementgoal(BlockPos pos, BuilderCalculationContext bcc) { - if (ctx.world().getBlockState(pos).getBlock() != Blocks.AIR) { + private Goal placementGoal(BlockPos pos, BuilderCalculationContext bcc) { + if (ctx.world().getBlockState(pos).getBlock() != Blocks.AIR) { // TODO can this even happen? return new GoalPlace(pos); } boolean allowSameLevel = ctx.world().getBlockState(pos.up()).getBlock() != Blocks.AIR; @@ -564,6 +569,21 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro return new GoalPlace(pos); } + private Goal breakGoal(BlockPos pos, BuilderCalculationContext bcc) { + if (Baritone.settings().goalBreakFromAbove.value && bcc.bsi.get0(pos.up()).getBlock() instanceof BlockAir && bcc.bsi.get0(pos.up(2)).getBlock() instanceof BlockAir) { // TODO maybe possible without the up(2) check? + return new JankyGoalComposite(new GoalBreak(pos), new GoalGetToBlock(pos.up()) { + @Override + public boolean isInGoal(int x, int y, int z) { + if (y > this.y || (x == this.x && y == this.y && z == this.z)) { + return false; + } + return super.isInGoal(x, y, z); + } + }); + } + return new GoalBreak(pos); + } + public static class GoalAdjacent extends GoalGetToBlock { private boolean allowSameLevel; From c931cde3ae66b3a45b025e47eecdfb746d5e8100 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 29 Apr 2019 16:43:47 -0700 Subject: [PATCH 06/45] fix error stacktrace on startup --- src/api/java/baritone/api/utils/SettingsUtil.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/api/java/baritone/api/utils/SettingsUtil.java b/src/api/java/baritone/api/utils/SettingsUtil.java index 8667f554..3f4de317 100644 --- a/src/api/java/baritone/api/utils/SettingsUtil.java +++ b/src/api/java/baritone/api/utils/SettingsUtil.java @@ -29,6 +29,7 @@ import java.io.IOException; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.nio.file.Files; +import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; @@ -80,6 +81,8 @@ public class SettingsUtil { ex.printStackTrace(); } }); + } catch (NoSuchFileException ignored) { + System.out.println("Baritone settings file not found, resetting."); } catch (Exception ex) { System.out.println("Exception while reading Baritone settings, some settings may be reset to default values!"); ex.printStackTrace(); From 920ce745c22aec543d573e5cf26ee1f8046cef44 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 29 Apr 2019 23:08:17 -0700 Subject: [PATCH 07/45] fix some scuff from minebot --- src/api/java/baritone/api/Settings.java | 9 ++++++--- .../java/baritone/pathing/movement/MovementHelper.java | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 8f2b31b1..d292e868 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -160,9 +160,12 @@ public final class Settings { /** * Blocks that Baritone is not allowed to break */ - public final Setting> blocksToAvoidBreaking = new Setting<>(new ArrayList<>( - // e.g. crafting table, beds - )); + public final Setting> blocksToAvoidBreaking = new Setting<>(new ArrayList<>(Arrays.asList( + Blocks.CRAFTING_TABLE, + Blocks.FURNACE, + Blocks.LIT_FURNACE, + Blocks.CHEST + ))); /** * Enables some more advanced vine features. They're honestly just gimmicks and won't ever be needed in real diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index c0683d47..b7be8636 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -18,6 +18,7 @@ package baritone.pathing.movement; import baritone.Baritone; +import baritone.api.BaritoneAPI; import baritone.api.IBaritone; import baritone.api.pathing.movement.ActionCosts; import baritone.api.pathing.movement.MovementStatus; @@ -55,8 +56,7 @@ public interface MovementHelper extends ActionCosts, Helper { || bsi.get0(x + 1, y, z).getBlock() instanceof BlockLiquid || bsi.get0(x - 1, y, z).getBlock() instanceof BlockLiquid || bsi.get0(x, y, z + 1).getBlock() instanceof BlockLiquid - || bsi.get0(x, y, z - 1).getBlock() instanceof BlockLiquid - || Baritone.settings().blocksToAvoidBreaking.value.contains(b); + || bsi.get0(x, y, z - 1).getBlock() instanceof BlockLiquid; } static boolean canWalkThrough(IPlayerContext ctx, BetterBlockPos pos) { @@ -363,7 +363,7 @@ public interface MovementHelper extends ActionCosts, Helper { if (block instanceof BlockLiquid) { return COST_INF; } - double m = Blocks.CRAFTING_TABLE.equals(block) ? 10 : 1; // TODO see if this is still necessary. it's from MineBot when we wanted to penalize breaking its crafting table + double m = Baritone.settings().blocksToAvoidBreaking.value.contains(block) ? 10 : 1; double strVsBlock = context.toolSet.getStrVsBlock(state); if (strVsBlock <= 0) { return COST_INF; From 166eb97c3fd882fd25cc14702bff0482b983887f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 30 Apr 2019 16:52:27 -0700 Subject: [PATCH 08/45] make right click on arrival time out after 1 second --- src/main/java/baritone/process/GetToBlockProcess.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/baritone/process/GetToBlockProcess.java b/src/main/java/baritone/process/GetToBlockProcess.java index 0116df83..69703894 100644 --- a/src/main/java/baritone/process/GetToBlockProcess.java +++ b/src/main/java/baritone/process/GetToBlockProcess.java @@ -42,6 +42,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl private BlockPos start; private int tickCount = 0; + private int arrivalTickCount = 0; public GetToBlockProcess(Baritone baritone) { super(baritone); @@ -53,6 +54,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl gettingTo = block; start = ctx.playerFeet(); blacklist = new ArrayList<>(); + arrivalTickCount = 0; rescan(new ArrayList<>(), new CalculationContext(baritone)); } @@ -196,6 +198,10 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl return true; } } + if (arrivalTickCount++ > 20) { + logDirect("Right click timed out"); + return true; + } return false; // trying to right click, will do it next tick or so } } From a14166b1e28f552b035564a4f797ce0c4e041513 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 30 Apr 2019 16:56:29 -0700 Subject: [PATCH 09/45] overhaul to usage --- USAGE.md | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/USAGE.md b/USAGE.md index 085f49c2..652c093e 100644 --- a/USAGE.md +++ b/USAGE.md @@ -34,15 +34,18 @@ 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` to mine diamond 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.) -- `click` to click your destination on the screen. left click to path into it, right click to path on top of it. left click and drag to clear 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 clear all blocks from an area. - `follow playerName` to follow a player. `follow` to follow the entity you're looking at (only works if it hitting range). `followplayers` to follow any players in range (combine with Kill Aura for a fun time). - `save waypointName` to save a waypoint. `goto waypointName` to go to it. +- `build` to build a schematic. `build blah` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420). +- `tunnel` to dig just straight ahead and make a tunnel +- `farm` to automatically harvest, replant, or bone meal crops - `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120). +- `explore x z` to explore the world from the origin of x,z. Leave out x and z to default to player feet. This will continually path towards the closest chunk to the origin that it's never seen before. `explorefilter filter.json` with optional invert can be used to load in a list of chunks to load. - `invert` to invert the current goal and path. This gets as far away from it as possible, instead of as close as possible. For example, do `goal` then `invert` to run as far as possible from where you're standing at the start. -- `render` to rerender the world in case `renderCachedChunks` is being glitchy - `version` to get the version of Baritone you're running - `damn` daniel -- `build` to build a schematic. `build blah` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420). + For the rest of the commands, you can take a look at the code [here](https://github.com/cabaletta/baritone/blob/master/src/main/java/baritone/utils/ExampleBaritoneControl.java). @@ -54,10 +57,18 @@ There are about a hundred settings, but here are some fun / interesting / import - `allowPlace` - `allowParkour` - `allowParkourPlace` +- `blockPlacementPenalty` - `renderCachedChunks` (and `cachedChunksOpacity`) <-- very fun but you need a beefy computer -- `avoidance` +- `avoidance` (avoidance of mobs / mob spawners) - `legitMine` - `followRadius` +- `backfill` (fill in tunnels behind you) +- `buildInLayers` +- `buildRepeatDistance` and `buildRepeatDirection` +- `worldExploringChunkOffset` +- `acceptableThrowawayItems` +- `blocksToAvoidBreaking` + From 7b7be32ca77d4289dc4d17501563aea18bb50783 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 30 Apr 2019 23:24:08 -0700 Subject: [PATCH 10/45] also break passable blocks at foot level like mushrooms, fixes #407 --- 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 6051fe4a..72abfe9d 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -111,7 +111,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro } Optional shaft = curr.stream() .filter(pos -> pos.getX() == ctx.playerFeet().getX() && pos.getZ() == ctx.playerFeet().getZ()) - .filter(pos -> pos.getY() > ctx.playerFeet().getY()) + .filter(pos -> pos.getY() >= ctx.playerFeet().getY()) .filter(pos -> !(BlockStateInterface.get(ctx, pos).getBlock() instanceof BlockAir)) // after breaking a block, it takes mineGoalUpdateInterval ticks for it to actually update this list =( .min(Comparator.comparingDouble(ctx.player()::getDistanceSq)); baritone.getInputOverrideHandler().clearAllKeys(); From 5f12f04e873c6d63eb79bd30692178fbba69634f Mon Sep 17 00:00:00 2001 From: SuperOP535 <27556391+SuperOP535@users.noreply.github.com> Date: Wed, 1 May 2019 14:05:47 +0200 Subject: [PATCH 11/45] Automatic CRLF -> LF normalization --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..176a458f --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto From e9e26c981a47def0082835614f38083a86051506 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 1 May 2019 10:37:23 -0700 Subject: [PATCH 12/45] fine babj --- src/api/java/baritone/api/Settings.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index d292e868..bb6038b6 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -164,7 +164,8 @@ public final class Settings { Blocks.CRAFTING_TABLE, Blocks.FURNACE, Blocks.LIT_FURNACE, - Blocks.CHEST + Blocks.CHEST, + Blocks.TRAPPED_CHEST ))); /** From d60a0bee9eb45b081e1df9e0b2e34db2611b958d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 1 May 2019 10:48:17 -0700 Subject: [PATCH 13/45] move this behind the toolset cache for performance --- .../baritone/pathing/movement/MovementHelper.java | 11 ++++------- src/main/java/baritone/utils/ToolSet.java | 10 +++++++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index b7be8636..e6f54213 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -18,7 +18,6 @@ package baritone.pathing.movement; import baritone.Baritone; -import baritone.api.BaritoneAPI; import baritone.api.IBaritone; import baritone.api.pathing.movement.ActionCosts; import baritone.api.pathing.movement.MovementStatus; @@ -353,6 +352,9 @@ public interface MovementHelper extends ActionCosts, Helper { static double getMiningDurationTicks(CalculationContext context, int x, int y, int z, IBlockState state, boolean includeFalling) { Block block = state.getBlock(); if (!canWalkThrough(context.bsi, x, y, z, state)) { + if (block instanceof BlockLiquid) { + return COST_INF; + } double mult = context.breakCostMultiplierAt(x, y, z); if (mult >= COST_INF) { return COST_INF; @@ -360,16 +362,11 @@ public interface MovementHelper extends ActionCosts, Helper { if (avoidBreaking(context.bsi, x, y, z, state)) { return COST_INF; } - if (block instanceof BlockLiquid) { - return COST_INF; - } - double m = Baritone.settings().blocksToAvoidBreaking.value.contains(block) ? 10 : 1; double strVsBlock = context.toolSet.getStrVsBlock(state); if (strVsBlock <= 0) { return COST_INF; } - - double result = m / strVsBlock; + double result = 1 / strVsBlock; result += context.breakBlockAdditionalCost; result *= mult; if (includeFalling) { diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index 31f23f20..69a5ae9a 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -65,10 +65,10 @@ public class ToolSet { } /** - * Using the best tool on the hotbar, how long would it take to mine this block + * Using the best tool on the hotbar, how fast we can mine this block * * @param state the blockstate to be mined - * @return how long it would take in ticks + * @return the speed of how fast we'll mine it. 1/(time in ticks) */ public double getStrVsBlock(IBlockState state) { return breakStrengthCache.computeIfAbsent(state.getBlock(), backendCalculation); @@ -128,7 +128,11 @@ public class ToolSet { */ private double getBestDestructionTime(Block b) { ItemStack stack = player.inventory.getStackInSlot(getBestSlot(b)); - return calculateSpeedVsBlock(stack, b.getDefaultState()); + return calculateSpeedVsBlock(stack, b.getDefaultState()) * avoidanceMultiplier(b); + } + + private double avoidanceMultiplier(Block b) { + return Baritone.settings().blocksToAvoidBreaking.value.contains(b) ? 0.1 : 1; } /** From 58ebd5f9a60401e9737e33ff77b99fdf12ed2285 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 1 May 2019 11:01:00 -0700 Subject: [PATCH 14/45] split this out into its own function --- .../pathing/movement/MovementHelper.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index e6f54213..6a0b07f0 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -51,11 +51,19 @@ public interface MovementHelper extends ActionCosts, Helper { return b == Blocks.ICE // ice becomes water, and water can mess up the path || b instanceof BlockSilverfish // obvious reasons // call context.get directly with x,y,z. no need to make 5 new BlockPos for no reason - || bsi.get0(x, y + 1, z).getBlock() instanceof BlockLiquid//don't break anything touching liquid on any side - || bsi.get0(x + 1, y, z).getBlock() instanceof BlockLiquid - || bsi.get0(x - 1, y, z).getBlock() instanceof BlockLiquid - || bsi.get0(x, y, z + 1).getBlock() instanceof BlockLiquid - || bsi.get0(x, y, z - 1).getBlock() instanceof BlockLiquid; + || avoidAdjacentBreaking(bsi, x, y + 1, z) + || avoidAdjacentBreaking(bsi, x + 1, y, z) + || avoidAdjacentBreaking(bsi, x - 1, y, z) + || avoidAdjacentBreaking(bsi, x, y, z + 1) + || avoidAdjacentBreaking(bsi, x, y, z - 1); + } + + static boolean avoidAdjacentBreaking(BlockStateInterface bsi, int x, int y, int z) { + // returns true if you should avoid breaking a block that's adjacent to this one (e.g. lava that will start flowing if you give it a path) + // this is only called for north, south, east, west, and up. this is NOT called for down. + // we assume that it's ALWAYS okay to break the block thats ABOVE liquid + IBlockState state = bsi.get0(x, y, z); + return state.getBlock() instanceof BlockLiquid; } static boolean canWalkThrough(IPlayerContext ctx, BetterBlockPos pos) { From 54da0d24a394ec2d89dc5a4b1820ea969d6fa055 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 1 May 2019 11:16:24 -0700 Subject: [PATCH 15/45] dont mine blocks that update falling blocks, fixes #395 --- src/api/java/baritone/api/Settings.java | 9 +++++++- .../pathing/movement/MovementHelper.java | 22 +++++++++++++------ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index bb6038b6..a2de8b40 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -160,7 +160,7 @@ public final class Settings { /** * Blocks that Baritone is not allowed to break */ - public final Setting> blocksToAvoidBreaking = new Setting<>(new ArrayList<>(Arrays.asList( + public final Setting> blocksToAvoidBreaking = new Setting<>(new ArrayList<>(Arrays.asList( // TODO can this be a HashSet or ImmutableSet? Blocks.CRAFTING_TABLE, Blocks.FURNACE, Blocks.LIT_FURNACE, @@ -168,6 +168,13 @@ public final class Settings { Blocks.TRAPPED_CHEST ))); + /** + * If this setting is true, Baritone will never break a block that is adjacent to an unsupported falling block. + *

+ * I.E. it will never trigger cascading sand / gravel falls + */ + public final Setting avoidUpdatingFallingBlocks = new Setting<>(true); + /** * Enables some more advanced vine features. They're honestly just gimmicks and won't ever be needed in real * pathing scenarios. And they can cause Baritone to get trapped indefinitely in a strange scenario. diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 6a0b07f0..d8f6a2f7 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -51,19 +51,27 @@ public interface MovementHelper extends ActionCosts, Helper { return b == Blocks.ICE // ice becomes water, and water can mess up the path || b instanceof BlockSilverfish // obvious reasons // call context.get directly with x,y,z. no need to make 5 new BlockPos for no reason - || avoidAdjacentBreaking(bsi, x, y + 1, z) - || avoidAdjacentBreaking(bsi, x + 1, y, z) - || avoidAdjacentBreaking(bsi, x - 1, y, z) - || avoidAdjacentBreaking(bsi, x, y, z + 1) - || avoidAdjacentBreaking(bsi, x, y, z - 1); + || avoidAdjacentBreaking(bsi, x, y + 1, z, true) + || avoidAdjacentBreaking(bsi, x + 1, y, z, false) + || avoidAdjacentBreaking(bsi, x - 1, y, z, false) + || avoidAdjacentBreaking(bsi, x, y, z + 1, false) + || avoidAdjacentBreaking(bsi, x, y, z - 1, false); } - static boolean avoidAdjacentBreaking(BlockStateInterface bsi, int x, int y, int z) { + static boolean avoidAdjacentBreaking(BlockStateInterface bsi, int x, int y, int z, boolean directlyAbove) { // returns true if you should avoid breaking a block that's adjacent to this one (e.g. lava that will start flowing if you give it a path) // this is only called for north, south, east, west, and up. this is NOT called for down. // we assume that it's ALWAYS okay to break the block thats ABOVE liquid IBlockState state = bsi.get0(x, y, z); - return state.getBlock() instanceof BlockLiquid; + Block block = state.getBlock(); + if (!directlyAbove // it is fine to mine a block that has a falling block directly above, this (the cost of breaking the stacked fallings) is included in cost calculations + // therefore if directlyAbove is true, we will actually ignore if this is falling + && block instanceof BlockFalling // obviously, this check is only valid for falling blocks + && Baritone.settings().avoidUpdatingFallingBlocks.value // and if the setting is enabled + && BlockFalling.canFallThrough(bsi.get0(x, y - 1, z))) { // and if it would fall (i.e. it's unsupported) + return true; // dont break a block that is adjacent to unsupported gravel because it can cause really weird stuff + } + return block instanceof BlockLiquid; } static boolean canWalkThrough(IPlayerContext ctx, BetterBlockPos pos) { From 4ea8f23fc7795e96ae68353b2c11064c9f59c5c4 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 1 May 2019 12:22:47 -0700 Subject: [PATCH 16/45] fix typo crash, fixes #406 --- src/api/java/baritone/api/utils/SettingsUtil.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/utils/SettingsUtil.java b/src/api/java/baritone/api/utils/SettingsUtil.java index 3f4de317..b494c662 100644 --- a/src/api/java/baritone/api/utils/SettingsUtil.java +++ b/src/api/java/baritone/api/utils/SettingsUtil.java @@ -34,6 +34,7 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Objects; import java.util.function.Consumer; import java.util.function.Function; import java.util.regex.Matcher; @@ -237,7 +238,9 @@ public class SettingsUtil { @Override public Object parse(ParserContext context, String raw) { - return this.parser.apply(raw); + Object parsed = this.parser.apply(raw); + Objects.requireNonNull(parsed); + return parsed; } @Override From d0a1c241a41946f1ac77a4f84578c3976d003781 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 1 May 2019 14:03:36 -0700 Subject: [PATCH 17/45] replace liquid source blocks in builder --- .../java/baritone/process/BuilderProcess.java | 44 +++++++++++++++---- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 9f49c595..c08ca8c6 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -37,6 +37,7 @@ import baritone.utils.schematic.AirSchematic; import baritone.utils.schematic.Schematic; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import net.minecraft.block.BlockAir; +import net.minecraft.block.BlockLiquid; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; @@ -51,7 +52,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.*; -import java.util.stream.Collectors; import static baritone.api.pathing.movement.ActionCosts.COST_INF; @@ -500,17 +500,45 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro } private Goal assemble(BuilderCalculationContext bcc, List approxPlacable) { - List placable = incorrectPositions.stream().filter(pos -> bcc.bsi.get0(pos).getBlock() == Blocks.AIR && approxPlacable.contains(bcc.getSchematic(pos.x, pos.y, pos.z))).collect(Collectors.toList()); - Goal[] toBreak = incorrectPositions.stream().filter(pos -> bcc.bsi.get0(pos).getBlock() != Blocks.AIR).map(pos -> breakGoal(pos, bcc)).toArray(Goal[]::new); - Goal[] toPlace = placable.stream().filter(pos -> !placable.contains(pos.down()) && !placable.contains(pos.down(2))).map(pos -> placementGoal(pos, bcc)).toArray(Goal[]::new); + List placable = new ArrayList<>(); + List breakable = new ArrayList<>(); + List sourceLiquids = new ArrayList<>(); + incorrectPositions.forEach(pos -> { + IBlockState state = bcc.bsi.get0(pos); + if (state.getBlock() instanceof BlockAir) { + if (approxPlacable.contains(bcc.getSchematic(pos.x, pos.y, pos.z))) { + placable.add(pos); + } + } else { + if (state.getBlock() instanceof BlockLiquid) { + // if the block itself is JUST a liquid (i.e. not just a waterlogged block), we CANNOT break it + // TODO for 1.13 make sure that this only matches pure water, not waterlogged blocks + if (!MovementHelper.possiblyFlowing(state)) { + // if it's a source block then we want to replace it with a throwaway + sourceLiquids.add(pos); + } + } else { + breakable.add(pos); + } + } + }); + List toBreak = new ArrayList<>(); + breakable.forEach(pos -> toBreak.add(breakGoal(pos, bcc))); + List toPlace = new ArrayList<>(); + placable.forEach(pos -> { + if (!placable.contains(pos.down()) && !placable.contains(pos.down(2))) { + toPlace.add(placementGoal(pos, bcc)); + } + }); + sourceLiquids.forEach(pos -> toPlace.add(new GoalBlock(pos.up()))); - if (toPlace.length != 0) { - return new JankyGoalComposite(new GoalComposite(toPlace), new GoalComposite(toBreak)); + if (!toPlace.isEmpty()) { + return new JankyGoalComposite(new GoalComposite(toPlace.toArray(new Goal[0])), new GoalComposite(toBreak.toArray(new Goal[0]))); } - if (toBreak.length == 0) { + if (toBreak.isEmpty()) { return null; } - return new GoalComposite(toBreak); + return new GoalComposite(toBreak.toArray(new Goal[0])); } public static class JankyGoalComposite implements Goal { From e05010c9d2454ca66137745f92cebcdb4a366119 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 1 May 2019 23:07:20 -0700 Subject: [PATCH 18/45] fix weird oscillation when mining large veins --- src/main/java/baritone/process/MineProcess.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index 72abfe9d..e8368d87 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -206,9 +206,16 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro knownOreLocations = locs; } - private static boolean internalMiningGoal(BlockPos pos, IPlayerContext ctx, List locs) { + private boolean internalMiningGoal(BlockPos pos, IPlayerContext ctx, List locs) { // Here, BlockStateInterface is used because the position may be in a cached chunk (the targeted block is one that is kept track of) - return locs.contains(pos) || (Baritone.settings().internalMiningAirException.value && BlockStateInterface.getBlock(ctx, pos) instanceof BlockAir); + if (locs.contains(pos)) { + return true; + } + Block block = BlockStateInterface.getBlock(ctx, pos); + if (Baritone.settings().internalMiningAirException.value && block instanceof BlockAir) { + return true; + } + return mining.contains(block); } private Goal coalesce(BlockPos loc, List locs) { @@ -363,7 +370,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro .filter(pos -> !blacklist.contains(pos)) - .sorted(Comparator.comparingDouble(ctx.getBaritone().getPlayerContext().playerFeet()::distanceSq)) + .sorted(Comparator.comparingDouble(ctx.getBaritone().getPlayerContext().player()::getDistanceSq)) .collect(Collectors.toList()); if (locs.size() > max) { From 0ffbb0c15112e029534acad1e9dc92d0e90a2ebc Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 2 May 2019 11:47:35 -0700 Subject: [PATCH 19/45] quiet --- src/main/java/baritone/cache/ContainerMemory.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/baritone/cache/ContainerMemory.java b/src/main/java/baritone/cache/ContainerMemory.java index c1cb7b34..e79435e3 100644 --- a/src/main/java/baritone/cache/ContainerMemory.java +++ b/src/main/java/baritone/cache/ContainerMemory.java @@ -29,6 +29,7 @@ import net.minecraft.util.math.BlockPos; import java.io.IOException; import java.nio.file.Files; +import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.util.*; @@ -45,6 +46,8 @@ public class ContainerMemory implements IContainerMemory { this.saveTo = saveTo; try { read(Files.readAllBytes(saveTo)); + } catch (NoSuchFileException ignored) { + inventories.clear(); } catch (Exception ex) { ex.printStackTrace(); inventories.clear(); From 77303b4a629c467d79964ff5c6ac71df4dd14ff4 Mon Sep 17 00:00:00 2001 From: evilsourcerer Date: Fri, 3 May 2019 01:48:37 -0400 Subject: [PATCH 20/45] render boxes for goalYLevel --- .gitignore | 2 +- src/api/java/baritone/api/Settings.java | 4 +++- .../java/baritone/api/pathing/goals/GoalYLevel.java | 2 +- src/main/java/baritone/utils/PathRenderer.java | 12 +++++++++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index de408ec0..0834b1e8 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,4 @@ classes/ # Copyright Files !/.idea/copyright/Baritone.xml -!/.idea/copyright/profiles_settings.xml \ No newline at end of file +!/.idea/copyright/profiles_settings.xml diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index a2de8b40..aa181a39 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -30,8 +30,8 @@ import java.awt.*; import java.lang.reflect.Field; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; -import java.util.*; import java.util.List; +import java.util.*; import java.util.function.Consumer; /** @@ -81,6 +81,8 @@ public final class Settings { */ public final Setting jumpPenalty = new Setting<>(2D); + public final Setting yLevelBoxSize = new Setting<>(15D); + /** * Walking on water uses up hunger really quick, so penalize it */ diff --git a/src/api/java/baritone/api/pathing/goals/GoalYLevel.java b/src/api/java/baritone/api/pathing/goals/GoalYLevel.java index ce54eebb..9add7176 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalYLevel.java +++ b/src/api/java/baritone/api/pathing/goals/GoalYLevel.java @@ -29,7 +29,7 @@ public class GoalYLevel implements Goal, ActionCosts { /** * The target Y level */ - private final int level; + public final int level; public GoalYLevel(int level) { this.level = level; diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index d1afe34d..88a18147 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -276,13 +276,13 @@ public final class PathRenderer implements Helper { double maxY; double y1; double y2; + double y = MathHelper.cos((float) (((float) ((System.nanoTime() / 100000L) % 20000L)) / 20000F * Math.PI * 2)); if (goal instanceof IGoalRenderPos) { BlockPos goalPos = ((IGoalRenderPos) goal).getGoalPos(); minX = goalPos.getX() + 0.002 - renderPosX; maxX = goalPos.getX() + 1 - 0.002 - renderPosX; minZ = goalPos.getZ() + 0.002 - renderPosZ; maxZ = goalPos.getZ() + 1 - 0.002 - renderPosZ; - double y = MathHelper.cos((float) (((float) ((System.nanoTime() / 100000L) % 20000L)) / 20000F * Math.PI * 2)); if (goal instanceof GoalGetToBlock || goal instanceof GoalTwoBlocks) { y /= 2; } @@ -341,6 +341,16 @@ public final class PathRenderer implements Helper { drawDankLitGoalBox(player, g, partialTicks, color); } return; + } else if (goal instanceof GoalYLevel) { + GoalYLevel goalpos = (GoalYLevel) goal; + minX = player.posX - Baritone.settings().yLevelBoxSize.value - renderPosX; + minZ = player.posZ - Baritone.settings().yLevelBoxSize.value - renderPosZ; + maxX = player.posX + Baritone.settings().yLevelBoxSize.value - renderPosX; + maxZ = player.posZ + Baritone.settings().yLevelBoxSize.value - renderPosZ; + minY = ((GoalYLevel) goal).level - renderPosY; + maxY = minY + 2; + y1 = 1 + y + goalpos.level - renderPosY; + y2 = 1 - y + goalpos.level - renderPosY; } else { return; } From 0f09a4654058f2adb0583a9687027bc3ef26bc81 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 2 May 2019 23:03:10 -0700 Subject: [PATCH 21/45] javadoc --- src/api/java/baritone/api/Settings.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index aa181a39..7a63fef7 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -30,8 +30,8 @@ import java.awt.*; import java.lang.reflect.Field; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; -import java.util.List; import java.util.*; +import java.util.List; import java.util.function.Consumer; /** @@ -81,6 +81,9 @@ public final class Settings { */ public final Setting jumpPenalty = new Setting<>(2D); + /** + * The size of the box that is rendered when the current goal is a GoalYLevel + */ public final Setting yLevelBoxSize = new Setting<>(15D); /** From 2a5ef35794e934306cfbd7a56bb7204d0d2b86a3 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 3 May 2019 11:44:37 -0700 Subject: [PATCH 22/45] move this down to the other render settings --- src/api/java/baritone/api/Settings.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 7a63fef7..76ea0e9a 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -81,11 +81,6 @@ public final class Settings { */ public final Setting jumpPenalty = new Setting<>(2D); - /** - * The size of the box that is rendered when the current goal is a GoalYLevel - */ - public final Setting yLevelBoxSize = new Setting<>(15D); - /** * Walking on water uses up hunger really quick, so penalize it */ @@ -804,6 +799,11 @@ public final class Settings { */ public final Setting> logger = new Setting<>(Minecraft.getMinecraft().ingameGUI.getChatGUI()::printChatMessage); + /** + * The size of the box that is rendered when the current goal is a GoalYLevel + */ + public final Setting yLevelBoxSize = new Setting<>(15D); + /** * The color of the current path */ From 7dcd7384f14a6e8cf4ac7259a1754698b9219cfb Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 4 May 2019 15:01:11 -0700 Subject: [PATCH 23/45] allow overshooting traverse --- src/api/java/baritone/api/Settings.java | 7 +++++++ .../pathing/movement/movements/MovementTraverse.java | 8 +++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 76ea0e9a..0c2c5d4b 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -215,6 +215,13 @@ public final class Settings { */ public final Setting sprintAscends = new Setting<>(true); + /** + * If we overshoot a traverse and end up one block beyond the destination, mark it as successful anyway. + *

+ * This helps with speed at >=20m/s + */ + public final Setting overshootTraverse = new Setting<>(true); + /** * When breaking blocks for a movement, wait until all falling blocks have settled before continuing */ diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 4f7ae713..a9266f14 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -36,8 +36,6 @@ import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; -import java.util.Objects; - public class MovementTraverse extends Movement { /** @@ -230,7 +228,11 @@ public class MovementTraverse extends Movement { } if (isTheBridgeBlockThere) { - if (ctx.playerFeet().equals(dest)) { + BetterBlockPos feet = ctx.playerFeet(); + if (feet.equals(dest)) { + return state.setStatus(MovementStatus.SUCCESS); + } + if (Baritone.settings().overshootTraverse.value && (feet.equals(dest.add(getDirection())) || feet.equals(dest.add(getDirection()).add(getDirection())))) { return state.setStatus(MovementStatus.SUCCESS); } Block low = BlockStateInterface.get(ctx, src).getBlock(); From 482d874af2206b63d14bad38ee774953d4d899c0 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 5 May 2019 23:57:56 -0700 Subject: [PATCH 24/45] this counts as a commit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 93b11474..50d2acfd 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Here are some links to help to get started: # API -The API is heavily documented, you can find the Javadocs for the latest release [here](https://baritone.leijurv.com/). +The API is heavily documented, you can find the Javadocs for the latest release [here](https://baritone.leijurv.com). Please note that usage of anything located outside of the ``baritone.api`` package is not supported by the API release jar. From 1501d721e7a56bf4ebbe541698a94cd6dbcbded4 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 6 May 2019 14:01:01 -0700 Subject: [PATCH 25/45] build repeat vector --- src/api/java/baritone/api/Settings.java | 11 +++-------- src/api/java/baritone/api/utils/SettingsUtil.java | 6 ++++++ src/main/java/baritone/process/BuilderProcess.java | 12 ++++-------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 0c2c5d4b..17bacf06 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -23,7 +23,7 @@ import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.init.Blocks; import net.minecraft.item.Item; -import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.Vec3i; import net.minecraft.util.text.ITextComponent; import java.awt.*; @@ -663,14 +663,9 @@ public final class Settings { public final Setting buildInLayers = new Setting<>(false); /** - * How far to move before repeating the build. -1 for the size of the build in that axis. 0 to disable + * How far to move before repeating the build. 0 to disable repeating on a certain axis, 0,0,0 to disable entirely */ - public final Setting buildRepeatDistance = new Setting<>(0); - - /** - * What direction to repeat the build in - */ - public final Setting buildRepeatDirection = new Setting<>(EnumFacing.NORTH); + public final Setting buildRepeat = new Setting<>(new Vec3i(0, 0, 0)); /** * Allow standing above a block while mining it, in BuilderProcess diff --git a/src/api/java/baritone/api/utils/SettingsUtil.java b/src/api/java/baritone/api/utils/SettingsUtil.java index b494c662..5dee6e88 100644 --- a/src/api/java/baritone/api/utils/SettingsUtil.java +++ b/src/api/java/baritone/api/utils/SettingsUtil.java @@ -21,6 +21,7 @@ import baritone.api.Settings; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.Vec3i; import java.awt.*; import java.io.BufferedReader; @@ -179,6 +180,11 @@ public class SettingsUtil { str -> new Color(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])), color -> color.getRed() + "," + color.getGreen() + "," + color.getBlue() ), + VEC3I( + Vec3i.class, + str -> new Vec3i(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])), + vec -> vec.getX() + "," + vec.getY() + "," + vec.getZ() + ), BLOCK( Block.class, str -> BlockUtils.stringToBlockRequired(str.trim()), diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index c08ca8c6..230edf0d 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -330,20 +330,16 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro layer++; return onTick(calcFailed, isSafeToCancel); } - int distance = Baritone.settings().buildRepeatDistance.value; - EnumFacing direction = Baritone.settings().buildRepeatDirection.value; - if (distance == 0) { + Vec3i repeat = Baritone.settings().buildRepeat.value; + if (repeat.equals(new Vec3i(0, 0, 0))) { logDirect("Done building"); onLostControl(); return null; } // build repeat time - if (distance == -1) { - distance = schematic.size(direction.getAxis()); - } layer = 0; - origin = new BlockPos(origin).offset(direction, distance); - logDirect("Repeating build " + distance + " blocks to the " + direction + ", new origin is " + origin); + origin = new BlockPos(origin).add(repeat); + logDirect("Repeating build in vector " + repeat + ", new origin is " + origin); return onTick(calcFailed, isSafeToCancel); } trim(bcc); From da8bf6b1b3c8a3d0e428874de906fc4c2ff29f56 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 6 May 2019 14:07:46 -0700 Subject: [PATCH 26/45] fix a potential concurrency issue --- src/main/java/baritone/process/BuilderProcess.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 230edf0d..81f790b6 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -301,6 +301,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro if (realSchematic == null) { realSchematic = schematic; } + ISchematic realSchematic = this.realSchematic; // wrap this properly, dont just have the inner class refer to the builderprocess.this schematic = new ISchematic() { @Override public IBlockState desiredState(int x, int y, int z) { From c738007538563921487ba75c4353f243cbd971e9 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 7 May 2019 21:40:03 -0800 Subject: [PATCH 27/45] epic label --- src/main/java/baritone/process/MineProcess.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index e8368d87..59c2d370 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -88,14 +88,14 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro return null; } } - boolean shouldCancel = calcFailed; - if (calcFailed && !knownOreLocations.isEmpty() && Baritone.settings().blacklistClosestOnFailure.value) { - logDirect("Unable to find any path to " + mining + ", blacklisting presumably unreachable closest instance..."); - knownOreLocations.stream().min(Comparator.comparingDouble(ctx.player()::getDistanceSq)).ifPresent(blacklist::add); - knownOreLocations.removeIf(blacklist::contains); - shouldCancel = false; // 😎 - } - if (shouldCancel) { + CANCEL: + if (calcFailed) { + if (!knownOreLocations.isEmpty() && Baritone.settings().blacklistClosestOnFailure.value) { + logDirect("Unable to find any path to " + mining + ", blacklisting presumably unreachable closest instance..."); + knownOreLocations.stream().min(Comparator.comparingDouble(ctx.player()::getDistanceSq)).ifPresent(blacklist::add); + knownOreLocations.removeIf(blacklist::contains); + break CANCEL; // 😎 + } logDirect("Unable to find any path to " + mining + ", canceling Mine"); cancel(); return null; From c9e81897a5d3105fbf1fdff78a43f147363f642f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 8 May 2019 11:51:48 -0700 Subject: [PATCH 28/45] im blind lol thanks babj --- src/main/java/baritone/process/MineProcess.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index 59c2d370..ca1b3490 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -88,17 +88,16 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro return null; } } - CANCEL: if (calcFailed) { if (!knownOreLocations.isEmpty() && Baritone.settings().blacklistClosestOnFailure.value) { logDirect("Unable to find any path to " + mining + ", blacklisting presumably unreachable closest instance..."); knownOreLocations.stream().min(Comparator.comparingDouble(ctx.player()::getDistanceSq)).ifPresent(blacklist::add); knownOreLocations.removeIf(blacklist::contains); - break CANCEL; // 😎 + } else { + logDirect("Unable to find any path to " + mining + ", canceling Mine"); + cancel(); + return null; } - logDirect("Unable to find any path to " + mining + ", canceling Mine"); - cancel(); - return null; } int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.value; List curr = new ArrayList<>(knownOreLocations); From 264b3db63c912857db528cce000e5170ddac4f06 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 9 May 2019 15:20:37 -0700 Subject: [PATCH 29/45] this counts as a commit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 50d2acfd..71e60aa4 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![HitCount](http://hits.dwyl.com/cabaletta/baritone.svg)](http://hits.dwyl.com/cabaletta/baritone) [![Code of Conduct](https://img.shields.io/badge/%E2%9D%A4-code%20of%20conduct-blue.svg?style=flat)](https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md) [![Known Vulnerabilities](https://snyk.io/test/github/cabaletta/baritone/badge.svg?targetFile=build.gradle)](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle) -[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/cabaletta/baritone/issues) +[![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/cabaletta/baritone/issues) [![Issues](https://img.shields.io/github/issues/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/issues/) [![GitHub issues-closed](https://img.shields.io/github/issues-closed/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/issues?q=is%3Aissue+is%3Aclosed) [![Pull Requests](https://img.shields.io/github/issues-pr/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/pulls/) From 79d448e5f435aed0d51c6f1b15cd8cb13eb6bd8f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 10 May 2019 23:55:50 -0700 Subject: [PATCH 30/45] add crucial explanation --- 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 17bacf06..ab04d334 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -646,7 +646,7 @@ public final class Settings { public final Setting exploreMaintainY = new Setting<>(64); /** - * Replant nether wart + * Replant nether wart while farming */ public final Setting replantNetherWart = new Setting<>(false); From 6a13e94c4fd942e0d0696c2504680e580c30a1dd Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 11 May 2019 21:13:46 -0700 Subject: [PATCH 31/45] warning --- src/api/java/baritone/api/Settings.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index ab04d334..56fb949e 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -545,6 +545,8 @@ public final class Settings { /** * Exclusively use cached chunks for pathing + *

+ * Never turn this on */ public final Setting pathThroughCachedOnly = new Setting<>(false); From 0293a767025ae8c9c838589b3b5936deaa852ba1 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 12 May 2019 23:25:50 -0700 Subject: [PATCH 32/45] less yikes --- src/main/java/baritone/process/BuilderProcess.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 81f790b6..7fb1b0ae 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -456,7 +456,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro observedCompleted.add(BetterBlockPos.longHash(pos)); } else { incorrectPositions.add(pos); - observedCompleted.rem(BetterBlockPos.longHash(pos)); + observedCompleted.remove(BetterBlockPos.longHash(pos)); } } } @@ -481,7 +481,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro observedCompleted.add(BetterBlockPos.longHash(blockX, blockY, blockZ)); } else { incorrectPositions.add(new BetterBlockPos(blockX, blockY, blockZ)); - observedCompleted.rem(BetterBlockPos.longHash(blockX, blockY, blockZ)); + observedCompleted.remove(BetterBlockPos.longHash(blockX, blockY, blockZ)); } continue; } From b2f38807225491224028fe6ca4477e5f5e431a21 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 13 May 2019 20:13:22 -0800 Subject: [PATCH 33/45] add todo --- src/api/java/baritone/api/utils/BetterBlockPos.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/api/java/baritone/api/utils/BetterBlockPos.java b/src/api/java/baritone/api/utils/BetterBlockPos.java index a1a3cb32..3b94a833 100644 --- a/src/api/java/baritone/api/utils/BetterBlockPos.java +++ b/src/api/java/baritone/api/utils/BetterBlockPos.java @@ -61,6 +61,8 @@ public final class BetterBlockPos extends BlockPos { } public static long longHash(int x, int y, int z) { + // TODO use the same thing as BlockPos.fromLong(); + // invertibility would be incredibly useful /* * This is the hashcode implementation of Vec3i (the superclass of the class which I shall not name) * From da58988f017e884faee4ab79f8749ace9d4f334a Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 14 May 2019 16:03:11 -0700 Subject: [PATCH 34/45] build in layers order --- src/api/java/baritone/api/Settings.java | 7 +++++++ .../java/baritone/process/BuilderProcess.java | 18 +++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 56fb949e..ed17ce17 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -664,6 +664,13 @@ public final class Settings { */ public final Setting buildInLayers = new Setting<>(false); + /** + * false = build from bottom to top + *

+ * true = build from top to bottom + */ + public final Setting layerOrder = 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 7fb1b0ae..17424345 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -302,12 +302,28 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro realSchematic = schematic; } ISchematic realSchematic = this.realSchematic; // wrap this properly, dont just have the inner class refer to the builderprocess.this + int minYInclusive; + int maxYInclusive; + // layer = 0 should be nothing + // layer = realSchematic.heightY() should be everything + if (Baritone.settings().layerOrder.value) { // top to bottom + maxYInclusive = realSchematic.heightY() - 1; + minYInclusive = realSchematic.heightY() - layer; + } else { + maxYInclusive = layer - 1; + minYInclusive = 0; + } schematic = new ISchematic() { @Override public IBlockState desiredState(int x, int y, int z) { return realSchematic.desiredState(x, y, z); } + @Override + public boolean inSchematic(int x, int y, int z) { + return ISchematic.super.inSchematic(x, y, z) && y >= minYInclusive && y <= maxYInclusive; + } + @Override public int widthX() { return realSchematic.widthX(); @@ -315,7 +331,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro @Override public int heightY() { - return layer; + return realSchematic.heightY(); } @Override From 0dd4834e18f472812adbe4c7540c5a0f174a0b9c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 15 May 2019 21:55:01 -0800 Subject: [PATCH 35/45] add explanation --- 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 ed17ce17..031443f4 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -577,7 +577,7 @@ public final class Settings { public final Setting renderCachedChunks = new Setting<>(false); /** - * 0.0f = not visible, fully transparent + * 0.0f = not visible, fully transparent (instead of setting this to 0, turn off renderCachedChunks) * 1.0f = fully opaque */ public final Setting cachedChunksOpacity = new Setting<>(0.5f); From 6861bfd4e667c9c23a8849e3efc42049fa6b6205 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 16 May 2019 11:50:48 -0700 Subject: [PATCH 36/45] relative goals --- .../baritone/api/utils/ExampleBaritoneControl.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 715d8edb..67cd5b47 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -688,18 +688,20 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener private Goal parseGoal(String[] params) { Goal goal; try { + BetterBlockPos playerFeet = ctx.playerFeet(); switch (params.length) { case 0: - goal = new GoalBlock(ctx.playerFeet()); + goal = new GoalBlock(playerFeet); break; case 1: - goal = new GoalYLevel(Integer.parseInt(params[0])); + + goal = new GoalYLevel(parseOrDefault(params[0], playerFeet.y)); break; case 2: - goal = new GoalXZ(Integer.parseInt(params[0]), Integer.parseInt(params[1])); + goal = new GoalXZ(parseOrDefault(params[0], playerFeet.x), parseOrDefault(params[1], playerFeet.z)); break; case 3: - goal = new GoalBlock(new BlockPos(Integer.parseInt(params[0]), Integer.parseInt(params[1]), Integer.parseInt(params[2]))); + goal = new GoalBlock(new BlockPos(parseOrDefault(params[0], playerFeet.x), parseOrDefault(params[1], playerFeet.y), parseOrDefault(params[2], playerFeet.z))); break; default: logDirect("unable to understand lol"); From 4679e1258832418aeac6b133d237a5aef2fa8876 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 16 May 2019 15:20:52 -0700 Subject: [PATCH 37/45] better usage --- USAGE.md | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/USAGE.md b/USAGE.md index 652c093e..ce8924a7 100644 --- a/USAGE.md +++ b/USAGE.md @@ -2,24 +2,17 @@ # Prefix -Baritone commands can by default be typed in the chatbox. However if you make a typo, like typing "gola 10000 10000" instead of goal it goes into public chat, which is bad. - -Therefore you can use a prefix before your messages. - -On Baritone v1.1.0 and newer: The prefix is `#` by default. Anything beginning with `#` isn't sent, and is only interpreted by Baritone. -For older than v1.1.0, `#` must be enabled by toggling on the `prefix` setting. - -**Only** in Impact is `.b` also a valid prefix. In 4.4, `#` does **not** work, neither does saying the commands directly in chat. `#` works by default in 4.5 (not 4.4). - -Other clients like Kami and Asuna have their own custom things (like `-path`), and can disable direct chat control entirely. +Baritone's chat control prefix is `#` by default. In Impact, you can also use `.b` as a prefix. (for example, `.b click` instead of `#click`) +Baritone commands can also by default be typed in the chatbox. However if you make a typo, like typing "gola 10000 10000" instead of "goal" it goes into public chat, which is bad, so using `#` is suggested. +To disable direct chat control (with no prefix), turn off the `chatControl` setting. To disable chat control with the `#` prefix, turn off the `prefixControl` setting. In Impact, `.b` cannot be disabled. Be careful that you don't leave yourself with all control methods disabled (if you do, reset your settings by deleting the file `minecraft/baritone/settings.txt` and relaunching). # Commands **All** of these commands may need a prefix before them, as above ^. -`help` for (rudimentary) help. You can see what it says [here](https://github.com/cabaletta/baritone/blob/master/src/main/java/baritone/utils/ExampleBaritoneControl.java#L53). +`help` for (rudimentary) help. You can see what it says [here](https://github.com/cabaletta/baritone/blob/master/src/api/java/baritone/api/utils/ExampleBaritoneControl.java#L47). To toggle a boolean setting, just say its name in chat (for example saying `allowBreak` toggles whether Baritone will consider breaking blocks). For a numeric setting, say its name then the new value (like `primaryTimeoutMS 250`). It's case insensitive. To reset a setting to its default value, say `acceptableThrowawayItems reset`. To reset all settings, say `reset`. To see all settings that have been modified from their default values, say `modified`. @@ -47,7 +40,7 @@ Some common examples: - `damn` daniel -For the rest of the commands, you can take a look at the code [here](https://github.com/cabaletta/baritone/blob/master/src/main/java/baritone/utils/ExampleBaritoneControl.java). +For the rest of the commands, you can take a look at the code [here](https://github.com/cabaletta/baritone/blob/master/src/api/java/baritone/api/utils/ExampleBaritoneControl.java). All the settings and documentation are here. If you find HTML easier to read than Javadoc, you can look here. From 352e4288900b0c6020ced930be7debce9e330643 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 17 May 2019 22:21:40 -0800 Subject: [PATCH 38/45] explicitly set serialized name post obf --- src/api/java/baritone/api/utils/MyChunkPos.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/api/java/baritone/api/utils/MyChunkPos.java b/src/api/java/baritone/api/utils/MyChunkPos.java index 5748a13d..0533fb0c 100644 --- a/src/api/java/baritone/api/utils/MyChunkPos.java +++ b/src/api/java/baritone/api/utils/MyChunkPos.java @@ -17,11 +17,15 @@ package baritone.api.utils; +import com.google.gson.annotations.SerializedName; + /** * Need a non obfed chunkpos that we can load using GSON */ public class MyChunkPos { + @SerializedName("x") public int x; + @SerializedName("y") public int z; @Override From ccc1b04e815c2626bb930396c4fa71c4a50c0522 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 18 May 2019 17:11:16 -0700 Subject: [PATCH 39/45] crucial spacing --- src/api/java/baritone/api/utils/MyChunkPos.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/api/java/baritone/api/utils/MyChunkPos.java b/src/api/java/baritone/api/utils/MyChunkPos.java index 0533fb0c..b122cdba 100644 --- a/src/api/java/baritone/api/utils/MyChunkPos.java +++ b/src/api/java/baritone/api/utils/MyChunkPos.java @@ -23,8 +23,10 @@ import com.google.gson.annotations.SerializedName; * Need a non obfed chunkpos that we can load using GSON */ public class MyChunkPos { + @SerializedName("x") public int x; + @SerializedName("y") public int z; From d70da4f37da27a2e7b0e8855baff529657270b82 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 19 May 2019 21:53:09 -0800 Subject: [PATCH 40/45] finalize these --- src/api/java/baritone/api/utils/MyChunkPos.java | 2 +- src/main/java/baritone/process/BackfillProcess.java | 2 +- src/main/java/baritone/process/BuilderProcess.java | 2 +- src/main/java/baritone/process/CustomGoalProcess.java | 2 +- src/main/java/baritone/process/ExploreProcess.java | 2 +- src/main/java/baritone/process/FarmProcess.java | 2 +- src/main/java/baritone/process/GetToBlockProcess.java | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/api/java/baritone/api/utils/MyChunkPos.java b/src/api/java/baritone/api/utils/MyChunkPos.java index b122cdba..1df7481d 100644 --- a/src/api/java/baritone/api/utils/MyChunkPos.java +++ b/src/api/java/baritone/api/utils/MyChunkPos.java @@ -23,7 +23,7 @@ import com.google.gson.annotations.SerializedName; * Need a non obfed chunkpos that we can load using GSON */ public class MyChunkPos { - + @SerializedName("x") public int x; diff --git a/src/main/java/baritone/process/BackfillProcess.java b/src/main/java/baritone/process/BackfillProcess.java index 8567a049..65e5692e 100644 --- a/src/main/java/baritone/process/BackfillProcess.java +++ b/src/main/java/baritone/process/BackfillProcess.java @@ -35,7 +35,7 @@ import net.minecraft.world.chunk.EmptyChunk; import java.util.*; import java.util.stream.Collectors; -public class BackfillProcess extends BaritoneProcessHelper { +public final class BackfillProcess extends BaritoneProcessHelper { public HashMap blocksToReplace = new HashMap<>(); diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 17424345..27c1f885 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -55,7 +55,7 @@ import java.util.*; import static baritone.api.pathing.movement.ActionCosts.COST_INF; -public class BuilderProcess extends BaritoneProcessHelper implements IBuilderProcess { +public final class BuilderProcess extends BaritoneProcessHelper implements IBuilderProcess { private HashSet incorrectPositions; private LongOpenHashSet observedCompleted; // positions that are completed even if they're out of render distance and we can't make sure right now diff --git a/src/main/java/baritone/process/CustomGoalProcess.java b/src/main/java/baritone/process/CustomGoalProcess.java index 4003b7a7..b45c7d6f 100644 --- a/src/main/java/baritone/process/CustomGoalProcess.java +++ b/src/main/java/baritone/process/CustomGoalProcess.java @@ -29,7 +29,7 @@ import baritone.utils.BaritoneProcessHelper; * * @author leijurv */ -public class CustomGoalProcess extends BaritoneProcessHelper implements ICustomGoalProcess { +public final class CustomGoalProcess extends BaritoneProcessHelper implements ICustomGoalProcess { /** * The current goal diff --git a/src/main/java/baritone/process/ExploreProcess.java b/src/main/java/baritone/process/ExploreProcess.java index 35ddcb84..aa7e2c2a 100644 --- a/src/main/java/baritone/process/ExploreProcess.java +++ b/src/main/java/baritone/process/ExploreProcess.java @@ -41,7 +41,7 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.List; -public class ExploreProcess extends BaritoneProcessHelper implements IExploreProcess { +public final class ExploreProcess extends BaritoneProcessHelper implements IExploreProcess { private BlockPos explorationOrigin; diff --git a/src/main/java/baritone/process/FarmProcess.java b/src/main/java/baritone/process/FarmProcess.java index ac6d488f..9593a192 100644 --- a/src/main/java/baritone/process/FarmProcess.java +++ b/src/main/java/baritone/process/FarmProcess.java @@ -50,7 +50,7 @@ import java.util.List; import java.util.Optional; import java.util.function.Predicate; -public class FarmProcess extends BaritoneProcessHelper implements IFarmProcess { +public final class FarmProcess extends BaritoneProcessHelper implements IFarmProcess { private boolean active; diff --git a/src/main/java/baritone/process/GetToBlockProcess.java b/src/main/java/baritone/process/GetToBlockProcess.java index 69703894..4fb4d540 100644 --- a/src/main/java/baritone/process/GetToBlockProcess.java +++ b/src/main/java/baritone/process/GetToBlockProcess.java @@ -34,7 +34,7 @@ import net.minecraft.util.math.BlockPos; import java.util.*; -public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBlockProcess { +public final class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBlockProcess { private Block gettingTo; private List knownLocations; From c7fe9c31719fbfbd6dc34e6312f85b8f4884b217 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 20 May 2019 22:37:51 -0700 Subject: [PATCH 41/45] finalize --- src/main/java/baritone/behavior/InventoryBehavior.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/behavior/InventoryBehavior.java b/src/main/java/baritone/behavior/InventoryBehavior.java index 03878ee5..684613af 100644 --- a/src/main/java/baritone/behavior/InventoryBehavior.java +++ b/src/main/java/baritone/behavior/InventoryBehavior.java @@ -33,7 +33,7 @@ import java.util.OptionalInt; import java.util.Random; import java.util.function.Predicate; -public class InventoryBehavior extends Behavior { +public final class InventoryBehavior extends Behavior { public InventoryBehavior(Baritone baritone) { super(baritone); } From 79da32cc60708ce64501118a8d3705e3e516b778 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 21 May 2019 15:07:05 -0700 Subject: [PATCH 42/45] unused --- src/main/java/baritone/pathing/movement/Movement.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index c9849cab..be29b988 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -32,7 +32,6 @@ import net.minecraft.util.math.BlockPos; import java.util.ArrayList; import java.util.List; -import java.util.Objects; import java.util.Optional; public abstract class Movement implements IMovement, MovementHelper { From bb924ad83ff8d5754dd039de9f5718fe1e85cf1b Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 22 May 2019 23:41:02 -0700 Subject: [PATCH 43/45] thank you intellij very cool --- src/api/java/baritone/api/utils/ExampleBaritoneControl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 67cd5b47..467d4d95 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -332,7 +332,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener if (suffix.isEmpty()) { // clear the area from the current goal to here Goal goal = baritone.getPathingBehavior().getGoal(); - if (goal == null || !(goal instanceof GoalBlock)) { + if (!(goal instanceof GoalBlock)) { logDirect("Need to specify goal of opposite corner"); return true; } From b4d203ab99abf71f3f29e3841839fee57c010922 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 23 May 2019 20:47:22 -0800 Subject: [PATCH 44/45] bye --- .../baritone/api/utils/ExampleBaritoneControl.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 467d4d95..927ba794 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -385,17 +385,6 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener logDirect("farming"); return true; } - // this literally doesn't work, memory is disabled lol - /*if (msg.equals("echest")) { - Optional> contents = baritone.getMemoryBehavior().echest(); - if (contents.isPresent()) { - logDirect("echest contents:"); - log(contents.get()); - } else { - logDirect("echest contents unknown"); - } - return true; - }*/ if (msg.equals("chests")) { for (Map.Entry entry : baritone.getWorldProvider().getCurrentWorld().getContainerMemory().getRememberedInventories().entrySet()) { logDirect(entry.getKey() + ""); From a6954aa719ae519a4d17418b3f69665843d41db2 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 24 May 2019 10:36:01 -0700 Subject: [PATCH 45/45] bye 2 --- .../api/utils/ExampleBaritoneControl.java | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 927ba794..29547281 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -638,24 +638,6 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener } return true; } - // this is completely impossible from api - /*if (msg.equals("costs")) { - List moves = Stream.of(Moves.values()).map(x -> x.apply0(new CalculationContext(baritone), ctx.playerFeet())).collect(Collectors.toCollection(ArrayList::new)); - while (moves.contains(null)) { - moves.remove(null); - } - moves.sort(Comparator.comparingDouble(move -> move.getCost(new CalculationContext(baritone)))); - for (Movement move : moves) { - String[] parts = move.getClass().toString().split("\\."); - double cost = move.getCost(); - String strCost = cost + ""; - if (cost >= ActionCosts.COST_INF) { - strCost = "IMPOSSIBLE"; - } - logDirect(parts[parts.length - 1] + " " + move.getDest().getX() + "," + move.getDest().getY() + "," + move.getDest().getZ() + " " + strCost); - } - return true; - }*/ if (msg.equals("damn")) { logDirect("daniel"); }