Skip to content

moving piston block entities are missing progressO read, causing desyncs and dupes#13774

Open
Uhuli wants to merge 1 commit intoPaperMC:mainfrom
Uhuli:fix/flying-machine-desync
Open

moving piston block entities are missing progressO read, causing desyncs and dupes#13774
Uhuli wants to merge 1 commit intoPaperMC:mainfrom
Uhuli:fix/flying-machine-desync

Conversation

@Uhuli
Copy link
Copy Markdown
Contributor

@Uhuli Uhuli commented Apr 11, 2026

Fixes #9220

Since the class net.minecraft.world.level.block.piston.PistonMovingBlockEntity is 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 that saveAdditional only persists progressO (previous-tick progress) but not progress (current-tick progress):

output.putFloat("progress", this.progressO);

On load, both fields are set to the same value:

this.progress = input.getFloatOr("progress", 0.0F);
this.progressO = this.progress;

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.progress in the existing progress field, flying machines always strictly cut off at the chunk border:

Image

Proposed fix

Save both values independently:

saveAdditional:

output.putFloat("progress", this.progressO);
output.putFloat("progressCurrent", this.progress);

loadAdditional:

this.progressO = input.getFloatOr("progress", 0.0F);
this.progress = input.getFloatOr("progressCurrent", this.progressO);

This preserves backward compatibility - old saves without progressCurrent fall back to progressO. 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.

@Uhuli Uhuli requested a review from a team as a code owner April 11, 2026 15:33
@github-project-automation github-project-automation bot moved this to Awaiting review in Paper PR Queue Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Awaiting review

Development

Successfully merging this pull request may close these issues.

Flying machines are destroyed after a restart

1 participant