Repository navigation
Tell Companion what the game plays and its packs on events, not by polling - #86
Conversation
…lling What the game plays is told when the player joins (LoggingIn) or leaves (LoggingOut); the packs when a client resource reload applies, when the server's tags arrive after a data reload, when the pack screen closes, and after each reload or pack selection Companion asks for. Nothing is sampled once a second any more: a rejoin is a change by construction, the capture cannot land mid-teardown, and Companion hears a change in the same tick. - The rolled-back reload is detected as the recovery reload applies, from the reload listener, instead of on ticks. - ChangePublisher goes: PLAYING is one field of TotalDebugClient, and the pack stack keeps its own last-told value. - PLAYING drops the LAN flag and the permission level, which nothing read; the server answers permission questions itself. Protocol 34. - Join, leave, reload, tag and pack-screen events live together in ClientLifecycleEvents. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8efe240227
ℹ️ 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".
| /** Tells Companion what the game plays, then the packs, which Companion reads for what it plays. Client thread only. */ | ||
| private void tellPlaying() { | ||
| this.companionApp.sendPlaying(new PlayingMessage(this.playing)); | ||
| this.packStacks.republish(); |
There was a problem hiding this comment.
Defer the pack republish until the integrated server is gone
When leaving a singleplayer world, LoggingOut runs before the integrated server is torn down, so this immediate republish captures and sends the departed world's datapacks immediately after sending Menu. Companion associates that stack with the menu, and PackResources.data treats any non-null stack as authoritative, leaving the old world's data resources visible indefinitely because no event republishes after server shutdown. Suppress datapacks when publishing the menu or defer this republish until the integrated server is gone.
AGENTS.md reference: AGENTS.md:L7-L7
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not reproducible on 1.21.1: Minecraft.disconnect sets this.singleplayerServer = null and only then calls ClientHooks.firePlayerLogout (the only LoggingOut site). So when left() republishes, getSingleplayerServer() is already null and the stack carries no datapacks. The same holds while disconnect waits for the server to stop. I added a comment on left() that names this ordering.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
What
The game no longer checks once a second what it plays and which packs are enabled. It tells Companion when the game's own events change them:
PLAYINGLoggingIn(the level and player exist) /LoggingOut(before teardown)/reload,/datapack, Companion's own)PLAYINGchanges, and when Companion connectsWhy it's better
ResourceReloads.tickis gone. A rolled-back reload is failed when the recovery reload reaches the reload listener.Cleanup
ChangePublisherand its test are removed.PLAYINGis one field ofTotalDebugClient, andPackStackPublisherkeeps its own last-told value.PLAYINGdrops the LAN flag (an opened world is the same world) and the permission level (nothing read it; the server answers permission questions, asSERVER_SCRIPTSdoes). Protocol 34.ClientLifecycleEvents.ClientTickTaskEventsonly drains tick tasks.GAME_LOCATION.mdgains the event table;MOD_SIDES.mdandRESOURCE_EDITING.mdno longer describe polling or the permission level.Not covered
A proxy that moves the player to another backend (reconfiguration) fires no
LoggingOut, only a newLoggingIn.PLAYINGthen changes only if the backend's TotalDebug channel differs. Before, the poll noticed this only by chance.Tests
:protocol:testpasses (68).:mod:testpasses (208).PLAYINGpass: GameState, ConfigChanges, PackSelections, ResourceEdits, ConfigPanel, CompanionReconnect and ApplicationNavigation (107)./datapack disable;🤖 Generated with Claude Code