Fixed entities that are surrounded by blocks (who's heads cannot be seen by players at all) from causing forcefield false-positives.

This commit is contained in:
h31ix committed 2012-09-29 16:51:43 -04:00
1 parent 9253a93fe0
commit 396ebf3758
1 file changed
+29 -1
@@ -578,7 +578,35 @@ public class Backend
public boolean checkSight(Player player, Entity entity)
{
return player.hasLineOfSight(entity);
// Check to make sure the entity's head is not surrounded
Block head = entity.getLocation().add(0, 1, 0).getBlock();
boolean solid = false;
if(head.getRelative(BlockFace.NORTH).getTypeId() != 0)
{
solid = net.minecraft.server.Block.byId[head.getRelative(BlockFace.NORTH).getTypeId()].material.isSolid();
}
if(!solid)
{
if(head.getRelative(BlockFace.SOUTH).getTypeId() != 0)
{
solid = net.minecraft.server.Block.byId[head.getRelative(BlockFace.SOUTH).getTypeId()].material.isSolid();
}
}
if(!solid)
{
if(head.getRelative(BlockFace.EAST).getTypeId() != 0)
{
solid = net.minecraft.server.Block.byId[head.getRelative(BlockFace.EAST).getTypeId()].material.isSolid();
}
}
if(!solid)
{
if(head.getRelative(BlockFace.WEST).getTypeId() != 0)
{
solid = net.minecraft.server.Block.byId[head.getRelative(BlockFace.WEST).getTypeId()].material.isSolid();
}
}
return solid ? true : player.hasLineOfSight(entity);
}
public boolean checkFlight(Player player, Distance distance)