diff --git a/src/main/java/baritone/behavior/FollowBehavior.java b/src/main/java/baritone/behavior/FollowBehavior.java index 21ebbbea4..a007a6b5d 100644 --- a/src/main/java/baritone/behavior/FollowBehavior.java +++ b/src/main/java/baritone/behavior/FollowBehavior.java @@ -42,6 +42,7 @@ public final class FollowBehavior extends Behavior implements Helper { @Override public void onTick(TickEvent event) { if (event.getType() == TickEvent.Type.OUT) { + following = null; return; } if (following == null) { diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index 3073c0f8e..853ef9cb5 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -58,6 +58,10 @@ public final class MineBehavior extends Behavior implements Helper { @Override public void onTick(TickEvent event) { + if (event.getType() == TickEvent.Type.OUT) { + cancel(); + return; + } if (mining == null) { return; } diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 1e049a2e4..112370050 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -23,6 +23,7 @@ import baritone.behavior.LookBehaviorUtils; import baritone.pathing.movement.MovementState.MovementStatus; import baritone.utils.*; import baritone.utils.pathing.BetterBlockPos; +import net.minecraft.block.BlockLiquid; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; @@ -158,7 +159,7 @@ public abstract class Movement implements Helper, MovementHelper { } boolean somethingInTheWay = false; for (BetterBlockPos blockPos : positionsToBreak) { - if (!MovementHelper.canWalkThrough(blockPos)) { + if (!MovementHelper.canWalkThrough(blockPos) && !(BlockStateInterface.getBlock(blockPos) instanceof BlockLiquid)) { // can't break liquid, so don't try somethingInTheWay = true; Optional reachable = LookBehaviorUtils.reachable(blockPos); if (reachable.isPresent()) { @@ -216,7 +217,7 @@ public abstract class Movement implements Helper, MovementHelper { public void reset() { currentState = new MovementState().setStatus(MovementStatus.PREPPING); } - + /** * Calculate latest movement state. * Gets called once a tick. diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index b1be71fda..fea40a02e 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -360,6 +360,9 @@ public interface MovementHelper extends ActionCosts, Helper { if (avoidBreaking(x, y, z, state)) { return COST_INF; } + 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 strVsBlock = context.getToolSet().getStrVsBlock(state); if (strVsBlock <= 0) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index 275344e4a..d5a7e7a2d 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -87,8 +87,10 @@ public class MovementDescend extends Movement { //if S is where you start, B needs to be air for a movementfall //A is plausibly breakable by either descend or fall //C, D, etc determine the length of the fall - if (!MovementHelper.canWalkOn(destX, y - 2, destZ)) { - return dynamicFallCost(context, x, y, z, destX, destZ, totalCost); + + IBlockState below = BlockStateInterface.get(destX, y - 2, destZ); + if (!MovementHelper.canWalkOn(destX, y - 2, destZ, below)) { + return dynamicFallCost(context, x, y, z, destX, destZ, totalCost, below); } Block tmp1 = BlockStateInterface.get(destX, y - 1, destZ).getBlock(); @@ -106,13 +108,16 @@ public class MovementDescend extends Movement { return new Tuple<>(y - 1, totalCost); } - public static Tuple dynamicFallCost(CalculationContext context, int x, int y, int z, int destX, int destZ, double frontBreak) { + public static Tuple dynamicFallCost(CalculationContext context, int x, int y, int z, int destX, int destZ, double frontBreak, IBlockState below) { if (frontBreak != 0 && BlockStateInterface.get(destX, y + 2, destZ).getBlock() instanceof BlockFalling) { // if frontBreak is 0 we can actually get through this without updating the falling block and making it actually fall // but if frontBreak is nonzero, we're breaking blocks in front, so don't let anything fall through this column, // and potentially replace the water we're going to fall into return IMPOSSIBLE; } + if (!MovementHelper.canWalkThrough(destX, y - 2, destZ, below) && below.getBlock() != Blocks.WATER) { + return IMPOSSIBLE; + } for (int fallHeight = 3; true; fallHeight++) { int newY = y - fallHeight; if (newY < 0) { @@ -122,13 +127,16 @@ public class MovementDescend extends Movement { } IBlockState ontoBlock = BlockStateInterface.get(destX, newY, destZ); double tentativeCost = WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[fallHeight] + frontBreak; - if (ontoBlock.getBlock() == Blocks.WATER) { // TODO flowing check required here? + if (ontoBlock.getBlock() == Blocks.WATER && !BlockStateInterface.isFlowing(ontoBlock)) { // TODO flowing check required here? if (Baritone.settings().assumeWalkOnWater.get()) { return IMPOSSIBLE; // TODO fix } // found a fall into water return new Tuple<>(newY, tentativeCost); // TODO incorporate water swim up cost? } + if (ontoBlock.getBlock() == Blocks.FLOWING_WATER) { + return IMPOSSIBLE; + } if (MovementHelper.canWalkThrough(destX, newY, destZ, ontoBlock)) { continue; } diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 815d6d1be..144b787fc 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -94,6 +94,7 @@ public class PathExecutor implements Helper { if (pathPosition == 0 && whereAmI.equals(whereShouldIBe.up()) && Math.abs(player().motionY) < 0.1 && !(path.movements().get(0) instanceof MovementAscend) && !(path.movements().get(0) instanceof MovementPillar)) { // avoid the Wrong Y coordinate bug + // TODO add a timer here new MovementDownward(whereAmI, whereShouldIBe).update(); return false; }