Repository navigation
Fix labels not being saved in singleplayer - #1784
Merged
Merged
Conversation
The integrated server used the client's copy of the labels, as the client copy was chosen for the physical client side instead of its thread, so labels never reached the saved data and were gone after leaving the world. Only the client thread now uses its copy. Labels are sent on login from the storage access instead of from every storage instance, as those were registered for each opened world, and the client copy, so stale labels were sent as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MHtucHo4Qy2pTfBMgeE54y
rubensworks
commented
Nov 9, 2026
…d/LabelsWorldStorage.java
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.
Labels set with the Labeller were never saved in singleplayer on 26.1. They disappeared when leaving the world, and
#labelreferences in expressions stopped resolving. Found while testing #1783.Cause
LabelsWorldStorage.Access#get()returned a client-only copy wheneverMinecraftHelpers#isClientSide()was true. That checks the physical side (FMLEnvironment.getDist() == Dist.CLIENT), so it is also true for the integrated server. In singleplayer, the server put labels into the client copy, and the saved data stayed empty.labels.datkept an empty list. Dedicated servers were not affected.LabelsWorldStorageregistered itself on the event bus and sent its labels to a player on login. That included the client copy and the storages of every world opened earlier in the session. With only the first part fixed, the server's list still happened to arrive last, but only because of registration order.Fix
get()returns the client copy unless the current thread is the integrated server's (ServerLifecycleHooks.getCurrentServer().isSameThread()). I didn't useisClientSideThread(), because that is false on the render thread while no level is loaded, and the getter would then fall through to the server storage with a null server.Access, which sends the labels of the server's storage. Storage instances no longer register on the event bus.Is this on 1.21?
No. On
master-1.21-lts,LabelsWorldStorageis a singleWorldStorageinstance shared by client and server. It is saved through@NBTPersiston server stop and world save, and its data holder is always dirty. The client-only copy was introduced in the 26.1 port, so this PR targetsmaster-26-lts.Testing
./gradlew build: all 1057 unit tests pass../gradlew runGameTestServer: all 1096 game tests pass. The game test server is a dedicated server, so it never reached the broken branch.5(id 0) and labelled itfivewith the Labeller.labels.datnow holds0 -> five; before the fix, it stayed empty in the same scenario.five.#five + 1resolves in the Logic Programmer's expression panel, typed Integer.Generated by Claude Code