From 396ebf37587f3bff20c91c7cb78cc8aa3fcc5350 Mon Sep 17 00:00:00 2001 From: h31ix Date: Sat, 29 Sep 2012 16:51:43 -0400 Subject: [PATCH] Fixed entities that are surrounded by blocks (who's heads cannot be seen by players at all) from causing forcefield false-positives. --- .../net/h31ix/anticheat/manage/Backend.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index 39fe40e..97f46ed 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -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)