From 58ebd5f9a60401e9737e33ff77b99fdf12ed2285 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 1 May 2019 11:01:00 -0700 Subject: [PATCH] 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) {