mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-03-10 21:49:53 +01:00
Attempt to reduce false positives with sprint+jump+attack.
Attacking while sprinting will now activate an extra buffer for the horizontal speed checking.
This commit is contained in:
parent
494c667592
commit
078c567e4b
@ -20,6 +20,9 @@ import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.checks.combined.Combined;
|
||||
import fr.neatmonster.nocheatplus.checks.combined.Improbable;
|
||||
import fr.neatmonster.nocheatplus.checks.inventory.Items;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.MovingListener;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
||||
@ -197,6 +200,23 @@ public class FightListener extends CheckListener {
|
||||
data.lastAttackedZ = targetLoc.getZ();
|
||||
// data.lastAttackedDist = targetDist;
|
||||
|
||||
// Velocity freedom adaption.
|
||||
if (!cancelled && player.isSprinting() && CheckUtils.distance(loc.getX(), loc.getZ(), targetLoc.getX(), targetLoc.getZ()) < 3.0){
|
||||
// Add "mini" freedom.
|
||||
final MovingData mData = MovingData.getData(player);
|
||||
// TODO: Check distance of other entity.
|
||||
if (mData.fromX != Double.MAX_VALUE){
|
||||
final double hDist = CheckUtils.distance(loc.getX(), loc.getZ(), mData.fromX, mData.fromZ) ;
|
||||
if (hDist >= 0.23 && mData.sfHorizontalBuffer > 0.5 && MovingListener.shouldCheckSurvivalFly(player, mData, MovingConfig.getConfig(player))){
|
||||
// Allow extra consumption with buffer.
|
||||
mData.sfHBufExtra = 7;
|
||||
if (cc.debug){
|
||||
System.out.println(player.getName() + " attacks, hDist to last from: " + hDist + " | targetdist=" + CheckUtils.distance(loc.getX(), loc.getZ(), targetLoc.getX(), targetLoc.getZ()) + " | sprinting=" + player.isSprinting() + " | food=" + player.getFoodLevel() +" | hbuf=" + mData.sfHorizontalBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
|
@ -143,6 +143,8 @@ public class MovingData extends ACheckData {
|
||||
|
||||
// Data of the survival fly check.
|
||||
public double sfHorizontalBuffer = 0;
|
||||
/** Times to add extra horizontal buffer if necessary. */
|
||||
public int sfHBufExtra = 0;
|
||||
public int sfJumpPhase = 0;
|
||||
/** "Dirty" flag, for receiving velocity and similar while in air. */
|
||||
public boolean sfDirty = false;
|
||||
@ -161,7 +163,6 @@ public class MovingData extends ACheckData {
|
||||
|
||||
// Accounting info.
|
||||
public final ActionAccumulator vDistAcc = new ActionAccumulator(3, 3);
|
||||
|
||||
|
||||
/**
|
||||
* Clear the data of the fly checks (not more-packets).
|
||||
@ -176,6 +177,7 @@ public class MovingData extends ACheckData {
|
||||
clearAccounting();
|
||||
clearNoFallData();
|
||||
sfHorizontalBuffer = 0;
|
||||
sfHBufExtra = 0;
|
||||
toWasReset = fromWasReset = false; // TODO: true maybe
|
||||
sfHoverTicks = sfHoverLoginTicks = -1;
|
||||
sfDirty = false;
|
||||
@ -204,6 +206,7 @@ public class MovingData extends ACheckData {
|
||||
// Keep bunny-hop delay (?)
|
||||
// keep jump phase.
|
||||
sfHorizontalBuffer = Math.min(0, sfHorizontalBuffer);
|
||||
sfHBufExtra = 0;
|
||||
toWasReset = fromWasReset = false; // TODO: true maybe
|
||||
sfHoverTicks = -1;
|
||||
sfDirty = false;
|
||||
@ -241,17 +244,13 @@ public class MovingData extends ACheckData {
|
||||
sfLastYDist = Double.MAX_VALUE;
|
||||
sfDirty = false;
|
||||
mediumLiftOff = defaultMediumLiftOff;
|
||||
// TODO: other buffers ?
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear accounting data.
|
||||
*/
|
||||
public void clearAccounting() {
|
||||
// final long now = System.currentTimeMillis();
|
||||
// hDistSum.clear(now);
|
||||
// hDistCount.clear(now);
|
||||
// vDistCount.clear(now);
|
||||
// vDistSum.clear(now);
|
||||
vDistAcc.clear();
|
||||
}
|
||||
|
||||
@ -267,7 +266,6 @@ public class MovingData extends ACheckData {
|
||||
* Clear the data of the new fall check.
|
||||
*/
|
||||
public void clearNoFallData() {
|
||||
// noFallOnGround = noFallWasOnGround = true;
|
||||
noFallFallDistance = 0;
|
||||
noFallMaxY = 0D;
|
||||
noFallSkipAirCheck = false;
|
||||
|
@ -124,17 +124,34 @@ public class SurvivalFly extends Check {
|
||||
|
||||
// Judge if horizontal speed is above limit.
|
||||
double hDistanceAboveLimit = hDistance - hAllowedDistance - data.horizontalFreedom;
|
||||
|
||||
// Tag for simple speed violation (medium), might get overridden.
|
||||
if (hDistanceAboveLimit > 0){
|
||||
// After failure permission checks ( + speed modifier + sneaking + blocking + speeding) !
|
||||
hAllowedDistance = getAllowedhDist(player, from, to, sprinting, hDistance, data, cc, true);
|
||||
hDistanceAboveLimit = hDistance - hAllowedDistance - data.horizontalFreedom;
|
||||
if (hAllowedDistance > 0){
|
||||
tags.add("hspeed");
|
||||
// Check extra buffer (!).
|
||||
final double extraUsed;
|
||||
if (data.sfHBufExtra > 0){
|
||||
extraUsed = 0.11;
|
||||
hDistanceAboveLimit = Math.max(0.0, hDistanceAboveLimit - extraUsed);
|
||||
data.sfHBufExtra --;
|
||||
tags.add("hbufextra");
|
||||
if (data.sfHBufExtra < 3 && to.isOnGround() || to.isResetCond()){
|
||||
data.sfHBufExtra = 0;
|
||||
}
|
||||
}
|
||||
else{
|
||||
extraUsed = 0.0;
|
||||
}
|
||||
// After failure permission checks ( + speed modifier + sneaking + blocking + speeding).
|
||||
if (hDistanceAboveLimit > 0){
|
||||
hAllowedDistance = getAllowedhDist(player, from, to, sprinting, hDistance, data, cc, true);
|
||||
hDistanceAboveLimit = hDistance - hAllowedDistance - data.horizontalFreedom - extraUsed;
|
||||
if (hAllowedDistance > 0){
|
||||
// (Horizontal buffer might still get used.)
|
||||
tags.add("hspeed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else{
|
||||
data.sfHBufExtra = 0;
|
||||
}
|
||||
///////
|
||||
// Note: here the normal speed checks must be finished.
|
||||
//////
|
||||
@ -473,9 +490,11 @@ public class SurvivalFly extends Check {
|
||||
final double hDistance, final double hAllowedDistance, final double yDistance, final double vAllowedDistance,
|
||||
final boolean fromOnGround, final boolean resetFrom, final boolean toOnGround, final boolean resetTo) {
|
||||
// TODO: also show resetcond (!)
|
||||
StringBuilder builder = new StringBuilder(500);
|
||||
final StringBuilder builder = new StringBuilder(500);
|
||||
final String hBuf = (data.sfHorizontalBuffer < 1.0 ? ((" hbuf=" + StringUtil.fdec3.format(data.sfHorizontalBuffer))) : "");
|
||||
final String hBufExtra = (data.sfHBufExtra > 0 ? (" hbufextra=" + data.sfHBufExtra) : "");
|
||||
builder.append(player.getName() + " ground: " + (data.noFallAssumeGround ? "(assumeonground) " : "") + (fromOnGround ? "onground -> " : (resetFrom ? "resetcond -> " : "--- -> ")) + (toOnGround ? "onground" : (resetTo ? "resetcond" : "---")) + ", jumpphase: " + data.sfJumpPhase);
|
||||
builder.append("\n" + player.getName() + " hDist: " + StringUtil.fdec3.format(hDistance) + " / " + StringUtil.fdec3.format(hAllowedDistance) + (data.sfHorizontalBuffer < 1.0 ? (" hbuf=" + StringUtil.fdec3.format(data.sfHorizontalBuffer)) : "") + " , vDist: " + StringUtil.fdec3.format(yDistance) + " (" + StringUtil.fdec3.format(to.getY() - data.getSetBackY()) + " / " + StringUtil.fdec3.format(vAllowedDistance) + ")");
|
||||
builder.append("\n" + player.getName() + " hDist: " + StringUtil.fdec3.format(hDistance) + " / " + StringUtil.fdec3.format(hAllowedDistance) + hBuf + hBufExtra + " , vDist: " + StringUtil.fdec3.format(yDistance) + " (" + StringUtil.fdec3.format(to.getY() - data.getSetBackY()) + " / " + StringUtil.fdec3.format(vAllowedDistance) + ")");
|
||||
if (data.verticalVelocityCounter > 0 || data.verticalFreedom >= 0.001){
|
||||
builder.append("\n" + player.getName() + " vertical freedom: " + StringUtil.fdec3.format(data.verticalFreedom) + " (vel=" + StringUtil.fdec3.format(data.verticalVelocity) + "/counter=" + data.verticalVelocityCounter +"/used="+data.verticalVelocityUsed);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user