mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 06:28:52 +00:00
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:
1 parent
9253a93fe0
commit
396ebf3758
1 file changed
+29
-1
@@ -578,7 +578,35 @@ public class Backend
|
|||||||
|
|
||||||
public boolean checkSight(Player player, Entity entity)
|
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)
|
public boolean checkFlight(Player player, Distance distance)
|
||||||
|
|||||||
Reference in new issue
Block a user