From c6ca584847d2076a6e02a974d4bd70521bdb51c4 Mon Sep 17 00:00:00 2001 From: Brady Date: Sat, 25 Aug 2018 17:24:00 -0500 Subject: [PATCH] Clean up isDoorPassable --- .../pathing/movement/MovementHelper.java | 42 +++++++------------ 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index ed52f8cc..547043e8 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -30,6 +30,7 @@ import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; @@ -119,41 +120,26 @@ public interface MovementHelper extends ActionCosts, Helper { } 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)) { + if (playerPos.equals(doorPos)) return false; - } + + IBlockState state = BlockStateInterface.get(doorPos); + if (!(state.getBlock() instanceof BlockDoor)) + return true; + + EnumFacing.Axis facing = state.getValue(BlockDoor.FACING).getAxis(); + boolean open = state.getValue(BlockDoor.OPEN); + + EnumFacing.Axis playerFacing; if (playerPos.north().equals(doorPos) || playerPos.south().equals(doorPos)) { - playerFacing = "northsouth"; + playerFacing = EnumFacing.Axis.Z; } else if (playerPos.east().equals(doorPos) || playerPos.west().equals(doorPos)) { - playerFacing = "eastwest"; + playerFacing = EnumFacing.Axis.X; } 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"; - } - } + return (facing == playerFacing) == open; } static boolean avoidWalkingInto(Block block) {