fix A* and scanner for data driven world height
This commit is contained in:
@@ -122,11 +122,12 @@ public final class ChunkPacker {
|
||||
if (MovementHelper.possiblyFlowing(state)) {
|
||||
return PathingBlockType.AVOID;
|
||||
}
|
||||
int adjY = y - chunk.getLevel().dimensionType().minY();
|
||||
if (
|
||||
(x != 15 && MovementHelper.possiblyFlowing(getFromChunk(chunk, x + 1, y, z)))
|
||||
|| (x != 0 && MovementHelper.possiblyFlowing(getFromChunk(chunk, x - 1, y, z)))
|
||||
|| (z != 15 && MovementHelper.possiblyFlowing(getFromChunk(chunk, x, y, z + 1)))
|
||||
|| (z != 0 && MovementHelper.possiblyFlowing(getFromChunk(chunk, x, y, z - 1)))
|
||||
(x != 15 && MovementHelper.possiblyFlowing(getFromChunk(chunk, x + 1, adjY, z)))
|
||||
|| (x != 0 && MovementHelper.possiblyFlowing(getFromChunk(chunk, x - 1, adjY, z)))
|
||||
|| (z != 15 && MovementHelper.possiblyFlowing(getFromChunk(chunk, x, adjY, z + 1)))
|
||||
|| (z != 0 && MovementHelper.possiblyFlowing(getFromChunk(chunk, x, adjY, z - 1)))
|
||||
) {
|
||||
return PathingBlockType.AVOID;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ public final class AStarPathFinder extends AbstractNodeCostSearch {
|
||||
|
||||
@Override
|
||||
protected Optional<IPath> calculate0(long primaryTimeout, long failureTimeout) {
|
||||
int minY = calcContext.world.dimensionType().minY();
|
||||
int height = calcContext.world.dimensionType().height();
|
||||
startNode = getNodeAtPosition(startX, startY, startZ, BetterBlockPos.longHash(startX, startY, startZ));
|
||||
startNode.cost = 0;
|
||||
startNode.combinedCost = startNode.estimatedCostToGoal;
|
||||
@@ -80,9 +82,9 @@ public final class AStarPathFinder extends AbstractNodeCostSearch {
|
||||
while (!openSet.isEmpty() && numEmptyChunk < pathingMaxChunkBorderFetch && !cancelRequested) {
|
||||
if ((numNodes & (timeCheckInterval - 1)) == 0) { // only call this once every 64 nodes (about half a millisecond)
|
||||
long now = System.currentTimeMillis(); // since nanoTime is slow on windows (takes many microseconds)
|
||||
if (now - failureTimeoutTime >= 0 || (!failing && now - primaryTimeoutTime >= 0)) {
|
||||
break;
|
||||
}
|
||||
// if (now - failureTimeoutTime >= 0 || (!failing && now - primaryTimeoutTime >= 0)) {
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
if (slowPath) {
|
||||
try {
|
||||
@@ -109,7 +111,7 @@ public final class AStarPathFinder extends AbstractNodeCostSearch {
|
||||
if (!moves.dynamicXZ && !worldBorder.entirelyContains(newX, newZ)) {
|
||||
continue;
|
||||
}
|
||||
if (currentNode.y + moves.yOffset > 256 || currentNode.y + moves.yOffset < 0) {
|
||||
if (currentNode.y + moves.yOffset > height || currentNode.y + moves.yOffset < 0) {
|
||||
continue;
|
||||
}
|
||||
res.reset();
|
||||
|
||||
@@ -97,9 +97,9 @@ public class BlockStateInterface {
|
||||
}
|
||||
|
||||
public BlockState get0(int x, int y, int z) { // Mickey resigned
|
||||
|
||||
y -= worldData.dimension.minY();
|
||||
// Invalid vertical position
|
||||
if (y < 0 || y >= 256) {
|
||||
if (y < 0 || y >= worldData.dimension.height()) {
|
||||
return AIR;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user