mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-13 19:11:22 +01:00
yawrate: Add judgement about stationary yaw.
This prevents adding up small yaw-differences for many cases.
This commit is contained in:
parent
4800efbf2a
commit
1759c1003f
@ -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);
|
||||
|
@ -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).
|
||||
|
Loading…
Reference in New Issue
Block a user