claude/entity-despawn-prevention-4gAps#7
Merged
Conversation
Worker entities were freezing/disappearing when the player moved beyond simulation distance because their chunks unloaded. This adds chunk force-loading tied to each worker block's lifecycle: - WorkerChunkManager (SavedData) tracks reference counts per chunk; setChunkForced is called only on first claim and last release, so multiple workers in the same chunk are handled correctly. - GameEventSubscriber listens for ChunkEvent.Load to auto-claim chunks for worker blocks that existed before this update (migration path). - All four block types (Farmer, Miner, Lumberjack, Warehouse) claim their chunk on onPlace and release it on onRemove. - All four entity types call setPersistenceRequired() as an additional guard against any edge-case natural despawning. https://claude.ai/code/session_016MRtBVQWg7kfgJFtG8dCEM
In 1.21 the SavedData abstract method signature changed to save(CompoundTag, HolderLookup.Provider) and the Factory deserializer expects BiFunction<CompoundTag, HolderLookup.Provider, T>. Updated save and load accordingly, and used explicit SavedData.Factory<> type to resolve diamond-inference failure. https://claude.ai/code/session_016MRtBVQWg7kfgJFtG8dCEM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Forces workers to load the chunk they are in to prevent despawning.