mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-07 11:10:05 +01:00
Adjust checking for 'head obstructed'.
Remove ambigue method, apply a different default margin, up to the next block in steps of 0.25, if within 0.35 reach. Default methods use this correction now, so some places might check with too high a margin now.
This commit is contained in:
parent
36c018bc3c
commit
f22bf88824
@ -219,11 +219,11 @@ public class SurvivalFly extends Check {
|
||||
}
|
||||
|
||||
// Check if head is obstructed.
|
||||
if (!resetFrom || !resetTo) {
|
||||
data.thisMove.headObstructed = (yDistance > 0.0 ? from.isHeadObstructedMax(yDistance) : from.isHeadObstructed())
|
||||
// || to.isHeadObstructed() // Best not have this one.
|
||||
;
|
||||
}
|
||||
//if (!resetFrom || !resetTo) {
|
||||
data.thisMove.headObstructed = (yDistance > 0.0 ? from.isHeadObstructed(yDistance) : from.isHeadObstructed())
|
||||
// || to.isHeadObstructed() // Best not have this one.
|
||||
;
|
||||
//}
|
||||
|
||||
//////////////////////
|
||||
// Horizontal move.
|
||||
@ -2260,7 +2260,7 @@ public class SurvivalFly extends Check {
|
||||
final String hBuf = (data.sfHorizontalBuffer < 1.0 ? ((" hbuf=" + StringUtil.fdec3.format(data.sfHorizontalBuffer))) : "");
|
||||
final String lostSprint = (data.lostSprintCount > 0 ? (" lostSprint=" + data.lostSprintCount) : "");
|
||||
final String hVelUsed = hFreedom > 0 ? " hVelUsed=" + StringUtil.fdec3.format(hFreedom) : "";
|
||||
builder.append("\nonground: " + (data.thisMove.touchedGroundWorkaround ? "(assumeonground) " : "") + (fromOnGround ? "onground -> " : (resetFrom ? "resetcond -> " : "--- -> ")) + (toOnGround ? "onground" : (resetTo ? "resetcond" : "---")) + ", jumpphase: " + data.sfJumpPhase + ", liftoff: " + data.liftOffEnvelope.name() + "(" + data.insideMediumCount + ")");
|
||||
builder.append("\nonground: " + (data.thisMove.headObstructed ? "(head obstr.) " : "") + (data.thisMove.touchedGroundWorkaround ? "(touched ground) " : "") + (fromOnGround ? "onground -> " : (resetFrom ? "resetcond -> " : "--- -> ")) + (toOnGround ? "onground" : (resetTo ? "resetcond" : "---")) + ", jumpphase: " + data.sfJumpPhase + ", liftoff: " + data.liftOffEnvelope.name() + "(" + data.insideMediumCount + ")");
|
||||
final String dHDist = (lastMove.toIsValid && Math.abs(lastMove.hDistance - hDistance) > 0.0005) ? ("(" + (hDistance > lastMove.hDistance ? "+" : "") + StringUtil.fdec3.format(hDistance - lastMove.hDistance) + ")") : "";
|
||||
builder.append("\n" + " hDist: " + StringUtil.fdec3.format(hDistance) + dHDist + " / " + StringUtil.fdec3.format(hAllowedDistance) + hBuf + lostSprint + hVelUsed + " , vDist: " + StringUtil.fdec3.format(yDistance) + (!lastMove.toIsValid ? "" : (" (" + (yDistance > lastMove.yDistance ? "+" : "") + StringUtil.fdec3.format(yDistance - lastMove.yDistance) + ")")) + " / " + StringUtil.fdec3.format(vAllowedDistance) + ", sby=" + (data.hasSetBack() ? (data.getSetBackY() + " (" + StringUtil.fdec3.format(to.getY() - data.getSetBackY()) + " / " + data.liftOffEnvelope.getMaxJumpHeight(data.jumpAmplifier) + ")") : "?"));
|
||||
if (data.verVelUsed != null) {
|
||||
|
@ -701,30 +701,41 @@ public class PlayerLocation {
|
||||
* @return
|
||||
*/
|
||||
public boolean isHeadObstructed(double marginAboveEyeHeight) {
|
||||
return isHeadObstructed(marginAboveEyeHeight, true); // TODO: This is changed behavior, need to check calls.
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if something solid/ground-like collides within the given margin
|
||||
* above the eye height of the player.
|
||||
*
|
||||
* @param marginAboveEyeHeight
|
||||
* @param stepCorrection
|
||||
* If set to true, a correction method is used for leniency.
|
||||
* @return
|
||||
*/
|
||||
public boolean isHeadObstructed(double marginAboveEyeHeight, boolean stepCorrection) {
|
||||
if (stepCorrection) {
|
||||
double ref = maxY + marginAboveEyeHeight;
|
||||
ref = ref - Location.locToBlock(ref) + 0.35;
|
||||
for (double bound = 1.0; bound >= 0.0; bound -= 0.25) {
|
||||
if (ref >= bound) {
|
||||
// Use this for correction.
|
||||
marginAboveEyeHeight += bound + 0.35 - ref;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return BlockProperties.collides(blockCache, minX , maxY, minZ, maxX, maxY + marginAboveEyeHeight, maxZ, BlockProperties.F_GROUND | BlockProperties.F_SOLID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if something solid/ground-like collides within a default margin
|
||||
* above the eye height of the player. Margin is yOnGround + max(0.0, 2.0 -
|
||||
* eyeHeight).
|
||||
* Test if something solid/ground-like collides within a default
|
||||
* margin/estimation above the eye height of the player.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isHeadObstructed() {
|
||||
return isHeadObstructed(Math.max(0.0, 2.0 - eyeHeight) + yOnGround);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if something solid/ground-like collides within the maximum of the
|
||||
* default margin and the given margin above the eye height of the player.
|
||||
* Will add yOnGround to the given margin.
|
||||
*
|
||||
* @param marginAboveEyeHeight
|
||||
* @return
|
||||
*/
|
||||
public boolean isHeadObstructedMax(double marginAboveEyeHeight) {
|
||||
return isHeadObstructed(Math.max(marginAboveEyeHeight, 2.0 - eyeHeight) + yOnGround);
|
||||
return isHeadObstructed(0.0, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user