fix block state mappings being replaced with random blocks - #690
Closed
derekcmoore wants to merge 1 commit into
Closed
derekcmoore wants to merge 1 commit into
derekcmoore wants to merge 1 commit into
Conversation
Author
|
Closed by a branch rename on my fork, reopened as #691 with the same change. |
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.
Every block state in an existing world fails to decode on 26.3, because the block state NBT keys were renamed:
StateHolder.NAME_TAG/PROPERTIES_TAGwent fromName/Propertiestoid/properties. The datafixer handles that rename correctly so vanilla blocks come back fine, but anything it cannot resolve, a block from a mod that is no longer installed being the usual case, decodes to air, andloadFromStoragethen hands that id a random block state and force-resaves it. The original is gone from disk and reinstalling the mod does not bring it back. I think this is at least part of theCORRUPTS OLD WORLDSmarker in 2c5698e, it is the piece I could reproduce.Entries that cannot be decoded now keep their id but map to nothing and are never written back, so the stored bytes survive and the block returns on its own once it can be resolved again. Dropping that path also drops the
block2stateEntry.put(...)inside it, which was overwriting a real entry's state to id mapping whenever the random pick collided with one already in the map.Three smaller things in the same function:
serializerecordsdata_versionso the datafixer can start from the right point instead of a hardcoded0, it writes throughFULL_CODECbecauseBlockState.CODECon 26.3 collapses a default state down to a bare string and makes the shape on disk vary per state, and the datafixer call is wrapped since it throws rather than returning an error on a type it has no schema for, which is the same crash #670 is aimed at.Checked with a harness that writes a mapping store in the pre-26.3 format and loads it back through
Mapperon 26.3, usingsomemod:unobtainium_oreas a block whose mod is no longer installed.Before:
After:
stone,dirt,short_grass,oak_log[axis=y]andoak_stairs[facing=east,..]round trip to the right state either way. Loading the same store a second time resolves every id identically and leaves the unresolved entry untouched.