Fixed issue #22 - #42
Merged
Merged
Conversation
…components - Prefer `connection.registryAccess()` over `level.registryAccess()` in `Storage` to match multiplayer network registries. - Wrap `DataComponentPatch.CODEC` with `SAFE_COMPONENT_PATCH_CODEC` in `ModCodecs` to catch unresolvable registry errors (e.g., server enchantments/trims) and fall back to empty component patches instead of failing the entire memory bank file save. Fixes issue ponuing#22
N-Echelibe
marked this pull request as ready for review
August 4, 2026 19:22
Owner
|
Looking at code, it should theoretically fix this problem, but unfortunately, it is not very possible to check how much it fixes in practice, because I was practically unable to recreate the crash. In general, in the worst case, it will not save only part of the memory bank, but not the entire one. |
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.
When opening chests with enchanted items or armor trims, serializing DataComponentPatch was failing if a component referenced a registry key not bound in the fallback registry ops (e.g. Can't access registry minecraft:enchantment). Because encoding failed for even a single item, FileUtil.saveToNbt threw an exception and aborted the save for the entire memory bank file.
To fix this, I updated Storage.java to prefer connection.registryAccess() when on a server so registry lookups match the active network session. I also added a SAFE_COMPONENT_PATCH_CODEC wrapper in ModCodecs.java so if an individual item component fails to encode due to an unresolvable registry reference, it logs a warning and falls back to an empty patch for that stack instead of crashing the entire save.