mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-02-05 22:31:26 +01:00
Make fight.reach distances (survival) configurable.
This commit is contained in:
parent
a04f4ad882
commit
c075e67f8f
@ -98,6 +98,10 @@ public class FightConfig extends ACheckConfig {
|
||||
public final long reachPenalty;
|
||||
public final boolean reachPrecision;
|
||||
public final boolean reachReduce;
|
||||
public final double reachSurvivalDistance;
|
||||
public final double reachReduceDistance;
|
||||
public final double reachReduceStep;
|
||||
|
||||
public final ActionList reachActions;
|
||||
|
||||
public final boolean selfHitCheck;
|
||||
@ -116,7 +120,7 @@ public class FightConfig extends ACheckConfig {
|
||||
// Special flags:
|
||||
public final boolean yawRateCheck;
|
||||
public final boolean cancelDead;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new fight configuration.
|
||||
*
|
||||
@ -157,9 +161,12 @@ public class FightConfig extends ACheckConfig {
|
||||
noSwingActions = data.getOptimizedActionList(ConfPaths.FIGHT_NOSWING_ACTIONS, Permissions.FIGHT_NOSWING);
|
||||
|
||||
reachCheck = data.getBoolean(ConfPaths.FIGHT_REACH_CHECK);
|
||||
reachSurvivalDistance = data.getDouble(ConfPaths.FIGHT_REACH_SURVIVALDISTANCE, 3.5, 6.0, 4.4);
|
||||
reachPenalty = data.getLong(ConfPaths.FIGHT_REACH_PENALTY);
|
||||
reachPrecision = data.getBoolean(ConfPaths.FIGHT_REACH_PRECISION);
|
||||
reachReduce = data.getBoolean(ConfPaths.FIGHT_REACH_REDUCE);
|
||||
reachReduceDistance = data.getDouble(ConfPaths.FIGHT_REACH_REDUCEDISTANCE, 0, reachSurvivalDistance, 0.9);
|
||||
reachReduceStep = data.getDouble(ConfPaths.FIGHT_REACH_REDUCESTEP, 0, reachReduceDistance, 0.15);
|
||||
reachActions = data.getOptimizedActionList(ConfPaths.FIGHT_REACH_ACTIONS, Permissions.FIGHT_REACH);
|
||||
|
||||
selfHitCheck = data.getBoolean(ConfPaths.FIGHT_SELFHIT_CHECK);
|
||||
|
@ -32,15 +32,6 @@ public class Reach extends Check {
|
||||
|
||||
/** The maximum distance allowed to interact with an entity in creative mode. */
|
||||
public static final double CREATIVE_DISTANCE = 6D;
|
||||
|
||||
/** The maximum distance allowed to interact with an entity in survival mode. */
|
||||
public static final double SURVIVAL_DISTANCE = 4.25D;
|
||||
|
||||
/** Amount which can be reduced by reach adaption. */
|
||||
public static final double DYNAMIC_RANGE = 0.75;
|
||||
|
||||
/** Adaption amount for dynamic range. */
|
||||
public static final double DYNAMIC_STEP = DYNAMIC_RANGE / 3.0;
|
||||
|
||||
/** Additum for distance, based on entity. */
|
||||
private static double getDistMod(final Entity damaged) {
|
||||
@ -74,6 +65,13 @@ public class Reach extends Check {
|
||||
final FightData data = FightData.getData(player);
|
||||
|
||||
boolean cancel = false;
|
||||
|
||||
// The maximum distance allowed to interact with an entity in survival mode.
|
||||
final double SURVIVAL_DISTANCE = cc.reachSurvivalDistance; // 4.4D;
|
||||
// Amount which can be reduced by reach adaption.
|
||||
final double DYNAMIC_RANGE = cc.reachReduceDistance; // 0.9
|
||||
// Adaption amount for dynamic range.
|
||||
final double DYNAMIC_STEP = cc.reachReduceStep / SURVIVAL_DISTANCE; // 0.15
|
||||
|
||||
final double distanceLimit = player.getGameMode() == GameMode.CREATIVE ? CREATIVE_DISTANCE : SURVIVAL_DISTANCE + getDistMod(damaged);
|
||||
final double distanceMin = (distanceLimit - DYNAMIC_RANGE) / distanceLimit;
|
||||
@ -145,8 +143,9 @@ public class Reach extends Check {
|
||||
if (data.reachLastViolationTime + cc.reachPenalty > System.currentTimeMillis()) {
|
||||
// A safeguard to avoid people getting stuck in penalty time indefinitely in case the system time of the
|
||||
// server gets changed.
|
||||
if (data.reachLastViolationTime > System.currentTimeMillis())
|
||||
data.reachLastViolationTime = 0;
|
||||
if (data.reachLastViolationTime > System.currentTimeMillis()){
|
||||
data.reachLastViolationTime = 0;
|
||||
}
|
||||
|
||||
// He is in penalty time, therefore request cancelling of the event.
|
||||
cancelByPenalty = !cancel;
|
||||
|
@ -417,9 +417,12 @@ public abstract class ConfPaths {
|
||||
|
||||
private static final String FIGHT_REACH = FIGHT + "reach.";
|
||||
public static final String FIGHT_REACH_CHECK = FIGHT_REACH + "active";
|
||||
public static final String FIGHT_REACH_SURVIVALDISTANCE = FIGHT_REACH + "survivaldistance";
|
||||
public static final String FIGHT_REACH_PENALTY = FIGHT_REACH + "penalty";
|
||||
public static final String FIGHT_REACH_PRECISION = FIGHT_REACH + "precision";
|
||||
public static final String FIGHT_REACH_REDUCE = FIGHT_REACH + "reduce";
|
||||
public static final String FIGHT_REACH_REDUCEDISTANCE = FIGHT_REACH + "reducedistance";
|
||||
public static final String FIGHT_REACH_REDUCESTEP = FIGHT_REACH + "reducestep";
|
||||
public static final String FIGHT_REACH_ACTIONS = FIGHT_REACH + "actions";
|
||||
|
||||
public static final String FIGHT_SELFHIT = FIGHT + "selfhit.";
|
||||
|
@ -328,8 +328,11 @@ public class DefaultConfig extends ConfigFile {
|
||||
set(ConfPaths.FIGHT_NOSWING_ACTIONS, "cancel vl>10 log:noswing:0:5:if cancel");
|
||||
|
||||
set(ConfPaths.FIGHT_REACH_CHECK, true);
|
||||
set(ConfPaths.FIGHT_REACH_SURVIVALDISTANCE, 4.4);
|
||||
set(ConfPaths.FIGHT_REACH_PENALTY, 500);
|
||||
set(ConfPaths.FIGHT_REACH_REDUCE, true);
|
||||
set(ConfPaths.FIGHT_REACH_REDUCEDISTANCE, 0.9);
|
||||
set(ConfPaths.FIGHT_REACH_REDUCESTEP, 0.15);
|
||||
set(ConfPaths.FIGHT_REACH_ACTIONS, "cancel vl>10 log:freach:2:5:if cancel");
|
||||
|
||||
set(ConfPaths.FIGHT_SELFHIT_CHECK, true);
|
||||
|
Loading…
Reference in New Issue
Block a user