mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-14 03:21:24 +01:00
Fix allowed h-dist in water (downstream).
Previously this was not applied in the "after-failure" h-dist estimation with permission checking.
This commit is contained in:
parent
1ad08b3729
commit
25e4cb3b05
@ -147,17 +147,13 @@ public class SurvivalFly extends Check {
|
|||||||
resetFrom = lostGround;
|
resetFrom = lostGround;
|
||||||
// Note: if not setting resetFrom, other places have to check assumeGround...
|
// Note: if not setting resetFrom, other places have to check assumeGround...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set flag for swimming with the flowing direction of liquid.
|
||||||
|
final boolean downStream = hDistance > swimmingSpeed && from.isInLiquid() && from.isDownStream(xDistance, zDistance);
|
||||||
|
|
||||||
// TODO: Account for lift-off medium / if in air [i.e. account for medium + friction]?
|
// TODO: Account for lift-off medium / if in air [i.e. account for medium + friction]?
|
||||||
// (Might set some margin for buffering if cutting down hAllowedDistance.)
|
// (Might set some margin for buffering if cutting down hAllowedDistance.)
|
||||||
double hAllowedDistance = getAllowedhDist(player, from, to, sprinting, hDistance, data, cc, false);
|
double hAllowedDistance = getAllowedhDist(player, from, to, sprinting, downStream, hDistance, data, cc, false);
|
||||||
|
|
||||||
// Account for flowing liquids (only if needed).
|
|
||||||
// Assume: If in liquids this would be placed right here.
|
|
||||||
// TODO: Consider data.mediumLiftOff != ...GROUND
|
|
||||||
if (hDistance > swimmingSpeed && from.isInLiquid() && from.isDownStream(xDistance, zDistance)) {
|
|
||||||
hAllowedDistance *= modDownStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Judge if horizontal speed is above limit.
|
// Judge if horizontal speed is above limit.
|
||||||
// double hDistanceAboveLimit = hDistance - hAllowedDistance - data.horizontalFreedom;
|
// double hDistanceAboveLimit = hDistance - hAllowedDistance - data.horizontalFreedom;
|
||||||
@ -196,7 +192,7 @@ public class SurvivalFly extends Check {
|
|||||||
// TODO: Use velocity already here ?
|
// TODO: Use velocity already here ?
|
||||||
// After failure permission checks ( + speed modifier + sneaking + blocking + speeding) and velocity (!).
|
// After failure permission checks ( + speed modifier + sneaking + blocking + speeding) and velocity (!).
|
||||||
if (hDistanceAboveLimit > 0){
|
if (hDistanceAboveLimit > 0){
|
||||||
hAllowedDistance = getAllowedhDist(player, from, to, sprinting, hDistance, data, cc, true);
|
hAllowedDistance = getAllowedhDist(player, from, to, sprinting, downStream, hDistance, data, cc, true);
|
||||||
// hDistanceAboveLimit = hDistance - hAllowedDistance - data.horizontalFreedom - extraUsed;
|
// hDistanceAboveLimit = hDistance - hAllowedDistance - data.horizontalFreedom - extraUsed;
|
||||||
if (hFreedom > 0){
|
if (hFreedom > 0){
|
||||||
hDistanceAboveLimit = hDistance - hAllowedDistance - extraUsed - hFreedom;
|
hDistanceAboveLimit = hDistance - hAllowedDistance - extraUsed - hFreedom;
|
||||||
@ -801,7 +797,7 @@ public class SurvivalFly extends Check {
|
|||||||
* @param cc
|
* @param cc
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private double getAllowedhDist(final Player player, final PlayerLocation from, final PlayerLocation to, final boolean sprinting, final double hDistance, final MovingData data, final MovingConfig cc, boolean checkPermissions)
|
private double getAllowedhDist(final Player player, final PlayerLocation from, final PlayerLocation to, final boolean sprinting, final boolean downStream, final double hDistance, final MovingData data, final MovingConfig cc, boolean checkPermissions)
|
||||||
{
|
{
|
||||||
if (checkPermissions) tags.add("permchecks");
|
if (checkPermissions) tags.add("permchecks");
|
||||||
// TODO: re-arrange for fastest checks first (check vs. allowed distance
|
// TODO: re-arrange for fastest checks first (check vs. allowed distance
|
||||||
@ -838,6 +834,13 @@ public class SurvivalFly extends Check {
|
|||||||
// If the player is on ice, give him an higher maximum speed.
|
// If the player is on ice, give him an higher maximum speed.
|
||||||
if (data.sfFlyOnIce > 0) hAllowedDistance *= modIce;
|
if (data.sfFlyOnIce > 0) hAllowedDistance *= modIce;
|
||||||
|
|
||||||
|
// Account for flowing liquids (only if needed).
|
||||||
|
// Assume: If in liquids this would be placed right here.
|
||||||
|
// TODO: Consider data.mediumLiftOff != ...GROUND
|
||||||
|
if (downStream) {
|
||||||
|
hAllowedDistance *= modDownStream;
|
||||||
|
}
|
||||||
|
|
||||||
if (hDistance <= hAllowedDistance) return hAllowedDistance;
|
if (hDistance <= hAllowedDistance) return hAllowedDistance;
|
||||||
|
|
||||||
// Speed amplifier.
|
// Speed amplifier.
|
||||||
|
Loading…
Reference in New Issue
Block a user