moving piston block entities are missing progressO read, causing desyncs and dupes#13774
Open
Uhuli wants to merge 1 commit intoPaperMC:mainfrom
Open
moving piston block entities are missing progressO read, causing desyncs and dupes#13774Uhuli wants to merge 1 commit intoPaperMC:mainfrom
Uhuli wants to merge 1 commit intoPaperMC:mainfrom
Conversation
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.
Fixes #9220
Since the class
net.minecraft.world.level.block.piston.PistonMovingBlockEntityis responsible for saving the moving blocks on a flying machine, I took a look there. As far as I could test and reproduce, the root cause is thatsaveAdditionalonly persistsprogressO(previous-tick progress) but notprogress(current-tick progress):On load, both fields are set to the same value:
This means up to half a tick of movement is lost every time a chunk unloads and reloads mid-extension. For flying machines crossing chunk boundaries, this causes the desync.
If you instead save just
this.progressin the existingprogressfield, flying machines always strictly cut off at the chunk border:Proposed fix
Save both values independently:
saveAdditional:loadAdditional:This preserves backward compatibility - old saves without
progressCurrentfall back toprogressO. With this change, the full piston state is restored correctly and the flying machine resumes from the exact position it was at when the chunk unloaded.