Refine conditions for passable.

* Do not check if moving inside of a block that is ignored by passable.
* ray-tracing: Always check vclip up AND down.
This commit is contained in:
asofold 2013-07-15 02:12:48 +02:00
parent 75e21797e1
commit 268c51b729

View File

@ -22,16 +22,18 @@ public class Passable extends Check {
public Location check(final Player player, Location loc, final PlayerLocation from, final PlayerLocation to, final MovingData data, final MovingConfig cc)
{
// Simple check (only from, to, player.getLocation).
// TODO: if (!from.isSameCoords(loc)){...check passable for loc -> from !?... + sf etc too?}
// TODO: Future: Account for the players bounding box? [test very-strict setting for at least the end points...]
String tags = "";
// Block distances (sum, max) for from-to (not for loc!).
final int manhattan = from.manhattan(to);
// Skip moves inside of ignored blocks right away.
if (manhattan == 0 && (BlockProperties.getBlockFlags(from.getTypeId()) & BlockProperties.F_IGN_PASSABLE) != 0){
return null;
}
boolean toPassable = to.isPassable();
// General condition check for using ray-tracing.
// TODO: consider in case of flying: sf does not cover moving up.
if (toPassable && cc.passableRayTracingCheck && (!cc.passableRayTracingVclipOnly || from.getY() > to.getY()) && (!cc.passableRayTracingBlockChangeOnly || manhattan > 0)){
if (toPassable && cc.passableRayTracingCheck && (!cc.passableRayTracingVclipOnly || from.getY() != to.getY()) && (!cc.passableRayTracingBlockChangeOnly || manhattan > 0)){
rayTracing.set(from, to);
rayTracing.loop();
if (rayTracing.collides() || rayTracing.getStepsDone() >= rayTracing.getMaxSteps()){
@ -53,9 +55,9 @@ public class Passable extends Check {
toPassable = false;
tags = "raytracing_";
}
// TODO: Future: If accuracy is demanded, also check the head position (or bounding box right away).
rayTracing.cleanup();
}
// TODO: Future: If accuracy is demanded, also check the head position (or bounding box right away).
rayTracing.cleanup();
}
// TODO: Checking order: If loc is not the same as from, a quick return here might not be wanted.