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 // 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). // 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. // TODO: Skip the on-ground check somehow?
if (player.getFallDistance() < cc.criticalFallDistance) { // removed velocity // TODO: Implement low jump penalty.
final MovingConfig ccM = MovingConfig.getConfig(player); if (mcFallDistance > 0f && player.getFallDistance() < cc.criticalFallDistance &&!BlockProperties.isOnGroundOrResetCond(player, loc, mCc.yOnGround) && !player.hasPotionEffect(PotionEffectType.BLINDNESS)){
final MovingData dataM = MovingData.getData(player); final MovingConfig ccM = MovingConfig.getConfig(player);
if (MovingListener.shouldCheckSurvivalFly(player, dataM, ccM)){ final MovingData dataM = MovingData.getData(player);
final double deltaFallDistance = (cc.criticalFallDistance - player.getFallDistance()) if (MovingListener.shouldCheckSurvivalFly(player, dataM, ccM)){
/ cc.criticalFallDistance; final double deltaFallDistance = (cc.criticalFallDistance - player.getFallDistance())
final double deltaVelocity = (cc.criticalVelocity - Math.abs(player.getVelocity().getY())) / cc.criticalFallDistance;
/ cc.criticalVelocity; final double deltaVelocity = (cc.criticalVelocity - Math.abs(player.getVelocity().getY()))
final double delta = deltaFallDistance > 0D ? deltaFallDistance / cc.criticalVelocity;
: 0D + deltaVelocity > 0D ? deltaVelocity : 0D; 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. // 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){ if (TickTask.getLag(1000) < 1.5){
// TODO: 1.5 is a fantasy value. // TODO: 1.5 is a fantasy value.
// Increment the violation level. // Increment the violation level.
data.criticalVL += delta; data.criticalVL += delta;
} }
// Execute whatever actions are associated with this check and the violation level and find out if we
// Execute whatever actions are associated with this check and the violation level and find out if we // should cancel the event.
// should cancel the event. cancel = executeActions(player, data.criticalVL, delta, cc.criticalActions);
cancel = executeActions(player, data.criticalVL, delta, cc.criticalActions);
}
} }
} }

View File

@ -164,17 +164,24 @@ public class NoFall extends Check {
if (!toReset && !toOnGround && yDiff < 0){ if (!toReset && !toOnGround && yDiff < 0){
data.noFallFallDistance -= yDiff; data.noFallFallDistance -= yDiff;
} }
else if (cc.noFallDealDamage && cc.noFallAntiCriticals && (toReset || toOnGround || (fromReset || fromOnGround || data.noFallAssumeGround) && yDiff >= 0)){ else if (cc.noFallAntiCriticals && (toReset || toOnGround || (fromReset || fromOnGround || data.noFallAssumeGround) && yDiff >= 0)){
// TODO: Only use this if dealdamage is true ? final double max = Math.max(data.noFallFallDistance, mcFallDistance);
if (data.noFallFallDistance > 0){ if (max > 0.0 && max < 0.75){ // (Ensure this does not conflict with deal-damage set to false.)
data.noFallFallDistance = 0; 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) + ")" : ""));
}
} }