Steps work properly, spam protection fixed, and a bit of work on where the eye is looking when it hits an entity.

This commit is contained in:
Adam committed 2012-04-15 17:22:05 -04:00
1 parent 93a725e031
commit f8b56784d5
8 files changed
+258 -36

No files matched your search

@@ -0,0 +1,62 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.h31ix.anticheat.checks;
import net.minecraft.server.EntityComplex;
import net.minecraft.server.EntityComplexPart;
import net.minecraft.server.Entity;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class EyeCheck {
Player player;
Entity entity;
public EyeCheck(Player player, Entity entity)
{
this.player = player;
this.entity = entity;
}
public double getOffset()
{
//Thanks to Evenprime (NoCheat)
if(entity instanceof EntityComplex || entity instanceof EntityComplexPart)
{
return -1;
}
final float width = entity.length > entity.width ? entity.length : entity.width;
final double height = entity.boundingBox.e - entity.boundingBox.b;
final double off = directionCheck(player, entity.locX, entity.locY + (height / 2D), entity.locZ, width, height, 75);
return off;
}
public final double directionCheck(final Player player, final double targetX, final double targetY, final double targetZ, final double targetWidth, final double targetHeight, final double precision)
{
//Thanks to Evenprime (NoCheat)
final Location eyes = player.getPlayer().getEyeLocation();
final double factor = Math.sqrt(Math.pow(eyes.getX() - targetX, 2) + Math.pow(eyes.getY() - targetY, 2) + Math.pow(eyes.getZ() - targetZ, 2));
final Vector direction = eyes.getDirection();
final double x = ((double) targetX) - eyes.getX();
final double y = ((double) targetY) - eyes.getY();
final double z = ((double) targetZ) - eyes.getZ();
final double xPrediction = factor * direction.getX();
final double yPrediction = factor * direction.getY();
final double zPrediction = factor * direction.getZ();
double off = 0.0D;
off += Math.max(Math.abs(x - xPrediction) - (targetWidth / 2 + precision), 0.0D);
off += Math.max(Math.abs(z - zPrediction) - (targetWidth / 2 + precision), 0.0D);
off += Math.max(Math.abs(y - yPrediction) - (targetHeight / 2 + precision), 0.0D);
if(off > 1) {
off = Math.sqrt(off);
}
return off;
}
}
@@ -15,11 +15,7 @@ public class LengthCheck {
{
double bx = l1.getX();
double px = l2.getX();
double xdiff = bx-px;
if(xdiff < 0)
{
xdiff = -xdiff;
}
double xdiff = Math.abs(bx-px);
return xdiff;
}
@@ -27,11 +23,7 @@ public class LengthCheck {
{
double bz = l1.getZ();
double pz = l2.getZ();
double zdiff = bz-pz;
if(zdiff < 0)
{
zdiff = -zdiff;
}
double zdiff = Math.abs(bz-pz);
return zdiff;
}
@@ -39,11 +31,7 @@ public class LengthCheck {
{
double by = l1.getY();
double py = l2.getY();
double ydiff = by-py;
if(ydiff < 0)
{
ydiff = -ydiff;
}
double ydiff = Math.abs(by-py);
return ydiff;
}
@@ -0,0 +1,12 @@
package net.h31ix.anticheat.checks;
import org.bukkit.Location;
public class StairCheck {
public StairCheck(Location location)
{
}
}