mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-10-06 10:27:26 +02:00
Let fight.direction use the location trace (simplified version @Iceee).
Allow 15 ticks total latency (2 x attacker + 1 x damaged) for the looping, decrease tolerance for direction by a lot.
This commit is contained in:
parent
dc1f5eced5
commit
4180d3b20b
@ -134,11 +134,11 @@ public class Direction extends Check {
|
|||||||
|
|
||||||
final double off;
|
final double off;
|
||||||
if (cc.directionStrict){
|
if (cc.directionStrict){
|
||||||
off = TrigUtil.combinedDirectionCheck(loc, player.getEyeHeight(), context.direction, dLoc.x, dLoc.y + context.damagedHeight / 2D, dLoc.z, context.damagedWidth, context.damagedHeight, TrigUtil.DIRECTION_PRECISION, 80.0);
|
off = TrigUtil.combinedDirectionCheck(loc, player.getEyeHeight(), context.direction, dLoc.x, dLoc.y + context.damagedHeight / 2D, dLoc.z, context.damagedWidth, context.damagedHeight, TrigUtil.DIRECTION_LOOP_PRECISION, 80.0);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// Also take into account the angle.
|
// Also take into account the angle.
|
||||||
off = TrigUtil.directionCheck(loc, player.getEyeHeight(), context.direction, dLoc.x, dLoc.y + context.damagedHeight / 2D, dLoc.z, context.damagedWidth, context.damagedHeight, TrigUtil.DIRECTION_PRECISION);
|
off = TrigUtil.directionCheck(loc, player.getEyeHeight(), context.direction, dLoc.x, dLoc.y + context.damagedHeight / 2D, dLoc.z, context.damagedWidth, context.damagedHeight, TrigUtil.DIRECTION_LOOP_PRECISION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (off > 0.1) {
|
if (off > 0.1) {
|
||||||
|
@ -116,6 +116,9 @@ public class FightConfig extends ACheckConfig {
|
|||||||
public final boolean cancelDead;
|
public final boolean cancelDead;
|
||||||
public final boolean knockBackVelocityPvP;
|
public final boolean knockBackVelocityPvP;
|
||||||
|
|
||||||
|
/** Maximum latency counted in ticks for the loop checks (reach, direction). */
|
||||||
|
public final long loopMaxLatencyTicks = 15; // TODO: Configurable, sections for players and entities.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new fight configuration.
|
* Instantiates a new fight configuration.
|
||||||
*
|
*
|
||||||
|
@ -339,7 +339,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
|
|||||||
final ReachContext reachContext = reachEnabled ? reach.getContext(player, loc, damaged, damagedLoc, data, cc, sharedContext) : null;
|
final ReachContext reachContext = reachEnabled ? reach.getContext(player, loc, damaged, damagedLoc, data, cc, sharedContext) : null;
|
||||||
final DirectionContext directionContext = directionEnabled ? direction.getContext(player, loc, damaged, damagedLoc, data, cc, sharedContext) : null;
|
final DirectionContext directionContext = directionEnabled ? direction.getContext(player, loc, damaged, damagedLoc, data, cc, sharedContext) : null;
|
||||||
|
|
||||||
final long traceOldest = tick; // - damagedTrace.getMaxSize(); // TODO: Set by window.
|
final long traceOldest = tick - cc.loopMaxLatencyTicks; // TODO: Set by latency-window.
|
||||||
// TODO: Iterating direction, which, static/dynamic choice.
|
// TODO: Iterating direction, which, static/dynamic choice.
|
||||||
final Iterator<TraceEntry> traceIt = damagedTrace.maxAgeIterator(traceOldest);
|
final Iterator<TraceEntry> traceIt = damagedTrace.maxAgeIterator(traceOldest);
|
||||||
|
|
||||||
|
@ -798,9 +798,9 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
|||||||
if (player.isInsideVehicle()) {
|
if (player.isInsideVehicle()) {
|
||||||
// TODO: refine (!).
|
// TODO: refine (!).
|
||||||
final Location ref = player.getVehicle().getLocation(useLoc);
|
final Location ref = player.getVehicle().getLocation(useLoc);
|
||||||
mData.resetPositions(ref);
|
mData.resetPositions(ref); // TODO: Consider using to and intercept cheat attempts in another way.
|
||||||
useLoc.setWorld(null);
|
useLoc.setWorld(null);
|
||||||
mData.updateTrace(player, ref, time);
|
mData.updateTrace(player, to, time); // TODO: Can you become invincible by sending special moves?
|
||||||
}
|
}
|
||||||
else if (!fromWorldName.equals(toWorldName)) {
|
else if (!fromWorldName.equals(toWorldName)) {
|
||||||
mData.resetPositions(to);
|
mData.resetPositions(to);
|
||||||
|
@ -18,8 +18,10 @@ public class TrigUtil {
|
|||||||
private static final Vector vec2 = new Vector();
|
private static final Vector vec2 = new Vector();
|
||||||
/** Multiply to get grad from rad. */
|
/** Multiply to get grad from rad. */
|
||||||
public static final double fRadToGrad = 360.0 / (2.0 * Math.PI);
|
public static final double fRadToGrad = 360.0 / (2.0 * Math.PI);
|
||||||
/** Some default precision value for the directionCheck method. */
|
/** Some default precision value for the classic fight.direction check. */
|
||||||
public static final double DIRECTION_PRECISION = 2.6;
|
public static final double DIRECTION_PRECISION = 2.6;
|
||||||
|
/** Precision for the fight.direction check within the LocationTrace loop. */
|
||||||
|
public static final double DIRECTION_LOOP_PRECISION = 0.5;
|
||||||
|
|
||||||
private static final Location useLoc = new Location(null, 0, 0, 0);
|
private static final Location useLoc = new Location(null, 0, 0, 0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user