-
-
Notifications
You must be signed in to change notification settings - Fork 55
/
FlyingBlockExaminer.java
30 lines (26 loc) · 1.01 KB
/
FlyingBlockExaminer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package net.citizensnpcs.api.astar.pathfinder;
import org.bukkit.Material;
import org.bukkit.util.Vector;
public class FlyingBlockExaminer implements BlockExaminer {
@Override
public float getCost(BlockSource source, PathPoint point) {
Vector pos = point.getVector();
Material above = source.getMaterialAt(pos.clone().add(UP));
Material in = source.getMaterialAt(pos);
if (above == Material.WEB || in == Material.WEB) {
return 1F;
}
return 0.5F;
}
@Override
public PassableState isPassable(BlockSource source, PathPoint point) {
Vector pos = point.getVector();
Material above = source.getMaterialAt(pos.clone().add(UP));
Material in = source.getMaterialAt(pos);
if (MinecraftBlockExaminer.isLiquid(above, in)) {
return PassableState.UNPASSABLE;
}
return PassableState.fromBoolean(MinecraftBlockExaminer.canStandIn(above, in));
}
private static final Vector UP = new Vector(0, 1, 0);
}