Skip to content

Feat/restore tracked players and entities - #416

Merged
twisti-dev merged 3 commits into
version/26.2from
feat/restore-tracked-players-and-entities
Aug 26, 2026
Merged

Feat/restore tracked players and entities#416
twisti-dev merged 3 commits into
version/26.2from
feat/restore-tracked-players-and-entities

Conversation

@twisti-dev

Copy link
Copy Markdown
Contributor

No description provided.

…ayers

- implement restoreAllTrackedEntities method to re-establish entity tracking
- implement restoreAllTrackedPlayers method to re-establish player tracking
@twisti-dev twisti-dev self-assigned this Aug 26, 2026
Copilot AI lite review requested due to automatic review settings August 26, 2026 18:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@twisti-dev
twisti-dev merged commit 0c1c865 into version/26.2 Aug 26, 2026
7 checks passed
@twisti-dev
twisti-dev deleted the feat/restore-tracked-players-and-entities branch August 26, 2026 18:54
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ API/ABI changes detected!

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 push

After updating, the CI will pass. Make sure the changes are backward compatible.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +102 to +105
val trackers = level.chunkSource.chunkMap.entityMap.values.toTypedArray()
for (tracker in trackers) {
try {
if (tracker.seenBy.remove(connection)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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