Skip to content

Commit

Permalink
Add lostground_vcollide.
Browse files Browse the repository at this point in the history
For efficiency (several?) other cases will be removable, once we model
the per-move ground/medium properties more accurately also for the past
move(s). At least lostground_pyramid should be removed then.
  • Loading branch information
asofold committed Sep 28, 2015
1 parent f0c6ab6 commit 222c6bd
Showing 1 changed file with 17 additions and 2 deletions.
Expand Up @@ -704,7 +704,7 @@ private boolean lostGround(final Player player, final PlayerLocation from, final
}
// Descending.
if (yDistance <= 0) {
if (lostGroundDescend(player, from, to, hDistance, yDistance, sprinting, data, cc)) {
if (lostGroundDescend(player, from, loc, to, hDistance, yDistance, sprinting, data, cc)) {
return true;
}
}
Expand Down Expand Up @@ -1828,12 +1828,26 @@ private final boolean lostGroundEdgeAsc(final Player player, final BlockCache bl
* @param cc
* @return
*/
private boolean lostGroundDescend(final Player player, final PlayerLocation from, final PlayerLocation to, final double hDistance, final double yDistance, final boolean sprinting, final MovingData data, final MovingConfig cc) {
private boolean lostGroundDescend(final Player player, final PlayerLocation from, final Location loc, final PlayerLocation to, final double hDistance, final double yDistance, final boolean sprinting, final MovingData data, final MovingConfig cc) {
// TODO: re-organize for faster exclusions (hDistance, yDistance).
// TODO: more strict conditions

final double setBackYDistance = to.getY() - data.getSetBackY();

// Collides vertically.
// Note: checking loc should make sense, rather if loc is higher than from?
if (!to.isOnGround() && from.isOnGround(from.getY() - to.getY() + 0.001)) {
// Test for passability of the entire box, roughly from feet downwards.
// TODO: Efficiency with Location instances.
// TODO: Full bounds check (!).
final Location ref = from.getLocation();
ref.setY(to.getY());
if (BlockProperties.isPassable(from.getLocation(), ref)) {
// TODO: Needs new model (store detailed on-ground properties).
return applyLostGround(player, from, false, data, "vcollide");
}
}

if (data.sfJumpPhase <= 7) {
// Check for sprinting down blocks etc.
if (data.lastYDist <= yDistance && setBackYDistance < 0 && !to.isOnGround()) {
Expand All @@ -1844,6 +1858,7 @@ private boolean lostGroundDescend(final Player player, final PlayerLocation from
if (from.isOnGround(0.6, 0.4, 0.0, 0L) ) {
// TODO: further narrow down bounds ?
// Temporary "fix".
// TODO: Seems to virtually always be preceded by a "vcollide" move.
return applyLostGround(player, from, true, data, "pyramid");
}
}
Expand Down

0 comments on commit 222c6bd

Please sign in to comment.