Reduce false positives with jumping almost onto block edges.

Also begin to rearrange lostground workaround checking.
This commit is contained in:
asofold 2013-02-27 21:04:12 +01:00
parent 9d1f7924b9
commit e0c6e9ebdd

View File

@ -103,7 +103,7 @@ public class SurvivalFly extends Check {
// "Lost ground" workaround. // "Lost ground" workaround.
if (fromOnGround || from.isResetCond()) resetFrom = true; if (fromOnGround || from.isResetCond()) resetFrom = true;
else if (lostGround(player, from, to, yDistance, sprinting, data, cc)){ else if (lostGround(player, from, to, hDistance, yDistance, sprinting, data, cc)){
// TODO: Consider && !resetTo ? // TODO: Consider && !resetTo ?
// TODO: Confine by max y distance and min xz-distance? // TODO: Confine by max y distance and min xz-distance?
resetFrom = true; resetFrom = true;
@ -480,27 +480,29 @@ public class SurvivalFly extends Check {
* @param cc * @param cc
* @return * @return
*/ */
private boolean lostGround(final Player player, final PlayerLocation from, final PlayerLocation to, final double yDistance, final boolean sprinting, final MovingData data, final MovingConfig cc) { private boolean lostGround(final Player player, final PlayerLocation from, final PlayerLocation to, final double hDistance, final double yDistance, final boolean sprinting, final MovingData data, final MovingConfig cc) {
// Don't set "useWorkaround = x()", to avoid potential trouble with
// reordering to come, and similar. // TODO: fast exclusion returns.
boolean useWorkaround = false; // TODO: order checks such that most frequent match comes first.
boolean setBackSafe = false; // Let compiler remove this if necessary. // TODO: re-organize for faster exclusions (hDistance, yDistance).
// Check for moving off stairs. // Check for moving off stairs.
if (!useWorkaround && from.isAboveStairs()) { if (from.isAboveStairs()) {
// TODO: This needs some safety guards. // TODO: This needs some safety guards.
useWorkaround = true; return applyWorkaround(player, from, true, data);
setBackSafe = true;
} }
// Check for "lost touch", for when moving events are missing somehow. // Check for "lost touch", for when moving events are missing somehow.
// Half block step up. // Half block step up.
if (!useWorkaround && yDistance > 0 && yDistance <= 0.5 && to.isOnGround() && from.isOnGround(0.5 - Math.abs(yDistance))){ if (yDistance >= 0 && yDistance <= 0.5 && hDistance < 0.5 && to.isOnGround()){
useWorkaround = true; // TODO: Also confine concerning hDist !
setBackSafe = true; if (data.sfLastYDist < 0 || from.isOnGround(0.5 - Math.abs(yDistance))){
return applyWorkaround(player, from, true, data);
}
} }
final double setBackYDistance = to.getY() - data.getSetBackY(); final double setBackYDistance = to.getY() - data.getSetBackY();
// Check for sprinting down blocks etc. // Check for sprinting down blocks etc.
if (!useWorkaround && yDistance <= 0.0 && Math.abs(yDistance) <= 0.5 && data.sfLastYDist <= yDistance && data.sfJumpPhase <= 7 && setBackYDistance < 0 && !to.isOnGround()){ if (yDistance <= 0.0 && Math.abs(yDistance) <= 0.5 && data.sfLastYDist <= yDistance && data.sfJumpPhase <= 7 && setBackYDistance < 0 && !to.isOnGround()){
// TODO: setbackydist: <= - 1.0 or similar // TODO: setbackydist: <= - 1.0 or similar
// TODO: <= 7 might work with speed II, not sure with above. // TODO: <= 7 might work with speed II, not sure with above.
// TODO: account for speed/sprint // TODO: account for speed/sprint
@ -508,18 +510,16 @@ public class SurvivalFly extends Check {
if (from.isOnGround(0.6, 0.4, 0, 0L) ){ if (from.isOnGround(0.6, 0.4, 0, 0L) ){
// TODO: further narrow down bounds ? // TODO: further narrow down bounds ?
// Temporary "fix". // Temporary "fix".
useWorkaround = true; return applyWorkaround(player, from, true, data);
setBackSafe = true;
} }
} }
// Check for jumping up strange blocks like flower pots on top of other blocks. // Check for jumping up strange blocks like flower pots on top of other blocks.
if (!useWorkaround && yDistance == 0 && data.sfLastYDist > 0 && data.sfLastYDist < 0.25 && data.sfJumpPhase <= 6 + data.jumpAmplifier * 3 && setBackYDistance > 1.0 && setBackYDistance < 1.5 + 0.2 * data.jumpAmplifier && !to.isOnGround()){ if (yDistance == 0 && data.sfLastYDist > 0 && data.sfLastYDist < 0.25 && data.sfJumpPhase <= 6 + data.jumpAmplifier * 3 && setBackYDistance > 1.0 && setBackYDistance < 1.5 + 0.2 * data.jumpAmplifier && !to.isOnGround()){
// TODO: confine by block types ? // TODO: confine by block types ?
if (from.isOnGround(0.25, 0.4, 0, 0L) ){ if (from.isOnGround(0.25, 0.4, 0, 0L) ){
// Temporary "fix". // Temporary "fix".
useWorkaround = true; return applyWorkaround(player, from, true, data);
setBackSafe = true;
} }
} }
@ -527,7 +527,7 @@ public class SurvivalFly extends Check {
// TODO: Check if the set-back distance still has relevance. // TODO: Check if the set-back distance still has relevance.
// TODO: Interpolation might also be necessary between from and to ! // TODO: Interpolation might also be necessary between from and to !
// TODO: Check use of jumpamplifier. // TODO: Check use of jumpamplifier.
if (!useWorkaround && data.fromX != Double.MAX_VALUE && yDistance > 0 && yDistance <= 0.5 + 0.2 * data.jumpAmplifier && data.sfLastYDist < 0 && !to.isOnGround()) { if (data.fromX != Double.MAX_VALUE && yDistance > 0 && yDistance <= 0.5 + 0.2 * data.jumpAmplifier && data.sfLastYDist < 0 && !to.isOnGround()) {
// TODO: Check if last-y-dist or sprinting should be considered. // TODO: Check if last-y-dist or sprinting should be considered.
if (setBackYDistance > 0D && setBackYDistance <= 1.5D + 0.2 * data.jumpAmplifier || setBackYDistance < 0 && Math.abs(setBackYDistance) < 3.0) { if (setBackYDistance > 0D && setBackYDistance <= 1.5D + 0.2 * data.jumpAmplifier || setBackYDistance < 0 && Math.abs(setBackYDistance) < 3.0) {
// Interpolate from last to-coordinates to the from // Interpolate from last to-coordinates to the from
@ -545,33 +545,38 @@ public class SurvivalFly extends Check {
// TODO: Might set margin higher depending on distance to 0 of block and last y distance etc. // TODO: Might set margin higher depending on distance to 0 of block and last y distance etc.
// TODO: check with iY + 0.25 removed. // TODO: check with iY + 0.25 removed.
if (BlockProperties.isOnGround(from.getBlockCache(), Math.min(data.fromX, from.getX()) - r, iY - yMargin, Math.min(data.fromZ, from.getZ()) - r, Math.max(data.fromX, from.getX()) + r, iY + 0.25, Math.max(data.fromZ, from.getZ()) + r, 0L)) { if (BlockProperties.isOnGround(from.getBlockCache(), Math.min(data.fromX, from.getX()) - r, iY - yMargin, Math.min(data.fromZ, from.getZ()) - r, Math.max(data.fromX, from.getX()) + r, iY + 0.25, Math.max(data.fromZ, from.getZ()) + r, 0L)) {
useWorkaround = true; return applyWorkaround(player, from, true, data);
setBackSafe = true;
} }
} }
} }
} }
if (useWorkaround) { // !toOnGround && to.isAboveStairs()) { // Nothing found.
// Set the new setBack and reset the jumpPhase. return false;
// TODO: Some interpolated position ? }
// TODO: (Task list: sharpen when this is used, might remove isAboveStairs!)
if (setBackSafe) data.setSetBack(from); /**
else{ *
// TODO: This seems dubious ! * @return true.
// Consider: 1.0 + ? or max(from.getY(), 1.0 + ...) ? */
data.setSetBackY(Location.locToBlock(data.getSetBackY())); private boolean applyWorkaround(final Player player, final PlayerLocation from, final boolean setBackSafe, final MovingData data){
} // Set the new setBack and reset the jumpPhase.
// data.ground ? // TODO: Some interpolated position ?
// ? set jumpphase to height / 0.15 ? // TODO: (Task list: sharpen when this is used, might remove isAboveStairs!)
data.sfJumpPhase = 0; if (setBackSafe) data.setSetBack(from);
data.jumpAmplifier = mcAccess.getJumpAmplifier(player); else{
data.clearAccounting(); // TODO: This seems dubious !
// Tell NoFall that we assume the player to have been on ground somehow. // Consider: 1.0 + ? or max(from.getY(), 1.0 + ...) ?
data.noFallAssumeGround = true; data.setSetBackY(Location.locToBlock(data.getSetBackY()));
tags.add("lostground");
return true;
} }
else return false; // data.ground ?
// ? set jumpphase to height / 0.15 ?
data.sfJumpPhase = 0;
data.jumpAmplifier = mcAccess.getJumpAmplifier(player);
data.clearAccounting();
// Tell NoFall that we assume the player to have been on ground somehow.
data.noFallAssumeGround = true;
tags.add("lostground");
return true;
} }
/** /**