Skip to content

fix(pathfinding): disable chunk column snapshot for async A*#11

Draft
Deathtanium wants to merge 3 commits into
masterfrom
cursor/pathfinding-chunk-caching-issue-89ab
Draft

fix(pathfinding): disable chunk column snapshot for async A*#11
Deathtanium wants to merge 3 commits into
masterfrom
cursor/pathfinding-chunk-caching-issue-89ab

Conversation

@Deathtanium
Copy link
Copy Markdown
Owner

@Deathtanium Deathtanium commented Mar 27, 2026

Summary

  1. Original fix: Async A* no longer called getChunk from worker threads (unsafe). Chunk snapshot was disabled for async.

  2. Follow-up (this update): Restore efficient column caching for async by building the snapshot on the server thread right before submitPathfinding, then passing it into calculatePath. Workers only follow WorldChunk references already resolved on the main thread—no redundant chunk-map work from the pool, without the previous threading hazard.

  • PathfindChunkCache.buildColumnSnapshot(world, mod)server thread only
  • PathfindChunkCache.liveWorldOnly(world) — fallback when no snapshot
  • calculatePath(..., @Nullable PathfindChunkCache prebuilt) plus overload without the last arg (null snapshot)

Verification

  • ./gradlew build
Open in Web Open in Cursor 

cursoragent and others added 3 commits March 27, 2026 07:57
PathfindChunkCache stored WorldChunk references and read block states from
pathfinder worker threads. Chunk column reads are not safe off the server
thread while the main thread mutates the world, which can stall or corrupt
async A*. Sync-batched jobs still snapshot columns on the server thread;
async calculatePath now uses live world.getBlockState only (pre-cache behavior).

Co-authored-by: Deathtanium <mishouro08@gmail.com>
…sync A*

PathfindChunkCache now exposes buildColumnSnapshot (main thread) and
liveWorldOnly. clamReach snapshots columns before queueing async work and
passes the cache into calculatePath so workers reuse WorldChunk refs without
getChunk. Adds calculatePath overload with optional prebuilt snapshot.

Co-authored-by: Deathtanium <mishouro08@gmail.com>
When false, async reach passes null to calculatePath so pathfinding uses
live ServerWorld#getBlockState only. Default true preserves column snapshot.

Co-authored-by: Deathtanium <mishouro08@gmail.com>
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.

2 participants