Feat/restore tracked players and entities - #416
Conversation
…ayers - implement restoreAllTrackedEntities method to re-establish entity tracking - implement restoreAllTrackedPlayers method to re-establish player tracking
|
This PR contains changes that modified the public API. To update the reference ABI dumps: ./gradlew updateKotlinAbi
git add **/api/**
git commit -m "Update ABI reference"
git pushAfter updating, the CI will pass. Make sure the changes are backward compatible. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 62e321fc3f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (tracker in trackers) { | ||
| try { | ||
| if (tracker.seenBy.remove(connection)) { | ||
| tracker.serverEntity.removePairing(nmsPlayer) |
There was a problem hiding this comment.
Avoid removing the pairing twice during restore
When this restore follows the matching remove operation, removeAllTrackedEntities has already called removePairing while deliberately retaining seenBy. Calling it again here causes Entity.stopSeenByPlayer—and therefore Paper's PlayerUntrackEntityEvent—to run a second time before Moonrise later adds the pairing again. Plugins maintaining per-viewer tracking state consequently receive two untrack notifications for one hidden interval; removing the connection from seenBy is sufficient to trigger the later pairing. The same duplicated call exists in restoreAllTrackedPlayers and both other version bridges.
Useful? React with 👍 / 👎.
| val trackers = level.chunkSource.chunkMap.entityMap.values.toTypedArray() | ||
| for (tracker in trackers) { | ||
| try { | ||
| if (tracker.seenBy.remove(connection)) { |
There was a problem hiding this comment.
Keep tracker mutations on their owning Folia regions
On Folia, calling this from the player's entity dispatcher does not make the current thread the owner of every entity in the world's entityMap. The map is an Int2ObjectOpenHashMap, and each tracker's seenBy is a non-concurrent ReferenceOpenHashSet that Moonrise mutates from that entity's region tick; snapshotting all trackers and removing from those sets here can therefore race entity addition/removal or the tracker tick when a visible entity belongs to another region. This repository explicitly advertises Folia support, so these mutations need to be dispatched to each tracked entity's owning region or the operation must be rejected in that environment; the same loop is present in the other two version bridges.
Useful? React with 👍 / 👎.
No description provided.