From d315e0829679e80747abbfad810f53c12359db3c Mon Sep 17 00:00:00 2001 From: Evenprime Date: Sun, 12 Feb 2012 18:25:15 +0100 Subject: [PATCH] Make "fight.direction" use bounding boxes to calculate entity height --- .../bukkit/nocheat/checks/fight/DirectionCheck.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/fight/DirectionCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/fight/DirectionCheck.java index 16884982..af75292a 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/fight/DirectionCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/fight/DirectionCheck.java @@ -4,7 +4,6 @@ import java.util.Locale; import net.minecraft.server.Entity; import net.minecraft.server.EntityComplex; import net.minecraft.server.EntityComplexPart; -import net.minecraft.server.EntityGiantZombie; import cc.co.evenprime.bukkit.nocheat.NoCheat; import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer; import cc.co.evenprime.bukkit.nocheat.actions.ParameterName; @@ -27,19 +26,17 @@ public class DirectionCheck extends FightCheck { // Get the width of the damagee Entity entity = data.damagee; - // Safeguard, if entity is Giant or Ender Dragon, this check will fail + // Safeguard, if entity is complex, this check will fail // due to giant and hard to define hitboxes - if(entity instanceof EntityComplex || entity instanceof EntityComplexPart || entity instanceof EntityGiantZombie) { + if(entity instanceof EntityComplex || entity instanceof EntityComplexPart) { return false; } final float width = entity.length > entity.width ? entity.length : entity.width; + // entity.height is broken and will always be 0, therefore calculate height instead + final double height = entity.boundingBox.e - entity.boundingBox.b; - // height = 2.0D as minecraft doesn't store the height of entities, - // and that should be enough. Because entityLocations are always set - // to center bottom of the hitbox, increase "y" location by 1/2 - // height to get the "center" of the hitbox - final double off = CheckUtil.directionCheck(player, entity.locX, entity.locY + 1.0D, entity.locZ, width, 2.0D, cc.directionPrecision); + final double off = CheckUtil.directionCheck(player, entity.locX, entity.locY + (height / 2D), entity.locZ, width, height, cc.directionPrecision); if(off < 0.1D) { // Player did probably nothing wrong