diff --git a/src/main/java/baritone/bot/pathing/movement/MovementHelper.java b/src/main/java/baritone/bot/pathing/movement/MovementHelper.java index 5a5732a3..9570ff60 100644 --- a/src/main/java/baritone/bot/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/bot/pathing/movement/MovementHelper.java @@ -87,9 +87,50 @@ public interface MovementHelper extends ActionCosts, Helper { if (BlockStateInterface.isFlowing(state) || BlockStateInterface.isLiquid(pos.up())) { return false; // Don't walk through flowing liquids } + if (block instanceof BlockDoor) { + return true; // we can just open the door + } return block.isPassable(mc.world, pos); } + static boolean isDoorPassable(BlockPos doorPos, BlockPos playerPos) { + IBlockState door = BlockStateInterface.get(doorPos); + if (!(door.getBlock() instanceof BlockDoor)) { + return true; + } + String facing = door.getValue(BlockDoor.FACING).getName(); + boolean open = door.getValue(BlockDoor.OPEN).booleanValue(); + /** + * yes this is dumb + * change it if you want + */ + String playerFacing = ""; + if (playerPos.equals(doorPos)) { + return false; + } + if (playerPos.north().equals(doorPos) || playerPos.south().equals(doorPos)) { + playerFacing = "northsouth"; + } else if (playerPos.east().equals(doorPos) || playerPos.west().equals(doorPos)){ + playerFacing = "eastwest"; + } else { + return true; + } + + if (facing == "north" || facing == "south") { + if (open) { + return playerFacing == "northsouth"; + } else { + return playerFacing == "eastwest"; + } + } else { + if (open) { + return playerFacing == "eastwest"; + } else { + return playerFacing == "northsouth"; + } + } + } + static boolean avoidWalkingInto(Block block) { return BlockStateInterface.isLava(block) || block instanceof BlockCactus diff --git a/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java index fb2cba39..2326d1f5 100644 --- a/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java @@ -26,6 +26,7 @@ import baritone.bot.pathing.movement.MovementState; import baritone.bot.utils.BlockStateInterface; import baritone.bot.utils.Utils; import net.minecraft.block.Block; +import net.minecraft.block.BlockDoor; import net.minecraft.block.BlockLadder; import net.minecraft.block.BlockVine; import net.minecraft.block.state.IBlockState; @@ -49,6 +50,7 @@ public class MovementTraverse extends Movement { public MovementTraverse(BlockPos from, BlockPos to) { super(from, to, new BlockPos[]{to.up(), to}, new BlockPos[]{to.down()}); int i = 0; + if (!to.north().equals(from)) against[i++] = to.north().down(); @@ -130,6 +132,22 @@ public class MovementTraverse extends Movement { } Block fd = BlockStateInterface.get(src.down()).getBlock(); boolean ladder = fd instanceof BlockLadder || fd instanceof BlockVine; + IBlockState pb0 = BlockStateInterface.get(positionsToBreak[0]); + IBlockState pb1 = BlockStateInterface.get(positionsToBreak[1]); + boolean door = BlockStateInterface.get(src).getBlock() instanceof BlockDoor || pb0.getBlock() instanceof BlockDoor || pb1.getBlock() instanceof BlockDoor; + if (door) { + boolean isDoorActuallyBlockingUs = false; + Block srcBlock = BlockStateInterface.get(src).getBlock(); + if (srcBlock instanceof BlockDoor && !MovementHelper.isDoorPassable(src, dest)) { + isDoorActuallyBlockingUs = true; + } else if (pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(dest, src)) { + isDoorActuallyBlockingUs = true; + } + if (isDoorActuallyBlockingUs) { + state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); + return state; + } + } boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(positionsToPlace[0]) || ladder; BlockPos whereAmI = playerFeet(); if (whereAmI.getY() != dest.getY() && !ladder) {