From d22a52976b2988a0daa7ec8324de32ab2c095d0c Mon Sep 17 00:00:00 2001 From: wagyourtail Date: Sat, 9 Oct 2021 14:54:07 -0600 Subject: [PATCH] fix A* and scanner for data driven world height --- src/main/java/baritone/cache/ChunkPacker.java | 9 +++++---- .../java/baritone/pathing/calc/AStarPathFinder.java | 10 ++++++---- src/main/java/baritone/utils/BlockStateInterface.java | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index cd15e4ed7..0f3c11749 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -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; } diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index 3e38ff41d..9e3d1f153 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -49,6 +49,8 @@ public final class AStarPathFinder extends AbstractNodeCostSearch { @Override protected Optional 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(); diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index c37d898ef..c615ff4e1 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -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; }