From 9714cfd7675e60e9b1409c325679873ad5f92d93 Mon Sep 17 00:00:00 2001 From: h31ix Date: Tue, 9 Oct 2012 23:05:29 -0400 Subject: [PATCH] Another fix for enderman/other entities in forcefield check --- .../net/h31ix/anticheat/manage/Backend.java | 44 +++++++------------ src/main/resources/plugin.yml | 2 +- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index 6a3f764..7216b47 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -543,38 +543,24 @@ public class Backend public boolean checkSight(Player player, Entity entity) { // Check to make sure the entity's head is not surrounded - Block head = entity.getWorld().getBlockAt((int)entity.getLocation().getX(), (int)((CraftEntity)entity).getHandle().getHeadHeight(), (int)entity.getLocation().getZ()); + Block head = entity.getWorld().getBlockAt((int)entity.getLocation().getX(), (int)(entity.getLocation().getY()+((CraftEntity)entity).getHandle().getHeadHeight()), (int)entity.getLocation().getZ()); boolean solid = false; - if(head.getTypeId() != 0) + //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++) { - solid = net.minecraft.server.Block.byId[head.getTypeId()].material.isSolid(); - } - if(!solid) - { - if(head.getRelative(BlockFace.NORTH).getTypeId() != 0) + for(int z=-2;z<=2;z++) { - 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(); + 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); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 27d2429..47909a2 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -6,7 +6,7 @@ name: AntiCheat softdepend: [AntiCheat] startup: postworld url: http://gravitydevelopment.net -version: ${project.version}-{build.number}-DEV +version: ${project.version}-DEV-b${BUILD_NUMBER} commands: anticheat: description: Control and view info about AntiCheat