Checks whether the given location is safe to teleport a player to - that a player would not be damaged as a result of being moved to this location @param loc The location to check @return Whether the given location is safe
(Location loc)
| 51 | * @return Whether the given location is safe |
| 52 | */ |
| 53 | public static boolean isSafe(Location loc) { |
| 54 | Block under = loc.clone().subtract(0, 1, 0).getBlock(); |
| 55 | if (under.getType().isSolid()) { |
| 56 | Block middle = loc.getBlock(); |
| 57 | Block above = loc.clone().add(0, 1, 0).getBlock(); |
| 58 | if (!isHazard(middle.getType()) && !isHazard(above.getType())) { |
| 59 | if (!middle.getType().isSolid() && !above.getType().isSolid() && !middle.isLiquid() && !above.isLiquid()) { |
| 60 | return true; |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | return false; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Gets the nearest safe location to the given location within the given distance passing the given predicate check |