Skip to content

Fixed issue #22 - #42

Merged
ponuing merged 1 commit into
ponuing:26.2from
N-Echelibe:26.2
Aug 5, 2026
Merged

Fixed issue #22#42
ponuing merged 1 commit into
ponuing:26.2from
N-Echelibe:26.2

Conversation

@N-Echelibe

Copy link
Copy Markdown

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.

…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
N-Echelibe marked this pull request as ready for review August 4, 2026 19:22
@ponuing

ponuing commented Aug 5, 2026

Copy link
Copy Markdown
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.

@ponuing
ponuing merged commit b831a90 into ponuing:26.2 Aug 5, 2026
2 checks passed
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