Skip to content

Avoid potentially unnecessary block acks#9699

Closed
pseudospace0 wants to merge 3 commits into
PaperMC:masterfrom
pseudospace0:Avoid-potentially-unnecessary-block-ack
Closed

Avoid potentially unnecessary block acks#9699
pseudospace0 wants to merge 3 commits into
PaperMC:masterfrom
pseudospace0:Avoid-potentially-unnecessary-block-ack

Conversation

@pseudospace0
Copy link
Copy Markdown

Avoids block change acks for blocks which are potentially out of a players reach.

@pseudospace0 pseudospace0 requested a review from a team as a code owner September 9, 2023 21:28
@Owen1212055
Copy link
Copy Markdown
Member

Owen1212055 commented Sep 10, 2023

Can you please further explain your change here? This part of the code is rather sensitive, and would appreciate why exactly you are making this change here.

Since, you are eliminating two places where the block ack occurs. But it doesn't really make sense why these acks should be cancelled, as if the client does introduce something like this (which may be due to a desync) it would make sense to do this ack to revert it clientside.

Additionally, this causes a bit of a desync as then the client is predicting this stage but an ack wasn't sent back, meaning next ack will also cause this prediction to be reverted. So.. not really sure what this is targeting.

Client Side Prediction:

this.startPrediction(this.minecraft.level, $$2 -> {
               this.destroyBlock($$0);
               return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, $$0, $$1, $$2);
            });

Vanilla server (always sends back ack):

case STOP_DESTROY_BLOCK:
            this.player.gameMode.handleBlockBreakAction($$1, $$2, $$0.getDirection(), this.player.level().getMaxBuildHeight(), $$0.getSequence());
            this.player.connection.ackBlockChangesUpTo($$0.getSequence());
            return;

Copy link
Copy Markdown
Member

@Owen1212055 Owen1212055 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, you are missing Paper comments.

@pseudospace0
Copy link
Copy Markdown
Author

Can you please further explain your change here? This part of the code is rather sensitive, and would appreciate why exactly you are making this change here.

Since, you are eliminating two places where the block ack occurs. But it doesn't really make sense why these acks should be cancelled, as if the client does introduce something like this (which may be due to a desync) it would make sense to do this ack to revert it clientside.

Additionally, this causes a bit of a desync as then the client is predicting this stage but an ack wasn't sent back, meaning next ack will also cause this prediction to be reverted. So.. not really sure what this is targeting.

Client Side Prediction:

this.startPrediction(this.minecraft.level, $$2 -> {
               this.destroyBlock($$0);
               return new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, $$0, $$1, $$2);
            });

Vanilla server (always sends back ack):

case STOP_DESTROY_BLOCK:
            this.player.gameMode.handleBlockBreakAction($$1, $$2, $$0.getDirection(), this.player.level().getMaxBuildHeight(), $$0.getSequence());
            this.player.connection.ackBlockChangesUpTo($$0.getSequence());
            return;

My thinking was that it didn't really seem necessary to acknowledge the player breaking a block which is out of their reach. If this prediction would be reverted by the next (within breaking range) ack from the server, wouldn't this be saving on a packet being sent?

@Owen1212055
Copy link
Copy Markdown
Member

Well, the issue is that it more leaves the client in a "still predicting" state even after the block break has finished.

@Owen1212055
Copy link
Copy Markdown
Member

Closing due to reasons mentioned above, and in general this leaves the client in an invalid still predicting... state.

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