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

@@ -453,6 +453,49 @@ public class Backend
{
return false;
}
//trapdoor fix
if (playerClick.getType() == Material.TRAP_DOOR)
{
Location x1 = new Location(targetBlock.getWorld(), playerClick.getX() - 1, playerClick.getY(), playerClick.getZ());
Location x2 = new Location(targetBlock.getWorld(), playerClick.getX() + 1, playerClick.getY(), playerClick.getZ());
Location y1 = new Location(targetBlock.getWorld(), playerClick.getX(), playerClick.getY() - 1, playerClick.getZ());
Location y2 = new Location(targetBlock.getWorld(), playerClick.getX(), playerClick.getY() + 1, playerClick.getZ());
Location z1 = new Location(targetBlock.getWorld(), playerClick.getX(), playerClick.getY(), playerClick.getZ() - 1);
Location z2 = new Location(targetBlock.getWorld(), playerClick.getX(), playerClick.getY(), playerClick.getZ() + 1);
if (x1.equals(targetBlock.getLocation()) || x2.equals(targetBlock.getLocation()) || y1.equals(targetBlock.getLocation()) || y2.equals(targetBlock.getLocation()) || z1.equals(targetBlock.getLocation()) || z2.equals(targetBlock.getLocation()))
{
System.out.println((int) playerClick.getData());
String dir = Utilities.getCardinalDirection(player);
int minimum = 0;
if (dir.equalsIgnoreCase("E"))
{
minimum = 0;
}
if (dir.equalsIgnoreCase("W"))
{
minimum = 1;
}
if (dir.equalsIgnoreCase("N"))
{
minimum = 2;
}
if (dir.equalsIgnoreCase("S"))
{
minimum = 3;
}
if ((int) playerClick.getData() == minimum)
return true; // they have to be hacking here.
if ((int) playerClick.getData() == minimum + 4 && (playerClick.getLocation().distance(player.getLocation())) < 2)
return false; // couldn't be hacking.
}
}
double x = targetBlock.getX() - playerClick.getX() * ((targetBlock.getX() - playerClick.getX() * 1) < 0 ? -1 : 1);
double y = targetBlock.getY() - playerClick.getY() * ((targetBlock.getY() - playerClick.getY() * 1) < 0 ? -1 : 1);
double z = targetBlock.getZ() - playerClick.getZ() * ((targetBlock.getZ() - playerClick.getZ() * 1) < 0 ? -1 : 1);
@@ -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)
{