Fix crop trampling being disabled by anticriticals.

This commit is contained in:
asofold 2013-04-21 21:23:51 +02:00
parent e26aec2cbd
commit 19ddaefb4c
2 changed files with 38 additions and 33 deletions

View File

@ -64,32 +64,30 @@ public class Critical extends Check {
// Check if the hit was a critical hit (positive fall distance, entity in the air, not on ladder, not in liquid
// and without blindness effect).
if (mcFallDistance > 0f && !BlockProperties.isOnGroundOrResetCond(player, loc, mCc.yOnGround) && !player.hasPotionEffect(PotionEffectType.BLINDNESS)){
// It was a critical hit, now check if the player has jumped or has sent a packet to mislead the server.
if (player.getFallDistance() < cc.criticalFallDistance) { // removed velocity
final MovingConfig ccM = MovingConfig.getConfig(player);
final MovingData dataM = MovingData.getData(player);
if (MovingListener.shouldCheckSurvivalFly(player, dataM, ccM)){
final double deltaFallDistance = (cc.criticalFallDistance - player.getFallDistance())
/ cc.criticalFallDistance;
final double deltaVelocity = (cc.criticalVelocity - Math.abs(player.getVelocity().getY()))
/ cc.criticalVelocity;
final double delta = deltaFallDistance > 0D ? deltaFallDistance
: 0D + deltaVelocity > 0D ? deltaVelocity : 0D;
// TODO: Skip the on-ground check somehow?
// TODO: Implement low jump penalty.
if (mcFallDistance > 0f && player.getFallDistance() < cc.criticalFallDistance &&!BlockProperties.isOnGroundOrResetCond(player, loc, mCc.yOnGround) && !player.hasPotionEffect(PotionEffectType.BLINDNESS)){
final MovingConfig ccM = MovingConfig.getConfig(player);
final MovingData dataM = MovingData.getData(player);
if (MovingListener.shouldCheckSurvivalFly(player, dataM, ccM)){
final double deltaFallDistance = (cc.criticalFallDistance - player.getFallDistance())
/ cc.criticalFallDistance;
final double deltaVelocity = (cc.criticalVelocity - Math.abs(player.getVelocity().getY()))
/ cc.criticalVelocity;
final double delta = deltaFallDistance > 0D ? deltaFallDistance
: 0D + deltaVelocity > 0D ? deltaVelocity : 0D;
// Player failed the check, but this is influenced by lag so don't do it if there was lag.
if (TickTask.getLag(1000) < 1.5){
// TODO: 1.5 is a fantasy value.
// Increment the violation level.
data.criticalVL += delta;
}
// Execute whatever actions are associated with this check and the violation level and find out if we
// should cancel the event.
cancel = executeActions(player, data.criticalVL, delta, cc.criticalActions);
}
// Player failed the check, but this is influenced by lag so don't do it if there was lag.
if (TickTask.getLag(1000) < 1.5){
// TODO: 1.5 is a fantasy value.
// Increment the violation level.
data.criticalVL += delta;
}
// Execute whatever actions are associated with this check and the violation level and find out if we
// should cancel the event.
cancel = executeActions(player, data.criticalVL, delta, cc.criticalActions);
}
}

View File

@ -164,17 +164,24 @@ public class NoFall extends Check {
if (!toReset && !toOnGround && yDiff < 0){
data.noFallFallDistance -= yDiff;
}
else if (cc.noFallDealDamage && cc.noFallAntiCriticals && (toReset || toOnGround || (fromReset || fromOnGround || data.noFallAssumeGround) && yDiff >= 0)){
// TODO: Only use this if dealdamage is true ?
if (data.noFallFallDistance > 0){
data.noFallFallDistance = 0;
else if (cc.noFallAntiCriticals && (toReset || toOnGround || (fromReset || fromOnGround || data.noFallAssumeGround) && yDiff >= 0)){
final double max = Math.max(data.noFallFallDistance, mcFallDistance);
if (max > 0.0 && max < 0.75){ // (Ensure this does not conflict with deal-damage set to false.)
if (cc.debug){
System.out.println(player.getName() + " NoFall: Reset fall distance (anticriticals): mc=" + StringUtil.fdec3.format(mcFallDistance) +" / nf=" + StringUtil.fdec3.format(data.noFallFallDistance) );
}
if (data.noFallFallDistance > 0){
data.noFallFallDistance = 0;
}
if (mcFallDistance > 0){
player.setFallDistance(0);
}
}
if (mcFallDistance > 0){
player.setFallDistance(0);
}
}
if (cc.debug) System.out.println(player.getName() + " NoFall: mc=" + StringUtil.fdec3.format(player.getFallDistance()) +" / nf=" + StringUtil.fdec3.format(data.noFallFallDistance) + (oldNFDist < data.noFallFallDistance ? " (+" + StringUtil.fdec3.format(data.noFallFallDistance - oldNFDist) + ")" : ""));
if (cc.debug){
System.out.println(player.getName() + " NoFall: mc=" + StringUtil.fdec3.format(mcFallDistance) +" / nf=" + StringUtil.fdec3.format(data.noFallFallDistance) + (oldNFDist < data.noFallFallDistance ? " (+" + StringUtil.fdec3.format(data.noFallFallDistance - oldNFDist) + ")" : ""));
}
}