Skip to content

Commit

Permalink
Minor perf improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Apr 26, 2019
1 parent d7bbfe3 commit 943714b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
Expand Up @@ -8,10 +8,6 @@
import org.bukkit.block.BlockState;
import org.bukkit.material.Door;

import net.citizensnpcs.api.astar.pathfinder.BlockExaminer;
import net.citizensnpcs.api.astar.pathfinder.BlockSource;
import net.citizensnpcs.api.astar.pathfinder.MinecraftBlockExaminer;
import net.citizensnpcs.api.astar.pathfinder.PathPoint;
import net.citizensnpcs.api.astar.pathfinder.PathPoint.PathCallback;
import net.citizensnpcs.api.npc.NPC;

Expand All @@ -36,7 +32,7 @@ static class DoorOpener implements PathCallback {
public void run(NPC npc, Block point, ListIterator<Block> path) {
BlockState state = point.getState();
Door door = (Door) state.getData();
if (npc.getStoredLocation().distance(point.getLocation()) < 2) {
if (npc.getStoredLocation().distanceSquared(point.getLocation()) < 4) {
boolean bottom = !door.isTopHalf();
Block set = bottom ? point : point.getRelative(BlockFace.DOWN);
state = set.getState();
Expand Down
Expand Up @@ -180,7 +180,6 @@ public static boolean validPosition(Block in) {
Material.JUNGLE_FENCE, Material.ACACIA_FENCE, Material.DARK_OAK_FENCE);
private static final Set<Material> UNWALKABLE = EnumSet.of(Material.AIR, Material.LAVA, Material.CACTUS);
private static final Vector UP = new Vector(0, 1, 0);

private static Material WEB = SpigotUtil.isUsing1_13API() ? Material.COBWEB : Material.valueOf("WEB");

static {
Expand Down
Expand Up @@ -35,7 +35,7 @@ public float h(VectorNode from) {

@Override
public boolean isFinished(VectorNode node) {
double distanceSquared = node.getVector().distanceSquared(goal);
double distanceSquared = node.location.distanceSquared(goal);
return goal.equals(node.location) || distanceSquared <= leeway;
}
}

0 comments on commit 943714b

Please sign in to comment.