Sharpen low-jump detection (box for detection, prevent improper reset).

This commit is contained in:
asofold 2015-01-06 01:42:12 +01:00
parent 7521f0169f
commit 6c83ebb02b

View File

@ -492,8 +492,11 @@ public class SurvivalFly extends Check {
data.setSetBack(to); data.setSetBack(to);
data.sfJumpPhase = 0; data.sfJumpPhase = 0;
data.clearAccounting(); data.clearAccounting();
data.sfLowJump = false;
data.sfNoLowJump = false; data.sfNoLowJump = false;
if (data.sfLowJump && resetFrom) {
// Prevent reset if coming from air (purpose of the flag).
data.sfLowJump = false;
}
} }
else if (resetFrom) { else if (resetFrom) {
// The player moved from ground. // The player moved from ground.
@ -822,14 +825,11 @@ public class SurvivalFly extends Check {
} }
if (setBackYDistance < estimate) { if (setBackYDistance < estimate) {
// Low jump, further check if there might have been a reason for low jumping. // Low jump, further check if there might have been a reason for low jumping.
final long flags = BlockProperties.F_GROUND | BlockProperties.F_SOLID; final double width = from.getWidth();
if ((BlockProperties.getBlockFlags(from.getTypeIdAbove()) & flags) == 0) { final long aboveFlags = BlockProperties.collectFlagsSimple(from.getBlockCache(), from.getX() - width, from.getY(), from.getZ() - width, from.getX() + width, from.getY() + 0.1, from.getZ() + width);
// Check block above that too (if high enough). if ((aboveFlags & (BlockProperties.F_GROUND | BlockProperties.F_SOLID)) == 0) {
final int refY = Location.locToBlock(from.getY() + 0.5); tags.add("lowjump");
if (refY == from.getBlockY() || (BlockProperties.getBlockFlags(from.getTypeId(from.getBlockX(), refY, from.getBlockZ())) & flags) == 0) { data.sfLowJump = true;
tags.add("lowjump");
data.sfLowJump = true;
}
} }
} }
} }