THERE'S YOUR PROBLEM

This commit is contained in:
h31ix committed 2012-11-27 21:51:28 -05:00
1 parent ba40bdc369
commit 31510b42d5
2 files changed
+25 -3

No files matched your search

@@ -166,7 +166,7 @@ public class EntityListener extends EventListener
log("tried to damage an entity without swinging their arm.", player, CheckType.NO_SWING);
noHack = false;
}
if (checkManager.willCheck(player, CheckType.FORCEFIELD))
if (checkManager.willCheck(player, CheckType.FORCEFIELD) && !backend.checkSight(player, e.getEntity()))
{
event.setCancelled(!config.silentMode());
log("tried to damage an entity that they couldn't see.", player, CheckType.FORCEFIELD);
@@ -565,8 +565,30 @@ public class Backend
public boolean checkSight(Player player, Entity entity)
{
// TODO: Internal method was screwed. Rewrite.
return true;
// Check to make sure the entity's head is not surrounded
Block head = entity.getWorld().getBlockAt((int) entity.getLocation().getX(), (int) (entity.getLocation().getY() + ((CraftEntity) entity).getHandle().getHeadHeight()), (int) entity.getLocation().getZ());
boolean solid = false;
//TODO: This sucks. See if it's possible to not have as many false-positives while still retaining most of the check.
for (int x = -2; x <= 2; x++)
{
for (int z = -2; z <= 2; z++)
{
for (int y = -1; y < 2; y++)
{
if (head.getRelative(x, y, z).getTypeId() != 0)
{
if (net.minecraft.server.Block.byId[head.getRelative(x, y, z).getTypeId()].material.isSolid())
{
solid = true;
break;
}
}
}
}
}
return solid ? true : player.hasLineOfSight(entity);
}
public boolean checkFlight(Player player, Distance distance)