diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowStopper.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowStopper.java index 35d8af1..6da7da5 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowStopper.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowStopper.java @@ -61,18 +61,23 @@ public class ArrowStopper { private boolean checkBlocks(Block start, Block end) { Block cursor = start; + BlockFace from = BlockFace.SELF; while (!cursor.getLocation().equals(end.getLocation())) { BlockFace nearest = BlockFace.SELF; - double nearestDistance = cursor.getLocation().distance(end.getLocation()); + double nearestDistance = cursor.getLocation().distanceSquared(end.getLocation()); for (BlockFace face : BLOCK_FACES) { + if(face == from) { + continue; + } Block relative = cursor.getRelative(face); - double distance = relative.getLocation().distance(end.getLocation()); + double distance = relative.getLocation().distanceSquared(end.getLocation()); if(distance < nearestDistance) { nearestDistance = distance; nearest = face; } } + from = nearest.getOppositeFace(); cursor = cursor.getRelative(nearest); if(checkBlock(cursor)) return true;