Fixed trapdoor issue with visual check.

This commit is contained in:
Super Spy committed 2012-06-17 22:34:23 -05:00
1 parent 96961a2ae5
commit d007fb733d
2 files changed
+119 -3

No files matched your search

@@ -51,6 +51,79 @@ public final class Utilities
}
}
/*
*
* Credits to sk89q for the calculation of cardinal direction.
*
*
*/
/**
* Get the cardinal compass direction of a player.
*
* @param player
* @return
*/
public static String getCardinalDirection(Player player)
{
double rot = (player.getLocation().getYaw() - 90) % 360;
if (rot < 0)
{
rot += 360.0;
}
return getDirection(rot);
}
/**
* Converts a rotation to a cardinal direction name.
*
* @param rot
* @return
*/
private static String getDirection(double rot)
{
if (0 <= rot && rot < 22.5)
{
return "N";
}
else if (22.5 <= rot && rot < 67.5)
{
return "N";
}
else if (67.5 <= rot && rot < 112.5)
{
return "E";
}
else if (112.5 <= rot && rot < 157.5)
{
return "E";
}
else if (157.5 <= rot && rot < 202.5)
{
return "S";
}
else if (202.5 <= rot && rot < 247.5)
{
return "S";
}
else if (247.5 <= rot && rot < 292.5)
{
return "W";
}
else if (292.5 <= rot && rot < 337.5)
{
return "W";
}
else if (337.5 <= rot && rot < 360.0)
{
return "N";
}
else
{
return null;
}
}
public static boolean cantStandAt(Block block)
{
return !canStand(block) && cantStandClose(block) && cantStandFar(block);
@@ -90,7 +163,7 @@ public final class Utilities
{
return PRESSURE_PLATES.contains(m);
}
public static boolean sprintFly(Player player)
{
return player.isSprinting() || player.isFlying();
@@ -130,11 +203,11 @@ public final class Utilities
{
return player.getLocation().getBlock().getType() == Material.VINE || player.getLocation().getBlock().getType() == Material.LADDER;
}
public static boolean isOnVine(Player player)
{
return player.getLocation().getBlock().getType() == Material.VINE;
}
}
public static boolean isInt(String string)
{