Non-solid blocks should not be blocking a players view of interacting with something. Fixes issue #91

This commit is contained in:
H31IX committed 2012-06-18 02:22:33 -04:00
1 parent a895bf94bd
commit 23303295bf
5 files changed
+25 -137

No files matched your search

@@ -403,56 +403,11 @@ public class Backend
public boolean checkVisuals(Player player, Block targetBlock, Block playerClick)
{
/*if (isInteracting(player) || playerClick.isLiquid())
{
return false;
}*/
if (!Utilities.isInteractable(targetBlock.getType()))
{
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()))
{
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);