Skip to content

Commit

Permalink
If neither from nor loc is passable, set back to from (earliest) rather.
Browse files Browse the repository at this point in the history
  • Loading branch information
asofold committed Oct 29, 2014
1 parent f29acd3 commit 6c0e1bb
Showing 1 changed file with 5 additions and 2 deletions.
Expand Up @@ -103,20 +103,22 @@ private Location potentialViolation(final Player player, Location loc, final Pla
loc = null;
tags += "into";
} else if (BlockProperties.isPassable(from.getBlockCache(), loc.getX(), loc.getY(), loc.getZ(), from.getTypeId(lbX, lbY, lbZ))) {
// Keep loc.
// Keep loc, because it it is passable.
tags += "into_shift";
}
// } else if (BlockProperties.isPassableExact(from.getBlockCache(), loc.getX(), loc.getY(), loc.getZ(), from.getTypeId(lbX, lbY, lbZ))) {
// (Mind that this can be the case on the same block theoretically.)
// Keep loc as set-back.
// }
else if (!from.isSameBlock(lbX, lbY, lbZ)) {
// Otherwise keep loc as set-back.
// Both loc and from are not passable. Use from as set.back (earliest).
tags += "cross_shift";
loc = null;
}
else if (manhattan == 1 && to.isBlockAbove(from) && BlockProperties.isPassable(from.getBlockCache(), from.getX(), from.getY() + player.getEyeHeight(), from.getZ(), from.getTypeId(from.getBlockX(), Location.locToBlock(from.getY() + player.getEyeHeight()), from.getBlockZ()))) {
// else if (to.isBlockAbove(from) && BlockProperties.isPassableExact(from.getBlockCache(), from.getX(), from.getY() + player.getEyeHeight(), from.getZ(), from.getTypeId(from.getBlockX(), Location.locToBlock(from.getY() + player.getEyeHeight()), from.getBlockZ()))) {
// Allow the move up if the head is free.
// TODO: Better distinguish ray-tracing (through something thin) or check to-head-passable too?
return null;
}
else if (manhattan > 0) {
Expand All @@ -137,6 +139,7 @@ else if (manhattan > 0) {

// Prefer the set-back location from the data.
if (data.hasSetBack()) {
// TODO: Review or make configurable.
final Location ref = data.getSetBack(to);
if (BlockProperties.isPassable(from.getBlockCache(), ref) || loc == null || TrigUtil.distance(from, loc) > 0.13) {
// if (BlockProperties.isPassableExact(from.getBlockCache(), ref)) {
Expand Down

0 comments on commit 6c0e1bb

Please sign in to comment.