diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/combined/Combined.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/combined/Combined.java index 454dbddf..859b7fb5 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/combined/Combined.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/combined/Combined.java @@ -10,6 +10,9 @@ import org.bukkit.entity.Player; */ public class Combined { + /** All hits within this angle range are regarded as stationary. */ + private static float stationary = 32f; + /** * Check if a penalty is set by changing horizontal facing dierection too often. * @param player @@ -51,6 +54,7 @@ public class Combined { // Timeout, world change. if (now - data.lastYawTime > 999 || !worldName.equals(data.lastWorld)){ data.lastYaw = yaw; + data.sumYaw = 0f; data.lastYawTime = now; data.lastWorld = worldName; } @@ -66,7 +70,21 @@ public class Combined { data.lastYaw = yaw; data.lastYawTime = now; - // TODO: If it should still be a problem, keep another yaw as stationary, add yaw without abs if near. + // Skip adding small changes. + if (yawDiff < stationary){ + // This could also be done by keeping a "stationaryYaw" and taking the distance to yaw. + data.sumYaw += yawDiff; + if (Math.abs(data.sumYaw) < stationary){ + // Still stationary, keep sum, add nothing. + data.yawFreq.update(now); + return; + } + else{ + // Reset. + data.sumYaw = 0f; + } + } + else data.sumYaw = 0f; final float dAbs = Math.abs(yawDiff); final float dNorm = (float) dAbs / (float) (1 + elapsed); diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/combined/CombinedData.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/combined/CombinedData.java index 59d401eb..d9914fdc 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/combined/CombinedData.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/combined/CombinedData.java @@ -62,6 +62,7 @@ public class CombinedData extends ACheckData { // Yawrate check. public float lastYaw; public long lastYawTime; + public float sumYaw; public final ActionFrequency yawFreq = new ActionFrequency(3, 333); // General penalty time (used for fighting mainly, set by yawrate check).