Skip to content

Fix a few small bugs in the cache, explore filter and goals - #5157

Open
Elpo55 wants to merge 5 commits into
cabaletta:1.21.4from
Elpo55:fix/small-fixes
Open

Elpo55 wants to merge 5 commits into
cabaletta:1.21.4from
Elpo55:fix/small-fixes

Conversation

@Elpo55

@Elpo55 Elpo55 commented Oct 27, 2026

Copy link
Copy Markdown

Five small bugs, one commit each. None of them is meant to change how Baritone behaves in game.

  • GoalRunAway.heuristic(): maxX/maxY/maxZ were computed from minX/minY/minZ instead of from themselves, so with several positions the box only covered the last one. Baritone itself only ever builds a GoalRunAway with a single position (mine and get to block), where the old code happened to give the same box, so this only matters for API users.
  • GoalAxis.equals(null) threw an NPE instead of returning false.
  • CachedWorld.prune(): distX * distX + distZ * distZ was done in int and overflows once a region is ~46k blocks from the player. The result could be negative (sqrt gives NaN) or small, so far away regions could stay in RAM.
  • CachedWorld.PackerThread: toPackMap has soft values, so remove(pos) can return null once the chunk has been collected, and ChunkPacker.pack(null) then threw an NPE that got printed to the log. These are now skipped.
  • ExploreProcess.JsonChunkFilter never closed the reader for the #explorefilter file, which keeps the file locked on Windows until the next GC.

Compiled and ran the existing unit tests with these changes applied.

maxX/maxY/maxZ were taken from minX/minY/minZ instead of themselves, so the box only covered the last position.
distX * distX overflows once a region is ~46k blocks from the player, so whether it got pruned was down to how the overflow happened to land.
toPackMap has soft values, so remove() can return null and ChunkPacker.pack(null) threw an NPE that got printed to the log.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant