-
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1.20.5] Record a BlockSnapshot for client break predictions and clea…
…nup break pipeline (#809)
- Loading branch information
1 parent
36c0cb2
commit d61ba73
Showing
9 changed files
with
238 additions
and
160 deletions.
There are no files selected for viewing
This file contains 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
8 changes: 0 additions & 8 deletions
8
patches/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch
This file contains 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
39 changes: 39 additions & 0 deletions
39
patches/net/minecraft/client/multiplayer/prediction/BlockStatePredictionHandler.java.patch
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- a/net/minecraft/client/multiplayer/prediction/BlockStatePredictionHandler.java | ||
+++ b/net/minecraft/client/multiplayer/prediction/BlockStatePredictionHandler.java | ||
@@ -49,6 +_,15 @@ | ||
p_233858_.syncBlockState( | ||
blockpos, blockstatepredictionhandler$serververifiedstate.blockState, blockstatepredictionhandler$serververifiedstate.playerPos | ||
); | ||
+ // Neo: Restore the BlockEntity if one was present before the break was cancelled. | ||
+ // Fixes MC-36093 and permits correct server-side only cancellation of block changes. | ||
+ var verifiedState = blockstatepredictionhandler$serververifiedstate; | ||
+ if (verifiedState.snapshot != null && verifiedState.blockState == verifiedState.snapshot.getState()) { | ||
+ if (verifiedState.snapshot.restoreBlockEntity(p_233858_, blockpos)) { | ||
+ // Attempt a re-render if BE data was loaded, since some blocks may depend on it. | ||
+ p_233858_.sendBlockUpdated(blockpos, verifiedState.blockState, verifiedState.blockState, 3); | ||
+ } | ||
+ } | ||
} | ||
} | ||
} | ||
@@ -72,8 +_,20 @@ | ||
return this.isPredicting; | ||
} | ||
|
||
+ /** | ||
+ * Sets the stored BlockSnapshot on the ServerVerifiedState for the given position. | ||
+ * This method is only called after {@link #retainKnownServerState}, so we are certain a map entry exists. | ||
+ */ | ||
+ public void retainSnapshot(BlockPos pos, net.neoforged.neoforge.common.util.BlockSnapshot snapshot) { | ||
+ this.serverVerifiedStates.get(pos.asLong()).snapshot = snapshot; | ||
+ } | ||
+ | ||
@OnlyIn(Dist.CLIENT) | ||
static class ServerVerifiedState { | ||
+ /** | ||
+ * Neo: Used to hold all data necessary for clientside restoration during break denial. | ||
+ */ | ||
+ net.neoforged.neoforge.common.util.BlockSnapshot snapshot; | ||
final Vec3 playerPos; | ||
int sequence; | ||
BlockState blockState; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.