Fix nofall check

This commit is contained in:
Evenprime 2012-02-05 21:14:22 +01:00
parent bf7ac37cb1
commit c4861eeed9
3 changed files with 14 additions and 2 deletions

View File

@ -31,4 +31,6 @@ public interface NoCheatPlayer {
public ExecutionHistory getExecutionHistory();
public void dealFallDamage();
}

View File

@ -1,7 +1,6 @@
package cc.co.evenprime.bukkit.nocheat.checks.moving;
import java.util.Locale;
import cc.co.evenprime.bukkit.nocheat.NoCheat;
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
import cc.co.evenprime.bukkit.nocheat.actions.ParameterName;
@ -32,12 +31,16 @@ public class NoFallCheck extends MovingCheck {
data.lastAddedFallDistance = 0F;
return null;
}
// This check is pretty much always a step behind for technical reasons.
if(data.fromOnOrInGround) {
// Start with zero fall distance
data.fallDistance = 0F;
}
if(data.fromOnOrInGround && data.toOnOrInGround && data.from.y <= data.to.y && player.getPlayer().getFallDistance() > 2.0F) {
player.dealFallDamage();
}
// If we increased fall height before for no good reason, reduce now by
// the same amount

View File

@ -117,4 +117,11 @@ public class NoCheatPlayerImpl implements NoCheatPlayer {
public ExecutionHistory getExecutionHistory() {
return history;
}
@Override
public void dealFallDamage() {
EntityPlayer p = ((CraftPlayer) player).getHandle();
p.b(0D, true);
}
}