diff options
3 files changed, 27 insertions, 12 deletions
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/AStarCornerCut.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/AStarCornerCut.java index d0fc9a16..2d060fbc 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/AStarCornerCut.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/AStarCornerCut.java @@ -114,16 +114,21 @@ public class AStarCornerCut implements IPathfinder { @Override public void setTarget(Vec3 from) { - if (lastSx != (int)Math.round(from.xCoord * 2) || lastSy != (int)Math.round(from.yCoord*2) || lastSz != (int)Math.round(from.zCoord * 2)) { + int tobeX = (int) Math.round(from.xCoord * 2); + int tobeY = (int) Math.round(from.zCoord * 2); + int tobeZ = (int) Math.round(from.yCoord * 2); + if (lastSx != tobeX || lastSy != tobeY || lastSz != tobeZ) { } else { return; } + if (dungeonRoom.isBlocked(tobeX, tobeY, tobeZ)) return; + + this.lastSx = tobeX; + this.lastSz = tobeY; + this.lastSy = tobeZ; open.clear(); pfindIdx++; found = false; - this.lastSx = (int) Math.round(from.xCoord * 2); - this.lastSy = (int) Math.round(from.yCoord * 2); - this.lastSz = (int) Math.round(from.zCoord * 2); goalNode = openNode(lastSx, lastSy, lastSz); diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/AStarFineGrid.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/AStarFineGrid.java index e3b73d52..9980a7c7 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/AStarFineGrid.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/AStarFineGrid.java @@ -111,16 +111,21 @@ public class AStarFineGrid implements IPathfinder { @Override public void setTarget(Vec3 from) { - if (lastSx != (int)Math.round(from.xCoord * 2) || lastSy != (int)Math.round(from.yCoord*2) || lastSz != (int)Math.round(from.zCoord * 2)) { + int tobeX = (int) Math.round(from.xCoord * 2); + int tobeY = (int) Math.round(from.zCoord * 2); + int tobeZ = (int) Math.round(from.yCoord * 2); + if (lastSx != tobeX || lastSy != tobeY || lastSz != tobeZ) { } else { return; } + if (dungeonRoom.isBlocked(tobeX, tobeY, tobeZ)) return; + + this.lastSx = tobeX; + this.lastSz = tobeY; + this.lastSy = tobeZ; open.clear(); pfindIdx++; found = false; - this.lastSx = (int) Math.round(from.xCoord * 2); - this.lastSy = (int) Math.round(from.yCoord * 2); - this.lastSz = (int) Math.round(from.zCoord * 2); goalNode = openNode(lastSx, lastSy, lastSz); diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/ThetaStar.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/ThetaStar.java index ce7ffcc8..9365485a 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/ThetaStar.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/algorithms/ThetaStar.java @@ -124,16 +124,21 @@ public class ThetaStar implements IPathfinder { @Override public void setTarget(Vec3 from) { - if (lastSx != (int)Math.round(from.xCoord * 2) || lastSy != (int)Math.round(from.yCoord*2) || lastSz != (int)Math.round(from.zCoord * 2)) { + int tobeX = (int) Math.round(from.xCoord * 2); + int tobeY = (int) Math.round(from.zCoord * 2); + int tobeZ = (int) Math.round(from.yCoord * 2); + if (lastSx != tobeX || lastSy != tobeY || lastSz != tobeZ) { } else { return; } + if (dungeonRoom.isBlocked(tobeX, tobeY, tobeZ)) return; + + this.lastSx = tobeX; + this.lastSz = tobeY; + this.lastSy = tobeZ; open.clear(); pfindIdx++; found = false; - this.lastSx = (int) Math.round(from.xCoord * 2); - this.lastSy = (int) Math.round(from.yCoord * 2); - this.lastSz = (int) Math.round(from.zCoord * 2); goalNode = openNode(lastSx, lastSy, lastSz); |