mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-09 12:10:37 +01:00
SurvivalFly: Small reordering for efficiency/future.
This commit is contained in:
parent
5ddbe0896a
commit
15d7adba00
@ -115,27 +115,31 @@ public class SurvivalFly extends Check {
|
|||||||
final double setBackYDistance = to.getY() - data.setBack.getY();
|
final double setBackYDistance = to.getY() - data.setBack.getY();
|
||||||
// If the player has touched the ground but it hasn't been noticed by the plugin, the workaround is here.
|
// If the player has touched the ground but it hasn't been noticed by the plugin, the workaround is here.
|
||||||
if (!resetFrom){
|
if (!resetFrom){
|
||||||
// TODO: check versus last to position ?
|
// Don't set "useWorkaround = x()", to avoid potential trouble with reordering to come, and similar.
|
||||||
final boolean inconsistent = yDistance > 0 && yDistance < 0.5 && data.survivalFlyLastYDist < 0
|
boolean useWorkaround = false;
|
||||||
&& setBackYDistance > 0D && setBackYDistance <= 1.5D;
|
// Check for moving off stairs.
|
||||||
boolean useWorkaround = from.isAboveStairs();
|
if (!useWorkaround && from.isAboveStairs()) useWorkaround = true;
|
||||||
if (inconsistent){
|
// Check for "lost touch", for when moving events were not created, for instance (1/256).
|
||||||
if (cc.debug) System.out.println(player.getName() + " Y-INCONSISTENCY");
|
if (!useWorkaround){
|
||||||
if (!useWorkaround && data.fromX != Double.MAX_VALUE){
|
final boolean inconsistent = yDistance > 0 && yDistance < 0.5 && data.survivalFlyLastYDist < 0
|
||||||
// Interpolate from last to-coordinates to the from coordinates (with some safe-guard).
|
&& setBackYDistance > 0D && setBackYDistance <= 1.5D;
|
||||||
final double dX = from.getX() - data.fromX;
|
if (inconsistent){
|
||||||
final double dY = from.getY() - data.fromY;
|
if (cc.debug) System.out.println(player.getName() + " Y-INCONSISTENCY");
|
||||||
final double dZ = from.getZ() - data.fromZ;
|
if (data.fromX != Double.MAX_VALUE){
|
||||||
if (dX * dX + dY * dY + dZ * dZ < 0.5){ // TODO: adjust limit maybe.
|
// Interpolate from last to-coordinates to the from coordinates (with some safe-guard).
|
||||||
// Check full bounding box since last from.
|
final double dX = from.getX() - data.fromX;
|
||||||
if (cc.debug) System.out.println(player.getName() + " CONSIDER WORKAROUND");
|
final double dY = from.getY() - data.fromY;
|
||||||
final double minY = Math.min(data.toY, Math.min(data.fromY, from.getY()));
|
final double dZ = from.getZ() - data.fromZ;
|
||||||
final double iY = minY; // TODO ...
|
if (dX * dX + dY * dY + dZ * dZ < 0.5){ // TODO: adjust limit maybe.
|
||||||
final double r = from.getWidth() / 2.0;
|
// Check full bounding box since last from.
|
||||||
useWorkaround = BlockProperties.isOnGround(from.getBlockAccess(), Math.min(data.fromX, from.getX()) - r, iY - cc.yOnGround, Math.min(data.fromZ, from.getZ()) - r, Math.max(data.fromX, from.getX()) + r, iY + 0.25, Math.max(data.fromZ, from.getZ()) + r);
|
if (cc.debug) System.out.println(player.getName() + " CONSIDER WORKAROUND");
|
||||||
|
final double minY = Math.min(data.toY, Math.min(data.fromY, from.getY()));
|
||||||
}
|
final double iY = minY; // TODO ...
|
||||||
}
|
final double r = from.getWidth() / 2.0;
|
||||||
|
if (BlockProperties.isOnGround(from.getBlockAccess(), Math.min(data.fromX, from.getX()) - r, iY - cc.yOnGround, Math.min(data.fromZ, from.getZ()) - r, Math.max(data.fromX, from.getX()) + r, iY + 0.25, Math.max(data.fromZ, from.getZ()) + r)) useWorkaround = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (useWorkaround){ // !toOnGround && to.isAboveStairs()) {
|
if (useWorkaround){ // !toOnGround && to.isAboveStairs()) {
|
||||||
// Set the new setBack and reset the jumpPhase.
|
// Set the new setBack and reset the jumpPhase.
|
||||||
|
Loading…
Reference in New Issue
Block a user