Skip to content

Commit

Permalink
Clone vectors during pathfinding
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Nov 13, 2020
1 parent 67e6d4d commit 678ac65
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Expand Up @@ -29,7 +29,11 @@ public List<PathPoint> getNeighbours(BlockSource source, PathPoint point) {
for (int z = -1; z <= 1; z++) {
if (x == 0 && y == 0 && z == 0)
continue;
neighbours.add(point.createAtOffset(point.getVector().add(new Vector(x, y, z))));
Vector mod = point.getVector().clone().add(new Vector(x, y, z));
if (mod.getY() < 0 || mod.getY() > 255 || mod.equals(point.getVector())) {
continue;
}
neighbours.add(point.createAtOffset(mod));
}
}
}
Expand Down
Expand Up @@ -24,7 +24,7 @@ public VectorNode(VectorGoal goal, Location location, BlockSource source, BlockE

public VectorNode(VectorNode parent, Vector location, PathInfo info) {
super(parent);
this.location = location.setX(location.getBlockX()).setY(location.getBlockY()).setZ(location.getBlockZ());
this.location = new Vector(location.getBlockX(), location.getBlockY(), location.getBlockZ());
this.info = info;
}

Expand Down

0 comments on commit 678ac65

Please sign in to comment.