[Bleeding] Account for lag in blockbreak.fastbreak.

This commit is contained in:
asofold 2013-01-04 14:21:08 +01:00
parent b85cd17688
commit 581cdef7bb

View File

@ -11,6 +11,7 @@ import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.ViolationData;
import fr.neatmonster.nocheatplus.permissions.Permissions;
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
import fr.neatmonster.nocheatplus.utilities.TickTask;
/*
* MM""""""""`M dP M#"""""""'M dP
@ -75,14 +76,20 @@ public class FastBreak extends Check {
// // Ignore those for now.
// }
// else
if (elapsedTime + cc.fastBreakDelay < breakingTime){
// lag or cheat or Minecraft.
final long missingTime = breakingTime - elapsedTime;
// Count in server side lag, if desired.
final float lag = cc.lag ? TickTask.getLag(breakingTime, true) : 1f;
final long missingTime = breakingTime - (long) (lag * elapsedTime);
if (missingTime > 0){
// Add as penalty
data.fastBreakPenalties.add(now, (float) missingTime);
// Only raise a violation, if the total penalty score exceeds the contention duration (for lag, delay).
if (data.fastBreakPenalties.score(cc.fastBreakBucketFactor) > cc.fastBreakGrace){
// TODO: maybe add one absolute penalty time for big amounts to stop breaking until then
@ -94,6 +101,7 @@ public class FastBreak extends Check {
}
// else: still within contention limits.
}
}
else if (breakingTime > cc.fastBreakDelay){
// Fast breaking does not decrease violation level.
data.fastBreakVL *= 0.9D;