Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add FlyingBlockExaminer and fix an issue with cloning NavigatorParame…
…ters
- Loading branch information
Showing
7 changed files
with
85 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/net/citizensnpcs/api/astar/pathfinder/FlyingBlockExaminer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 boolean 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 false; | ||
} | ||
return MinecraftBlockExaminer.canStandIn(above, in); | ||
} | ||
|
||
private static final Vector UP = new Vector(0, 1, 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters