Upload files to "/"
This commit is contained in:
@@ -19,7 +19,8 @@ public class AStarPathfinder {
|
||||
};
|
||||
private static final double SQRT2 = 1.41421356;
|
||||
|
||||
public static List<BlockPos> find(ClientWorld world, BlockPos start, BlockPos goal, boolean flying) {
|
||||
|
||||
public static List<BlockPos> find(ClientWorld world, BlockPos start, BlockPos goal, boolean flying, java.util.Set<BlockPos> blacklistedNodes) {
|
||||
PriorityQueue<PathNode> open = new PriorityQueue<>();
|
||||
Map<BlockPos, Double> gScore = new HashMap<>();
|
||||
|
||||
@@ -36,7 +37,7 @@ public class AStarPathfinder {
|
||||
return smooth(world, raw, flying);
|
||||
}
|
||||
|
||||
for (PathNode nb : neighbours(world, current, goal, flying)) {
|
||||
for (PathNode nb : neighbours(world, current, goal, flying, blacklistedNodes)) {
|
||||
double existing = gScore.getOrDefault(nb.pos, Double.MAX_VALUE);
|
||||
if (nb.g < existing) {
|
||||
gScore.put(nb.pos, nb.g);
|
||||
@@ -120,16 +121,15 @@ public class AStarPathfinder {
|
||||
int steps = Math.max(dx, Math.max(dy, dz));
|
||||
|
||||
for (int i = 0; i < steps; i++) {
|
||||
BlockPos pos = new BlockPos(cx, cy, cz);
|
||||
// Sprawdź czy gracz (2 bloki wysokości) przejdzie
|
||||
if (!isPassable(world, pos) || !isPassable(world, pos.up())) return false;
|
||||
if (!isPassable(world, new BlockPos(cx, cy, cz))) return false;
|
||||
if (!isPassable(world, new BlockPos(cx, cy + 1, cz))) return false;
|
||||
|
||||
int e2XY = 2 * errXY;
|
||||
int e2XZ = 2 * errXZ;
|
||||
|
||||
if (e2XY > -dy) { errXY -= dy; cx += sx; }
|
||||
if (e2XY < dx) { errXY += dx; cy += sy; }
|
||||
if (e2XZ > -dz) { errXZ -= dz; }
|
||||
if (e2XZ > -dz) { errXZ -= dz; cx += sx; }
|
||||
if (e2XZ < dx) { errXZ += dx; cz += sz; }
|
||||
}
|
||||
return true;
|
||||
@@ -160,9 +160,10 @@ public class AStarPathfinder {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static List<PathNode> neighbours(ClientWorld world, PathNode current, BlockPos goal, boolean flying) {
|
||||
private static List<PathNode> neighbours(ClientWorld world, PathNode current, BlockPos goal, boolean flying, java.util.Set<BlockPos> blacklist) {
|
||||
List<PathNode> result = new ArrayList<>();
|
||||
BlockPos pos = current.pos;
|
||||
if (blacklist.contains(pos)) return result;
|
||||
|
||||
if (flying) {
|
||||
// ── Tryb lotu — ruch we wszystkich 26 kierunkach ──────────────────
|
||||
|
||||
Reference in New Issue
Block a user