MCPcopy Create free account
hub / github.com/boxbeam/RedLib / isSafe

Method isSafe

src/redempt/redlib/misc/LocationUtils.java:53–65  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 6

isHazardMethod · 0.95
subtractMethod · 0.80
getBlockMethod · 0.45
cloneMethod · 0.45
getTypeMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected