Properly fix invalid block entities being created #10768
Closed
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.
Fixes #10750
Replaces #10375 which fixed #10022
This fixes the invalid block entities, not by removing them which the original fix did. that causes data loss as evidenced by the new issue this fixes relating to loot tables disappearing. The correct fix is to not mutate the WorldGenRegion's ProtoChunks when calling
BlockGetter#getBlockEntity
. Vanilla, if calling getBlockEntity on a block which doesn't have one and has a BlockState that should have one, cretes a BlockEntity and inserts it into the map (the mutation). Then if the block is later changed, the block entity and blockstate might not match. This isn't an issue in vanilla, because getBlockEntity is only caused in very specific places, but the BLockTransformer system was making it be called for every block in order to create a BlockState for the API. The fix is to just get a block entity as well as a "saving callback" in order to write the block entity back to the correct map to save changes to it.Some testing around on worlds being generated would be appreciated so as to ensure there isn't any new data loss issue that was created.
Download the paperclip jar for this pull request: paper-10768.zip