Adjust use of isHeadObstructed.

* Remove extra conditions for from.isHeadObstructed in vDistAir.
* Account for yDistance in more places. Use the maximum of the default
margin and yDistance.
* Add a tag for not setting low jump, due to the head being obstructed.

Fixes:
* Issues with 2-high ceiling with normal ground.

Issues remaining:
* Ice floor + 2-high ceiling.
* Jump/bunny with head blocked, moving to where the head is not blocked.
This commit is contained in:
asofold 2015-12-13 14:23:27 +01:00
parent 532f8e3a4b
commit 742877dd6d
2 changed files with 34 additions and 15 deletions

View File

@ -930,7 +930,7 @@ public class SurvivalFly extends Check {
vDistRelVL = true;
}
} // else: yDistDiffEx <= 0.0
else if (yDistance >= 0.0) {
else if (yDistance >= 0.0) { // Moved too short.
if (!strictVdistRel || Math.abs(yDistDiffEx) <= GRAVITY_SPAN || vAllowedDistance <= 0.2) {
// Allow jumping less high unless within "strict envelope".
// TODO: Extreme anti-jump effects, perhaps.
@ -951,9 +951,7 @@ public class SurvivalFly extends Check {
// Too strong decrease with velocity.
// TODO: Observed when moving off water, might be confined by that.
}
else if (to.isHeadObstructed()
// TODO: Not sure about the second case:
|| data.lastYDist > 0.0 && yDistance == 0.0 && from.isHeadObstructed()) {
else if (to.isHeadObstructed() || from.isHeadObstructedMax(yDistance)) {
// Head is blocked, thus a shorter move.
}
else {
@ -1463,7 +1461,14 @@ public class SurvivalFly extends Check {
}
if (setBackYDistance < estimate) {
// Low jump, further check if there might have been a reason for low jumping.
if (!from.isHeadObstructed() && !to.isHeadObstructed()) {
if (yDistance >= 0.0 && from.isHeadObstructedMax(yDistance)
|| yDistance < 0.0 && from.isHeadObstructed()
|| to.isHeadObstructed() // TODO: Not sure this should count at all (should with 1st on might be multiple?).
) {
// Exempt.
tags.add("nolowjump_ceil");
}
else {
tags.add("lowjump_set");
data.sfLowJump = true;
}
@ -1645,15 +1650,17 @@ public class SurvivalFly extends Check {
// TODO: LiftOffEnvelope.allowBunny ?
if (data.liftOffEnvelope == LiftOffEnvelope.NORMAL
&& (!data.sfLowJump || data.sfNoLowJump)
// Y-distance envelope.
// 0: Y-distance envelope.
&& yDistance >= 0.0
&& (
yDistance > 0.0
&& yDistance > data.liftOffEnvelope.getMinJumpGain(data.jumpAmplifier) - GRAVITY_SPAN
|| yDistance > 0.0 && from.isHeadObstructed(yDistance + from.getyOnGround())
|| (cc.sfGroundHop && yDistance >= 0 || yDistance == 0.0 && !data.fromWasReset) // TODO: (2nd) demand try next jump.
|| from.isHeadObstructedMax(yDistance)
// TODO: (2nd below) demand try next jump.
|| (cc.sfGroundHop || yDistance == 0.0 && !data.fromWasReset)
&& hAllowedDistance > 0.0 && hDistance / hAllowedDistance < 1.35
)
// Bad auto indent.
// 0: Bad auto indent.
&& (data.sfJumpPhase == 0 && from.isOnGround() || data.sfJumpPhase <= 1 && (data.noFallAssumeGround || data.fromWasReset) || double_bunny)
&& !from.isResetCond() && !to.isResetCond() // TODO: !to.isResetCond() should be reviewed.
) {

View File

@ -660,26 +660,38 @@ public class PlayerLocation {
/**
* Test if something solid/ground-like collides within the given margin
* above the height of the player.
* above the eye height of the player.
*
* @param marginAboveHeight
* @param marginAboveEyeHeight
* @return
*/
public boolean isHeadObstructed(double marginAboveHeight) {
return BlockProperties.collides(blockCache, x - width, y + eyeHeight, z - width, x + width, y + eyeHeight + marginAboveHeight, z + width, BlockProperties.F_GROUND | BlockProperties.F_SOLID);
public boolean isHeadObstructed(double marginAboveEyeHeight) {
return BlockProperties.collides(blockCache, x - width, y + eyeHeight, z - width, x + width, y + eyeHeight + marginAboveEyeHeight, z + width, BlockProperties.F_GROUND | BlockProperties.F_SOLID);
}
/**
* Test if something solid/ground-like collides within a default margin
* above the height of the player. Margin is yOnGround + max(0.0, 2.0 - eyeHeight).
* above the eye height of the player. Margin is yOnGround + max(0.0, 2.0 -
* eyeHeight).
*
* @param marginAboveHeight
* @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);
}
/**
* Convenience method for testing for either.
* @return